bfd5aa8739f8d5bf65ad608f30998215e29958d6
[platform/upstream/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 exec >"$target"
13
14 echo '#define UNPACKED_USAGE "" \'
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 ''
23
24 echo '#define PACKED_USAGE \'
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
28 ##
29 ## "$loc/usage" | bzip2 -1 | od -v -x \
30 ## | $SED -e 's/^[^ ]*//' \
31 ##      -e 's/ //g' \
32 ##      -e '/^$/d' \
33 ##      -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
34 ##      -e 's/$/ \\/'
35 "$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -t x1 \
36 | $SED -e 's/^[^ ]*//' \
37         -e 's/ //g' \
38         -e '/^$/d' \
39         -e 's/\(..\)/0x\1,/g' \
40         -e 's/$/ \\/'
41 echo ''