blob: 9ddf16d389887b9cc0656c1567478e2efe50ec45 [file] [log] [blame]
Rob Landley7e21d5f2006-04-27 23:34:46 +00001#!/bin/sh
2
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00003target="$1"
4loc="$2"
Rob Landley7e21d5f2006-04-27 23:34:46 +00005
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00006test "$target" || exit 1
Rob Landley7e21d5f2006-04-27 23:34:46 +00007test "$loc" || loc=.
Bernhard Reutner-Fischera1e130f2006-05-21 10:45:01 +00008test -x "$loc/usage" || exit 1
Denis Vlasenko7d219aa2006-10-05 10:17:08 +00009test "$SED" || SED=sed
Bernhard Reutner-Fischerb35e3a82009-10-27 17:05:31 +010010test "$DD" || DD=dd
Denis Vlasenko7d219aa2006-10-05 10:17:08 +000011
Denys Vlasenko08f0b782010-07-04 23:34:02 +020012exec >"$target.$$"
Rob Landley7e21d5f2006-04-27 23:34:46 +000013
Denys Vlasenko2f32bf82010-06-06 04:14:28 +020014echo '#define UNPACKED_USAGE "" \'
Denys Vlasenko0e5ba082010-06-05 23:11:07 +020015"$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/$/" \\/'
22echo ''
Denis Vlasenko937b10f2008-02-09 09:26:43 +000023
Denys Vlasenko0e5ba082010-06-05 23:11:07 +020024echo '#define PACKED_USAGE \'
Denis Vlasenko63e49fa2008-08-09 20:31:57 +000025## 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 Vlasenkoea7c9b32008-09-25 10:39:10 +000028##
Denis Vlasenko63e49fa2008-08-09 20:31:57 +000029## "$loc/usage" | bzip2 -1 | od -v -x \
30## | $SED -e 's/^[^ ]*//' \
Denys Vlasenko3581c622010-01-25 13:39:24 +010031## -e 's/ //g' \
32## -e '/^$/d' \
33## -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
Denys Vlasenko0e5ba082010-06-05 23:11:07 +020034## -e 's/$/ \\/'
Bernhard Reutner-Fischerb35e3a82009-10-27 17:05:31 +010035"$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -t x1 \
Denis Vlasenko937b10f2008-02-09 09:26:43 +000036| $SED -e 's/^[^ ]*//' \
Bernhard Reutner-Fischerb35e3a82009-10-27 17:05:31 +010037 -e 's/ //g' \
38 -e '/^$/d' \
Denys Vlasenko0e5ba082010-06-05 23:11:07 +020039 -e 's/\(..\)/0x\1,/g' \
40 -e 's/$/ \\/'
41echo ''
Denys Vlasenko08f0b782010-07-04 23:34:02 +020042
43if cmp -s "$target.$$" "$target" 2>/dev/null; then
44 rm -- "$target.$$"
45else
46 mv -- "$target.$$" "$target"
47fi