-
Notifications
You must be signed in to change notification settings - Fork 88
/
macports.sh
90 lines (74 loc) · 2.61 KB
/
macports.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
# Based on https://github.com/GiovanniBussi/macports-ci
set -Exeuo pipefail
export COLUMNS=80
MACPORTS_VERSION=2.6.4
MACPORTS_PREFIX=/opt/local
MACPORTS_SYNC=tarball
pushd "$(mktemp -d)"
OSX_VERSION="$(sw_vers -productVersion | sed 's/\.[^\.]*$//')"
if test "$OSX_VERSION" == 10.10 ; then
OSX_NAME=Yosemite
elif test "$OSX_VERSION" == 10.11 ; then
OSX_NAME=ElCapitan
elif test "$OSX_VERSION" == 10.12 ; then
OSX_NAME=Sierra
elif test "$OSX_VERSION" == 10.13 ; then
OSX_NAME=HighSierra
elif test "$OSX_VERSION" == 10.14 ; then
OSX_NAME=Mojave
else
echo "macports-ci: Unknown OSX version $OSX_VERSION"
exit 1
fi
echo "macports-ci: OSX version $OSX_VERSION $OSX_NAME"
MACPORTS_PKG=MacPorts-${MACPORTS_VERSION}-${OSX_VERSION}-${OSX_NAME}.pkg
URL="https://distfiles.macports.org/MacPorts"
URL="https://github.com/macports/macports-base/releases/download/v$MACPORTS_VERSION/"
echo "macports-ci: Base URL is $URL"
# download installer:
curl -LO $URL/$MACPORTS_PKG
# install:
sudo installer -verbose -pkg $MACPORTS_PKG -target /
# update:
export PATH="$MACPORTS_PREFIX/bin:$PATH"
i=1
# run through a while to retry upon failure
while true
do
echo "macports-ci: Trying to selfupdate (iteration $i)"
# here I test for the presence of a known portfile
# this check confirms that ports were installed
# notice that port -N selfupdate && break is not sufficient as a test
# (sometime it returns a success even though ports have not been installed)
# for some misterious reasons, running without "-d" does not work in some case
sudo port -d -N selfupdate 2>&1 | grep -v DEBUG | awk '{if($1!="x")print}'
port info xdrfile > /dev/null && break || true
sleep 5
i=$((i+1))
if ((i>20)) ; then
echo "macports-ci: Failed after $i iterations"
exit 1
fi
done
echo "macports-ci: Selfupdate successful after $i iterations"
dir="$PWD"
popd
sudo rm -rf $dir