diff options
author | maximilian attems <maks@debian.org> | 2005-10-21 19:07:51 +0200 |
---|---|---|
committer | maximilian attems <maks@debian.org> | 2005-10-21 19:07:51 +0200 |
commit | bbf15576550507c54b3e190ae6eac63ca070e333 (patch) | |
tree | afd65fdbb6d89ba13fff8da1424e3976f009a53d | |
parent | 46727679e6e5bfdb67268511dc7a91a7a828abd7 (diff) | |
download | initramfs-tools-bbf15576550507c54b3e190ae6eac63ca070e333.tar.gz initramfs-tools-bbf15576550507c54b3e190ae6eac63ca070e333.zip |
jonas: Quote variables. Use test options -n and -z.
-rw-r--r-- | debian/changelog | 4 | ||||
-rw-r--r-- | hook-functions | 40 | ||||
-rwxr-xr-x | mkinitramfs | 92 | ||||
-rw-r--r-- | update-initramfs | 28 |
4 files changed, 83 insertions, 81 deletions
diff --git a/debian/changelog b/debian/changelog index 4b75eec..96efc42 100644 --- a/debian/changelog +++ b/debian/changelog @@ -43,8 +43,10 @@ initramfs-tools (0.31) UNRELEASED; urgency=low [ Jonas Smedegaard ] * Use GNU getopt (instead of bash builtin getopts) for improved handling. + * Quote variables. + * Use test options -n and -z. - -- Jonas Smedegaard <dr@jones.dk> Tue, 18 Oct 2005 04:03:48 +0200 + -- Jonas Smedegaard <dr@jones.dk> Tue, 18 Oct 2005 04:16:30 +0200 initramfs-tools (0.31) unstable; urgency=low diff --git a/hook-functions b/hook-functions index cb424d4..32a7e5f 100644 --- a/hook-functions +++ b/hook-functions @@ -7,13 +7,13 @@ catenate_cpiogz() { return fi - cat "${1}" >>${__TMPCPIOGZ} + cat "${1}" >>"${__TMPCPIOGZ}" } force_load() { manual_add_modules ${@} - echo ${@} >>${DESTDIR}/conf/modules + echo ${@} >>"${DESTDIR}/conf/modules" } # Takes a file containing a list of modules to be added as an @@ -34,7 +34,7 @@ add_modules_from_file() fi sed -e '/^#/d' ${1} | while read module rest; do - force_load ${module} "${rest}" + force_load "${module}" "${rest}" done } @@ -42,21 +42,21 @@ manual_add_modules() { for mam_x in $(modprobe --set-version=${version} --show-depends ${1} 2>/dev/null | awk '{ print $2 }'); do # Prune duplicates - if [ -e ${DESTDIR}/${mam_x} ]; then + if [ -e "${DESTDIR}/${mam_x}" ]; then continue fi - mkdir -p ${DESTDIR}/$(dirname ${mam_x}) - ln -s ${mam_x} ${DESTDIR}/$(dirname ${mam_x}) + mkdir -p "${DESTDIR}/$(dirname "${mam_x}")" + ln -s "${mam_x}" "${DESTDIR}/$(dirname "${mam_x}")" done } # Copy entire subtrees to the initramfs copy_modules_dir() { - tmpdir_modbase=${DESTDIR}/lib/modules/${version} - mkdir -p $(dirname ${tmpdir_modbase}/${1}) - cp -a ${MODULESDIR}/${1} ${tmpdir_modbase}/${1} + tmpdir_modbase="${DESTDIR}/lib/modules/${version}" + mkdir -p "$(dirname "${tmpdir_modbase}/${1}")" + cp -a "${MODULESDIR}/${1}" "${tmpdir_modbase}/${1}" } dep_add_modules() @@ -64,24 +64,24 @@ dep_add_modules() # Things that are too hard to autodetect. for x in md raid0 raid1 raid5 raid6 ext2 ext3 isofs jfs nfs reiserfs xfs af_packet dm_mod; do - manual_add_modules ${x} + manual_add_modules "${x}" done for x in /sys/bus/pci/devices/*; do - if [ -e ${x}/modalias ]; then - manual_add_modules $(cat ${x}/modalias) + if [ -e "${x}/modalias" ]; then + manual_add_modules $(cat "${x}/modalias") fi done for x in /sys/bus/usb/devices/*; do - if [ -e ${x}/modalias ]; then - manual_add_modules $(cat ${x}/modalias) + if [ -e "${x}/modalias" ]; then + manual_add_modules $(cat "${x}/modalias") fi done if [ -e /proc/ide ]; then for x in ide-generic ide-disk ide-cd; do - manual_add_modules ${x} + manual_add_modules "${x}" done fi @@ -100,27 +100,27 @@ auto_add_modules() { # base for x in md raid0 raid1 raid5 raid6 ehci-hcd ohci-hcd uhci-hcd usbhid usb-storage ext2 ext3 isofs jfs nfs reiserfs xfs af_packet dm_mod; do - manual_add_modules ${x} + manual_add_modules "${x}" done # Ethernet for x in 3c59x 8139cp 8139too 8390 b44 bmac bnx2 defxx dl2k e1000 e100 epic100 eql fealnx famachi forcedeth hp100 mace mv643xx_eth natsemi ne2k-pci netconsole ns83820 pcnet32 r8169 s2io sis900 skge slhc starfire sundance sungem sungem_phy sunhme tg3 tlan de2104x de4x5 dmfe tulip winbond-840 xircom_cb xircom_tulip_cb typhon via-rhine via-velocity yellowfin; do - manual_add_modules ${x} + manual_add_modules "${x}" done # ide for x in ide-cd ide-disk ide-generic aec62xx alim15x3 amd74xx atiixp atuuxo cmd64x cs5520 cs5530 cy82c693 generic hpt34x hpt366 ns87415 opti621 pdc202xx_new pdc202xx_old piix rz1000 sc1200 serverworks siimage sis5513 slc82c105 slc90e66 triflex trm290 via82cxxx; do - manual_add_modules ${x} + manual_add_modules "${x}" done # scsi for x in 3w-9xxx 3w-xxxx a100u2x aacraid advansys ahci aic79xx aic7xxx ata_piix atari_scsi atp870u BusLogic cciss ch dc395x dmx3191d dpt_i2o eata fdomain ibmvscsic initio ipr ips isp1020 lpfc max_scsi mac53c94 megaraid megaraid_mbox megaraid_mm mesh mptscsih nsp32 osst qla1280 qla2100 qla2200 qla2300 qla2322 qla2xxx qla6312 qlogicfas408 qlogicfc sata_promise sata_nv sata_qstor sata_sil sata_sis sata_svw sata_sx4 sata_uli sata_via sata_vsc scsi_mod scsi_transport_fc scsi_transport_iscsi scsi_transport_spi sd_mod sym53c8xx tmscsim; do - manual_add_modules ${x} + manual_add_modules "${x}" done # i2o for x in i2o_block; do - manual_add_modules ${x} + manual_add_modules "${x}" done } diff --git a/mkinitramfs b/mkinitramfs index bcf640b..874d2ce 100755 --- a/mkinitramfs +++ b/mkinitramfs @@ -30,7 +30,7 @@ while true; do -o) touch $2 shift $2 - outfile="$(readlink -f $2)" + outfile="$(readlink -f "$2")" ;; -k) keep="y" @@ -55,17 +55,17 @@ done . /usr/share/initramfs-tools/scripts/functions . /usr/share/initramfs-tools/hook-functions -. ${CONFDIR}/initramfs.conf +. "${CONFDIR}/initramfs.conf" -if [ x${outfile} = x ]; then +if [ -z "${outfile}" ]; then usage fi # And by "version" we really mean path to kernel modules # This is braindead, and exists to preserve the interface with mkinitrd if [ ${#} -ne 1 ]; then - version=$(uname -r) -else + version="$(uname -r)" +else version="${1}" fi @@ -74,36 +74,36 @@ if dpkg --compare-versions "${version}" lt 2.6.12; then exit 1 fi -case ${version} in +case "${version}" in /lib/modules/*/[!/]*) ;; /lib/modules/[!/]*) - version=${version#/lib/modules/} - version=${version%%/*} + version="${version#/lib/modules/}" + version="${version%%/*}" ;; esac -case ${version} in +case "${version}" in */*) - echo $PROG: ${version} is not a valid kernel version >&2 + echo "$PROG: ${version} is not a valid kernel version" >&2 exit 1 ;; esac -if [ -d ${outfile} ]; then +if [ -d "${outfile}" ]; then echo "${outfile} is a directory" exit 1 fi MODULESDIR="/lib/modules/${version}" -if [ ! -e ${MODULESDIR} ]; then +if [ ! -e "${MODULESDIR}" ]; then echo "Cannot find ${MODULESDIR}" exit 1 fi -DESTDIR=$(mktemp -t -d mkinitramfs_XXXXXX) || exit 1 -__TMPCPIOGZ=$(mktemp -t mkinitramfs-OL_XXXXXX) || exit 1 +DESTDIR="$(mktemp -t -d mkinitramfs_XXXXXX)" || exit 1 +__TMPCPIOGZ="$(mktemp -t mkinitramfs-OL_XXXXXX)" || exit 1 # Export environment for hook scripts. # @@ -116,13 +116,13 @@ export DESTDIR export __TMPCPIOGZ for d in bin conf etc lib modules sbin scripts; do - mkdir -p ${DESTDIR}/${d} + mkdir -p "${DESTDIR}/${d}" done # MODULES=list case. Always honour. -for x in ${CONFDIR}/modules /usr/share/initramfs-tools/modules.d/*; do +for x in "${CONFDIR}/modules" /usr/share/initramfs-tools/modules.d/*; do if [ -f "${x}" ]; then - add_modules_from_file ${x} + add_modules_from_file "${x}" fi done @@ -137,60 +137,60 @@ fi # Have to do each file, because cpio --dereference doesn't recurse down # symlinks. -cp /usr/share/initramfs-tools/init ${DESTDIR}/init -cp -a /usr/share/initramfs-tools/scripts/* ${DESTDIR}/scripts +cp /usr/share/initramfs-tools/init "${DESTDIR}/init" +cp -a /usr/share/initramfs-tools/scripts/* "${DESTDIR}/scripts" for f in $(cd /etc/mkinitramfs/scripts && \ find . \( -name '*.dpkg*' -prune -o -name '*~' -prune \) \ -o -type f -print); do - mkdir --parents ${DESTDIR}/scripts/$(dirname ${f}) -cp -p /etc/mkinitramfs/scripts/${f} ${DESTDIR}/scripts/$(dirname ${f}) + mkdir --parents "${DESTDIR}/scripts/$(dirname "${f}")" +cp -p "/etc/mkinitramfs/scripts/${f}" "${DESTDIR}/scripts/$(dirname "${f}")" done -cp ${CONFDIR}/initramfs.conf ${DESTDIR}/conf -cp -a /etc/udev ${DESTDIR}/etc +cp "${CONFDIR}/initramfs.conf" "${DESTDIR}/conf" +cp -a /etc/udev "${DESTDIR}/etc" # udev -cp /sbin/udev ${DESTDIR}/sbin -cp /sbin/udevd ${DESTDIR}/sbin -cp /sbin/udevsynthesize ${DESTDIR}/sbin -cp -a /lib/hotplug ${DESTDIR}/lib +cp /sbin/udev "${DESTDIR}/sbin" +cp /sbin/udevd "${DESTDIR}/sbin" +cp /sbin/udevsynthesize "${DESTDIR}/sbin" +cp -a /lib/hotplug "${DESTDIR}/lib" # Busybox -cp ${BUSYBOXDIR}/busybox ${DESTDIR}/bin/busybox +cp "${BUSYBOXDIR}/busybox" "${DESTDIR}/bin/busybox" # Modutils -cp /sbin/modprobe ${DESTDIR}/sbin -cp /sbin/depmod ${DESTDIR}/sbin -cp /sbin/rmmod ${DESTDIR}/sbin -mkdir -p ${DESTDIR}/etc/modprobe.d -cp /etc/modprobe.d/aliases ${DESTDIR}/etc/modprobe.d +cp /sbin/modprobe "${DESTDIR}/sbin" +cp /sbin/depmod "${DESTDIR}/sbin" +cp /sbin/rmmod "${DESTDIR}/sbin" +mkdir -p "${DESTDIR}/etc/modprobe.d" +cp /etc/modprobe.d/aliases "${DESTDIR}/etc/modprobe.d" # Raid -cp /sbin/mdadm ${DESTDIR}/sbin -cp /sbin/mdrun ${DESTDIR}/sbin +cp /sbin/mdadm "${DESTDIR}/sbin" +cp /sbin/mdrun "${DESTDIR}/sbin" # LVM -cp /lib/lvm-200/vgchange ${DESTDIR}/sbin +cp /lib/lvm-200/vgchange "${DESTDIR}/sbin" -mklibs-copy -d ${DESTDIR}/lib --root=${DESTDIR} $(find ${DESTDIR} -type f -perm +0111 -o -name '*.so') +mklibs-copy -d "${DESTDIR}/lib" --root="${DESTDIR}" $(find "${DESTDIR}" -type f -perm +0111 -o -name '*.so') -ln -s /usr/lib/klibc/bin/* ${DESTDIR}/bin -ln -s /usr/lib/klibc/lib/* ${DESTDIR}/lib +ln -s /usr/lib/klibc/bin/* "${DESTDIR}/bin" +ln -s /usr/lib/klibc/lib/* "${DESTDIR}/lib" -rm ${DESTDIR}/bin/sh -ln -s busybox ${DESTDIR}/bin/sh +rm "${DESTDIR}/bin/sh" +ln -s busybox "${DESTDIR}/bin/sh" run_scripts /usr/share/initramfs-tools/hooks run_scripts /etc/mkinitramfs/hooks # Apply DSDT to initramfs -if [ -e ${CONFDIR}/DSDT.aml ]; then - cp ${CONFDIR}/DSDT.aml ${DESTDIR} +if [ -e "${CONFDIR}/DSDT.aml" ]; then + cp "${CONFDIR}/DSDT.aml" "${DESTDIR}" fi -(cd ${DESTDIR} && find . | cpio --quiet --dereference -o -H newc | gzip -9 >${outfile}) +(cd "${DESTDIR}" && find . | cpio --quiet --dereference -o -H newc | gzip -9 >"${outfile}") -if [ -s ${__TMPCPIOGZ} ]; then - cat ${__TMPCPIOGZ} >>${outfile} +if [ -s "${__TMPCPIOGZ}" ]; then + cat "${__TMPCPIOGZ}" >>"${outfile}" fi if [ "${keep}" = "y" ]; then diff --git a/update-initramfs b/update-initramfs index bd5a4ab..644a1aa 100644 --- a/update-initramfs +++ b/update-initramfs @@ -63,33 +63,33 @@ set_initramfs() generate_initramfs() { verbose "Generating ${initramfs}" - mkinitramfs -o ${initramfs} ${version} + mkinitramfs -o "${initramfs}" "${version}" set_sha1 } compare_sha1() { - sha1sum ${initramfs} | diff ${STATEDIR}/${version} - >/dev/null 2>&1 + sha1sum "${initramfs}" | diff "${STATEDIR}/${version}" - >/dev/null 2>&1 return $? } # Note that this must overwrite so that updates work. set_sha1() { - sha1sum ${initramfs} > ${STATEDIR}/${version} + sha1sum "${initramfs}" > "${STATEDIR}/${version}" } delete_sha1() { - rm -f ${STATEDIR}/${version} + rm -f "${STATEDIR}/${version}" } get_sorted_versions() { version_list="" - for gsv_x in ${STATEDIR}/*; do - gsv_x=$(basename ${gsv_x}) + for gsv_x in "${STATEDIR}"/*; do + gsv_x="$(basename "${gsv_x}")" if [ "${gsv_x}" = '*' ]; then verbose "Nothing to do, exiting." exit 0 @@ -106,7 +106,7 @@ get_sorted_versions() if [ "${gsv_x}" != "" ]; then worklist="${worklist} ${gsv_x}" fi - version_list=${worklist} + version_list="${worklist}" done verbose "Available versions: ${version_list}" @@ -115,11 +115,11 @@ get_sorted_versions() set_linked_version() { if [ -L /initrd.img ]; then - linktarget=$(basename $(readlink /initrd.img)) + linktarget="$(basename "$(readlink /initrd.img)")" fi if [ -L /boot/initrd.img ]; then - linktarget=$(basename $(readlink /boot/initrd.img)) + linktarget="$(basename "$(readlink /boot/initrd.img)")" fi if [ -z "${linktarget}" ]; then @@ -145,11 +145,11 @@ create() set_initramfs if [ "${takeover}" = 0 ]; then - if version_exists ${version}; then + if version_exists "${version}"; then panic "Cannot create version ${version}: already exists" fi - if [ -e ${initramfs} ]; then + if [ -e "${initramfs}" ]; then panic "${initramfs} already exists, cannot create." fi fi @@ -176,7 +176,7 @@ update() fi # Don't stop if one version doesn't work. set +e - ${0} ${vflag} -u -k ${u_version} + "${0}" "${vflag}" -u -k "${u_version}" set -e done exit 0 @@ -198,11 +198,11 @@ delete() set_initramfs - if [ ! -e ${initramfs} ]; then + if [ ! -e "${initramfs}" ]; then panic "Cannot delete ${initramfs}, doesn't exist." fi - if ! version_exists ${version}; then + if ! version_exists "${version}"; then panic "Cannot delete version ${version}: Not created by this utility." fi |