From 5a3ac05d80044d929b5fa7e58be00487ea61257a Mon Sep 17 00:00:00 2001 From: Tim Yamin Date: Thu, 29 Jul 2004 20:50:36 +0000 Subject: [PATCH] Patch for bug #57867 adding --cachedir= by Martin Parm. git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@123 67a159dc-881f-0410-a524-ba9dfbe2cb84 --- gen_cmdline.sh | 7 ++++++- gen_determineargs.sh | 11 +++++++++++ gen_funcs.sh | 12 +++++++++++- genkernel | 1 + genkernel.conf | 21 ++++++++++++--------- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 3b1fa24..2c776a2 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -61,8 +61,9 @@ longusage() { echo " --no-lvm2 Don't add in LVM2 support." echo " --bootloader=grub Add new kernel to GRUB configuration" echo " Internals" - echo " --tempdir= Location of Genkernel's temporary directory" 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 " Output Settings" echo " --minkernpackage= File to output a .tar.bz2'd kernel and initrd:" echo " No modules outside of the initrd will be" @@ -278,6 +279,10 @@ parse_cmdline() { CMD_INSTALL_MOD_PATH=`parse_opt "$*"` print_info 2 "CMD_INSTALL_MOD_PATH: $CMD_INSTALL_MOD_PATH" ;; + --cachedir*) + CACHE_DIR=`parse_opt "$*"` + print_info 2 "CACHE_DIR: $CACHE_DIR" + ;; --minkernpackage*) CMD_MINKERNPACKAGE=`parse_opt "$*"` print_info 2 "MINKERNPACKAGE: $CMD_MINKERNPACKAGE" diff --git a/gen_determineargs.sh b/gen_determineargs.sh index f276226..e6866a8 100644 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -82,6 +82,17 @@ determine_real_args() { UTILS_AS="${CMD_UTILS_AS}" fi + CACHE_DIR=`arch_replace "${CACHE_DIR}"` + + BUSYBOX_BINCACHE=`cache_replace "${BUSYBOX_BINCACHE}"` + MODULE_INIT_TOOLS_BINCACHE=`cache_replace "${MODULE_INIT_TOOLS_BINCACHE}"` + MODUTILS_BINCACHE=`cache_replace "${MODUTILS_BINCACHE}"` + DIETLIBC_BINCACHE=`cache_replace "${DIETLIBC_BINCACHE}"` + DIETLIBC_BINCACHE_TEMP=`cache_replace "${DIETLIBC_BINCACHE_TEMP}"` + DEVFSD_BINCACHE=`cache_replace "${DEVFSD_BINCACHE}"` + DEVFSD_CONF_BINCACHE=`cache_replace "${DEVFSD_CONF_BINCACHE}"` + UDEV_BINCACHE=`cache_replace "${UDEV_BINCACHE}"` + DEFAULT_KERNEL_CONFIG=`arch_replace "${DEFAULT_KERNEL_CONFIG}"` BUSYBOX_CONFIG=`arch_replace "${BUSYBOX_CONFIG}"` BUSYBOX_BINCACHE=`arch_replace "${BUSYBOX_BINCACHE}"` diff --git a/gen_funcs.sh b/gen_funcs.sh index 9a49b01..0d6da0e 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -170,13 +170,23 @@ print_warning() var_replace() { - echo "${3}" | sed -e "s/%%${1}%%/${2}/g" - + # Escape '\' and '.' in $2 to make it safe to use + # in the later sed expression + local SAFE_VAR + SAFE_VAR=`echo "${2}" | sed -e 's/\([\/\.]\)/\\\\\\1/g'` + + echo "${3}" | sed -e "s/%%${1}%%/${SAFE_VAR}/g" - + echo "${3}" | sed -e "s/%%${1}%%/${SAFE_VAR}/g" >> /tmp/out } arch_replace() { var_replace "ARCH" "${ARCH}" "${1}" } +cache_replace() { + var_replace "CACHE" "${CACHE_DIR}" "${1}" +} + clear_log() { [ -f "${DEBUGFILE}" ] && echo > "${DEBUGFILE}" } diff --git a/genkernel b/genkernel index d554576..3f04396 100755 --- a/genkernel +++ b/genkernel @@ -50,6 +50,7 @@ source ${ARCH_CONFIG} || gen_die "Could not read ${ARCH_CONFIG}" source ${GK_SHARE}/${ARCH}/modules_load || gen_die "Could not read ${GK_SHARE}/${ARCH}/modules_load" [ ! -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... diff --git a/genkernel.conf b/genkernel.conf index 0353f61..d568b22 100755 --- a/genkernel.conf +++ b/genkernel.conf @@ -35,7 +35,8 @@ USECOLOR="yes" # =========GENKERNEL LOCATION CONFIGURATION============ # Variables: -# %%ARCH%% - Final determined architecture +# %%ARCH%% - Final determined architecture +# %%CACHE%% - Final determined cache location # Default share directory location GK_SHARE="/usr/share/genkernel" @@ -43,6 +44,8 @@ GK_SHARE="/usr/share/genkernel" # Location of helper-scripts #GK_BIN="${GK_SHARE}/bin" GK_BIN="${GK_SHARE}" +# Location of the default cache +CACHE_DIR="${GK_SHARE}/pkg/%%ARCH%%" # Log output file DEBUGFILE="/var/log/genkernel.log" # Debug Level @@ -59,7 +62,7 @@ BUSYBOX_CONFIG="${GK_SHARE}/%%ARCH%%/busy-config" BUSYBOX_VER="1.00-pre7-losetup-crypto-alpha" # Busybox bin-cache location, to store pre-compiled busybox # binary is just a bzip2 busybox executable -BUSYBOX_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/busybox-${BUSYBOX_VER}-%%ARCH%%.bz2" +BUSYBOX_BINCACHE="%%CACHE%%/busybox-${BUSYBOX_VER}-%%ARCH%%.bz2" # Location of BusyBox source tarball BUSYBOX_SRCTAR="${GK_SHARE}/pkg/busybox-${BUSYBOX_VER}.tar.bz2" # Directory created after busybox tarball is extracted @@ -68,26 +71,26 @@ BUSYBOX_DIR="busybox-${BUSYBOX_VER}" MODULE_INIT_TOOLS_VER="0.9.15-pre4" MODULE_INIT_TOOLS_SRCTAR="${GK_SHARE}/pkg/module-init-tools-${MODULE_INIT_TOOLS_VER}.tar.bz2" MODULE_INIT_TOOLS_DIR="module-init-tools-${MODULE_INIT_TOOLS_VER}" -MODULE_INIT_TOOLS_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/insmod-%%ARCH%%-static-2.6.bz2" +MODULE_INIT_TOOLS_BINCACHE="%%CACHE%%/insmod-%%ARCH%%-static-2.6.bz2" MODUTILS_VER="2.4.26" MODUTILS_SRCTAR="${GK_SHARE}/pkg/modutils-${MODUTILS_VER}.tar.bz2" MODUTILS_DIR="modutils-${MODUTILS_VER}" -MODUTILS_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/insmod-%%ARCH%%-static-2.4.bz2" +MODUTILS_BINCACHE="%%CACHE%%/insmod-%%ARCH%%-static-2.4.bz2" DIETLIBC_VER="0.24" DIETLIBC_SRCTAR="${GK_SHARE}/pkg/dietlibc-${DIETLIBC_VER}.tar.bz2" DIETLIBC_DIR="dietlibc-${DIETLIBC_VER}" -DIETLIBC_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/dietlibc-${DIETLIBC_VER}-%%ARCH%%.tar.bz2" -DIETLIBC_BINCACHE_TEMP="${GK_SHARE}/pkg/%%ARCH%%/dietlibc-${DIETLIBC_VER}-%%ARCH%%-tempdir" +DIETLIBC_BINCACHE="%%CACHE%%/dietlibc-${DIETLIBC_VER}-%%ARCH%%.tar.bz2" +DIETLIBC_BINCACHE_TEMP="%%CACHE%%/dietlibc-${DIETLIBC_VER}-%%ARCH%%-tempdir" DEVFSD_VER="1.3.25-dietlibc-kernel25" DEVFSD_SRCTAR="${GK_SHARE}/pkg/devfsd-${DEVFSD_VER}.tar.bz2" DEVFSD_DIR="devfsd" -DEVFSD_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/devfsd-${DEVFSD_VER}-%%ARCH%%.bz2" -DEVFSD_CONF_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/devfsd-conf-${DIETLIBC_VER}-%%ARCH%%.bz2" +DEVFSD_BINCACHE="%%CACHE%%/devfsd-${DEVFSD_VER}-%%ARCH%%.bz2" +DEVFSD_CONF_BINCACHE="%%CACHE%%/devfsd-conf-${DIETLIBC_VER}-%%ARCH%%.bz2" UDEV_VER="030" UDEV_DIR="udev-${UDEV_VER}" UDEV_SRCTAR="${GK_SHARE}/pkg/udev-${UDEV_VER}.tar.bz2" -UDEV_BINCACHE="${GK_SHARE}/pkg/%%ARCH%%/udev-${UDEV_VER}-%%ARCH%%.tar.bz2" +UDEV_BINCACHE="%%CACHE%%/udev-${UDEV_VER}-%%ARCH%%.tar.bz2" -- 2.26.2