Dash:
[t2-trunk.git] / target / share / install / build_initrd.sh
blobb46f459b0a63b20a2bd6bcb6961b68e4a4196fda
1 #!/bin/bash
2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # T2 SDE: target/share/install/build_initrd.sh
4 # Copyright (C) 2004 - 2021 The T2 SDE Project
5 #
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
8 #
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License version 2.
11 # --- T2-COPYRIGHT-NOTE-END ---
13 set -e
15 [ "$boot_title" ] || boot_title="T2 Installation"
17 . $base/misc/target/initrd.in
18 . $base/misc/target/boot.in
20 cd $build_toolchain
22 # Additional initrd overlay
24 rm -rf initramfs
25 mkdir -p initramfs/{,usr/}{,s}bin
26 # TODO: add gzip ip
27 cp $build_root/usr/embutils/{tar,readlink,rmdir,bunzip2} initramfs/bin/
28 cp -a $build_root/usr/bin/{,un}zstd initramfs/usr/bin/
29 cp $build_root/usr/bin/fget initramfs/bin/
31 sed '/PANICMARK/Q' $build_root/sbin/initrdinit > initramfs/init
32 cat $base/target/share/install/init >> initramfs/init
33 chmod +x initramfs/init
35 # For each available kernel:
37 arch_boot_cd_pre $isofsdir
38 for x in `egrep 'X .* KERNEL .*' $base/config/$config/packages |
39 cut -d ' ' -f 5`; do
40 kernel=${x/_*/}
41 for kernelver in `sed -n "s,.*boot/kconfig.,,p" $build_root/var/adm/flists/$kernel`; do
42 initrd="initrd-$kernelver"
43 kernelimg=`ls $build_root/boot/vmlinu?-$kernelver`
44 kernelimg=${kernelimg##*/}
46 cp $build_root/boot/vmlinu?-$kernelver $isofsdir/boot/
47 cp $build_root/boot/$initrd $isofsdir/boot/
48 extend_initrd $isofsdir/boot/$initrd $build_toolchain/initramfs
49 arch_boot_cd_add $isofsdir $kernelver "$boot_title" \
50 /boot/$kernelimg /boot/$initrd
51 initrd=${initrd/initrd/minird}
52 if [ -e $build_root/boot/$initrd ]; then
53 cp $build_root/boot/$initrd $isofsdir/boot/
54 extend_initrd $isofsdir/boot/$initrd $build_toolchain/initramfs
55 arch_boot_cd_add $isofsdir $kernelver-minird "$boot_title (minird)" \
56 /boot/$kernelimg /boot/$initrd
58 done
59 done
61 arch_boot_cd_post $isofsdir