Dash:
[t2-trunk.git] / target / share / initrd / build.sh
blob738b2f34c7db4e87dc3ef3b2440fdfe8e5abbf9e
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: target/share/initrd/build.sh
3 # Copyright (C) 2004 - 2021 The T2 SDE Project
4 #
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2.
10 # --- T2-COPYRIGHT-NOTE-END ---
12 #Description: Initial RAM disk (initrd) / RAM FS (initramfs)
14 # TODO: share code with livecd imager
16 set -e
17 imagelocation="$build_toolchain/rootfs" # where the roofs is prepared
19 . $base/misc/target/functions.in
21 mkdir -p $imagelocation ; cd $imagelocation
22 # just in case it is still there from the last run
23 (umount proc ; umount dev) 2>/dev/null || true
25 echo "Creating root file-system file lists ..."
26 f=" $pkg_filter "
27 for pkg in `grep '^X ' $base/config/$config/packages | cut -d ' ' -f 5`; do
28 # include the package?
29 if [ "${f/ $pkg /}" == "$f" ] ; then
30 cut -d ' ' -f 2 $build_root/var/adm/flists/$pkg 2>/dev/null || true
32 done > ../files-wanted
33 unset f
34 [ "$filter_hook" ] && "$filter_hook" ../files-wanted
35 sort -u ../files-wanted > x ; mv -f x ../files-wanted
37 # for rsync with --delete we can not use file lists, since rsync does not
38 # delete in that mode - instead we need to generate a negative list
39 time find $build_root -mount -wholename $build_root/TOOLCHAIN -prune -o -printf '%P\n' |
40 sort -u > ../files-all
41 # the difference
42 diff -u ../files-all ../files-wanted |
43 sed -n -e '/var\/adm\/olist/d' -e '/var\/adm\/logs/d' \
44 -e '/var\/adm\/dep-debug/d' -e '/var\/adm\/cache/d' -e 's/^-//p' > ../files-exclude
45 echo "TOOLCHAIN
46 proc/*
47 dev/*
48 */share/doc/*
49 var/adm/olist
50 var/adm/logs
51 var/adm/dep-debug
52 var/adm/cache" >> ../files-exclude
54 echo "Syncing root file-system (this may take some time) ..."
55 [ -e $imagelocation/bin ] && v="-v" || v=""
56 time rsync -artH $v --devices --specials --delete --delete-excluded \
57 --exclude-from ../files-exclude $build_root/ $imagelocation/
58 rm ../files-{wanted,all,exclude}
60 echo "Overlaying root file-system with target defined files ..."
61 copy_and_parse_from_source $base/target/share/initrd/rootfs $imagelocation
62 [ -e $base/target/$target/rootfs ] &&
63 copy_and_parse_from_source $base/target/$target/rootfs $imagelocation
65 [ "$inject_hook" ] && "$inject_hook"
67 if false; then
68 echo "Running ldconfig and other postinstall scripts ..."
69 mount /dev dev --bind
70 mount none proc -t proc
71 for x in sbin/ldconfig etc/postinstall.d/*; do
72 cat > $$.sh <<-EOT
73 . /etc/profile
75 EOT
76 chmod +x $$.sh
77 case $x in
78 */scrollkeeper) echo "$x left out" ;;
79 *) chroot . /bin/sh -c ". /etc/profile; /$x" && true ;;
80 esac
81 rm $$.sh
82 done
83 umount proc
84 umount dev
87 echo "Compression root file-system (this may take some time) ..."
88 time find . | cpio -o -H newc | gzip -c9 > $imagelocation/../initrd
89 du -sh $imagelocation/../initrd
91 # For each available kernel:
93 mkdir -p $imagelocation/../boot/
94 for x in `egrep 'X .* KERNEL .*' $base/config/$config/packages |
95 cut -d ' ' -f 5`; do
96 kernel=${x/_*/}
97 for kernelver in `sed -n "s,.*boot/kconfig.,,p" $build_root/var/adm/flists/$kernel`; do
98 initrd="initrd-$kernelver"
99 kernelimg=`ls $build_root/boot/vmlinu?-$kernelver`
100 kernelimg=${kernelimg##*/}
102 cp $build_root/boot/vmlinu?-$kernelver $imagelocation/../boot/
103 cp $imagelocation/../initrd $imagelocation/../boot/$initrd
104 done
105 done