diff options
-rw-r--r-- | install/autodetect | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | mkinitcpio | 41 |
2 files changed, 27 insertions, 20 deletions
diff --git a/install/autodetect b/install/autodetect index 2ae8db6..4042956 100644 --- a/install/autodetect +++ b/install/autodetect @@ -2,7 +2,7 @@ install () { - MODULE_FILE="$(mktemp /tmp/initcpio_modules.XXXXXX)" + MODULE_FILE="$(${TMPDIR}/autodetect_modules)" #blegh, we'll let /tmp clean itself up AUTODETECT="$(auto_modules -e '/scsi/' -e '/block' -e '/fusion/' \ -e '/usb/' -e '/ide/' -e '/ieee1394/' -e '/cdrom' \ @@ -50,11 +50,11 @@ install () case "${m}" in #*/ieee1394/*) echo -e "sbp2\nsd_mod\nsr_mod" >> "${MODULE_FILE}";; *ext3*) echo "jbd" >> "${MODULE_FILE}" ;; - *afs*)echo "rxrpc" >> "${MODULE_FILE}" ;; + *afs*) echo "rxrpc" >> "${MODULE_FILE}" ;; *cramfs*) echo "zlib_inflate" >> "${MODULE_FILE}" ;; *isofs*) echo "zlib_inflate" >> "${MODULE_FILE}" ;; *msdos*) echo "fat" >> "${MODULE_FILE}" ;; - *vfat*)echo -e "fat\nnls_cp437" >> "${MODULE_FILE}" ;; + *vfat*) echo -e "fat\nnls_cp437" >> "${MODULE_FILE}" ;; *ocfs2*) echo -e "ocfs2_dlm\njbd\nocfs2_nodemanager\nconfigfs" >> "${MODULE_FILE}" ;; esac echo "${modname}" >> "${MODULE_FILE}" diff --git a/mkinitcpio b/mkinitcpio index 987a882..07fe7f7 100644..100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -10,13 +10,13 @@ # use -z "${var}" to test for nulls/empty strings # incase of embedded spaces, quote all path names and string comarpisons # -#TODO trap and remove FILELIST # Settings +TMPDIR="$(mktemp -d /tmp/mkinitcpio.XXXXXX)" BASEDIR="" -FILELIST="$(mktemp /tmp/.tmpfilelist.XXXX)" -MESSAGEFILE="$(mktemp /tmp/.message.XXXX)" +FILELIST="$(${TMPDIR}/filelist)" +MESSAGEFILE="$(${TMPDIR}/message)" KERNELVERSION="$(uname -r)" FUNCTIONS="functions" CONFIG="mkinitcpio.conf" @@ -59,6 +59,19 @@ usage () exit 1 } +cleanup () +{ + [ -n "${TMPDIR}" -a -d "${TMPDIR}" ] && rm -rf ${TMPDIR} +} + +sighandler() { + cleanup + exit 1 +} + +trap SIGTERM sighandler +trap SIGINT sighandler + while getopts ':c:k:s:b:g:a:p:m:vH:LMhS:' arg; do if [ "${OPTARG:0:1}" = "-" ]; then echo "error: optional argument to '-$arg' begins with a '-'" @@ -228,13 +241,13 @@ if [ "${HAS_MODULES}" == "y" ]; then echo ":: Generating module dependencies" for mod in $(grep "file /lib/modules/${KERNELVERSION}" ${FILELIST} | cut -d' ' -f2); do dir=$(dirname "${mod}") - mkdir -p "/tmp/${dir}" - cp "${BASEDIR}${mod}" "/tmp/${dir}/" + mkdir -p "${TMPDIR}/${dir}" + cp "${BASEDIR}${mod}" "${TMPDIR}/${dir}/" done - /sbin/depmod -b /tmp ${KERNELVERSION} - add_file "/tmp/lib/modules/${KERNELVERSION}/modules.dep" "/lib/modules/${KERNELVERSION}/modules.dep" - add_file "/tmp/lib/modules/${KERNELVERSION}/modules.alias" "/lib/modules/${KERNELVERSION}/modules.alias" - add_file "/tmp/lib/modules/${KERNELVERSION}/modules.symbols" "/lib/modules/${KERNELVERSION}/modules.symbols" + /sbin/depmod -b ${TMPDIR} ${KERNELVERSION} + add_file "${TMPDIR}/lib/modules/${KERNELVERSION}/modules.dep" "/lib/modules/${KERNELVERSION}/modules.dep" + add_file "${TMPDIR}/lib/modules/${KERNELVERSION}/modules.alias" "/lib/modules/${KERNELVERSION}/modules.alias" + add_file "${TMPDIR}/lib/modules/${KERNELVERSION}/modules.symbols" "/lib/modules/${KERNELVERSION}/modules.symbols" fi status=0 @@ -256,13 +269,7 @@ else echo ":: Dry run complete, use -g IMAGE to generate a real image" fi -#cleanup - we should probably trap this... -isempty () { [ $(ls -1 "${1}" | wc -l) -eq 0 ]; } -[ -e "${MODULE_FILE}" ] && rm "${MODULE_FILE}" -if [ -d /tmp/lib/modules/${KERNELVERSION} ]; then - rm -rf /tmp/lib/modules/${KERNELVERSION} - isempty /tmp/lib/modules && rm -rf /tmp/lib/modules - isempty /tmp/lib && rm -rf /tmp/lib -fi +cleanup + exit $status #vim:set ft=sh ts=4 sw=4 noet: |