summaryrefslogtreecommitdiff
path: root/scripts/functions
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/functions')
-rw-r--r--scripts/functions77
1 files changed, 15 insertions, 62 deletions
diff --git a/scripts/functions b/scripts/functions
index d6beceb..81015ff 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -231,25 +231,6 @@ CT_Popd() {
popd >/dev/null 2>&1
}
-# Makes a path absolute
-# Usage: CT_MakeAbsolutePath path
-CT_MakeAbsolutePath() {
- # Try to cd in that directory
- if [ -d "$1" ]; then
- CT_Pushd "$1"
- pwd
- CT_Popd
- else
- # No such directory, fail back to guessing
- case "$1" in
- /*) echo "$1";;
- *) echo "$(pwd)/$1";;
- esac
- fi
-
- return 0
-}
-
# Creates a temporary directory
# $1: variable to assign to
# Usage: CT_MktempDir foo
@@ -279,17 +260,15 @@ CT_GetFileExtension() {
shift
local first_ext="$1"
- CT_Pushd "${CT_TARBALLS_DIR}"
# we need to also check for an empty extension for those very
# peculiar components that don't have one (such as sstrip from
# buildroot).
for ext in ${first_ext} .tar.gz .tar.bz2 .tgz .tar ''; do
- if [ -f "${file}${ext}" ]; then
+ if [ -f "${CT_TARBALLS_DIR}/${file}${ext}" ]; then
echo "${ext}"
break
fi
done
- CT_Popd
return 0
}
@@ -578,40 +557,25 @@ CT_GetCVS() {
# Extract a tarball and patch the resulting sources if necessary.
# Some tarballs need to be extracted in specific places. Eg.: glibc addons
# must be extracted in the glibc directory; uCLibc locales must be extracted
-# in the extra/locale sub-directory of uClibc.
+# in the extra/locale sub-directory of uClibc. This is taken into account
+# by the caller, that did a 'cd' into the correct path before calling us
+# and sets nochdir to 'nochdir'.
+# Usage: CT_ExtractAndPatch <basename> [nochdir]
CT_ExtractAndPatch() {
local file="$1"
+ local nochdir="$2"
local base_file=$(echo "${file}" |cut -d - -f 1)
local ver_file=$(echo "${file}" |cut -d - -f 2-)
local official_patch_dir
local custom_patch_dir
- local libc_addon
local ext=$(CT_GetFileExtension "${file}")
CT_TestAndAbort "'${file}' not found in '${CT_TARBALLS_DIR}'" -z "${ext}"
local full_file="${CT_TARBALLS_DIR}/${file}${ext}"
- CT_Pushd "${CT_SRC_DIR}"
+ [ "${nochdir}" = "nochdir" ] || CT_Pushd "${CT_SRC_DIR}"
- # Add-ons need a little love, really.
- case "${file}" in
- glibc-[a-z]*-*|eglibc-[a-z]*-*)
- CT_TestAndAbort "Trying to extract the C-library addon/locales '${file}' when C-library not yet extracted" ! -d "${CT_LIBC_FILE}"
- cd "${CT_LIBC_FILE}"
- libc_addon=y
- [ -f ".${file}.extracted" ] && return 0
- touch ".${file}.extracted"
- ;;
- uClibc-locale-*)
- CT_TestAndAbort "Trying to extract the C-library addon/locales '${file}' when C-library not yet extracted" ! -d "${CT_LIBC_FILE}"
- cd "${CT_LIBC_FILE}/extra/locale"
- libc_addon=y
- [ -f ".${file}.extracted" ] && return 0
- touch ".${file}.extracted"
- ;;
- esac
-
- # If the directory exists, then consider extraction and patching done
- if [ -d "${file}" ]; then
+ # Check if already extracted
+ if [ -e "${CT_SRC_DIR}/.${file}.extracted" ]; then
CT_DoLog DEBUG "Already extracted '${file}'"
return 0
fi
@@ -623,36 +587,25 @@ CT_ExtractAndPatch() {
.tar) CT_DoExecLog ALL tar xvf "${full_file}";;
*) CT_Abort "Don't know how to handle '${file}': unknown extension" ;;
esac
+ touch "${CT_SRC_DIR}/.${file}.extracted"
# Snapshots might not have the version number in the extracted directory
# name. This is also the case for some (odd) packages, such as D.U.M.A.
# Overcome this issue by symlink'ing the directory.
- if [ ! -d "${file}" -a "${libc_addon}" != "y" ]; then
+ if [ ! -d "${file}" ]; then
case "${ext}" in
.tar.bz2) base=$(tar tjf "${full_file}" |head -n 1 |cut -d / -f 1 || true);;
.tar.gz|.tgz) base=$(tar tzf "${full_file}" |head -n 1 |cut -d / -f 1 || true);;
.tar) base=$(tar tf "${full_file}" |head -n 1 |cut -d / -f 1 || true);;
esac
CT_TestOrAbort "There was a problem when extracting '${file}'" -d "${base}" -o "${base}" != "${file}"
- ln -s "${base}" "${file}"
+ mv "${base}" "${file}"
fi
# Kludge: outside this function, we wouldn't know if we had just extracted
# a libc addon, or a plain package. Apply patches now.
- if [ "${libc_addon}" = "y" ]; then
- # Some addon tarballs directly contain the correct addon directory,
- # while others have the addon directory named after the tarball.
- # Fix that by always using the short name (eg: linuxthreads, ports, etc...)
- addon_short_name=$(echo "${file}" |sed -r -e 's/^[^-]+-([^-]+)-.*$/\1/;')
- if [ ! -d "${addon_short_name}" ]; then
- mv "${file}" "${addon_short_name}"
- # Keep a symlink to avoid re-extracting later on.
- ln -s "${addon_short_name}" "${file}"
- fi
- # If libc addon, we're already in the correct place
- else
- cd "${file}"
- fi
+
+ [ "${nochdir}" = "nochdir" ] || cd "${file}"
official_patch_dir=
custom_patch_dir=
@@ -680,7 +633,7 @@ CT_ExtractAndPatch() {
done
fi
- CT_Popd
+ [ "${nochdir}" = "nochdir" ] || CT_Popd
}
# Two wrappers to call config.(guess|sub) either from CT_TOP_DIR or CT_LIB_DIR.