[152525] contrib
larryv at macports.org
larryv at macports.org
Sun Sep 11 18:58:56 PDT 2016
Revision: 152525
https://trac.macports.org/changeset/152525
Author: larryv at macports.org
Date: 2016-09-11 18:58:56 -0700 (Sun, 11 Sep 2016)
Log Message:
-----------
mpbb: Separate global and subcommand options
À la Git, command-line options that are applicable to all subcommands
(e.g., `--prefix`) are now given before the subcommand name, while
options that are specific to particular subcommands (e.g.,
`--archive-site`) come after. For example, this:
mpbb checkout --prefix /opt/local --svn /usr/bin/svn
is now:
mpbb --prefix /opt/local checkout --svn /usr/bin/svn
This is a practical improvement as well as a conceptual one, as the
Buildbot configuration will be able to factor out the common command
prefix like so:
cmd = ('./mpbb/mpbb', '--prefix', WithProperties(prefix))
cmd_selfupdate = cmd + ('selfupdate',)
cmd_checkout = cmd + ('checkout', '--svn-url', svnurl)
[...]
For backwards compatibility with our current Buildbot deployment, all
subcommands except `list-subports` still accept `--prefix`.
Modified Paths:
--------------
contrib/buildbot-test/master.cfg
contrib/mp-buildbot/README.md
contrib/mp-buildbot/mpbb
contrib/mp-buildbot/mpbb-checkout
contrib/mp-buildbot/mpbb-cleanup
contrib/mp-buildbot/mpbb-gather-archives
contrib/mp-buildbot/mpbb-install-dependencies
contrib/mp-buildbot/mpbb-install-port
contrib/mp-buildbot/mpbb-selfupdate
Modified: contrib/buildbot-test/master.cfg
===================================================================
--- contrib/buildbot-test/master.cfg 2016-09-12 01:58:52 UTC (rev 152524)
+++ contrib/buildbot-test/master.cfg 2016-09-12 01:58:56 UTC (rev 152525)
@@ -333,20 +333,20 @@
haltOnFailure=True))
portwatcher_factory.addStep(ShellCommand(
- command=['./mpbb/mpbb', 'cleanup', '--prefix', WithProperties(prefix)],
+ command=['./mpbb/mpbb', '--prefix', WithProperties(prefix), 'cleanup'],
name="cleanup",
description=["cleaning"],
descriptionDone=["clean"]))
portwatcher_factory.addStep(ShellCommand(
- command=['./mpbb/mpbb', 'selfupdate', '--prefix', WithProperties(prefix)],
+ command=['./mpbb/mpbb', '--prefix', WithProperties(prefix), 'selfupdate'],
name="selfupdate",
description=["updating", "MacPorts"],
descriptionDone=["update", "MacPorts"],
haltOnFailure=True))
portwatcher_factory.addStep(ShellCommand(
- command=['./mpbb/mpbb', 'checkout', '--prefix', WithProperties(prefix), '--svn-url', config['svnurl']],
+ command=['./mpbb/mpbb', '--prefix', WithProperties(prefix), 'checkout', '--svn-url', config['svnurl']],
timeout=3600,
name="checkout",
description=["syncing", "ports"],
@@ -399,7 +399,7 @@
logdir = os.path.join(portbuilder_factory.workdir, "logs")
portbuilder_factory.addStep(Compile(
- command=['./mpbb/mpbb', 'install-dependencies', '--prefix', WithProperties(prefix), WithProperties('%(portname)s')],
+ command=['./mpbb/mpbb', '--prefix', WithProperties(prefix), 'install-dependencies', WithProperties('%(portname)s')],
name="install-dependencies",
description=["installing", "dependencies", "of", WithProperties("%(portname)s")],
descriptionDone=["install", "dependencies", "of", WithProperties("%(portname)s")],
@@ -407,7 +407,7 @@
haltOnFailure=True))
portbuilder_factory.addStep(Compile(
- command=['./mpbb/mpbb', 'install-port', '--prefix', WithProperties(prefix), WithProperties('%(portname)s')],
+ command=['./mpbb/mpbb', '--prefix', WithProperties(prefix), 'install-port', WithProperties('%(portname)s')],
name="install-port",
description=["installing", WithProperties("%(portname)s")],
descriptionDone=["install", WithProperties("%(portname)s")],
@@ -419,7 +419,7 @@
haltOnFailure=True))
portbuilder_factory.addStep(ShellCommand(
- command=['./mpbb/mpbb', 'gather-archives', '--prefix', WithProperties(prefix), '--archive-site', config['archivesite'], '--staging-dir', ulpath],
+ command=['./mpbb/mpbb', '--prefix', WithProperties(prefix), 'gather-archives', '--archive-site', config['archivesite'], '--staging-dir', ulpath],
name="gather-archives",
description=["gathering", "archives"],
descriptionDone=["gather", "archives"],
@@ -443,7 +443,7 @@
# TODO: do we want to upload the individual logs so maintainers can review them?
portbuilder_factory.addStep(ShellCommand(
- command=['./mpbb/mpbb', 'cleanup', '--prefix', WithProperties(prefix)],
+ command=['./mpbb/mpbb', '--prefix', WithProperties(prefix), 'cleanup'],
name="cleanup",
description=["cleaning"],
descriptionDone=["clean"],
Modified: contrib/mp-buildbot/README.md
===================================================================
--- contrib/mp-buildbot/README.md 2016-09-12 01:58:52 UTC (rev 152524)
+++ contrib/mp-buildbot/README.md 2016-09-12 01:58:56 UTC (rev 152525)
@@ -17,35 +17,33 @@
1. Update base without updating the portindex.
- mpbb selfupdate --prefix /opt/local
+ mpbb --prefix /opt/local selfupdate
2. Checkout ports tree and update the portindex.
- mpbb checkout \
- --prefix /opt/local \
- --work-dir /tmp/scratch \
+ mpbb --prefix /opt/local --work-dir /tmp/scratch \
+ checkout \
--svn-url https://svn.macports.org/repository/macports/trunk \
--svn-revision 123456
3. Print one or more ports' subports to standard output.
- mpbb list-subports --prefix /opt/local php cmake llvm-3.8 [...]
+ mpbb --prefix /opt/local list-subports php cmake llvm-3.8 [...]
4. For each subport listed in step 3:
a. Install dependencies.
- mpbb install-dependencies --prefix /opt/local php71
+ mpbb --prefix /opt/local install-dependencies php71
b. Install the subport itself.
- mpbb install-port --prefix /opt/local php71
+ mpbb --prefix /opt/local install-port php71
c. Gather archives.
- mpbb gather-archives \
- --prefix /opt/local \
- --work-dir /tmp/scratch \
+ mpbb --prefix /opt/local --work-dir /tmp/scratch \
+ gather-archives \
--archive-site https://packages.macports.org \
--staging-dir /tmp/scratch/staging
@@ -56,7 +54,7 @@
f. Clean up. This must always be run, even if a previous step
failed.
- mpbb cleanup --prefix /opt/local
+ mpbb --prefix /opt/local cleanup
## Subcommand API ##
@@ -79,19 +77,8 @@
- `$command`:
The name of the subcommand.
-- `$option_archive_site`:
- The URL of the mirror to check for preexisting archives.
- `$option_prefix`:
The prefix of the MacPorts installation.
-- `$option_staging_dir`:
- The directory for staging distributable archives for upload.
-- `$option_svn`:
- The path to the Subversion executable.
-- `$option_svn_revision`:
- The revision to checkout from the `$option_svn_url` repository.
-- `$option_svn_url`:
- The URL of a Subversion repository containing the MacPorts `base`
- and `dports` directory trees.
- `$option_work_dir`:
A directory for storing temporary data. It is guaranteed to
persist for the duration of an `mpbb` run, so it may be used to
Modified: contrib/mp-buildbot/mpbb
===================================================================
--- contrib/mp-buildbot/mpbb 2016-09-12 01:58:52 UTC (rev 152524)
+++ contrib/mp-buildbot/mpbb 2016-09-12 01:58:56 UTC (rev 152525)
@@ -70,32 +70,6 @@
exit 2
}
-## Load the mpbb-$command scripts and source them to load the actual implementations and help messages of available commands
-commands=()
-thisdir=$(cd "$(dirname "$0")" && pwd)
-for cmdfile in "$thisdir/mpbb-"*; do
- # Unfortunately ShellCheck does not currently support following multiple
- # files, so we'll just disable the warning.
- # shellcheck disable=SC1090
- . "$cmdfile"
- commands+=(${cmdfile#$thisdir/mpbb-})
-done
-
-## The first argument should be the subcommand
-if [[ $# -lt 1 ]]; then
- err "No command specified"
- usage
-fi
-
-command=$1
-shift
-if [ ! -f "$thisdir/mpbb-$command" ]; then
- if [ "$command" != "--help" ]; then
- err "Unknown command $command"
- fi
- usage
-fi
-
# TODO Documentation, obviously :)
parseopt() {
# Be stricter about this than getopt(1) is.
@@ -164,17 +138,12 @@
fi
# Process options.
-parseopt archive-site:,help,port:,prefix:,svn:,svn_revision:,svn_url:,staging-dir:,work-dir: "$@" || exit
+parseopt help,prefix:,work-dir: "$@" || exit
# Use sensible defaults for options that weren't set on the command line.
: "${option_port=}"
: "${option_prefix=/opt/local}"
: "${option_work_dir=${PWD:-/tmp/mp-buildbot}}"
-: "${option_archive_site=https://packages.macports.org}"
-: "${option_staging_dir=${option_work_dir}/archive-staging}"
-: "${option_svn=$(which svn)}"
-: "${option_svn_revision=HEAD}"
-: "${option_svn_url=https://svn.macports.org/repository/macports/trunk}"
: "${option_help=0}"
# shellcheck disable=SC2034 disable=SC2154
@@ -186,6 +155,30 @@
# enabled, "${foo[@]}" doesn't work if foo is empty.
set -- ${args+"${args[@]}"}
+# Load the mpbb-$command scripts and source them to load the actual
+# implementations and help messages of available commands.
+cmds=()
+thisdir=$(cd "$(dirname "$0")" && pwd)
+for cmdfile in "$thisdir/mpbb-"*; do
+ # Unfortunately ShellCheck does not currently support following multiple
+ # files, so we'll just disable the warning.
+ # shellcheck disable=SC1090
+ . "$cmdfile"
+ cmds+=("${cmdfile#$thisdir/mpbb-}")
+done
+
+if (( $# < 1 )); then
+ err "No command specified"
+ usage
+fi
+
+command=$1
+shift
+if [[ ! -f "$thisdir/mpbb-$command" ]]; then
+ err "Unknown command \`$command'"
+ usage
+fi
+
## If subcommand help is requested, print that
if [[ $option_help -eq 1 ]]; then
usage
Modified: contrib/mp-buildbot/mpbb-checkout
===================================================================
--- contrib/mp-buildbot/mpbb-checkout 2016-09-12 01:58:52 UTC (rev 152524)
+++ contrib/mp-buildbot/mpbb-checkout 2016-09-12 01:58:56 UTC (rev 152525)
@@ -15,17 +15,20 @@
}
checkout() {
+ local args
+ parseopt prefix:,svn:,svn-revision:,svn-url: "$@" || return
+ : "${option_svn=$(which svn)}"
+ : "${option_svn_revision=HEAD}"
+ : "${option_svn_url=https://svn.macports.org/repository/macports/trunk}"
+ # shellcheck disable=SC2086
+ set -- ${args+"${args[@]}"}
+
# $option_work_dir is set in mpbb, which sources this script
# shellcheck disable=SC2154
dports_svn=${option_work_dir}/dports
tools_svn=${option_work_dir}/tools
- # $option_svn is set in mpbb
- # shellcheck disable=SC2154
svn=${option_svn}
- # $option_svn_url and $option_svn_revision are set in mpbb
- # shellcheck disable=SC2154
svn_url=${option_svn_url}
- # shellcheck disable=SC2154
svn_rev=${option_svn_revision}
if [[ -d "${tools_svn}/.svn" ]] ; then
Modified: contrib/mp-buildbot/mpbb-cleanup
===================================================================
--- contrib/mp-buildbot/mpbb-cleanup 2016-09-12 01:58:52 UTC (rev 152524)
+++ contrib/mp-buildbot/mpbb-cleanup 2016-09-12 01:58:56 UTC (rev 152525)
@@ -10,8 +10,13 @@
}
cleanup() {
+ local args
+ parseopt prefix: "$@" || return
+ # shellcheck disable=SC2086
+ set -- ${args+"${args[@]}"}
+
# if this is the very first build, selfupdate did not install port yet
- # $option_prefix is set by mpbb
+ # $option_prefix is set by parseopt
# shellcheck disable=SC2154
if [ ! -e "${option_prefix}/bin/port" ]; then
echo "---> Skipping cleanup"
Modified: contrib/mp-buildbot/mpbb-gather-archives
===================================================================
--- contrib/mp-buildbot/mpbb-gather-archives 2016-09-12 01:58:52 UTC (rev 152524)
+++ contrib/mp-buildbot/mpbb-gather-archives 2016-09-12 01:58:56 UTC (rev 152525)
@@ -11,12 +11,18 @@
}
gather-archives() {
+ local args
+ parseopt archive-site:,prefix:,staging-dir: "$@" || return
+ : "${option_archive_site=https://packages.macports.org}"
+ # shellcheck disable=SC2154
+ : "${option_staging_dir=${option_work_dir}/archive-staging}"
+ # shellcheck disable=SC2086
+ set -- ${args+"${args[@]}"}
+
# $option_prefix is set in mpbb
# shellcheck disable=SC2154
tclsh=${option_prefix}/bin/port-tclsh
- # $option_staging_dir is set in mpbb
- # shellcheck disable=SC2154
if [ -d "${option_staging_dir}" ]; then
find "${option_staging_dir}" -type f -delete -print | sed -E -e "s|^.*/||" -e 's/^/Deleting previously staged archive: /'
rm -rf "${option_staging_dir}"
@@ -30,8 +36,6 @@
archive_port=$(basename "$(dirname "${archive_path}")")
archive_basename=$(basename "${archive_path}")
- # $option_archive_site is set in mpbb
- # shellcheck disable=SC2154
if ! curl -fIsL "${option_archive_site}/${archive_port}/${archive_basename}" > /dev/null; then
# $option_work_dir is set in mpbb
# shellcheck disable=SC2154
Modified: contrib/mp-buildbot/mpbb-install-dependencies
===================================================================
--- contrib/mp-buildbot/mpbb-install-dependencies 2016-09-12 01:58:52 UTC (rev 152524)
+++ contrib/mp-buildbot/mpbb-install-dependencies 2016-09-12 01:58:56 UTC (rev 152525)
@@ -19,7 +19,14 @@
}
install-dependencies() {
- local port=${1-${option_port-}}
+ local args
+ parseopt port:,prefix: "$@" || return
+ # shellcheck disable=SC2154
+ : "${option_port=}"
+ # shellcheck disable=SC2086
+ set -- ${args+"${args[@]}"}
+
+ local port=${1-${option_port}}
if [[ -z $port ]]; then
err "Must specify a port"
return 1
Modified: contrib/mp-buildbot/mpbb-install-port
===================================================================
--- contrib/mp-buildbot/mpbb-install-port 2016-09-12 01:58:52 UTC (rev 152524)
+++ contrib/mp-buildbot/mpbb-install-port 2016-09-12 01:58:56 UTC (rev 152525)
@@ -19,7 +19,14 @@
}
install-port() {
- local port=${1-${option_port-}}
+ local args
+ parseopt port:,prefix: "$@" || return
+ # shellcheck disable=SC2154
+ : "${option_port=}"
+ # shellcheck disable=SC2086
+ set -- ${args+"${args[@]}"}
+
+ local port=${1-${option_port}}
if [[ -z $port ]]; then
err "Must specify a port"
return 1
Modified: contrib/mp-buildbot/mpbb-selfupdate
===================================================================
--- contrib/mp-buildbot/mpbb-selfupdate 2016-09-12 01:58:52 UTC (rev 152524)
+++ contrib/mp-buildbot/mpbb-selfupdate 2016-09-12 01:58:56 UTC (rev 152525)
@@ -10,6 +10,11 @@
}
selfupdate() {
+ local args
+ parseopt prefix: "$@" || return
+ # shellcheck disable=SC2086
+ set -- ${args+"${args[@]}"}
+
# $option_prefix is set in mpbb
# shellcheck disable=SC2154
if [ ! -f "${option_prefix}/bin/port" ]; then
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/macports-changes/attachments/20160911/5c925309/attachment-0001.html>
More information about the macports-changes
mailing list