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