syntax: drop parse_opt usage and crufty, deprecated subshelling through ``

These changes have been ported from official Gentoo LiveDVD
cleanup-cruft
Fabio Erculiani 14 years ago
parent 3453a0621c
commit d6696d0df6

@ -5,6 +5,10 @@
# Distributed under the GPL v2 # Distributed under the GPL v2
# $Id$ # $Id$
11 Sep 2011; Fabio Erculiani <lxnay@gentoo.org> defaults/initrd.scripts,
defaults/linuxrc:
drop parse_opt usage and crufty, deprecated subshelling through
30 Aug 2011; Sebastian Pipping <sping@gentoo.org> defaults/initrd.scripts: 30 Aug 2011; Sebastian Pipping <sping@gentoo.org> defaults/initrd.scripts:
Fix quoting issue (bug #380729). Fix quoting issue (bug #380729).

@ -6,14 +6,6 @@ backup() {
echo -ne "\033[0G\033[0K" echo -ne "\033[0G\033[0K"
} }
parse_opt() {
case "$1" in
*\=*)
echo "$1" | cut -d= -f2-
;;
esac
}
modules_load() { modules_load() {
for module in $* for module in $*
do do

@ -33,7 +33,7 @@ fi
quiet_kmsg quiet_kmsg
CMDLINE=`cat /proc/cmdline` CMDLINE=$(cat /proc/cmdline)
# Scan CMDLINE for any specified real_root= or cdroot arguments # Scan CMDLINE for any specified real_root= or cdroot arguments
FAKE_ROOT='' FAKE_ROOT=''
REAL_ROOTFLAGS='' REAL_ROOTFLAGS=''
@ -42,41 +42,41 @@ CRYPT_SILENT=0
for x in ${CMDLINE} for x in ${CMDLINE}
do do
case "${x}" in case "${x}" in
real_root\=*) real_root=*)
REAL_ROOT=`parse_opt "${x}"` REAL_ROOT=${x#*=}
;; ;;
root\=*) root=*)
FAKE_ROOT=`parse_opt "${x}"` FAKE_ROOT=${x#*=}
;; ;;
subdir\=*) subdir=*)
SUBDIR=`parse_opt "${x}"` SUBDIR=${x#*=}
;; ;;
real_init\=*) real_init=*)
REAL_INIT=`parse_opt "${x}"` REAL_INIT=${x#*=}
;; ;;
init_opts\=*) init_opts=*)
INIT_OPTS=`parse_opt "${x}"` INIT_OPTS=${x#*=}
;; ;;
# Livecd options # Livecd options
cdroot) cdroot)
CDROOT=1 CDROOT=1
;; ;;
cdroot\=*) cdroot=*)
CDROOT=1 CDROOT=1
CDROOT_DEV=`parse_opt "${x}"` CDROOT_DEV=${x#*=}
;; ;;
cdroot_type\=*) cdroot_type=*)
CDROOT_TYPE=`parse_opt "${x}"` CDROOT_TYPE=${x#*=}
;; ;;
# Start livecd loop, looptype options # Start livecd loop, looptype options
loop\=*) loop=*)
LOOP=`parse_opt "${x}"` LOOP=${x#*=}
;; ;;
looptype\=*) looptype=*)
LOOPTYPE=`parse_opt "${x}"` LOOPTYPE=${x#*=}
;; ;;
isoboot\=*) isoboot=*)
ISOBOOT=`parse_opt "${x}"` ISOBOOT=${x#*=}
;; ;;
# Start Volume manager options # Start Volume manager options
dolvm) dolvm)
@ -92,8 +92,8 @@ do
dodmraid) dodmraid)
USE_DMRAID_NORMAL=1 USE_DMRAID_NORMAL=1
;; ;;
dodmraid\=*) dodmraid=*)
DMRAID_OPTS=`parse_opt "${x}"` DMRAID_OPTS=${x#*=}
USE_DMRAID_NORMAL=1 USE_DMRAID_NORMAL=1
;; ;;
# Debug Options # Debug Options
@ -101,102 +101,102 @@ do
DEBUG='yes' DEBUG='yes'
;; ;;
# Scan delay options # Scan delay options
scandelay\=*) scandelay=*)
SDELAY=`parse_opt "${x}"` SDELAY=${x#*=}
;; ;;
scandelay) scandelay)
SDELAY=3 SDELAY=3
;; ;;
# Module no-loads # Module no-loads
doload\=*) doload=*)
MDOLIST=`parse_opt "${x}"` MDOLIST=${x#*=}
MDOLIST="`echo ${MDOLIST} | sed -e 's/,/ /g'`" MDOLIST=$(echo ${MDOLIST} | sed -e 's/,/ /g'`)
;; ;;
nodetect) nodetect)
NODETECT=1 NODETECT=1
;; ;;
noload\=*) noload=*)
MLIST=`parse_opt "${x}"` MLIST=${x#*=}
MLIST="`echo ${MLIST} | sed -e 's/,/ /g'`" MLIST="$(echo ${MLIST} | sed -e 's/,/ /g')"
export MLIST export MLIST
;; ;;
# Redirect output to a specific tty # Redirect output to a specific tty
CONSOLE\=*|console\=*) CONSOLE=*|console=*)
CONSOLE=`parse_opt "${x}"` CONSOLE=${x#*=}
CONSOLE=`basename ${CONSOLE}` CONSOLE=$(basename ${CONSOLE})
# exec >${CONSOLE} <${CONSOLE} 2>&1 # exec >${CONSOLE} <${CONSOLE} 2>&1
;; ;;
# /dev/md # /dev/md
lvmraid\=*) lvmraid=*)
RAID_DEVICES="`parse_opt ${x}`" RAID_DEVICES="${x#*=}"
RAID_DEVICES="`echo ${RAID_DEVICES} | sed -e 's/,/ /g'`" RAID_DEVICES="$(echo ${RAID_DEVICES} | sed -e 's/,/ /g')"
USE_LVM_NORMAL=1 USE_LVM_NORMAL=1
;; ;;
part\=*) part=*)
MDPART=`parse_opt "${x}"` MDPART=${x#*=}
;; ;;
# NFS # NFS
ip\=*) ip=*)
IP=`parse_opt "${x}"` IP=${x#*=}
;; ;;
nfsroot\=*) nfsroot=*)
NFSROOT=`parse_opt "${x}"` NFSROOT=${x#*=}
;; ;;
# iSCSI # iSCSI
iscsi_initiatorname\=*) iscsi_initiatorname=*)
ISCSI_INITIATORNAME=`parse_opt "${x}"` ISCSI_INITIATORNAME=${x#*=}
;; ;;
iscsi_target\=*) iscsi_target=*)
ISCSI_TARGET=`parse_opt "${x}"` ISCSI_TARGET=${x#*=}
;; ;;
iscsi_tgpt\=*) iscsi_tgpt=*)
ISCSI_TGPT=`parse_opt "${x}"` ISCSI_TGPT=${x#*=}
;; ;;
iscsi_address\=*) iscsi_address=*)
ISCSI_ADDRESS=`parse_opt "${x}"` ISCSI_ADDRESS=${x#*=}
;; ;;
iscsi_port\=*) iscsi_port=*)
ISCSI_PORT=`parse_opt "${x}"` ISCSI_PORT=${x#*=}
;; ;;
iscsi_username\=*) iscsi_username=*)
ISCSI_USERNAME=`parse_opt "${x}"` ISCSI_USERNAME=${x#*=}
;; ;;
iscsi_password\=*) iscsi_password=*)
ISCSI_PASSWORD=`parse_opt "${x}"` ISCSI_PASSWORD=${x#*=}
;; ;;
iscsi_username_in\=*) iscsi_username_in=*)
ISCSI_USERNAME_IN=`parse_opt "${x}"` ISCSI_USERNAME_IN=${x#*=}
;; ;;
iscsi_password_in\=*) iscsi_password_in=*)
ISCSI_PASSWORD_IN=`parse_opt "${x}"` ISCSI_PASSWORD_IN=${x#*=}
;; ;;
iscsi_debug\=*) iscsi_debug=*)
ISCSI_DEBUG=`parse_opt "${x}"` ISCSI_DEBUG=${x#*=}
;; ;;
iscsi_noibft) iscsi_noibft)
ISCSI_NOIBFT=1 ISCSI_NOIBFT=1
;; ;;
# Crypto # Crypto
crypt_root\=*) crypt_root=*)
CRYPT_ROOT=`parse_opt "${x}"` CRYPT_ROOT=${x#*=}
;; ;;
crypt_swap\=*) crypt_swap=*)
CRYPT_SWAP=`parse_opt "${x}"` CRYPT_SWAP=${x#*=}
;; ;;
root_key\=*) root_key=*)
CRYPT_ROOT_KEY=`parse_opt "${x}"` CRYPT_ROOT_KEY=${x#*=}
;; ;;
root_keydev\=*) root_keydev=*)
CRYPT_ROOT_KEYDEV=`parse_opt "${x}"` CRYPT_ROOT_KEYDEV=${x#*=}
;; ;;
swap_key\=*) swap_key=*)
CRYPT_SWAP_KEY=`parse_opt "${x}"` CRYPT_SWAP_KEY=${x#*=}
;; ;;
swap_keydev\=*) swap_keydev=*)
CRYPT_SWAP_KEYDEV=`parse_opt "${x}"` CRYPT_SWAP_KEYDEV=${x#*=}
;; ;;
real_resume\=*|resume\=*) real_resume=*|resume=*)
REAL_RESUME=`parse_opt "${x}"` REAL_RESUME=${x#*=}
;; ;;
noresume) noresume)
NORESUME=1 NORESUME=1
@ -204,14 +204,14 @@ do
crypt_silent) crypt_silent)
CRYPT_SILENT=1 CRYPT_SILENT=1
;; ;;
real_rootflags\=*) real_rootflags=*)
REAL_ROOTFLAGS=`parse_opt "${x}"` REAL_ROOTFLAGS=${x#*=}
;; ;;
rootfstype\=*) rootfstype=*)
ROOTFSTYPE=`parse_opt "${x}"` ROOTFSTYPE=${x#*=}
;; ;;
keymap\=*) keymap=*)
keymap=`parse_opt "${x}"` keymap=${x#*=}
;; ;;
aufs) aufs)
USE_AUFS_NORMAL=1 USE_AUFS_NORMAL=1
@ -228,19 +228,19 @@ do
nounionfs) nounionfs)
USE_UNIONFS_NORMAL=0 USE_UNIONFS_NORMAL=0
;; ;;
# unionfs\=*) # unionfs=*)
# if [ ! -x /sbin/unionfs ] # if [ ! -x /sbin/unionfs ]
# then # then
# USE_UNIONFS_NORMAL=0 # USE_UNIONFS_NORMAL=0
# bad_msg 'unionfs binary not found: aborting use of unionfs!' # bad_msg 'unionfs binary not found: aborting use of unionfs!'
# else # else
# USE_UNIONFS_NORMAL=1 # USE_UNIONFS_NORMAL=1
# CMD_UNIONFS=`parse_opt "${x}"` # CMD_UNIONFS=${x#*=}
# echo ${CMD_UNIONFS}|grep , >/dev/null 2>&1 # echo ${CMD_UNIONFS}|grep , >/dev/null 2>&1
# if [ $? -eq 0 ] # if [ $? -eq 0 ]
# then # then
# UID=`echo ${CMD_UNIONFS#*,}` # UID=$(echo ${CMD_UNIONFS#*,})
# UNIONFS=`echo ${CMD_UNIONFS%,*}` # UNIONFS=$(echo ${CMD_UNIONFS%,*})
# else # else
# UNIONFS=${CMD_UNIONFS} # UNIONFS=${CMD_UNIONFS}
# fi # fi
@ -321,23 +321,23 @@ then
if [ "${NORESUME}" != '1' ] && [ -n "${REAL_RESUME}" ] if [ "${NORESUME}" != '1' ] && [ -n "${REAL_RESUME}" ]
then then
case "${REAL_RESUME}" in case "${REAL_RESUME}" in
LABEL\=*|UUID\=*) LABEL=*|UUID=*)
RESUME_DEV="" RESUME_DEV=""
retval=1 retval=1
if [ ${retval} -ne 0 ]; then if [ ${retval} -ne 0 ]; then
RESUME_DEV=`findfs "${REAL_RESUME}" 2>/dev/null` RESUME_DEV=$(findfs "${REAL_RESUME}" 2>/dev/null)
retval=$? retval=$?
fi fi
if [ ${retval} -ne 0 ]; then if [ ${retval} -ne 0 ]; then
RESUME_DEV=`busybox findfs "${REAL_RESUME}" 2>/dev/null` RESUME_DEV=$(busybox findfs "${REAL_RESUME}" 2>/dev/null)
retval=$? retval=$?
fi fi
if [ ${retval} -ne 0 ]; then if [ ${retval} -ne 0 ]; then
RESUME_DEV=`blkid -l -t "${REAL_RESUME}" | cut -d ":" -f 1 2>/dev/null` RESUME_DEV=$(blkid -l -t "${REAL_RESUME}" | cut -d ":" -f 1 2>/dev/null)
retval=$? retval=$?
fi fi
@ -434,17 +434,17 @@ do
retval=1 retval=1
if [ ${retval} -ne 0 ]; then if [ ${retval} -ne 0 ]; then
ROOT_DEV=`findfs "${REAL_ROOT}" 2>/dev/null` ROOT_DEV=$(findfs "${REAL_ROOT}" 2>/dev/null)
retval=$? retval=$?
fi fi
if [ ${retval} -ne 0 ]; then if [ ${retval} -ne 0 ]; then
ROOT_DEV=`busybox findfs "${REAL_ROOT}" 2>/dev/null` ROOT_DEV=$(busybox findfs "${REAL_ROOT}" 2>/dev/null)
retval=$? retval=$?
fi fi
if [ ${retval} -ne 0 ]; then if [ ${retval} -ne 0 ]; then
ROOT_DEV=`blkid -l -t "${REAL_ROOT}" | cut -d ":" -f 1 2>/dev/null` ROOT_DEV=$(blkid -l -t "${REAL_ROOT}" | cut -d ":" -f 1 2>/dev/null)
retval=$? retval=$?
fi fi
@ -630,9 +630,9 @@ then
then then
if [ -e "${NEW_ROOT}/mnt/cdrom/add" ] if [ -e "${NEW_ROOT}/mnt/cdrom/add" ]
then then
for targz in `ls ${NEW_ROOT}/mnt/cdrom/add/*.tar.gz` for targz in $(ls ${NEW_ROOT}/mnt/cdrom/add/*.tar.gz)
do do
tarname=`basename ${targz}` tarname=$(basename ${targz})
good_msg "Adding additional package ${tarname}" good_msg "Adding additional package ${tarname}"
(cd ${NEW_ROOT} ; /bin/tar -xzf ${targz}) (cd ${NEW_ROOT} ; /bin/tar -xzf ${targz})
done done
@ -655,7 +655,7 @@ then
do do
if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ] if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]
then then
ln -s "`readlink ${NEW_ROOT}/${FS_LOCATION}/${x}`" "${x}" 2>/dev/null ln -s "$(readlink ${NEW_ROOT}/${FS_LOCATION}/${x})" "${x}" 2>/dev/null
else else
# 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
@ -665,7 +665,7 @@ then
# Skip this directory if we already linked a parent directory # Skip this directory if we already linked a parent directory
if [ "${current_parent}" != '' ]; then if [ "${current_parent}" != '' ]; then
var=`echo "${directory}" | grep "^${current_parent}"` var=$(echo "${directory}" | grep "^${current_parent}")
if [ "${var}" != '' ]; then if [ "${var}" != '' ]; then
continue continue
fi fi
@ -674,7 +674,7 @@ then
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
for file in `ls /${NEW_ROOT}/${FS_LOCATION}/${directory}` for file in $(ls /${NEW_ROOT}/${FS_LOCATION}/${directory})
do do
if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then
ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null
@ -694,7 +694,7 @@ then
fi fi
#UML=`cat /proc/cpuinfo|grep UML|sed -e 's|model name.*: ||'` #UML=$(cat /proc/cpuinfo|grep UML|sed -e 's|model name.*: ||')
#if [ "${UML}" = 'UML' ] #if [ "${UML}" = 'UML' ]
#then #then
# # UML Fixes # # UML Fixes

Loading…
Cancel
Save