5 # Set some more or less unchanging variables
7 DYN_BIN="/usr/sbin/pcscd /usr/lib64/readers/usb/ifd-ccid.bundle/Contents/Linux/libccid.so"
12 packages="/usr/portage/distfiles"
16 cryptsetup="cryptsetup"
22 find $packages -iname "${1}*" | head -n 1
25 # Create basic directory structure
26 mkdir -p ${RD}/{bin,dev,etc/dropbear,lib64,mnt/root,proc,root/.ssh,sys,usr/sbin,var/log,var/run}
31 tar xf $(distfile ${busybox})
34 cp ${cur}/busybox_config ./.config
38 mkdir ${wd}/busybox/bin -p
39 cp _install/bin/busybox ${RD}/bin/busybox
40 cp examples/udhcp/simple.script ${RD}/bin/simple.script
44 tar xf $(distfile ${cryptsetup})
48 ./configure --prefix=/ \
52 --enable-static-cryptsetup \
53 --disable-verity-setup \
54 --disable-cryptsetup-reencrypt \
55 --disable-integritysetup \
58 --with-crypto_backend=kernel
61 make install DESTDIR=${RD}
62 mv -f ${RD}/sbin/cryptsetup.static ${RD}/sbin/cryptsetup
66 tar xf $(distfile ${lvm})
72 LIBS="-luuid -lrt -lpthread -lm" \
73 ./configure --prefix=/ \
74 --enable-static_link \
76 --with-snapshots=none \
82 --disable-udev-systemd-background-jobs
85 make install DESTDIR=${RD}
86 mv -f ${RD}/sbin/lvm.static ${RD}/sbin/lvm
90 tar xf $(distfile ${dropbear})
94 ./configure --prefix=/ \
107 make install DESTDIR=${RD}
111 tar xf $(distfile ${gpg})
118 --enable-static_rnd=linux \
119 --disable-gnupg-iconv \
121 --disable-agent-support \
122 --disable-photo-viewers \
123 --disable-keyserver-helpers \
127 --with-included-zlib \
128 --enable-card-support \
132 make install DESTDIR=${RD}
135 # Copy all necessary dynamic libraries
136 for bin in ${DYN_BIN}; do
137 for lib in $(lddtree -l ${bin}); do
138 DIR=$(dirname ${lib})
140 cp -L ${lib} ${RD}${lib}
144 cat << EOF > ${RD}/init
147 /bin/busybox echo "Something went wrong. Dropping you to a shell"
148 /bin/busybox --install -s
153 /bin/busybox mount -t devtmpfs none /dev || rescue_shell
154 /bin/busybox mount -t proc none /proc || rescue_shell
155 /bin/busybox mount -t sysfs none /sys || rescue_shell
156 #/bin/busybox echo 0 > /proc/sys/kernel/printk || rescue_shell
159 /sbin/cryptsetup -T 5 luksOpen /dev/sdb3 lukssdb3 || rescue_shell
161 # Create LVM nodes /dev/main/root etc
162 /sbin/lvm vgscan --mknodes || rescue_shell
163 /sbin/lvm lvchange -a ly main/root || rescue_shell
164 /sbin/lvm lvchange -a ly main/home || rescue_shell
165 /sbin/lvm lvchange -a ly main/swap || rescue_shell
166 /sbin/lvm vgscan --mknodes || rescue_shell
169 /bin/busybox mount -o ro /dev/main/root /mnt/root || rescue_shell
171 # Unmount filesystems
172 /bin/busybox umount /dev || rescue_shell
174 # Rescue shell for dicking around:
175 /bin/busybox install -s
179 exec /bin/busybox switch_root /mnt/root /sbin/init || rescue_shell
184 find ${RD} -type f -printf "/%P %p %m 0 0\n" > ${wd}/filelist
185 find ${RD} -type d -printf "/%P %m 0 0 \n" >> ${wd}/filelist
188 /usr/src/linux/scripts/gen_initramfs_list.sh \
189 -o ${wd}/initramfs.gz -u "squash" -g "squash" ${wd}/filelist
192 echo "Initramfs has been generated at ${RD}"
193 echo "Initramfs.gz has been generated at ${wd}/initramfs.gz"