Skip to content

Commit 4d64cff

Browse files
Rusydy-MekariRusydy
authored andcommitted
Fix download extraction and resolve "latest" version
Clean the download directory before extracting to prevent errors on retries. Resolve "latest" to an actual version number before download. Simplify extraction by stripping components. Also fix bison path check in install script.
1 parent e09cb20 commit 4d64cff

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

bin/download

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ download_source() {
2424
local version=$2
2525
local download_path=$3
2626

27+
# Clean download directory to prevent extraction errors on retry
28+
if [ -d "$download_path" ]; then
29+
rm -rf "${download_path:?}"/*
30+
fi
31+
mkdir -p "$download_path"
32+
33+
# Resolve "latest" to actual version number
34+
if [ "$version" = "latest" ]; then
35+
local script_dir
36+
script_dir=$(dirname "${BASH_SOURCE[0]}")
37+
version=$("$script_dir/latest-stable")
38+
echo "Resolved 'latest' to version $version"
39+
fi
40+
2741
local php_version
2842
php_version=$(get_php_version "$version")
2943
local download_file="$download_path/php-${php_version}.tar.gz"
@@ -34,16 +48,7 @@ download_source() {
3448
curl -Lo "$download_file" "$download_url"
3549

3650
echo "Extracting PHP source..."
37-
tar -xzf "$download_file" -C "$download_path" --strip-components=0
38-
39-
# The extracted directory name
40-
local extracted_dir="$download_path/php-src-php-${php_version}"
41-
42-
# Move contents to download_path root if extracted to subdirectory
43-
if [ -d "$extracted_dir" ]; then
44-
mv "$extracted_dir"/* "$download_path"/
45-
rm -rf "$extracted_dir"
46-
fi
51+
tar -xzf "$download_file" -C "$download_path" --strip-components=1
4752

4853
# Clean up tarball
4954
rm -f "$download_file"

bin/install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ os_based_configure_options() {
251251
export ASDF_PKG_MISSING="freetype"
252252
fi
253253

254-
if [ -n "$bison_path" ]; then
254+
if [ -z "$bison_path" ]; then
255255
export ASDF_PKG_MISSING="$ASDF_PKG_MISSING bison"
256256
fi
257257

0 commit comments

Comments
 (0)