scripts/functions: add a generic custom location infrastructure
authorDavid Holsgrove <david.holsgrove@xilinx.com>
Thu Oct 04 13:26:14 2012 +1000 (2012-10-04)
changeset 3075aadd4647dd91
parent 3074 bcfcd68a4e0d
child 3076 63d108a39453
scripts/functions: add a generic custom location infrastructure

Add a generic custom location infrastructure (inspired by the one in
kernel/linux) to allow the user to use custom tarballs or directories
for any component.

Signed-off-by: "David Holsgrove" <david.holsgrove@xilinx.com>
[yann.morin.1998@free.fr: move config option, improve help text, fix API doc]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Message-Id: <131c163c69f9cc81d2be.1349931191@localhost.localdomain>
PatchWork-Id: 190784
Message-Id: <0bbaba9190a76ba97f72.1349931192@localhost.localdomain>
PatchWork-Id: 190785
config/global/paths.in
scripts/functions
     1.1 --- a/config/global/paths.in	Sat Oct 13 18:26:26 2012 +0200
     1.2 +++ b/config/global/paths.in	Thu Oct 04 13:26:14 2012 +1000
     1.3 @@ -19,6 +19,15 @@
     1.4        If you say 'y' here, new downloaded tarballs will be saved in the
     1.5        directory you entered above.
     1.6  
     1.7 +config CUSTOM_LOCATION_ROOT_DIR
     1.8 +    string
     1.9 +    depends on EXPERIMENTAL
    1.10 +    prompt "Directory containing custom source components"
    1.11 +    help
    1.12 +      This is the path CT-NG will attempt to use as a root for locating
    1.13 +      local copies of source components (CUSTOM_LOCATION_ROOT_DIR/component)
    1.14 +      unless a component declares its own specific custom location.
    1.15 +
    1.16  config WORK_DIR
    1.17      string
    1.18      prompt "Working directory" if ! BACKEND
     2.1 --- a/scripts/functions	Sat Oct 13 18:26:26 2012 +0200
     2.2 +++ b/scripts/functions	Thu Oct 04 13:26:14 2012 +1000
     2.3 @@ -516,6 +516,41 @@
     2.4      return 1
     2.5  }
     2.6  
     2.7 +# This function gets the custom source from either a tarball or directory
     2.8 +# Usage: CT_GetCustom <component> <custom_version> <custom_location>
     2.9 +CT_GetCustom() {
    2.10 +    local custom_component="$1"
    2.11 +    local custom_version="$2"
    2.12 +    local custom_location="$3"
    2.13 +    local custom_name="${custom_component}-${custom_version}"
    2.14 +
    2.15 +    CT_TestAndAbort "${custom_name}: CT_CUSTOM_LOCATION_ROOT_DIR or ${custom_component}'s CUSTOM_LOCATION must be set." \
    2.16 +                    -z "${CT_CUSTOM_LOCATION_ROOT_DIR}" -a -z "${custom_location}"
    2.17 +
    2.18 +    if [ -n "${CT_CUSTOM_LOCATION_ROOT_DIR}" \
    2.19 +         -a -z "${custom_location}"          ]; then
    2.20 +        custom_location="${CT_CUSTOM_LOCATION_ROOT_DIR}/${custom_component}"
    2.21 +    fi
    2.22 +
    2.23 +    CT_DoLog EXTRA "Using '${custom_name}' from custom location"
    2.24 +    if [ ! -d "${custom_location}" ]; then
    2.25 +        # We need to know the custom tarball extension,
    2.26 +        # so we can create a properly-named symlink, which
    2.27 +        # we use later on in 'extract'
    2.28 +        case "${custom_location}" in
    2.29 +            *.tar.bz2)      custom_name="${custom_name}.tar.bz2";;
    2.30 +            *.tar.gz|*.tgz) custom_name="${custom_name}.tar.gz";;
    2.31 +            *.tar)          custom_name="${custom_name}.tar";;
    2.32 +            *)  CT_Abort "Unknown extension for custom tarball '${custom_location}'";;
    2.33 +        esac
    2.34 +        CT_DoExecLog DEBUG ln -sf "${custom_location}"  \
    2.35 +                                  "${CT_TARBALLS_DIR}/${custom_name}"
    2.36 +    else
    2.37 +        CT_DoExecLog DEBUG ln -snf "${custom_location}" \
    2.38 +                                   "${CT_SRC_DIR}/${custom_name}"
    2.39 +    fi
    2.40 +}
    2.41 +
    2.42  # This function saves the specified to local storage if possible,
    2.43  # and if so, symlinks it for later usage
    2.44  # Usage: CT_SaveLocal </full/path/file.name>