mirror of
https://github.com/shivammathur/setup-php.git
synced 2026-12-06 09:50:56 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ca1ee6aee | ||
|
|
7ad1a97ee1 | ||
|
|
91a169a846 | ||
|
|
9ebeb73afd | ||
|
|
8c5b98f2bd |
@@ -7,7 +7,6 @@ describe('Extension tests', () => {
|
|||||||
${'none'} | ${'7.4'} | ${'Disable-AllShared'}
|
${'none'} | ${'7.4'} | ${'Disable-AllShared'}
|
||||||
${':intl'} | ${'7.4'} | ${'Disable-Extension intl'}
|
${':intl'} | ${'7.4'} | ${'Disable-Extension intl'}
|
||||||
${'ast-beta'} | ${'7.4'} | ${'Add-Extension ast beta'}
|
${'ast-beta'} | ${'7.4'} | ${'Add-Extension ast beta'}
|
||||||
${'ast-stable'} | ${'7.4'} | ${'Add-Extension ast stable'}
|
|
||||||
${'blackfire'} | ${'7.3'} | ${'Add-Blackfire blackfire'}
|
${'blackfire'} | ${'7.3'} | ${'Add-Blackfire blackfire'}
|
||||||
${'blackfire-1.31.0'} | ${'7.3'} | ${'Add-Blackfire blackfire-1.31.0'}
|
${'blackfire-1.31.0'} | ${'7.3'} | ${'Add-Blackfire blackfire-1.31.0'}
|
||||||
${'grpc-1.2.3'} | ${'7.4'} | ${'Add-Extension grpc stable 1.2.3'}
|
${'grpc-1.2.3'} | ${'7.4'} | ${'Add-Extension grpc stable 1.2.3'}
|
||||||
@@ -42,6 +41,14 @@ describe('Extension tests', () => {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it('omits the stable argument from the generated Windows command', async () => {
|
||||||
|
const script = await extensions.addExtensionWindows(
|
||||||
|
'mbstring-stable',
|
||||||
|
'8.4'
|
||||||
|
);
|
||||||
|
expect(script.trim()).toBe('Add-Extension mbstring');
|
||||||
|
});
|
||||||
|
|
||||||
it.each`
|
it.each`
|
||||||
extension | version | output
|
extension | version | output
|
||||||
${'none'} | ${'7.4'} | ${'disable_all_shared'}
|
${'none'} | ${'7.4'} | ${'disable_all_shared'}
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -180,7 +180,7 @@ export async function addExtensionWindows(
|
|||||||
add_script += await utils.joins(
|
add_script += await utils.joins(
|
||||||
'\nAdd-Extension',
|
'\nAdd-Extension',
|
||||||
ext_name,
|
ext_name,
|
||||||
ext_version
|
ext_version.replace('stable', '')
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
// match extensions for compiling from source
|
// match extensions for compiling from source
|
||||||
|
|||||||
@@ -167,8 +167,9 @@ get_pecl_version() {
|
|||||||
local extension=$1
|
local extension=$1
|
||||||
local requested=${2:-stable}
|
local requested=${2:-stable}
|
||||||
local states=("stable" "rc" "preview" "beta" "alpha" "devel" "snapshot")
|
local states=("stable" "rc" "preview" "beta" "alpha" "devel" "snapshot")
|
||||||
|
local curl_opts=("${curl_opts[@]}" --fail)
|
||||||
local stability major_version response pecl_version pattern
|
local stability major_version response pecl_version pattern
|
||||||
response=$(get -s -n "" "https://pecl.php.net/rest/r/$extension/allreleases.xml")
|
response=$(get -s -n "" "https://pecl.php.net/rest/r/$extension/allreleases.xml") || response=
|
||||||
if [[ "$requested" =~ ^[0-9] ]]; then
|
if [[ "$requested" =~ ^[0-9] ]]; then
|
||||||
# Preserve exact pins and PECL's case-sensitive archive directory names.
|
# Preserve exact pins and PECL's case-sensitive archive directory names.
|
||||||
pecl_version=$(echo "$response" | grep -Fio "<v>$requested</v>" | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1)
|
pecl_version=$(echo "$response" | grep -Fio "<v>$requested</v>" | head -n 1 | cut -d '>' -f 2 | cut -d '<' -f 1)
|
||||||
@@ -176,6 +177,10 @@ get_pecl_version() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
requested="$(echo "$requested" | tr '[:upper:]' '[:lower:]')"
|
requested="$(echo "$requested" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
# Only relax stable when the complete PECL release list contains no stable release.
|
||||||
|
if [[ "$requested" = stable && "$response" = *'<r>'*'</r>'*'</a>'* ]] && ! grep -Fqi '<s>stable</s>' <<< "$response"; then
|
||||||
|
requested=snapshot
|
||||||
|
fi
|
||||||
[[ " ${states[*]} " = *" $requested "* ]] || return 0
|
[[ " ${states[*]} " = *" $requested "* ]] || return 0
|
||||||
IFS=' ' read -r -a states <<< "$(echo "${states[@]}" | grep -Eo ".*$requested")"
|
IFS=' ' read -r -a states <<< "$(echo "${states[@]}" | grep -Eo ".*$requested")"
|
||||||
stability="$(IFS='|' ; echo "${states[*]}")"
|
stability="$(IFS='|' ; echo "${states[*]}")"
|
||||||
|
|||||||
@@ -403,27 +403,30 @@ Function Add-ComposerToolHelper() {
|
|||||||
}
|
}
|
||||||
return composer global show $prefix$tool 2>&1 | findstr '^versions'
|
return composer global show $prefix$tool 2>&1 | findstr '^versions'
|
||||||
} else {
|
} else {
|
||||||
$release_stream = [System.IO.MemoryStream]::New([System.Text.Encoding]::ASCII.GetBytes($release))
|
$scoped_dir = "$composer_bin\_tools\$tool"
|
||||||
$scoped_dir_suffix = (Get-FileHash -InputStream $release_stream -Algorithm sha256).Hash
|
|
||||||
$scoped_dir = "$composer_bin\_tools\$tool-$scoped_dir_suffix"
|
|
||||||
$unix_scoped_dir = $scoped_dir.replace('\', '/')
|
$unix_scoped_dir = $scoped_dir.replace('\', '/')
|
||||||
if(-not(Test-Path $scoped_dir\vendor\autoload.php)) {
|
$log = if((Test-Path $scoped_dir\vendor\autoload.php) -and $tool_version -match '^v?\d+\.\d+\.\d+([-+][a-zA-Z0-9.+-]+)?$') {
|
||||||
New-Item -ItemType Directory -Force -Path $scoped_dir > $null 2>&1
|
composer show $prefix$tool $tool_version -d $unix_scoped_dir 2>$null | findstr '^versions'
|
||||||
Set-Content -Path $scoped_dir\composer.json -Value "{}"
|
}
|
||||||
|
if(-not $log) {
|
||||||
|
if($tool_version -eq 'latest') { $tool_version = '*' }
|
||||||
|
if(-not(Test-Path $scoped_dir\composer.json)) {
|
||||||
|
New-Item -ItemType File -Path $scoped_dir\composer.json -Value '{}' -Force >$null
|
||||||
|
}
|
||||||
if((composer show $prefix$tool $tool_version -d $unix_scoped_dir -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) {
|
if((composer show $prefix$tool $tool_version -d $unix_scoped_dir -a 2>&1 | findstr '^type *: *composer-plugin') -and ($composer_args -ne '')) {
|
||||||
composer config -d $unix_scoped_dir --no-plugins allow-plugins."$prefix$tool" true >$null 2>&1
|
composer config -d $unix_scoped_dir --no-plugins allow-plugins."$prefix$tool" true >$null 2>&1
|
||||||
}
|
}
|
||||||
composer require $prefix$release -d $unix_scoped_dir $composer_args >$null 2>&1
|
composer require "$prefix${tool}:$tool_version" -d $unix_scoped_dir --update-with-dependencies $composer_args >$null 2>&1
|
||||||
if($LASTEXITCODE -ne 0) {
|
if($LASTEXITCODE -ne 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
$log = composer show $prefix$tool -d $unix_scoped_dir 2>&1 | findstr '^versions'
|
||||||
}
|
}
|
||||||
$log = composer show $prefix$tool -d $unix_scoped_dir 2>&1 | findstr '^versions'
|
|
||||||
if(-not $log) {
|
if(-not $log) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
[System.Environment]::SetEnvironmentVariable(($tool.replace('-', '_') + '_bin'), "$scoped_dir\vendor\bin")
|
[System.Environment]::SetEnvironmentVariable(($tool.replace('-', '_') + '_bin'), "$scoped_dir\vendor\bin")
|
||||||
Add-Path $scoped_dir\vendor\bin
|
Add-Path $scoped_dir\vendor\bin -Force:(Test-Path -LiteralPath "$scoped_dir\phar\$tool.bat")
|
||||||
return $log
|
return $log
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -478,6 +481,14 @@ Function Add-ComposerTool() {
|
|||||||
Add-Log $tick $tool "Added $tool $tool_version"
|
Add-Log $tick $tool "Added $tool $tool_version"
|
||||||
} elseif($fallback_url) {
|
} elseif($fallback_url) {
|
||||||
Add-Log "!" $tool "Could not setup $tool using Composer. Falling back to PHAR."
|
Add-Log "!" $tool "Could not setup $tool using Composer. Falling back to PHAR."
|
||||||
|
if($scope -eq 'scoped') {
|
||||||
|
$bin_dir = "$composer_bin\_tools\$tool\phar"
|
||||||
|
New-Item -ItemType Directory -Path $bin_dir -Force >$null
|
||||||
|
Add-Path $bin_dir -Force
|
||||||
|
$env:PATH = "$bin_dir;$env:PATH"
|
||||||
|
$alias_command = "Set-Alias $tool $tool.bat"
|
||||||
|
Add-ToProfile $current_profile "/C:$alias_command" $alias_command
|
||||||
|
}
|
||||||
Add-Tool $fallback_url $tool $fallback_version_parameter
|
Add-Tool $fallback_url $tool $fallback_version_parameter
|
||||||
} else {
|
} else {
|
||||||
Add-Log $cross $tool "Could not setup $tool"
|
Add-Log $cross $tool "Could not setup $tool"
|
||||||
|
|||||||
@@ -333,18 +333,24 @@ add_composer_tool_helper() {
|
|||||||
composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1 || return 1
|
composer global require "$prefix$release" "$composer_args" >/dev/null 2>&1 || return 1
|
||||||
composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
|
composer global show "$prefix$tool" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
scoped_dir="$composer_bin/_tools/$tool-$(echo -n "$release" | shasum -a 256 | cut -d ' ' -f 1)"
|
scoped_dir="$composer_bin/_tools/$tool"
|
||||||
if ! [ -f "$scoped_dir/vendor/autoload.php" ]; then
|
if [[ ! -f "$scoped_dir/vendor/autoload.php" || ! "$tool_version" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+([-+][a-zA-Z0-9.+-]+)?$ ]] ||
|
||||||
|
! composer show "$prefix$tool" "$tool_version" -d "$scoped_dir" 2>/dev/null | grep '^versions' > /tmp/composer.log; then
|
||||||
|
[ "$tool_version" != latest ] || tool_version='*'
|
||||||
mkdir -p "$scoped_dir"
|
mkdir -p "$scoped_dir"
|
||||||
echo '{}' | tee "$scoped_dir/composer.json" >/dev/null
|
[ -f "$scoped_dir/composer.json" ] || echo '{}' > "$scoped_dir/composer.json"
|
||||||
if composer show "$prefix$tool" "$tool_version" -d "$scoped_dir" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then
|
if composer show "$prefix$tool" "$tool_version" -d "$scoped_dir" -a 2>&1 | grep -qE '^type *: *composer-plugin' && [ -n "$composer_args" ]; then
|
||||||
composer config -d "$scoped_dir" --no-plugins allow-plugins."$prefix$tool" true >/dev/null 2>&1
|
composer config -d "$scoped_dir" --no-plugins allow-plugins."$prefix$tool" true >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
composer require "$prefix$release" -d "$scoped_dir" "$composer_args" >/dev/null 2>&1 || return 1
|
composer require "$prefix$tool:$tool_version" -d "$scoped_dir" --update-with-dependencies ${composer_args:+"$composer_args"} >/dev/null 2>&1 || return 1
|
||||||
|
composer show "$prefix$tool" -d "$scoped_dir" 2>/dev/null | grep '^versions' > /tmp/composer.log
|
||||||
fi
|
fi
|
||||||
composer show "$prefix$tool" -d "$scoped_dir" 2>&1 | grep -E ^versions | sudo tee /tmp/composer.log >/dev/null 2>&1
|
|
||||||
[ -s /tmp/composer.log ] || return 1
|
[ -s /tmp/composer.log ] || return 1
|
||||||
add_path "$scoped_dir"/vendor/bin
|
add_path "$scoped_dir"/vendor/bin
|
||||||
|
# Switch the fallback's tool-cache link back to the Composer launcher.
|
||||||
|
if [[ -L "$tool_cache_path_dir/$tool" && "$(readlink "$tool_cache_path_dir/$tool")" = "$scoped_dir/phar/$tool" ]]; then
|
||||||
|
sudo ln -sfn "$scoped_dir/vendor/bin/$tool" "$tool_cache_path_dir/$tool"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +378,12 @@ add_composer_tool() {
|
|||||||
add_log "$tick" "$tool" "Added $tool $tool_version"
|
add_log "$tick" "$tool" "Added $tool $tool_version"
|
||||||
elif [ -n "$fallback_url" ]; then
|
elif [ -n "$fallback_url" ]; then
|
||||||
add_log "!" "$tool" "Could not setup $tool using Composer. Falling back to PHAR."
|
add_log "!" "$tool" "Could not setup $tool using Composer. Falling back to PHAR."
|
||||||
add_tool "$fallback_url" "$tool" "$fallback_version_parameter"
|
if [ "$scope" = scoped ]; then
|
||||||
|
# Keep the PHAR private. Only its tool-cache link belongs on the runner PATH.
|
||||||
|
PATH="$scoped_dir/phar:$PATH" tool_path_dir="$scoped_dir/phar" add_tool "$fallback_url" "$tool" "$fallback_version_parameter"
|
||||||
|
else
|
||||||
|
add_tool "$fallback_url" "$tool" "$fallback_version_parameter"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
add_log "$cross" "$tool" "Could not setup $tool"
|
add_log "$cross" "$tool" "Could not setup $tool"
|
||||||
fi
|
fi
|
||||||
|
|||||||
+62
-28
@@ -46,6 +46,13 @@ update_lists_helper() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Search active APT files, including symlinks, without descending into directories.
|
||||||
|
grep_sources() (
|
||||||
|
shopt -s nullglob
|
||||||
|
local files=("$list_dir"/*.list "$list_dir"/*.sources)
|
||||||
|
(( ${#files[@]} )) && grep -d skip -D skip "$@" -- "${files[@]}"
|
||||||
|
)
|
||||||
|
|
||||||
# Function to update the package lists.
|
# Function to update the package lists.
|
||||||
update_lists() {
|
update_lists() {
|
||||||
local ppa=${1:-}
|
local ppa=${1:-}
|
||||||
@@ -56,7 +63,7 @@ update_lists() {
|
|||||||
if [ -f "$ppa_search" ]; then
|
if [ -f "$ppa_search" ]; then
|
||||||
list="$ppa_search"
|
list="$ppa_search"
|
||||||
else
|
else
|
||||||
list="$(grep -Elr "$ppa_search" "$list_dir" 2>/dev/null | head -n 1)"
|
list="$(grep_sources -El -e "$ppa_search" 2>/dev/null | head -n 1)"
|
||||||
fi
|
fi
|
||||||
[ -n "$list" ] || return 1
|
[ -n "$list" ] || return 1
|
||||||
status_file="/tmp/os_lists_refresh_${list##*/}"
|
status_file="/tmp/os_lists_refresh_${list##*/}"
|
||||||
@@ -226,10 +233,10 @@ handle_existing_list() {
|
|||||||
echo "Repository $ppa ($branches) already exists" && return 1
|
echo "Repository $ppa ($branches) already exists" && return 1
|
||||||
fi
|
fi
|
||||||
if merged_components="$(merge_components_from_file "$check_lists_file" "$branches")"; then
|
if merged_components="$(merge_components_from_file "$check_lists_file" "$branches")"; then
|
||||||
sudo rm -f "$check_lists_file" && printf '%s\n' "$merged_components" && return 0
|
printf '%s\n' "$merged_components" && return 0
|
||||||
fi
|
fi
|
||||||
if [[ "$list_format" = "deb822" && "$check_lists_file" = *.list ]]; then
|
if [[ "$list_format" = "deb822" && "$check_lists_file" = *.list ]]; then
|
||||||
sudo rm -f "$check_lists_file" && printf '%s\n' "$branches" && return 0
|
printf '%s\n' "$branches" && return 0
|
||||||
fi
|
fi
|
||||||
echo "Repository $ppa ($branches) already exists" && return 1
|
echo "Repository $ppa ($branches) already exists" && return 1
|
||||||
}
|
}
|
||||||
@@ -243,19 +250,23 @@ write_list() {
|
|||||||
local components=$5
|
local components=$5
|
||||||
local key_file=$6
|
local key_file=$6
|
||||||
local list_basename="${ppa%%/*}"-"$ID"-"${ppa#*/}"-"$suite"
|
local list_basename="${ppa%%/*}"-"$ID"-"${ppa#*/}"-"$suite"
|
||||||
local arch by_hash=
|
local arch list dest by_hash=
|
||||||
arch="$(dpkg --print-architecture)"
|
arch="$(dpkg --print-architecture)"
|
||||||
case "${url%/}" in
|
case "${url%/}" in
|
||||||
"$ppa_sp/sury"|"$ppa_sp/apache2") by_hash=' by-hash=force' ;;
|
"$ppa_sp/sury"|"$ppa_sp/apache2") by_hash=' by-hash=force' ;;
|
||||||
esac
|
esac
|
||||||
sudo rm -f "$list_dir"/"${ppa/\//-}".list "$list_dir"/"${ppa/\//-}".sources "$list_dir"/"$list_basename".list "$list_dir"/"$list_basename".sources || true
|
dest="$list_dir/$list_basename.$(get_sources_extension "$type")"
|
||||||
|
for list in "$list_dir/${ppa/\//-}".{list,sources} "$list_dir/$list_basename".{list,sources}; do
|
||||||
|
[[ "$list" = "$dest" ]] || remove_list_entry "$list" "$url" || return 1
|
||||||
|
done
|
||||||
|
preserve_list "$dest" "$url" || return 1
|
||||||
if [ "$type" = "deb822" ]; then
|
if [ "$type" = "deb822" ]; then
|
||||||
{
|
{
|
||||||
printf '%s\n' "Types: deb" "URIs: $url" "Suites: $suite" "Components: $components" "Architectures: $arch" "Signed-By: $key_file"
|
printf '%s\n' "Types: deb" "URIs: $url" "Suites: $suite" "Components: $components" "Architectures: $arch" "Signed-By: $key_file"
|
||||||
if [ -n "$by_hash" ]; then printf '%s\n' 'By-Hash: force'; fi
|
if [ -n "$by_hash" ]; then printf '%s\n' 'By-Hash: force'; fi
|
||||||
} | sudo tee "$list_dir"/"$list_basename".sources >/dev/null
|
} | sudo tee "$dest" >/dev/null
|
||||||
else
|
else
|
||||||
echo "deb [arch=$arch signed-by=$key_file$by_hash] $url $suite $components" | sudo tee "$list_dir"/"$list_basename".list >/dev/null 2>&1
|
echo "deb [arch=$arch signed-by=$key_file$by_hash] $url $suite $components" | sudo tee "$dest" >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,7 +277,7 @@ check_lists() {
|
|||||||
local match_file=
|
local match_file=
|
||||||
check_lists_file=
|
check_lists_file=
|
||||||
if [ -n "$pattern" ]; then
|
if [ -n "$pattern" ]; then
|
||||||
match_file=$(grep -Elr "$pattern" "$list_dir" 2>/dev/null | head -n 1)
|
match_file=$(grep_sources -El -e "$pattern" 2>/dev/null | head -n 1)
|
||||||
fi
|
fi
|
||||||
if [ -n "$match_file" ]; then
|
if [ -n "$match_file" ]; then
|
||||||
check_lists_file="$match_file"
|
check_lists_file="$match_file"
|
||||||
@@ -306,6 +317,7 @@ add_list() {
|
|||||||
fi
|
fi
|
||||||
[ -e "$key_source" ] && key_file=$key_source || key_file="$key_dir"/"${ppa/\//-}"-keyring.gpg
|
[ -e "$key_source" ] && key_file=$key_source || key_file="$key_dir"/"${ppa/\//-}"-keyring.gpg
|
||||||
add_key "$ppa" "$ppa_url" "$package_dist" "$key_source" "$key_file" "${6:-}" || return 1
|
add_key "$ppa" "$ppa_url" "$package_dist" "$key_source" "$key_file" "${6:-}" || return 1
|
||||||
|
[[ -z "$list_path" ]] || remove_list_entry "$list_path" "$ppa_url" || return 1
|
||||||
write_list "$list_format" "$ppa" "$ppa_url" "$package_dist" "$branches" "$key_file" || return 1
|
write_list "$list_format" "$ppa" "$ppa_url" "$package_dist" "$branches" "$key_file" || return 1
|
||||||
list_path="$list_dir"/"${ppa%%/*}"-"$ID"-"${ppa#*/}"-"$package_dist"."$list_extension"
|
list_path="$list_dir"/"${ppa%%/*}"-"$ID"-"${ppa#*/}"-"$package_dist"."$list_extension"
|
||||||
# A caller requesting an index needs a successful refresh, even if APT has cached lists.
|
# A caller requesting an index needs a successful refresh, even if APT has cached lists.
|
||||||
@@ -337,29 +349,50 @@ check_ppa() {
|
|||||||
check_lists "$ppa" "$primary_pattern" "$secondary_pattern" || return 1
|
check_lists "$ppa" "$primary_pattern" "$secondary_pattern" || return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Remove matching entries from one APT file and invalidate its cached refresh.
|
||||||
|
remove_list_entry() {
|
||||||
|
local list=$1 ppa_url=$2 uri filter
|
||||||
|
[[ -f "$list" ]] && grep -Fq -- "${ppa_url%/}" "$list" || return 0
|
||||||
|
uri=$(escape_regex "${ppa_url%/}")
|
||||||
|
[[ "$ppa_url" != //* ]] || uri="https?:$uri"
|
||||||
|
if [[ "$list" = *.sources ]]; then
|
||||||
|
# Match URIs within one deb822 paragraph, including folded fields.
|
||||||
|
local gap='([[:blank:]]|\r?\n(#[^\n]*\n)*[[:blank:]])'
|
||||||
|
filter='/^[[:space:]]*$/b
|
||||||
|
:stanza
|
||||||
|
$!{N; /\n[[:blank:]]*\r?$/!b stanza;}
|
||||||
|
/(^|\n)[Uu][Rr][Ii][Ss]:'"$gap*([^[:space:]]+$gap+)*$uri"'\/*([[:space:]]|$)/d'
|
||||||
|
else
|
||||||
|
filter="/^[[:blank:]]*deb(-src)?[[:blank:]]+(\\[[^]]*\\][[:blank:]]+)?$uri\\/*([[:space:]]|$)/d"
|
||||||
|
fi
|
||||||
|
sudo sed --follow-symlinks -Ei "$filter" "$list" || return 1
|
||||||
|
grep -q '[^[:space:]]' "$list" || sudo rm -f -- "$list" || return 1
|
||||||
|
sudo rm -f -- "/tmp/os_lists_refresh_${list##*/}" "${RUNNER_TEMP:-/tmp}/os_lists_${list##*/}" || return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Keep any other entries at an active sibling path before publishing a managed source.
|
||||||
|
preserve_list() {
|
||||||
|
local list=$1 url saved stamp="${RUNNER_TEMP:-/tmp}/os_lists_${1##*/}"
|
||||||
|
[[ -e "$list" || -L "$list" ]] || return 0
|
||||||
|
if [[ -f "$stamp" ]] && tail -n +4 "$stamp" | cmp -s - "$list"; then
|
||||||
|
sudo rm -f -- "$list"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
for url in "$@"; do remove_list_entry "$list" "$url" || return 1; done
|
||||||
|
[[ -e "$list" || -L "$list" ]] || return 0
|
||||||
|
saved=$(sudo mktemp --suffix=".${list##*.}" "${list%.*}.XXXXXXXX") && sudo mv -fT -- "$list" "$saved"
|
||||||
|
}
|
||||||
|
|
||||||
# Function to remove a PPA.
|
# Function to remove a PPA.
|
||||||
remove_list() {
|
remove_list() {
|
||||||
local ppa=${1-$default_ppa} list ppa_url uri filter
|
local ppa=${1-$default_ppa} list ppa_url
|
||||||
local -a ppa_urls
|
local -a ppa_urls
|
||||||
[ -n "$2" ] && ppa_urls=("$2") || ppa_urls=("$lp_ppa/$ppa/ubuntu" "$lpc_ppa/$ppa/ubuntu")
|
[ -n "$2" ] && ppa_urls=("$2") || ppa_urls=("$lp_ppa/$ppa/ubuntu" "$lpc_ppa/$ppa/ubuntu")
|
||||||
for ppa_url in "${ppa_urls[@]}"; do
|
for ppa_url in "${ppa_urls[@]}"; do
|
||||||
uri=$(escape_regex "${ppa_url%/}")
|
|
||||||
[[ "$ppa_url" != //* ]] || uri="https?:$uri"
|
|
||||||
while IFS= read -r -d '' list; do
|
while IFS= read -r -d '' list; do
|
||||||
if [[ "$list" = *.sources ]]; then
|
remove_list_entry "$list" "$ppa_url" || return 1
|
||||||
# Match URIs within one deb822 paragraph, including folded fields.
|
done < <(grep_sources -FlZ --exclude="${3:-}" -e "${ppa_url%/}")
|
||||||
local gap='([[:blank:]]|\r?\n(#[^\n]*\n)*[[:blank:]])'
|
|
||||||
filter='/^[[:space:]]*$/b
|
|
||||||
:stanza
|
|
||||||
$!{N; /\n[[:blank:]]*\r?$/!b stanza;}
|
|
||||||
/(^|\n)[Uu][Rr][Ii][Ss]:'"$gap*([^[:space:]]+$gap+)*$uri"'\/*([[:space:]]|$)/d'
|
|
||||||
else
|
|
||||||
filter="/^[[:blank:]]*deb(-src)?[[:blank:]]+(\\[[^]]*\\][[:blank:]]+)?$uri\\/*([[:space:]]|$)/d"
|
|
||||||
fi
|
|
||||||
sudo sed -Ei "$filter" "$list" || return 1
|
|
||||||
grep -q '[^[:space:]]' "$list" || sudo rm -f -- "$list" || return 1
|
|
||||||
sudo rm -f -- "/tmp/os_lists_refresh_${list##*/}" "${RUNNER_TEMP:-/tmp}/os_lists_${list##*/}" || return 1
|
|
||||||
done < <(grep -FlrZ --include='*.list' --include='*.sources' --exclude="${3:-}" -- "${ppa_url%/}" "$list_dir")
|
|
||||||
done
|
done
|
||||||
[[ ! -e "$key_dir/${ppa/\//-}-keyring" ]] || sudo rm -f "$key_dir/${ppa/\//-}-keyring"
|
[[ ! -e "$key_dir/${ppa/\//-}-keyring" ]] || sudo rm -f "$key_dir/${ppa/\//-}-keyring"
|
||||||
}
|
}
|
||||||
@@ -376,7 +409,7 @@ remove_legacy_mirrors() {
|
|||||||
for ppa in ondrej/php ondrej/apache2; do
|
for ppa in ondrej/php ondrej/apache2; do
|
||||||
old_ppa="//${ppa_sp#*://}/$ppa/ubuntu"
|
old_ppa="//${ppa_sp#*://}/$ppa/ubuntu"
|
||||||
old_sp="//${sp#*://}/$ppa/ubuntu"
|
old_sp="//${sp#*://}/$ppa/ubuntu"
|
||||||
if grep -Fqr -e "$old_ppa" -e "$old_sp" "$list_dir"; then
|
if grep_sources -Fq -e "$old_ppa" -e "$old_sp"; then
|
||||||
remove_list "$ppa" "$old_ppa" && remove_list "$ppa" "$old_sp" || return 1
|
remove_list "$ppa" "$old_ppa" && remove_list "$ppa" "$old_sp" || return 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -417,7 +450,7 @@ add_list_with_fallback() (
|
|||||||
{ [[ "${require_mirror_by_hash:-}" != true ]] || ! grep -Fq "${mirror%/}" "$list_dir/$source" ||
|
{ [[ "${require_mirror_by_hash:-}" != true ]] || ! grep -Fq "${mirror%/}" "$list_dir/$source" ||
|
||||||
grep -Eq '^By-Hash: force$| by-hash=force( |])' "$list_dir/$source"; }; then
|
grep -Eq '^By-Hash: force$| by-hash=force( |])' "$list_dir/$source"; }; then
|
||||||
# A cache can restore another source file after this archive was selected.
|
# A cache can restore another source file after this archive was selected.
|
||||||
(( $# > 6 )) && grep -qrF --exclude="$source" -f <(printf '%s\n' "${@:7}") "$list_dir" || return 0
|
(( $# > 6 )) && grep_sources -qF --exclude="$source" -f <(printf '%s\n' "${@:7}") || return 0
|
||||||
else
|
else
|
||||||
stage=$(mktemp -d /tmp/setup-php-list.XXXXXXXX) || return 1
|
stage=$(mktemp -d /tmp/setup-php-list.XXXXXXXX) || return 1
|
||||||
trap 'rm -rf "$stage"' EXIT
|
trap 'rm -rf "$stage"' EXIT
|
||||||
@@ -459,6 +492,7 @@ add_list_with_fallback() (
|
|||||||
add_key "$repo" "$primary" "$suite" "$key" "$managed_key" || return 1
|
add_key "$repo" "$primary" "$suite" "$key" "$managed_key" || return 1
|
||||||
key=$managed_key
|
key=$managed_key
|
||||||
fi
|
fi
|
||||||
|
preserve_list "$list_dir/$source" "$primary" "$mirror" "${@:7}" || return 1
|
||||||
sudo install -m 644 "$stage/$source" "$list_dir/$source" || return 1
|
sudo install -m 644 "$stage/$source" "$list_dir/$source" || return 1
|
||||||
{ printf '%s\n' "$request" && cat "$stage/index" && printf '%s\n' "$key" && cat "$stage/$source"; } > "$stage/stamp" && mv -fT "$stage/stamp" "$stamp"
|
{ printf '%s\n' "$request" && cat "$stage/index" && printf '%s\n' "$key" && cat "$stage/$source"; } > "$stage/stamp" && mv -fT "$stage/stamp" "$stamp"
|
||||||
)
|
)
|
||||||
@@ -558,7 +592,7 @@ update_ppa() {
|
|||||||
list_path="$list_dir/${repo%%/*}-$ID-${repo#*/}-$package_dist.$(get_sources_extension "$list_format")"
|
list_path="$list_dir/${repo%%/*}-$ID-${repo#*/}-$package_dist.$(get_sources_extension "$list_format")"
|
||||||
if [[ -n "${2:-}" || ! -s "$list_path" ]]; then
|
if [[ -n "${2:-}" || ! -s "$list_path" ]]; then
|
||||||
IFS='|' read -r primary_pattern secondary_pattern <<< "$(get_repo_patterns "$list_format" "$ppa_url" "$package_dist" "$branches")"
|
IFS='|' read -r primary_pattern secondary_pattern <<< "$(get_repo_patterns "$list_format" "$ppa_url" "$package_dist" "$branches")"
|
||||||
list_path="$(grep -Elr "$primary_pattern" "$list_dir" 2>/dev/null | head -n 1)"
|
list_path="$(grep_sources -El -e "$primary_pattern" 2>/dev/null | head -n 1)"
|
||||||
[ -n "$list_path" ] || return 1
|
[ -n "$list_path" ] || return 1
|
||||||
fi
|
fi
|
||||||
local rc=0
|
local rc=0
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ read_env() {
|
|||||||
use_builds_cache="${use_builds_cache:-${use_package_cache:-}}"
|
use_builds_cache="${use_builds_cache:-${use_package_cache:-}}"
|
||||||
[ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release
|
[ "${debug:-${DEBUG:-false}}" = "true" ] && debug=debug && update=true || debug=release
|
||||||
[[ "${phpts:-${PHPTS:-nts}}" = "ts" || "${phpts:-${PHPTS:-nts}}" = "zts" ]] && ts=zts && update=true || ts=nts
|
[[ "${phpts:-${PHPTS:-nts}}" = "ts" || "${phpts:-${PHPTS:-nts}}" = "zts" ]] && ts=zts && update=true || ts=nts
|
||||||
[[ "${asan:-${ASAN:-false}}" = "true" ]] && asan=asan && configure_asan || asan=
|
[[ "$OSTYPE" = linux* && "${asan:-${ASAN:-false}}" = "true" ]] && asan=asan && configure_asan || asan=
|
||||||
fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
|
fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
|
||||||
[[ ( -z "$ImageOS" && -z "$ImageVersion" ) ||
|
[[ ( -z "$ImageOS" && -z "$ImageVersion" ) ||
|
||||||
( -n "$RUNNER_ENVIRONMENT" && "$RUNNER_ENVIRONMENT" = "self-hosted" ) ||
|
( -n "$RUNNER_ENVIRONMENT" && "$RUNNER_ENVIRONMENT" = "self-hosted" ) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user