Allow non-btree speculative insertion indexes
[pgsql.git] / src / tools / ci / ci_macports_packages.sh
blob63e97b37c78635ac556a51e0a4d3c05205ed6d37
1 #!/bin/sh
3 # Installs the passed in packages via macports. To make it fast enough
4 # for CI, cache the installation as a .dmg file. To avoid
5 # unnecessarily updating the cache, the cached image is only modified
6 # when packages are installed or removed. Any package this script is
7 # not instructed to install, will be removed again.
9 # This currently expects to be run in a macos cirrus-ci environment.
11 set -e
12 # set -x
14 packages="$@"
16 macos_major_version="` sw_vers -productVersion | sed 's/\..*//' `"
17 echo "macOS major version: $macos_major_version"
19 # Scan the available MacPorts releases to find one that matches the running
20 # macOS release.
21 macports_release_list_url="https://api.github.com/repos/macports/macports-base/releases"
22 macports_version_pattern="2\.10\.1"
23 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 )"
24 echo "MacPorts package URL: $macports_url"
26 cache_dmg="macports.hfs.dmg"
28 if [ "$CIRRUS_CI" != "true" ]; then
29 echo "expect to be called within cirrus-ci" 1>2
30 exit 1
33 sudo mkdir -p /opt/local
34 mkdir -p ${MACPORTS_CACHE}/
36 # If we are starting from clean cache, perform a fresh macports
37 # install. Otherwise decompress the .dmg we created previously.
39 # After this we have a working macports installation, with an unknown set of
40 # packages installed.
41 new_install=0
42 update_cached_image=0
43 if [ -e ${MACPORTS_CACHE}/${cache_dmg}.zstd ]; then
44 time zstd -T0 -d ${MACPORTS_CACHE}/${cache_dmg}.zstd -o ${cache_dmg}
45 time sudo hdiutil attach -kernel ${cache_dmg} -owners on -shadow ${cache_dmg}.shadow -mountpoint /opt/local
46 else
47 new_install=1
48 curl -fsSL -o macports.pkg "$macports_url"
49 time sudo installer -pkg macports.pkg -target /
50 # this is a throwaway environment, and it'd be a few lines to gin
51 # up a correct user / group when using the cache.
52 echo macportsuser root | sudo tee -a /opt/local/etc/macports/macports.conf
54 export PATH=/opt/local/sbin/:/opt/local/bin/:$PATH
56 # mark all installed packages unrequested, that allows us to detect
57 # packages that aren't needed anymore
58 if [ -n "$(port -q installed installed)" ] ; then
59 sudo port unsetrequested installed
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
68 update_cached_image=1
70 done
71 echo "done"
72 if [ "$update_cached_image" -eq 1 ]; then
73 echo not all required packages installed, doing so now
74 # to keep the image small, we deleted the ports tree from the image...
75 sudo port selfupdate
76 # XXX likely we'll need some other way to force an upgrade at some
77 # point...
78 sudo port upgrade outdated
79 sudo port install -N $packages
80 sudo port setrequested $packages
83 # check if any ports should be uninstalled
84 if [ -n "$(port -q installed rleaves)" ] ; then
85 echo superfluous packages installed
86 update_cached_image=1
87 sudo port uninstall --follow-dependencies rleaves
89 # remove prior cache contents, don't want to increase size
90 rm -f ${MACPORTS_CACHE}/*
93 # Shrink installation if we created / modified it
94 if [ "$new_install" -eq 1 -o "$update_cached_image" -eq 1 ]; then
95 sudo /opt/local/bin/port clean --all installed
96 sudo rm -rf /opt/local/var/macports/{software,sources}/*
99 # If we're starting from a clean cache, start a new image. If we have
100 # an image, but the contents changed, update the image in the cache
101 # location.
102 if [ "$new_install" -eq 1 ]; then
103 # use a generous size, so additional software can be installed later
104 time sudo hdiutil create -fs HFS+ -format UDRO -size 10g -layout NONE -srcfolder /opt/local/ ${cache_dmg}
105 time zstd -T -10 -z ${cache_dmg} -o ${MACPORTS_CACHE}/${cache_dmg}.zstd
106 elif [ "$update_cached_image" -eq 1 ]; then
107 sudo hdiutil detach /opt/local/
108 time hdiutil convert -format UDRO ${cache_dmg} -shadow ${cache_dmg}.shadow -o updated.hfs.dmg
109 rm ${cache_dmg}.shadow
110 mv updated.hfs.dmg ${cache_dmg}
111 time zstd --force -T -10 -z ${cache_dmg} -o ${MACPORTS_CACHE}/${cache_dmg}.zstd
112 time sudo hdiutil attach -kernel ${cache_dmg} -owners on -shadow ${cache_dmg}.shadow -mountpoint /opt/local