Patchwork [02,of,13] scripts/functions: add a generic custom location infrastructure

login
register
mail settings
Submitter David Holsgrove
Date Oct. 11, 2012, 4:53 a.m.
Message ID <131c163c69f9cc81d2be.1349931191@localhost.localdomain>
Download mbox | patch
Permalink /patch/190784/
State Accepted
Commit aadd4647dd91
Headers show

Comments

David Holsgrove - Oct. 11, 2012, 4:53 a.m.
# HG changeset patch
# User David Holsgrove <david.holsgrove@xilinx.com>
# Date 1349321174 -36000
# Node ID 131c163c69f9cc81d2beabaa998dca9c9386df38
# Parent  7a666ba8c0ea5e8f4b18f3c34a8a5bbb170f0233
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>


--
For unsubscribe information see http://sourceware.org/lists.html#faq
Yann E. MORIN - Oct. 13, 2012, 10 p.m.
David, All,

Your patch:
    scripts/functions: add a generic custom location infrastructure

has been applied as #aadd4647dd91. Thank you!

Regards,
Yann E. MORIN.



--
For unsubscribe information see http://sourceware.org/lists.html#faq

Patch

diff -r 7a666ba8c0ea -r 131c163c69f9 scripts/functions
--- a/scripts/functions	Thu Oct 11 14:37:45 2012 +1000
+++ b/scripts/functions	Thu Oct 04 13:26:14 2012 +1000
@@ -516,6 +516,42 @@ 
     return 1
 }
 
+# This function gets the custom source from either a tarball or directory
+# Usage: CT_GetCustom custom_name <custom_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}"
+    fi
+
+    if [ ! -d "${custom_location}" ]; then
+        # 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.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}'";;
+        esac
+        CT_DoLog EXTRA "Using '${custom_name}' from local storage"
+        CT_DoExecLog DEBUG ln -sf "${custom_location}"  \
+                                  "${CT_TARBALLS_DIR}/${custom_name}"
+    else
+        CT_DoLog EXTRA "Using '${custom_name}' from local storage"
+        CT_DoExecLog DEBUG ln -snf "${custom_location}"  \
+                                  "${CT_SRC_DIR}/${custom_name}"
+    fi
+}
+
 # This function saves the specified to local storage if possible,
 # and if so, symlinks it for later usage
 # Usage: CT_SaveLocal </full/path/file.name>