1.1 --- a/scripts/functions Sun Jan 04 14:35:25 2009 +0000
1.2 +++ b/scripts/functions Sun Jan 04 22:17:53 2009 +0000
1.3 @@ -231,25 +231,6 @@
1.4 popd >/dev/null 2>&1
1.5 }
1.6
1.7 -# Makes a path absolute
1.8 -# Usage: CT_MakeAbsolutePath path
1.9 -CT_MakeAbsolutePath() {
1.10 - # Try to cd in that directory
1.11 - if [ -d "$1" ]; then
1.12 - CT_Pushd "$1"
1.13 - pwd
1.14 - CT_Popd
1.15 - else
1.16 - # No such directory, fail back to guessing
1.17 - case "$1" in
1.18 - /*) echo "$1";;
1.19 - *) echo "$(pwd)/$1";;
1.20 - esac
1.21 - fi
1.22 -
1.23 - return 0
1.24 -}
1.25 -
1.26 # Creates a temporary directory
1.27 # $1: variable to assign to
1.28 # Usage: CT_MktempDir foo
1.29 @@ -279,17 +260,15 @@
1.30 shift
1.31 local first_ext="$1"
1.32
1.33 - CT_Pushd "${CT_TARBALLS_DIR}"
1.34 # we need to also check for an empty extension for those very
1.35 # peculiar components that don't have one (such as sstrip from
1.36 # buildroot).
1.37 for ext in ${first_ext} .tar.gz .tar.bz2 .tgz .tar ''; do
1.38 - if [ -f "${file}${ext}" ]; then
1.39 + if [ -f "${CT_TARBALLS_DIR}/${file}${ext}" ]; then
1.40 echo "${ext}"
1.41 break
1.42 fi
1.43 done
1.44 - CT_Popd
1.45
1.46 return 0
1.47 }
1.48 @@ -578,40 +557,25 @@
1.49 # Extract a tarball and patch the resulting sources if necessary.
1.50 # Some tarballs need to be extracted in specific places. Eg.: glibc addons
1.51 # must be extracted in the glibc directory; uCLibc locales must be extracted
1.52 -# in the extra/locale sub-directory of uClibc.
1.53 +# in the extra/locale sub-directory of uClibc. This is taken into account
1.54 +# by the caller, that did a 'cd' into the correct path before calling us
1.55 +# and sets nochdir to 'nochdir'.
1.56 +# Usage: CT_ExtractAndPatch <basename> [nochdir]
1.57 CT_ExtractAndPatch() {
1.58 local file="$1"
1.59 + local nochdir="$2"
1.60 local base_file=$(echo "${file}" |cut -d - -f 1)
1.61 local ver_file=$(echo "${file}" |cut -d - -f 2-)
1.62 local official_patch_dir
1.63 local custom_patch_dir
1.64 - local libc_addon
1.65 local ext=$(CT_GetFileExtension "${file}")
1.66 CT_TestAndAbort "'${file}' not found in '${CT_TARBALLS_DIR}'" -z "${ext}"
1.67 local full_file="${CT_TARBALLS_DIR}/${file}${ext}"
1.68
1.69 - CT_Pushd "${CT_SRC_DIR}"
1.70 + [ "${nochdir}" = "nochdir" ] || CT_Pushd "${CT_SRC_DIR}"
1.71
1.72 - # Add-ons need a little love, really.
1.73 - case "${file}" in
1.74 - glibc-[a-z]*-*|eglibc-[a-z]*-*)
1.75 - CT_TestAndAbort "Trying to extract the C-library addon/locales '${file}' when C-library not yet extracted" ! -d "${CT_LIBC_FILE}"
1.76 - cd "${CT_LIBC_FILE}"
1.77 - libc_addon=y
1.78 - [ -f ".${file}.extracted" ] && return 0
1.79 - touch ".${file}.extracted"
1.80 - ;;
1.81 - uClibc-locale-*)
1.82 - CT_TestAndAbort "Trying to extract the C-library addon/locales '${file}' when C-library not yet extracted" ! -d "${CT_LIBC_FILE}"
1.83 - cd "${CT_LIBC_FILE}/extra/locale"
1.84 - libc_addon=y
1.85 - [ -f ".${file}.extracted" ] && return 0
1.86 - touch ".${file}.extracted"
1.87 - ;;
1.88 - esac
1.89 -
1.90 - # If the directory exists, then consider extraction and patching done
1.91 - if [ -d "${file}" ]; then
1.92 + # Check if already extracted
1.93 + if [ -e "${CT_SRC_DIR}/.${file}.extracted" ]; then
1.94 CT_DoLog DEBUG "Already extracted '${file}'"
1.95 return 0
1.96 fi
1.97 @@ -623,36 +587,25 @@
1.98 .tar) CT_DoExecLog ALL tar xvf "${full_file}";;
1.99 *) CT_Abort "Don't know how to handle '${file}': unknown extension" ;;
1.100 esac
1.101 + touch "${CT_SRC_DIR}/.${file}.extracted"
1.102
1.103 # Snapshots might not have the version number in the extracted directory
1.104 # name. This is also the case for some (odd) packages, such as D.U.M.A.
1.105 # Overcome this issue by symlink'ing the directory.
1.106 - if [ ! -d "${file}" -a "${libc_addon}" != "y" ]; then
1.107 + if [ ! -d "${file}" ]; then
1.108 case "${ext}" in
1.109 .tar.bz2) base=$(tar tjf "${full_file}" |head -n 1 |cut -d / -f 1 || true);;
1.110 .tar.gz|.tgz) base=$(tar tzf "${full_file}" |head -n 1 |cut -d / -f 1 || true);;
1.111 .tar) base=$(tar tf "${full_file}" |head -n 1 |cut -d / -f 1 || true);;
1.112 esac
1.113 CT_TestOrAbort "There was a problem when extracting '${file}'" -d "${base}" -o "${base}" != "${file}"
1.114 - ln -s "${base}" "${file}"
1.115 + mv "${base}" "${file}"
1.116 fi
1.117
1.118 # Kludge: outside this function, we wouldn't know if we had just extracted
1.119 # a libc addon, or a plain package. Apply patches now.
1.120 - if [ "${libc_addon}" = "y" ]; then
1.121 - # Some addon tarballs directly contain the correct addon directory,
1.122 - # while others have the addon directory named after the tarball.
1.123 - # Fix that by always using the short name (eg: linuxthreads, ports, etc...)
1.124 - addon_short_name=$(echo "${file}" |sed -r -e 's/^[^-]+-([^-]+)-.*$/\1/;')
1.125 - if [ ! -d "${addon_short_name}" ]; then
1.126 - mv "${file}" "${addon_short_name}"
1.127 - # Keep a symlink to avoid re-extracting later on.
1.128 - ln -s "${addon_short_name}" "${file}"
1.129 - fi
1.130 - # If libc addon, we're already in the correct place
1.131 - else
1.132 - cd "${file}"
1.133 - fi
1.134 +
1.135 + [ "${nochdir}" = "nochdir" ] || cd "${file}"
1.136
1.137 official_patch_dir=
1.138 custom_patch_dir=
1.139 @@ -680,7 +633,7 @@
1.140 done
1.141 fi
1.142
1.143 - CT_Popd
1.144 + [ "${nochdir}" = "nochdir" ] || CT_Popd
1.145 }
1.146
1.147 # Two wrappers to call config.(guess|sub) either from CT_TOP_DIR or CT_LIB_DIR.