diff --git a/.github/workflows/continuous-integration.yaml b/.github/workflows/continuous-integration.yaml index 30ab5f4..574c999 100644 --- a/.github/workflows/continuous-integration.yaml +++ b/.github/workflows/continuous-integration.yaml @@ -24,7 +24,11 @@ jobs: matrix: os: ['macos-12', 'macos-13', 'macos-14'] version: ['2.9.3'] - prefix: ['/opt/local'] + prefix: ['local'] + include: + - os: 'macos-14' + version: '2.9.3' + prefix: 'package' runs-on: '${{ matrix.os }}' name: 'Install MacPorts' needs: 'run-testsuite' @@ -33,14 +37,15 @@ jobs: - uses: ./ id: 'macports' with: - parameters: 'testsuite/run-testsuite-on-${{ matrix.os }}.yaml' + parameters: 'testsuite/run-testsuite-on-${{ matrix.os }}-${{ matrix.prefix }}.yaml' - name: 'Validate installed MacPorts version' run: >- test "$(port version)" = 'Version: ${{ matrix.version }}' - name: 'Validate transmitted MacPorts prefix' run: >- - test "${{ steps.macports.outputs.prefix }}" = '${{ matrix.prefix }}' + test "${{ steps.macports.outputs.prefix }}" = '/opt/${{ matrix.prefix }}' - name: 'Validate transmitted MacPorts version' run: >- test "${{ steps.macports.outputs.version }}" = '${{ matrix.version }}' + - run: /opt/${{ matrix.prefix }}/bin/port version - run: port version diff --git a/README.md b/README.md index 1a055da..67922d8 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,8 @@ The configuration file is in YAML and has the following format: * `version: '2.9.3'` — The MacPorts version to install. * `prefix: '/opt/local'` — The installation prefix to install MacPorts to. - Currently the only supported value is '/opt/local'. + The default is `/opt/local` and only needs to be changed when + preparing self-install packages for instane. * `variants.select: []` — The list of selected variants in the global variants configuration. See Also variants.conf(5). * `variants.deselect: []` — The list of deselected variants in the diff --git a/action.yaml b/action.yaml index 66ad45a..888ed79 100644 --- a/action.yaml +++ b/action.yaml @@ -88,7 +88,9 @@ runs: - name: 'Install MacPorts' if: steps.cache-macports.outputs.cache-hit != 'true' shell: sh - env: - TOPLEVELDIR: ${{ github.action_path }} run: | ${{ github.action_path }}/install_macports + env: + TOPLEVELDIR: ${{ github.action_path }} + macports_prefix: ${{ steps.configure-macports.outputs.prefix }} + macports_version: ${{ steps.configure-macports.outputs.version }} diff --git a/configure_macports b/configure_macports index d733929..07489af 100755 --- a/configure_macports +++ b/configure_macports @@ -45,7 +45,7 @@ experimental() cache_key() { - openssl ripemd160 "${macports_prefix}/etc/gha-install-macports.yaml"\ + openssl ripemd160 "${macports_prefix}/etc/setup-macports.yaml"\ | awk -v "macos=${macos}" '{print(macos "-" $2)}' } @@ -101,8 +101,8 @@ main() esac if [ -f "${parameterfile}" -a -r "${parameterfile}" ]; then - version=$(yq ".version // \"${macports_version}\"" < "${parameterfile}") - prefix=$(yq ".prefix // \"${macports_prefix}\"" < "${parameterfile}") + macports_version=$(yq ".version // \"${macports_version}\"" < "${parameterfile}") + macports_prefix=$(yq ".prefix // \"${macports_prefix}\"" < "${parameterfile}") fi if [ "${action}" = 'experimental' ]; then @@ -112,14 +112,14 @@ main() setup_path sudo install -d -o $(id -u -n) -g $(id -g -n) -m 755 "${macports_prefix}" - write_configuration "${parameterfile}" "${macports_prefix}/etc/gha-install-macports.yaml" - write_variants "${macports_prefix}/etc/gha-install-macports.yaml" - write_sources "${macports_prefix}/etc/gha-install-macports.yaml" + 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/gha-install-macports.yaml" + 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}" diff --git a/install_macports b/install_macports index 7422ea1..f195d3e 100755 --- a/install_macports +++ b/install_macports @@ -162,6 +162,24 @@ fetch_and_install_package() sudo chown -R $(id -u -n):$(id -g -n) "${macports_prefix}" } +install_from_source() +{ + local srcdir + srcdir='/opt/local/src' + sudo install -d -o $(id -u -n) -g $(id -g -n) -m 755 "${srcdir}" + ( + cd "${srcdir}" + git clone https://github.com/macports/macports-base.git + cd macports-base + git checkout "v${macports_version}" + ./configure --enable-readline --prefix="${macports_prefix}" + make + sudo make install + ) + sudo rm -Rf "${srcdir}" + sudo port -v selfupdate +} + install_ports() { ports_document "$1" | xargs -J '%' sudo port install '%' @@ -208,8 +226,13 @@ main() 'Configuration Summary'\ configuration_summary - fetch_and_install_package "$(make_package)" - install_ports "${macports_prefix}/etc/gha-install-macports.yaml" + if [ "${macports_prefix}" = '/opt/local' ]; then + fetch_and_install_package "$(make_package)" + else + install_from_source + fi + + install_ports "${macports_prefix}/etc/setup-macports.yaml" } main "$@" diff --git a/subr/macports.sh b/subr/macports.sh index 942090b..ab7f304 100644 --- a/subr/macports.sh +++ b/subr/macports.sh @@ -62,7 +62,7 @@ YAML variants_document() { if [ "$#" -eq 0 ]; then - set -- "${macports_prefix}/etc/gha-install-macports.yaml" + set -- "${macports_prefix}/etc/setup-macports.yaml" fi printf '# MacPorts system-wide global variants configuration file.\n' @@ -82,7 +82,7 @@ variants_document() ports_document() { if [ "$#" -eq 0 ]; then - set -- "${macports_prefix}/etc/gha-install-macports.yaml" + set -- "${macports_prefix}/etc/setup-macports.yaml" fi yq ' @@ -100,7 +100,7 @@ ports_document() sources_document() { if [ "$#" -eq 0 ]; then - set -- "${macports_prefix}/etc/gha-install-macports.yaml" + set -- "${macports_prefix}/etc/setup-macports.yaml" fi yq ' @@ -131,7 +131,7 @@ make_package() case $# in 0) macos=$(probe_macos) - version=$(yq ".version // \"${macports_version}\"" < "${macports_prefix}/etc/gha-install-macports.yaml") + version=$(yq ".version // \"${macports_version}\"" < "${macports_prefix}/etc/setup-macports.yaml") ;; 1) macos=$(probe_macos) diff --git a/testsuite/run-testsuite-on-macos-12.yaml b/testsuite/run-testsuite-on-macos-12-local.yaml similarity index 100% rename from testsuite/run-testsuite-on-macos-12.yaml rename to testsuite/run-testsuite-on-macos-12-local.yaml diff --git a/testsuite/run-testsuite-on-macos-13.yaml b/testsuite/run-testsuite-on-macos-13-local.yaml similarity index 100% rename from testsuite/run-testsuite-on-macos-13.yaml rename to testsuite/run-testsuite-on-macos-13-local.yaml diff --git a/testsuite/run-testsuite-on-macos-14.yaml b/testsuite/run-testsuite-on-macos-14-local.yaml similarity index 100% rename from testsuite/run-testsuite-on-macos-14.yaml rename to testsuite/run-testsuite-on-macos-14-local.yaml diff --git a/testsuite/run-testsuite-on-macos-14-package.yaml b/testsuite/run-testsuite-on-macos-14-package.yaml new file mode 100644 index 0000000..d4ae141 --- /dev/null +++ b/testsuite/run-testsuite-on-macos-14-package.yaml @@ -0,0 +1,15 @@ +version: '2.9.3' +prefix: '/opt/package' +variants: + select: + - aqua + - metal + deselect: x11 +ports: + - name: db48 + deselect: [ java ] + select: [ tcl, universal ] + - name: gmp + select: native + - name: dbus + diff --git a/validate_configuration b/validate_configuration index 1e9f5fb..24a190e 100755 --- a/validate_configuration +++ b/validate_configuration @@ -69,10 +69,6 @@ main() if [ ! -r "$1" ]; then failwith 'The pathname \047%s\047 does not designate a readable file.' "$1" fi - - if ! [ $(yq '.prefix' "$1") = '/opt/local' ]; then - failwith 'The only supported prefix is \047/opt/local\047.' - fi } main "$@"