<!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>[146885] trunk/base/src/macports1.0</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/146885">146885</a></dd>
<dt>Author</dt> <dd>raimue@macports.org</dd>
<dt>Date</dt> <dd>2016-03-19 07:49:40 -0700 (Sat, 19 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Move selfupdate code into separate file</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbasesrcmacports10Makefilein">trunk/base/src/macports1.0/Makefile.in</a></li>
<li><a href="#trunkbasesrcmacports10macportstcl">trunk/base/src/macports1.0/macports.tcl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkbasesrcmacports10selfupdatetcl">trunk/base/src/macports1.0/selfupdate.tcl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbasesrcmacports10Makefilein"></a>
<div class="modfile"><h4>Modified: trunk/base/src/macports1.0/Makefile.in (146884 => 146885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/base/src/macports1.0/Makefile.in        2016-03-19 13:41:04 UTC (rev 146884)
+++ trunk/base/src/macports1.0/Makefile.in        2016-03-19 14:49:40 UTC (rev 146885)
</span><span class="lines">@@ -4,7 +4,7 @@
</span><span class="cx"> include ../../Mk/macports.autoconf.mk
</span><span class="cx"> 
</span><span class="cx"> SRCS=                macports.tcl macports_dlist.tcl macports_util.tcl \
</span><del>-                macports_autoconf.tcl diagnose.tcl reclaim.tcl
</del><ins>+                macports_autoconf.tcl diagnose.tcl reclaim.tcl selfupdate.tcl
</ins><span class="cx"> OBJS=                macports.o get_systemconfiguration_proxies.o sysctl.o
</span><span class="cx"> SHLIB_NAME=        MacPorts${SHLIB_SUFFIX}
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbasesrcmacports10macportstcl"></a>
<div class="modfile"><h4>Modified: trunk/base/src/macports1.0/macports.tcl (146884 => 146885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/base/src/macports1.0/macports.tcl        2016-03-19 13:41:04 UTC (rev 146884)
+++ trunk/base/src/macports1.0/macports.tcl        2016-03-19 14:49:40 UTC (rev 146885)
</span><span class="lines">@@ -38,6 +38,7 @@
</span><span class="cx"> package require macports_util 1.0
</span><span class="cx"> package require diagnose 1.0
</span><span class="cx"> package require reclaim 1.0
</span><ins>+package require selfupdate 1.0
</ins><span class="cx"> package require Tclx
</span><span class="cx"> 
</span><span class="cx"> namespace eval macports {
</span><span class="lines">@@ -3544,198 +3545,7 @@
</span><span class="cx"> 
</span><span class="cx"> # selfupdate procedure
</span><span class="cx"> proc macports::selfupdate {{optionslist {}} {updatestatusvar {}}} {
</span><del>-    global macports::prefix macports::portdbpath macports::rsync_server macports::rsync_dir \
-           macports::rsync_options macports::autoconf::macports_version \
-           macports::autoconf::rsync_path tcl_platform macports::autoconf::openssl_path \
-           macports::autoconf::tar_path
-    array set options $optionslist
-
-    # variable that indicates whether we actually updated base
-    if {$updatestatusvar ne &quot;&quot;} {
-        upvar $updatestatusvar updatestatus
-        set updatestatus no
-    }
-
-    # are we syncing a tarball? (implies detached signature)
-    set is_tarball 0
-    if {[string range $rsync_dir end-3 end] eq &quot;.tar&quot;} {
-        set is_tarball 1
-        set mp_source_path [file join $portdbpath sources $rsync_server [file dirname $rsync_dir]]
-    } else {
-        if {[string index $rsync_dir end] ne &quot;/&quot;} {
-            append rsync_dir /
-        }
-        set mp_source_path [file join $portdbpath sources $rsync_server $rsync_dir]
-    }
-    # create the path to the to be downloaded sources if it doesn't exist
-    if {![file exists $mp_source_path]} {
-        file mkdir $mp_source_path
-    }
-    ui_debug &quot;MacPorts sources location: $mp_source_path&quot;
-
-    # sync the MacPorts sources
-    ui_msg &quot;$macports::ui_prefix Updating MacPorts base sources using rsync&quot;
-    try -pass_signal {
-        system &quot;$rsync_path $rsync_options rsync://${rsync_server}/$rsync_dir $mp_source_path&quot;
-    } catch {{*} eCode eMessage} {
-        return -code error &quot;Error synchronizing MacPorts sources: $eMessage&quot;
-    }
-
-    if {$is_tarball} {
-        # verify signature for tarball
-        global macports::archivefetch_pubkeys
-        try -pass_signal {
-            system &quot;$rsync_path $rsync_options rsync://${rsync_server}/${rsync_dir}.rmd160 $mp_source_path&quot;
-        } catch {{*} eCode eMessage} {
-            return -code error &quot;Error synchronizing MacPorts source signature: $eMessage&quot;
-        }
-        set openssl [findBinary openssl $macports::autoconf::openssl_path]
-        set tarball ${mp_source_path}/[file tail $rsync_dir]
-        set signature ${tarball}.rmd160
-        set verified 0
-        foreach pubkey $macports::archivefetch_pubkeys {
-            try -pass_signal {
-                exec $openssl dgst -ripemd160 -verify $pubkey -signature $signature $tarball
-                set verified 1
-                ui_debug &quot;successful verification with key $pubkey&quot;
-                break
-            }  catch {{*} eCode eMessage} {
-                ui_debug &quot;failed verification with key $pubkey&quot;
-                ui_debug &quot;openssl output: $eMessage&quot;
-            }
-        }
-        if {!$verified} {
-            return -code error &quot;Failed to verify signature for MacPorts source!&quot;
-        }
-
-        # extract tarball and move into place
-        set tar [macports::findBinary tar $macports::autoconf::tar_path]
-        file mkdir ${mp_source_path}/tmp
-        set tar_cmd &quot;$tar -C ${mp_source_path}/tmp -xf $tarball&quot;
-        try -pass_signal {
-            system $tar_cmd
-        } catch {*} {
-            return -code error &quot;Failed to extract MacPorts sources from tarball!&quot;
-        }
-        file delete -force ${mp_source_path}/base
-        file rename ${mp_source_path}/tmp/base ${mp_source_path}/base
-        file delete -force ${mp_source_path}/tmp
-        # set the final extracted source path
-        set mp_source_path ${mp_source_path}/base
-    }
-
-    # echo current MacPorts version
-    ui_msg &quot;MacPorts base version $macports::autoconf::macports_version installed,&quot;
-
-    if {[info exists options(ports_force)] &amp;&amp; $options(ports_force)} {
-        set use_the_force_luke yes
-        ui_debug &quot;Forcing a rebuild and reinstallation of MacPorts&quot;
-    } else {
-        set use_the_force_luke no
-        ui_debug &quot;Rebuilding and reinstalling MacPorts if needed&quot;
-    }
-
-    # Choose what version file to use: old, floating point format or new, real version number format
-    set version_file [file join $mp_source_path config macports_version]
-    if {[file exists $version_file]} {
-        set fd [open $version_file r]
-        gets $fd macports_version_new
-        close $fd
-        # echo downloaded MacPorts version
-        ui_msg &quot;MacPorts base version $macports_version_new downloaded.&quot;
-    } else {
-        ui_warn &quot;No version file found, please rerun selfupdate.&quot;
-        set macports_version_new 0
-    }
-
-    # check if we we need to rebuild base
-    set comp [vercmp $macports_version_new $macports::autoconf::macports_version]
-
-    # syncing ports tree.
-    if {![info exists options(ports_selfupdate_nosync)] || !$options(ports_selfupdate_nosync)} {
-        if {$comp &gt; 0} {
-            # updated portfiles potentially need new base to parse - tell sync to try to
-            # use prefabricated PortIndex files and signal if it couldn't
-            lappend optionslist no_reindex 1 needed_portindex_var needed_portindex
-        }
-        try {
-            mportsync $optionslist
-        }  catch {{*} eCode eMessage} {
-            return -code error &quot;Couldn't sync the ports tree: $eMessage&quot;
-        }
-    }
-
-    if {$use_the_force_luke || $comp &gt; 0} {
-        if {[info exists options(ports_dryrun)] &amp;&amp; $options(ports_dryrun)} {
-            ui_msg &quot;$macports::ui_prefix MacPorts base is outdated, selfupdate would install $macports_version_new (dry run)&quot;
-        } else {
-            ui_msg &quot;$macports::ui_prefix MacPorts base is outdated, installing new version $macports_version_new&quot;
-
-            # get installation user/group and permissions
-            set owner [file attributes $prefix -owner]
-            set group [file attributes $prefix -group]
-            set perms [string range [file attributes $prefix -permissions] end-3 end]
-            if {$tcl_platform(user) ne &quot;root&quot; &amp;&amp; $tcl_platform(user) ne $owner} {
-                return -code error &quot;User $tcl_platform(user) does not own $prefix - try using sudo&quot;
-            }
-            ui_debug &quot;Permissions OK&quot;
-
-            set configure_args &quot;--prefix=[macports::shellescape $prefix] --with-install-user=[macports::shellescape $owner] --with-install-group=[macports::shellescape $group] --with-directory-mode=[macports::shellescape $perms]&quot;
-            # too many users have an incompatible readline in /usr/local, see ticket #10651
-            if {$tcl_platform(os) ne &quot;Darwin&quot; || $prefix eq &quot;/usr/local&quot;
-                || ([glob -nocomplain /usr/local/lib/lib{readline,history}*] eq &quot;&quot; &amp;&amp; [glob -nocomplain /usr/local/include/readline/*.h] eq &quot;&quot;)} {
-                append configure_args &quot; --enable-readline&quot;
-            } else {
-                ui_warn &quot;Disabling readline support due to readline in /usr/local&quot;
-            }
-
-            if {$prefix eq &quot;/usr/local&quot; || $prefix eq &quot;/usr&quot;} {
-                append configure_args &quot; --with-unsupported-prefix&quot;
-            }
-
-            # Choose a sane compiler
-            set cc_arg {}
-            if {$::macports::os_platform eq &quot;darwin&quot;} {
-                set cc_arg &quot;CC=/usr/bin/cc OBJC=/usr/bin/cc &quot;
-            }
-
-            # do the actual configure, build and installation of new base
-            ui_msg &quot;Installing new MacPorts release in $prefix as ${owner}:${group}; permissions ${perms}\n&quot;
-            try {
-                system -W $mp_source_path &quot;${cc_arg}./configure $configure_args &amp;&amp; make SELFUPDATING=1 &amp;&amp; make install SELFUPDATING=1&quot;
-            } catch {{*} eCode eMessage} {
-                return -code error &quot;Error installing new MacPorts base: $eMessage&quot;
-            }
-            if {[info exists updatestatus]} {
-                set updatestatus yes
-            }
-        }
-    } elseif {$comp &lt; 0} {
-        ui_msg &quot;$macports::ui_prefix MacPorts base is probably trunk or a release candidate&quot;
-    } else {
-        ui_msg &quot;$macports::ui_prefix MacPorts base is already the latest version&quot;
-    }
-
-    # set the MacPorts sources to the right owner
-    set sources_owner [file attributes [file join $portdbpath sources/] -owner]
-    ui_debug &quot;Setting MacPorts sources ownership to $sources_owner&quot;
-    try {
-        exec [findBinary chown $macports::autoconf::chown_path] -R $sources_owner [file join $portdbpath sources/]
-    }  catch {{*} eCode eMessage} {
-        return -code error &quot;Couldn't change permissions of the MacPorts sources at $mp_source_path to ${sources_owner}: $eMessage&quot;
-    }
-
-    if {![info exists options(ports_selfupdate_nosync)] || !$options(ports_selfupdate_nosync)} {
-        if {[info exists needed_portindex]} {
-            ui_msg &quot;Not all sources could be fully synced using the old version of MacPorts.&quot;
-            ui_msg &quot;Please run selfupdate again now that MacPorts base has been updated.&quot;
-        } else {
-            ui_msg &quot;\nThe ports tree has been updated. To upgrade your installed ports, you should run&quot;
-            ui_msg &quot;  port upgrade outdated&quot;
-        }
-    }
-
-    return 0
</del><ins>+    return [uplevel [list selfupdate::main $optionslist $updatestatusvar]]
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> # upgrade API wrapper procedure
</span></span></pre></div>
<a id="trunkbasesrcmacports10selfupdatetcl"></a>
<div class="addfile"><h4>Added: trunk/base/src/macports1.0/selfupdate.tcl (0 => 146885)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/base/src/macports1.0/selfupdate.tcl                                (rev 0)
+++ trunk/base/src/macports1.0/selfupdate.tcl        2016-03-19 14:49:40 UTC (rev 146885)
</span><span class="lines">@@ -0,0 +1,233 @@
</span><ins>+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
+# selfupdate.tcl
+# $Id$
+#
+# Copyright (c) 2016 The MacPorts Project
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of Apple Inc. nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &quot;AS IS&quot;
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+package provide selfupdate 1.0
+
+package require macports
+
+namespace eval selfupdate {
+    namespace export main
+}
+
+proc selfupdate::main {{optionslist {}} {updatestatusvar {}}} {
+    global macports::prefix macports::portdbpath macports::rsync_server macports::rsync_dir \
+           macports::rsync_options macports::autoconf::macports_version \
+           macports::autoconf::rsync_path tcl_platform macports::autoconf::openssl_path \
+           macports::autoconf::tar_path
+    array set options $optionslist
+
+    # variable that indicates whether we actually updated base
+    if {$updatestatusvar ne &quot;&quot;} {
+        upvar $updatestatusvar updatestatus
+        set updatestatus no
+    }
+
+    # are we syncing a tarball? (implies detached signature)
+    set is_tarball 0
+    if {[string range $rsync_dir end-3 end] eq &quot;.tar&quot;} {
+        set is_tarball 1
+        set mp_source_path [file join $portdbpath sources $rsync_server [file dirname $rsync_dir]]
+    } else {
+        if {[string index $rsync_dir end] ne &quot;/&quot;} {
+            append rsync_dir /
+        }
+        set mp_source_path [file join $portdbpath sources $rsync_server $rsync_dir]
+    }
+    # create the path to the to be downloaded sources if it doesn't exist
+    if {![file exists $mp_source_path]} {
+        file mkdir $mp_source_path
+    }
+    ui_debug &quot;MacPorts sources location: $mp_source_path&quot;
+
+    # sync the MacPorts sources
+    ui_msg &quot;$macports::ui_prefix Updating MacPorts base sources using rsync&quot;
+    try -pass_signal {
+        system &quot;$rsync_path $rsync_options rsync://${rsync_server}/$rsync_dir $mp_source_path&quot;
+    } catch {{*} eCode eMessage} {
+        return -code error &quot;Error synchronizing MacPorts sources: $eMessage&quot;
+    }
+
+    if {$is_tarball} {
+        # verify signature for tarball
+        global macports::archivefetch_pubkeys
+        try -pass_signal {
+            system &quot;$rsync_path $rsync_options rsync://${rsync_server}/${rsync_dir}.rmd160 $mp_source_path&quot;
+        } catch {{*} eCode eMessage} {
+            return -code error &quot;Error synchronizing MacPorts source signature: $eMessage&quot;
+        }
+        set openssl [macports::findBinary openssl $macports::autoconf::openssl_path]
+        set tarball ${mp_source_path}/[file tail $rsync_dir]
+        set signature ${tarball}.rmd160
+        set verified 0
+        foreach pubkey $macports::archivefetch_pubkeys {
+            try -pass_signal {
+                exec $openssl dgst -ripemd160 -verify $pubkey -signature $signature $tarball
+                set verified 1
+                ui_debug &quot;successful verification with key $pubkey&quot;
+                break
+            }  catch {{*} eCode eMessage} {
+                ui_debug &quot;failed verification with key $pubkey&quot;
+                ui_debug &quot;openssl output: $eMessage&quot;
+            }
+        }
+        if {!$verified} {
+            return -code error &quot;Failed to verify signature for MacPorts source!&quot;
+        }
+
+        # extract tarball and move into place
+        set tar [macports::findBinary tar $macports::autoconf::tar_path]
+        file mkdir ${mp_source_path}/tmp
+        set tar_cmd &quot;$tar -C ${mp_source_path}/tmp -xf $tarball&quot;
+        try -pass_signal {
+            system $tar_cmd
+        } catch {*} {
+            return -code error &quot;Failed to extract MacPorts sources from tarball!&quot;
+        }
+        file delete -force ${mp_source_path}/base
+        file rename ${mp_source_path}/tmp/base ${mp_source_path}/base
+        file delete -force ${mp_source_path}/tmp
+        # set the final extracted source path
+        set mp_source_path ${mp_source_path}/base
+    }
+
+    # echo current MacPorts version
+    ui_msg &quot;MacPorts base version $macports::autoconf::macports_version installed,&quot;
+
+    if {[info exists options(ports_force)] &amp;&amp; $options(ports_force)} {
+        set use_the_force_luke yes
+        ui_debug &quot;Forcing a rebuild and reinstallation of MacPorts&quot;
+    } else {
+        set use_the_force_luke no
+        ui_debug &quot;Rebuilding and reinstalling MacPorts if needed&quot;
+    }
+
+    # Choose what version file to use: old, floating point format or new, real version number format
+    set version_file [file join $mp_source_path config macports_version]
+    if {[file exists $version_file]} {
+        set fd [open $version_file r]
+        gets $fd macports_version_new
+        close $fd
+        # echo downloaded MacPorts version
+        ui_msg &quot;MacPorts base version $macports_version_new downloaded.&quot;
+    } else {
+        ui_warn &quot;No version file found, please rerun selfupdate.&quot;
+        set macports_version_new 0
+    }
+
+    # check if we we need to rebuild base
+    set comp [vercmp $macports_version_new $macports::autoconf::macports_version]
+
+    # syncing ports tree.
+    if {![info exists options(ports_selfupdate_nosync)] || !$options(ports_selfupdate_nosync)} {
+        if {$comp &gt; 0} {
+            # updated portfiles potentially need new base to parse - tell sync to try to
+            # use prefabricated PortIndex files and signal if it couldn't
+            lappend optionslist no_reindex 1 needed_portindex_var needed_portindex
+        }
+        try {
+            mportsync $optionslist
+        }  catch {{*} eCode eMessage} {
+            return -code error &quot;Couldn't sync the ports tree: $eMessage&quot;
+        }
+    }
+
+    if {$use_the_force_luke || $comp &gt; 0} {
+        if {[info exists options(ports_dryrun)] &amp;&amp; $options(ports_dryrun)} {
+            ui_msg &quot;$macports::ui_prefix MacPorts base is outdated, selfupdate would install $macports_version_new (dry run)&quot;
+        } else {
+            ui_msg &quot;$macports::ui_prefix MacPorts base is outdated, installing new version $macports_version_new&quot;
+
+            # get installation user/group and permissions
+            set owner [file attributes $prefix -owner]
+            set group [file attributes $prefix -group]
+            set perms [string range [file attributes $prefix -permissions] end-3 end]
+            if {$tcl_platform(user) ne &quot;root&quot; &amp;&amp; $tcl_platform(user) ne $owner} {
+                return -code error &quot;User $tcl_platform(user) does not own $prefix - try using sudo&quot;
+            }
+            ui_debug &quot;Permissions OK&quot;
+
+            set configure_args &quot;--prefix=[macports::shellescape $prefix] --with-install-user=[macports::shellescape $owner] --with-install-group=[macports::shellescape $group] --with-directory-mode=[macports::shellescape $perms]&quot;
+            # too many users have an incompatible readline in /usr/local, see ticket #10651
+            if {$tcl_platform(os) ne &quot;Darwin&quot; || $prefix eq &quot;/usr/local&quot;
+                || ([glob -nocomplain /usr/local/lib/lib{readline,history}*] eq &quot;&quot; &amp;&amp; [glob -nocomplain /usr/local/include/readline/*.h] eq &quot;&quot;)} {
+                append configure_args &quot; --enable-readline&quot;
+            } else {
+                ui_warn &quot;Disabling readline support due to readline in /usr/local&quot;
+            }
+
+            if {$prefix eq &quot;/usr/local&quot; || $prefix eq &quot;/usr&quot;} {
+                append configure_args &quot; --with-unsupported-prefix&quot;
+            }
+
+            # Choose a sane compiler
+            set cc_arg {}
+            if {$::macports::os_platform eq &quot;darwin&quot;} {
+                set cc_arg &quot;CC=/usr/bin/cc OBJC=/usr/bin/cc &quot;
+            }
+
+            # do the actual configure, build and installation of new base
+            ui_msg &quot;Installing new MacPorts release in $prefix as ${owner}:${group}; permissions ${perms}\n&quot;
+            try {
+                system -W $mp_source_path &quot;${cc_arg}./configure $configure_args &amp;&amp; make SELFUPDATING=1 &amp;&amp; make install SELFUPDATING=1&quot;
+            } catch {{*} eCode eMessage} {
+                return -code error &quot;Error installing new MacPorts base: $eMessage&quot;
+            }
+            if {[info exists updatestatus]} {
+                set updatestatus yes
+            }
+        }
+    } elseif {$comp &lt; 0} {
+        ui_msg &quot;$macports::ui_prefix MacPorts base is probably trunk or a release candidate&quot;
+    } else {
+        ui_msg &quot;$macports::ui_prefix MacPorts base is already the latest version&quot;
+    }
+
+    # set the MacPorts sources to the right owner
+    set sources_owner [file attributes [file join $portdbpath sources/] -owner]
+    ui_debug &quot;Setting MacPorts sources ownership to $sources_owner&quot;
+    try {
+        exec [macports::findBinary chown $macports::autoconf::chown_path] -R $sources_owner [file join $portdbpath sources/]
+    }  catch {{*} eCode eMessage} {
+        return -code error &quot;Couldn't change permissions of the MacPorts sources at $mp_source_path to ${sources_owner}: $eMessage&quot;
+    }
+
+    if {![info exists options(ports_selfupdate_nosync)] || !$options(ports_selfupdate_nosync)} {
+        if {[info exists needed_portindex]} {
+            ui_msg &quot;Not all sources could be fully synced using the old version of MacPorts.&quot;
+            ui_msg &quot;Please run selfupdate again now that MacPorts base has been updated.&quot;
+        } else {
+            ui_msg &quot;\nThe ports tree has been updated. To upgrade your installed ports, you should run&quot;
+            ui_msg &quot;  port upgrade outdated&quot;
+        }
+    }
+
+    return 0
+}
</ins><span class="cx">Property changes on: trunk/base/src/macports1.0/selfupdate.tcl
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnkeywords"></a>
<div class="addfile"><h4>Added: svn:keywords</h4></div>
<a id="svneolstyle"></a>
<div class="addfile"><h4>Added: svn:eol-style</h4></div>
</div>

</body>
</html>