summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bächler <thomas@archlinux.org>2008-03-15 23:25:52 +0100
committerThomas Bächler <thomas@archlinux.org>2008-03-15 23:25:52 +0100
commit3add4c0cf67f48eea2138739528586f358aad567 (patch)
treee52b4fb183ac70b3dcbccfba67b09a3b6d6b61bc
parentc75f6726f08f338ce000cfbbca3fd27ec8356798 (diff)
downloadmkinitcpio-3add4c0cf67f48eea2138739528586f358aad567.tar.gz
mkinitcpio-3add4c0cf67f48eea2138739528586f358aad567.tar.xz
Fix trap call, always call cleanup
-rw-r--r--functions2
-rwxr-xr-xmkinitcpio12
2 files changed, 11 insertions, 3 deletions
diff --git a/functions b/functions
index 421b85e..e124303 100644
--- a/functions
+++ b/functions
@@ -35,7 +35,7 @@ checked_modules ()
msg () { [ "${QUIET}" = "n" ] && echo ${@}; }
err () { echo "ERROR: ${@}" >&2; }
-die () { echo "FATAL: ${@}" >&2; exit 1; }
+die () { echo "FATAL: ${@}" >&2; cleanup; exit 1; }
add_full_dir ()
{
diff --git a/mkinitcpio b/mkinitcpio
index 9a8006c..159e135 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -56,6 +56,7 @@ usage ()
echo " -L List all available hooks."
echo " -H HOOKNAME Output help for hook 'HOOKNAME'."
echo " -h This message."
+ cleanup
exit 1
}
@@ -69,8 +70,7 @@ sighandler() {
exit 1
}
-trap SIGTERM sighandler
-trap SIGINT sighandler
+trap sighandler TERM INT
while getopts ':c:k:s:b:g:a:p:m:vH:LMhS:' arg; do
if [ "${OPTARG:0:1}" = "-" ]; then
@@ -92,11 +92,13 @@ while getopts ':c:k:s:b:g:a:p:m:vH:LMhS:' arg; do
H) source "${INSTDIR}/${OPTARG}";
echo "Help for hook '${OPTARG}':"
help
+ cleanup
exit 0 ;;
L) echo "Available hooks: "
for h in ${INSTDIR}/*; do
echo " $(basename ${h})"
done
+ cleanup
exit 0 ;;
M) SHOW_AUTOMODS="y" ;;
h|?) usage ;;
@@ -159,9 +161,11 @@ if [ -n "${PRESET}" ]; then
echo "==> FAIL"
fi
done
+ cleanup
exit 0
else
echo "Preset ${PRESET} does not exist. Exiting."
+ cleanup
exit 1
fi
fi
@@ -178,12 +182,14 @@ if [ -n "${BASEDIR}" ]; then
BASEDIR="$(pwd)/${BASEDIR}"
elif [ ! -d "${BASEDIR}" ]; then
echo "base directory '${BASEDIR}' does not exist or is not a directory"
+ cleanup
exit 1
fi
fi
if [ ! -f "${CONFIG}" ]; then
echo "config file '${CONFIG}' cannot be found, aborting..."
+ cleanup
exit 1
fi
source "${CONFIG}"
@@ -194,6 +200,7 @@ if [ -f "${FILELIST}" -a -z "${APPEND}" ]; then
touch "${FILELIST}"
else
echo "destination file list '${FILELIST}' exists - remove before running"
+ cleanup
exit 1
fi
else
@@ -210,6 +217,7 @@ if [ "${SHOW_AUTOMODS}" = "y" ]; then
source "${INSTDIR}/autodetect"
install
cat "${MODULE_FILE}"
+ cleanup
exit 0
fi