List of commits:
Subject Hash Author Date (UTC)
many script fixes 184aade382453dfa4874b5d3705269f45be024dd Sylvain BERTRAND 2014-12-16 19:07:04
some minor cleanup b47f5ef4f6dff33c88943b9a175ae90fc9a02332 Sylvain BERTRAND 2014-12-08 16:47:05
some cleanup 2cf8ba8e82181b954891d688c5bf3ed51dede5ff Sylvain BERTRAND 2014-12-02 02:22:24
Massive refactoring. Support live/mobile linux OSes. dd09f40ecd7ec40b6745bafbbba0743ecafe4bdf Sylvain BERTRAND 2014-12-02 02:04:37
use kernel version for initramfs 2762a46a6eb9d9f3a63a8b69f5e826b89d1a46e9 Sylvain BERTRAND 2014-08-19 16:42:19
enforce kernel version setting, binfmt_script f0aaf75a34bd2b4fdb84bea6bd572ff5b715fd2b Sylvain BERTRAND 2013-09-11 00:41:45
Create LICENSE.md 73147c4952cdeee9ad96fe447c543ffbf6ab494a Sylvain BERTRAND 2013-07-17 19:00:49
scsi_wait_scan is gone from upstream d7bc928da1caea553b1279d131596344df93273f Sylvain BERTRAND 2012-12-19 16:24:37
wrong init place abf8267b4a36f1385facf5a4752746c121914674 root 2012-07-05 00:35:09
adapt sample script for devtmpfs 983e8e944dae73846c5e0ea5ab26726851073dec root 2012-03-28 14:47:01
must up the ethernet interface 79bd84790e904ce471101762a35dbd280bb2673f root 2012-02-02 18:30:24
init have more children than gettys 57f4231ffd8e97b7511226bfc4f058e0814a4e8e Sylvain BERTRAND 2012-01-31 13:10:32
clean sigprogmask for children 89a379820196e9a4de7d6bf38ec49a679f9de917 Sylvain BERTRAND 2012-01-31 12:52:11
ready to be used 51f3d5adedf51ab5b47a61724035141bcbb71354 Sylvain BERTRAND 2012-01-30 15:27:56
ready, now need to know why init libc is crashing 39e165e544af1632e0d1926a686173e8b7543bdd Sylvain BERTRAND 2011-12-30 02:35:57
uevents cleanup 082938475c119d68ce5def18a1c21f69c596b1a1 Sylvain BERTRAND 2011-12-26 23:32:00
uevent monitor to ulinux patterns e9e2e03953d3a28e08aeb3a7388b334cda8a8479 Sylvain BERTRAND 2011-12-26 22:38:45
modules properly loaded ac79794945662bad9e97562c479dea5afe455687 Sylvain BERTRAND 2011-12-26 22:08:54
ulinux patterns: insert a kernel module ed879829ce6c44b77bddcd9c106a106261f47301 Sylvain BERTRAND 2011-12-26 21:29:33
ulinux dir_parse pattern 63cc7acc186efc291a76255e97d86e80901174e5 Sylvain BERTRAND 2011-12-26 02:24:55
Commit 184aade382453dfa4874b5d3705269f45be024dd - many script fixes
* remove some bash-isms
* remove some excessive non-posix-isms
* bugs
Author: Sylvain BERTRAND
Author date (UTC): 2014-12-16 19:07
Committer name: Sylvain BERTRAND
Committer date (UTC): 2014-12-16 19:07
Parent(s): b47f5ef4f6dff33c88943b9a175ae90fc9a02332
Signing key:
Tree: b4e1ce6a1a441774de0ad237c6700a8f4e896ceb
File Lines added Lines deleted
make 32 23
script/cpio_libs_add.sh 14 14
script/cpio_modules_add.sh 11 9
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
File script/cpio_modules_add.sh changed (mode: 100755) (index 6206f75..dbc77d2)
2 2
3 3 uniqify() uniqify()
4 4 { {
5 local p= paths_list=
5 local p=
6 local paths_list=
6 7 for p in $MODULES_ORDERED; do for p in $MODULES_ORDERED; do
7 8 case "$paths_list" in case "$paths_list" in
8 9 *"$p"*) ;; *"$p"*) ;;
 
... ... uniqify()
15 16
16 17 modules_ordered_build() modules_ordered_build()
17 18 { {
18 local deps m
19 local deps=
20 local m=
19 21 for m; do for m; do
20 if modinfo $m &>/dev/null;then
22 if modinfo $kmod_option_basedir -k $kernel_release $m >/dev/null 2>&1;then
21 23 echo module $m found, adding... echo module $m found, adding...
22 24 else else
23 25 echo module $m not found, skipping... echo module $m not found, skipping...
 
... ... modules_ordered_build()
38 40 #recursive emiting of cpio dir entries for the module #recursive emiting of cpio dir entries for the module
39 41 dirs_emit() dirs_emit()
40 42 { {
41 local cur
42 cur=$(dirname $1)
43 if test "$cur" == "/lib/modules/$kernel_release"; then
43 local cur=$(dirname $1)
44 if test "$cur" = "/lib/modules/$kernel_release"; then
44 45 return; return;
45 46 fi fi
46 47
47 48 for p in $DIRS_EMITED; do for p in $DIRS_EMITED; do
48 if test "$p" == "$cur"; then
49 if test "$p" = "$cur"; then
49 50 return; return;
50 51 fi fi
51 52 done done
 
... ... cpio_kmod_files='modules.alias.bin,modules.builtin.bin,modules.dep.bin'
58 59
59 60 cpio_emit() cpio_emit()
60 61 { {
61 local f m
62 local f=
63 local m=
62 64 for f in $cpio_kmod_files; do for f in $cpio_kmod_files; do
63 65 echo "file /lib/modules/$kernel_release/$f \ echo "file /lib/modules/$kernel_release/$f \
64 66 $kernel_modules_base_dir/lib/modules/$kernel_release/$f \ $kernel_modules_base_dir/lib/modules/$kernel_release/$f \
 
... ... cpio=$4
80 82 MODULES_ORDERED= MODULES_ORDERED=
81 83 DIRS_EMITED=/lib/modules/$kernel_release DIRS_EMITED=/lib/modules/$kernel_release
82 84
83 if test "$kernel_modules_base_dir"=='/'; then
85 if test "$kernel_modules_base_dir" = '/'; then
84 86 kmod_option_basedir= kmod_option_basedir=
85 87 kernel_modules_base_dir= kernel_modules_base_dir=
86 88 else else
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/sylware/cinitramfs

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/sylware/cinitramfs

Clone this repository using git:
git clone git://git.rocketgit.com/user/sylware/cinitramfs

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main