File make changed (mode: 100755) (index 9f4bb09..32c47c6) |
5 |
5 |
#for the moment, it's hardcoded for a gcc toolchain... BAD! Since now |
#for the moment, it's hardcoded for a gcc toolchain... BAD! Since now |
6 |
6 |
#gcc is a c++ piece of shit |
#gcc is a c++ piece of shit |
7 |
7 |
|
|
8 |
|
# stolen from ffmpeg configure like a pig |
|
|
8 |
|
#stolen from ffmpeg configure like a pig |
9 |
9 |
set -e |
set -e |
10 |
10 |
|
|
11 |
|
# Prevent locale nonsense from breaking basic text processing. |
|
|
11 |
|
#prevent locale nonsense from breaking basic text processing. |
12 |
12 |
LC_ALL=C |
LC_ALL=C |
13 |
13 |
export LC_ALL |
export LC_ALL |
14 |
14 |
|
|
|
... |
... |
clean_do() |
38 |
38 |
rm -f $init_file_name |
rm -f $init_file_name |
39 |
39 |
for init_src_file in $init_src_files |
for init_src_file in $init_src_files |
40 |
40 |
do |
do |
41 |
|
rm -f ${init_src_file/\.c/.pp.c} |
|
42 |
|
rm -f ${init_src_file/\.c/.o} |
|
|
41 |
|
init_pp_file=${init_src_file%.c} |
|
42 |
|
init_pp_file=${init_pp_file}.pp.c |
|
43 |
|
rm -f ${init_pp_file} |
|
44 |
|
init_o_file=${init_src_file%.c} |
|
45 |
|
init_o_file=${init_o_file}.o |
|
46 |
|
rm -f ${init_o_file} |
43 |
47 |
#clean directories, but keep root of build tree |
#clean directories, but keep root of build tree |
44 |
48 |
tgt_dir=$(dirname $init_src_file) |
tgt_dir=$(dirname $init_src_file) |
45 |
49 |
if test -d $tgt_dir -a "$tgt_dir" != "."; then |
if test -d $tgt_dir -a "$tgt_dir" != "."; then |
|
... |
... |
sep_start() |
56 |
60 |
|
|
57 |
61 |
sep_end() |
sep_end() |
58 |
62 |
{ |
{ |
59 |
|
echo -e '###############################################################################\n' |
|
|
63 |
|
echo "###############################################################################\n" |
60 |
64 |
} |
} |
61 |
65 |
|
|
62 |
66 |
subsep_start() |
subsep_start() |
63 |
67 |
{ |
{ |
64 |
|
echo -e '*******************************************************************************' |
|
|
68 |
|
echo '*******************************************************************************' |
65 |
69 |
} |
} |
66 |
70 |
|
|
67 |
71 |
subsep_end() |
subsep_end() |
68 |
72 |
{ |
{ |
69 |
|
echo -e '*******************************************************************************' |
|
|
73 |
|
echo '*******************************************************************************' |
70 |
74 |
} |
} |
71 |
75 |
################################################################################ |
################################################################################ |
72 |
76 |
|
|
|
... |
... |
CMDLINE_SET=' |
99 |
103 |
init_ld |
init_ld |
100 |
104 |
init_ulinux_arch |
init_ulinux_arch |
101 |
105 |
uevents_timeout |
uevents_timeout |
102 |
|
root_uuid |
|
103 |
106 |
gen_init_cpio |
gen_init_cpio |
104 |
107 |
kernel_release |
kernel_release |
105 |
108 |
extra_modules |
extra_modules |
|
... |
... |
CMDLINE_SET=' |
110 |
113 |
#command line set defaults |
#command line set defaults |
111 |
114 |
#if the root is not around in less than 4s, something is really wrong |
#if the root is not around in less than 4s, something is really wrong |
112 |
115 |
uevents_timeout_default=4000 |
uevents_timeout_default=4000 |
113 |
|
root_uuid_default=00000000-0000-0000-0000-000000000000 |
|
114 |
116 |
gen_init_cpio_default='$linux_src_dir/usr/gen_init_cpio' |
gen_init_cpio_default='$linux_src_dir/usr/gen_init_cpio' |
115 |
117 |
linux_src_dir_default=/usr/src/linux |
linux_src_dir_default=/usr/src/linux |
116 |
118 |
#------------------------------------------------------------------------------- |
#------------------------------------------------------------------------------- |
|
... |
... |
Help options: |
148 |
150 |
--help print this message |
--help print this message |
149 |
151 |
|
|
150 |
152 |
Standard options: |
Standard options: |
151 |
|
--root-uuid=ROOT_UUID the uuid or the root filesystem to mount [$root_uuid_default] |
|
152 |
153 |
--lib-path-list=LIB_PATH_LIST colon separated paths to look for target libraries |
--lib-path-list=LIB_PATH_LIST colon separated paths to look for target libraries |
153 |
154 |
--uevents-timeout=UEVENTS_TIMEOUT uevents timeout in ms looking up for root block device to go online [$uevents_timeout] |
--uevents-timeout=UEVENTS_TIMEOUT uevents timeout in ms looking up for root block device to go online [$uevents_timeout] |
154 |
155 |
--quiet init will be silenced (output code compiled out) |
--quiet init will be silenced (output code compiled out) |
|
... |
... |
sep_end |
223 |
224 |
|
|
224 |
225 |
#define variable in source |
#define variable in source |
225 |
226 |
CPPFLAGS="$CPPFLAGS -DUEVENTS_TIMEOUT=$uevents_timeout" |
CPPFLAGS="$CPPFLAGS -DUEVENTS_TIMEOUT=$uevents_timeout" |
226 |
|
CPPFLAGS="$CPPFLAGS -DROOT_UUID="$root_uuid"" |
|
227 |
227 |
CPPFLAGS="$CPPFLAGS $($pkg_config --cflags-only-I libkmod blkid)" |
CPPFLAGS="$CPPFLAGS $($pkg_config --cflags-only-I libkmod blkid)" |
228 |
228 |
CFLAGS="$CFLAGS $($pkg_config --cflags-only-other libkmod blkid)" |
CFLAGS="$CFLAGS $($pkg_config --cflags-only-other libkmod blkid)" |
229 |
229 |
LDFLAGS="$LDFLAGS $($pkg_config --libs libkmod blkid)" |
LDFLAGS="$LDFLAGS $($pkg_config --libs libkmod blkid)" |
|
... |
... |
sep_end |
241 |
241 |
#generated some code/headers |
#generated some code/headers |
242 |
242 |
|
|
243 |
243 |
sep_start |
sep_start |
244 |
|
revision=$(uname -r | egrep -o '^[[:digit:]]+\.[[:digit:]]+') |
|
245 |
|
source $src_path/$revision |
|
246 |
|
echo -e "linux revision is $revision, $src_path/$revision was sourced:\n--------" |
|
|
244 |
|
revision=$(echo "$kernel_release" | egrep -o '^[[:digit:]]+\.[[:digit:]]+') |
|
245 |
|
. $src_path/$revision |
|
246 |
|
echo "linux revision is $revision, $src_path/$revision was sourced:\n--------" |
247 |
247 |
cat $src_path/$revision |
cat $src_path/$revision |
248 |
248 |
echo '--------' |
echo '--------' |
249 |
249 |
sep_end |
sep_end |
|
... |
... |
sep_end |
259 |
259 |
sep_start;echo 'C preprocess init src files:' |
sep_start;echo 'C preprocess init src files:' |
260 |
260 |
for init_src_file in $init_src_files |
for init_src_file in $init_src_files |
261 |
261 |
do |
do |
262 |
|
init_pp_c_file=${init_src_file/\.c/.pp.c} |
|
|
262 |
|
init_pp_c_file=${init_src_file%.c} |
|
263 |
|
init_pp_c_file=${init_pp_c_file}.pp.c |
263 |
264 |
echo "INIT_CPP $init_src_file->$init_pp_c_file" |
echo "INIT_CPP $init_src_file->$init_pp_c_file" |
264 |
265 |
mkdir -p $(dirname $init_pp_c_file) |
mkdir -p $(dirname $init_pp_c_file) |
265 |
266 |
$init_cpp $CPPFLAGS -I. -I$src_path -o $init_pp_c_file \ |
$init_cpp $CPPFLAGS -I. -I$src_path -o $init_pp_c_file \ |
|
... |
... |
sep_end |
273 |
274 |
sep_start;echo 'compile init preprocessed src files:' |
sep_start;echo 'compile init preprocessed src files:' |
274 |
275 |
for init_pp_c_file in $init_pp_c_files |
for init_pp_c_file in $init_pp_c_files |
275 |
276 |
do |
do |
276 |
|
init_obj_file=${init_pp_c_file/\.pp.c/.o} |
|
|
277 |
|
init_obj_file=${init_pp_c_file%.pp.c} |
|
278 |
|
init_obj_file=${init_obj_file}.o |
277 |
279 |
echo "INIT_CC $init_pp_c_file-->$init_obj_file" |
echo "INIT_CC $init_pp_c_file-->$init_obj_file" |
278 |
280 |
$init_cc $CFLAGS -o $init_obj_file $init_pp_c_file |
$init_cc $CFLAGS -o $init_obj_file $init_pp_c_file |
279 |
281 |
init_obj_files="$init_obj_file $init_obj_files" |
init_obj_files="$init_obj_file $init_obj_files" |
|
... |
... |
sep_end |
284 |
286 |
|
|
285 |
287 |
sep_start;echo 'link the init objects to produce the init binary:' |
sep_start;echo 'link the init objects to produce the init binary:' |
286 |
288 |
echo "INIT_LD $init_file_name" |
echo "INIT_LD $init_file_name" |
|
289 |
|
echo $init_ld -o $init_file_name $init_obj_files $LDFLAGS |
287 |
290 |
$init_ld -o $init_file_name $init_obj_files $LDFLAGS |
$init_ld -o $init_file_name $init_obj_files $LDFLAGS |
288 |
291 |
sep_end |
sep_end |
289 |
292 |
|
|
|
... |
... |
IFS=: |
303 |
306 |
#replace the sysroot marker, '=', in gcc library path |
#replace the sysroot marker, '=', in gcc library path |
304 |
307 |
if test -n "$gcc_sysroot"; then |
if test -n "$gcc_sysroot"; then |
305 |
308 |
for p in $lib_path_nosysroot; do |
for p in $lib_path_nosysroot; do |
306 |
|
lib_path_norealpath="$lib_path_norealpath:$(echo $p | sed -r "s:^=:$gcc_sysroot:")" |
|
|
309 |
|
lib_path_noncanonical="$lib_path_noncanonical:$(echo "$p" | sed -r "s:^=:$gcc_sysroot:")" |
307 |
310 |
done |
done |
308 |
311 |
else |
else |
309 |
312 |
for p in $lib_path_nosysroot; do |
for p in $lib_path_nosysroot; do |
310 |
|
lib_path_norealpath="$lib_path_norealpath:$(echo $p | sed -r 's/^=//')" |
|
|
313 |
|
lib_path_noncanonical="$lib_path_noncanonical:$(echo "$p" | sed -r 's/^=//')" |
311 |
314 |
done |
done |
312 |
315 |
fi |
fi |
313 |
|
for p in $lib_path_norealpath; do |
|
314 |
|
if realpath -q "$p" &>/dev/null; then |
|
315 |
|
lib_path="$lib_path:$(realpath "$p")" |
|
|
316 |
|
|
|
317 |
|
lib_path_noncanonical=${lib_path_noncanonical#:} |
|
318 |
|
|
|
319 |
|
for p in $lib_path_noncanonical; do |
|
320 |
|
if readlink -m -q "$p" >/dev/null 2>&1; then |
|
321 |
|
lib_path="$lib_path:$(readlink -m "$p")" |
316 |
322 |
fi |
fi |
317 |
323 |
done |
done |
|
324 |
|
|
318 |
325 |
lib_path=${lib_path#:} |
lib_path=${lib_path#:} |
319 |
326 |
echo "final LIB_PATH=$lib_path" |
echo "final LIB_PATH=$lib_path" |
320 |
327 |
sep_end |
sep_end |
|
... |
... |
sep_end |
332 |
339 |
################################################################################ |
################################################################################ |
333 |
340 |
|
|
334 |
341 |
sep_start;echo 'generate the cpio source file:' |
sep_start;echo 'generate the cpio source file:' |
335 |
|
sed -e "s:@INIT_PATH@:$(realpath $init_file_name):" "$src_path/cpio.in" >cpio |
|
|
342 |
|
sed -e "s:@INIT_PATH@:$(readlink -f $init_file_name):" "$src_path/cpio.in" >cpio |
336 |
343 |
echo "dir /lib/modules/$kernel_release 0755 0 0">>cpio |
echo "dir /lib/modules/$kernel_release 0755 0 0">>cpio |
337 |
344 |
|
|
338 |
345 |
modules=$HW_MODULES,$DISK_MODULES,$FS_MODULES |
modules=$HW_MODULES,$DISK_MODULES,$FS_MODULES |
|
... |
... |
$src_path/script/cpio_libs_add.sh "$readelf" "$lib_path" ./init \ |
352 |
359 |
"$elf_interpreter" ./cpio |
"$elf_interpreter" ./cpio |
353 |
360 |
subsep_end |
subsep_end |
354 |
361 |
|
|
355 |
|
echo -e 'cpio source file is:\n--------' |
|
|
362 |
|
echo "cpio source file is:\n--------" |
356 |
363 |
cat cpio |
cat cpio |
357 |
364 |
echo '--------' |
echo '--------' |
358 |
365 |
sep_end |
sep_end |
359 |
366 |
|
|
360 |
367 |
################################################################################ |
################################################################################ |
361 |
368 |
|
|
|
369 |
|
sep_start;echo 'generating and compressing the cpio archive' |
362 |
370 |
e_gen_init_cpio=$(eval echo "$gen_init_cpio") |
e_gen_init_cpio=$(eval echo "$gen_init_cpio") |
363 |
371 |
$e_gen_init_cpio cpio >${kernel_release}.cpio |
$e_gen_init_cpio cpio >${kernel_release}.cpio |
364 |
372 |
xz --force --check=crc32 --extreme --stdout ${kernel_release}.cpio >${kernel_release}.cpio.xz |
xz --force --check=crc32 --extreme --stdout ${kernel_release}.cpio >${kernel_release}.cpio.xz |
|
373 |
|
sep_end |
File script/cpio_libs_add.sh changed (mode: 100755) (index 9cad189..28d4f43) |
... |
... |
uniqify() |
43 |
43 |
{ |
{ |
44 |
44 |
local p= |
local p= |
45 |
45 |
local paths_list= |
local paths_list= |
|
46 |
|
echo "LIB_PATHS=$LIB_PATHS" |
46 |
47 |
for p in $LIB_PATHS; do |
for p in $LIB_PATHS; do |
47 |
48 |
case "$paths_list" in |
case "$paths_list" in |
48 |
49 |
*"$p"*) ;; |
*"$p"*) ;; |
|
... |
... |
uniqify() |
55 |
56 |
|
|
56 |
57 |
cpio_dirs_emit() |
cpio_dirs_emit() |
57 |
58 |
{ |
{ |
58 |
|
local cur |
|
59 |
|
cur=$(dirname $1) |
|
60 |
|
if test "$cur" == "/"; then |
|
|
59 |
|
local cur=$(dirname $1) |
|
60 |
|
if test "$cur" = "/"; then |
61 |
61 |
return; |
return; |
62 |
62 |
fi |
fi |
63 |
63 |
|
|
64 |
64 |
for p in $CPIO_DIRS_EMITED; do |
for p in $CPIO_DIRS_EMITED; do |
65 |
65 |
|
|
66 |
|
if test "$p" == "$cur"; then |
|
|
66 |
|
if test "$p" = "$cur"; then |
67 |
67 |
return; |
return; |
68 |
68 |
fi |
fi |
69 |
69 |
done |
done |
|
... |
... |
cpio_dirs_emit() |
74 |
74 |
|
|
75 |
75 |
cpio_libs_emit() |
cpio_libs_emit() |
76 |
76 |
{ |
{ |
77 |
|
local p |
|
|
77 |
|
local p= |
78 |
78 |
for p in $LIB_PATHS; do |
for p in $LIB_PATHS; do |
79 |
|
#the shared lib soname file, may be a symbolic link, use realpath to sort that out |
|
80 |
|
echo "file $(dirname $ELF_BINARY_INTERPRETER)/$(basename $p) $(realpath $p) 0755 0 0" >>$cpio |
|
|
79 |
|
#the shared lib soname file, may be a symbolic link, use readlink -f to sort that out |
|
80 |
|
echo "file $(dirname $ELF_BINARY_INTERPRETER)/$(basename $p) $(readlink -f $p) 0755 0 0" >>$cpio |
81 |
81 |
done |
done |
82 |
82 |
} |
} |
83 |
83 |
|
|
|
... |
... |
cpio_libs_emit() |
85 |
85 |
lib_paths_collect() |
lib_paths_collect() |
86 |
86 |
{ |
{ |
87 |
87 |
for soname in $*; do |
for soname in $*; do |
88 |
|
if test "$soname" == "$(basename $ELF_BINARY_INTERPRETER)"; then |
|
89 |
|
echo -e "soname $1 is elf interpreter, skipping\n--------" |
|
|
88 |
|
if test "$soname" = "$(basename $ELF_BINARY_INTERPRETER)"; then |
|
89 |
|
echo "soname $1 is elf interpreter, skipping\n--------" |
90 |
90 |
continue |
continue |
91 |
91 |
fi |
fi |
92 |
92 |
|
|
93 |
|
echo -e "collecting needed for soname=$soname" |
|
|
93 |
|
echo "collecting needed for soname=$soname" |
94 |
94 |
local lib_path= |
local lib_path= |
95 |
95 |
lib_locate $soname |
lib_locate $soname |
96 |
96 |
echo "lib location is $lib_path"; |
echo "lib location is $lib_path"; |
97 |
97 |
|
|
98 |
|
local needed=$($target_readelf --dynamic "$lib_path" | egrep NEEDED | sed --regexp-extended 's/^.+\(NEEDED\).+Shared library:.+\[(.+)\]$/\1:/' | tr -d '\n') |
|
|
98 |
|
local needed="$($target_readelf --dynamic "$lib_path" | egrep NEEDED | sed --regexp-extended 's/^.+\(NEEDED\).+Shared library:.+\[(.+)\]$/\1:/' | tr -d '\n')" |
99 |
99 |
needed=${needed%:} |
needed=${needed%:} |
100 |
|
echo -e "needed=$needed\n--------" |
|
|
100 |
|
echo "needed=$needed\n--------" |
101 |
101 |
lib_paths_collect $needed |
lib_paths_collect $needed |
102 |
102 |
LIB_PATHS="$LIB_PATHS:$lib_path" |
LIB_PATHS="$LIB_PATHS:$lib_path" |
103 |
103 |
done |
done |
|
... |
... |
uniqify |
124 |
124 |
CPIO_DIR_EMITED= |
CPIO_DIR_EMITED= |
125 |
125 |
cpio_dirs_emit $ELF_BINARY_INTERPRETER |
cpio_dirs_emit $ELF_BINARY_INTERPRETER |
126 |
126 |
cpio_libs_emit |
cpio_libs_emit |
127 |
|
#sort out with realpath the case where the elf interpreter is a symbolic link |
|
128 |
|
echo "file $ELF_BINARY_INTERPRETER $(realpath "$elf_interpreter_location") 0755 0 0" >>$cpio |
|
|
127 |
|
#sort out with readlink -f the case where the elf interpreter is a symbolic link |
|
128 |
|
echo "file $ELF_BINARY_INTERPRETER $(readlink -f "$elf_interpreter_location") 0755 0 0" >>$cpio |