applets/usage_compressed: combine many seds in one; hide dd stats
[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 sz=`"$loc/usage" | wc -c` || exit 1
13
14 exec >"$target"
15
16 echo 'static const char packed_usage[] ALIGN1 = {'
17
18 ## Breaks on big-endian systems!
19 ## # Extra effort to avoid using "od -t x1": -t is not available
20 ## # in non-CONFIG_DESKTOPed busybox od
21 ##
22 ## "$loc/usage" | bzip2 -1 | od -v -x \
23 ## | $SED -e 's/^[^ ]*//' \
24 ##      -e 's/ //g' \
25 ##      -e '/^$/d' \
26 ##      -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
27
28 "$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -t x1 \
29 | $SED -e 's/^[^ ]*//' \
30         -e 's/ //g' \
31         -e '/^$/d' \
32         -e 's/\(..\)/0x\1,/g'
33
34 echo '};'
35 echo '#define SIZEOF_usage_messages' `expr 0 + $sz`