44 |
|
|
45 |
CONFMODS="${MODULES}" |
CONFMODS="${MODULES}" |
46 |
MODULES="" |
MODULES="" |
47 |
|
INITEXEC="/sbin/init" |
48 |
|
|
49 |
compress=1 |
compress=1 |
50 |
allowmissing="" |
allowmissing="" |
77 |
echo " [--image-version] [--force-scsi-probe | --omit-raid-modules]" |
echo " [--image-version] [--force-scsi-probe | --omit-raid-modules]" |
78 |
echo " [--with=<module>] [--force-lvm-probe | --omit-lvm-modules]" |
echo " [--with=<module>] [--force-lvm-probe | --omit-lvm-modules]" |
79 |
echo " [--builtin=<module>] [--initramfs | --loopback] [--no-strip]" |
echo " [--builtin=<module>] [--initramfs | --loopback] [--no-strip]" |
80 |
echo " [--fstab=<fstab>] [--nocompress] <initrd-image> <kernel-version>" |
echo " [--fstab=<fstab>] [--nocompress] [--initexec=<init>]" |
81 |
|
echo " <initrd-image> <kernel-version>" |
82 |
echo |
echo |
83 |
echo " (ex: $(basename $0) /boot/initrd-2.2.5-15.img 2.2.5-15)" |
echo " (ex: $(basename $0) /boot/initrd-2.2.5-15.img 2.2.5-15)" |
84 |
|
|
417 |
--initramfs) IMAGE_TYPE=initramfs ;; |
--initramfs) IMAGE_TYPE=initramfs ;; |
418 |
--loopback) IMAGE_TYPE=loopback ;; |
--loopback) IMAGE_TYPE=loopback ;; |
419 |
--no-strip) NOSTRIP=true ;; |
--no-strip) NOSTRIP=true ;; |
420 |
|
--initexec*) |
421 |
|
if echo $1 | grep -q '=' ; then |
422 |
|
INITEXEC=$(echo $1 | sed 's/^--initexec=//') |
423 |
|
else |
424 |
|
INITEXEC=$2 |
425 |
|
shift |
426 |
|
fi |
427 |
|
;; |
428 |
*) |
*) |
429 |
if [ -z "${target}" ] |
if [ -z "${target}" ] |
430 |
then |
then |
846 |
done |
done |
847 |
fi |
fi |
848 |
|
|
849 |
|
# get the right initexec |
850 |
|
add_initrd "INITEXEC=\"${INITEXEC}\"" |
851 |
|
# support init=* from cmdline |
852 |
|
add_initrd 'for i in $(cat /proc/cmdline); do if [[ ${i} = init=* ]]; then INITEXEC=${i/init=}; fi; done' |
853 |
|
|
854 |
add_initrd 'echo "-- Mounting sysroot ..."' |
add_initrd 'echo "-- Mounting sysroot ..."' |
855 |
add_initrd '. /etc/rootdev' |
add_initrd '. /etc/rootdev' |
856 |
add_initrd 'echo "${device} /sysroot ${rootfs} defaults,ro 0 0" > /etc/fstab' |
add_initrd 'echo "${device} /sysroot ${rootfs} defaults,ro 0 0" > /etc/fstab' |
867 |
add_initrd 'umount /sys' |
add_initrd 'umount /sys' |
868 |
add_initrd 'umount /proc' |
add_initrd 'umount /proc' |
869 |
|
|
870 |
[[ ${IMAGE_TYPE} = initramfs ]] && add_initrd 'exec run-init /sysroot /sbin/init $@ </sysroot/dev/console >/sysroot/dev/console' |
[[ ${IMAGE_TYPE} = initramfs ]] && add_initrd 'exec run-init /sysroot ${INITEXEC} $@ </sysroot/dev/console >/sysroot/dev/console' |
871 |
if [[ ${IMAGE_TYPE} = loopback ]] |
if [[ ${IMAGE_TYPE} = loopback ]] |
872 |
then |
then |
873 |
add_initrd 'cd /sysroot' |
add_initrd 'cd /sysroot' |
874 |
add_initrd 'pivot_root . initrd' |
add_initrd 'pivot_root . initrd' |
875 |
add_initrd "exec /sbin/chroot . sh -c 'umount -n /initrd >/dev/null 2>&1;exec -a init.new /sbin/init'</dev/console >/dev/console 2>&1" |
add_initrd "exec /sbin/chroot . sh -c 'umount -n /initrd >/dev/null 2>&1;exec -a init.new \${INITEXEC}'</dev/console >/dev/console 2>&1" |
876 |
fi |
fi |
877 |
|
|
878 |
chmod +x ${DEST}/init || die |
chmod +x ${DEST}/init || die |