Files

60 lines
2.2 KiB
Bash
Raw Permalink Normal View History

2016-03-17 08:06:27 +00:00
#!/bin/bash
# -*- coding: utf-8; mode: sh; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=sh:et:sw=4:ts=4:sts=4
2016-03-17 08:06:27 +00:00
2016-08-29 19:36:09 +00:00
# Note:
# This script is sourced by the mpbb wrapper script.
2016-03-17 08:06:27 +00:00
# Do not execute this directly!
2016-09-12 01:59:04 +00:00
selfupdate-usage() {
# "prog" is defined in mpbb-help.
# shellcheck disable=SC2154
cat <<EOF
usage: $prog [<global options>] selfupdate
Install or update the auxiliary MacPorts base installation. (To reindex
port sources, use \`$prog checkout'.)
Run \`$prog help' for global options and a list of other subcommands.
EOF
2016-03-17 08:06:27 +00:00
}
selfupdate() {
# $option_prefix is set in mpbb
# shellcheck disable=SC2154
if [ ! -f "${option_prefix}/bin/port" ]; then
macports_version=2.10.5
macports_distname=MacPorts-${macports_version}
macports_distfile=${macports_distname}.tar.bz2
if [ ! -d ${macports_distname} ]; then
if [ ! -f ${macports_distfile} ]; then
2016-09-04 20:55:03 +00:00
curl -fsLO https://distfiles.macports.org/MacPorts/${macports_distfile} || return
fi
2016-09-04 20:55:03 +00:00
tar -xjf ${macports_distfile} || return
fi
2016-09-04 20:55:03 +00:00
cd ${macports_distname} || return
if [ "${option_prefix}" != "/opt/local" ]; then
applications_dir_flag="--with-applications-dir=${option_prefix}/Applications/MacPorts"
fi
: "${applications_dir_flag=}"
if [ "$(id -u)" -ne 0 ]; then
install_user_and_group_flags="--with-install-user=$(id -un) --with-install-group=$(id -gn)"
fi
: "${install_user_and_group_flags=}"
PATH=/usr/bin:/bin:/usr/sbin:/sbin ./configure \
--prefix="${option_prefix}" \
${applications_dir_flag} \
${install_user_and_group_flags} \
--enable-readline || return
2016-09-04 20:55:03 +00:00
make -j"$(sysctl -n hw.activecpu)" || return
make install || return
cd .. || return
rm -rf ${macports_distfile} ${macports_distname} || return
fi
2024-08-16 11:14:25 +10:00
# selfupdate at most once every 12 hours
if [[ ! -f selfupdate.timestamp || $(($(date +%s) - $(stat -f %m selfupdate.timestamp))) -gt 43200 ]]; then
"${option_prefix}/bin/port" -d selfupdate --no-sync || return
touch selfupdate.timestamp
2019-05-26 12:50:13 +10:00
fi
2016-03-17 08:06:27 +00:00
}