From 12959500616da20ff5a012cda83003951cb7de0a Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Thu, 27 Jun 2024 16:21:13 +1200 Subject: [PATCH v3 2/2] ci: Find appropriate MacPorts package automatically. Instead of hard-coding a MacPorts installation URL, deduce it from the running macOS version and the available releases. This removes the need to keep the ci_macports_packages.sh in sync with .cirrus.task.yml, and to advance the MacPorts version from time to time. It also helps smooth over the transition if Cirrus decides to force an incompatible MacOS image on some users. Discussion: https://postgr.es/m/CA%2BhUKGLqJdv6RcwyZ_0H7khxtLTNJyuK%2BvDFzv3uwYbn8hKH6A%40mail.gmail.com --- .cirrus.tasks.yml | 2 -- src/tools/ci/ci_macports_packages.sh | 14 +++++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.yml index 7cdc6bd26e3..a95c04ef1f3 100644 --- a/.cirrus.tasks.yml +++ b/.cirrus.tasks.yml @@ -420,8 +420,6 @@ task: # work OK. See # https://postgr.es/m/20220927040208.l3shfcidovpzqxfh%40awork3.anarazel.de TEST_JOBS: 8 - # If changing the macOS release, you probably also need to change - # macports_url in src/tools/ci/ci_macports_packages.sh IMAGE: ghcr.io/cirruslabs/macos-sonoma-base:latest CIRRUS_WORKING_DIR: ${HOME}/pgsql/ diff --git a/src/tools/ci/ci_macports_packages.sh b/src/tools/ci/ci_macports_packages.sh index db811a28c8e..a002eca7e30 100755 --- a/src/tools/ci/ci_macports_packages.sh +++ b/src/tools/ci/ci_macports_packages.sh @@ -13,7 +13,19 @@ set -e packages="$@" -macports_url="https://github.com/macports/macports-base/releases/download/v2.9.3/MacPorts-2.9.3-14-Sonoma.pkg" +macos_major_version="` sw_vers | grep ProductVersion | sed 's/[^0-9]*//;s/\..*//' `" +echo "macOS major version: $macos_major_version" + +# Scan the avialable MacPorts releases to find the latest one for the +# running macOS release. By default we assume the first match is the most +# recent MacPorts version but that can be changed below if it turns out to be +# problematic or a particular MacPorts release turns out to be broken. +macports_release_list_url="https://api.github.com/repos/macports/macports-base/releases" +macports_version_pattern=".*" +#macports_version_pattern="2\.9\.3" +macports_url="$( curl -s $macports_release_list_url | grep "\"https://github.com/macports/macports-base/releases/download/v$macports_version_pattern/MacPorts-$macports_version_pattern-$macos_major_version-[A-Za-z]*\.pkg\"" | sed 's/.*: "//;s/".*//' | head -1 )" +echo "MacPorts package URL: $macports_url" + cache_dmg="macports.hfs.dmg" if [ "$CIRRUS_CI" != "true" ]; then -- 2.39.2