Performed some minor cleanup.

git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@596 67a159dc-881f-0410-a524-ba9dfbe2cb84
cleanup-cruft
Chris Gianelloni 17 years ago
parent 239e46b186
commit 5b462be907

@ -2,6 +2,10 @@
# Copyright 2006-2008 Gentoo Foundation; Distributed under the GPL v2 # Copyright 2006-2008 Gentoo Foundation; Distributed under the GPL v2
# $Header: $ # $Header: $
14 Feb 2008; Chris Gianelloni <wolf31o2@gentoo.org>
generic/initrd.scripts, generic/linuxrc:
Performed some minor cleanup.
14 Feb 2008; Chris Gianelloni <wolf31o2@gentoo.org> generic/linuxrc: 14 Feb 2008; Chris Gianelloni <wolf31o2@gentoo.org> generic/linuxrc:
Move busybox --install -s to outside the /init check. Fix problems with Move busybox --install -s to outside the /init check. Fix problems with
running mknod on a non-CD root filesystem, which will be read-only, for bug running mknod on a non-CD root filesystem, which will be read-only, for bug
@ -1306,7 +1310,7 @@
Fix #100637. Fix #100637.
05 Dec 2005; Tim Yamin <plasmaroo@gentoo.org> generic/linuxrc: 05 Dec 2005; Tim Yamin <plasmaroo@gentoo.org> generic/linuxrc:
Back out suspend2 support temporarily as per #114266c10. Back out suspend2 support temporarily as per #114266 comment 10.
05 Dec 2005; Tim Yamin <plasmaroo@gentoo.org> generic/linuxrc: 05 Dec 2005; Tim Yamin <plasmaroo@gentoo.org> generic/linuxrc:
Fix #113634, #114266. Fix #113634, #114266.

