scripts/functions
changeset 1126 1ab3d2e08c8b
parent 1124 eec7a46a4c19
child 1127 1fd2e11ccdd9
     1.1 --- a/scripts/functions	Mon Jan 05 20:37:03 2009 +0000
     1.2 +++ b/scripts/functions	Mon Jan 05 23:02:43 2009 +0000
     1.3 @@ -554,58 +554,60 @@
     1.4      CT_DoExecLog ALL rm -rf "${tmp_dir}"
     1.5  }
     1.6  
     1.7 -# Extract a tarball and patch the resulting sources if necessary.
     1.8 +# Extract a tarball
     1.9  # Some tarballs need to be extracted in specific places. Eg.: glibc addons
    1.10  # must be extracted in the glibc directory; uCLibc locales must be extracted
    1.11  # in the extra/locale sub-directory of uClibc. This is taken into account
    1.12  # by the caller, that did a 'cd' into the correct path before calling us
    1.13  # and sets nochdir to 'nochdir'.
    1.14 -# Usage: CT_ExtractAndPatch <basename> [nochdir]
    1.15 -CT_ExtractAndPatch() {
    1.16 -    local file="$1"
    1.17 +# Usage: CT_Extract <basename> [nochdir]
    1.18 +CT_Extract() {
    1.19 +    local basename="$1"
    1.20      local nochdir="$2"
    1.21 -    local base_file=$(echo "${file}" |cut -d - -f 1)
    1.22 -    local ver_file=$(echo "${file}" |cut -d - -f 2-)
    1.23 -    local official_patch_dir
    1.24 -    local custom_patch_dir
    1.25 -    local ext=$(CT_GetFileExtension "${file}")
    1.26 -    CT_TestAndAbort "'${file}' not found in '${CT_TARBALLS_DIR}'" -z "${ext}"
    1.27 -    local full_file="${CT_TARBALLS_DIR}/${file}${ext}"
    1.28 +    local ext=$(CT_GetFileExtension "${basename}")
    1.29 +    CT_TestAndAbort "'${basename}' not found in '${CT_TARBALLS_DIR}'" -z "${ext}"
    1.30 +    local full_file="${CT_TARBALLS_DIR}/${basename}${ext}"
    1.31 +
    1.32 +    # Check if already extracted
    1.33 +    if [ -e "${CT_SRC_DIR}/.${basename}.extracted" ]; then
    1.34 +        CT_DoLog DEBUG "Already extracted '${basename}'"
    1.35 +        return 0
    1.36 +    fi
    1.37  
    1.38      [ "${nochdir}" = "nochdir" ] || CT_Pushd "${CT_SRC_DIR}"
    1.39  
    1.40 -    # Check if already extracted
    1.41 -    if [ -e "${CT_SRC_DIR}/.${file}.extracted" ]; then
    1.42 -        CT_DoLog DEBUG "Already extracted '${file}'"
    1.43 -        return 0
    1.44 -    fi
    1.45 -
    1.46 -    CT_DoLog EXTRA "Extracting and patching '${file}'"
    1.47 +    CT_DoLog EXTRA "Extracting '${basename}'"
    1.48      case "${ext}" in
    1.49          .tar.bz2)     CT_DoExecLog ALL tar xvjf "${full_file}";;
    1.50          .tar.gz|.tgz) CT_DoExecLog ALL tar xvzf "${full_file}";;
    1.51          .tar)         CT_DoExecLog ALL tar xvf  "${full_file}";;
    1.52 -        *)            CT_Abort "Don't know how to handle '${file}': unknown extension" ;;
    1.53 +        *)            CT_Abort "Don't know how to handle '${basename}${ext}': unknown extension" ;;
    1.54      esac
    1.55 -    touch "${CT_SRC_DIR}/.${file}.extracted"
    1.56  
    1.57 -    # Snapshots might not have the version number in the extracted directory
    1.58 -    # name. This is also the case for some (odd) packages, such as D.U.M.A.
    1.59 -    # Overcome this issue by symlink'ing the directory.
    1.60 -    if [ ! -d "${file}" ]; then
    1.61 -        case "${ext}" in
    1.62 -            .tar.bz2)     base=$(tar tjf "${full_file}" |head -n 1 |cut -d / -f 1 || true);;
    1.63 -            .tar.gz|.tgz) base=$(tar tzf "${full_file}" |head -n 1 |cut -d / -f 1 || true);;
    1.64 -            .tar)         base=$(tar tf  "${full_file}" |head -n 1 |cut -d / -f 1 || true);;
    1.65 -        esac
    1.66 -        CT_TestOrAbort "There was a problem when extracting '${file}'" -d "${base}" -o "${base}" != "${file}"
    1.67 -        ln -s "${base}" "${file}"
    1.68 +    touch "${CT_SRC_DIR}/.${basename}.extracted"
    1.69 +
    1.70 +    [ "${nochdir}" = "nochdir" ] || CT_Popd
    1.71 +}
    1.72 +
    1.73 +# Patches the specified component
    1.74 +# Usage: CT_Patch <basename> [nochdir]
    1.75 +CT_Patch() {
    1.76 +    local basename="$1"
    1.77 +    local nochdir="$2"
    1.78 +    local base_file="${basename%%-*}"
    1.79 +    local ver_file="${basename#*-}"
    1.80 +    local official_patch_dir
    1.81 +    local custom_patch_dir
    1.82 +
    1.83 +    # Check if already patched
    1.84 +    if [ -e "${CT_SRC_DIR}/.${basename}.patched" ]; then
    1.85 +        CT_DoLog DEBUG "Already patched '${basename}'"
    1.86 +        return 0
    1.87      fi
    1.88  
    1.89 -    # Kludge: outside this function, we wouldn't know if we had just extracted
    1.90 -    # a libc addon, or a plain package. Apply patches now.
    1.91 +    [ "${nochdir}" = "nochdir" ] || CT_Pushd "${CT_SRC_DIR}/${basename}"
    1.92  
    1.93 -    [ "${nochdir}" = "nochdir" ] || cd "${file}"
    1.94 +    CT_DoLog EXTRA "Patching '${basename}'"
    1.95  
    1.96      official_patch_dir=
    1.97      custom_patch_dir=
    1.98 @@ -633,6 +635,8 @@
    1.99          done
   1.100      fi
   1.101  
   1.102 +    touch "${CT_SRC_DIR}/.${basename}.patched"
   1.103 +
   1.104      [ "${nochdir}" = "nochdir" ] || CT_Popd
   1.105  }
   1.106