Commits

Mike Gilbert committed 89a0a01

Consolidate getlibs into initrafms.sh

  • Participants
  • Parent commits bfeabf2

Comments (0)

Files changed (3)

 initramfs.img: initramfs.txt init
 	$(GEN_INIT_CPIO) initramfs.txt | gzip > initramfs.img
 
-initramfs.txt: initramfs.sh getlibs
+initramfs.txt: initramfs.sh
 	./initramfs.sh > initramfs.txt
 
 .PHONY: install

File getlibs

-#!/bin/sh
-# vim:sw=4 ts=4 noet
-
-depfile=$(mktemp)
-
-for x; do
-	ldd "$x" | awk '
-	$1 ~ /^\// { print $1 }
-	$2 == "=>" { print $3 }
-	' >> "${depfile}"
-done
-
-libs=$(sort -u "${depfile}")
-rm -f "${depfile}"
-
-for libname in ${libs}; do
-	basename=${libname##*/}
-	dirname=${libname%/*}
-	libdir=${dirname##*/}
-	printf "file\t%s\t%s\t0755 0 0\n" "/${libdir}/${basename}" "${libname}"
-done

File initramfs.sh

 #!/bin/sh
 dirname=${0%/*}
 init=${dirname}/init
-getlibs=${dirname}/getlibs
+
+getlibs() {
+	depfile="$(mktemp)"
+
+	for x; do
+		ldd "$x" | awk '
+		$1 ~ /^\// { print $1 }
+		$2 == "=>" { print $3 }
+		' >> "${depfile}"
+	done
+
+	libs="$(sort -u "${depfile}")"
+	rm -f "${depfile}"
+
+	for libname in ${libs}; do
+		basename=${libname##*/}
+		dirname=${libname%/*}
+		libdir=${dirname##*/}
+		printf "file\t%s\t%s\t0755 0 0\n" "/${libdir}/${basename}" "${libname}"
+	done
+}
+
 cat <<EOF
 # Basic initramfs
 # vim:tw=0 ts=8 noet
 file	/bin/btrfs	/sbin/btrfs	0755 0 0
 
 EOF
-"${getlibs}" /bin/busybox /sbin/btrfs
+getlibs /bin/busybox /sbin/btrfs