propagator/mkinitfs
Sergey Bolshakov 11bf8de59c thinkos fixed
2008-03-07 22:48:01 +03:00

64 lines
1.3 KiB
Bash
Executable File

#!/bin/sh -e
out=$1
shift
[ -n "$out" ] || {
echo "Usage: mkinitfs outfile" >&2
exit 1
}
exit_handler()
{
local rc=$?
trap - EXIT
[ $rc -eq 0 ] || rm -f -- $out
exit $rc
}
trap exit_handler HUP PIPE INT TERM QUIT EXIT
(
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
dir /sbin 0755 0 0
file /sbin/modprobe /lib/mkinitrd/module-init-tools/sbin/modprobe 0755 0 0
file /sbin/stage1 stage1 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 - |gzip -c > $out