Patch for bug #57867 adding --cachedir=<dir> by Martin Parm.
authorTim Yamin <plasmaroo@gentoo.org>
Thu, 29 Jul 2004 20:50:36 +0000 (20:50 +0000)
committerTim Yamin <plasmaroo@gentoo.org>
Thu, 29 Jul 2004 20:50:36 +0000 (20:50 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/genkernel/trunk@123 67a159dc-881f-0410-a524-ba9dfbe2cb84

gen_cmdline.sh
gen_determineargs.sh
gen_funcs.sh
genkernel
genkernel.conf

index 3b1fa24d70aa33fed62f8713533723e6628aff39..2c776a29c108f26949fe900a6cbde788b7bbfa84 100755 (executable)
@@ -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=<dir>         Location of Genkernel's temporary directory"
   echo "       --arch-override=<arch>  Force to arch instead of autodetect"
+  echo "       --cachedir=<dir>        Override the default cache location"
+  echo "       --tempdir=<dir>         Location of Genkernel's temporary directory"
   echo "  Output Settings"
   echo "        --minkernpackage=<tbz2> 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"
index f2762265310369a7180e8adb4cfca82656657029..e6866a8d7f9c69a7a92ea2a2f9f78439bd201e7e 100644 (file)
@@ -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}"`
index 9a49b0126f7a080fc6a550bb15af37eca224a2e5..0d6da0eaf58045d6e0e34f35be97af246836918e 100755 (executable)
@@ -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}"
 }
index d5545760df03ed1a067884570292c49d4c2131da..3f04396a6fcfc8b120ba5dbf5ce3e739b2d9f2cc 100755 (executable)
--- 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...
index 0353f616fad9ccb97ec52dd74a05ba1ab99cd425..d568b2265b59f872301e75381e95da99d65f085f 100755 (executable)
@@ -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"