88 lines
2.0 KiB
Bash
Executable File
88 lines
2.0 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."
|
|
|
|
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 /lib 0755 0 0
|
|
dir /lib64 0755 0 0
|
|
dir /lib/udev 0755 0 0
|
|
dir /lib/udev/rules.d 0755 0 0
|
|
dir /lib/modules 0755 0 0
|
|
dir /lib/firmware 0755 0 0
|
|
|
|
dir /bin 0755 0 0
|
|
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
|
|
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
|
|
|
|
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/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|\
|
|
sed -e 's,^.\+$,file\t&\t&\t0644\t0 0,g'
|
|
) | `pwd`/gencpio - > "$TEMP"
|
|
|
|
gzip -c < "$TEMP" > "$OUT"
|