summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2020-11-16 12:17:54 -0500
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2020-11-16 12:17:54 -0500
commit83f429c4e64a04faba57ccf5fb1106811cab77b1 (patch)
tree2ffa62d97d18f264f7ba7fbefca0e561f7439a66
parent3cec6d5f41929f8d440c92c56d99ba11468487b7 (diff)
downloadminitramfs-83f429c4e64a04faba57ccf5fb1106811cab77b1.tar.xz
minitramfs-83f429c4e64a04faba57ccf5fb1106811cab77b1.zip
make: add comments, simplify
-rwxr-xr-xmake24
1 files changed, 13 insertions, 11 deletions
diff --git a/make b/make
index 9d7ae95..09433f7 100755
--- a/make
+++ b/make
@@ -2,30 +2,36 @@
# generate a cpio entry for a command
gen_cmd() {
- cmd=$1
- cmdp="$(command -v "$cmd")" || exit 1
- # ignore builtins
- [ "$cmd" != "$cmdp" ] || return
+ cmdp="$(command -v "$1")" || exit 1
printf 'file %s %s 0755 0 0\n' "$cmdp" "$cmdp"
+
+ # ELF interpreter handled in cpio_list.txt
ldd "$cmdp" | awk '/=>/ { print "file /lib64/" $1 " " $3 " 0755 0 0" }'
}
# generate the main file list
gen_cpio_list() {
+ # static entries
sed -e '/^#/d' cpio_list.txt
+
+ # modules
tr ' ' '\n' < modules.dep | sed -e "s/://;s:.*:file /lib/modules/$KERNVER/& /lib/modules/$KERNVER/& 0644 0 0:"
+
+ # commands
gen_cmd e2fsck
gen_cmd dropbear
gen_cmd cryptsetup
+
+ # cryptsetup needs libgcc_s.so.1 for pthread_cancel
ldconfig -p | awk '$1 == "libgcc_s.so.1" && $2 ~ /x86-64/ { print "file /lib64/" $1 " " $4 " 0755 0 0" }'
}
-# filter the list and insert parent directory entries
+# insert parent directory entries
gen_dir_ents() {
- awk '{print; while (sub("/[^/]*$", "", $2) && $2) print "dir " $2 " 0755 0 0"; }'
+ awk '{ print; while (sub("/[^/]*$", "", $2) && $2) print "dir " $2 " 0755 0 0" }'
}
-# filter the list and generate the make dependency file
+# generate the make dependency file
gen_depfile() {
awk -v f=/dev/fd/3 -v deps="cpio_list.txt make" '
{ print }
@@ -34,8 +40,4 @@ gen_depfile() {
'
}
-if ! [ -e cpio_list.txt ] || ! [ -e gen_init_cpio ]; then
- cd "${0%/*}"
-fi
-
gen_cpio_list | gen_dir_ents | sort -u | gen_depfile 3>initramfs.d | ./gen_init_cpio -t 0 - | $COMPRESSOR > initramfs.img