summaryrefslogtreecommitdiff
path: root/make
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2019-07-26 20:17:54 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2019-07-26 20:17:54 -0400
commitefd5d866be3cdb9c2b5b3221319fbc80aa0d039b (patch)
tree5aa6603f47e56bcc380db0274513b95240727e64 /make
downloadminitramfs-efd5d866be3cdb9c2b5b3221319fbc80aa0d039b.tar.xz
minitramfs-efd5d866be3cdb9c2b5b3221319fbc80aa0d039b.zip
Initial commit
Diffstat (limited to 'make')
-rwxr-xr-xmake91
1 files changed, 91 insertions, 0 deletions
diff --git a/make b/make
new file mode 100755
index 0000000..6d150ba
--- /dev/null
+++ b/make
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+set -e
+
+scriptloc=${BASH_SOURCE:-$0}
+scriptdir=${scriptloc%/*}
+
+gen_cpio_list() {
+ cat << EOF
+dir /dev 0755 0 0
+dir /mnt 0755 0 0
+dir /proc 0755 0 0
+dir /run 0755 0 0
+dir /run/cryptsetup 0755 0 0
+dir /sys 0755 0 0
+
+nod /dev/console 0600 0 0 c 5 1
+
+slink /bin/sh busybox 0755 0 0
+slink /etc/mtab /proc/self/mounts 0755 0 0
+
+slink /usr/lib64/libgcc_s.so libgcc_s.so.1 0755 0 0
+file /usr/lib64/libgcc_s.so.1 /usr/lib/gcc/x86_64-pc-linux-gnu/9.1.0/libgcc_s.so.1 0755 0 0
+
+file /bin/busybox /bin/busybox 0755 0 0
+file /etc/passwd $scriptdir/passwd 0644 0 0
+file /etc/dropbear/dropbear_rsa_host_key $scriptdir/dropbear_rsa_host_key 0600 0 0
+file /etc/dropbear/dropbear_ecdsa_host_key $scriptdir/dropbear_ecdsa_host_key 0600 0 0
+file /init $scriptdir/init 0755 0 0
+file /lib/firmware/radeon/CAYMAN_mc.bin /lib/firmware/radeon/CAYMAN_mc.bin 0644 0 0
+file /lib/firmware/radeon/CAYMAN_me.bin /lib/firmware/radeon/CAYMAN_me.bin 0644 0 0
+file /lib/firmware/radeon/CAYMAN_pfp.bin /lib/firmware/radeon/CAYMAN_pfp.bin 0644 0 0
+file /lib/firmware/radeon/CAYMAN_rlc.bin /lib/firmware/radeon/CAYMAN_rlc.bin 0644 0 0
+file /lib/firmware/radeon/CAYMAN_smc.bin /lib/firmware/radeon/CAYMAN_smc.bin 0644 0 0
+file /lib/firmware/radeon/SUMO_uvd.bin /lib/firmware/radeon/SUMO_uvd.bin 0644 0 0
+file /lib/firmware/rtl_nic/rtl8168h-2.fw /lib/firmware/rtl_nic/rtl8168h-2.fw 0644 0 0
+file /lib64/libnss_files.so.2 /lib64/libnss_files.so.2 0755 0 0
+file /root/.ssh/authorized_keys $scriptdir/authorized_keys 0600 0 0
+file /unlock $scriptdir/unlock 0755 0 0
+file /usr/share/alsa/cards/HDA-Intel.conf /usr/share/alsa/cards/HDA-Intel.conf 0644 0 0
+file /usr/share/alsa/cards/USB-Audio.conf /usr/share/alsa/cards/USB-Audio.conf 0644 0 0
+file /usr/share/sounds/ding.wav $scriptdir/ding.wav 0644 0 0
+EOF
+ find /usr/share/alsa \
+ \( -name cards -o -name speaker-test -o -name ucm -o -name topology \) -prune -o \
+ -type f -print | while read f; do
+ printf 'file %s %s 0644 0 0\n' "$f" "$f"
+ done
+ for cmd in cryptsetup e2fsck aplay amixer dropbear; do
+ cmdp="$(command -v "$cmd")"
+ # builtin
+ if [ "$cmd" = "$cmdp" ]; then
+ continue
+ fi
+ ldd "$cmdp" | while read a b c d; do
+ if [ "$b" = '=>' ]; then
+ printf 'file /lib64/%s %s 0755 0 0\n' "${c##*/}" "$c"
+ else
+ # interpreter
+ case "$a" in
+ /*) printf 'file %s %s 0755 0 0\n' "$a" "$a" ;;
+ esac
+ fi
+ done
+ printf 'file %s %s 0755 0 0\n' "$cmdp" "$cmdp"
+ done
+}
+
+gen_dir_ents() {
+ while read type target args; do
+ printf '%s %s %s\n' "$type" "$target" "$args"
+ while [ "${target%/*}" != '' ]; do
+ target=${target%/*}
+ printf 'dir %s 0755 0 0\n' "$target"
+ done
+ done
+}
+
+gen_depfile() {
+ echo "initramfs.img: make" >&3
+ while read type target source args; do
+ printf '%s %s %s %s\n' "$type" "$target" "$source" "$args"
+ if [ "$type" = file ]; then
+ echo "initramfs.img: $source" >&3
+ fi
+ done
+}
+
+gen_cpio_list | gen_dir_ents | sort -u | gen_depfile 3>initramfs.d | "${scriptdir}"/gen_init_cpio -t 0 - | xz --x86 --lzma2=preset=9e --check=crc32 -c > initramfs.img
+
+# vim:ft=sh: