Skip to content

Commit c93dffd

Browse files
committed
ci: Fix cached MacPorts installation management
1. The error reporting of "port setrequested list-of-packages..." changed, hiding errors we were relying on to know if all packages in our list were already installed. Use a loop instead. 2. The cached MacPorts installation was shared between PostgreSQL major branches, though each branch wanted different packages. Add the list of packages to cache key, so that different branches, when tested in one github account/repo such as postgres/postgres, stop fighting with each other, adding and removing packages. Back-patch to 15 where CI began. Author: Thomas Munro <thomas.munro@gmail.com> Author: Nazir Bilal Yavuz <byavuz81@gmail.com> Suggested-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/au2uqfuy2nf43nwy2txmc5t2emhwij7kzupygto3d2ffgtrdgr%40ckvrlwyflnh2
1 parent adb103f commit c93dffd

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

.cirrus.tasks.yml

+18-16
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,20 @@ task:
426426
CCACHE_DIR: ${HOME}/ccache
427427
MACPORTS_CACHE: ${HOME}/macports-cache
428428

429+
MACOS_PACKAGE_LIST: >-
430+
ccache
431+
icu
432+
kerberos5
433+
lz4
434+
meson
435+
openldap
436+
openssl
437+
p5.34-io-tty
438+
p5.34-ipc-run
439+
python312
440+
tcl
441+
zstd
442+
429443
CC: ccache cc
430444
CXX: ccache c++
431445
CFLAGS: -Og -ggdb
@@ -461,26 +475,14 @@ task:
461475
macports_cache:
462476
folder: ${MACPORTS_CACHE}
463477
fingerprint_script: |
464-
# Include the OS major version in the cache key. If the OS image changes
465-
# to a different major version, we need to reinstall.
478+
# Reinstall packages if the OS major version, the list of the packages
479+
# to install or the MacPorts install script changes.
466480
sw_vers -productVersion | sed 's/\..*//'
467-
# Also start afresh if we change our MacPorts install script.
481+
echo $MACOS_PACKAGE_LIST
468482
md5 src/tools/ci/ci_macports_packages.sh
469483
reupload_on_changes: true
470484
setup_additional_packages_script: |
471-
sh src/tools/ci/ci_macports_packages.sh \
472-
ccache \
473-
icu \
474-
kerberos5 \
475-
lz4 \
476-
meson \
477-
openldap \
478-
openssl \
479-
p5.34-io-tty \
480-
p5.34-ipc-run \
481-
python312 \
482-
tcl \
483-
zstd
485+
sh src/tools/ci/ci_macports_packages.sh $MACOS_PACKAGE_LIST
484486
# system python doesn't provide headers
485487
sudo /opt/local/bin/port select python3 python312
486488
# Make macports install visible for subsequent steps

src/tools/ci/ci_macports_packages.sh

+11-4
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,18 @@ if [ -n "$(port -q installed installed)" ] ; then
5959
sudo port unsetrequested installed
6060
fi
6161

62-
# if setting all the required packages as requested fails, we need
63-
# to install at least one of them
64-
if ! sudo port setrequested $packages > /dev/null 2>&1 ; then
65-
echo not all required packages installed, doing so now
62+
# If setting all the required packages as requested fails, we need
63+
# to install at least one of them. Need to do so one-by-one as
64+
# port setrequested only reports failures for the first package.
65+
echo "checking if all required packages are installed"
66+
for package in $packages ; do
67+
if ! sudo port setrequested $package > /dev/null 2>&1 ; then
6668
update_cached_image=1
69+
fi
70+
done
71+
echo "done"
72+
if [ "$update_cached_image" -eq 1 ]; then
73+
echo not all required packages installed, doing so now
6774
# to keep the image small, we deleted the ports tree from the image...
6875
sudo port selfupdate
6976
# XXX likely we'll need some other way to force an upgrade at some

0 commit comments

Comments
 (0)