summaryrefslogtreecommitdiff
path: root/sys-boot
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2019-10-23 11:39:36 +0200
committerKarel Kočí <karel.koci@nic.cz>2019-10-23 11:39:36 +0200
commiteb94c731605c3bf2064e75fb7b9499c4618516a9 (patch)
treea077be871e44016645631c4c4691a56464ea20ea /sys-boot
parent239024d73497ad30d8cf468678bc71cd41a8218c (diff)
downloadgentoo-personal-overlay-eb94c731605c3bf2064e75fb7b9499c4618516a9.tar.gz
gentoo-personal-overlay-eb94c731605c3bf2064e75fb7b9499c4618516a9.tar.bz2
gentoo-personal-overlay-eb94c731605c3bf2064e75fb7b9499c4618516a9.zip
x11-boot/myinitramfs: drop root and wait for UUID drive
Diffstat (limited to 'sys-boot')
-rwxr-xr-xsys-boot/myinitramfs/files/gen.sh6
-rwxr-xr-xsys-boot/myinitramfs/files/init.enc23
-rw-r--r--sys-boot/myinitramfs/myinitramfs-1.4.3-r1.ebuild (renamed from sys-boot/myinitramfs/myinitramfs-1.4.2-r1.ebuild)0
3 files changed, 13 insertions, 16 deletions
diff --git a/sys-boot/myinitramfs/files/gen.sh b/sys-boot/myinitramfs/files/gen.sh
index b633731..916ba84 100755
--- a/sys-boot/myinitramfs/files/gen.sh
+++ b/sys-boot/myinitramfs/files/gen.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/ash
set -e
OUT="$(readlink -f "$1")"
@@ -14,11 +14,11 @@ cp baselist "$LIST"
echo "file /init ./init.enc 755 0 0" >> "$LIST"
echo >> "$LIST"
# Executables
-while read EXE; do
+while read -r 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
+ ldd "$P" | awk '{ print $3 }' | sed -n '/^[^ ]\+$/p' | while read -r LIB; do
echo "file $LIB $LIB 755 0 0" >> "$LIST"
done
done <exelist
diff --git a/sys-boot/myinitramfs/files/init.enc b/sys-boot/myinitramfs/files/init.enc
index 9fcde55..b1cd3a2 100755
--- a/sys-boot/myinitramfs/files/init.enc
+++ b/sys-boot/myinitramfs/files/init.enc
@@ -1,4 +1,4 @@
-#!/bin/busybox sh
+#!/bin/busybox ash
# vim:ft=sh
# Init must have pid 1 otherwise switch_root won't work.
@@ -42,17 +42,14 @@ busybox mount -t sysfs none /sys || fail "/sys mount failed!"
busybox mount -t devtmpfs none /dev || fail "/dev mount failed!"
# Now open and mount root
-root=""
+uuid=""
rootflags=""
recovery=false
for opt in $(cat /proc/cmdline); do
case "$opt" in
- root=*)
- root=${opt:5}
- ;;
rootuuid=*)
- root="$(blkid | awk "/UUID=\"${opt:9}\"/{ print \$1 }" | tr -d ':')"
+ uuid="${opt:9}"
;;
rootflags=*)
rootflags=${opt:10}
@@ -60,7 +57,7 @@ for opt in $(cat /proc/cmdline); do
recovery)
recovery=true
;;
- BOOT_IMAGE=*|initrd=*)
+ BOOT_IMAGE=*|initrd=*|fbcon=*)
# Ignore those
;;
*)
@@ -71,19 +68,19 @@ done
$recovery && fail "Requested recovery."
-[ -z "$root" ] && fail "Missing root argument!"
+[ -z "$uuid" ] && fail "Missing rootuuid argument!"
-echo -ne "${C_GRAY}Waiting for root ($root)..."
+echo -ne "${C_GRAY}Waiting for root ($uuid)..."
CNT=10
-while [ ! -e "$root" ] && [ $CNT -gt 0 ]; do
- CNT=$(expr $CNT - 1)
+while [ $CNT -gt 0 ] && ! blkid | grep -q "UUID=\"$uuid\""; do
+ CNT=$((CNT - 1))
sleep 1
echo -n " $CNT"
done
echo -e "${C_NO}"
-[ -e "$root" ] || fail "Root not located!"
-# TODO mount boot parition and look for key saved there (on unlock remove it)
+root="$(blkid | awk -v uuid="UUID=\"$uuid\"" '$2 == uuid { gsub(/:$/,"",$1); print $1 }')"
+[ -e "$root" ] || fail "Root not located!"
echo -e "${C_GREEN}Unlocking root...${C_NO}"
cryptsetup open "$root" encroot || fail "Unlocking root failed! /proc/cmdline=$(cat /proc/cmdline)"
diff --git a/sys-boot/myinitramfs/myinitramfs-1.4.2-r1.ebuild b/sys-boot/myinitramfs/myinitramfs-1.4.3-r1.ebuild
index e31efdc..e31efdc 100644
--- a/sys-boot/myinitramfs/myinitramfs-1.4.2-r1.ebuild
+++ b/sys-boot/myinitramfs/myinitramfs-1.4.3-r1.ebuild