Debian Codegraph @

scripts/embedded_scripts

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 . ./.configscip-shell source . . `./.config`. || exit 1
4
5 target="$1"
6 custom_loc="$2"
7 applet_loc="$3"
8
9 testscip-shell system . . test. "$target" || exit 1
10 testscip-shell system . . test. "$SED" || SED=sed
11 testscip-shell system . . test. "$DD" || DD=dd
12
13 if [scip-shell system . . `[`. x"$CONFIG_FEATURE_SH_EMBEDDED_SCRIPTS" != x"y" ]
14 then
15 printfscip-shell system . . printf. '#define NUM_SCRIPTS 0\n' >"$target"
16 exit 0
17 fi
18
19 # Some people were bitten by their system lacking a (proper) od
20 odscip-shell system . . od. -v -b </dev/nullscip-shell filesystem . . `/dev/null`. >/dev/nullscip-shell filesystem . . `/dev/null`.
21 if testscip-shell system . . test. $? != 0; then
22 echoscip-shell system . . echo. 'od tool is not installed or cannot accept "-v -b" options'
23 exit 1
24 fi
25
26 bzip2scip-shell system . . bzip2. </dev/nullscip-shell filesystem . . `/dev/null`. >/dev/nullscip-shell filesystem . . `/dev/null`.
27 if testscip-shell system . . test. $? != 0; then
28 echoscip-shell system . . echo. 'bzip2 is not installed'
29 exit 1
30 fi
31
32 custom_scripts=""
33 if [scip-shell system . . `[`. -d "$custom_loc" ]
34 then
35 custom_scripts=$(cd $custom_loc; lsscip-shell system . . ls. * 2>/dev/nullscip-shell filesystem . . `/dev/null`.)
36 fi
37 all_scripts=$($srctree/applets/busybox.mkscripts)
38
39 # all_scripts includes applet scripts and custom scripts, sort them out
40 applet_scripts=""
41 for i in $all_scripts
42 do
43 found=0
44 for j in $custom_scripts
45 do
46 if [scip-shell system . . `[`. "$i" = "$j" ]
47 then
48 found=1
49 break;
50 fi
51 done
52 if [scip-shell system . . `[`. $found -eq 0 ]
53 then
54 # anything that isn't a custom script is an applet script
55 applet_scripts="$applet_scripts $i"
56 fi
57 done
58
59 # we know the custom scripts are present but applet scripts might have
60 # become detached from their configuration
61 for i in $applet_scripts
62 do
63 #if [ ! -f "$applet_loc/$i" -a ! -f "$custom_loc/$i" ]
64 if [scip-shell system . . `[`. ! -f "$applet_loc/$i" ]
65 then
66 echoscip-shell system . . echo. "missing applet script $i"
67 exit 1
68 fi
69 done
70
71 n=$(echoscip-shell system . . echo. $custom_scripts $applet_scripts | wcscip-shell system . . wc. -w)
72 nall=$(echoscip-shell system . . echo. $all_scripts | wcscip-shell system . . wc. -w)
73
74 if [scip-shell system . . `[`. $n -ne $nall ]
75 then
76 echoscip-shell system . . echo. "script mismatch $n != $nall"
77 exit 1
78 fi
79
80 concatenate_scriptsscip-shell shell shell-project 0.0.0 concatenate_scripts().() {
81 for i in $custom_scripts
82 do
83 catscip-shell system . . cat. $custom_loc/$i
84 printfscip-shell system . . printf. '\000'
85 done
86 for i in $applet_scripts
87 do
88 catscip-shell system . . cat. $applet_loc/$i
89 printfscip-shell system . . printf. '\000'
90 done
91 }
92
93 exec >"$target.$$"
94
95 if [scip-shell system . . `[`. $n -ne 0 ]
96 then
97 printfscip-shell system . . printf. '#ifdef DEFINE_SCRIPT_DATA\n'
98 printfscip-shell system . . printf. 'const uint16_t applet_numbers[] = {\n'
99 for i in $custom_scripts $applet_scripts
100 do
101 # TODO support applets with names including invalid characters
102 printfscip-shell system . . printf. '\tAPPLET_NO_%s,\n' $i
103 done
104 printfscip-shell system . . printf. '};\n'
105 printfscip-shell system . . printf. '#else\n'
106 printfscip-shell system . . printf. 'extern const uint16_t applet_numbers[];\n'
107 printfscip-shell system . . printf. '#endif\n'
108 fi
109
110 printfscip-shell system . . printf. "\n"
111 printfscip-shell system . . printf. '#define NUM_SCRIPTS %d\n' $n
112 printfscip-shell system . . printf. "\n"
113
114 if [scip-shell system . . `[`. $n -ne 0 ]
115 then
116 printfscip-shell system . . printf. '#define UNPACKED_SCRIPTS_LENGTH '
117 concatenate_scriptsscip-shell shell shell-project 0.0.0 concatenate_scripts(). | wcscip-shell system . . wc. -c
118
119 printfscip-shell system . . printf. '#define PACKED_SCRIPTS \\\n'
120 concatenate_scriptsscip-shell shell shell-project 0.0.0 concatenate_scripts(). | bzip2scip-shell system . . bzip2. -1 | $DD bs=2 skip=1 2>/dev/nullscip-shell filesystem . . `/dev/null`. | \
121 od -v -b \
122 | grepscip-shell system . . grep. -v '^ ' \
123 | $SED -e 's/^[^ ]*//' \
124 -e 's/ //g' \
125 -e '/^$/dscip-shell filesystem . . `/^$/d`.' \
126 -e 's/\(...\)/0\1,/g' \
127 -e 's/$/ \\/'
128 printfscip-shell system . . printf. '\n'
129 fi
130
131 mvscip-shell system . . mv. -- "$target.$$" "$target"