aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/genkernel.8.txt8
-rwxr-xr-xgen_cmdline.sh8
-rwxr-xr-xgen_determineargs.sh29
-rwxr-xr-xgen_funcs.sh41
-rwxr-xr-xgen_package.sh65
-rwxr-xr-xgenkernel14
-rw-r--r--genkernel.conf9
7 files changed, 127 insertions, 47 deletions
diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index 00b3874..9e37b32 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -390,10 +390,10 @@ OUTPUT SETTINGS
*--modulespackage*=<tbz2>::
File to output a .tar.bz2'd modules after the callbacks have run.
-*--kerncache*=<tbz2>::
- File to output a .tar.bz2'd kernel, contents of '/lib/modules/'
- and the kernel config. NOTE: This is created before the callbacks
- are run.
+*--kerncache*=<archive>::
+ Archive file created using tar containing kernel binary, content of
+ '/lib/modules' and the kernel config. NOTE: Archive is created before
+ the callbacks are run.
*--*[*no-*]*kernel-sources*::
This option is only valid if kerncache is defined If there is a
diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index 69a997a..25ce6e5 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -167,10 +167,9 @@ longusage() {
echo " included..."
echo " --modulespackage=<tbz2> File to output a .tar.bz2'd modules after the"
echo " callbacks have run"
- echo " --kerncache=<tbz2> File to output a .tar.bz2'd kernel contents"
- echo " of /lib/modules/ and the kernel config"
- echo " NOTE: This is created before the callbacks"
- echo " are run!"
+ echo " --kerncache=<archive> Archive file created using tar containing kernel binary,"
+ echo " content of /lib/modules and the kernel config."
+ echo " NOTE: Archive is created before the callbacks are run!"
echo " --no-kernel-sources This option is only valid if kerncache is"
echo " defined. If there is a valid kerncache no checks"
echo " will be made against a kernel source tree"
@@ -651,7 +650,6 @@ parse_cmdline() {
;;
--kerncache=*)
CMD_KERNCACHE="${*#*=}"
- [ ${CMD_KERNCACHE:0:1} != / ] && CMD_KERNCACHE=$PWD/$CMD_KERNCACHE
print_info 2 "KERNCACHE: ${CMD_KERNCACHE}"
;;
--kernname=*)
diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index 875ed2b..e1517ca 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -7,14 +7,16 @@ determine_KV() {
if ! isTrue "${KERNEL_SOURCES}" && [ -e "${KERNCACHE}" ]
then
- /bin/tar -x -C ${TEMP} -f ${KERNCACHE} kerncache.config
- if [ -e ${TEMP}/kerncache.config ]
+ tar -x -C "${TEMP}" -f "${KERNCACHE}" kerncache.config \
+ || gen_die "Failed to extract 'kerncache.config' from '${KERNCACHE}' to '${TEMP}'!"
+
+ if [ -e "${TEMP}/kerncache.config" ]
then
- 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")
- LOV=$(grep ^CONFIG_LOCALVERSION\= ${TEMP}/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/")
+ 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")
+ LOV=$(grep ^CONFIG_LOCALVERSION\ \= "${TEMP}"/kerncache.config | sed -e "s/CONFIG_LOCALVERSION=\"\(.*\)\"/\1/")
KV=${VER}.${PAT}.${SUB}${EXV}${LOV}
else
gen_die "Could not find kerncache.config in the kernel cache! Exiting."
@@ -252,9 +254,18 @@ determine_real_args() {
if [ -n "${KERNCACHE}" ]
then
+ KERNCACHE=$(expand_file "${CMD_KERNCACHE}")
+ if [[ -z "${KERNCACHE}" || "${KERNCACHE}" != *.tar* ]]
+ then
+ gen_die "--kerncache value '${CMD_KERNCACHE}' is invalid!"
+ fi
+
local kerncache_dir=$(dirname "${KERNCACHE}")
- mkdir -p "${kerncache_dir}" \
- || gen_die "Failed to create '${kerncache_dir}'!"
+ if [ ! -d "${kerncache_dir}" ]
+ then
+ mkdir -p "${kerncache_dir}" \
+ || gen_die "Failed to create '${kerncache_dir}'!"
+ fi
fi
if ! isTrue "${BUILD_RAMDISK}"
diff --git a/gen_funcs.sh b/gen_funcs.sh
index c83e261..9a8c794 100755
--- a/gen_funcs.sh
+++ b/gen_funcs.sh
@@ -526,6 +526,47 @@ debug_breakpoint() {
exit 99
}
+# @FUNCTION: get_tar_cmd
+# @USAGE: <ARCHIVE>
+# @DESCRIPTION:
+# Returns tar command which can make use of pbzip2, pxz or pigz when
+# possible.
+#
+# <ARCHIVE> Archive file
+get_tar_cmd() {
+ [[ ${#} -ne 1 ]] \
+ && gen_die "$(get_useful_function_stack "${FUNCNAME}")Invalid usage of ${FUNCNAME}(): Function takes exactly one arguments (${#} given)!"
+
+ local archive_file=${1}
+
+ local -a tar_cmd
+ tar_cmd+=( 'tar -c' )
+
+ local pcmd
+ if [[ "${archive_file}" == *.tar.bz2 ]]
+ then
+ pcmd=$(which pbzip2 2>/dev/null)
+ elif [[ "${archive_file}" == *.tar.xz ]]
+ then
+ pcmd=$(which pxz 2>/dev/null)
+ elif [[ "${archive_file}" == *.tar.gz ]]
+ then
+ pcmd=$(which pigz 2>/dev/null)
+ fi
+
+ if [ -n "${pcmd}" ]
+ then
+ tar_cmd+=( "-I ${pcmd}" )
+ else
+ tar_cmd+=( '-a' )
+ fi
+
+ tar_cmd+=( '-pf' )
+ tar_cmd+=( "${archive_file}" )
+
+ echo "${tar_cmd[@]}"
+}
+
get_useful_function_stack() {
local end_function=${1:-${FUNCNAME}}
local n_functions=${#FUNCNAME[@]}
diff --git a/gen_package.sh b/gen_package.sh
index d8ffac0..8b6816e 100755
--- a/gen_package.sh
+++ b/gen_package.sh
@@ -81,54 +81,73 @@ gen_modulespackage() {
return 0
}
-gen_kerncache()
-{
+gen_kerncache() {
print_info 1 ''
- print_info 1 "Creating kernel cache in '${KERNCACHE}'..."
- rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
- mkdir "${TEMP}/kerncache" || gen_die 'Could not make a directory for the kernel cache!'
+ print_info 1 "Creating kernel cache in '${KERNCACHE}' ..."
+ rm -rf "${TEMP}/kerncache" >/dev/null 2>&1
+ mkdir "${TEMP}/kerncache" || gen_die "Failed to create '${TEMP}/kerncache'!"
local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY})
- local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2})
if [ -z "${tmp_kernel_binary}" ]
then
- gen_die "Cannot locate kernel binary"
+ gen_die "Failed locate kernel binary '${KERNEL_BINARY}'!"
fi
- cd "${KERNEL_OUTPUTDIR}"
- cp "${tmp_kernel_binary}" "${TEMP}/kerncache/kernel-${ARCH}-${KV}" || gen_die 'Could not the copy kernel for the kernel package!'
- cp "${KERNEL_OUTPUTDIR}/.config" "${TEMP}/kerncache/config-${ARCH}-${KV}"
+ cd "${KERNEL_OUTPUTDIR}" || gen_die "Failed to chdir to '${KERNEL_OUTPUTDIR}'!"
+
+ cp -aL "${tmp_kernel_binary}" "${TEMP}/kerncache/kernel-${ARCH}-${KV}" \
+ || gen_die "Could not copy the kernel binary '${tmp_kernel_binary}' for the kernel package!"
+
+ cp -aL "${KERNEL_OUTPUTDIR}/.config" "${TEMP}/kerncache/config-${ARCH}-${KV}" \
+ || gen_die "Could not copy the kernel config '${KERNEL_OUTPUTDIR}/.config' for the kernel package!"
if [[ "$(file --brief --mime-type "${KERNEL_CONFIG}")" == application/x-gzip ]]; then
# Support --kernel-config=/proc/config.gz, mainly
- zcat "${KERNEL_CONFIG}" > "${TEMP}/kerncache/config-${ARCH}-${KV}.orig"
+ zcat "${KERNEL_CONFIG}" > "${TEMP}/kerncache/config-${ARCH}-${KV}.orig" \
+ || gen_die "Could not copy the kernel config '${KERNEL_CONFIG}' for the kernel package!"
else
- cp "${KERNEL_CONFIG}" "${TEMP}/kerncache/config-${ARCH}-${KV}.orig"
+ cp -aL "${KERNEL_CONFIG}" "${TEMP}/kerncache/config-${ARCH}-${KV}.orig" \
+ || gen_die "Could not copy the kernel config '${KERNEL_CONFIG}' for the kernel package!"
fi
- cp "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/kerncache/System.map-${ARCH}-${KV}"
+
+ cp -aL "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/kerncache/System.map-${ARCH}-${KV}" \
+ || gen_die "Could not copy the System.map '${KERNEL_OUTPUTDIR}/System.map' for the kernel package!"
+
if isTrue "${GENZIMAGE}"
then
- cp "${tmp_kernel_binary2}" "${TEMP}/kerncache/kernelz-${ARCH}-${KV}" || gen_die "Could not copy the kernelz for the kernel package"
+ local tmp_kernel_binary2=$(find_kernel_binary ${KERNEL_BINARY_2})
+ if [ -z "${tmp_kernel_binary2}" ]
+ then
+ gen_die "Failed locate kernelz binary '${KERNEL_BINARY_2}'!"
+ fi
+
+ cp -aL "${tmp_kernel_binary2}" "${TEMP}/kerncache/kernelz-${ARCH}-${KV}" \
+ || gen_die "Could not copy the kernelz '${tmp_kernel_binary2}' for the kernel package!"
fi
- echo "VERSION = ${VER}" > "${TEMP}/kerncache/kerncache.config"
+ echo "VERSION = ${VER}" > "${TEMP}/kerncache/kerncache.config" \
+ || gen_die "Failed to write to '${TEMP}/kerncache/kerncache.config'!"
+
echo "PATCHLEVEL = ${PAT}" >> "${TEMP}/kerncache/kerncache.config"
echo "SUBLEVEL = ${SUB}" >> "${TEMP}/kerncache/kerncache.config"
echo "EXTRAVERSION = ${EXV}" >> "${TEMP}/kerncache/kerncache.config"
+ echo "CONFIG_LOCALVERSION = ${LOV}" >> "${TEMP}/kerncache/kerncache.config"
- mkdir -p "${TEMP}/kerncache/lib/modules/"
+ mkdir -p "${TEMP}/kerncache/lib/modules/" \
+ || gen_die "Failed to create '${TEMP}/kerncache/lib/modules'"
- if [ -d ${INSTALL_MOD_PATH}/lib/modules/${KV} ]
+ if [ -d "${INSTALL_MOD_PATH}/lib/modules/${KV}" ]
then
- cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/kerncache/lib/modules"
+ cp -arP "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/kerncache/lib/modules"
fi
- cd "${TEMP}/kerncache"
- /bin/tar -jcpf ${KERNCACHE} * || gen_die 'Could not compress the kernel package!'
+ cd "${TEMP}/kerncache" || gen_die "Failed to chdir to '${TEMP}/kerncache'!"
- cd "${TEMP}"
- isTrue "${CMD_DEBUGCLEANUP}" && rm -rf "${TEMP}/kerncache" > /dev/null
- return 0
+ local -a tar_cmd=( "$(get_tar_cmd "${KERNCACHE}")" )
+ tar_cmd+=( '*' )
+
+ print_info 2 "COMMAND: ${tar_cmd[*]}" 1 0 1
+ eval "${tar_cmd[@]}" || gen_die "Failed to create compressed kernel package '${KERNCACHE}'!"
}
gen_kerncache_extract_kernel()
diff --git a/genkernel b/genkernel
index 919a012..086f5c9 100755
--- a/genkernel
+++ b/genkernel
@@ -321,7 +321,19 @@ then
compile_kernel
fi
-[ -n "${KERNCACHE}" ] && gen_kerncache
+if [ -n "${KERNCACHE}" ]
+then
+ if ! isTrue "${KERNCACHE_IS_VALID}"
+ then
+ # Only update KERNCACHE when KERNCACHE wasn't used because
+ # when it was used nothing has been changed so no update is
+ # necessary.
+ gen_kerncache
+ else
+ print_info 3 "Kerncache was used and kernel/modules therefore didn't change; Skipping '${KERNCACHE}' generation ..."
+ fi
+fi
+
[ -n "${MINKERNPACKAGE}" ] && gen_minkernpackage
[ -n "${MODULESPACKAGE}" ] && gen_modulespackage
diff --git a/genkernel.conf b/genkernel.conf
index 3504b26..84f1088 100644
--- a/genkernel.conf
+++ b/genkernel.conf
@@ -283,11 +283,10 @@ DEFAULT_KERNEL_SOURCE="/usr/src/linux"
# Make and install kernelz image (PowerPC)
#GENZIMAGE="no"
-# File to output a .tar.bz2'd kernel contents
-# of /lib/modules/ and the kernel config
-# NOTE: This is created before the callbacks
-# are run!
-#KERNCACHE="/path/to/file.bz2"
+# Archive file created using tar containing kernel binary, content
+# of /lib/modules and the kernel config.
+# NOTE: Archive is created before the callbacks are run!
+#KERNCACHE="/path/to/file.tar.xz"
# Prefix to kernel module destination, modules
# will be installed in <prefix>/lib/modules