43794ff45d
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
67 lines
1.1 KiB
Bash
Executable File
67 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
target="$1"
|
|
loc="$2"
|
|
|
|
test "$target" || exit 1
|
|
test "$SED" || SED=sed
|
|
test "$DD" || DD=dd
|
|
|
|
# Some people were bitten by their system lacking a (proper) od
|
|
od -v -b </dev/null >/dev/null
|
|
if test $? != 0; then
|
|
echo 'od tool is not installed or cannot accept "-v -b" options'
|
|
exit 1
|
|
fi
|
|
|
|
exec >"$target.$$"
|
|
|
|
scripts=""
|
|
if [ -d "$loc" ]
|
|
then
|
|
scripts=$(cd $loc; ls * 2>/dev/null)
|
|
fi
|
|
|
|
n=$(echo $scripts | wc -w)
|
|
|
|
if [ $n -ne 0 ]
|
|
then
|
|
printf '#ifdef DEFINE_script_names\n'
|
|
printf 'const char script_names[] ALIGN1 = '
|
|
for i in $scripts
|
|
do
|
|
printf '"%s\\0"' $i
|
|
done
|
|
printf ';\n'
|
|
printf '#else\n'
|
|
printf 'extern const char script_names[] ALIGN1;\n'
|
|
printf '#endif\n'
|
|
fi
|
|
printf "#define NUM_SCRIPTS $n\n\n"
|
|
|
|
if [ $n -ne 0 ]
|
|
then
|
|
printf '#define UNPACKED_SCRIPTS_LENGTH '
|
|
for i in $scripts
|
|
do
|
|
cat $loc/$i
|
|
printf '\000'
|
|
done | wc -c
|
|
|
|
printf '#define PACKED_SCRIPTS \\\n'
|
|
for i in $scripts
|
|
do
|
|
cat $loc/$i
|
|
printf '\000'
|
|
done | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -b \
|
|
| grep -v '^ ' \
|
|
| $SED -e 's/^[^ ]*//' \
|
|
-e 's/ //g' \
|
|
-e '/^$/d' \
|
|
-e 's/\(...\)/0\1,/g' \
|
|
-e 's/$/ \\/'
|
|
printf '\n'
|
|
fi
|
|
|
|
mv -- "$target.$$" "$target"
|