usage_compressed 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. target="$1"
  3. loc="$2"
  4. test "$target" || exit 1
  5. test "$loc" || loc=.
  6. test -x "$loc/usage" || exit 1
  7. test "$SED" || SED=sed
  8. test "$DD" || DD=dd
  9. # Some people were bitten by their system lacking a (proper) od
  10. od -v -t x1 </dev/null >/dev/null
  11. if test $? != 0; then
  12. echo 'od tool is not installed or cannot accept "-v -t x1" options'
  13. exit 1
  14. fi
  15. exec >"$target.$$"
  16. echo '#define UNPACKED_USAGE "" \'
  17. "$loc/usage" | od -v -t x1 \
  18. | $SED -e 's/^[^ ]*//' \
  19. -e 's/ //g' \
  20. -e '/^$/d' \
  21. -e 's/\(..\)/\\x\1/g' \
  22. -e 's/^/"/' \
  23. -e 's/$/" \\/'
  24. echo ''
  25. echo '#define PACKED_USAGE \'
  26. ## Breaks on big-endian systems!
  27. ## # Extra effort to avoid using "od -t x1": -t is not available
  28. ## # in non-CONFIG_DESKTOPed busybox od
  29. ##
  30. ## "$loc/usage" | bzip2 -1 | od -v -x \
  31. ## | $SED -e 's/^[^ ]*//' \
  32. ## -e 's/ //g' \
  33. ## -e '/^$/d' \
  34. ## -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
  35. ## -e 's/$/ \\/'
  36. "$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -t x1 \
  37. | $SED -e 's/^[^ ]*//' \
  38. -e 's/ //g' \
  39. -e '/^$/d' \
  40. -e 's/\(..\)/0x\1,/g' \
  41. -e 's/$/ \\/'
  42. echo ''
  43. mv -- "$target.$$" "$target"