@ -892,7 +892,7 @@ rundebugshell() {
} }
swsusp_resume() { swsusp_resume() {
### determine swap resume partition # determine swap resume partition
local device=$(ls -l "${REAL_RESUME}" | sed 's/\ */ /g' | cut -d \ -f 6-7 | sed 's/,\ */:/') local device=$(ls -l "${REAL_RESUME}" | sed 's/\ */ /g' | cut -d \ -f 6-7 | sed 's/,\ */:/')
[ -f /sys/power/resume ] && echo "${device}" > /sys/power/resume [ -f /sys/power/resume ] && echo "${device}" > /sys/power/resume
return 0 return 0

@ -203,18 +203,18 @@ then
# Load appropriate kernel modules # Load appropriate kernel modules
if [ "${NODETECT}" != '1' ] if [ "${NODETECT}" != '1' ]
then then
for modules in $MY_HWOPTS for modules in ${MY_HWOPTS}
do do
modules_scan $modules modules_scan ${modules}
eval DO_`echo $modules | sed 's/-//'`=1 eval DO_`echo ${modules} | sed 's/-//'`=1
done done
fi fi
# Always eval doload=... # Always eval doload=...
modules_load $MDOLIST modules_load ${MDOLIST}
else else
for modules in $MY_HWOPTS for modules in ${MY_HWOPTS}
do do
eval DO_`echo $modules | sed 's/-//'`=1 eval DO_`echo ${modules} | sed 's/-//'`=1
done done
good_msg 'Skipping module load; no modules in the initrd!' good_msg 'Skipping module load; no modules in the initrd!'
fi fi
@ -242,13 +242,12 @@ then
then then
swsusp_resume swsusp_resume
# suspend_resume # suspend_resume
# suspend2_resume
tuxonice_resume tuxonice_resume
fi fi
fi fi
mkdir -p ${NEW_ROOT} mkdir -p "${NEW_ROOT}"
CHROOT=${NEW_ROOT} CHROOT="${NEW_ROOT}"
# Run debug shell if requested # Run debug shell if requested
rundebugshell rundebugshell
@ -256,28 +255,28 @@ rundebugshell
if [ "${CDROOT}" = '1' ] if [ "${CDROOT}" = '1' ]
then then
good_msg "Making tmpfs for ${NEW_ROOT}" good_msg "Making tmpfs for ${NEW_ROOT}"
mount -t tmpfs tmpfs ${NEW_ROOT} mount -t tmpfs tmpfs "${NEW_ROOT}"
for i in dev mnt mnt/cdrom mnt/livecd mnt/key tmp tmp/.initrd mnt/gentoo sys for i in dev mnt mnt/cdrom mnt/livecd mnt/key tmp tmp/.initrd mnt/gentoo sys
do do
mkdir -p ${NEW_ROOT}/$i mkdir -p "${NEW_ROOT}/${i}"
chmod 755 ${NEW_ROOT}/$i chmod 755 "${NEW_ROOT}/${i}"
done done
[ ! -e ${NEW_ROOT}/dev/null ] && mknod ${NEW_ROOT}/dev/null c 1 3 [ ! -e "${NEW_ROOT}/dev/null" ] && mknod "${NEW_ROOT}"/dev/null c 1 3
[ ! -e ${NEW_ROOT}/dev/console ] && mknod ${NEW_ROOT}/dev/console c 5 1 [ ! -e "${NEW_ROOT}/dev/console" ] && mknod "${NEW_ROOT}"/dev/console c 5 1
# For SGI LiveCDs ... # For SGI LiveCDs ...
if [ "${LOOPTYPE}" = "sgimips" ] if [ "${LOOPTYPE}" = "sgimips" ]
then then
[ ! -e ${NEW_ROOT}/dev/sr0 ] && mknod ${NEW_ROOT}/dev/sr0 b 11 0 [ ! -e "${NEW_ROOT}/dev/sr0" ] && mknod "${NEW_ROOT}/dev/sr0" b 11 0
[ ! -e ${NEW_ROOT}/dev/loop0 ] && mknod ${NEW_ROOT}/dev/loop0 b 7 0 [ ! -e "${NEW_ROOT}/dev/loop0" ] && mknod "${NEW_ROOT}/dev/loop0" b 7 0
fi fi
# Required for gensplash to work. Not an issue with the initrd as this # Required for splash to work. Not an issue with the initrd as this
# device isn't created there and is not needed. # device isn't created there and is not needed.
if [ -e /dev/tty1 ] if [ -e /dev/tty1 ]
then then
[ ! -e ${NEW_ROOT}/dev/tty1 ] && mknod ${NEW_ROOT}/dev/tty1 c 4 1 [ ! -e "${NEW_ROOT}/dev/tty1" ] && mknod "${NEW_ROOT}/dev/tty1" c 4 1
fi fi
if [ "${REAL_ROOT}" != "/dev/nfs" ] && [ "${LOOPTYPE}" != "sgimips" ] if [ "${REAL_ROOT}" != "/dev/nfs" ] && [ "${LOOPTYPE}" != "sgimips" ]
@ -290,10 +289,10 @@ then
echo -n -e "${WARN}>>${NORMAL}${BOLD} No bootable medium found. Waiting for new devices" echo -n -e "${WARN}>>${NORMAL}${BOLD} No bootable medium found. Waiting for new devices"
COUNTER=0 COUNTER=0
while [ $COUNTER -lt 3 ]; do while [ ${COUNTER} -lt 3 ]; do
sleep 3 sleep 3
echo -n '.' echo -n '.'
let COUNTER=$COUNTER+1 let COUNTER=${COUNTER}+1
done done
sleep 1 sleep 1
@ -304,12 +303,12 @@ then
if [ "${REAL_ROOT}" = '' ] if [ "${REAL_ROOT}" = '' ]
then then
# Undo stuff # Undo stuff
umount ${NEW_ROOT}/dev 2>/dev/null umount "${NEW_ROOT}/dev" 2>/dev/null
umount ${NEW_ROOT}/sys 2>/dev/null umount "${NEW_ROOT}/sys" 2>/dev/null
umount /sys 2>/dev/null umount /sys 2>/dev/null
umount ${NEW_ROOT} umount "${NEW_ROOT}"
rm -rf ${NEW_ROOT}/* rm -rf "${NEW_ROOT}/*"
bad_msg 'Could not find CD to boot, something else needed!' bad_msg 'Could not find CD to boot, something else needed!'
CDROOT=0 CDROOT=0
@ -392,8 +391,6 @@ do
findnfsmount findnfsmount
else else
# mount ro so fsck doesn't barf later # mount ro so fsck doesn't barf later
# REAL_ROOT_TYPE=`vol_id -t ${REAL_ROOT}`
# mount -t ${REAL_ROOT_TYPE} -o ro ${REAL_ROOT} ${NEW_ROOT}
if [ "${REAL_ROOTFLAGS}" = '' ]; then if [ "${REAL_ROOTFLAGS}" = '' ]; then
mount -o ro ${REAL_ROOT} ${NEW_ROOT} mount -o ro ${REAL_ROOT} ${NEW_ROOT}
else else
@ -404,7 +401,6 @@ do
# If mount is successful break out of the loop # If mount is successful break out of the loop
# else not a good root and start over. # else not a good root and start over.
if [ "$?" = '0' ] if [ "$?" = '0' ]
then then
break break
@ -419,11 +415,11 @@ done
#verbose_kmsg #verbose_kmsg
# If cd root is set determine the looptype to boot # If CD root is set determine the looptype to boot
if [ "${CDROOT}" = '1' ] if [ "${CDROOT}" = '1' ]
then then
good_msg 'Determining looptype ...' good_msg 'Determining looptype ...'
cd ${NEW_ROOT} cd "${NEW_ROOT}"
# Find loop and looptype if we have NFS-mounted a livecd # Find loop and looptype if we have NFS-mounted a livecd
if [ "${LOOP}" = '' ] && [ "${REAL_ROOT}" = '/dev/nfs' ] if [ "${LOOP}" = '' ] && [ "${REAL_ROOT}" = '/dev/nfs' ]
@ -477,16 +473,13 @@ then
# If encrypted, find key and mount, otherwise mount as usual # If encrypted, find key and mount, otherwise mount as usual
if [ -n "${CRYPT_ROOT}" ] if [ -n "${CRYPT_ROOT}" ]
then then
good_msg 'You booted an encrypted livecd' ${CRYPT_SILENT} CRYPT_ROOT_KEY="$(head -n 1 ${NEW_ROOT}/mnt/cdrom/livecd)"
CRYPT_ROOT='/dev/loop0'
CRYPT_ROOT_KEY=$(head -n 1 ${NEW_ROOT}/mnt/cdrom/livecd) good_msg 'You booted an encrypted livecd' "${CRYPT_SILENT}"
losetup /dev/loop0 ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}
losetup /dev/loop0 "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}"
test_success 'Preparing loop filesystem' test_success 'Preparing loop filesystem'
CRYPT_ROOT='/dev/loop0'
startLUKS startLUKS
case ${LOOPTYPE} in case ${LOOPTYPE} in
@ -498,50 +491,39 @@ then
;; ;;
esac esac
mount -t "${MOUNTTYPE}" -o ro /dev/mapper/root "${NEW_ROOT}/mnt/livecd"
mount -t ${MOUNTTYPE} -o ro /dev/mapper/root ${NEW_ROOT}/mnt/livecd
test_success 'Mount filesystem' test_success 'Mount filesystem'
FS_LOCATION='mnt/livecd' FS_LOCATION='mnt/livecd'
# Setup the loopback mounts, if unencrypted # Setup the loopback mounts, if unencrypted
else else
if [ "${LOOPTYPE}" = 'normal' ] if [ "${LOOPTYPE}" = 'normal' ]
then then
good_msg 'Mounting loop filesystem' good_msg 'Mounting loop filesystem'
mount -t ext2 -o loop,ro ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP} ${NEW_ROOT}/mnt/livecd mount -t ext2 -o loop,ro "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd"
test_success 'Mount filesystem' test_success 'Mount filesystem'
FS_LOCATION='mnt/livecd' FS_LOCATION='mnt/livecd'
elif [ "${LOOPTYPE}" = 'squashfs' ] elif [ "${LOOPTYPE}" = 'squashfs' ]
then then
good_msg 'Mounting squashfs filesystem' good_msg 'Mounting squashfs filesystem'
mount -t squashfs -o loop,ro ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP} ${NEW_ROOT}/mnt/livecd mount -t squashfs -o loop,ro "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd"
test_success 'Mount filesystem' test_success 'Mount filesystem'
FS_LOCATION='mnt/livecd' FS_LOCATION='mnt/livecd'
elif [ "${LOOPTYPE}" = 'gcloop' ] elif [ "${LOOPTYPE}" = 'gcloop' ]
then then
good_msg 'Mounting gcloop filesystem' good_msg 'Mounting gcloop filesystem'
echo ' ' | losetup -E 19 -e ucl-0 -p0 ${NEW_ROOT}/dev/loop0 ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP} echo ' ' | losetup -E 19 -e ucl-0 -p0 "${NEW_ROOT}/dev/loop0" "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}"
test_success 'losetup the loop device' test_success 'losetup the loop device'
mount -t ext2 -o ro ${NEW_ROOT}/dev/loop0 ${NEW_ROOT}/mnt/livecd mount -t ext2 -o ro "${NEW_ROOT}/dev/loop0" "${NEW_ROOT}/mnt/livecd"
test_success 'Mount the losetup loop device' test_success 'Mount the losetup loop device'
FS_LOCATION='mnt/livecd' FS_LOCATION='mnt/livecd'
elif [ "${LOOPTYPE}" = 'zisofs' ] elif [ "${LOOPTYPE}" = 'zisofs' ]
then then
FS_LOCATION="mnt/cdrom/${LOOPEXT}${LOOP}" FS_LOCATION="mnt/cdrom/${LOOPEXT}${LOOP}"
elif [ "${LOOPTYPE}" = 'noloop' ] elif [ "${LOOPTYPE}" = 'noloop' ]
then then
FS_LOCATION='mnt/cdrom' FS_LOCATION='mnt/cdrom'
elif [ "${LOOPTYPE}" = 'sgimips' ] elif [ "${LOOPTYPE}" = 'sgimips' ]
then then
# getdvhoff finds the starting offset (in bytes) of the squashfs # getdvhoff finds the starting offset (in bytes) of the squashfs
@ -555,22 +537,18 @@ then
# the LiveCD rootfs # the LiveCD rootfs
good_msg 'Locating the SGI LiveCD Root Partition' good_msg 'Locating the SGI LiveCD Root Partition'
echo ' ' | \ echo ' ' | \
losetup -o $(/bin/getdvhoff ${NEW_ROOT}${REAL_ROOT} 0) \ losetup -o $(/bin/getdvhoff "${NEW_ROOT}${REAL_ROOT}" 0) \
${NEW_ROOT}${CDROOT_DEV} \ "${NEW_ROOT}${CDROOT_DEV}" \
${NEW_ROOT}${REAL_ROOT} "${NEW_ROOT}${REAL_ROOT}"
test_success 'losetup /dev/sr0 /dev/loop0' test_success 'losetup /dev/sr0 /dev/loop0'
good_msg 'Mounting the Root Partition' good_msg 'Mounting the Root Partition'
mount -t squashfs -o ro ${NEW_ROOT}${CDROOT_DEV} ${NEW_ROOT}/mnt/livecd mount -t squashfs -o ro "${NEW_ROOT}${CDROOT_DEV}" "${NEW_ROOT}/mnt/livecd"
test_success 'mount /dev/loop0 /' test_success 'mount /dev/loop0 /'
FS_LOCATION='mnt/livecd' FS_LOCATION='mnt/livecd'
fi fi
fi fi
#
# End cdrom looptype determination and mounting if necessary
#
# Unpacking additional packages from NFS mount # Unpacking additional packages from NFS mount
# This is useful for adding kernel modules to /lib # This is useful for adding kernel modules to /lib
# We do this now, so that additional packages can add whereever they want. # We do this now, so that additional packages can add whereever they want.
@ -590,7 +568,7 @@ then
good_msg "Copying read-write image contents to tmpfs" good_msg "Copying read-write image contents to tmpfs"
# Copy over stuff that should be writable # Copy over stuff that should be writable
(cd ${NEW_ROOT}/${FS_LOCATION}; cp -a ${ROOT_TREES} ${NEW_ROOT}) (cd "${NEW_ROOT}/${FS_LOCATION}"; cp -a "${ROOT_TREES}" "${NEW_ROOT}")
# Now we do the links. # Now we do the links.
for x in ${ROOT_LINKS} for x in ${ROOT_LINKS}
@ -602,17 +580,17 @@ then
# List all subdirectories of x # List all subdirectories of x
find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null | while read directory find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null | while read directory
do do
## Strip the prefix of the FS_LOCATION # Strip the prefix of the FS_LOCATION
directory=${directory#${NEW_ROOT}/${FS_LOCATION}/} directory="${directory#${NEW_ROOT}/${FS_LOCATION}/}"
## Skip this directory if we already linked a parent directory # Skip this directory if we already linked a parent directory
if [ "${curent_parrent}" != '' ]; then if [ "${curent_parrent}" != '' ]; then
var=`echo "${directory}" | grep "^${curent_parrent}"` var=`echo "${directory}" | grep "^${curent_parrent}"`
if [ "${var}" != '' ]; then if [ "${var}" != '' ]; then
continue continue
fi fi
fi fi
## Test if the directory exists already # Test if the directory exists already
if [ -e "/${NEW_ROOT}/${directory}" ] if [ -e "/${NEW_ROOT}/${directory}" ]
then then
# It does exist, link all the individual files # It does exist, link all the individual files
@ -625,7 +603,7 @@ then
else else
# It does not exist, make a link to the livecd # It does not exist, make a link to the livecd
ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null
current_parent=${directory} current_parent="${directory}"
fi fi
done done
fi fi
@ -660,23 +638,23 @@ cdupdate
if [ "${SUBDIR}" != '' -a -e "${CHROOT}/${SUBDIR}" ] if [ "${SUBDIR}" != '' -a -e "${CHROOT}/${SUBDIR}" ]
then then
good_msg "Entering ${SUBDIR} to boot" good_msg "Entering ${SUBDIR} to boot"
CHROOT=${CHROOT}/${SUBDIR} CHROOT="${CHROOT}/${SUBDIR}"
fi fi
verbose_kmsg verbose_kmsg
if [ "$0" = '/linuxrc' ] || [ "$0" = 'linuxrc' ] if [ "$0" = '/linuxrc' ] || [ "$0" = 'linuxrc' ]
then then
if [ ! -e ${CHROOT}/dev/console ] || [ ! -e ${CHROOT}/dev/null ] \ if [ ! -e "${CHROOT}/dev/console" ] || [ ! -e "${CHROOT}/dev/null" ] \
|| [ ! -e ${CHROOT}/dev/tty1 ] || [ ! -e "${CHROOT}/dev/tty1" ]
then then
echo -ne "${BAD}>>{NORMAL}${BOLD} ERROR: /dev is broken!${NORMAL}" echo -ne "${BAD}>>{NORMAL}${BOLD} ERROR: /dev is broken!${NORMAL}"
else else
echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting${NORMAL}" echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting${NORMAL}"
fi fi
cd ${CHROOT} cd "${CHROOT}"
mkdir ${CHROOT}/proc ${CHROOT}/sys 2>/dev/null mkdir "${CHROOT}/proc" "${CHROOT}/sys" 2>/dev/null
pivot_root . tmp/.initrd pivot_root . tmp/.initrd
if [ "${DO_slowusb}" ] || [ "${FORCE_slowusb}" ] if [ "${DO_slowusb}" ] || [ "${FORCE_slowusb}" ]
then then
@ -719,26 +697,26 @@ then
exec chroot . /bin/sh <<- EOF exec chroot . /bin/sh <<- EOF
umount /tmp/.initrd || echo "*: Failed to unmount the initrd!" umount /tmp/.initrd || echo "*: Failed to unmount the initrd!"
/sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
exec ${REAL_INIT:-/sbin/init} ${INIT_OPTS} exec "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}"
EOF EOF
elif [ "$0" = '/init' ] elif [ "$0" = '/init' ]
then then
if [ ! -e ${CHROOT}/dev/console ] || [ ! -e ${CHROOT}/dev/null ] \ if [ ! -e "${CHROOT}/dev/console" ] || [ ! -e "${CHROOT}/dev/null" ] \
|| [ ! -e ${CHROOT}/dev/tty1 ] || [ ! -e "${CHROOT}/dev/tty1" ]
then then
echo -ne "${BAD}>>{NORMAL}${BOLD} ERROR: /dev is broken!${NORMAL}" echo -ne "${BAD}>>{NORMAL}${BOLD} ERROR: /dev is broken!${NORMAL}"
else else
echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting (initramfs)${NORMAL}" echo -ne "${GOOD}>>${NORMAL}${BOLD} Booting (initramfs)${NORMAL}"
fi fi
cd ${CHROOT} cd "${CHROOT}"
mkdir ${CHROOT}/proc ${CHROOT}/sys 2>/dev/null mkdir "${CHROOT}/proc" "${CHROOT}/sys" 2>/dev/null
echo -ne "${BOLD}.${NORMAL}" echo -ne "${BOLD}.${NORMAL}"
umount /sys || echo '*: Failed to unmount the initrd /sys!' umount /sys || echo '*: Failed to unmount the initrd /sys!'
umount /proc || echo '*: Failed to unmount the initrd /proc!' umount /proc || echo '*: Failed to unmount the initrd /proc!'
echo -e "${BOLD}.${NORMAL}" echo -e "${BOLD}.${NORMAL}"
exec switch_root -c "/dev/console" "${CHROOT}" ${REAL_INIT:-/sbin/init} ${INIT_OPTS} exec switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}"
fi fi
splash 'verbose' splash 'verbose'

Loading…
Cancel
Save