scripts/build/kernel/linux.sh
changeset 2603 461b9c476104
parent 2567 92e02b41d2d1
child 2604 d35d7cdc0494
     1.1 --- a/scripts/build/kernel/linux.sh	Fri Jul 22 21:45:07 2011 +0200
     1.2 +++ b/scripts/build/kernel/linux.sh	Sun Aug 14 19:59:02 2011 +0200
     1.3 @@ -18,9 +18,25 @@
     1.4  # Download the kernel
     1.5  do_kernel_get() {
     1.6      local k_ver
     1.7 -    if [    "${CT_KERNEL_LINUX_INSTALL}" = "y"  \
     1.8 -         -a "${CT_KERNEL_LINUX_CUSTOM}" != "y"  \
     1.9 -       ]; then
    1.10 +    local custom_name
    1.11 +
    1.12 +    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y"  ]; then
    1.13 +        return 0
    1.14 +    fi
    1.15 +
    1.16 +    if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
    1.17 +        # Wee need to know the custom tarball extension,
    1.18 +        # so we can cerate a properly-named symlink, which
    1.19 +        # we use later on in 'extract'
    1.20 +        case "${CT_KERNEL_LINUX_CUSTOM_TARBALL}" in
    1.21 +            *.tar.bz2)      custom_name="linux-custom.tar.bz2";;
    1.22 +            *.tar.gz|*.tgz) custom_name="linux-custom.tar.gz";;
    1.23 +            *.tar)          custom_name="linux-custom.tar";;
    1.24 +            *)  CT_Abort "Unknown extension for custom linux tarball '${CT_KERNEL_LINUX_CUSTOM_TARBALL}'";;
    1.25 +        esac
    1.26 +        CT_DoExecLog DEBUG ln -sf "${CT_KERNEL_LINUX_CUSTOM_TARBALL}"  \
    1.27 +                                  "${CT_SRC_DIR}/${custom_name}"
    1.28 +    else # Not a custom tarball
    1.29          case "${CT_KERNEL_VERSION}" in
    1.30              2.6.*.*|3.*.*)
    1.31                  # 4-part versions (for 2.6 stables and long-terms), and
    1.32 @@ -44,54 +60,22 @@
    1.33  
    1.34  # Extract kernel
    1.35  do_kernel_extract() {
    1.36 -    local tar_opt
    1.37 -    if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
    1.38 -        if [ "${CT_KERNEL_LINUX_CUSTOM}" = "y" ]; then
    1.39 -            # We extract the custom linux tree into a directory with a
    1.40 -            # well-known name, and strip the leading directory component
    1.41 -            # of the extracted pathes. This is needed because we do not
    1.42 -            # know the value for this first component, because it is a
    1.43 -            # _custom_ tree.
    1.44 -            # Also, we have to protect from partial extraction using the
    1.45 -            # .extracting and .extracted locks (not using .patching and
    1.46 -            # .patched as we are *not* patching that kernel).
    1.47 -
    1.48 -            if [ -e "${CT_SRC_DIR}/.linux-custom.extracted" ]; then
    1.49 -                CT_DoLog DEBUG "Custom linux kernel tree already extracted"
    1.50 -                return 0
    1.51 -            fi
    1.52 -
    1.53 -            CT_TestAndAbort "Custom kernel tree partially extracted. Remove before resuming" -f "${CT_SRC_DIR}/.linux-custom.extracting"
    1.54 -            CT_DoExecLog DEBUG touch "${CT_SRC_DIR}/.linux-custom.extracting"
    1.55 -            CT_DoExecLog DEBUG mkdir "${CT_SRC_DIR}/linux-custom"
    1.56 -
    1.57 -            case "${CT_KERNEL_LINUX_CUSTOM_TARBALL}" in
    1.58 -                *.tar.bz2)      tar_opt=-j;;
    1.59 -                *.tar.gz|*.tgz) tar_opt=-z;;
    1.60 -                *.tar)          ;;
    1.61 -                *)              CT_Abort "Don't know how to handle '${CT_KERNEL_LINUX_CUSTOM_TARBALL}': unknown extension";;
    1.62 -            esac
    1.63 -            CT_DoLog EXTRA "Extracting custom linux kernel"
    1.64 -            CT_DoExecLog ALL tar x -C "${CT_SRC_DIR}/linux-custom"      \
    1.65 -                                 --strip-components 1 -v ${tar_opt}     \
    1.66 -                                 -f "${CT_KERNEL_LINUX_CUSTOM_TARBALL}"
    1.67 -
    1.68 -            CT_DoExecLog ALL mv -v "${CT_SRC_DIR}/.linux-custom.extracting" "${CT_SRC_DIR}/.linux-custom.extracted"
    1.69 -        else
    1.70 -            CT_Extract "linux-${CT_KERNEL_VERSION}"
    1.71 -            CT_Patch "linux" "${CT_KERNEL_VERSION}"
    1.72 -        fi
    1.73 +    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y"  ]; then
    1.74 +        return 0
    1.75      fi
    1.76 +    # This also handles the custom tarball
    1.77 +    CT_Extract "linux-${CT_KERNEL_VERSION}"
    1.78 +    CT_Patch "linux" "${CT_KERNEL_VERSION}"
    1.79  }
    1.80  
    1.81  # Wrapper to the actual headers install method
    1.82  do_kernel_headers() {
    1.83      CT_DoStep INFO "Installing kernel headers"
    1.84  
    1.85 -    if [ "${CT_KERNEL_LINUX_INSTALL}" = "y" ]; then
    1.86 +    if [ "${CT_KERNEL_LINUX_USE_CUSTOM_HEADERS}" = "y" ]; then
    1.87 +        do_kernel_custom
    1.88 +    else
    1.89          do_kernel_install
    1.90 -    else
    1.91 -        do_kernel_custom
    1.92      fi
    1.93  
    1.94      CT_EndStep