kernel/linux: simplify custom tarball handling
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Aug 14 19:59:02 2011 +0200 (2011-08-14)
changeset 2603461b9c476104
parent 2602 242695a00db5
child 2604 d35d7cdc0494
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>
config/kernel/linux.in
config/kernel/linux.in.2
scripts/build/kernel/linux.sh
     1.1 --- a/config/kernel/linux.in	Sun Aug 14 16:05:33 2011 +0200
     1.2 +++ b/config/kernel/linux.in	Sun Aug 14 19:59:02 2011 +0200
     1.3 @@ -18,11 +18,7 @@
     1.4        If you want to use your own full kernel tree, then you want to say 'N'
     1.5        here, and select KERNEL_LINUX_CUSTOM, in the versions list, below.
     1.6  
     1.7 -config KERNEL_LINUX_INSTALL
     1.8 -    bool
     1.9 -    default y if ! KERNEL_LINUX_USE_CUSTOM_HEADERS
    1.10 -
    1.11 -if KERNEL_LINUX_INSTALL
    1.12 +if ! KERNEL_LINUX_USE_CUSTOM_HEADERS
    1.13  
    1.14  choice
    1.15      bool
    1.16 @@ -161,8 +157,9 @@
    1.17      default "2.6.32.44" if KERNEL_V_2_6_32_44
    1.18      default "2.6.31.14" if KERNEL_V_2_6_31_14
    1.19      default "2.6.27.59" if KERNEL_V_2_6_27_59
    1.20 +    default "custom" if KERNEL_LINUX_CUSTOM
    1.21  
    1.22 -endif # KERNEL_LINUX_INSTALL
    1.23 +endif # ! KERNEL_LINUX_USE_CUSTOM_HEADERS
    1.24  
    1.25  if KERNEL_LINUX_USE_CUSTOM_HEADERS
    1.26  
     2.1 --- a/config/kernel/linux.in.2	Sun Aug 14 16:05:33 2011 +0200
     2.2 +++ b/config/kernel/linux.in.2	Sun Aug 14 19:59:02 2011 +0200
     2.3 @@ -1,6 +1,6 @@
     2.4  # Linux kernel options
     2.5  
     2.6 -if KERNEL_LINUX_INSTALL
     2.7 +if ! KERNEL_LINUX_USE_CUSTOM_HEADERS
     2.8  
     2.9  choice
    2.10      bool
    2.11 @@ -41,4 +41,4 @@
    2.12        If you are in doubt that installed headers are buggy, say 'Y'
    2.13        here to have an extra check passed onto the headers.
    2.14  
    2.15 -endif # KERNEL_LINUX_INSTALL
    2.16 +endif # ! KERNEL_LINUX_USE_CUSTOM_HEADERS
     3.1 --- a/scripts/build/kernel/linux.sh	Sun Aug 14 16:05:33 2011 +0200
     3.2 +++ b/scripts/build/kernel/linux.sh	Sun Aug 14 19:59:02 2011 +0200
     3.3 @@ -18,9 +18,25 @@
     3.4  # Download the kernel
     3.5  do_kernel_get() {
     3.6      local k_ver
     3.7 -    if [    "${CT_KERNEL_LINUX_INSTALL}" = "y"  \
     3.8 -         -a "${CT_KERNEL_LINUX_CUSTOM}" != "y"  \
     3.9 -       ]; then
    3.10 +    local custom_name
    3.11 +
    3.12 +    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y"  ]; then
    3.13 +        return 0
    3.14 +    fi
    3.15 +
    3.16 +    if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
    3.17 +        # Wee need to know the custom tarball extension,
    3.18 +        # so we can cerate a properly-named symlink, which
    3.19 +        # we use later on in 'extract'
    3.20 +        case "${CT_KERNEL_LINUX_CUSTOM_TARBALL}" in
    3.21 +            *.tar.bz2)      custom_name="linux-custom.tar.bz2";;
    3.22 +            *.tar.gz|*.tgz) custom_name="linux-custom.tar.gz";;
    3.23 +            *.tar)          custom_name="linux-custom.tar";;
    3.24 +            *)  CT_Abort "Unknown extension for custom linux tarball '${CT_KERNEL_LINUX_CUSTOM_TARBALL}'";;
    3.25 +        esac
    3.26 +        CT_DoExecLog DEBUG ln -sf "${CT_KERNEL_LINUX_CUSTOM_TARBALL}"  \
    3.27 +                                  "${CT_SRC_DIR}/${custom_name}"
    3.28 +    else # Not a custom tarball
    3.29          case "${CT_KERNEL_VERSION}" in
    3.30              2.6.*.*|3.*.*)
    3.31                  # 4-part versions (for 2.6 stables and long-terms), and
    3.32 @@ -44,54 +60,22 @@
    3.33  
    3.34  # Extract kernel
    3.35  do_kernel_extract() {
    3.36 -    local tar_opt
    3.37 -    if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
    3.38 -        if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
    3.39 -            # We extract the custom linux tree into a directory with a
    3.40 -            # well-known name, and strip the leading directory component
    3.41 -            # of the extracted pathes. This is needed because we do not
    3.42 -            # know the value for this first component, because it is a
    3.43 -            # _custom_ tree.
    3.44 -            # Also, we have to protect from partial extraction using the
    3.45 -            # .extracting and .extracted locks (not using .patching and
    3.46 -            # .patched as we are *not* patching that kernel).
    3.47 -
    3.48 -            if [ -e "${CT_SRC_DIR}/.linux-custom.extracted" ]; then
    3.49 -                CT_DoLog DEBUG "Custom linux kernel tree already extracted"
    3.50 -                return 0
    3.51 -            fi
    3.52 -
    3.53 -            CT_TestAndAbort "Custom kernel tree partially extracted. Remove before resuming" -f "${CT_SRC_DIR}/.linux-custom.extracting"
    3.54 -            CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.linux-custom.extracting"
    3.55 -            CT_DoExecLog DEBUG mkdir "${CT_SRC_DIR}/linux-custom"
    3.56 -
    3.57 -            case "${CT_KERNEL_LINUX_CUSTOM_TARBALL}" in
    3.58 -                *.tar.bz2)      tar_opt=-j;;
    3.59 -                *.tar.gz|*.tgz) tar_opt=-z;;
    3.60 -                *.tar)          ;;
    3.61 -                *)              CT_Abort "Don't know how to handle '${CT_KERNEL_LINUX_CUSTOM_TARBALL}': unknown extension";;
    3.62 -            esac
    3.63 -            CT_DoLog EXTRA "Extracting custom linux kernel"
    3.64 -            CT_DoExecLog ALL tar x -C "${CT_SRC_DIR}/linux-custom"      \
    3.65 -                                 --strip-components 1 -v ${tar_opt}     \
    3.66 -                                 -f "${CT_KERNEL_LINUX_CUSTOM_TARBALL}"
    3.67 -
    3.68 -            CT_DoExecLog ALL mv -v "${CT_SRC_DIR}/.linux-custom.extracting" "${CT_SRC_DIR}/.linux-custom.extracted"
    3.69 -        else
    3.70 -            CT_Extract "linux-${CT_KERNEL_VERSION}"
    3.71 -            CT_Patch "linux" "${CT_KERNEL_VERSION}"
    3.72 -        fi
    3.73 +    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y"  ]; then
    3.74 +        return 0
    3.75      fi
    3.76 +    # This also handles the custom tarball
    3.77 +    CT_Extract "linux-${CT_KERNEL_VERSION}"
    3.78 +    CT_Patch "linux" "${CT_KERNEL_VERSION}"
    3.79  }
    3.80  
    3.81  # Wrapper to the actual headers install method
    3.82  do_kernel_headers() {
    3.83      CT_DoStep INFO "Installing kernel headers"
    3.84  
    3.85 -    if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
    3.86 +    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y" ]; then
    3.87 +        do_kernel_custom
    3.88 +    else
    3.89          do_kernel_install
    3.90 -    else
    3.91 -        do_kernel_custom
    3.92      fi
    3.93  
    3.94      CT_EndStep