config: make selecting the patch origin a choice rather than a bool
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Mon Aug 31 12:05:52 2009 +0200 (2009-08-31)
changeset 1507ec5314609c00
parent 1506 d33da84b1317
child 1508 7eeeaf4bc78a
config: make selecting the patch origin a choice rather than a bool
config/global/paths.in
scripts/functions
     1.1 --- a/config/global/paths.in	Mon Aug 31 11:57:13 2009 +0200
     1.2 +++ b/config/global/paths.in	Mon Aug 31 12:05:52 2009 +0200
     1.3 @@ -60,36 +60,54 @@
     1.4  #      The reason you might also want to install elsewhere is if you are going
     1.5  #      to package your shinny new toolchain for distribution.
     1.6  
     1.7 -config CUSTOM_PATCH
     1.8 +choice
     1.9 +    prompt "Patches origin"
    1.10      bool
    1.11 -    prompt "Use custom patch directory"
    1.12 +    default PATCH_BUNDLED
    1.13 +
    1.14 +config PATCH_BUNDLED
    1.15 +    bool
    1.16 +    prompt "Bundled only"
    1.17 +    help
    1.18 +      Only apply patches bundled with crosstool-NG.
    1.19 +
    1.20 +config PATCH_LOCAL
    1.21 +    bool
    1.22 +    prompt "Local only"
    1.23 +    select PATCH_USE_LOCAL
    1.24 +    help
    1.25 +      Only apply your local patches.
    1.26 +
    1.27 +config PATCH_BUNDLED_LOCAL
    1.28 +    bool
    1.29 +    prompt "Bundled, then local"
    1.30 +    select PATCH_USE_LOCAL
    1.31 +    help
    1.32 +      Apply the patches bundled with crosstool-NG,
    1.33 +      then apply your local patches.
    1.34 +
    1.35 +endchoice
    1.36 +
    1.37 +config PATCH_ORDER
    1.38 +    string
    1.39 +    default "bundled"           if PATCH_BUNDLED
    1.40 +    default "local"             if PATCH_LOCAL
    1.41 +    default "bundled,local"     if PATCH_BUNDLED_LOCAL
    1.42 +
    1.43 +config PATCH_USE_LOCAL
    1.44 +    bool
    1.45      default n
    1.46 -    help
    1.47 -      If you have custom patches that you want to be applied, say 'Y' here and
    1.48 -      enter the path directory below.
    1.49 -      
    1.50 -      Note that you must ensure that the patch directory is arranged the same
    1.51 -      way the official directory is.
    1.52  
    1.53 -config CUSTOM_PATCH_ONLY
    1.54 -    bool
    1.55 -    prompt "Only use custom patches"
    1.56 -    default n
    1.57 -    depends on CUSTOM_PATCH
    1.58 -    help
    1.59 -      Don't apply patches coming with crosstool-NG, only those patches available
    1.60 -      in the directory below.
    1.61 -      
    1.62 -      If you say 'N' here, then the patches provided with crosstool-NG will be
    1.63 -      applied first, and then your patches.
    1.64 -
    1.65 -config CUSTOM_PATCH_DIR
    1.66 +config LOCAL_PATCH_DIR
    1.67      string
    1.68 -    prompt "Custom patch directory"
    1.69 +    prompt "|  Local patch directory"
    1.70      default ""
    1.71 -    depends on CUSTOM_PATCH
    1.72 +    depends on PATCH_USE_LOCAL
    1.73      help
    1.74        Enter the custom patch directory here.
    1.75 +      
    1.76 +      Note that you must ensure that the directory contianing your custom
    1.77 +      patches is arranged the same way the official directory is.
    1.78  
    1.79  config REMOVE_DOCS
    1.80      bool
     2.1 --- a/scripts/functions	Mon Aug 31 11:57:13 2009 +0200
     2.2 +++ b/scripts/functions	Mon Aug 31 12:05:52 2009 +0200
     2.3 @@ -585,8 +585,10 @@
     2.4      local nochdir="$2"
     2.5      local base_file="${basename%%-*}"
     2.6      local ver_file="${basename#*-}"
     2.7 -    local official_patch_dir
     2.8 -    local custom_patch_dir
     2.9 +    local d
    2.10 +    local -a patch_dirs
    2.11 +    local bundled_patch_dir
    2.12 +    local local_patch_dir
    2.13  
    2.14      # Check if already patched
    2.15      if [ -e "${CT_SRC_DIR}/.${basename}.patched" ]; then
    2.16 @@ -609,13 +611,19 @@
    2.17  
    2.18      CT_DoLog EXTRA "Patching '${basename}'"
    2.19  
    2.20 -    official_patch_dir=
    2.21 -    custom_patch_dir=
    2.22 -    [ "${CT_CUSTOM_PATCH_ONLY}" = "y" ] || official_patch_dir="${CT_LIB_DIR}/patches/${base_file}/${ver_file}"
    2.23 -    [ "${CT_CUSTOM_PATCH}" = "y" ] && custom_patch_dir="${CT_CUSTOM_PATCH_DIR}/${base_file}/${ver_file}"
    2.24 -    for patch_dir in "${official_patch_dir}" "${custom_patch_dir}"; do
    2.25 -        if [ -n "${patch_dir}" -a -d "${patch_dir}" ]; then
    2.26 -            for p in "${patch_dir}"/*.patch; do
    2.27 +    bundled_patch_dir="${CT_LIB_DIR}/patches/${base_file}/${ver_file}"
    2.28 +    local_patch_dir="${CT_CUSTOM_PATCH_DIR}/${base_file}/${ver_file}"
    2.29 +
    2.30 +    case "${CT_PATCH_ORDER}" in
    2.31 +        bundled)        patch_dirs=("${bundled_patch_dir}");;
    2.32 +        local)          patch_dirs=("${local_patch_dir}");;
    2.33 +        bundled,local)  patch_dirs=("${bundled_patch_dir}" "${local_patch_dir}");;
    2.34 +    esac
    2.35 +
    2.36 +    for d in "${patch_dirs[@]}"; do
    2.37 +        CT_DoLog DEBUG "Looking for patches in '${d}'..."
    2.38 +        if [ -n "${d}" -a -d "${d}" ]; then
    2.39 +            for p in "${d}"/*.patch; do
    2.40                  if [ -f "${p}" ]; then
    2.41                      CT_DoLog DEBUG "Applying patch '${p}'"
    2.42                      CT_DoExecLog ALL patch -g0 -F1 -p1 -f <"${p}"