From bad466c064eac4a2d6e2a3eb1729fa52413fb305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Wed, 28 Mar 2018 14:50:51 +0200 Subject: New version of myinitramfs (1.3) This changes how initramfs is generated. It generates list dynamically. --- sys-boot/myinitramfs/files/baselist | 21 ++++++++++++ sys-boot/myinitramfs/files/exelist | 2 ++ sys-boot/myinitramfs/files/gen.sh | 47 ++++++++++++++++++++++++++ sys-boot/myinitramfs/files/list | 35 ------------------- sys-boot/myinitramfs/myinitramfs-1.2-r2.ebuild | 46 ------------------------- sys-boot/myinitramfs/myinitramfs-1.3-r1.ebuild | 37 ++++++++++++++++++++ 6 files changed, 107 insertions(+), 81 deletions(-) create mode 100644 sys-boot/myinitramfs/files/baselist create mode 100644 sys-boot/myinitramfs/files/exelist create mode 100755 sys-boot/myinitramfs/files/gen.sh delete mode 100644 sys-boot/myinitramfs/files/list delete mode 100644 sys-boot/myinitramfs/myinitramfs-1.2-r2.ebuild create mode 100644 sys-boot/myinitramfs/myinitramfs-1.3-r1.ebuild (limited to 'sys-boot') 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 "$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.2-r2.ebuild deleted file mode 100644 index ebdc6c5..0000000 --- a/sys-boot/myinitramfs/myinitramfs-1.2-r2.ebuild +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright 1999-2017 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -# TODO support encrytion and btrfs only as option - -EAPI=6 - -VER="${PV%-r*}" - -DESCRIPTION="My personal initramfs (verry simple with encryption support)" -S="${WORKDIR}/myinitramfs-${VER}" - -LICENSE="GPLv2" -SLOT="0" -KEYWORDS="amd64 x86" -IUSE="+encrypted" - -DEPEND="sys-fs/cryptsetup -sys-fs/btrfs-progs -sys-apps/linux-misc-apps -sys-apps/busybox[static]" -RDEPEND="${DEPENDS} -sys-kernel/linux[initramfs]" - -src_unpack() { - # Well we have no sources so just create empty directory - mkdir -p "${S}" -} - -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 -} - -src_install() { - dodir /boot - insinto /boot - newins initramfs.cpio.gz initramfs-gentoo -} diff --git a/sys-boot/myinitramfs/myinitramfs-1.3-r1.ebuild b/sys-boot/myinitramfs/myinitramfs-1.3-r1.ebuild new file mode 100644 index 0000000..eec0d8c --- /dev/null +++ b/sys-boot/myinitramfs/myinitramfs-1.3-r1.ebuild @@ -0,0 +1,37 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +# TODO support encrytion and btrfs only as option + +EAPI=6 + +VER="${PV%-r*}" + +DESCRIPTION="My personal initramfs (verry simple with encryption support)" +S="${WORKDIR}/myinitramfs-${VER}" + +LICENSE="GPLv2" +SLOT="0" +KEYWORDS="amd64 x86" +IUSE="+encrypted" + +DEPEND="sys-fs/cryptsetup +sys-fs/btrfs-progs +sys-apps/linux-misc-apps +sys-apps/busybox[static]" +RDEPEND="sys-kernel/linux[initramfs]" + +src_unpack() { + # Well we have no sources so just create empty directory + mkdir -p "${S}" +} + +src_compile() { + "${FILESDIR}/gen.sh" initramfs-gentoo $(usev encrypted) +} + +src_install() { + dodir /boot + insinto /boot + newins initramfs.cpio.gz initramfs-gentoo +} -- cgit v1.2.3