Rob Landley | 7e21d5f | 2006-04-27 23:34:46 +0000 | [diff] [blame] | 1 | #!/bin/sh |
2 | |||||
Denis Vlasenko | 7d219aa | 2006-10-05 10:17:08 +0000 | [diff] [blame] | 3 | target="$1" |
4 | loc="$2" | ||||
Rob Landley | 7e21d5f | 2006-04-27 23:34:46 +0000 | [diff] [blame] | 5 | |
Denis Vlasenko | 7d219aa | 2006-10-05 10:17:08 +0000 | [diff] [blame] | 6 | test "$target" || exit 1 |
Rob Landley | 7e21d5f | 2006-04-27 23:34:46 +0000 | [diff] [blame] | 7 | test "$loc" || loc=. |
Bernhard Reutner-Fischer | a1e130f | 2006-05-21 10:45:01 +0000 | [diff] [blame] | 8 | test -x "$loc/usage" || exit 1 |
Denis Vlasenko | 7d219aa | 2006-10-05 10:17:08 +0000 | [diff] [blame] | 9 | test "$SED" || SED=sed |
Bernhard Reutner-Fischer | b35e3a8 | 2009-10-27 17:05:31 +0100 | [diff] [blame] | 10 | test "$DD" || DD=dd |
Denis Vlasenko | 7d219aa | 2006-10-05 10:17:08 +0000 | [diff] [blame] | 11 | |
Denys Vlasenko | 0fdf2e1 | 2010-09-16 15:46:20 +0200 | [diff] [blame] | 12 | # Some people were bitten by their system lacking a (proper) od |
Denys Vlasenko | 195c436 | 2013-11-26 14:56:29 +0100 | [diff] [blame] | 13 | od -v -b </dev/null >/dev/null |
Denys Vlasenko | 06a80bd | 2010-09-16 13:23:15 +0200 | [diff] [blame] | 14 | if test $? != 0; then |
Denys Vlasenko | 195c436 | 2013-11-26 14:56:29 +0100 | [diff] [blame] | 15 | echo 'od tool is not installed or cannot accept "-v -b" options' |
Denys Vlasenko | 06a80bd | 2010-09-16 13:23:15 +0200 | [diff] [blame] | 16 | exit 1 |
17 | fi | ||||
18 | |||||
Denys Vlasenko | 08f0b78 | 2010-07-04 23:34:02 +0200 | [diff] [blame] | 19 | exec >"$target.$$" |
Rob Landley | 7e21d5f | 2006-04-27 23:34:46 +0000 | [diff] [blame] | 20 | |
Denys Vlasenko | 2f32bf8 | 2010-06-06 04:14:28 +0200 | [diff] [blame] | 21 | echo '#define UNPACKED_USAGE "" \' |
Denys Vlasenko | 195c436 | 2013-11-26 14:56:29 +0100 | [diff] [blame] | 22 | "$loc/usage" | od -v -b \ |
Denys Vlasenko | 0e5ba08 | 2010-06-05 23:11:07 +0200 | [diff] [blame] | 23 | | $SED -e 's/^[^ ]*//' \ |
24 | -e 's/ //g' \ | ||||
25 | -e '/^$/d' \ | ||||
Denys Vlasenko | 195c436 | 2013-11-26 14:56:29 +0100 | [diff] [blame] | 26 | -e 's/\(...\)/\\\1/g' \ |
Denys Vlasenko | 0e5ba08 | 2010-06-05 23:11:07 +0200 | [diff] [blame] | 27 | -e 's/^/"/' \ |
28 | -e 's/$/" \\/' | ||||
29 | echo '' | ||||
Denis Vlasenko | 937b10f | 2008-02-09 09:26:43 +0000 | [diff] [blame] | 30 | |
Denys Vlasenko | 0e5ba08 | 2010-06-05 23:11:07 +0200 | [diff] [blame] | 31 | echo '#define PACKED_USAGE \' |
Denis Vlasenko | 63e49fa | 2008-08-09 20:31:57 +0000 | [diff] [blame] | 32 | ## Breaks on big-endian systems! |
33 | ## # Extra effort to avoid using "od -t x1": -t is not available | ||||
34 | ## # in non-CONFIG_DESKTOPed busybox od | ||||
Denis Vlasenko | ea7c9b3 | 2008-09-25 10:39:10 +0000 | [diff] [blame] | 35 | ## |
Denis Vlasenko | 63e49fa | 2008-08-09 20:31:57 +0000 | [diff] [blame] | 36 | ## "$loc/usage" | bzip2 -1 | od -v -x \ |
37 | ## | $SED -e 's/^[^ ]*//' \ | ||||
Denys Vlasenko | 3581c62 | 2010-01-25 13:39:24 +0100 | [diff] [blame] | 38 | ## -e 's/ //g' \ |
39 | ## -e '/^$/d' \ | ||||
40 | ## -e 's/\(..\)\(..\)/0x\2,0x\1,/g' | ||||
Denys Vlasenko | 0e5ba08 | 2010-06-05 23:11:07 +0200 | [diff] [blame] | 41 | ## -e 's/$/ \\/' |
Denys Vlasenko | 195c436 | 2013-11-26 14:56:29 +0100 | [diff] [blame] | 42 | "$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -b \ |
Denis Vlasenko | 937b10f | 2008-02-09 09:26:43 +0000 | [diff] [blame] | 43 | | $SED -e 's/^[^ ]*//' \ |
Bernhard Reutner-Fischer | b35e3a8 | 2009-10-27 17:05:31 +0100 | [diff] [blame] | 44 | -e 's/ //g' \ |
45 | -e '/^$/d' \ | ||||
Denys Vlasenko | 195c436 | 2013-11-26 14:56:29 +0100 | [diff] [blame] | 46 | -e 's/\(...\)/0\1,/g' \ |
Denys Vlasenko | 0e5ba08 | 2010-06-05 23:11:07 +0200 | [diff] [blame] | 47 | -e 's/$/ \\/' |
48 | echo '' | ||||
Denys Vlasenko | 08f0b78 | 2010-07-04 23:34:02 +0200 | [diff] [blame] | 49 | |
Denys Vlasenko | 1d36f24 | 2010-07-08 02:29:47 +0200 | [diff] [blame] | 50 | mv -- "$target.$$" "$target" |