propagator/mkinitfs

83 lines
1.8 KiB
Plaintext
Raw Normal View History

#!/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."
udevd="/lib/mkinitrd/udev/sbin/udevd"
[ -x "$udevd" ] && {
udev_version="$($udevd --version 2>/dev/null)"
printf '%s\n' "${udev_version:-105}" > udev_version
} || {
Fatal "$udevd doesn't exists or not executable"
}
(
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
2008-03-16 02:24:39 +03:00
dir /lib64 0755 0 0
dir /lib/udev 0755 0 0
2008-03-07 22:48:01 +03:00
dir /lib/modules 0755 0 0
dir /bin 0755 0 0
file /bin/sh /lib/mkinitrd/busybox 0755 0 0
2008-03-13 19:12:12 +03:00
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
file /.udev_version udev_version 0644 0 0
EOF
2008-03-16 02:24:39 +03:00
find /lib/mkinitrd/klibc -xtype f -name klibc\*.so|\
sed -e 's,^.\+/\([^\/]\+/[^\/]\+\)$,file\t/\1\t&\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"