2008-03-01 22:02:06 +03:00
#!/bin/sh -e
2008-03-14 17:59:18 +03:00
PROG=mkinitfs
2008-03-01 22:02:06 +03:00
2008-03-14 17:59:18 +03:00
Fatal()
{
echo "$PROG: $*" >&2
2008-03-01 22:02:06 +03:00
exit 1
}
2008-03-14 17:59:18 +03:00
TEMP=
2008-03-01 22:02:06 +03:00
exit_handler()
{
local rc=$?
trap - EXIT
2008-03-14 17:59:18 +03:00
[ -z "$TEMP" ] || rm -f -- "$TEMP"
[ $rc -eq 0 ] || rm -f -- "$OUT"
2008-03-01 22:02:06 +03:00
exit $rc
}
2008-03-14 17:59:18 +03:00
[ -n "$1" ] || Fatal "Usage: mkinitfs outfile"
OUT="$1"; shift
2008-03-01 22:02:06 +03:00
trap exit_handler HUP PIPE INT TERM QUIT EXIT
2008-03-14 17:59:18 +03:00
TEMP=`mktemp -t mkinitfs.XXXXXXXXXX` || Fatal "Failed to create temporary file."
2008-03-01 22:02:06 +03:00
2008-06-13 01:03:01 +04:00
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"
}
2008-03-01 22:02:06 +03:00
(
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 /lib 0755 0 0
2008-03-16 02:24:39 +03:00
dir /lib64 0755 0 0
2008-03-01 22:02:06 +03:00
dir /lib/udev 0755 0 0
2008-09-03 21:39:12 +04:00
dir /lib/udev/rules.d 0755 0 0
2008-03-07 22:48:01 +03:00
dir /lib/modules 0755 0 0
2010-07-01 23:50:37 +04:00
dir /lib/firmware 0755 0 0
2008-03-01 22:02:06 +03:00
dir /bin 0755 0 0
2008-12-15 13:20:08 +03:00
file /bin/sh /lib/mkinitrd/klibc/bin/sh 0755 0 0
file /bin/mount /lib/mkinitrd/klibc/bin/mount 0755 0 0
file /bin/umount /lib/mkinitrd/klibc/bin/umount 0755 0 0
2008-03-13 19:12:12 +03:00
file /bin/nfsmount /lib/mkinitrd/klibc/bin/nfsmount 0755 0 0
2008-03-01 22:02:06 +03:00
dir /sbin 0755 0 0
file /sbin/modprobe /lib/mkinitrd/module-init-tools/sbin/modprobe 0755 0 0
file /init init 0755 0 0
2008-06-13 01:03:01 +04:00
file /.udev_version udev_version 0644 0 0
2008-03-01 22:02:06 +03:00
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'
2008-03-01 22:02:06 +03:00
find /lib/mkinitrd/udev -type f|\
sed -e 's,/lib/mkinitrd/udev,,' -e 's,^.\+$,file\t&\t/lib/mkinitrd/udev&\t0755\t0 0,g'
2008-09-03 21:39:12 +04:00
find /etc/udev/initramfs-rules.d/ -xtype f|\
sed -e 's,^.\+rules\.d\(.\+\)$,file\t/lib/udev/rules.d\1\t&\t0644\t0 0,g'
find /etc/modprobe.d/ -type f|\
2008-03-01 22:02:06 +03:00
sed -e 's,^.\+$,file\t&\t&\t0644\t0 0,g'
2008-03-14 17:59:18 +03:00
) | `pwd`/gencpio - > "$TEMP"
gzip -c < "$TEMP" > "$OUT"