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 | |
Denis Vlasenko | 7d219aa | 2006-10-05 10:17:08 +0000 | [diff] [blame] | 12 | exec >"$target" |
Rob Landley | 7e21d5f | 2006-04-27 23:34:46 +0000 | [diff] [blame] | 13 | |
Denys Vlasenko | 2f32bf8 | 2010-06-06 04:14:28 +0200 | [diff] [blame] | 14 | echo '#define UNPACKED_USAGE "" \' |
Denys Vlasenko | 0e5ba08 | 2010-06-05 23:11:07 +0200 | [diff] [blame] | 15 | "$loc/usage" | od -v -t x1 \ |
| 16 | | $SED -e 's/^[^ ]*//' \ |
| 17 | -e 's/ //g' \ |
| 18 | -e '/^$/d' \ |
| 19 | -e 's/\(..\)/\\x\1/g' \ |
| 20 | -e 's/^/"/' \ |
| 21 | -e 's/$/" \\/' |
| 22 | echo '' |
Denis Vlasenko | 937b10f | 2008-02-09 09:26:43 +0000 | [diff] [blame] | 23 | |
Denys Vlasenko | 0e5ba08 | 2010-06-05 23:11:07 +0200 | [diff] [blame] | 24 | echo '#define PACKED_USAGE \' |
Denis Vlasenko | 63e49fa | 2008-08-09 20:31:57 +0000 | [diff] [blame] | 25 | ## Breaks on big-endian systems! |
| 26 | ## # Extra effort to avoid using "od -t x1": -t is not available |
| 27 | ## # in non-CONFIG_DESKTOPed busybox od |
Denis Vlasenko | ea7c9b3 | 2008-09-25 10:39:10 +0000 | [diff] [blame] | 28 | ## |
Denis Vlasenko | 63e49fa | 2008-08-09 20:31:57 +0000 | [diff] [blame] | 29 | ## "$loc/usage" | bzip2 -1 | od -v -x \ |
| 30 | ## | $SED -e 's/^[^ ]*//' \ |
Denys Vlasenko | 3581c62 | 2010-01-25 13:39:24 +0100 | [diff] [blame] | 31 | ## -e 's/ //g' \ |
| 32 | ## -e '/^$/d' \ |
| 33 | ## -e 's/\(..\)\(..\)/0x\2,0x\1,/g' |
Denys Vlasenko | 0e5ba08 | 2010-06-05 23:11:07 +0200 | [diff] [blame] | 34 | ## -e 's/$/ \\/' |
Bernhard Reutner-Fischer | b35e3a8 | 2009-10-27 17:05:31 +0100 | [diff] [blame] | 35 | "$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -t x1 \ |
Denis Vlasenko | 937b10f | 2008-02-09 09:26:43 +0000 | [diff] [blame] | 36 | | $SED -e 's/^[^ ]*//' \ |
Bernhard Reutner-Fischer | b35e3a8 | 2009-10-27 17:05:31 +0100 | [diff] [blame] | 37 | -e 's/ //g' \ |
| 38 | -e '/^$/d' \ |
Denys Vlasenko | 0e5ba08 | 2010-06-05 23:11:07 +0200 | [diff] [blame] | 39 | -e 's/\(..\)/0x\1,/g' \ |
| 40 | -e 's/$/ \\/' |
| 41 | echo '' |