aboutsummaryrefslogtreecommitdiff
path: root/shell/embedded_scripts
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xshell/embedded_scripts62
1 files changed, 62 insertions, 0 deletions
diff --git a/shell/embedded_scripts b/shell/embedded_scripts
new file mode 100755
index 000000000..0ca89b91e
--- /dev/null
+++ b/shell/embedded_scripts
@@ -0,0 +1,62 @@
1#!/bin/sh
2
3target="$1"
4loc="$2"
5
6test "$target" || exit 1
7test "$SED" || SED=sed
8test "$DD" || DD=dd
9
10# Some people were bitten by their system lacking a (proper) od
11od -v -b </dev/null >/dev/null
12if test $? != 0; then
13 echo 'od tool is not installed or cannot accept "-v -b" options'
14 exit 1
15fi
16
17exec >"$target.$$"
18
19scripts=""
20if [ -d "$loc" ]
21then
22 scripts=$(cd $loc; ls * 2>/dev/null)
23fi
24
25n=$(echo $scripts | wc -w)
26
27if [ $n -ne 0 ]
28then
29 printf 'static const char script_names[] ALIGN1 = '
30 for i in $scripts
31 do
32 printf '"%s\\0"' $i
33 done
34 printf '"\\0";\n'
35fi
36printf "#define NUM_SCRIPTS $n\n\n"
37
38if [ $n -ne 0 ]
39then
40 printf '#define UNPACKED_SCRIPTS_LENGTH '
41 for i in $scripts
42 do
43 cat $loc/$i
44 printf '\000'
45 done | wc -c
46
47 printf '#define PACKED_SCRIPTS \\\n'
48 for i in $scripts
49 do
50 cat $loc/$i
51 printf '\000'
52 done | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -b \
53 | grep -v '^ ' \
54 | $SED -e 's/^[^ ]*//' \
55 -e 's/ //g' \
56 -e '/^$/d' \
57 -e 's/\(...\)/0\1,/g' \
58 -e 's/$/ \\/'
59 printf '\n'
60fi
61
62mv -- "$target.$$" "$target"