<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[152529] contrib/mp-buildbot/mpbb-checkout</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="https://trac.macports.org/changeset/152529">152529</a></dd>
<dt>Author</dt> <dd>larryv@macports.org</dd>
<dt>Date</dt> <dd>2016-09-11 18:59:06 -0700 (Sun, 11 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>mpbb: Generalize checkout operations

- Rename options and parameters to be VCS-agnostic.

- Don't assume that the jobs tools and ports tree are stored in the same
  repository. Add new options &quot;--jobs-url&quot; and &quot;--ports-url&quot; and
  deprecate &quot;--svn-url&quot;.

- Conditionalize existing Subversion code.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#contribmpbuildbotmpbbcheckout">contrib/mp-buildbot/mpbb-checkout</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="contribmpbuildbotmpbbcheckout"></a>
<div class="modfile"><h4>Modified: contrib/mp-buildbot/mpbb-checkout (152528 => 152529)</h4>
<pre class="diff"><span>
<span class="info">--- contrib/mp-buildbot/mpbb-checkout        2016-09-12 01:59:04 UTC (rev 152528)
+++ contrib/mp-buildbot/mpbb-checkout        2016-09-12 01:59:06 UTC (rev 152529)
</span><span class="lines">@@ -16,77 +16,97 @@
</span><span class="cx"> 
</span><span class="cx"> Options:
</span><span class="cx"> 
</span><del>-  --svn=&lt;path&gt;
-    A command-line Subversion client. Defaults to the first \`svn'
-    executable found in \$PATH.
</del><ins>+  --jobs-url=&lt;URL&gt;
+    URL to a repository containing the jobs tools. Only used when
+    checking out a new working copy. Defaults to
+    \`https://svn.macports.org/repository/macports/trunk/base/portmgr/jobs'.
</ins><span class="cx"> 
</span><del>-  --svn-url=&lt;URL&gt;
-    URL to a Subversion repository that contains \`dports' and
-    \`base/portmgr/jobs' subdirectories. Only used when checking out
-    a new working copy. Defaults to
-    \`https://svn.macports.org/repository/macports/trunk'.
-
-  --svn-revision=&lt;rev&gt;
-    Revision number at which the ports tree will be checked out.
</del><ins>+  --ports-commit=&lt;commit&gt;
+    A commit or revision at which the ports tree will be checked out.
+    Any specifier understood by the version-control client may be used.
</ins><span class="cx">     Defaults to \`HEAD'.
</span><span class="cx"> 
</span><ins>+  --ports-url=&lt;URL&gt;
+    URL to a repository containing the ports tree. Only used when
+    checking out a new working copy. Defaults to
+    \`https://svn.macports.org/repository/macports/trunk/dports'.
+
+  --svn[=&lt;path&gt;]
+    Use Subversion to obtain the jobs tools and ports tree; this is the
+    default behavior. The path to a Subversion client may be provided
+    explicitly, otherwise \`svn' is used.
+
</ins><span class="cx"> Run \`$prog help' for global options and a list of other subcommands.
</span><span class="cx"> EOF
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> checkout() {
</span><span class="cx">     local args
</span><del>-    parseopt prefix:,svn:,svn-revision:,svn-url: &quot;$@&quot; || return
-    : &quot;${option_svn=$(which svn)}&quot;
-    : &quot;${option_svn_revision=HEAD}&quot;
-    : &quot;${option_svn_url=https://svn.macports.org/repository/macports/trunk}&quot;
</del><ins>+    parseopt jobs-url:,ports-commit:,ports-url:,prefix:,svn::,svn-url: &quot;$@&quot; \
+        || return
</ins><span class="cx">     # shellcheck disable=SC2086
</span><span class="cx">     set -- ${args+&quot;${args[@]}&quot;}
</span><span class="cx"> 
</span><del>-    # $option_work_dir is set in mpbb, which sources this script
</del><span class="cx">     # shellcheck disable=SC2154
</span><del>-    dports_svn=${option_work_dir}/dports
-    tools_svn=${option_work_dir}/tools
-    svn=${option_svn}
-    svn_url=${option_svn_url}
-    svn_rev=${option_svn_revision}
</del><ins>+    # To maintain backwards compatibility, --svn-url implies --svn.
+    if [[ -n ${option_svn_url+_} ]]; then
+        : &quot;${option_svn=}&quot;
+    fi
</ins><span class="cx"> 
</span><del>-    if [[ -d &quot;${tools_svn}/.svn&quot; ]] ; then
</del><ins>+    # shellcheck disable=SC2154
+    local -r ports_dir=${option_work_dir}/dports
+
+    local jobs_dir svn
+    # shellcheck disable=SC2154
+    if svn=${option_svn:-$(command -v svn)}; then
+        jobs_dir=${option_work_dir}/tools
+        if [[ -n ${option_svn_url+_} ]]; then
+            : &quot;${option_jobs_url=${option_svn_url}/base/portmgr/jobs}&quot;
+            : &quot;${option_ports_url=${option_svn_url}/dports}&quot;
+        else
+            : &quot;${option_jobs_url=https://svn.macports.org/repository/macports/trunk/base/portmgr/jobs}&quot;
+            : &quot;${option_ports_url=https://svn.macports.org/repository/macports/trunk/dports}&quot;
+        fi
+    if [[ -d &quot;${jobs_dir}/.svn&quot; ]] ; then
</ins><span class="cx">         echo &quot;Update macports tools from svn...&quot;
</span><del>-        if [[ -e &quot;${tools_svn}/.svn/lock&quot; ]]; then
-            &quot;$svn&quot; --non-interactive cleanup &quot;${tools_svn}&quot; || return
</del><ins>+        if [[ -e &quot;${jobs_dir}/.svn/lock&quot; ]]; then
+            &quot;$svn&quot; --non-interactive cleanup &quot;${jobs_dir}&quot; || return
</ins><span class="cx">         fi
</span><span class="cx">         &quot;$svn&quot; update --non-interactive \
</span><span class="cx">             -r HEAD \
</span><del>-            &quot;${tools_svn}&quot; || return
</del><ins>+            &quot;${jobs_dir}&quot; || return
</ins><span class="cx">     else
</span><span class="cx">         echo &quot;Checking out macports tools from svn...&quot;
</span><del>-        mkdir -p &quot;${option_work_dir}&quot;
</del><ins>+        mkdir -p &quot;$(dirname &quot;${jobs_dir}&quot;)&quot;
</ins><span class="cx">         &quot;$svn&quot; checkout --non-interactive \
</span><del>-            -r HEAD &quot;${svn_url}/base/portmgr/jobs&quot; \
-            &quot;${tools_svn}&quot; || return
</del><ins>+            -r HEAD &quot;${option_jobs_url}&quot; \
+            &quot;${jobs_dir}&quot; || return
</ins><span class="cx">     fi
</span><span class="cx"> 
</span><del>-    if [[ -d &quot;${dports_svn}/.svn&quot; ]] ; then
</del><ins>+    if [[ -d &quot;${ports_dir}/.svn&quot; ]] ; then
</ins><span class="cx">         echo &quot;Update macports from svn...&quot;
</span><span class="cx">         # TODO: add switching of SVN server
</span><del>-        if [[ -e &quot;${dports_svn}/.svn/lock&quot; ]]; then
-            &quot;$svn&quot; --non-interactive cleanup &quot;${dports_svn}&quot; || return
</del><ins>+        if [[ -e &quot;${ports_dir}/.svn/lock&quot; ]]; then
+            &quot;$svn&quot; --non-interactive cleanup &quot;${ports_dir}&quot; || return
</ins><span class="cx">         fi
</span><span class="cx">         &quot;$svn&quot; update --non-interactive \
</span><del>-            -r &quot;${svn_rev}&quot; \
-            &quot;${dports_svn}&quot; || return
</del><ins>+            -r &quot;${option_ports_commit-HEAD}&quot; \
+            &quot;${ports_dir}&quot; || return
</ins><span class="cx">     else
</span><span class="cx">         echo &quot;Checking out macports from svn...&quot;
</span><del>-        mkdir -p &quot;${option_work_dir}&quot;
</del><ins>+        mkdir -p &quot;$(dirname &quot;${ports_dir}&quot;)&quot;
</ins><span class="cx">         &quot;$svn&quot; checkout --non-interactive \
</span><del>-            -r &quot;${svn_rev}&quot; &quot;${svn_url}/dports&quot; \
-            &quot;${dports_svn}&quot; || return
</del><ins>+            -r &quot;${option_ports_commit-HEAD}&quot; &quot;${option_ports_url}&quot; \
+            &quot;${ports_dir}&quot; || return
</ins><span class="cx">     fi
</span><ins>+    else
+        err 'cannot find a Subversion client'
+        return 1
+    fi
</ins><span class="cx"> 
</span><span class="cx">     # $option_prefix is set in mpbb
</span><span class="cx">     # shellcheck disable=SC2154
</span><del>-    (cd &quot;${dports_svn}&quot; &amp;&amp; &quot;${option_prefix}/bin/portindex&quot;) || return
</del><ins>+    (cd &quot;${ports_dir}&quot; &amp;&amp; &quot;${option_prefix}/bin/portindex&quot;) || return
</ins><span class="cx"> 
</span><span class="cx">     local -ar mirrors=(aarnet.au cjj.kr fco.it her.gr jnb.za jog.id
</span><span class="cx">                        lil.fr mse.uk nou.nc nue.de osl.no sea.us ykf.ca)
</span><span class="lines">@@ -103,7 +123,7 @@
</span><span class="cx">     cat &gt; &quot;${option_work_dir}/sources.conf&quot; &lt;&lt;EOF || return
</span><span class="cx"> # Automatically overwritten by mpbb-checkout
</span><span class="cx"> # Do not edit !!!
</span><del>-file://${dports_svn} [default]
</del><ins>+file://${ports_dir} [default]
</ins><span class="cx"> EOF
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>