73 lines
1.5 KiB
Bash
Executable File
73 lines
1.5 KiB
Bash
Executable File
#!/bin/sh -e
|
|
|
|
PROG=mkinitfs
|
|
|
|
Fatal()
|
|
{
|
|
echo "$PROG: $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
TEMP=
|
|
|
|
exit_handler()
|
|
{
|
|
local rc=$?
|
|
trap - EXIT
|
|
[ -z "$TEMP" ] || rm -f -- "$TEMP"
|
|
[ $rc -eq 0 ] || rm -f -- "$OUT"
|
|
exit $rc
|
|
}
|
|
|
|
[ -n "$1" ] || Fatal "Usage: mkinitfs outfile"
|
|
OUT="$1"; shift
|
|
|
|
trap exit_handler HUP PIPE INT TERM QUIT EXIT
|
|
TEMP=`mktemp -t mkinitfs.XXXXXXXXXX` || Fatal "Failed to create temporary file."
|
|
|
|
(
|
|
|
|
cat <<EOF
|
|
dir /dev 0755 0 0
|
|
dir /image 0755 0 0
|
|
dir /proc 0755 0 0
|
|
dir /sys 0755 0 0
|
|
dir /root 0755 0 0
|
|
dir /tmp 0755 0 0
|
|
dir /var 0755 0 0
|
|
dir /var/lock 0755 0 0
|
|
|
|
dir /etc 0755 0 0
|
|
dir /etc/modprobe.d 0755 0 0
|
|
|
|
dir /etc/terminfo 0755 0 0
|
|
dir /etc/terminfo/l 0755 0 0
|
|
file /etc/terminfo/l/linux /lib/terminfo/l/linux 0644 0 0
|
|
|
|
dir /etc/udev 0755 0 0
|
|
dir /etc/udev/rules.d 0755 0 0
|
|
|
|
dir /lib 0755 0 0
|
|
dir /lib/udev 0755 0 0
|
|
dir /lib/modules 0755 0 0
|
|
|
|
dir /bin 0755 0 0
|
|
file /bin/sh /lib/mkinitrd/busybox 0755 0 0
|
|
file /bin/nfsmount /lib/mkinitrd/klibc/bin/nfsmount 0755 0 0
|
|
|
|
dir /sbin 0755 0 0
|
|
file /sbin/modprobe /lib/mkinitrd/module-init-tools/sbin/modprobe 0755 0 0
|
|
|
|
file /init init 0755 0 0
|
|
EOF
|
|
|
|
find /lib/mkinitrd/klibc/lib -xtype f|\
|
|
sed -e 's,/lib/mkinitrd/klibc,,' -e 's,^.\+$,file\t&\t/lib/mkinitrd/klibc&\t0755\t0 0,g'
|
|
find /lib/mkinitrd/udev -type f|\
|
|
sed -e 's,/lib/mkinitrd/udev,,' -e 's,^.\+$,file\t&\t/lib/mkinitrd/udev&\t0755\t0 0,g'
|
|
find /etc/modprobe.d/ /etc/udev/rules.d -type f|\
|
|
sed -e 's,^.\+$,file\t&\t&\t0644\t0 0,g'
|
|
) | `pwd`/gencpio - > "$TEMP"
|
|
|
|
gzip -c < "$TEMP" > "$OUT"
|