summaryrefslogtreecommitdiff
path: root/mkinitramfs
diff options
context:
space:
mode:
authormaximilian attems <maks@debian.org>2005-10-21 19:07:51 +0200
committermaximilian attems <maks@debian.org>2005-10-21 19:07:51 +0200
commitbbf15576550507c54b3e190ae6eac63ca070e333 (patch)
treeafd65fdbb6d89ba13fff8da1424e3976f009a53d /mkinitramfs
parent46727679e6e5bfdb67268511dc7a91a7a828abd7 (diff)
downloadinitramfs-tools-bbf15576550507c54b3e190ae6eac63ca070e333.tar.gz
initramfs-tools-bbf15576550507c54b3e190ae6eac63ca070e333.zip
jonas: Quote variables. Use test options -n and -z.
Diffstat (limited to 'mkinitramfs')
-rwxr-xr-xmkinitramfs92
1 files changed, 46 insertions, 46 deletions
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