From e0d3d1530fba55dea7e78ae2b0096214eb694743 Mon Sep 17 00:00:00 2001 From: Pablo Castellano Date: Sun, 20 Aug 2017 21:45:26 +0200 Subject: [PATCH] Close #362: Add deviceinfo to initramfs (#394) * Added deviceinfo to initramfs * init.sh.in: removed @MODULES@ variable * Add and describe new copy_files parameter for changing file mode bits --- main/postmarketos-mkinitfs/APKBUILD | 6 +++--- main/postmarketos-mkinitfs/init.sh.in | 5 ++++- main/postmarketos-mkinitfs/mkinitfs.sh | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/main/postmarketos-mkinitfs/APKBUILD b/main/postmarketos-mkinitfs/APKBUILD index 2b54aaf5d..356e2fb4a 100644 --- a/main/postmarketos-mkinitfs/APKBUILD +++ b/main/postmarketos-mkinitfs/APKBUILD @@ -1,6 +1,6 @@ pkgname=postmarketos-mkinitfs pkgver=0.3.3 -pkgrel=3 +pkgrel=4 pkgdesc="Tool to generate initramfs images for postmarketOS" url="https://github.com/postmarketOS" # multipath-tools: kpartx @@ -25,6 +25,6 @@ package() { "$pkgdir/sbin/mkinitfs" mkdir -p "$pkgdir/etc/postmarketos-mkinitfs/hooks/" } -sha512sums="95e49eb5e7891d319543165290fb7279733e696db8c768d864d87ef36a20b04e1c4e8a1702a2927e7492ea2e9f3d4fdd83d9ea55811969689b9c2483fb3b44c4 init.sh.in +sha512sums="8607f772b1e5854cde27f6d7df3ce083095eb2e13d13c5ef59f0b5820777220cd0f22019a888e5aa884a8833646813e85bf4e94fbe2182a957ec528cc5bee355 init.sh.in 2331fe9a89ba58348b41fbfdeb6f4daeff3f6ef161d1b7582c3e900baba377fa9411efa0b052ea5c2ae22f75bc48f6b8f38dafad0bd836a0319906e70482898c init_functions.sh -8b61ecc989f32ed49b34463d457e8506b267af9af5a9f42639354506c27e858517a9e954a62c808bbd114fd31c9628e263bb5ed4d7b754c65d4aea33675ca0ad mkinitfs.sh" +c844c15fe19ff63e6578cf06d183e0f7178f429e341296e7cdb16674fbf8795e9ffcf9b292c3437cf817dc0199725bd74255b254ecaa77c5f3176c85508933e1 mkinitfs.sh" diff --git a/main/postmarketos-mkinitfs/init.sh.in b/main/postmarketos-mkinitfs/init.sh.in index 2c78b63e7..c19dfb1ff 100644 --- a/main/postmarketos-mkinitfs/init.sh.in +++ b/main/postmarketos-mkinitfs/init.sh.in @@ -1,4 +1,6 @@ #!/bin/sh +# shellcheck disable=SC1091 +. /etc/deviceinfo . ./init_functions.sh export PATH=/usr/bin:/bin:/usr/sbin:/sbin @@ -8,7 +10,8 @@ export PATH=/usr/bin:/bin:/usr/sbin:/sbin # Mount everything, set up logging, modules, mdev mount_proc_sys_dev setup_log -[ -d /lib/modules ] && modprobe -a @MODULES@ +# shellcheck disable=SC2154 +[ -d /lib/modules ] && modprobe -a "${deviceinfo_modules_initfs} ext4" setup_mdev mount_subpartitions diff --git a/main/postmarketos-mkinitfs/mkinitfs.sh b/main/postmarketos-mkinitfs/mkinitfs.sh index 55e852814..98cd64d9c 100644 --- a/main/postmarketos-mkinitfs/mkinitfs.sh +++ b/main/postmarketos-mkinitfs/mkinitfs.sh @@ -127,11 +127,13 @@ get_binaries_extra() # FIXME: this is a performance bottleneck # $1: files # $2: destination +# $3: file mode bits (as in chmod), default: 755 copy_files() { + mode="${3:-755}" for file in $1; do [ -e "$file" ] || continue - install -Dm755 "$file" "$2$file" + install -Dm$mode "$file" "$2$file" done } @@ -144,7 +146,6 @@ create_device_nodes() replace_init_variables() { - sed -i "s:@MODULES@:${deviceinfo_modules_initfs} ext4:g" "$tmpdir/init" sed -i "s:@INITRAMFS_EXTRA@:${outfile_extra}:g" "$tmpdir/init" } @@ -251,6 +252,7 @@ tmpdir=$(mktemp -d /tmp/mkinitfs.XXXXXX) create_folders copy_files "$(get_modules)" "$tmpdir" copy_files "$(get_binaries)" "$tmpdir" +copy_files "/etc/deviceinfo" "$tmpdir" "644" copy_files "/etc/postmarketos-mkinitfs/hooks/*.sh" "$tmpdir" create_device_nodes ln -s "/bin/busybox" "$tmpdir/bin/sh"