Skip to content

Commit 9e78e1b

Browse files
committed
external_deps: improve extract logging
1 parent 18a7b71 commit 9e78e1b

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

external_deps/build.sh

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,38 +93,44 @@ log() {
9393
# Extract an archive into the given subdirectory of the build dir and cd to it
9494
# Usage: extract <filename> <directory>
9595
extract() {
96-
rm -rf "${2}"
97-
mkdir -p "${2}"
98-
case "${1}" in
96+
local archive_file="${1}"; shift
97+
local extract_dir="${1}"; shift
98+
99+
local archive_name="$(basename "${archive_file}")"
100+
log STATUS "Extracting ${archive_name}"
101+
102+
rm -rf "${extract_dir}"
103+
mkdir -p "${extract_dir}"
104+
case "${archive_file}" in
99105
*.tar.bz2)
100-
tar xjf "${1}" -C "${2}"
106+
tar xjf "${archive_file}" -C "${extract_dir}"
101107
;;
102108
*.tar.xz)
103-
tar xJf "${1}" -C "${2}"
109+
tar xJf "${archive_file}" -C "${extract_dir}"
104110
;;
105111
*.tar.gz|*.tgz)
106-
tar xzf "${1}" -C "${2}"
112+
tar xzf "${archive_file}" -C "${extract_dir}"
107113
;;
108114
*.zip)
109-
unzip -d "${2}" "${1}"
115+
unzip -d "${extract_dir}" "${archive_file}"
110116
;;
111117
*.cygtar.bz2)
112118
# Some Windows NaCl SDK packages have incorrect symlinks, so use
113119
# cygtar to extract them.
114-
"${SCRIPT_DIR}/cygtar.py" -xjf "${1}" -C "${2}"
120+
"${SCRIPT_DIR}/cygtar.py" -xjf "${archive_file}" -C "${extract_dir}"
115121
;;
116122
*.dmg)
117123
local dmg_temp_dir="$(mktemp -d)"
118-
hdiutil attach -mountpoint "${dmg_temp_dir}" "${1}"
119-
cp -R "${dmg_temp_dir}/"* "${2}/"
124+
hdiutil attach -mountpoint "${dmg_temp_dir}" "${archive_file}"
125+
cp -R "${dmg_temp_dir}/"* "${extract_dir}/"
120126
hdiutil detach "${dmg_temp_dir}"
121127
rmdir "${dmg_temp_dir}"
122128
;;
123129
*)
124-
log ERROR "Unknown archive type for ${1}"
130+
log ERROR "Unknown archive type for ${archive_name}"
125131
;;
126132
esac
127-
cd "${2}"
133+
cd "${extract_dir}"
128134
}
129135

130136
download() {

0 commit comments

Comments
 (0)