kernel/linux: simplify custom tarball handling

Simplify the way the custom tarball is handled:
- fake version="custom"
- at download, simply link the custom tarball to:
    "linux-custom.${custom_extension}"
- at extract, the above allows to simply extract "linux-${LINUX_VERSION}"
  where LINUX_VERISON is set to the fake version="custom"

Not that much convoluted, in fact... :-/

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
This commit is contained in:
Yann E. MORIN" 2011-08-14 19:59:02 +02:00
parent 47229f15af
commit 59499a2cda
3 changed files with 32 additions and 51 deletions

View File

@ -18,11 +18,7 @@ config KERNEL_LINUX_USE_CUSTOM_HEADERS
If you want to use your own full kernel tree, then you want to say 'N'
here, and select KERNEL_LINUX_CUSTOM, in the versions list, below.
config KERNEL_LINUX_INSTALL
bool
default y if ! KERNEL_LINUX_USE_CUSTOM_HEADERS
if KERNEL_LINUX_INSTALL
if ! KERNEL_LINUX_USE_CUSTOM_HEADERS
choice
bool
@ -161,8 +157,9 @@ config KERNEL_VERSION
default "2.6.32.44" if KERNEL_V_2_6_32_44
default "2.6.31.14" if KERNEL_V_2_6_31_14
default "2.6.27.59" if KERNEL_V_2_6_27_59
default "custom" if KERNEL_LINUX_CUSTOM
endif # KERNEL_LINUX_INSTALL
endif # ! KERNEL_LINUX_USE_CUSTOM_HEADERS
if KERNEL_LINUX_USE_CUSTOM_HEADERS

View File

@ -1,6 +1,6 @@
# Linux kernel options
if KERNEL_LINUX_INSTALL
if ! KERNEL_LINUX_USE_CUSTOM_HEADERS
choice
bool
@ -41,4 +41,4 @@ config KERNEL_LINUX_INSTALL_CHECK
If you are in doubt that installed headers are buggy, say 'Y'
here to have an extra check passed onto the headers.
endif # KERNEL_LINUX_INSTALL
endif # ! KERNEL_LINUX_USE_CUSTOM_HEADERS

View File

@ -18,9 +18,25 @@ CT_DoKernelTupleValues() {
# Download the kernel
do_kernel_get() {
local k_ver
if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" \
-a "${CT_KERNEL_LINUX_CUSTOM}" != "y" \
]; then
local custom_name
if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y" ]; then
return 0
fi
if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
# Wee need to know the custom tarball extension,
# so we can cerate a properly-named symlink, which
# we use later on in 'extract'
case "${CT_KERNEL_LINUX_CUSTOM_TARBALL}" in
*.tar.bz2) custom_name="linux-custom.tar.bz2";;
*.tar.gz|*.tgz) custom_name="linux-custom.tar.gz";;
*.tar) custom_name="linux-custom.tar";;
*) CT_Abort "Unknown extension for custom linux tarball '${CT_KERNEL_LINUX_CUSTOM_TARBALL}'";;
esac
CT_DoExecLog DEBUG ln -sf "${CT_KERNEL_LINUX_CUSTOM_TARBALL}" \
"${CT_SRC_DIR}/${custom_name}"
else # Not a custom tarball
case "${CT_KERNEL_VERSION}" in
2.6.*.*|3.*.*)
# 4-part versions (for 2.6 stables and long-terms), and
@ -44,54 +60,22 @@ do_kernel_get() {
# Extract kernel
do_kernel_extract() {
local tar_opt
if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
# We extract the custom linux tree into a directory with a
# well-known name, and strip the leading directory component
# of the extracted pathes. This is needed because we do not
# know the value for this first component, because it is a
# _custom_ tree.
# Also, we have to protect from partial extraction using the
# .extracting and .extracted locks (not using .patching and
# .patched as we are *not* patching that kernel).
if [ -e "${CT_SRC_DIR}/.linux-custom.extracted" ]; then
CT_DoLog DEBUG "Custom linux kernel tree already extracted"
return 0
fi
CT_TestAndAbort "Custom kernel tree partially extracted. Remove before resuming" -f "${CT_SRC_DIR}/.linux-custom.extracting"
CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.linux-custom.extracting"
CT_DoExecLog DEBUG mkdir "${CT_SRC_DIR}/linux-custom"
case "${CT_KERNEL_LINUX_CUSTOM_TARBALL}" in
*.tar.bz2) tar_opt=-j;;
*.tar.gz|*.tgz) tar_opt=-z;;
*.tar) ;;
*) CT_Abort "Don't know how to handle '${CT_KERNEL_LINUX_CUSTOM_TARBALL}': unknown extension";;
esac
CT_DoLog EXTRA "Extracting custom linux kernel"
CT_DoExecLog ALL tar x -C "${CT_SRC_DIR}/linux-custom" \
--strip-components 1 -v ${tar_opt} \
-f "${CT_KERNEL_LINUX_CUSTOM_TARBALL}"
CT_DoExecLog ALL mv -v "${CT_SRC_DIR}/.linux-custom.extracting" "${CT_SRC_DIR}/.linux-custom.extracted"
else
CT_Extract "linux-${CT_KERNEL_VERSION}"
CT_Patch "linux" "${CT_KERNEL_VERSION}"
fi
if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y" ]; then
return 0
fi
# This also handles the custom tarball
CT_Extract "linux-${CT_KERNEL_VERSION}"
CT_Patch "linux" "${CT_KERNEL_VERSION}"
}
# Wrapper to the actual headers install method
do_kernel_headers() {
CT_DoStep INFO "Installing kernel headers"
if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
do_kernel_install
else
if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y" ]; then
do_kernel_custom
else
do_kernel_install
fi
CT_EndStep