summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-03-28 14:50:51 +0200
committerKarel Kočí <cynerd@email.cz>2018-03-28 14:50:51 +0200
commitbad466c064eac4a2d6e2a3eb1729fa52413fb305 (patch)
tree274b62c91b0c9412a02f9b88e84d3d3e30884fe0
parentd45b8f991744d270273065de46127b41a7b93397 (diff)
downloadgentoo-personal-overlay-bad466c064eac4a2d6e2a3eb1729fa52413fb305.tar.gz
gentoo-personal-overlay-bad466c064eac4a2d6e2a3eb1729fa52413fb305.tar.bz2
gentoo-personal-overlay-bad466c064eac4a2d6e2a3eb1729fa52413fb305.zip
New version of myinitramfs (1.3)
This changes how initramfs is generated. It generates list dynamically.
-rw-r--r--sys-boot/myinitramfs/files/baselist21
-rw-r--r--sys-boot/myinitramfs/files/exelist2
-rwxr-xr-xsys-boot/myinitramfs/files/gen.sh47
-rw-r--r--sys-boot/myinitramfs/files/list35
-rw-r--r--sys-boot/myinitramfs/myinitramfs-1.3-r1.ebuild (renamed from sys-boot/myinitramfs/myinitramfs-1.2-r2.ebuild)13
5 files changed, 72 insertions, 46 deletions
diff --git a/sys-boot/myinitramfs/files/baselist b/sys-boot/myinitramfs/files/baselist
new file mode 100644
index 0000000..ee06cf5
--- /dev/null
+++ b/sys-boot/myinitramfs/files/baselist
@@ -0,0 +1,21 @@
+# Dirs
+dir /bin 755 0 0
+dir /dev 755 0 0
+dir /etc 755 0 0
+dir /lib 755 0 0
+dir /lib64 755 0 0
+dir /mnt 755 0 0
+dir /mnt/root 755 0 0
+dir /proc 755 0 0
+dir /root 755 0 0
+dir /sbin 755 0 0
+dir /sys 755 0 0
+dir /usr 755 0 0
+dir /usr/lib64 755 0 0
+
+# Ld
+file /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2 755 0 0
+
+# Busybox
+file /bin/busybox /bin/busybox 755 0 0
+
diff --git a/sys-boot/myinitramfs/files/exelist b/sys-boot/myinitramfs/files/exelist
new file mode 100644
index 0000000..39329f9
--- /dev/null
+++ b/sys-boot/myinitramfs/files/exelist
@@ -0,0 +1,2 @@
+cryptsetup
+btrfs
diff --git a/sys-boot/myinitramfs/files/gen.sh b/sys-boot/myinitramfs/files/gen.sh
new file mode 100755
index 0000000..3341d93
--- /dev/null
+++ b/sys-boot/myinitramfs/files/gen.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+set -e
+
+OUT="$(readlink -f "$1")"
+shift
+
+cd "$(dirname "$(readlink -f "$0")")"
+
+INIT="./init.plain"
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ encrypted)
+ INIT="./init.enc"
+ ;;
+ esac
+ shift
+done
+
+LIST="$(mktemp)"
+
+# Base list
+cp baselist "$LIST"
+# Init script
+echo "file /init $INIT 755 0 0" >> "$LIST"
+echo >> "$LIST"
+# Executables
+while read EXE; do
+ P="$(which "$EXE")"
+ echo "# $EXE" >> "$LIST"
+ echo "file $P $P 755 0 0" >> "$LIST"
+ ldd "$P" | awk '{ print $3 }' | sed -n '/^[^ ]\+$/p' | while read LIB; do
+ echo "file $LIB $LIB 755 0 0" >> "$LIST"
+ done
+done <exelist
+
+# Print current list
+cat "$LIST"
+
+# Buld initramfs
+CPIO="$(mktemp)"
+gen_init_cpio "$LIST" > "$CPIO"
+gzip "$CPIO"
+mv "$CPIO.gz" "$OUT"
+
+# Cleaup
+rm "$LIST"
diff --git a/sys-boot/myinitramfs/files/list b/sys-boot/myinitramfs/files/list
deleted file mode 100644
index 9645521..0000000
--- a/sys-boot/myinitramfs/files/list
+++ /dev/null
@@ -1,35 +0,0 @@
-# Dirs
-dir /bin 755 0 0
-dir /dev 755 0 0
-dir /etc 755 0 0
-dir /lib 755 0 0
-dir /lib64 755 0 0
-dir /mnt 755 0 0
-dir /mnt/root 755 0 0
-dir /proc 755 0 0
-dir /root 755 0 0
-dir /sbin 755 0 0
-dir /sys 755 0 0
-
-# Binaries
-file /bin/busybox /bin/busybox 755 0 0
-file /sbin/cryptsetup /sbin/cryptsetup 755 0 0
-file /sbin/btrfs /sbin/btrfs 755 0 0
-
-# Ld
-file /lib64/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2 755 0 0
-# Libraries
-file /lib64/libblkid.so.1 /lib64/libblkid.so.1 755 0 0
-file /lib64/libc.so.6 /lib64/libc.so.6 755 0 0
-file /lib64/libdevmapper.so.1.02 /lib64/libdevmapper.so.1.02 755 0 0
-file /lib64/liblzo2.so.2 /lib64/liblzo2.so.2 755 0 0
-file /lib64/libm.so.6 /lib64/libm.so.6 755 0 0
-file /lib64/libpthread.so.0 /lib64/libpthread.so.0 755 0 0
-file /lib64/librt.so.1 /lib64/librt.so.1 755 0 0
-file /lib64/libudev.so.1 /lib64/libudev.so.1 755 0 0
-file /lib64/libuuid.so.1 /lib64/libuuid.so.1 755 0 0
-file /lib64/libz.so.1 /lib64/libz.so.1 755 0 0
-file /lib64/libcryptsetup.so.4 /usr/lib64/libcryptsetup.so.4 755 0 0
-file /lib64/libgcrypt.so.20 /usr/lib64/libgcrypt.so.20 755 0 0
-file /lib64/libgpg-error.so.0 /usr/lib64/libgpg-error.so.0 755 0 0
-file /lib64/libpopt.so.0 /usr/lib64/libpopt.so.0 755 0 0
diff --git a/sys-boot/myinitramfs/myinitramfs-1.2-r2.ebuild b/sys-boot/myinitramfs/myinitramfs-1.3-r1.ebuild
index ebdc6c5..eec0d8c 100644
--- a/sys-boot/myinitramfs/myinitramfs-1.2-r2.ebuild
+++ b/sys-boot/myinitramfs/myinitramfs-1.3-r1.ebuild
@@ -19,8 +19,7 @@ DEPEND="sys-fs/cryptsetup
sys-fs/btrfs-progs
sys-apps/linux-misc-apps
sys-apps/busybox[static]"
-RDEPEND="${DEPENDS}
-sys-kernel/linux[initramfs]"
+RDEPEND="sys-kernel/linux[initramfs]"
src_unpack() {
# Well we have no sources so just create empty directory
@@ -28,15 +27,7 @@ src_unpack() {
}
src_compile() {
- # TODO generate list dynamically
- cp "${FILESDIR}"/list list
- if use encrypted; then
- echo "file /init ${FILESDIR}/init.enc 755 0 0" >> list
- else
- echo "file /init ${FILESDIR}/init.plain 755 0 0" >> list
- fi
- gen_init_cpio list > initramfs.cpio
- gzip initramfs.cpio
+ "${FILESDIR}/gen.sh" initramfs-gentoo $(usev encrypted)
}
src_install() {