From: Eric Edgar Date: Mon, 18 Jul 2005 15:12:00 +0000 (+0000) Subject: Create additional cleanup options. --postclear for final cleanup and 2 new genkernel... X-Git-Tag: v3.4.10.902~485 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6fd6712d41b35d440d2198e4e4f5063162a6ccae;p=genkernel.git Create additional cleanup options. --postclear for final cleanup and 2 new genkernel.conf options. Also fixup TEMP dir creation and extraneous %%ARCH%% creation in the cache_dir git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@267 67a159dc-881f-0410-a524-ba9dfbe2cb84 --- diff --git a/gen_bootloader.sh b/gen_bootloader.sh index 6f6a24f..b201506 100644 --- a/gen_bootloader.sh +++ b/gen_bootloader.sh @@ -27,16 +27,16 @@ set_grub_bootloader() { fi # Read GRUB device map - [ ! -d ${tmp} ] && mkdir ${tmp} - grub --batch --device-map=${tmp}/grub.map </dev/null 2>&1 + [ ! -d ${TEMP} ] && mkdir ${TEMP} + grub --batch --device-map=${TEMP}/grub.map </dev/null 2>&1 quit EOF # Get the GRUB mapping for our device local GRUB_BOOT_DISK1=$(echo $GRUB_BOOTFS | sed -e 's#\(/dev/.\+\)[[:digit:]]\+#\1#') - local GRUB_BOOT_DISK=$(awk '{if ($2 == "'$GRUB_BOOT_DISK1'") {gsub(/(\(|\))/, "", $1); print $1;}}' ${tmp}/grub.map) + local GRUB_BOOT_DISK=$(awk '{if ($2 == "'$GRUB_BOOT_DISK1'") {gsub(/(\(|\))/, "", $1); print $1;}}' ${TEMP}/grub.map) local GRUB_BOOT_PARTITION=$(echo $GRUB_BOOTFS | sed -e 's#/dev/.\+\([[:digit:]]?*\)#\1#') - [ ! -d ${tmp} ] && rm -r ${tmp} + [ ! -d ${TEMP} ] && rm -r ${TEMP} # Create grub configuration directory and file if it doesn't exist. [ ! -e `basename $GRUB_CONF` ] && mkdir -p `basename $GRUB_CONF` diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 64f4469..3e1920d 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -76,6 +76,7 @@ longusage() { echo " --arch-override= Force to arch instead of autodetect" echo " --cachedir= Override the default cache location" echo " --tempdir= Location of Genkernel's temporary directory" + echo " --postclear Clear all tmp files and caches after genkernel has run" echo " Output Settings" echo " --kernname=<...> Tag the kernel and initrd with a name:" echo " If not defined the option defaults to 'genkernel'" @@ -334,6 +335,10 @@ parse_cmdline() { TEMP=`parse_opt "$*"` print_info 2 "TEMP: $TEMP" ;; + --postclear) + CMD_POSTCLEAR=1 + print_info 2 "CMD_POSTCLEAR: $CMD_POSTCLEAR" + ;; --arch-override=*) CMD_ARCHOVERRIDE=`parse_opt "$*"` print_info 2 "CMD_ARCHOVERRIDE: $CMD_ARCHOVERRIDE" diff --git a/gen_determineargs.sh b/gen_determineargs.sh index 349d4bf..f6015d0 100644 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -3,21 +3,21 @@ get_KV() { if [ "${CMD_NO_KERNEL_SOURCES}" = '1' -a -e "${CMD_KERNCACHE}" ] then - [ -d ${tmp} ] && gen_die "temporary directory already exists! Exiting." - (umask 077 && mkdir ${tmp}) || { + [ -d ${TEMP} ] && gen_die "temporary directory already exists! Exiting." + (umask 077 && mkdir ${TEMP}) || { gen_die "Could not create temporary directory! Exiting." } - /bin/tar -xj -C ${tmp} -f ${CMD_KERNCACHE} kerncache.config - if [ -e ${tmp}/kerncache.config ] + /bin/tar -xj -C ${TEMP} -f ${CMD_KERNCACHE} kerncache.config + if [ -e ${TEMP}/kerncache.config ] then KERN_24=0 - VER=`grep ^VERSION\ \= ${tmp}/kerncache.config | awk '{ print $3 };'` - PAT=`grep ^PATCHLEVEL\ \= ${tmp}/kerncache.config | awk '{ print $3 };'` - SUB=`grep ^SUBLEVEL\ \= ${tmp}/kerncache.config | awk '{ print $3 };'` - EXV=`grep ^EXTRAVERSION\ \= ${tmp}/kerncache.config | sed -e "s/EXTRAVERSION =//" -e "s/ //g"` + VER=`grep ^VERSION\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'` + PAT=`grep ^PATCHLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'` + SUB=`grep ^SUBLEVEL\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'` + EXV=`grep ^EXTRAVERSION\ \= ${TEMP}/kerncache.config | sed -e "s/EXTRAVERSION =//" -e "s/ //g"` if [ "${PAT}" -gt '4' -a "${VER}" -ge '2' ] then - LOV=`grep ^CONFIG_LOCALVERSION\= ${tmp}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"` + LOV=`grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/"` KV=${VER}.${PAT}.${SUB}${EXV}${LOV} else KERN_24=1 @@ -25,10 +25,10 @@ get_KV() { fi else - rm -r ${tmp} + rm -r ${TEMP} gen_die "Could not find kerncache.config in the kernel cache! Exiting." fi - rm -r ${tmp} + rm -r ${TEMP} else # Configure the kernel @@ -172,9 +172,9 @@ determine_real_args() { then UTILS_AS="${CMD_UTILS_AS}" fi - + CACHE_DIR=`arch_replace "${CACHE_DIR}"` - + CACHE_CPIO_DIR="${CACHE_DIR}/cpio" BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"` MODULE_INIT_TOOLS_BINCACHE=`cache_replace "${MODULE_INIT_TOOLS_BINCACHE}"` MODUTILS_BINCACHE=`cache_replace "${MODUTILS_BINCACHE}"` @@ -238,6 +238,13 @@ determine_real_args() { COMPRESS_INITRD=0 fi + if isTrue ${CMD_POSTCLEAR} + then + POSTCLEAR=1 + else + POSTCLEAR=0 + fi + if [ "${CMD_MRPROPER}" != '' ] then MRPROPER="${CMD_MRPROPER}" diff --git a/gen_funcs.sh b/gen_funcs.sh index 3512551..21d35f3 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -250,3 +250,22 @@ isBootRO() done return 1 } + +setup_cache_dir() +{ + +[ ! -d "${CACHE_DIR}" ] && mkdir -p "${CACHE_DIR}" + +if [ "${CLEAR_CACHE_DIR}" == 'yes' ] +then + print_info 1 "Clearing cache dir contents from ${CACHE_DIR}" + CACHE_DIR_CONTENTS=`ls ${CACHE_DIR}|grep -v CVS|grep -v cpio|grep -v README` + for i in ${CACHE_DIR_CONTENTS} + do + print_info 1 " >> removing ${i}" + rm ${CACHE_DIR}/${i} + done +fi + +} + diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 9d158ec..a664e60 100644 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -34,7 +34,7 @@ create_base_layout_cpio() { mknod -m 660 null c 1 3 mknod -m 600 tty1 c 4 1 cd "${TEMP}/initramfs-base-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-base-layout.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-base-layout.cpio.gz rm -rf "${TEMP}/initramfs-base-temp" > /dev/null } @@ -62,7 +62,7 @@ create_busybox_cpio() { done cd "${TEMP}/initramfs-busybox-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-busybox-${BUSYBOX_VER}.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-busybox-${BUSYBOX_VER}.cpio.gz rm -rf "${TEMP}/initramfs-busybox-temp" > /dev/null } @@ -81,7 +81,7 @@ create_insmod_cpio() { chmod +x "${TEMP}/initramfs-insmod-temp/bin/insmod" cd "${TEMP}/initramfs-insmod-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-insmod-${MODULE_INIT_TOOLS_VER}.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-insmod-${MODULE_INIT_TOOLS_VER}.cpio.gz rm -rf "${TEMP}/initramfs-insmod-temp" > /dev/null } @@ -95,7 +95,7 @@ create_udev_cpio(){ [ "${UDEV}" -eq '1' ] && { /bin/tar -jxpf "${UDEV_BINCACHE}" -C "${TEMP}/initramfs-udev-temp" || gen_die "Could not extract udev binary cache!"; } cd "${TEMP}/initramfs-udev-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-udev-${UDEV_VER}.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-udev-${UDEV_VER}.cpio.gz rm -rf "${TEMP}/initramfs-udev-temp" > /dev/null } @@ -110,7 +110,7 @@ create_blkid_cpio(){ gen_die "Could not extract blkid binary cache!"; } chmod a+x "${TEMP}/initramfs-blkid-temp/bin/blkid" cd "${TEMP}/initramfs-blkid-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-blkid-${E2FSPROGS_VER}.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-blkid-${E2FSPROGS_VER}.cpio.gz rm -rf "${TEMP}/initramfs-blkid-temp" > /dev/null } @@ -127,7 +127,7 @@ create_devfs_cpio(){ bunzip2 "${TEMP}/initramfs-devfs-temp/bin/devfsd.bz2" || gen_die "could not uncompress devfsd" chmod +x "${TEMP}/initramfs-devfs-temp/bin/devfsd" cd "${TEMP}/initramfs-devfs-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-devfs-${DEVFSD_VER}.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-devfs-${DEVFSD_VER}.cpio.gz rm -rf "${TEMP}/initramfs-devfs-temp" > /dev/null } @@ -145,7 +145,7 @@ create_unionfs_modules_cpio(){ /bin/tar -jxpf "${UNIONFS_MODULES_BINCACHE}" -C "${TEMP}/initramfs-unionfs-modules-temp" || gen_die "Could not extract unionfs modules binary cache!"; cd "${TEMP}/initramfs-unionfs-modules-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz rm -r "${TEMP}/initramfs-unionfs-modules-temp/" fi } @@ -164,7 +164,7 @@ create_unionfs_tools_cpio(){ /bin/tar -jxpf "${UNIONFS_BINCACHE}" -C "${TEMP}/initramfs-unionfs-tools-temp" || gen_die "Could not extract unionfs tools binary cache!"; cd "${TEMP}/initramfs-unionfs-tools-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz rm -r "${TEMP}/initramfs-unionfs-tools-temp/" fi } @@ -183,7 +183,7 @@ create_dmraid_cpio(){ /bin/tar -jxpf "${DMRAID_BINCACHE}" -C "${TEMP}/initramfs-dmraid-temp" || gen_die "Could not extract dmraid binary cache!"; cd "${TEMP}/initramfs-dmraid-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-dmraid-${DMRAID_VER}.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-dmraid-${DMRAID_VER}.cpio.gz rm -r "${TEMP}/initramfs-dmraid-temp/" fi } @@ -212,7 +212,7 @@ create_lvm2_cpio(){ gen_die 'LVM2 error: Could not move lvm.static to lvm!' fi cd "${TEMP}/initramfs-lvm2-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-lvm2-${LVM2_VER}.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-lvm2-${LVM2_VER}.cpio.gz rm -r "${TEMP}/initramfs-lvm2-temp/" else # Deprecation warning; remove in a few versions. if [ -e '/sbin/lvm' ] @@ -259,7 +259,7 @@ create_evms2_cpio(){ done fi cd "${TEMP}/initramfs-evms2-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-evms2.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-evms2.cpio.gz rm -r "${TEMP}/initramfs-evms2-temp/" fi } @@ -275,7 +275,7 @@ create_gensplash(){ cd / local tmp="" [ -n "${GENSPLASH_RES}" ] && tmp="-r ${GENSPLASH_RES}" - splash_geninitramfs -g ${CACHE_DIR}/cpio/initramfs-splash-${KV}.cpio.gz ${tmp} ${GENSPLASH_THEME} + splash_geninitramfs -g ${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz ${tmp} ${GENSPLASH_THEME} if [ -e "/usr/share/splashutils/initrd.splash" ]; then if [ -d "${TEMP}/initramfs-gensplash-temp" ] then @@ -283,9 +283,9 @@ create_gensplash(){ fi mkdir -p "${TEMP}/initramfs-gensplash-temp/etc" cd "${TEMP}/initramfs-gensplash-temp/" - gunzip -c ${CACHE_DIR}/cpio/initramfs-splash-${KV}.cpio.gz | cpio -idm --quiet -H newc + gunzip -c ${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz | cpio -idm --quiet -H newc cp "/usr/share/splashutils/initrd.splash" "${TEMP}/initramfs-gensplash-temp/etc" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-splash-${KV}.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz rm -r "${TEMP}/initramfs-gensplash-temp/" fi else @@ -295,7 +295,7 @@ create_gensplash(){ } create_initramfs_overlay_cpio(){ cd ${INITRAMFS_OVERLAY} - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-overlay.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-overlay.cpio.gz } print_list() { @@ -346,7 +346,7 @@ create_initramfs_modules() { print_list ${!group_modules} > "${TEMP}/initramfs-modules-${KV}-temp/etc/modules/${group}" done cd "${TEMP}/initramfs-modules-${KV}-temp/" - find . | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-modules-${KV}.cpio.gz + find . | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-modules-${KV}.cpio.gz rm -r "${TEMP}/initramfs-modules-${KV}-temp/" } @@ -411,74 +411,74 @@ create_initramfs_aux() { chmod +x "${TEMP}/initramfs-aux-temp/etc/initrd.defaults" chmod +x "${TEMP}/initramfs-aux-temp/sbin/modprobe" cd "${TEMP}/initramfs-aux-temp/" - find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_DIR}/cpio/initramfs-aux.cpio.gz + find . -print | cpio --quiet -o -H newc | gzip -9 > ${CACHE_CPIO_DIR}/initramfs-aux.cpio.gz rm -r "${TEMP}/initramfs-aux-temp/" } merge_initramfs_cpio_archives(){ - cd "${CACHE_DIR}/cpio/" + cd "${CACHE_CPIO_DIR}" MERGE_LIST="initramfs-base-layout.cpio.gz initramfs-aux.cpio.gz" - if [ ! -e "${CACHE_DIR}/cpio/initramfs-base-layout.cpio.gz" ] + if [ ! -e "${CACHE_CPIO_DIR}/initramfs-base-layout.cpio.gz" ] then - gen_die "${CACHE_DIR}/cpio/initramfs-base-layout.cpio.gz is missing." + gen_die "${CACHE_CPIO_DIR}/initramfs-base-layout.cpio.gz is missing." fi - if [ ! -e "${CACHE_DIR}/cpio/initramfs-aux.cpio.gz" ] + if [ ! -e "${CACHE_CPIO_DIR}/initramfs-aux.cpio.gz" ] then - gen_die "${CACHE_DIR}/cpio/initramfs-aux.cpio.gz is missing." + gen_die "${CACHE_CPIO_DIR}/initramfs-aux.cpio.gz is missing." fi - if [ "${BUSYBOX}" -eq '1' -a -e ${CACHE_DIR}/cpio/initramfs-busybox-${BUSYBOX_VER}.cpio.gz ] + if [ "${BUSYBOX}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-busybox-${BUSYBOX_VER}.cpio.gz ] then MERGE_LIST="${MERGE_LIST} initramfs-busybox-${BUSYBOX_VER}.cpio.gz" fi - if [ "${NOINITRDMODULES}" = '' -a -e ${CACHE_DIR}/cpio/initramfs-insmod-${MODULE_INIT_TOOLS_VER}.cpio.gz ] + if [ "${NOINITRDMODULES}" = '' -a -e ${CACHE_CPIO_DIR}/initramfs-insmod-${MODULE_INIT_TOOLS_VER}.cpio.gz ] then MERGE_LIST="${MERGE_LIST} initramfs-insmod-${MODULE_INIT_TOOLS_VER}.cpio.gz" fi - if [ "${UDEV}" -eq '1' -a -e ${CACHE_DIR}/cpio/initramfs-udev-${UDEV_VER}.cpio.gz ] + if [ "${UDEV}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-udev-${UDEV_VER}.cpio.gz ] then MERGE_LIST="${MERGE_LIST} initramfs-udev-${UDEV_VER}.cpio.gz" fi - if [ "${DISKLABEL}" -eq '1' -a -e ${CACHE_DIR}/cpio/initramfs-blkid-${E2FSPROGS_VER}.cpio.gz ] + if [ "${DISKLABEL}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-blkid-${E2FSPROGS_VER}.cpio.gz ] then MERGE_LIST="${MERGE_LIST} initramfs-blkid-${E2FSPROGS_VER}.cpio.gz" fi - if [ "${UNIONFS}" -eq '1' -a -e ${CACHE_DIR}/cpio/initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz ] + if [ "${UNIONFS}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz ] then MERGE_LIST="${MERGE_LIST} initramfs-unionfs-${UNIONFS_VER}-tools.cpio.gz" fi - if [ "${UNIONFS}" -eq '1' -a -e ${CACHE_DIR}/cpio/initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz ] + if [ "${UNIONFS}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz ] then MERGE_LIST="${MERGE_LIST} initramfs-unionfs-${UNIONFS_VER}-modules-${KV}.cpio.gz" fi - if [ "${EVMS2}" -eq '1' -a -e "${CACHE_DIR}/cpio/initramfs-evms2.cpio.gz" ] + if [ "${EVMS2}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-evms2.cpio.gz" ] then MERGE_LIST="${MERGE_LIST} initramfs-evms2.cpio.gz" fi - if [ "${LVM2}" -eq '1' -a -e "${CACHE_DIR}/cpio/initramfs-lvm2-${LVM2_VER}.cpio.gz" ] + if [ "${LVM2}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-lvm2-${LVM2_VER}.cpio.gz" ] then MERGE_LIST="${MERGE_LIST} initramfs-lvm2-${LVM2_VER}.cpio.gz" fi - if [ "${DEVFS}" -eq '1' -a -e "${CACHE_DIR}/cpio/initramfs-devfs-${DEVFSD_VER}.cpio.gz" ] + if [ "${DEVFS}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-devfs-${DEVFSD_VER}.cpio.gz" ] then MERGE_LIST="${MERGE_LIST} initramfs-devfs-${DEVFSD_VER}.cpio.gz" fi - if [ "${DMRAID}" -eq '1' -a -e ${CACHE_DIR}/cpio/initramfs-dmraid-${DMRAID_VER}.cpio.gz ] + if [ "${DMRAID}" -eq '1' -a -e ${CACHE_CPIO_DIR}/initramfs-dmraid-${DMRAID_VER}.cpio.gz ] then MERGE_LIST="${MERGE_LIST} initramfs-dmraid-${DMRAID_VER}.cpio.gz" fi - if [ "${NOINITRDMODULES}" = '' -a -e "${CACHE_DIR}/cpio/initramfs-modules-${KV}.cpio.gz" ] + if [ "${NOINITRDMODULES}" = '' -a -e "${CACHE_CPIO_DIR}/initramfs-modules-${KV}.cpio.gz" ] then MERGE_LIST="${MERGE_LIST} initramfs-modules-${KV}.cpio.gz" fi - if [ "${GENSPLASH}" -eq '1' -a -e "${CACHE_DIR}/cpio/initramfs-splash-${KV}.cpio.gz" ] + if [ "${GENSPLASH}" -eq '1' -a -e "${CACHE_CPIO_DIR}/initramfs-splash-${KV}.cpio.gz" ] then MERGE_LIST="${MERGE_LIST} initramfs-splash-${KV}.cpio.gz" fi # This should always be appended last - if [ "${INITRAMFS_OVERLAY}" != '' -a -e "${CACHE_DIR}/cpio/initramfs-overlay.cpio.gz" ] + if [ "${INITRAMFS_OVERLAY}" != '' -a -e "${CACHE_CPIO_DIR}/initramfs-overlay.cpio.gz" ] then MERGE_LIST="${MERGE_LIST} initramfs-overlay.cpio.gz" fi @@ -498,9 +498,19 @@ merge_initramfs_cpio_archives(){ } clear_cpio_dir(){ - if [ -d ${CACHE_DIR}/cpio/ ] + if [ "${CLEAR_CPIO_CACHE}" == 'yes' ] then - rm -r ${CACHE_DIR}/cpio/ + + if [ -d ${CACHE_CPIO_DIR} ] + then + print_info 1 " >> Clearing old cpio archives..." + rm -r ${CACHE_CPIO_DIR} + fi + fi + + if [ ! -d ${CACHE_CPIO_DIR} ] + then + mkdir -p ${CACHE_CPIO_DIR} fi } @@ -509,7 +519,7 @@ create_initramfs() { print_info 1 "initramfs: >> Initializing..." clear_cpio_dir - mkdir -p ${CACHE_DIR}/cpio/ + mkdir -p ${CACHE_CPIO_DIR} print_info 1 " >> Creating base_layout cpio archive..." create_base_layout_cpio diff --git a/gen_package.sh b/gen_package.sh index 70e2e9a..fcda622 100644 --- a/gen_package.sh +++ b/gen_package.sh @@ -70,20 +70,20 @@ gen_kerncache() gen_kerncache_extract_kernel() { - [ -d ${tmp} ] && gen_die "temporary directory already exists! Exiting." - (umask 077 && mkdir ${tmp}) || { + [ -d ${TEMP} ] && gen_die "temporary directory already exists! Exiting." + (umask 077 && mkdir ${TEMP}) || { gen_die "Could not create temporary directory! Exiting." } - /bin/tar -f ${KERNCACHE} -C ${tmp} -xj - cp "${tmp}/kernel-${ARCH}-${KV}" "/boot/kernel-${KNAME}-${ARCH}-${KV}" || { - rm -r ${tmp} + /bin/tar -f ${KERNCACHE} -C ${TEMP} -xj + cp "${TEMP}/kernel-${ARCH}-${KV}" "/boot/kernel-${KNAME}-${ARCH}-${KV}" || { + rm -r ${TEMP} gen_die 'Could not copy the kernel binary to /boot!' } - cp "${tmp}/System.map-${ARCH}-${KV}" "/boot/System.map-${KNAME}-${ARCH}-${KV}" || { - rm -r ${tmp} + cp "${TEMP}/System.map-${ARCH}-${KV}" "/boot/System.map-${KNAME}-${ARCH}-${KV}" || { + rm -r ${TEMP} gen_die 'Could not copy System.map to /boot!' } - rm -r ${tmp} + rm -r ${TEMP} } gen_kerncache_extract_modules() @@ -108,32 +108,32 @@ gen_kerncache_is_valid() BUILD_KERNEL=0 # Can make this more secure .... - [ -d ${tmp} ] && gen_die "temporary directory already exists! Exiting." - (umask 077 && mkdir ${tmp}) || { + [ -d ${TEMP} ] && gen_die "temporary directory already exists! Exiting." + (umask 077 && mkdir ${TEMP}) || { gen_die "Could not create temporary directory! Exiting." } - /bin/tar -xj -f ${KERNCACHE} -C ${tmp} - if [ -e ${tmp}/config-${ARCH}-${KV} -a -e ${tmp}/kernel-${ARCH}-${KV} ] + /bin/tar -xj -f ${KERNCACHE} -C ${TEMP} + if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e ${TEMP}/kernel-${ARCH}-${KV} ] then print_info 1 'Valid kernel cache found; no sources will be used' KERNCACHE_IS_VALID=1 fi - /bin/rm -r ${tmp} + /bin/rm -r ${TEMP} else if [ -e "${KERNCACHE}" ] then - [ -d ${tmp} ] && gen_die "temporary directory already exists! Exiting." - (umask 077 && mkdir ${tmp}) || { + [ -d ${TEMP} ] && gen_die "temporary directory already exists! Exiting." + (umask 077 && mkdir ${TEMP}) || { gen_die "Could not create temporary directory! Exiting." } - /bin/tar -xj -f ${KERNCACHE} -C ${tmp} - if [ -e ${tmp}/config-${ARCH}-${KV} -a -e /${KERNEL_DIR}/.config ] + /bin/tar -xj -f ${KERNCACHE} -C ${TEMP} + if [ -e ${TEMP}/config-${ARCH}-${KV} -a -e /${KERNEL_DIR}/.config ] then - test1=$(md5sum ${tmp}/config-${ARCH}-${KV} | cut -d " " -f 1) + test1=$(md5sum ${TEMP}/config-${ARCH}-${KV} | cut -d " " -f 1) test2=$(md5sum /${KERNEL_DIR}/.config | cut -d " " -f 1) if [ "${test1}" == "${test2}" ] then @@ -144,7 +144,7 @@ gen_kerncache_is_valid() KERNCACHE_IS_VALID=1 fi fi - /bin/rm -r ${tmp} + /bin/rm -r ${TEMP} fi fi export KERNCACHE_IS_VALID diff --git a/generic/initrd.scripts b/generic/initrd.scripts index be1bc72..db9b685 100644 --- a/generic/initrd.scripts +++ b/generic/initrd.scripts @@ -64,7 +64,6 @@ findcdmount() { then good_msg "Attempting to mount CD:- ${x}" mount -r ${x} ${NEW_ROOT}/mnt/cdrom > /dev/null 2>&1 - if [ "$?" = '0' ] then # Check for a LiveCD @@ -269,6 +268,7 @@ start_dev_mgr(){ kill_devfsd good_msg 'Activating udev' runUdev + cd / else if [ ! -e /dev/.devfsd ] then diff --git a/generic/linuxrc b/generic/linuxrc index 8a8b936..2169f5b 100644 --- a/generic/linuxrc +++ b/generic/linuxrc @@ -219,7 +219,7 @@ then for i in dev mnt mnt/cdrom mnt/livecd tmp tmp/.initrd mnt/gentoo sys do - mkdir ${NEW_ROOT}/$i + mkdir -p ${NEW_ROOT}/$i chmod 755 ${NEW_ROOT}/$i done cp /dev/null ${NEW_ROOT}/dev diff --git a/genkernel b/genkernel index 92dd787..9c15c16 100755 --- a/genkernel +++ b/genkernel @@ -25,14 +25,28 @@ source ${GK_BIN}/gen_moddeps.sh || gen_die "Could not read ${GK_BIN}/gen_moddeps source ${GK_BIN}/gen_package.sh || gen_die "Could not read ${GK_BIN}/gen_package.sh" source ${GK_BIN}/gen_bootloader.sh || gen_die "Could not read ${GK_BIN}/gen_bootloader.sh" -tmp=${TMPDIR-/tmp} -tmp=${tmp}/genkernel.$RANDOM.$RANDOM.$RANDOM.$$ +TEMP=${TEMP}/$RANDOM.$RANDOM.$RANDOM.$$ cleanup(){ - if [ -n "$tmp" -a -d "$tmp" ]; then - echo "Removing $tmp" - rm -rf "$tmp" + if [ -n "$TEMP" -a -d "$TEMP" ]; then + echo "Removing $TEMP" + rm -rf "$TEMP" fi + + if isTrue ${POSTCLEAR} + then + print_info 1 '' + print_info 1 'RUNNING FINAL CACHE/TMP CLEANUP' + print_info 1 "CACHE_DIR: ${CACHE_DIR}" + CLEAR_CACHE_DIR='yes' + setup_cache_dir + ls -la ${CACHE_DIR} + print_info 1 "CACHE_CPIO_DIR: ${CACHE_CPIO_DIR}" + CLEAR_CPIO_CACHE='yes' + clear_cpio_dir + ls -la ${CACHE_CPIO_DIR} + fi + exit 1 } trap cleanup SIGHUP SIGQUIT SIGINT SIGTERM SIGKILL @@ -75,13 +89,17 @@ for group_modules in ${!AMODULES_*}; do print_info 1 " Merged AMODULES_${group}:'${cmodules}' into MODULES_${group}" done -[ ! -f "${TEMP}" ] && mkdir -p "${TEMP}" -[ ! -f "${CACHE_DIR}" ] && mkdir -p "${CACHE_DIR}" # Based on genkernel.conf, arch-specific configs, and commandline options, # get the real arguments for usage... determine_real_args + +[ ! -f "${TEMP}" ] && mkdir -p "${TEMP}" + +setup_cache_dir + + dump_debugcache NORMAL=${BOLD} print_info 1 "Linux Kernel ${BOLD}${KV}${NORMAL} for ${BOLD}${ARCH}${NORMAL}..." @@ -156,7 +174,6 @@ then echo print_warning 1 'Running multiple genkernels on the same source tree will cause data loss!' print_info 1 "Press ^C to halt; ^D to continue [ ${BOLD}if${NORMAL} you know what you're doing! ]" - cat echo CTEMP="${TEMP}" TEMP=${TMPDIR-/tmp} @@ -409,3 +426,6 @@ print_info 1 'Do NOT report kernel bugs as genkernel bugs unless your bug' print_info 1 'is about the default genkernel configuration...' print_info 1 '' print_info 1 'Make sure you have the latest genkernel before reporting bugs.' + +#Final Cleanup +cleanup diff --git a/genkernel.conf b/genkernel.conf index d45259c..b23f60b 100755 --- a/genkernel.conf +++ b/genkernel.conf @@ -33,6 +33,13 @@ USECOLOR="yes" # Add new kernel to grub? # BOOTLOADER="grub" +# Clear initramfs cpio cache dir +# CLEAR_CPIO_CACHE="yes" + +# Clear build cache dir +# CLEAR_CACHE_DIR="yes" + + # =========GENKERNEL LOCATION CONFIGURATION============ # Variables: # %%ARCH%% - Final determined architecture