-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathconfigure_macports
More file actions
executable file
·139 lines (118 loc) · 3.64 KB
/
Copy pathconfigure_macports
File metadata and controls
executable file
·139 lines (118 loc) · 3.64 KB
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/sh
# configure_macports — Configure MacPorts
# Melusina Actions (https://github.com/melusina-org/setup-macports)
# This file is part of Melusina Actions.
#
# Copyright © 2022–2023 Michaël Le Barbier
# All rights reserved.
# This file must be used under the terms of the MIT License.
# This source file is licensed as described in the file LICENSE, which
# you should have received as part of this distribution. The terms
# are also available at https://opensource.org/licenses/MIT
: ${TOPLEVELDIR:=$(git rev-parse --show-toplevel)}
: ${subrdir:=${TOPLEVELDIR}/subr}
. "${subrdir}/stdlib.sh"
. "${subrdir}/macos.sh"
. "${subrdir}/macports.sh"
github_owner='macports'
github_repo='macports-base'
parameterfile='.github/parameters/setup-macports.yaml'
parameterfile_compat='.github/parameters/gha-install-macports.yaml'
usage()
{
if [ "$#" -gt 0 ]; then
wlog 'Failure' "$@"
fi
cat 1>&2 <<'EOF'
Usage: configure_macports [VERSION-OR-PATHNAME]
Configure MacPorts
EOF
exit 64
}
experimental()
{
:
}
cache_key()
{
local macos arch
macos=$(probe_macos)
arch=$(probe_architecture)
openssl ripemd160 "${macports_prefix}/etc/setup-macports.yaml"\
| awk -v "macos=${macos}" -v "arch=${arch}" '{print(macos "-" arch "-" $2)}'
}
setup_path()
{
sudo install -o root -g wheel -m 644 /dev/null /etc/paths.d/900-macports
sudo sh -c "printf '%s/bin\n/' ${macports_prefix} > /etc/paths.d/900-macports"
sudo sh -c "printf '%s/sbin\n/' ${macports_prefix} > /etc/paths.d/900-macports"
PATH="${macports_prefix}/bin:${macports_prefix}/sbin:${PATH}"
}
main()
{
local OPTIND OPTION OPTARG
local macos package action
ensure_macos
action='install'
macos=$(probe_macos)
OPTIND=1
while getopts 'x' OPTION; do
case ${OPTION} in
x)
action='experimental'
;;
*)
usage '\047%s\047 Unsupported option.' "${OPTION}"
;;
esac
done
shift $(expr ${OPTIND} - 1)
case "$#" in
0)
:
;;
1)
if [ -f "$1" -a -r "$1" ]; then
parameterfile="$1"
elif [ "$1" = ':no-value' -a -f "${parameterfile}" -a -r "${parameterfile}" ]; then
wlog 'Info' 'Use parameter file \047%s\047.' "${parameterfile}"
elif [ "$1" = ':no-value' -a -f "${parameterfile_compat}" -a -r "${parameterfile_compat}" ]; then
wlog 'Info' 'Use parameter file \047%s\047.' "${parameterfile_compat}"
parameterfile="${parameterfile_compat}"
else
parameterfile=':no-value'
fi
;;
*)
usage 'Too many arguments.'
;;
esac
if [ -f "${parameterfile}" -a -r "${parameterfile}" ]; then
macports_version=$(yq ".version // \"${macports_version}\"" < "${parameterfile}")
macports_prefix=$(yq ".prefix // \"${macports_prefix}\"" < "${parameterfile}")
fi
if [ "${action}" = 'experimental' ]; then
experimental "$@"
exit 0
fi
setup_path
sudo install -d -o $(id -u -n) -g $(id -g -n) -m 755 "${macports_prefix}"
write_configuration "${parameterfile}" "${macports_prefix}/etc/setup-macports.yaml"
write_variants "${macports_prefix}/etc/setup-macports.yaml"
write_sources "${macports_prefix}/etc/setup-macports.yaml"
if [ "${GITHUB_ACTIONS}" = 'true' ]; then
{
printf 'prefix=%s\n' "${macports_prefix}"
printf 'parameters=%s\n' "${macports_prefix}/etc/setup-macports.yaml"
printf 'cache-key=%sn\n' "$(cache_key)"
printf 'package=%s\n' "$(make_package)"
printf 'version=%s\n' "${macports_version}"
} >> "${GITHUB_OUTPUT}"
{
printf '%s/bin\n' "${macports_prefix}"
printf '%s/sbin\n' "${macports_prefix}"
} >> "${GITHUB_PATH}"
fi
}
main "$@"
# End of file `configure_macports'