summaryrefslogtreecommitdiff
path: root/scripts/functions
diff options
context:
space:
mode:
authorBryan Hundven <bryanhundven@gmail.com>2015-11-26 12:58:40 (GMT)
committerBryan Hundven <bryanhundven@gmail.com>2015-12-08 15:20:35 (GMT)
commit1b3131448809f05d47cd50a98ede0d1b78eb85f0 (patch)
tree7b8e527e24ee0401edd1e3398ab9715b91774d64 /scripts/functions
parent5d967e8b3949db7f4b8dae31e2f0b14efc568de9 (diff)
CT_GetCustom: Rewrite function to meet expectations
The previous version of CT_GetCustom was a bit... funky. It didn't handle custom versions to location very well. This new version is exactly as it appears: CT_GetCustom <name> <version> <location> The name is the beginning of the archive (file or directory). The version is the second half of the archive. The location is where it can be found. This should be made an absolute path, but this version is expecting the path in kconfig to be absolute. A file should extract to a directory: <name>-<version> A directory will be copied to: <name>-<version> This keeps our expectations of what we should get. Signed-off-by: Bryan Hundven <bryanhundven@gmail.com> Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Diffstat (limited to 'scripts/functions')
-rw-r--r--scripts/functions73
1 files changed, 47 insertions, 26 deletions
diff --git a/scripts/functions b/scripts/functions
index 4761c1e..5a64232 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -1,4 +1,6 @@
-# This file contains some usefull common functions -*- sh -*-
+# -*- mode: sh; tab-width: 4 -*-
+# vi: ts=4:sw=4:sts=4:et
+# This file contains some usefull common functions
# Copyright 2007 Yann E. MORIN
# Licensed under the GPL v2. See COPYING in the root of this package
@@ -625,39 +627,58 @@ CT_GetLocal() {
}
# This function gets the custom source from either a tarball or directory
-# Usage: CT_GetCustom <component> <custom_version> <custom_location>
+# Usage: CT_GetCustom <name> <version> <location>
CT_GetCustom() {
- local custom_component="$1"
- local custom_version="$2"
- local custom_location="$3"
- local custom_name="${custom_component}-${custom_version}"
-
- CT_TestAndAbort "${custom_name}: CT_CUSTOM_LOCATION_ROOT_DIR or ${custom_component}'s CUSTOM_LOCATION must be set." \
- -z "${CT_CUSTOM_LOCATION_ROOT_DIR}" -a -z "${custom_location}"
-
- if [ -n "${CT_CUSTOM_LOCATION_ROOT_DIR}" \
- -a -z "${custom_location}" ]; then
- custom_location="${CT_CUSTOM_LOCATION_ROOT_DIR}/${custom_component}"
+ local component_name="$1"
+ local component_version="$2"
+ local component_location="$3"
+
+ # Some local variables we use to help us figure out what to do
+ local component_location_type="dir" # str: 'file' or 'dir'
+ local component_location_filename="" # filename... if it's a file
+
+ CT_TestAndAbort \
+ "${component_name}: Custom location setting is empty" \
+ -z "${component_location}"
+
+ CT_TestAndAbort \
+ "${component_name}: Custom version setting is empty" \
+ -z "${component_version}"
+
+ if [ -f "${component_location}" ]; then
+ component_location_type="file"
+ component_location_filename="$(basename ${component_location})"
+ elif [ -d "${component_location}" ]; then
+ # Yes, it's the default, but it rules out the else case in the `if'.
+ component_location_type="dir"
+ # as -d and -f say: it's a <directory|file> and is readable!
+ else
+ CT_Abort "${component_name}: Unable to read ${component_location}, make sure the setting is correct and double check the permissions!"
fi
- CT_DoLog EXTRA "Using '${custom_name}' from custom location"
- if [ ! -d "${custom_location}" ]; then
+ if [ "${component_location_type}" = "file" ]; then
+ CT_DoLog EXTRA "Got '${component_location}' from custom location"
# We need to know the custom tarball extension,
# so we can create a properly-named symlink, which
# we use later on in 'extract'
- case "${custom_location}" in
- *.tar.xz) custom_name="${custom_name}.tar.xz";;
- *.tar.bz2) custom_name="${custom_name}.tar.bz2";;
- *.tar.gz|*.tgz) custom_name="${custom_name}.tar.gz";;
- *.tar) custom_name="${custom_name}.tar";;
- *) CT_Abort "Unknown extension for custom tarball '${custom_location}'";;
+ case "${component_location}" in
+ *.tar.xz|*.tar.bz2|*.tar.lzma|*.tar.gz|*.tgz|*.tar|*.zip) ;;
+ *) CT_Abort "Unknown extension for custom tarball '${component_location}'" ;;
esac
- CT_DoExecLog DEBUG ln -sf "${custom_location}" \
- "${CT_TARBALLS_DIR}/${custom_name}"
- else
- CT_DoExecLog DEBUG ln -snf "${custom_location}" \
- "${CT_SRC_DIR}/${custom_name}"
+ [ ! -L "${CT_TARBALLS_DIR}/${component_location_filename}" ] && \
+ CT_DoExecLog DEBUG ln -sf "${component_location}" \
+ "${CT_TARBALLS_DIR}/${component_location_filename}"
+ elif [ "${component_location_type}" = "dir" ]; then
+ CT_DoLog EXTRA "Got '${component_location}' from custom location"
+ [ ! -d "${CT_SRC_DIR}/${component_name}-${component_version}" ] && \
+ CT_DoExecLog DEBUG cp -al "${component_location}" \
+ "${CT_SRC_DIR}/${component_name}-${component_version}"
+
+ # Don't try to extract from source directory, it's extracted!
+ touch "${CT_SRC_DIR}/.${component_name}-${component_version}.extracted"
fi
+ # Don't patch a custom source, it's custom!
+ touch "${CT_SRC_DIR}/.${component_name}-${component_version}.patched"
}
# This function saves the specified to local storage if possible,