[100533] branches/new-help-system/base

raimue at macports.org raimue at macports.org
Fri Dec 14 16:33:09 PST 2012


Revision: 100533
          https://trac.macports.org/changeset/100533
Author:   raimue at macports.org
Date:     2012-12-14 16:33:09 -0800 (Fri, 14 Dec 2012)
Log Message:
-----------
Merge from trunk

Modified Paths:
--------------
    branches/new-help-system/base/ChangeLog
    branches/new-help-system/base/LICENSE
    branches/new-help-system/base/Makefile.in
    branches/new-help-system/base/NEWS
    branches/new-help-system/base/aclocal.m4
    branches/new-help-system/base/config/RELEASE_URL
    branches/new-help-system/base/config/macports_version
    branches/new-help-system/base/configure
    branches/new-help-system/base/configure.ac
    branches/new-help-system/base/doc/Makefile
    branches/new-help-system/base/doc/base.mtree.in
    branches/new-help-system/base/doc/macports.conf.in
    branches/new-help-system/base/doc/portfile.7
    branches/new-help-system/base/portmgr/ReleaseProcess
    branches/new-help-system/base/portmgr/dmg/License.html
    branches/new-help-system/base/portmgr/dmg/postflight
    branches/new-help-system/base/portmgr/jobs/mprsyncup
    branches/new-help-system/base/portmgr/jobs/port_binary_distributable.tcl
    branches/new-help-system/base/setupenv.bash.in
    branches/new-help-system/base/src/cregistry/registry.c
    branches/new-help-system/base/src/cregistry/sql.c
    branches/new-help-system/base/src/cregistry/util.c
    branches/new-help-system/base/src/darwintracelib1.0/darwintrace.c
    branches/new-help-system/base/src/images_to_archives.tcl
    branches/new-help-system/base/src/machista1.0/Makefile.in
    branches/new-help-system/base/src/machista1.0/libmachista.c
    branches/new-help-system/base/src/machista1.0/libmachista.h
    branches/new-help-system/base/src/machista1.0/machista.i
    branches/new-help-system/base/src/machista1.0/machista_wrap.c
    branches/new-help-system/base/src/machista1.0/tests/libmachista-test.c
    branches/new-help-system/base/src/macports1.0/macports.tcl
    branches/new-help-system/base/src/macports1.0/macports_dlist.tcl
    branches/new-help-system/base/src/package1.0/package.tcl
    branches/new-help-system/base/src/package1.0/portarchivefetch.tcl
    branches/new-help-system/base/src/package1.0/portdmg.tcl
    branches/new-help-system/base/src/package1.0/portdpkg.tcl
    branches/new-help-system/base/src/package1.0/portmdmg.tcl
    branches/new-help-system/base/src/package1.0/portmpkg.tcl
    branches/new-help-system/base/src/package1.0/portpkg.tcl
    branches/new-help-system/base/src/package1.0/portportpkg.tcl
    branches/new-help-system/base/src/package1.0/portrpm.tcl
    branches/new-help-system/base/src/package1.0/portsrpm.tcl
    branches/new-help-system/base/src/package1.0/portunarchive.tcl
    branches/new-help-system/base/src/pextlib1.0/Pextlib.c
    branches/new-help-system/base/src/pextlib1.0/base32cmd.c
    branches/new-help-system/base/src/pextlib1.0/md_wrappers.h
    branches/new-help-system/base/src/pextlib1.0/rmd160cmd.c
    branches/new-help-system/base/src/pextlib1.0/system.c
    branches/new-help-system/base/src/pextlib1.0/tests/base32.tcl
    branches/new-help-system/base/src/pextlib1.0/tracelib.c
    branches/new-help-system/base/src/port/port-help.tcl
    branches/new-help-system/base/src/port/port.tcl
    branches/new-help-system/base/src/port/portindex.tcl
    branches/new-help-system/base/src/port1.0/Makefile
    branches/new-help-system/base/src/port1.0/fetch_common.tcl
    branches/new-help-system/base/src/port1.0/port.tcl
    branches/new-help-system/base/src/port1.0/port_autoconf.tcl.in
    branches/new-help-system/base/src/port1.0/portbuild.tcl
    branches/new-help-system/base/src/port1.0/portchecksum.tcl
    branches/new-help-system/base/src/port1.0/portconfigure.tcl
    branches/new-help-system/base/src/port1.0/portdestroot.tcl
    branches/new-help-system/base/src/port1.0/portdistcheck.tcl
    branches/new-help-system/base/src/port1.0/portfetch.tcl
    branches/new-help-system/base/src/port1.0/portinstall.tcl
    branches/new-help-system/base/src/port1.0/portlint.tcl
    branches/new-help-system/base/src/port1.0/portlivecheck.tcl
    branches/new-help-system/base/src/port1.0/portmain.tcl
    branches/new-help-system/base/src/port1.0/portstartupitem.tcl
    branches/new-help-system/base/src/port1.0/portsubmit.tcl
    branches/new-help-system/base/src/port1.0/porttrace.tcl
    branches/new-help-system/base/src/port1.0/portutil.tcl
    branches/new-help-system/base/src/registry2.0/portuninstall.tcl
    branches/new-help-system/base/tests/Makefile
    branches/new-help-system/base/tests/test/checksums-1/master
    branches/new-help-system/base/tests/test/dependencies-c/master
    branches/new-help-system/base/tests/test/dependencies-d/master
    branches/new-help-system/base/tests/test/dependencies-e/master
    branches/new-help-system/base/tests/test/envvariables/master
    branches/new-help-system/base/tests/test/site-tags/master
    branches/new-help-system/base/tests/test/svn-and-patchsites/master
    branches/new-help-system/base/tests/test/trace/master
    branches/new-help-system/base/tests/test/variants/master
    branches/new-help-system/base/tests/test/xcodeversion/master

Added Paths:
-----------
    branches/new-help-system/base/doc/archive_sites.conf
    branches/new-help-system/base/portmgr/dmg/Distribution
    branches/new-help-system/base/src/port1.0/portsandbox.tcl
    branches/new-help-system/base/src/port1.0/tests/common.tcl
    branches/new-help-system/base/src/port1.0/tests/portdestroot.tcl
    branches/new-help-system/base/src/port1.0/tests/portfetch.tcl
    branches/new-help-system/base/tests/test/statefile-unknown-version/
    branches/new-help-system/base/tests/test/statefile-version1/
    branches/new-help-system/base/tests/test/statefile-version1-outdated/
    branches/new-help-system/base/tests/test/statefile-version2/
    branches/new-help-system/base/tests/test/statefile-version2-invalid/
    branches/new-help-system/base/tests/test/statefile-version2-outdated/

Property Changed:
----------------
    branches/new-help-system/base/


Property changes on: branches/new-help-system/base
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base:37343-46937
/branches/gsoc09-logging/base:51231-60371
/branches/gsoc11-rev-upgrade/base:78828-88375
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:49341-90355
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692
   + /branches/gsoc08-privileges/base:37343-46937
/branches/gsoc09-logging/base:51231-60371
/branches/gsoc11-rev-upgrade/base:78828-88375
/branches/universal-sanity/base:51872-52323
/branches/variant-descs-14482/base:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base:49341-100532
/users/perry/base-bugs_and_notes:45682-46060
/users/perry/base-select:44044-44692

Modified: branches/new-help-system/base/ChangeLog
===================================================================
--- branches/new-help-system/base/ChangeLog	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/ChangeLog	2012-12-15 00:33:09 UTC (rev 100533)
@@ -3,31 +3,185 @@
 # $Id$
 ###
 
-Unreleased changes:
+Release 2.2.0 (unreleased)
+    - Added 'subport:' pseudo-portname that expands to ports that provide
+      a matching subport; added 'subportof:' pseudo-portname that expands to
+      the list of subports of the given port name
+      (raimue in r100059)
 
+    - Fixes bringing trace mode back to a working state. Improvements to reduce
+      the number of builds trace mode breaks.
+      (cal in r100071-100073, r100077, r100126, r100221)
+
+Release 2.1.3 (unreleased)
+    - Fixed a bug where a certain order of starting and aborting a build,
+      running selfupdate and continuing a build would resume building although
+      it should start from the beginning.
+      (#29223, cal in r96136, r96399, r96400, r96538)
+
+    - Fix permission problem in the creation of the ccache directory with
+      ccache >= 3.1.7 by running the initialization step as the macportsuser.
+      (raimue in r97868)
+
+    - Fix an endless loop that could be triggered in rev-upgrade when a user
+      hasn't run selfupdate in more than a year or the portindex is corrupt.
+      (cal in r100129)
+
+    - Set a busy timeout on SQLite connections to prevent MacPorts from
+      uselessly burning CPU cycles when waiting for a database lock.
+      (cal in r100217)
+
+    - Switch from exclusive locking to immediate locking in the registry
+      database to avoid locking reads where not needed.
+      (cal in r100218)
+
+    - Fix a problem where interrupting the uninstallation process could leave
+      the registry database in a corrupted state.
+      (cal in r100219)
+
+Release 2.1.2 (2012-07-26 by jmr):
+    - Fixed autodetection of developer_dir with Xcode 4.4
+      (#35150, mfeiri in r95552)
+
+    - Made conversion of images to archives more robust against missing images
+      (jmr in r95480)
+
+    - Support spaces in hg.tag when fetching from mercurial (#22684 comment
+      11,12, cal in r95438)
+
+    - Made mpkg fail when building a component pkg fails, instead of trying to
+      continue (jmr in r95382)
+
+    - Added a log message when everything to be installed has an unsatisfied
+      dependency, such as in the case of circular dependencies (jmr in r93962)
+
+    - Fixed incorrect error message when installing a port that has a
+      dependency that is not in the index (#31130, jmr in r93511)
+
+Release 2.1.1 (2012-05-19 by jmr):
+    - Fixed incorrect parsing of mirror group URLs that contain a colon to
+      indicate a port number (#32018, jmr in r93258)
+
+    - Do not print detailed progress information in rev-upgrade when stdout is
+      not a terminal (#34480, cal in r93221,r93222)
+
+    - Made rev-upgrade avoid trying to upgrade ports that are not in the index
+      (jmr in r93197)
+
+    - Fixed rev-upgrade disabling source-only mode in its first upgrade pass
+      (jmr in r93153)
+
+    - Fixed incorrect rebuild order in rev-upgrade (cal in r93129)
+
+    - Fixed port lookups failing for all sources when the index is missing in
+      one source (#30593, jmr in r92976)
+
+    - Fix database upgrade on Tiger, where SQLite doesn't support ALTER TABLE
+      ADD COLUMN (#34463, cal in r93256)
+
+Release 2.1.0 (2012-05-15 by jmr):
+    - New configure.compiler options: macports-clang-2.9, macports-clang-3.0,
+      macports-clang-3.1, macports-gcc-4.7, macports-gcc-4.8
+      (jeremyhu in r86719, ryandesign in r91521)
+
+    - Avoid using pkg-config to find sqlite3 in our configure script unless it
+      can't be found by other means, because some third-party packages
+      incorrectly install a /usr/bin/pkg-config that points to an incompatible
+      copy of sqlite3. (#30932, dluke/jmr in r91512)
+
+    - 'port pkg' and 'port mpkg' will now create flat packages (i.e. a xar
+      archive rather than a directory) on 10.6+.
+      (jmr in r91317, r91329, r91331, r91437)
+
+    - Fixed dependencies sometimes being installed multiple times when
+      required with different archs. (#31794, jmr in r91357)
+
+    - Build-time dependencies will no longer be installed if a prebuilt
+      archive is available for download (and port is configured to use it).
+      (jmr in r91196, r91217)
+
+    - Added new config file archive_sites.conf, which can be used to configure
+      additional archive download sources. Each source has an associated
+      archive type; portarchivetype is now only used when creating archives
+      locally. Sources also have an associated prefix, applications_dir and
+      frameworks_dir, and if any of these do not match the current values, the
+      source is not used. (jmr in r91009)
+
+    - Xcode 4.3 support: Search harder for developer directory; advise user to
+      run xcode-select when necessary, searching for Xcode and suggesting
+      xcode-select commands.
+      (jberry, jmr in r89970,r89971,r89972,r89996,r89999,r90003,r90005-r90009,
+      r90018-r90019,r90024,r90031)
+
+    - warn about non-existing developer_dir when it's set in macports.conf
+      (cal in 90802)
+
+    - port automatically installs bsdmake when there's no bsdmake in $PATH and a
+      port sets build.type bsd (#33355, cal in r90650)
+
+    - Added -W option for reinplace that sets a base directory that all file
+      arguments are interpreted as being relative to. (raimue in r90610)
+
+    - Added macports.conf options 'host_blacklist' and 'preferred_hosts', used
+      for indicating lists of download hosts that should not be used or should
+      be used preferentially, respectively. These override the usual ping time
+      check. Ping times are also now cached for 24 hours. (jmr in r89459)
+
+    - Added 'rev-upgrade' action checking for broken linkage and rebuilding
+      ports containing broken files. Made rev-upgrade run automatically after
+      each upgrade or install.
+      (cal in branch gsoc11-rev-upgrade, merge in r88376, also cal, raimue, jmr
+      in r88377,r88411,r88441,r88511,r88666,r88732,r89180,r89659,r89661,r90102,
+      r90381)
+
+    - Added options controlling rev-upgrade behavior to macports.conf
+      (jmr, cal in r88725,r88794,r89189)
+
     - port livecheck regex finds multiple matches on the same line
       (raimue in r88031)
 
     - Several improvements to port lint:
       licenses, subversion properties, maintainer addresses
-      (snc, raimue in r85929, r86016, r89428, r89610)
+      (#30194, snc, raimue in r85929, r86016, r89428, r89610)
 
+    - Added license_noconflict option to specify dependencies for which the
+      maintainer has manually checked license compatibility and wishes to
+      overrule the conservative automated checks. (jmr in r89004)
+
+    - Xcode 4.3 support: Use xcrun -find to find xcode compiler if it's not
+      found in /usr/bin.
+      (jberry, jmr in r88540,r88541,r88546,r88777,r88779,r88787,r89359,r89984,r90028)
+
+    - Added options compiler.blacklist, compiler.whitelist, and
+      compiler.fallback; to allow blacklisting, whitelisting, and setting the
+      fallback order for configure.compiler values, respectively.
+      (#30041, jmr in r88676)
+
+    - Fix sync with subdirectory of Subversion 1.7-format working copy
+      (#33573, jmr in 86872)
+
+    - Fixed conflicts not being checked for when installing ports that have no
+      dependencies. (#31571, dports in r85382)
+
+    - dmg postflight: quote all paths to handle the increasingly frequent
+      occurrence that $HOME contains spaces (#33583, ryandesign in r84345)
+
+    - dmg postflight: adjust wording of some messages (ryandesign in r84344)
+
+    - The deprecated Portfile options svn.tag, distcheck.check and
+      livecheck.check have been removed. (raimue in r82763)
+
     - Implement new option-replace using lsearch/lreplace. The old behavior is
       deprecated for option-replace with only one argument, but can still be
       found in option-strsed.
       (raimue in r82760, r82761)
 
-    - Xcode 4.3 support: Use xcrun -find to find xcode compiler if it's not
-      found in /usr/bin.
-      (jberry, jmr in r88540,r88541,r88546,r88777,r88779,r88787,r89359,r89984,r90028)
+    - Added 'buildfromsource' macports.conf setting, which allows permanently
+      selecting the behaviour of the -s or -b option. (jmr in r81540)
 
-    - Xcode 4.3 support: Search harder for developer directory; advise user to
-      run xcode-select when necessary, searching for Xcode and suggesting
-      xcode-select commands.
-      (jberry, jmr in r89970,r89971,r89972,r89996,r89999,r90003,r90005-r90009,
-      r90018-r90019,r90024,r90031)
+Release 2.0.4 (2012-02-25 by jmr)
+    - Added -locale option for reinplace (jeremyhu in r89839)
 
-Release 2.0.4 (2012-02-25 by jmr)
     - Xcode 4.3 support: Change home directory for MacPorts user to
       ${prefix}/var/macports/home.
       (jberry, jmr in r89988, r89993, r90002, r90010, r90011)
@@ -35,6 +189,9 @@
     - set env(HOME) to ${workpath}/.home when building ports
       (#31827, jmr in r89994, r90004)
 
+    - Fix use_xmkmf to honor xmkmf.env for its make Makefiles phase
+      (#31504, jeremyhu in r89537, r89538, r89539)
+
     - Added configure.cxx setting when configure.compiler is apple-gcc-4.2
       (jeremyhu in r80248)
 
@@ -220,8 +377,8 @@
     - Computing large dependency trees that contain the same port(s) multiple
       times should be considerably faster. (jmr in r73133)
 
-    - configure.compiler can now be set to macports-llvm-gcc-4.2 or
-      macports-clang (mfeiri in r72936, r72937)
+    - New configure.compiler options: macports-gcc-4.6, macports-llvm-gcc-4.2,
+      macports-clang (jmr in r71487; mfeiri in r72936, r72937)
 
     - Add '-n' option to reinplace (#26406, ryandesign in r73227)
 

Modified: branches/new-help-system/base/LICENSE
===================================================================
--- branches/new-help-system/base/LICENSE	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/LICENSE	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,5 +1,5 @@
 Copyright (c) 2002 - 2003, Apple Inc.
-Copyright (c) 2004 - 2011, The MacPorts Project.
+Copyright (c) 2004 - 2012, The MacPorts Project.
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without

Modified: branches/new-help-system/base/Makefile.in
===================================================================
--- branches/new-help-system/base/Makefile.in	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/Makefile.in	2012-12-15 00:33:09 UTC (rev 100533)
@@ -32,9 +32,10 @@
 include Mk/macports.subdir.mk
 
 install::
-	[ ! -f $(DESTDIR)${sysconfdir}/macports/mp_version ] || rm -vf $(DESTDIR)${sysconfdir}/macports/mp_version
-	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 setupenv.bash  $(DESTDIR)${datadir}/macports/
-	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 macports-pubkey.pem  $(DESTDIR)${datadir}/macports/
+	[ ! -f "$(DESTDIR)${sysconfdir}/macports/mp_version" ] || rm -vf "$(DESTDIR)${sysconfdir}/macports/mp_version"
+	$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} "$(DESTDIR)${datadir}/macports/"
+	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 setupenv.bash  "$(DESTDIR)${datadir}/macports/"
+	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 macports-pubkey.pem  "$(DESTDIR)${datadir}/macports/"
 # Only run these scripts when not building in a destroot
 ifeq ($(DESTDIR),)
 # create run user if it doesn't exist
@@ -64,7 +65,7 @@
                 ${DSCL} -q . -create /Users/${RUNUSR} RealName MacPorts ; \
                 ${DSCL} -q . -create /Users/${RUNUSR} Password \* ; \
                 ${DSCL} -q . -create /Users/${RUNUSR} PrimaryGroupID $$(${DSCL} -q . -read /Groups/${RUNUSR} PrimaryGroupID | /usr/bin/awk '{print $$2}') ; \
-                ${DSCL} -q . -create /Users/${RUNUSR} NFSHomeDirectory ${localstatedir}/macports/home ; \
+                ${DSCL} -q . -create /Users/${RUNUSR} NFSHomeDirectory "${localstatedir}/macports/home" ; \
                 ${DSCL} -q . -create /Users/${RUNUSR} UserShell /usr/bin/false ; \
             else \
                 echo "Not creating user \"${RUNUSR}\" (not root)" ; \
@@ -73,7 +74,7 @@
         if test "$$(${DSCL} -q . -read /Users/${RUNUSR} NFSHomeDirectory)" = "NFSHomeDirectory: /var/empty" ; then \
             if test `id -u` -eq 0; then \
                 echo "Updating home directory location for user \"${RUNUSR}\"" ; \
-                ${DSCL} -q . -create /Users/${RUNUSR} NFSHomeDirectory ${localstatedir}/macports/home ; \
+                ${DSCL} -q . -create /Users/${RUNUSR} NFSHomeDirectory "${localstatedir}/macports/home" ; \
             else \
                 echo "Not updating home directory location for user \"${RUNUSR}\" (not root)" ; \
             fi ; \

Modified: branches/new-help-system/base/NEWS
===================================================================
--- branches/new-help-system/base/NEWS	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/NEWS	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,3 +1,41 @@
+== Overview of changes from MacPorts 2.0.4 to 2.1.0 ==
+
+# For regular users:
+
+*) New 'rev-upgrade' action that checks for and rebuilds ports that may have
+   become incorrectly linked when a dependency was upgraded to a new,
+   binary-incompatible version. This runs automatically after upgrades and
+   installs by default, and can be turned off or configured to only report
+   problems in macports.conf.
+
+*) The pkg and mpkg targets will create flat packages on 10.6+.
+
+*) Build-time dependencies will no longer be installed if a prebuilt
+   archive is available for download (and port is configured to use it).
+
+*) Config file archive_sites.conf can be used to download archives from
+   custom locations.
+
+*) 'buildfromsource' macports.conf option allows permanently choosing
+   source-only or binary-only mode.
+
+*) New macports.conf options 'host_blacklist' and 'preferred_hosts', for
+   controlling which download hosts will be used.
+
+# For Portfile writers:
+
+*) New -W option for reinplace that sets a base directory for all file
+   arguments.
+
+*) Livecheck can now find multiple regex matches on each line.
+
+*) license_noconflict option can be used to override automatic license
+   compatibility checks.
+
+*) compiler.whitelist, compiler.blacklist, and compiler.fallback options allow
+   simpler, detailed control over which compilers are used to build ports.
+
+
 == Overview of changes from MacPorts 1.9.2 to 2.0.0 ==
 
 # For regular users:
@@ -166,7 +204,7 @@
     builds (defaulting to no);
 *) Improved building of configure-based universal ports on Leopard;
 *) Fixed a bug by which the 'universal' variant would disappear if a 'macosx' variant was selected;
-*) Added a 'macosx_deployment_target' option to the main 'macports.conf' file for ports that benefit form this Mac OS X specific flag;
+*) Added a 'macosx_deployment_target' option to the main 'macports.conf' file for ports that benefit from this Mac OS X specific flag;
 *) Added a 'configurepipe' option to the main 'macports.conf' file for using pipes rather than intermediate files when compiling C/C++
     based ports;
 *) Removed LD_PREBIND & LD_PREBIND_ALLOW_OVERLAP variables from MacPorts' environment to prevent prebinding of binaries, which can be harmful

Modified: branches/new-help-system/base/aclocal.m4
===================================================================
--- branches/new-help-system/base/aclocal.m4	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/aclocal.m4	2012-12-15 00:33:09 UTC (rev 100533)
@@ -295,7 +295,7 @@
 	AC_MSG_CHECKING([that any existing MacPorts install can be upgraded])
 
 	eval dpversionfile="${sysconfdir}/ports/dp_version"
-	if test -f $dpversionfile; then
+	if test -f "$dpversionfile"; then
 		AC_MSG_ERROR([Existing MacPorts or DarwinPorts install is too old to be upgraded. Install MacPorts 1.7.1 first.])
 	else
 		AC_MSG_RESULT([yes])
@@ -810,21 +810,23 @@
 		   [  sqlite3prefix=$withval ])
 
 	if test "x$sqlite3prefix" = "x"; then
-		AC_PATH_PROG([PKG_CONFIG], [pkg-config])
-		if test "x$PKG_CONFIG" = "x" || ! $PKG_CONFIG --exists sqlite3; then
-		    # assume it's somewhere like /usr that needs no extra flags
-		    AC_CHECK_HEADER(sqlite3.h, [], [AC_MSG_ERROR([cannot find sqlite3 header])])
-            CFLAGS_SQLITE3=""
-		    LDFLAGS_SQLITE3="-lsqlite3"
-        else
-            CFLAGS_SQLITE3=$($PKG_CONFIG --cflags sqlite3)
-            LDFLAGS_SQLITE3=$($PKG_CONFIG --libs sqlite3)
-            # for tclsqlite below
-            mp_sqlite3_dir=$($PKG_CONFIG --variable=prefix sqlite3)
-            if test "x$mp_sqlite3_dir" != "x"; then
-                mp_sqlite3_dir=${mp_sqlite3_dir}/lib/sqlite3
-            fi
-        fi
+		# see if it's somewhere like /usr that needs no extra flags
+		LDFLAGS_SQLITE3="-lsqlite3"
+		AC_CHECK_HEADER(sqlite3.h, [],[
+		    # nope - try pkg-config
+			AC_PATH_PROG([PKG_CONFIG], [pkg-config])
+			if test "x$PKG_CONFIG" = "x" || ! $PKG_CONFIG --exists sqlite3; then
+				AC_MSG_ERROR([cannot find sqlite3 header])
+			else
+				CFLAGS_SQLITE3=$($PKG_CONFIG --cflags sqlite3)
+				LDFLAGS_SQLITE3=$($PKG_CONFIG --libs sqlite3)
+				# for tclsqlite below
+				mp_sqlite3_dir=$($PKG_CONFIG --variable=prefix sqlite3)
+            			if test "x$mp_sqlite3_dir" != "x"; then
+                			mp_sqlite3_dir=${mp_sqlite3_dir}/lib/sqlite3
+            			fi
+			fi
+		])
 	else
 	    CFLAGS_SQLITE3="-I${sqlite3prefix}/include"
 		LDFLAGS_SQLITE3="-L${sqlite3prefix}/lib -lsqlite3"

Modified: branches/new-help-system/base/config/RELEASE_URL
===================================================================
--- branches/new-help-system/base/config/RELEASE_URL	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/config/RELEASE_URL	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1 +1 @@
-https://svn.macports.org/repository/macports/tags/release_2_0_4/base
+https://svn.macports.org/repository/macports/tags/release_2_1_2/base

Modified: branches/new-help-system/base/config/macports_version
===================================================================
--- branches/new-help-system/base/config/macports_version	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/config/macports_version	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1 +1 @@
-2.0.99
+2.1.99

Modified: branches/new-help-system/base/configure
===================================================================
--- branches/new-help-system/base/configure	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/configure	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,13 +1,11 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for MacPorts 2.0.99.
+# Generated by GNU Autoconf 2.69 for MacPorts 2.1.99.
 #
 # Report bugs to <macports-dev at lists.macosforge.org>.
 #
 #
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-# Foundation, Inc.
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
 #
 #
 # This configure script is free software; the Free Software Foundation
@@ -136,6 +134,31 @@
 # CDPATH.
 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
 
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
 if test "x$CONFIG_SHELL" = x; then
   as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
   emulate sh
@@ -169,7 +192,8 @@
 else
   exitcode=1; echo positional parameters were not saved.
 fi
-test x\$exitcode = x0 || exit 1"
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
   as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
   as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
   eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
@@ -214,21 +238,25 @@
 
 
       if test "x$CONFIG_SHELL" != x; then :
-  # We cannot yet assume a decent shell, so we have to provide a
-	# neutralization value for shells without unset; and this also
-	# works around shells that cannot unset nonexistent variables.
-	# Preserve -v and -x to the replacement shell.
-	BASH_ENV=/dev/null
-	ENV=/dev/null
-	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-	export CONFIG_SHELL
-	case $- in # ((((
-	  *v*x* | *x*v* ) as_opts=-vx ;;
-	  *v* ) as_opts=-v ;;
-	  *x* ) as_opts=-x ;;
-	  * ) as_opts= ;;
-	esac
-	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
 fi
 
     if test x$as_have_required = xno; then :
@@ -331,6 +359,14 @@
 
 
 } # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
 # as_fn_append VAR VALUE
 # ----------------------
 # Append the text in VALUE to the end of the definition contained in VAR. Take
@@ -452,6 +488,10 @@
   chmod +x "$as_me.lineno" ||
     { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
 
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
   # Don't try to exec as it changes $[0], causing all sort of problems
   # (the dirname of $[0] is not the place where we might find the
   # original and so on.  Autoconf is especially sensitive to this).
@@ -486,16 +526,16 @@
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -507,28 +547,8 @@
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
 
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
@@ -560,8 +580,8 @@
 # Identity of this package.
 PACKAGE_NAME='MacPorts'
 PACKAGE_TARNAME='macports'
-PACKAGE_VERSION='2.0.99'
-PACKAGE_STRING='MacPorts 2.0.99'
+PACKAGE_VERSION='2.1.99'
+PACKAGE_STRING='MacPorts 2.1.99'
 PACKAGE_BUGREPORT='macports-dev at lists.macosforge.org'
 PACKAGE_URL=''
 
@@ -690,6 +710,7 @@
 SWIG
 SVN
 SED
+SANDBOX_EXEC
 RSYNC
 RMDIR
 PAX
@@ -1306,8 +1327,6 @@
 if test "x$host_alias" != x; then
   if test "x$build_alias" = x; then
     cross_compiling=maybe
-    $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host.
-    If a cross compiler is detected then cross compile mode will be used" >&2
   elif test "x$build_alias" != "x$host_alias"; then
     cross_compiling=yes
   fi
@@ -1393,7 +1412,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures MacPorts 2.0.99 to adapt to many kinds of systems.
+\`configure' configures MacPorts 2.1.99 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1459,7 +1478,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of MacPorts 2.0.99:";;
+     short | recursive ) echo "Configuration of MacPorts 2.1.99:";;
    esac
   cat <<\_ACEOF
 
@@ -1605,10 +1624,10 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-MacPorts configure 2.0.99
-generated by GNU Autoconf 2.68
+MacPorts configure 2.1.99
+generated by GNU Autoconf 2.69
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it.
 _ACEOF
@@ -1722,7 +1741,7 @@
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
+	 test -x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -1969,7 +1988,7 @@
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
+	 test -x conftest$ac_exeext
        }; then :
   ac_retval=0
 else
@@ -2274,8 +2293,8 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by MacPorts $as_me 2.0.99, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+It was created by MacPorts $as_me 2.1.99, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
 
@@ -2769,7 +2788,7 @@
 # Read in the MacPorts version from the base/config/macports_version file
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking MacPorts version" >&5
 $as_echo_n "checking MacPorts version... " >&6; }
-MACPORTS_VERSION=2.0.99
+MACPORTS_VERSION=2.1.99
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MACPORTS_VERSION" >&5
 $as_echo "$MACPORTS_VERSION" >&6; }
 
@@ -2819,7 +2838,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_SW_VERS="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2859,7 +2878,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_DEFAULTS="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2899,7 +2918,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_XCODE_SELECT="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -2935,7 +2954,7 @@
     as_fn_error $? "This version of Mac OS X is not supported
                   Please upgrade at http://store.apple.com/" "$LINENO" 5
     ;;
-  10.4.[0-9]|10.4.10|10.5.[0-7]|10.6.[0-7])
+  10.4.[0-9]|10.4.10|10.5.[0-7]|10.6.[0-7]|10.7.[0-2])
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: This version of Mac OS X is out of date" >&5
 $as_echo "$as_me: WARNING: This version of Mac OS X is out of date" >&2;}
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Please run Software Update to update it" >&5
@@ -2948,23 +2967,36 @@
 esac
 
 # locate currently selected Xcode path
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Xcode location" >&5
+$as_echo_n "checking Xcode location... " >&6; }
 if test "x$XCODE_SELECT" != "x"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking Xcode location" >&5
-$as_echo_n "checking Xcode location... " >&6; }
   DEVELOPER_DIR=`$XCODE_SELECT -print-path`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEVELOPER_DIR" >&5
+fi
+if test -z "$DEVELOPER_DIR" -o ! -d "$DEVELOPER_DIR" ; then
+    if test -d /Applications/Xcode.app/Contents/Developer ; then
+        DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
+    else
+        DEVELOPER_DIR=/Developer
+    fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEVELOPER_DIR" >&5
 $as_echo "$DEVELOPER_DIR" >&6; }
-else
-  DEVELOPER_DIR=/Developer
-fi
 
 
-XCODEPLIST=$DEVELOPER_DIR/Applications/Xcode.app/Contents/version.plist
+case "$DEVELOPER_DIR" in
+  *Xcode.app/Contents/Developer)
+    XCODEPLIST_BASE=`dirname $DEVELOPER_DIR`/version
+    ;;
+  *)
+    XCODEPLIST_BASE=$DEVELOPER_DIR/Applications/Xcode.app/Contents/version
+    ;;
+esac
+XCODEPLIST=${XCODEPLIST_BASE}.plist
 if test -r "$XCODEPLIST"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking Xcode version" >&5
 $as_echo_n "checking Xcode version... " >&6; }
   if test "x$DEFAULTS" != "x"; then
-    XCODE_VERSION=`$DEFAULTS read $DEVELOPER_DIR/Applications/Xcode.app/Contents/version CFBundleShortVersionString`
+    XCODE_VERSION=`$DEFAULTS read $XCODEPLIST_BASE CFBundleShortVersionString`
   else
     XCODE_VERSION=`tr -d '\r\n' < $XCODEPLIST | sed -e 's/.*<key>CFBundleShortVersionString<\/key>.<string>\([0-9.]*\)<\/string>.*/\1/'`
   fi
@@ -3014,7 +3046,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3054,7 +3086,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="gcc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3107,7 +3139,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="${ac_tool_prefix}cc"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3148,7 +3180,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
        ac_prog_rejected=yes
        continue
@@ -3206,7 +3238,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3250,7 +3282,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_CC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3696,8 +3728,7 @@
 /* end confdefs.h.  */
 #include <stdarg.h>
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
+struct stat;
 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
 struct buf { int x; };
 FILE * (*rcsopen) (struct buf *, struct stat *, int);
@@ -3819,7 +3850,7 @@
     # by default.
     for ac_prog in ginstall scoinst install; do
       for ac_exec_ext in '' $ac_executable_extensions; do
-	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+	if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
 	  if test $ac_prog = install &&
 	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
 	    # AIX install.  It has an incompatible calling convention.
@@ -3941,7 +3972,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_OBJC="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -3985,7 +4016,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_ac_ct_OBJC="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4189,7 +4220,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_BSDMAKE="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4232,7 +4263,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_BZIP2="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4272,7 +4303,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_BZR="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4313,7 +4344,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_CHOWN="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4353,7 +4384,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_CP="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4393,7 +4424,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_CPIO="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4433,7 +4464,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_CVS="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4473,7 +4504,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_DIFF="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4513,7 +4544,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_DSCL="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4553,7 +4584,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_DSEDITGROUP="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4593,7 +4624,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_FILE="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4633,7 +4664,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_GIT="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4676,7 +4707,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_GNUMAKE="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4722,7 +4753,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_GNUPATCH="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4768,7 +4799,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_GNUTAR="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4811,7 +4842,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_GZIP="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4851,7 +4882,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_HDIUTIL="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4891,7 +4922,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_HG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4931,7 +4962,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_LAUNCHCTL="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -4971,7 +5002,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_LIPO="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5011,7 +5042,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_LSBOM="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5051,7 +5082,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_LZMA="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5091,7 +5122,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_MAKE="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5131,7 +5162,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_MDFIND="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5171,7 +5202,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_MDLS="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5211,7 +5242,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_MKBOM="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5252,7 +5283,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_MTREE="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5292,7 +5323,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_OPEN="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5332,7 +5363,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_OPENSSL="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5372,7 +5403,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_PATCH="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5412,7 +5443,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_PAX="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5452,7 +5483,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_RMDIR="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5492,7 +5523,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_RSYNC="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5514,6 +5545,46 @@
 fi
 
 
+# Extract the first word of "sandbox-exec", so it can be a program name with args.
+set dummy sandbox-exec; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_SANDBOX_EXEC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $SANDBOX_EXEC in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_SANDBOX_EXEC="$SANDBOX_EXEC" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /usr/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_SANDBOX_EXEC="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+SANDBOX_EXEC=$ac_cv_path_SANDBOX_EXEC
+if test -n "$SANDBOX_EXEC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SANDBOX_EXEC" >&5
+$as_echo "$SANDBOX_EXEC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
 # Extract the first word of "sed", so it can be a program name with args.
 set dummy sed; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -5532,7 +5603,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_SED="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5572,7 +5643,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_SVN="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5613,7 +5684,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_SWIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5653,7 +5724,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_TAR="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5693,7 +5764,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_UNZIP="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5733,7 +5804,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_XAR="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5773,7 +5844,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_XCODEBUILD="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5813,7 +5884,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_XCRUN="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5853,7 +5924,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_XZ="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5893,7 +5964,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_ZIP="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5932,7 +6003,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_HAVE_LAUNCHD="yes"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -5973,7 +6044,11 @@
 
 
 
+if test "x$MTREE" = "x"; then
+    as_fn_error $? "mtree not found" "$LINENO" 5
+fi
 
+
 	# Extract the first word of "sed", so it can be a program name with args.
 set dummy sed; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
@@ -5992,7 +6067,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_SED="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6062,7 +6137,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_TAR="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6117,7 +6192,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_TAR="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6157,7 +6232,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_GNUTAR="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6222,7 +6297,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_PATCH="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6262,7 +6337,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_GNUPATCH="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6540,7 +6615,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_prog_acx_pthread_config="yes"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -6849,7 +6924,7 @@
     for ac_prog in grep ggrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+      as_fn_executable_p "$ac_path_GREP" || continue
 # Check for GNU ac_path_GREP and select it if it is found.
   # Check for GNU $ac_path_GREP
 case `"$ac_path_GREP" --version 2>&1` in
@@ -6915,7 +6990,7 @@
     for ac_prog in egrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
       ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+      as_fn_executable_p "$ac_path_EGREP" || continue
 # Check for GNU ac_path_EGREP and select it if it is found.
   # Check for GNU $ac_path_EGREP
 case `"$ac_path_EGREP" --version 2>&1` in
@@ -9348,7 +9423,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_TCLSH="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -9391,7 +9466,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_TCLSH="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -9545,7 +9620,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_CURL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -9586,7 +9661,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_CURL_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -9640,7 +9715,15 @@
 
 
 	if test "x$sqlite3prefix" = "x"; then
-		# Extract the first word of "pkg-config", so it can be a program name with args.
+		# see if it's somewhere like /usr that needs no extra flags
+		LDFLAGS_SQLITE3="-lsqlite3"
+		ac_fn_c_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default"
+if test "x$ac_cv_header_sqlite3_h" = xyes; then :
+
+else
+
+		    # nope - try pkg-config
+			# Extract the first word of "pkg-config", so it can be a program name with args.
 set dummy pkg-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
@@ -9658,7 +9741,7 @@
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
     ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
@@ -9680,27 +9763,21 @@
 fi
 
 
-		if test "x$PKG_CONFIG" = "x" || ! $PKG_CONFIG --exists sqlite3; then
-		    # assume it's somewhere like /usr that needs no extra flags
-		    ac_fn_c_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default"
-if test "x$ac_cv_header_sqlite3_h" = xyes; then :
+			if test "x$PKG_CONFIG" = "x" || ! $PKG_CONFIG --exists sqlite3; then
+				as_fn_error $? "cannot find sqlite3 header" "$LINENO" 5
+			else
+				CFLAGS_SQLITE3=$($PKG_CONFIG --cflags sqlite3)
+				LDFLAGS_SQLITE3=$($PKG_CONFIG --libs sqlite3)
+				# for tclsqlite below
+				mp_sqlite3_dir=$($PKG_CONFIG --variable=prefix sqlite3)
+            			if test "x$mp_sqlite3_dir" != "x"; then
+                			mp_sqlite3_dir=${mp_sqlite3_dir}/lib/sqlite3
+            			fi
+			fi
 
-else
-  as_fn_error $? "cannot find sqlite3 header" "$LINENO" 5
 fi
 
 
-            CFLAGS_SQLITE3=""
-		    LDFLAGS_SQLITE3="-lsqlite3"
-        else
-            CFLAGS_SQLITE3=$($PKG_CONFIG --cflags sqlite3)
-            LDFLAGS_SQLITE3=$($PKG_CONFIG --libs sqlite3)
-            # for tclsqlite below
-            mp_sqlite3_dir=$($PKG_CONFIG --variable=prefix sqlite3)
-            if test "x$mp_sqlite3_dir" != "x"; then
-                mp_sqlite3_dir=${mp_sqlite3_dir}/lib/sqlite3
-            fi
-        fi
 	else
 	    CFLAGS_SQLITE3="-I${sqlite3prefix}/include"
 		LDFLAGS_SQLITE3="-L${sqlite3prefix}/lib -lsqlite3"
@@ -9963,7 +10040,7 @@
 $as_echo_n "checking that any existing MacPorts install can be upgraded... " >&6; }
 
 	eval dpversionfile="${sysconfdir}/ports/dp_version"
-	if test -f $dpversionfile; then
+	if test -f "$dpversionfile"; then
 		as_fn_error $? "Existing MacPorts or DarwinPorts install is too old to be upgraded. Install MacPorts 1.7.1 first." "$LINENO" 5
 	else
 		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
@@ -10402,16 +10479,16 @@
     # ... but there are two gotchas:
     # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
     # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -p'.
+    # In both cases, we have to default to `cp -pR'.
     ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -p'
+      as_ln_s='cp -pR'
   elif ln conf$$.file conf$$ 2>/dev/null; then
     as_ln_s=ln
   else
-    as_ln_s='cp -p'
+    as_ln_s='cp -pR'
   fi
 else
-  as_ln_s='cp -p'
+  as_ln_s='cp -pR'
 fi
 rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
 rmdir conf$$.dir 2>/dev/null
@@ -10471,29 +10548,17 @@
   as_mkdir_p=false
 fi
 
-if test -x / >/dev/null 2>&1; then
-  as_test_x='test -x'
-else
-  if ls -dL / >/dev/null 2>&1; then
-    as_ls_L_option=L
-  else
-    as_ls_L_option=
-  fi
-  as_test_x='
-    eval sh -c '\''
-      if test -d "$1"; then
-	test -d "$1/.";
-      else
-	case $1 in #(
-	-*)set "./$1";;
-	esac;
-	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
-	???[sx]*):;;*)false;;esac;fi
-    '\'' sh
-  '
-fi
-as_executable_p=$as_test_x
 
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
 # Sed expression to map a string onto a valid CPP name.
 as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
 
@@ -10513,8 +10578,8 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by MacPorts $as_me 2.0.99, which was
-generated by GNU Autoconf 2.68.  Invocation command line was
+This file was extended by MacPorts $as_me 2.1.99, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -10575,11 +10640,11 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-MacPorts config.status 2.0.99
-configured by $0, generated by GNU Autoconf 2.68,
+MacPorts config.status 2.1.99
+configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
-Copyright (C) 2010 Free Software Foundation, Inc.
+Copyright (C) 2012 Free Software Foundation, Inc.
 This config.status script is free software; the Free Software Foundation
 gives unlimited permission to copy, distribute and modify it."
 
@@ -10668,7 +10733,7 @@
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 if \$ac_cs_recheck; then
-  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
   shift
   \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
   CONFIG_SHELL='$SHELL'

Modified: branches/new-help-system/base/configure.ac
===================================================================
--- branches/new-help-system/base/configure.ac	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/configure.ac	2012-12-15 00:33:09 UTC (rev 100533)
@@ -32,7 +32,7 @@
     AC_MSG_ERROR([This version of Mac OS X is not supported
                   Please upgrade at http://store.apple.com/])
     ;;
-  10.4.[[0-9]]|10.4.10|10.5.[[0-7]]|10.6.[[0-7]])
+  10.4.[[0-9]]|10.4.10|10.5.[[0-7]]|10.6.[[0-7]]|10.7.[[0-2]])
     AC_MSG_WARN([This version of Mac OS X is out of date])
     AC_MSG_WARN([Please run Software Update to update it])
     ;;
@@ -44,20 +44,33 @@
 esac
 
 # locate currently selected Xcode path
+AC_MSG_CHECKING(Xcode location)
 if test "x$XCODE_SELECT" != "x"; then
-  AC_MSG_CHECKING(Xcode location)
   DEVELOPER_DIR=`$XCODE_SELECT -print-path`
-  AC_MSG_RESULT([$DEVELOPER_DIR])
-else
-  DEVELOPER_DIR=/Developer
 fi
+if test -z "$DEVELOPER_DIR" -o ! -d "$DEVELOPER_DIR" ; then
+    if test -d /Applications/Xcode.app/Contents/Developer ; then
+        DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
+    else
+        DEVELOPER_DIR=/Developer
+    fi
+fi
+AC_MSG_RESULT([$DEVELOPER_DIR])
 AC_SUBST(DEVELOPER_DIR)
 
-XCODEPLIST=$DEVELOPER_DIR/Applications/Xcode.app/Contents/version.plist
+case "$DEVELOPER_DIR" in
+  *Xcode.app/Contents/Developer)
+    XCODEPLIST_BASE=`dirname $DEVELOPER_DIR`/version
+    ;;
+  *)
+    XCODEPLIST_BASE=$DEVELOPER_DIR/Applications/Xcode.app/Contents/version
+    ;;
+esac
+XCODEPLIST=${XCODEPLIST_BASE}.plist
 if test -r "$XCODEPLIST"; then
   AC_MSG_CHECKING(Xcode version)
   if test "x$DEFAULTS" != "x"; then
-    XCODE_VERSION=`$DEFAULTS read $DEVELOPER_DIR/Applications/Xcode.app/Contents/version CFBundleShortVersionString`
+    XCODE_VERSION=`$DEFAULTS read $XCODEPLIST_BASE CFBundleShortVersionString`
   else
     XCODE_VERSION=`tr -d '\r\n' < $XCODEPLIST | sed -e 's/.*<key>CFBundleShortVersionString<\/key>.<string>\([[0-9.]]*\)<\/string>.*/\1/'`
   fi
@@ -120,6 +133,7 @@
 AC_PATH_PROG(PAX, [pax], [])
 AC_PATH_PROG(RMDIR, [rmdir], [])
 AC_PATH_PROG(RSYNC, [rsync], [])
+AC_PATH_PROG(SANDBOX_EXEC, [sandbox-exec], [], [/usr/bin])
 AC_PATH_PROG(SED, [sed])
 AC_PATH_PROG(SVN, [svn], [])
 AC_PATH_PROG(SWIG, [swig], [], [$PATH:/usr/local/bin])
@@ -152,6 +166,10 @@
 AC_ARG_VAR(XAR, [path to xar command])
 AC_ARG_VAR(XZ, [path to xz command])
 
+if test "x$MTREE" = "x"; then
+    AC_MSG_ERROR([mtree not found])
+fi
+
 MP_SED_EXTENDED_REGEXP
 MP_TAR_FAST_READ
 MP_TAR_NO_SAME_OWNER

Modified: branches/new-help-system/base/doc/Makefile
===================================================================
--- branches/new-help-system/base/doc/Makefile	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/doc/Makefile	2012-12-15 00:33:09 UTC (rev 100533)
@@ -36,7 +36,7 @@
 # HTML version for all man pages
 MANHTML=	${MAN:%=%.html}
 
-CONF=       macports.conf pubkeys.conf sources.conf variants.conf
+CONF=       	archive_sites.conf macports.conf pubkeys.conf sources.conf variants.conf
 INSTALLDIR=	${DESTDIR}${prefix}
 TOPSRCDIR=	..
 
@@ -110,31 +110,24 @@
 endif
 
 install: all
-	$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} ${INSTALLDIR}
-	$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} ${DESTDIR}${mpconfigdir}
+	$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} "${INSTALLDIR}"
+	$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} "${DESTDIR}${mpconfigdir}"
 
-	< prefix.mtree $(MTREE) -U -e -p ${INSTALLDIR} > /dev/null
-	< base.mtree $(MTREE) -U -e -p ${INSTALLDIR} > /dev/null
-	if test -L "${INSTALLDIR}/man" ; then \
-		rm -f "${INSTALLDIR}/man"; \
-	fi
+	< prefix.mtree $(MTREE) -U -e -p "${INSTALLDIR}" > /dev/null
+	< base.mtree $(MTREE) -U -e -p "${INSTALLDIR}" > /dev/null
 
-	if test ! -e "${INSTALLDIR}/man" ; then \
-		$(LN_S) share/man ${INSTALLDIR}/man; \
-	fi
-
 	for f in ${CONF}; do \
-		$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 $$f ${DESTDIR}${mpconfigdir}/$${f}.default; \
-		if test ! -e ${DESTDIR}${mpconfigdir}/$$f ; then \
+		$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 $$f "${DESTDIR}${mpconfigdir}/$${f}.default"; \
+		if test ! -e "${DESTDIR}${mpconfigdir}/$$f" ; then \
 			set -x; \
-			$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 644 $$f ${DESTDIR}${mpconfigdir}; \
+			$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 644 $$f "${DESTDIR}${mpconfigdir}"; \
 		fi; \
 	done
 
 	# delete old uncompressed man pages if they exist
-	for m in ${MAN1}; do rm -f ${INSTALLDIR}/share/man/man1/$$m ; done
-	for m in ${MAN5}; do rm -f ${INSTALLDIR}/share/man/man5/$$m ; done
-	for m in ${MAN7}; do rm -f ${INSTALLDIR}/share/man/man7/$$m ; done
+	for m in ${MAN1}; do rm -f "${INSTALLDIR}/share/man/man1/$$m" ; done
+	for m in ${MAN5}; do rm -f "${INSTALLDIR}/share/man/man5/$$m" ; done
+	for m in ${MAN7}; do rm -f "${INSTALLDIR}/share/man/man7/$$m" ; done
 
 	$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} ${INSTALLDIR}/share/macports/install
 	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 644 base.mtree ${INSTALLDIR}/share/macports/install/

Copied: branches/new-help-system/base/doc/archive_sites.conf (from rev 100531, trunk/base/doc/archive_sites.conf)
===================================================================
--- branches/new-help-system/base/doc/archive_sites.conf	                        (rev 0)
+++ branches/new-help-system/base/doc/archive_sites.conf	2012-12-15 00:33:09 UTC (rev 100533)
@@ -0,0 +1,27 @@
+# Configuration for (binary) archive sources.
+# $Id$
+
+# Each entry is started by a name line. The only required values are name and
+# urls. Other fields are type, prefix, applications_dir and frameworks_dir,
+# which have the usual default values:
+#    type tbz2
+#    prefix /opt/local
+#    applications_dir /Applications/MacPorts
+#    frameworks_dir ${prefix}/Library/Frameworks
+#
+# type can be any of: tgz, tar, tbz, tbz2, tlz, txz, xar, zip, cpgz, cpio
+# Note that some types require a corresponding tool to be installed, and
+# entries with an unsupported type will not be used.
+
+# Example:
+#name                mysource
+#urls                http://example.com/ ftp://ftp.example.org/
+#type                tbz2
+#prefix              /opt/mysource
+#applications_dir    /opt/mysource/Applications
+#frameworks_dir      /opt/mysource/Library/Frameworks
+
+# If you want to disable use of the archive sites listed in the ports tree,
+# you could do this:
+#name                macports_archives
+#urls

Modified: branches/new-help-system/base/doc/base.mtree.in
===================================================================
--- branches/new-help-system/base/doc/base.mtree.in	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/doc/base.mtree.in	2012-12-15 00:33:09 UTC (rev 100533)
@@ -5,6 +5,8 @@
 
 /set type=dir uname=@DSTUSR@ gname=@DSTGRP@ mode=@DSTMODE@
 .
+    man type=link link=share/man
+    ..
     var
         macports
             build

Modified: branches/new-help-system/base/doc/macports.conf.in
===================================================================
--- branches/new-help-system/base/doc/macports.conf.in	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/doc/macports.conf.in	2012-12-15 00:33:09 UTC (rev 100533)
@@ -10,12 +10,14 @@
 # Where to store MacPorts working data
 portdbpath		@localstatedir_expanded@/macports
 
-# PATH settings that are used for external tools (configure, make, etc.) while installing ports. The default
-# paths are given in the example; it need not be uncommented.  Customizing binpath is intended for advanced users only.
+# PATH settings that are used for external tools (configure, make, etc.) while
+# installing ports. The default paths are given in the example; it need not be
+# uncommented.  Customizing binpath is unsupported and is intended for
+# advanced users only.
 #binpath		@prefix_expanded@/bin:@prefix_expanded@/sbin:/bin:/sbin:/usr/bin:/usr/sbin
 
 # Directory containing Xcode Tools (default is to ask xcode-select)
-#developer_dir       @DEVELOPER_DIR@
+#developer_dir		@DEVELOPER_DIR@
 
 # Path to PackageMaker.app
 # It may be necessary to set this with Xcode >= 4.3, as that version
@@ -40,33 +42,33 @@
 # When to build ports from source. Default is 'ifneeded', which downloads an
 # archive if available or builds from source otherwise. 'always' has the same
 # effect as -s on the command line, and 'never' is likewise the same as -b.
-#buildfromsource    ifneeded
+#buildfromsource	ifneeded
 
 # Type of archives to use for port images
 #
 # Supported types: tgz, tar, tbz, tbz2 (default), tlz, txz, xar, zip, cpgz, cpio
-#portarchivetype		tbz2
+#portarchivetype	tbz2
 
 # CPU architecture to compile for. Defaults to i386 or ppc on Mac OS X 10.5
 # and earlier, depending on the CPU type detected at runtime. On Mac OS X 10.6
 # the default is x86_64 if the CPU supports it, i386 otherwise.
-#build_arch			i386
+#build_arch		i386
 
 # CPU architectures to use for Universal Binaries (+universal variant)
 universal_archs		@UNIVERSAL_ARCHS@
 
 # Use ccache (C/C++ compiler cache) - see http://ccache.samba.org/
-#configureccache		no
+#configureccache	no
 
 # Location where ccache stores its files
-#ccache_dir			@localstatedir_expanded@/macports/build/.ccache
+#ccache_dir		@localstatedir_expanded@/macports/build/.ccache
 
 # Maximum size ccache may use.
 # Use 'G', 'M', or 'K' suffix for giga-, mega- or kilobytes.
-#ccache_size			2G
+#ccache_size		2G
 
 # Use distcc (distributed compiler) - see http://distcc.samba.org/
-#configuredistcc		no
+#configuredistcc	no
 
 # Use pipes rather than intermediate files when compiling C/C++/etc
 #configurepipe		yes
@@ -81,13 +83,13 @@
 #buildmakejobs		0
 
 # umask value to use when a port installs its files
-#destroot_umask 022
+#destroot_umask		022
 
 # Set whether to automatically execute "clean" after "install" of ports
 #portautoclean		yes
 
 # Set to yes if you don't want logs to be deleted after successful builds
-#keeplogs no
+#keeplogs		no
 
 # Rsync server to fetch MacPorts sources from. Note that this is only used
 # for selfupdate. The source(s) for the ports tree are set in sources.conf.
@@ -100,7 +102,7 @@
 # Rsync directory from which to pull the base/ component (infrastructure) of MacPorts
 # If this points to a .tar file, a signed .rmd160 must exist next to it
 # on the server and will be used to verify its integrity.
-#rsync_dir			release/tarballs/base.tar
+#rsync_dir		release/tarballs/base.tar
 
 # Rsync options
 #rsync_options		-rtzv --delete-after
@@ -118,7 +120,7 @@
 # startupitem_install may be empty, "yes" or "no";
 # if the option is NOT "no" then a symlink for the startupitem will be created in
 # the appropriate system directory.
-#startupitem_install    yes
+#startupitem_install	yes
 
 # Extra environment variables to keep. Any variables listed here are added
 # to the list of variables that are not removed from the environment used
@@ -138,22 +140,29 @@
 # Equivalent environment variables: http_proxy, HTTPS_PROXY, FTP_PROXY,
 # RSYNC_PROXY, NO_PROXY
 #
-#proxy_override_env    yes
+#proxy_override_env	yes
 # HTTP proxy:
-#proxy_http            hostname:12345
+#proxy_http		hostname:12345
 # HTTPS proxy:
-#proxy_https       hostname:12345
+#proxy_https		hostname:12345
 # FTP proxy:
-#proxy_ftp         hostname:12345
+#proxy_ftp		hostname:12345
 # rsync proxy:
-#proxy_rsync       hostname:12345
+#proxy_rsync		hostname:12345
 # hosts not to go through the proxy (comma-separated, applies to HTTP, HTTPS,
 # and FTP, but not rsync):
-#proxy_skip            internal1, internal2, internal3
+#proxy_skip		internal1, internal2, internal3
 
+# Options 'host_blacklist' and 'preferred_hosts', used for indicating
+# space separated lists of download hosts that should not be used or
+# should be used preferentially, respectively. These override the usual
+# ping time check.
+#host_blacklist     badhost1.org badhost2.org
+#preferred_hosts    preferredhost1.org preferredhost2.org
+
 # Set whether to automatically run rev-upgrade after upgrading ports
 #revupgrade_autorun yes
 # Option controlling action taken by rev-upgrade, which checks for broken
 # linking and can rebuild affected ports. Possible values are
 #'rebuild' (default) or 'report'.
-#revupgrade_mode rebuild
+#revupgrade_mode	rebuild

Modified: branches/new-help-system/base/doc/portfile.7
===================================================================
--- branches/new-help-system/base/doc/portfile.7	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/doc/portfile.7	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1248,6 +1248,8 @@
 .Em macports-gcc-4.4
 .Em macports-gcc-4.5
 .Em macports-gcc-4.6
+.Em macports-gcc-4.7
+.Em macports-gcc-4.8
 .Em macports-llvm-gcc-4.2
 use the vanilla compiler suites installed via MacPorts.
 .br
@@ -1255,7 +1257,7 @@
 .Em optional
 .br
 .Sy Values:
-.Em gcc-3.3 gcc-4.0 gcc-4.2 llvm-gcc-4.2 clang apple-gcc-4.0 apple-gcc-4.2 macports-gcc-4.2 macports-gcc-4.3 macports-gcc-4.4 macports-gcc-4.5 macports-gcc-4.6 macports-llvm-gcc-4.2
+.Em gcc-3.3 gcc-4.0 gcc-4.2 llvm-gcc-4.2 clang apple-gcc-4.0 apple-gcc-4.2 macports-gcc-4.2 macports-gcc-4.3 macports-gcc-4.4 macports-gcc-4.5 macports-gcc-4.6 macports-gcc-4.7 macports-gcc-4.8 macports-llvm-gcc-4.2
 .br
 .Sy Example:
 .Dl configure.compiler llvm-gcc-4.2

Modified: branches/new-help-system/base/portmgr/ReleaseProcess
===================================================================
--- branches/new-help-system/base/portmgr/ReleaseProcess	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/portmgr/ReleaseProcess	2012-12-15 00:33:09 UTC (rev 100533)
@@ -137,30 +137,38 @@
  Security experts in the project, would you be interested in leading this effort? Eric? Mark? Anyone else?)
 
 
-=== Create Release Disk Image(s) ===
+=== Create Release Packages and Disk Image(s) ===
 
 The dmg is a Mac OS X disk image that contains a standalone installer, configured in the usual way, for major
 MacPorts releases (x.y.0), named in a consistent fashion and incorporating the OS version for which it
 was built.
 
+For 10.6 and newer, we now build flat packages, so an enclosing dmg is not necessary.
+
  MacPorts-2.0.0-10.5-Leopard.dmg
- MacPorts-2.0.0-10.6-SnowLeopard.dmg
- MacPorts-2.0.0-10.7-Lion.dmg
+ MacPorts-2.0.0-10.6-SnowLeopard.pkg
+ MacPorts-2.0.0-10.7-Lion.pkg
 
-To create a disk image, use the MacPorts port. The Portfile will need to be updated to incorporate the
+To create a pkg or dmg, use the MacPorts port. The Portfile will need to be updated to incorporate the
 proper release version and checksums, and the release tarballs will need to be already uploaded to the
-downloads section of the site (wherefrom the sources are fetched by the MacPorts port to build the dmg
-for the release). Make sure the ports tree you're using to build the dmg's is fully up to date.
+downloads section of the site (wherefrom the sources are fetched by the MacPorts port to build the pkg
+for the release). Make sure the ports tree you're using to build the pkgs is fully up to date.
 
+ sudo port -d pkg MacPorts
  sudo port -d dmg MacPorts
 
-Name the dmg appropriately, and generate checksums, which will need to be added to the existing checksums
-file in the downloads directory:
+Name each pkg/dmg appropriately, and then sign the pkgs with a Developer ID (make sure to use the
+Installer certificate, not the Application one):
 
  cd work
- mv MacPorts-2.0.0.dmg MacPorts-2.0.0-10.6-SnowLeopard.dmg
- for dmg in MacPorts-2.0.0-*.dmg; do for type in -md5 -sha1 -ripemd160 -sha256; do openssl dgst $type $dmg; done >> MacPorts-2.0.0.chk.txt; done
+ mv MacPorts-2.0.0.pkg unsigned/MacPorts-2.0.0-10.7-Lion.pkg
+ productsign --sign "Developer ID Installer: John Doe" unsigned/MacPorts-2.0.0-10.7-Lion.pkg MacPorts-2.0.0-10.7-Lion.pkg
 
+After signing, generate checksums, which will need to be added to the existing checksums
+file in the downloads directory:
+
+ for pkg in MacPorts-2.0.0-*.{pkg,dmg}; do for type in -md5 -sha1 -ripemd160 -sha256; do openssl dgst $type $pkg; done >> MacPorts-2.0.0.chk.txt; done
+
 These new products, along with the new checksums, also have to be posted to the appropriate
 directory of the MacPorts distfiles server. Developers are required to validate the generated installer as
 thoroughly as possible through extensive testing, which is mainly why this step of the release process
@@ -219,7 +227,8 @@
 Once the release has been posted, notification of the release should be sent/posted to the following places:
 
  * The macports-announce@, macports-users@ and macports-dev@ mailing lists.
- * The MacPorts website, by adapting the $macports_version_major and $macports_version_latest variables as appropriate in the trunk/www/includes/common.inc file.
+ * The MacPorts website, by adapting the $macports_version_major and $macports_version_latest variables as
+   appropriate in the trunk/www/includes/common.inc file.
  * [https://trac.macports.org/news/] The MacOSforge news section (submitter: portmgr@)
  * [http://freecode.com/projects/macports/ Freecode] (submitter: mww@)
  * [http://www.versiontracker.com/dyn/moreinfo/macosx/26679 VersionTracker] (submitter: mij@)

Copied: branches/new-help-system/base/portmgr/dmg/Distribution (from rev 100531, trunk/base/portmgr/dmg/Distribution)
===================================================================
--- branches/new-help-system/base/portmgr/dmg/Distribution	                        (rev 0)
+++ branches/new-help-system/base/portmgr/dmg/Distribution	2012-12-15 00:33:09 UTC (rev 100533)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8"?>
+<installer-gui-script minSpecVersion="1">
+    <title>MacPorts</title>
+    <options customize="never"/>
+    <allowed-os-versions><os-version min="__XVERS__" before="__NEXT_XVERS__"/></allowed-os-versions>
+    <installation-check script="InstallationCheck();"/>
+    <script><![CDATA[
+function InstallationCheck () {
+    if (system.compareVersions(system.version.ProductVersion, "__XVERS__") < 0
+        || system.compareVersions(system.version.ProductVersion, "__NEXT_XVERS__") >= 0) {
+        my.result.message = "This package is meant to be installed on Mac OS X __XVERS__.";
+        my.result.type = 'Fatal';
+        return false;
+    }
+    if (system.files.fileExistsAtPath('__PREFIX__/etc/ports/dp_version')) {
+        my.result.message = "Your existing MacPorts or DarwinPorts installation is too old to be upgraded by this installer. Please install MacPorts 1.7.1 first.";
+        my.result.type = 'Fatal';
+        return false;
+    }
+    if (!system.files.fileExistsAtPath('/usr/bin/xcodebuild')) {
+        my.result.message = "Xcode is not installed, or was installed without __XCODECLITOOLS__.";
+        my.result.type = 'Warn';
+        return false;
+    }
+    return true;
+}
+    ]]>
+    </script>
+    <background file="background.tiff" mime-type="image/tiff" alignment="bottomleft" scaling="none"/>
+    <license mime-type="text/html" file="License.html"/>
+    <readme mime-type="text/rtf" file="ReadMe.rtf"/>
+    <welcome mime-type="text/html" file="Welcome.html"/>
+    <choices-outline>
+        <line choice="default">
+            <line choice="org.macports.MacPorts"/>
+        </line>
+    </choices-outline>
+    <choice id="default"/>
+    <choice id="org.macports.MacPorts" visible="false">
+        <pkg-ref id="org.macports.MacPorts"/>
+    </choice>
+    <pkg-ref id="org.macports.MacPorts">MacPorts-__VERSION__-component.pkg</pkg-ref>
+</installer-gui-script>

Modified: branches/new-help-system/base/portmgr/dmg/License.html
===================================================================
--- branches/new-help-system/base/portmgr/dmg/License.html	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/portmgr/dmg/License.html	2012-12-15 00:33:09 UTC (rev 100533)
@@ -15,7 +15,7 @@
 
     <body>
     
-        <p>Copyright (c) 2002 - 2003, Apple Inc.<br>Copyright (c) 2004 - 2011, The MacPorts Project.</p>
+        <p>Copyright (c) 2002 - 2003, Apple Inc.<br>Copyright (c) 2004 - 2012, The MacPorts Project.</p>
         <p>All rights reserved.</p>
         <p><br></p>
         

Modified: branches/new-help-system/base/portmgr/dmg/postflight
===================================================================
--- branches/new-help-system/base/portmgr/dmg/postflight	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/portmgr/dmg/postflight	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,7 +1,7 @@
 #!/bin/bash
 # -*- coding: utf-8; mode: shell-script-mode; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=sh:et:sw=4:ts=4:sts=4
 #
-# Copyright (c) 2008-2011 The MacPorts Project
+# Copyright (c) 2008-2012 The MacPorts Project
 # Copyright (c) 2002-2007 Juan Manuel Palacios <jmpp at macports.org>, The MacPorts Project.
 # All rights reserved.
 #
@@ -36,7 +36,7 @@
 #set -x
 
 # Script identification ('cause more often than not the svn Id is not expanded):
-VERSION=2.0.0
+VERSION=2.1.0
 
 # Abstraction variables:
 PREFIX=__PREFIX__
@@ -56,7 +56,7 @@
 
 # Create config files from defaults if not present
 function setup_configs {
-    for f in macports.conf pubkeys.conf sources.conf variants.conf ; do
+    for f in archive_sites.conf macports.conf pubkeys.conf sources.conf variants.conf ; do
         if [[ ! -f ${CONFIGPATH}/${f} ]]; then
             echo "Copying ${f}.default to ${f}"
             /bin/cp ${CONFIGPATH}/${f}.default ${CONFIGPATH}/${f}
@@ -67,12 +67,13 @@
 
 # Command to update the MacPorts installation through "selfupdate":
 function update_macports {
+    SCRIPT_DIR=$(dirname $0)
     # Add [default] tag to the central MacPorts repository, if it isn't already
     echo "Adding [default] tag to sources.conf if needed..."
-    ${TCLSH} ${PACKAGE_PATH}/Contents/Resources/upgrade_sources_conf_default.tcl ${PREFIX}
+    ${TCLSH} ${SCRIPT_DIR}/upgrade_sources_conf_default.tcl ${PREFIX}
     # Convert image directories (and direct mode installs) to image archives
     echo "Updating port image format..."
-    ${TCLSH} ${PACKAGE_PATH}/Contents/Resources/images_to_archives.tcl ${MACPORTS_TCL_DIR}
+    ${TCLSH} ${SCRIPT_DIR}/images_to_archives.tcl ${MACPORTS_TCL_DIR}
 
     echo "Synchronizing the MacPorts installation with the project's rsync server..."
     if ! ${BINPATH}/port -v selfupdate; then 

Modified: branches/new-help-system/base/portmgr/jobs/mprsyncup
===================================================================
--- branches/new-help-system/base/portmgr/jobs/mprsyncup	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/portmgr/jobs/mprsyncup	2012-12-15 00:33:09 UTC (rev 100533)
@@ -55,9 +55,7 @@
 PATH=${PREFIX}/bin:/bin:/usr/bin:/usr/sbin:/opt/local/bin
 
 # platforms we generate indexes for
-PLATFORMS="8_powerpc 8_i386 9_powerpc 9_i386 10_i386 11_i386"
-# copy new index of this platform to old index location for MP v1.8 compatability
-OLD_INDEX_PLATFORM="9_i386"
+PLATFORMS="8_powerpc 8_i386 9_powerpc 9_i386 10_i386 11_i386 12_i386"
 
 # Sources information:
 SVNURL=https://svn.macports.org/repository/macports
@@ -87,7 +85,7 @@
 # Read what tag we're releasing from, switch to/checkout a copy, export and rsync it to ${RSYNCROOT}/release/base:
 read RELEASE_URL < ${TBASE}/${RELEASE_URL_FILE}
 if [ ! -n ${RELEASE_URL} ]; then
-    echo "no RELEASE_URL specified in svn trunk, baling out!"
+    echo "no RELEASE_URL specified in svn trunk, bailing out!"
     exit 1
 fi
 if [ -d ${RBASE}/.svn ]; then
@@ -127,11 +125,9 @@
 popd
 
 for PLATFORM in $PLATFORMS; do
-	$PORTINDEX -p darwin_${PLATFORM} -o PortIndex_darwin_${PLATFORM};
+	$PORTINDEX -p macosx_${PLATFORM} -o PortIndex_darwin_${PLATFORM};
 done
 
-# support MP 1.8
-cp PortIndex_darwin_${OLD_INDEX_PLATFORM}/* ./
 popd
 
 if [ ! -d ${RSYNCROOT}/release/ports ]; then

Modified: branches/new-help-system/base/portmgr/jobs/port_binary_distributable.tcl
===================================================================
--- branches/new-help-system/base/portmgr/jobs/port_binary_distributable.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/portmgr/jobs/port_binary_distributable.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -35,12 +35,12 @@
 # to do so below.
 # 'Noncommercial' means a license that prohibits commercial use.
 set good_licenses {afl agpl apache apsl artistic autoconf beopen bitstreamvera \
-                   boost bsd bsd-old cecill cecill-b cecill-c cnri copyleft \
+                   boost bsd bsd-old cddl cecill cecill-b cecill-c cnri copyleft \
                    cpl curl epl fpll fontconfig freetype gd gfdl gpl \
                    gplconflict ibmpl ijg isc jasper lgpl libtool lppl mit \
                    mpl ncsa noncommercial openldap openssl permissive php \
                    psf public-domain qpl restrictive/distributable ruby \
-                   sleepycat ssleay tcl/tk vim w3c wtfpl x11 zlib wxwidgets zpl}
+                   sleepycat ssleay tcl/tk vim w3c wtfpl wxwidgets x11 zlib zpl}
 foreach lic $good_licenses {
     set license_good($lic) 1
 }
@@ -56,38 +56,42 @@
 
 # keep these values sorted
 array set license_conflicts \
-    "afl {cecill gpl}
-    agpl {apache-1 apache-1.1 cecill gpl-1 gpl-2 gplconflict noncommercial restrictive/distributable}
-    apache {cecill gpl-1 gpl-2}
+    "afl {agpl cecill gpl}
+    agpl {afl apache-1 apache-1.1 apsl beopen bsd-old cddl cecill cnri cpl epl gd gpl-1 gpl-2 gplconflict ibmpl lppl mpl noncommercial openssl php qpl restrictive/distributable ruby ssleay zpl-1}
+    agpl-1 {apache freetype gpl-3 gpl-3+ lgpl-3 lgpl-3+}
+    apache {agpl-1 cecill gpl-1 gpl-2}
     apache-1 {agpl gpl}
     apache-1.1 {agpl gpl}
-    apsl {cecill gpl}
-    beopen {cecill gpl}
-    bsd-old {cecill gpl}
-    cnri {cecill gpl}
-    cpl {cecill gpl}
-    cecill {afl agpl apache apsl beopen bsd-old cnri cpl epl gd gplconflict ibmpl lppl mpl noncommercial openssl php qpl restrictive/distributable ruby ssleay zpl-1}
-    epl {cecill gpl}
-    freetype {gpl-2}
-    gd {cecill gpl}
-    gpl {afl agpl apache-1 apache-1.1 apsl beopen cnri bsd-old cpl epl gd gplconflict ibmpl lppl mpl noncommercial openssl php qpl restrictive/distributable ruby ssleay zpl-1}
-    gpl-1 {apache gpl-3 gpl-3+ lgpl-3 lgpl-3+}
-    gpl-2 {apache freetype gpl-3 gpl-3+ lgpl-3 lgpl-3+}
-    gpl-3 {gpl-1 gpl-2}
-    gpl-3+ {gpl-1 gpl-2}
-    ibmpl {cecill gpl}
-    lgpl-3 {gpl-1 gpl-2}
-    lgpl-3+ {gpl-1 gpl-2}
-    lppl {cecill gpl}
-    mpl {cecill gpl}
-    openssl {cecill gpl}
+    apsl {agpl cecill gpl}
+    beopen {agpl cecill gpl}
+    bsd-old {agpl cecill gpl}
+    cddl {agpl cecill gpl}
+    cecill {afl agpl apache apsl beopen bsd-old cddl cnri cpl epl gd gplconflict ibmpl lppl mpl noncommercial openssl php qpl restrictive/distributable ruby ssleay zpl-1}
+    cnri {agpl cecill gpl}
+    cpl {agpl cecill gpl}
+    epl {agpl cecill gpl}
+    freetype {agpl-1 gpl-2}
+    gd {agpl cecill gpl}
+    gpl {afl apache-1 apache-1.1 apsl beopen cddl cnri bsd-old cpl epl gd gplconflict ibmpl lppl mpl noncommercial openssl php qpl restrictive/distributable ruby ssleay zpl-1}
+    gpl-1 {agpl apache gpl-3 gpl-3+ lgpl-3 lgpl-3+}
+    gpl-2 {agpl apache freetype gpl-3 gpl-3+ lgpl-3 lgpl-3+}
+    gpl-3 {agpl-1 gpl-1 gpl-2}
+    gpl-3+ {agpl-1 gpl-1 gpl-2}
+    gplconflict {agpl cecill gpl}
+    ibmpl {agpl cecill gpl}
+    lgpl-3 {agpl-1 gpl-1 gpl-2}
+    lgpl-3+ {agpl-1 gpl-1 gpl-2}
+    lppl {agpl cecill gpl}
+    mpl {agpl cecill gpl}
+    noncommercial {agpl cecill gpl}
+    openssl {agpl cecill gpl}
     opensslexception [all_licenses_except openssl ssleay]
-    php {cecill gpl}
-    qpl {cecill gpl}
+    php {agpl cecill gpl}
+    qpl {agpl cecill gpl}
     restrictive/distributable {agpl cecill gpl}
-    ruby {cecill gpl}
-    ssleay {cecill gpl}
-    zpl-1 {cecill gpl}"
+    ruby {agpl cecill gpl}
+    ssleay {agpl cecill gpl}
+    zpl-1 {agpl cecill gpl}"
 
 proc printUsage {} {
     puts "Usage: $::argv0 \[-hvV\] \[-t macports-tcl-path\] port-name \[variants...\]"
@@ -153,6 +157,9 @@
     global license_good license_conflicts
     array set portSeen {}
     set top_info [infoForPort $portName $variantInfo]
+    if {$top_info == {}} {
+        return 1
+    }
     set top_license [lindex $top_info 1]
     foreach noconflict_port [lindex $top_info 3] {
         set noconflict_ports($noconflict_port) 1
@@ -248,9 +255,14 @@
             }
         }
 
+        # skip deps that are explicitly stated to not conflict
+        array unset aPort_noconflict_ports
+        foreach noconflict_port [lindex $aPortInfo 3] {
+            set aPort_noconflict_ports($noconflict_port) 1
+        }
         # add its deps to the list
         foreach possiblyNewPort [lindex $aPortInfo 0] {
-            if {![info exists portSeen($possiblyNewPort)]} {
+            if {![info exists portSeen($possiblyNewPort)] && ![info exists aPort_noconflict_ports($possiblyNewPort)]} {
                 lappend portList $possiblyNewPort
             }
         }

Modified: branches/new-help-system/base/setupenv.bash.in
===================================================================
--- branches/new-help-system/base/setupenv.bash.in	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/setupenv.bash.in	2012-12-15 00:33:09 UTC (rev 100533)
@@ -34,6 +34,8 @@
     local sbinpath="@prefix_expanded@/sbin"
 
     local IFS=":"
+    local p
+
     for p in $PATH; do
         if [ "$p" == "$binpath" ]; then
             binpath=""
@@ -54,13 +56,14 @@
 }
 
 function export_manpath() {
-    mpath="@prefix_expanded@/share/man"
+    local mpath="@prefix_expanded@/share/man"
+    local IFS=":"
+    local p
 
     if [ -z "$MANPATH" ]; then
         return
     fi
 
-    local IFS=":"
     for p in $MANPATH; do
         if [ "$p" == "$mpath" ]; then
             mpath=""
@@ -75,7 +78,7 @@
 }
 
 function export_display() {
-    if [ -z $DISPLAY ]; then
+    if [ -z "$DISPLAY" ]; then
         export DISPLAY=":0.0"
     fi
 }

Modified: branches/new-help-system/base/src/cregistry/registry.c
===================================================================
--- branches/new-help-system/base/src/cregistry/registry.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/cregistry/registry.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -118,6 +118,8 @@
         sqlite3_extended_result_codes(reg->db, 1);
 #endif
 
+        sqlite3_busy_timeout(reg->db, 25);
+
         if (init_db(reg->db, errPtr)) {
             reg->status = reg_none;
             *regPtr = reg;
@@ -364,7 +366,7 @@
  * @return             true if success; false if failure
  */
 int reg_start_write(reg_registry* reg, reg_error* errPtr) {
-    if (reg_start(reg, "BEGIN EXCLUSIVE", errPtr)) {
+    if (reg_start(reg, "BEGIN IMMEDIATE", errPtr)) {
         reg->status |= reg_transacting | reg_can_write;
         return 1;
     } else {

Modified: branches/new-help-system/base/src/cregistry/sql.c
===================================================================
--- branches/new-help-system/base/src/cregistry/sql.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/cregistry/sql.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -257,13 +257,47 @@
             return 0;
         }
 
-        /* we can't call rpm_vercomp directly because it's static, but we have
+        /* we can't call vercmp directly because it's static, but we have
          * sql_version, which is basically an alias */
         if (sql_version(NULL, -1, version, -1, "1.1") < 0) {
             /* we need to update to 1.1, add binary field and index to files
              * table */
             static char* version_1_1_queries[] = {
+#if SQLITE_VERSION_NUMBER >= 3002000
                 "ALTER TABLE registry.files ADD COLUMN binary BOOL",
+#else
+                /*
+                 * SQLite < 3.2.0 doesn't support ALTER TABLE ADD COLUMN
+                 * Unfortunately, Tiger ships with SQLite < 3.2.0 (#34463)
+                 * This is taken from http://www.sqlite.org/faq.html#q11
+                 */
+
+                /* Create a temporary table */
+                "CREATE TEMPORARY TABLE mp_files_backup (id INTEGER, path TEXT, "
+                    "actual_path TEXT, active INT, mtime DATETIME, md5sum TEXT, editable INT, "
+                    "FOREIGN KEY(id) REFERENCES ports(id))",
+
+                /* Copy all data into the temporary table */
+                "INSERT INTO mp_files_backup SELECT id, path, actual_path, active, mtime, "
+                    "md5sum, editable FROM registry.files",
+
+                /* Drop the original table and re-create it with the new structure */
+                "DROP TABLE registry.files",
+                "CREATE TABLE registry.files (id INTEGER, path TEXT, actual_path TEXT, "
+                    "active INT, mtime DATETIME, md5sum TEXT, editable INT, binary BOOL, "
+                    "FOREIGN KEY(id) REFERENCES ports(id))",
+                "CREATE INDEX registry.file_port ON files(id)",
+                "CREATE INDEX registry.file_path ON files(path)",
+                "CREATE INDEX registry.file_actual ON files(actual_path)",
+
+                /* Copy all data back from temporary table */
+                "INSERT INTO registry.files (id, path, actual_path, active, mtime, md5sum, "
+                    "editable) SELECT id, path, actual_path, active, mtime, md5sum, "
+                    "editable FROM mp_files_backup",
+
+                /* Remove temporary table */
+                "DROP TABLE mp_files_backup",
+#endif
                 "CREATE INDEX registry.file_binary ON files(binary)",
 
                 "UPDATE registry.metadata SET value = '1.100' WHERE key = 'version'",

Modified: branches/new-help-system/base/src/cregistry/util.c
===================================================================
--- branches/new-help-system/base/src/cregistry/util.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/cregistry/util.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -123,6 +123,7 @@
  * @param [in] query_len length of the query (or -1 for automatic)
  * @param [out] objects  the objects selected
  * @param [in] fn        a function to convert sqlite3_stmts to the desired type
+ * @param [inout] data   data passed along to the cast function
  * @param [in] del       a function to delete the desired type of object
  * @param [out] errPtr   on error, a description of the error that occurred
  * @return               the number of objects if success; negative if failure

Modified: branches/new-help-system/base/src/darwintracelib1.0/darwintrace.c
===================================================================
--- branches/new-help-system/base/src/darwintracelib1.0/darwintrace.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/darwintracelib1.0/darwintrace.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -59,19 +59,21 @@
 #include <sys/paths.h>
 #endif
 
+#include <dirent.h>
+#include <dlfcn.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/socket.h>
 #include <sys/stat.h>
-#include <sys/param.h>
 #include <sys/syscall.h>
-#include <errno.h>
-#include <sys/socket.h>
+#include <sys/types.h>
 #include <sys/un.h>
+#include <unistd.h>
 
 #ifndef HAVE_STRLCPY
 /* Define strlcpy if it's not available. */
@@ -140,10 +142,11 @@
 inline char* const* __darwintrace_restore_env(char* const envp[]);
 inline void __darwintrace_setup();
 inline void __darwintrace_cleanup_path(char *path);
-static char * exchange_with_port(const char * buf, size_t len, int answer, char failures);
+static char * exchange_with_port(const char * buf, size_t len, int answer);
 
-#define START_FD 81
-static int __darwintrace_fd = -1;
+static int __darwintrace_fd = -2;
+static FILE *__darwintrace_debug = NULL;
+static pid_t __darwintrace_pid = (pid_t) -1;
 #define BUFFER_SIZE	1024
 
 /**
@@ -160,15 +163,15 @@
 static char* __env_dyld_insert_libraries;
 static char* __env_dyld_force_flat_namespace;
 static char* __env_darwintrace_log;
+static char* __env_darwintrace_debug_log;
 
+#if DARWINTRACE_DEBUG_OUTPUT
 #if __STDC_VERSION__>=199901L
-#if DARWINTRACE_DEBUG_OUTPUT
-#define debug_printf(...) fprintf(stderr, __VA_ARGS__)
+#define debug_printf(format, ...) fprintf(stderr, "darwintrace[%d]: " format, getpid(), __VA_ARGS__); \
+	if (__darwintrace_debug) { \
+		fprintf(__darwintrace_debug, "darwintrace: " format, __VA_ARGS__); \
+	}
 #else
-#define debug_printf(...)
-#endif
-#else
-#if DARWINTRACE_DEBUG_OUTPUT
 __attribute__ ((format (printf, 1, 2)))
 static inline
 int debug_printf(const char *format, ...) {
@@ -179,40 +182,12 @@
     va_end(args);
     return ret;
 }
+#endif
 #else
-#define debug_printf(format, param)
+#define debug_printf(...)
 #endif
-#endif
 
 /*
- * char wait_for_socket(int sock, char w)
- * Function used for read/write operation to socket...
- * Args:
- *  sock - socket 
- *  w - what should socket do in next operation. 1 for write, 0 for read
- * Return value: 
- *  1 - everything is ok, we can read/write to/from it
- *  0 - something's went wrong
- */
-static int wait_for_socket(int sock, char w)
-{
-	struct timeval tv;
-	fd_set fds;
-	
-	if(sock==-1)
-		return 0;
-	
-	tv.tv_sec=10;
-	tv.tv_usec=0;
-	FD_ZERO(&fds);
-	FD_SET(sock, &fds);
-	if(select(sock+1, (w==0 ? &fds : 0), (w==1 ? &fds : 0), 0, &tv)<1)
-		return 0;
-	return FD_ISSET(sock, &fds)!=0;
-}
-
-
-/*
  * return 0 if str doesn't begin with prefix, 1 otherwise.
  */
 inline int __darwintrace_strbeginswith(const char* str, const char* prefix) {
@@ -248,6 +223,12 @@
 	} else {
 		__env_darwintrace_log = NULL;
 	}
+	theValue = getenv("DARWINTRACE_DEBUG_LOG");
+	if (theValue != NULL) {
+		__env_darwintrace_debug_log = strdup(theValue);
+	} else {
+		__env_darwintrace_debug_log = NULL;
+	}
 }
 
 /*
@@ -291,6 +272,10 @@
 		__darwintrace_alloc_env(
 			"DARWINTRACE_LOG",
 			__env_darwintrace_log);
+	char* darwintrace_debug_log_ptr =	
+		__darwintrace_alloc_env(
+			"DARWINTRACE_DEBUG_LOG",
+			__env_darwintrace_debug_log);
 
 	char* const * theEnvIter = envp;
 	int theEnvLength = 0;
@@ -318,6 +303,9 @@
 		} else if (__darwintrace_strbeginswith(theValue, "DARWINTRACE_LOG=")) {
 			theValue = darwintrace_log_ptr;
 			darwintrace_log_ptr = NULL;
+		} else if (__darwintrace_strbeginswith(theValue, "DARWINTRACE_DEBUG_LOG=")) {
+			theValue = darwintrace_debug_log_ptr;
+			darwintrace_debug_log_ptr = NULL;
 		}
 		
 		if (theValue) {
@@ -336,6 +324,9 @@
 	if (darwintrace_log_ptr) {
 		*theCopyIter++ = darwintrace_log_ptr;
 	}
+	if (darwintrace_debug_log_ptr) {
+		*theCopyIter++ = darwintrace_debug_log_ptr;
+	}
 
 	*theCopyIter = 0;
 	
@@ -344,7 +335,7 @@
 
 static void ask_for_filemap()
 {
-	filemap=exchange_with_port("filemap\t", sizeof("filemap\t"), 1, 0);
+	filemap=exchange_with_port("filemap\t", sizeof("filemap\t"), 1);
 	if(filemap==(char*)-1)
 		filemap=0;
 }
@@ -353,17 +344,29 @@
 inline void __darwintrace_setup() {
 #define open(x,y,z) syscall(SYS_open, (x), (y), (z))
 #define close(x) syscall(SYS_close, (x))
-	if (__darwintrace_fd == -1) {
+	pid_t oldpid = __darwintrace_pid;
+	if (__darwintrace_pid != (pid_t) -1 && __darwintrace_pid != getpid()) {
+		if (__darwintrace_fd != -2) {
+			close(__darwintrace_fd);
+			__darwintrace_fd = -2;
+		}
+		if (__darwintrace_debug) {
+			fclose(__darwintrace_debug);
+			__darwintrace_debug = NULL;
+		}
+		__darwintrace_pid = (pid_t) -1;
+	}
+	if (__darwintrace_pid == (pid_t) -1) {
+		__darwintrace_pid = getpid();
 		if (__env_darwintrace_log != NULL) {
 			int olderrno = errno;
-			int sock=socket(AF_UNIX, SOCK_STREAM, 0);
+			int sock = socket(AF_UNIX, SOCK_STREAM, 0);
 			struct sockaddr_un sun;
-			sun.sun_family=AF_UNIX;
+			sun.sun_family = AF_UNIX;
 			strncpy(sun.sun_path, __env_darwintrace_log, sizeof(sun.sun_path));
-			if(connect(sock, (struct sockaddr*)&sun, strlen(__env_darwintrace_log)+1+sizeof(sun.sun_family))!=-1)
-			{
-				debug_printf("darwintrace: connect successful. socket %d\n", sock);
-				__darwintrace_fd=sock;
+			if (connect(sock, (struct sockaddr*)&sun, strlen(__env_darwintrace_log) + 1 + sizeof(sun.sun_family)) != -1) {
+				debug_printf("connect successful, socket %d in pid %d\n", sock, __darwintrace_pid);
+				__darwintrace_fd = sock;
 				ask_for_filemap();
 			} else {
 				debug_printf("connect failed: %s\n", strerror(errno));
@@ -371,6 +374,21 @@
 			}
 			errno = olderrno;
 		}
+		if (__darwintrace_debug == NULL) {
+			if (__env_darwintrace_debug_log != NULL) {
+				char logpath[MAXPATHLEN];
+				snprintf(logpath, MAXPATHLEN, __env_darwintrace_debug_log, getpid());
+				if (NULL == (__darwintrace_debug = fopen(logpath, "w"))) {
+					fprintf(stderr, "failed to open logfile: %s\n", strerror(errno));
+					abort();
+				}
+				fprintf(__darwintrace_debug, "pid %d is process %s\n", getpid(), getenv("_"));
+				debug_printf("logging socket communication to: %s\n", logpath);
+			}
+		}
+		if (oldpid != (pid_t) -1) {
+			debug_printf("seems to have forked from %d, re-opened files\n", oldpid);
+		}
 	}
 #undef close
 #undef open
@@ -386,7 +404,7 @@
 	int size;
 	char somepath[MAXPATHLEN];
 	char logbuffer[BUFFER_SIZE];
-	
+
 	do {
 #ifdef __APPLE__ /* Only Darwin has volfs and F_GETPATH */
 		if ((fd > 0) && (DARWINTRACE_LOG_FULL_PATH
@@ -416,9 +434,9 @@
 
 	size = snprintf(logbuffer, sizeof(logbuffer),
 		"%s\t%s",
-		op, somepath );
+		op, somepath);
 
-	exchange_with_port(logbuffer, size+1, 0, 0);
+	exchange_with_port(logbuffer, size+1, 0);
 	
 	return;
 }
@@ -427,82 +445,66 @@
  * do a partial realpath(3) to fix "foo//bar" to "foo/bar"
  */
 inline void __darwintrace_cleanup_path(char *path) {
-  size_t pathlen;
+	size_t pathlen;
 #ifdef __APPLE__
-  size_t rsrclen;
+	size_t rsrclen;
 #endif
-  size_t i, shiftamount;
-  enum { SAWSLASH, NOTHING } state = NOTHING;
+	size_t i, shiftamount;
+	enum { SAWSLASH, NOTHING } state = NOTHING;
 
-  /* if this is a foo/..namedfork/rsrc, strip it off */
-  pathlen = strlen(path);
-  /* ..namedfork/rsrc is only on OS X */
-#ifdef __APPLE__ 
-  rsrclen = strlen(_PATH_RSRCFORKSPEC);
-  if(pathlen > rsrclen
-     && 0 == strcmp(path + pathlen - rsrclen,
-		    _PATH_RSRCFORKSPEC)) {
-    path[pathlen - rsrclen] = '\0';
-    pathlen -= rsrclen;
-  }
+	/* if this is a foo/..namedfork/rsrc, strip it off */
+	pathlen = strlen(path);
+	/* ..namedfork/rsrc is only on OS X */
+#ifdef __APPLE__
+	rsrclen = strlen(_PATH_RSRCFORKSPEC);
+	if (pathlen > rsrclen && 0 == strcmp(path + pathlen - rsrclen, _PATH_RSRCFORKSPEC)) {
+		path[pathlen - rsrclen] = '\0';
+		pathlen -= rsrclen;
+	}
 #endif
 
-  /* for each position in string (including
-     terminal \0), check if we're in a run of
-     multiple slashes, and only emit the
-     first one
-  */
-  for(i=0, shiftamount=0; i <= pathlen; i++) {
-    if(state == SAWSLASH) {
-      if(path[i] == '/') {
-	/* consume it */
-	shiftamount++;
-      } else {
-	state = NOTHING;
-	path[i - shiftamount] = path[i];
-      }
-    } else {
-      if(path[i] == '/') {
-	state = SAWSLASH;
-      }
-      path[i - shiftamount] = path[i];
-    }
-  }
-
-  debug_printf("darwintrace: cleanup resulted in %s\n", path);
+	/* for each position in string (including terminal \0), check if we're in
+	 * a run of multiple slashes, and only emit the first one */
+	for(i = 0, shiftamount = 0; i <= pathlen; i++) {
+		if (state == SAWSLASH) {
+			if (path[i] == '/') {
+				/* consume it */
+				shiftamount++;
+				continue;
+			} else {
+				state = NOTHING;
+			}
+		} else {
+			if (path[i] == '/') {
+				state = SAWSLASH;
+			}
+		}
+		path[i - shiftamount] = path[i];
+	}
 }
 
 /*
- * return 1 if path is directory or not exists
- * return 0 otherwise
+ * return 1 if path allowed, 0 otherwise
  */
-static int is_directory(const char * path)
-{
-#define stat(path, sb) syscall(SYS_stat, path, sb)
-	struct stat s;
-	if(stat(path, &s)==-1)
-		/* Actually is not directory, but anyway, we shouldn't test a dependency unless file exists */
-		return 1;
-	
-	return S_ISDIR(s.st_mode);
-#undef stat
-}
+static int ask_for_dependency(char * path) {
+#define stat(y, z) syscall(SYS_stat, (y), (z))
+	char buffer[BUFFER_SIZE], *p;
+	int result = 0;
+	struct stat st;
 
+	debug_printf("ask_for_dependency: %s\n", path);
 
-/*
- * return 1 if path allowed, 0 otherwise
- */
-static int ask_for_dependency(char * path)
-{
-	char buffer[BUFFER_SIZE], *p;
-	int result=0;
-	
-	if(is_directory(path))
+	if (-1 == stat(path, &st)) {
 		return 1;
+	}
+	if (S_ISDIR(st.st_mode)) {
+		debug_printf("%s is directory\n", path);
+		return 1;
+	}
 	
 	strncpy(buffer, "dep_check\t", sizeof(buffer));
 	strncpy(buffer+10, path, sizeof(buffer)-10);
-	p=exchange_with_port(buffer, strlen(buffer)+1, 1, 0);
+	p=exchange_with_port(buffer, strlen(buffer)+1, 1);
 	if(p==(char*)-1||!p)
 		return 0;
 	
@@ -511,6 +513,7 @@
 	
 	free(p);
 	return result;
+#undef stat
 }
 
 /*
@@ -525,155 +528,182 @@
  *    0      -- data successfully sent
  *    string -- answer (caller shoud free it)
  */
-static char * exchange_with_port(const char * buf, size_t len, int answer, char failures)
-{
-	wait_for_socket(__darwintrace_fd, 1);
-	if(send(__darwintrace_fd, buf, len, 0)==-1)
-	{
-		if(errno==ENOTSOCK && failures<3)
-		{
-			__darwintrace_fd=-1;
-			__darwintrace_setup();
-			return exchange_with_port(buf, len, answer, failures+1);
+static char * exchange_with_port(const char * buf, size_t len, int answer) {
+	size_t sent = 0;
+
+	if (__darwintrace_debug) {
+		fprintf(__darwintrace_debug, "> %s\n", buf);
+	}
+	while (sent < len) {
+		ssize_t local_sent = send(__darwintrace_fd, buf + sent, len - sent, 0);
+		if (local_sent == -1) {
+			debug_printf("error communicating with socket %d: %s\n", __darwintrace_fd, strerror(errno));
+			if (__darwintrace_debug)
+				fprintf(__darwintrace_debug, "darwintrace: error communicating with socket %d: %s\n", __darwintrace_fd, strerror(errno));
+			abort();
 		}
-		return (char*)-1;
+		sent += local_sent;
 	}
-	if(!answer)
+	if (!answer) {
 		return 0;
-	{
-		size_t l=0;
-		char * b;
+	} else {
+		size_t recv_len = 0, received;
+		char *recv_buf;
 		
-		wait_for_socket(__darwintrace_fd, 0);
-		recv(__darwintrace_fd, &l, sizeof(l),0);
-		if(!l)
+		received = 0;
+		while (received < sizeof(recv_len)) {
+			ssize_t local_received = recv(__darwintrace_fd, ((char *) &recv_len) + received, sizeof(recv_len) - received, 0);
+			if (local_received == -1) {
+				debug_printf("error reading data from socket %d: %s\n", __darwintrace_fd, strerror(errno));
+				if (__darwintrace_debug)
+					fprintf(__darwintrace_debug, "darwintrace: error reading data from socket %d: %s\n", __darwintrace_fd, strerror(errno));
+				abort();
+			}
+			received += local_received;
+		}
+		if (recv_len == 0) {
 			return 0;
-		b=(char*)malloc(l+1);
-		b[l]=0;
-		recv(__darwintrace_fd, b, l, 0);
-		return b;
+		}
+
+		recv_buf = malloc(recv_len + 1);
+		recv_buf[recv_len] = '\0';
+
+		received = 0;
+		while (received < recv_len) {
+			ssize_t local_received = recv(__darwintrace_fd, recv_buf + received, recv_len - received, 0);
+			if (local_received == -1) {
+				debug_printf("error reading data from socket %d: %s\n", __darwintrace_fd, strerror(errno));
+				if (__darwintrace_debug)
+					fprintf(__darwintrace_debug, "darwintrace: error reading data from socket %d: %s\n", __darwintrace_fd, strerror(errno));
+				abort();
+			}
+			received += local_received;
+		}
+		if (__darwintrace_debug) {
+			fprintf(__darwintrace_debug, "< %s\n", recv_buf);
+		}
+		return recv_buf;
 	}
 }
 
+#define DARWINTRACE_STATUS_PATH    ((char) 0)
+#define DARWINTRACE_STATUS_COMMAND ((char) 1)
+#define DARWINTRACE_STATUS_DONE    ((char) 2)
+
 /*
  * return 1 if path (once normalized) is in sandbox or redirected, 0 otherwise.
  */
 __attribute__((always_inline))
 inline int __darwintrace_is_in_sandbox(const char* path, char * newpath) {
-	char * t, * p, * _;
-	int result=-1;
+	char *t, *p, *_;
+	char lpath[MAXPATHLEN];
 	
 	__darwintrace_setup();
 	
-	if(!filemap)
+	if (!filemap)
 		return 1;
 	
-	if(*path=='/')
-		p=strdup(path);
-	else
-	{
-		p=(char*)malloc(MAXPATHLEN);
-		if (getcwd(p, MAXPATHLEN-1) == NULL) {
+	if (*path=='/') {
+		p = strcpy(lpath, path);
+	} else {
+		if (getcwd(lpath, MAXPATHLEN - 1) == NULL) {
 			fprintf(stderr, "darwintrace: getcwd: %s, path was: %s\n", strerror(errno), path);
 			abort();
 		}
-		if (p[strlen(p)-1] != '/')
-			strcat(p, "/");
-		strcat(p, path);
+		strcat(lpath, "/");
+		strcat(lpath, path);
 	}
-	__darwintrace_cleanup_path(p);
-			
-	do
-	{
-		for(t=filemap; *t;)
-		{
-			if(__darwintrace_strbeginswith(p, t))
-			{
-				t+=strlen(t)+1;
-				switch(*t)
-				{
+
+	p = lpath;
+
+	for (t = filemap; *t;) {
+		char state;
+		
+		if (__darwintrace_strbeginswith(p, t)) {
+			/* move t to the integer describing how to handle this match */
+			t += strlen(t) + 1;
+			switch (*t) {
 				case 0:
-					result=1;
-					break;
+					return 1;
 				case 1:
-					if(!newpath)
-					{
-						result=0;
-						break;
+					if (!newpath) {
+						return 0;
 					}
-					strcpy(newpath, t+1);
-					_=newpath+strlen(newpath);
-					if(_[-1]!='/')
-						*_++='/';
+					/* the redirected path starts right after the byte telling
+					 * us we should redirect */
+					strcpy(newpath, t + 1);
+					_ = newpath + strlen(newpath);
+					/* append '/' if it's missing */
+					if (_[-1] != '/') {
+						*_ = '/';
+					}
 					strcpy(_, p);
-					result=1;
-					break;
+					return 1;
 				case 2:
-					result=ask_for_dependency(p);
+					/* ask the socket whether this file is OK */
+					return ask_for_dependency(p);
+				default:
+					fprintf(stderr, "darwintrace: error: unexpected byte in file map: `%x'\n", *t);
+					abort();
+			}
+		}
+
+		/* advance the cursor: if the number after the string is not 1, there's
+		 * no path behind it and we can advance by strlen(t) + 3. If it is 1,
+		 * make sure to skip the path, too.
+		 */
+		state = DARWINTRACE_STATUS_PATH;
+		while (state != DARWINTRACE_STATUS_DONE) {
+			switch (state) {
+				case DARWINTRACE_STATUS_PATH:
+					if (!*t) {
+						state = DARWINTRACE_STATUS_COMMAND;
+					}
 					break;
-				}
+				case DARWINTRACE_STATUS_COMMAND:
+					if (*t == 1) {
+						state = DARWINTRACE_STATUS_PATH;
+						t++;
+					} else {
+						state = DARWINTRACE_STATUS_DONE;
+					}
+					break;
 			}
-			if(result!=-1)
-				break;
-			t+=strlen(t)+1;
-			if(*t==1)
-				t+=strlen(t)+1;
-			else
-				t+=2;
+			t++;
 		}
-		if(result!=-1)
-			break;
-		__darwintrace_log_op("sandbox_violation", path, 0);
-		result=0;
+		t++;
 	}
-	while(0);
-	free(p);
-	return result;
+
+	__darwintrace_log_op("sandbox_violation", path, 0);
+	return 0;
 }
 
-/* Log calls to open(2) into the file specified by DARWINTRACE_LOG.
-   Only logs if the DARWINTRACE_LOG environment variable is set.
-   Only logs files (or rather, do not logs directories)
-   Only logs files where the open succeeds.
-   Only logs files opened for read access, without the O_CREAT flag set
-   	(unless DARWINTRACE_LOG_CREATE is set).
-   The assumption is that any file that can be created isn't necessary
-   to build the project.
-*/
-
+/* wrapper for open(2) preventing opening files outside the sandbox */
 int open(const char* path, int flags, ...) {
 #define open(x,y,z) syscall(SYS_open, (x), (y), (z))
 	mode_t mode;
-	int result;
 	va_list args;
-	struct stat sb;
 	char newpath[MAXPATHLEN];
-	int isInSandbox;	
 
+	debug_printf("open(%s)\n", path);
+
+	*newpath = '\0';
+	if (!__darwintrace_is_in_sandbox(path, newpath)) {
+		debug_printf("open %s was forbidden\n", path);
+		errno = ((flags & O_CREAT) > 0) ? EACCES : ENOENT;
+		return -1;
+	}
+
+	if (*newpath) {
+		path = newpath;
+	}
+
 	/* Why mode here ? */
 	va_start(args, flags);
 	mode = va_arg(args, int);
 	va_end(args);
-	
-	result = 0;
-	
-	if((stat(path, &sb)!=-1 && !(sb.st_mode&S_IFDIR)) || flags & O_CREAT )
-	{
-		*newpath=0;
-		__darwintrace_setup();
-		isInSandbox = __darwintrace_is_in_sandbox(path, newpath);
-		if (isInSandbox == 0) {
-			debug_printf("darwintrace: creation/writing was forbidden at %s\n", path);
-			errno = EACCES;
-			result = -1;
-		}
-		if(*newpath)
-			path=newpath;
-	}
-	if (result == 0) {
-		result = open(path, flags, mode);
-	}
-	return result;
+
+	return open(path, flags, mode);
 #undef open
 }
 
@@ -682,25 +712,26 @@
    Only logs files where the readlink succeeds.
 */
 #ifdef READLINK_IS_NOT_P1003_1A
-int  readlink(const char * path, char * buf, int bufsiz) {
+int readlink(const char * path, char * buf, int bufsiz) {
 #else
-ssize_t  readlink(const char * path, char * buf, size_t bufsiz) {
+ssize_t readlink(const char * path, char * buf, size_t bufsiz) {
 #endif
 #define readlink(x,y,z) syscall(SYS_readlink, (x), (y), (z))
-	ssize_t result;
-	int isInSandbox;
+	char newpath[MAXPATHLEN];
 
-	result = readlink(path, buf, bufsiz);
-	if (result >= 0) {
-		__darwintrace_setup();
-		isInSandbox = __darwintrace_is_in_sandbox(path, 0);
-		if (!isInSandbox)
-		{
-			errno=EACCES;
-			result=-1;
-		}
+	debug_printf("readlink(%s)\n", path);
+
+	*newpath = '\0';
+	if (!__darwintrace_is_in_sandbox(path, newpath)) {
+		errno = ENOENT;
+		return -1;
 	}
-	return result;
+
+	if (*newpath) {
+		path = newpath;
+	}
+
+	return readlink(path, buf, bufsiz);
 #undef readlink
 }
 
@@ -709,314 +740,442 @@
 #define open(x,y,z) syscall(SYS_open, (x), (y), (z))
 #define close(x) syscall(SYS_close, (x))
 #define lstat(x, y) syscall(SYS_lstat, (x), (y))
-	int result;
+	debug_printf("execve(%s)\n", path);
 	__darwintrace_setup();
 	if (__darwintrace_fd >= 0) {
-	  struct stat sb;
-	  /* for symlinks, we want to capture
-	   * both the original path and the modified one,
-	   * since for /usr/bin/gcc -> gcc-4.0,
-	   * both "gcc_select" and "gcc" are contributors
-	   */
-	  if (lstat(path, &sb) == 0) {
-	  	int fd;
+		struct stat sb;
+		/* for symlinks, we want to capture both the original path and the
+		 * modified one, since for /usr/bin/gcc -> gcc-4.0, both "gcc_select"
+		 * and "gcc" are contributors
+		 */
+		if (lstat(path, &sb) == 0) {
+			int fd;
+			if (S_ISLNK(sb.st_mode)) {
+				/* for symlinks, print both */
+				__darwintrace_log_op("execve", path, 0);
+			}
 
-	    if(S_ISLNK(sb.st_mode)) {
-	      /* for symlinks, print both */
-		  __darwintrace_log_op("execve", path, 0);
-	    }
-		
-		fd = open(path, O_RDONLY, 0);
-		if (fd > 0) {
-		  char buffer[MAXPATHLEN+1], newpath[MAXPATHLEN+1];
-		  ssize_t bytes_read;
-		
-		  *newpath=0;
-		  if(__darwintrace_is_in_sandbox(path, newpath)==0)
-		  {
-			close(fd);
-			errno=ENOENT;
-		    return -1;
-		  }
-		  if(*newpath)
-		    path=newpath;
+			fd = open(path, O_RDONLY, 0);
+			if (fd > 0) {
+				char buffer[MAXPATHLEN+1];
+				ssize_t bytes_read;
+
+				if(!__darwintrace_is_in_sandbox(path, NULL)) {
+					close(fd);
+					errno = ENOENT;
+					return -1;
+				}
 	
-		  /* once we have an open fd, if a full path was requested, do it */
-		  __darwintrace_log_op("execve", path, fd);
-
-		  /* read the file for the interpreter */
-		  bytes_read = read(fd, buffer, MAXPATHLEN);
-		  buffer[bytes_read] = 0;
-		  if (bytes_read > 2 &&
-			buffer[0] == '#' && buffer[1] == '!') {
-			const char* interp = &buffer[2];
-			int i;
-			/* skip past leading whitespace */
-			for (i = 2; i < bytes_read; ++i) {
-			  if (buffer[i] != ' ' && buffer[i] != '\t') {
-				interp = &buffer[i];
-				break;
-			  }
+				/* once we have an open fd, if a full path was requested, do it */
+				__darwintrace_log_op("execve", path, fd);
+	
+				/* read the file for the interpreter */
+				bytes_read = read(fd, buffer, MAXPATHLEN);
+				buffer[bytes_read] = 0;
+				if (bytes_read > 2 && buffer[0] == '#' && buffer[1] == '!') {
+					const char* interp = &buffer[2];
+					int i;
+					/* skip past leading whitespace */
+					for (i = 2; i < bytes_read; ++i) {
+						if (buffer[i] != ' ' && buffer[i] != '\t') {
+							interp = &buffer[i];
+							break;
+						}
+					}
+					/* found interpreter (or ran out of data); skip until next
+					 * whitespace, then terminate the string */
+					for (; i < bytes_read; ++i) {
+						if (buffer[i] == ' ' || buffer[i] == '\t' || buffer[i] == '\n') {
+							buffer[i] = 0;
+							break;
+						}
+					}
+					/* we have liftoff */
+					if (interp && interp[0] != '\0') {
+						__darwintrace_log_op("execve", interp, 0);
+					}
+				}
+				close(fd);
 			}
-			/* found interpreter (or ran out of data)
-			   skip until next whitespace, then terminate the string */
-			for (; i < bytes_read; ++i) {
-			  if (buffer[i] == ' ' || buffer[i] == '\t' || buffer[i] == '\n') {
-				buffer[i] = 0;
-				break;
-			  }
-			}
-			/* we have liftoff */
-			if (interp && interp[0] != '\0') {
-			  __darwintrace_log_op("execve", interp, 0);
-			}
-		  }
-		  close(fd);
 		}
-	  }
-	close(__darwintrace_fd);
-	__darwintrace_fd=-1;
 	}
-	
+	/* our variables won't survive exec, clean up */
+	if (__darwintrace_fd != -2) {
+		close(__darwintrace_fd);
+		__darwintrace_fd = -2;
+	}
+	if (__darwintrace_debug) {
+		fclose(__darwintrace_debug);
+		__darwintrace_debug = NULL;
+	}
+	__darwintrace_pid = (pid_t) -1;
+
 	/* call the original execve function, but fix the environment if required. */
-	result = __execve(path, argv, __darwintrace_restore_env(envp));
-	return result;
+	return __execve(path, argv, __darwintrace_restore_env(envp));
 #undef lstat
 #undef close
 #undef open
 #undef execve
 }
 
-/* if darwintrace has been initialized, trap
-   attempts to close our file descriptor
-*/
+/* if darwintrace has been initialized, trap attempts to close our file
+ * descriptor */
 int close(int fd) {
 #define close(x) syscall(SYS_close, (x))
+	if (__darwintrace_fd != -2 && fd == __darwintrace_fd) {
+		errno = EBADF;
+		return -1;
+	}
 
-  if(__darwintrace_fd != -2 && fd == __darwintrace_fd) {
-    errno = EBADF;
-    return -1;
-  }
-
-  return close(fd);
+	return close(fd);
 #undef close
 }
 
-/* Trap attempts to unlink a file outside the sandbox.
- */
+/* if darwintrace has been initialized, trap attempts to dup2 over our file descriptor */
+int dup2(int filedes, int filedes2) {
+#define dup2(x, y) syscall(SYS_dup2, (x), (y))
+
+	debug_printf("dup2(%d, %d)\n", filedes, filedes2);
+	if (__darwintrace_fd != -2 && filedes2 == __darwintrace_fd) {
+		/* if somebody tries to close our file descriptor, just move it out of
+		 * the way. Make sure it doesn't end up as stdin/stdout/stderr, though!
+		 * */
+		int new_darwintrace_fd;
+
+		if (-1 == (new_darwintrace_fd = fcntl(__darwintrace_fd, F_DUPFD, STDOUT_FILENO + 1))) {
+			/* if duplicating fails, do not allow overwriting either! */
+			return -1;
+		}
+
+		debug_printf("moving __darwintrace_fd from %d to %d\n", __darwintrace_fd, new_darwintrace_fd);
+		__darwintrace_fd = new_darwintrace_fd;
+	}
+
+	return dup2(filedes, filedes2);
+#undef dup2
+}
+
+
+/* Trap attempts to unlink a file outside the sandbox. */
 int unlink(const char* path) {
 #define __unlink(x) syscall(SYS_unlink, (x))
-	int result = 0;
-	int isInSandbox = __darwintrace_is_in_sandbox(path, 0);
-	if (isInSandbox == 1) {
-		debug_printf("darwintrace: unlink was allowed at %s\n", path);
-	} else if (isInSandbox == 0) {
-		/* outside sandbox, but sandbox is defined: forbid */
-		debug_printf("darwintrace: unlink was forbidden at %s\n", path);
-		errno = EACCES;
-		result = -1;
+	char newpath[MAXPATHLEN];
+
+	*newpath = '\0';
+	if (!__darwintrace_is_in_sandbox(path, newpath)) {
+		debug_printf("unlink %s was forbidden\n", path);
+		errno = ENOENT;
+		return -1;
 	}
-	
-	if (result == 0) {
-		result = __unlink(path);
+
+	if (*newpath) {
+		path = newpath;
 	}
-	
-	return result;
+
+	debug_printf("unlink %s was allowed\n", path);
+
+	return __unlink(path);
 }
 
 /* Trap attempts to create directories outside the sandbox.
  */
 int mkdir(const char* path, mode_t mode) {
 #define __mkdir(x,y) syscall(SYS_mkdir, (x), (y))
-	int result = 0;
-	int isInSandbox = __darwintrace_is_in_sandbox(path, 0);
-	if (isInSandbox == 1) {
-		debug_printf("darwintrace: mkdir was allowed at %s\n", path);
-	} else if (isInSandbox == 0) {
-		/* outside sandbox, but sandbox is defined: forbid */
-		/* only consider directories that do not exist. */
-		struct stat theInfo;
-		int err;
-		err = lstat(path, &theInfo);
-		if ((err == -1) && (errno == ENOENT))
-		{
-			debug_printf("darwintrace: mkdir was forbidden at %s\n", path);
-			errno = EACCES;
-			result = -1;
-		} /* otherwise, mkdir will do nothing (directory exists) or fail
-		     (another error) */
+	char newpath[MAXPATHLEN];
+
+	*newpath = '\0';
+	if (!__darwintrace_is_in_sandbox(path, newpath)) {
+		struct stat st;
+		if (-1 == lstat(path, &st)) {
+			if (errno == ENOENT) {
+				/* directory doesn't exist yet */
+				debug_printf("mkdir was forbidden at %s\n", path);
+				errno = EACCES;
+				return -1;
+			}
+		}
+		/* otherwise, mkdir will do nothing or fail with a hopefully meaningful
+		 * error */
+	} else {
+		if (*newpath) {
+			path = newpath;
+		}
+
+		debug_printf("mkdir was allowed at %s\n", path);
 	}
-	
-	if (result == 0) {
-		result = __mkdir(path, mode);
-	}
-	
-	return result;
+
+	return __mkdir(path, mode);
 }
 
 /* Trap attempts to remove directories outside the sandbox.
  */
 int rmdir(const char* path) {
 #define __rmdir(x) syscall(SYS_rmdir, (x))
-	int result = 0;
-	int isInSandbox = __darwintrace_is_in_sandbox(path, 0);
-	if (isInSandbox == 1) {
-		debug_printf("darwintrace: rmdir was allowed at %s\n", path);
-	} else if (isInSandbox == 0) {
-		/* outside sandbox, but sandbox is defined: forbid */
-		debug_printf("darwintrace: removing directory %s was forbidden\n", path);
-		errno = EACCES;
-		result = -1;
+	if (!__darwintrace_is_in_sandbox(path, NULL)) {
+		debug_printf("removing directory %s was forbidden\n", path);
+		errno = ENOENT;
+		return -1;
 	}
-	
-	if (result == 0) {
-		result = __rmdir(path);
-	}
-	
-	return result;
+
+	debug_printf("rmdir %s was allowed\n", path);
+
+	return __rmdir(path);
 }
 
 /* Trap attempts to rename files/directories outside the sandbox.
  */
 int rename(const char* from, const char* to) {
 #define __rename(x,y) syscall(SYS_rename, (x), (y))
-	int result = 0;
-	int isInSandbox = __darwintrace_is_in_sandbox(from, 0);
-	if (isInSandbox == 1) {
-		debug_printf("darwintrace: rename was allowed at %s\n", from);
-	} else if (isInSandbox == 0) {
-		/* outside sandbox, but sandbox is defined: forbid */
-		debug_printf("darwintrace: renaming from %s was forbidden\n", from);
+	if (!__darwintrace_is_in_sandbox(from, NULL)) {
+		/* outside sandbox, forbid */
+		debug_printf("renaming from %s was forbidden\n", from);
+		errno = ENOENT;
+		return -1;
+	}
+	if (!__darwintrace_is_in_sandbox(to, NULL)) {
+		debug_printf("renaming to %s was forbidden\n", to);
 		errno = EACCES;
-		result = -1;
+		return -1;
 	}
 
-	if (result == 0) {
-		isInSandbox = __darwintrace_is_in_sandbox(to, 0);
-		if (isInSandbox == 1) {
-			debug_printf("darwintrace: rename was allowed at %s\n", to);
-		} else if (isInSandbox == 0) {
-			/* outside sandbox, but sandbox is defined: forbid */
-			debug_printf("darwintrace: renaming to %s was forbidden\n", to);
-			errno = EACCES;
-			result = -1;
-		}
-	}
-	
-	if (result == 0) {
-		result = __rename(from, to);
-	}
-	
-	return result;
+	debug_printf("renaming from %s to %s was allowed\n", from, to);
+
+	return __rename(from, to);
 }
 
-int stat(const char * path, struct stat * sb)
-{
+int stat(const char * path, struct stat * sb) {
 #define stat(path, sb) syscall(SYS_stat, path, sb)
-	int result=0;
-	char newpath[260];
-		
-	*newpath=0;
-	if(!is_directory(path)&&__darwintrace_is_in_sandbox(path, newpath)==0)
-	{
-		errno=ENOENT;
-		result=-1;
-	}else
-	{
-		if(*newpath)
-			path=newpath;
-			
-		result=stat(path, sb);
+	int result = 0;
+	char newpath[MAXPATHLEN];
+
+	debug_printf("stat(%s)\n", path);
+	if (-1 == (result = stat(path, sb))) {
+		return -1;
 	}
-	
+
+	if (S_ISDIR(sb->st_mode)) {
+		return result;
+	}
+
+	*newpath = '\0';
+	if (!__darwintrace_is_in_sandbox(path, newpath)) {
+		errno = ENOENT;
+		return -1;
+	}
+
+	if (*newpath) {
+		result = stat(newpath, sb);
+	}
+
 	return result;
 #undef stat
 }
 
 #if defined(__DARWIN_64_BIT_INO_T) && !defined(_DARWIN_FEATURE_ONLY_64_BIT_INODE)
 
-int stat64(const char * path, struct stat64 * sb)
-{
+int stat64(const char * path, struct stat64 * sb) {
 #define stat64(path, sb) syscall(SYS_stat64, path, sb)
-	int result=0;
-	char newpath[260];
-		
-	*newpath=0;
-	if(!is_directory(path)&&__darwintrace_is_in_sandbox(path, newpath)==0)
-	{
-		errno=ENOENT;
-		result=-1;
-	}else
-	{
-		if(*newpath)
-			path=newpath;
-			
-		result=stat64(path, sb);
+	int result = 0;
+	char newpath[MAXPATHLEN];
+
+	debug_printf("stat64(%s)\n", path);
+	if (-1 == (result = stat64(path, sb))) {
+		return -1;
 	}
-	
+
+	if (S_ISDIR(sb->st_mode)) {
+		return result;
+	}
+
+	*newpath = '\0';
+	if (!__darwintrace_is_in_sandbox(path, newpath)) {
+		errno = ENOENT;
+		return -1;
+	}
+
+	if (*newpath) {
+		result = stat64(newpath, sb);
+	}
+
 	return result;
 #undef stat64
 }
 
-int stat$INODE64(const char * path, struct stat64 * sb)
-{
+int stat$INODE64(const char * path, struct stat64 * sb) {
     return stat64(path, sb);
 }
 
 #endif /* defined(__DARWIN_64_BIT_INO_T) && !defined(_DARWIN_FEATURE_ONLY_64_BIT_INODE) */
 
 
-int lstat(const char * path, struct stat * sb)
-{
+int lstat(const char * path, struct stat * sb) {
 #define lstat(path, sb) syscall(SYS_lstat, path, sb)
-	int result=0;
-	char newpath[260];
-	
-	*newpath=0;
-	if(!is_directory(path)&&__darwintrace_is_in_sandbox(path, newpath)==0)
-	{
-		errno=ENOENT;
-		result=-1;
-	}else
-	{
-		if(*newpath)
-			path=newpath;
-			
-		result=lstat(path, sb);
+	int result = 0;
+	char newpath[MAXPATHLEN];
+
+	debug_printf("lstat(%s)\n", path);
+	if (-1 == (result = lstat(path, sb))) {
+		return -1;
 	}
-	
+
+	if (S_ISDIR(sb->st_mode)) {
+		return result;
+	}
+
+	*newpath = '\0';
+	if (!__darwintrace_is_in_sandbox(path, newpath)) {
+		errno = ENOENT;
+		return -1;
+	}
+
+	if (*newpath) {
+		result = lstat(newpath, sb);
+	}
+
 	return result;
 #undef lstat
 }
 
 #if defined(__DARWIN_64_BIT_INO_T) && !defined(_DARWIN_FEATURE_ONLY_64_BIT_INODE)
 
-int lstat64(const char * path, struct stat64 * sb)
-{
+int lstat64(const char * path, struct stat64 * sb) {
 #define lstat64(path, sb) syscall(SYS_lstat64, path, sb)
-	int result=0;
-	char newpath[260];
-	
-	*newpath=0;
-	if(!is_directory(path)&&__darwintrace_is_in_sandbox(path, newpath)==0)
-	{
-		errno=ENOENT;
-		result=-1;
-	}else
-	{
-		if(*newpath)
-			path=newpath;
-			
-		result=lstat64(path, sb);
+	int result = 0;
+	char newpath[MAXPATHLEN];
+
+	debug_printf("lstat64(%s)\n", path);
+	if (-1 == (result = lstat64(path, sb))) {
+		return -1;
 	}
-	
+
+	if (S_ISDIR(sb->st_mode)) {
+		return result;
+	}
+
+	*newpath = '\0';
+	if (!__darwintrace_is_in_sandbox(path, newpath)) {
+		errno = ENOENT;
+		return -1;
+	}
+
+	if (*newpath) {
+		result = lstat64(newpath, sb);
+	}
+
 	return result;
 #undef lstat64
 }
 
-int lstat$INODE64(const char * path, struct stat64 * sb)
-{
+int lstat$INODE64(const char * path, struct stat64 * sb) {
     return lstat64(path, sb);
 }
 
 #endif /* defined(__DARWIN_64_BIT_INO_T) && !defined(_DARWIN_FEATURE_ONLY_64_BIT_INODE) */
+
+/**
+ * re-implementation of getdirent(2) and __getdirent64(2) preventing paths
+ * outside the sandbox to show up when reading the contents of a directory.
+ * Unfortunately, since we need to access the contents of the buffer, but the
+ * contents differ by architecture, we can not rely on the dirent structure
+ * defined by the header included by this program, because we don't know
+ * whether darwintrace.dylib has been compiled for 64bit or 32bit inodes. We
+ * thus copy both structs and decide at runtime.
+ */
+
+#ifdef __APPLE__
+/* only do this on mac, because fcntl(fd, F_GETPATH) might not be available on
+ * other systems, and because other system's syscall names are probably
+ * different anyway */
+
+#pragma pack(4)
+struct dirent32 {
+	ino_t d_ino;			/* file number of entry */
+	__uint16_t d_reclen;		/* length of this record */
+	__uint8_t  d_type; 		/* file type, see below */
+	__uint8_t  d_namlen;		/* length of string in d_name */
+	char d_name[__DARWIN_MAXNAMLEN + 1];	/* name must be no longer than this */
+};
+#pragma pack()
+
+struct dirent64  {
+	__uint64_t  d_ino;      /* file number of entry */
+	__uint64_t  d_seekoff;  /* seek offset (optional, used by servers) */
+	__uint16_t  d_reclen;   /* length of this record */
+	__uint16_t  d_namlen;   /* length of string in d_name */
+	__uint8_t   d_type;     /* file type, see below */
+	char      d_name[__DARWIN_MAXPATHLEN]; /* entry name (up to MAXPATHLEN bytes) */
+};
+
+size_t __getdirentries64(int fd, void *buf, size_t bufsize, __darwin_off_t *basep) {
+#define __getdirentries64(w,x,y,z) syscall(SYS_getdirentries64, (w), (x), (y), (z))
+	size_t sz = __getdirentries64(fd, buf, bufsize, basep);
+	char dirname[MAXPATHLEN];
+	size_t dnamelen;
+
+	if (-1 == fcntl(fd, F_GETPATH, dirname)) {
+		errno = EBADF;
+		return 0;
+	}
+
+	dnamelen = strlen(dirname);
+	if (dirname[dnamelen - 1] != '/') {
+		dirname[dnamelen] = '/';
+		dirname[dnamelen + 1] = '\0';
+		dnamelen++;
+	}
+
+	dnamelen = strlen(dirname);
+	size_t offset;
+	for (offset = 0; offset < sz;) {
+		struct dirent64 *dent = (struct dirent64 *)(((char *) buf) + offset);
+		dirname[dnamelen] = '\0';
+		strcat(dirname, dent->d_name);
+		if (!__darwintrace_is_in_sandbox(dirname, NULL)) {
+			debug_printf("__getdirentries64: filtered %s\n", dirname);
+			dent->d_ino = 0;
+		} else {
+			debug_printf("__getdirentries64:  allowed %s\n", dirname);
+		}
+		offset += dent->d_reclen;
+	}
+
+	return sz;
+#undef __getdirentries64
+}
+
+int getdirentries(int fd, char *buf, int nbytes, long *basep) {
+#define getdirentries(w,x,y,z) syscall(SYS_getdirentries, (w), (x), (y), (z))
+	size_t sz = getdirentries(fd, buf, nbytes, basep);
+	char dirname[MAXPATHLEN];
+	size_t dnamelen;
+
+	if (-1 == fcntl(fd, F_GETPATH, dirname)) {
+		errno = EBADF;
+		return 0;
+	}
+
+	dnamelen = strlen(dirname);
+	if (dirname[dnamelen - 1] != '/') {
+		dirname[dnamelen] = '/';
+		dirname[dnamelen + 1] = '\0';
+		dnamelen++;
+	}
+
+	size_t offset;
+	for (offset = 0; offset < sz;) {
+		struct dirent32 *dent = (struct dirent32 *)(buf + offset);
+		dirname[dnamelen] = '\0';
+		strcat(dirname, dent->d_name);
+		if (!__darwintrace_is_in_sandbox(dirname, NULL)) {
+			debug_printf("getdirentries: filtered %s\n", dirname);
+			dent->d_ino = 0;
+		} else {
+			debug_printf("getdirentries:  allowed %s\n", dirname);
+		}
+		offset += dent->d_reclen;
+	}
+
+	return sz;
+#undef getdirentries
+}
+#endif /* __APPLE__ */

Modified: branches/new-help-system/base/src/images_to_archives.tcl
===================================================================
--- branches/new-help-system/base/src/images_to_archives.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/images_to_archives.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -92,19 +92,21 @@
             set targetdir [file dirname $location]
         } else {
             set targetdir [file join ${macports::registry.path} software ${iname}]
-            file mkdir $targetdir
+        }
+        if {$location == "" || ![file isdirectory $location]} {
             set contents [$iref imagefiles]
         }
+        file mkdir $targetdir
         set newlocation [file join $targetdir $archivename]
 
         if {$found} {
             file rename $oldarchivefullpath $newlocation
-        } elseif {$installtype == "image"} {
+        } elseif {$installtype == "image" && [file isdirectory $location]} {
             # create archive from image dir
-            system "cd $location && $tarcmd -cjf $newlocation * > ${targetdir}/error.log 2>&1"
+            system -W $location "$tarcmd -cjf $newlocation * > ${targetdir}/error.log 2>&1"
             file delete -force ${targetdir}/error.log
         } else {
-            # direct mode, create archive from installed files
+            # direct mode (or missing image dir), create archive from installed files
             # we tell tar to read filenames from a file so as not to run afoul of command line length limits
             set fd [open ${targetdir}/tarlist w]
             foreach entry $contents {

Modified: branches/new-help-system/base/src/machista1.0/Makefile.in
===================================================================
--- branches/new-help-system/base/src/machista1.0/Makefile.in	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/machista1.0/Makefile.in	2012-12-15 00:33:09 UTC (rev 100533)
@@ -40,6 +40,9 @@
 	rm -f ${TESTS}
 	rm -rf ${TESTS:%=%.dSYM}
 
+distclean::
+	rm -f Makefile
+
 test:: ${TESTS}
 	${TESTS}
 

Modified: branches/new-help-system/base/src/machista1.0/libmachista.c
===================================================================
--- branches/new-help-system/base/src/machista1.0/libmachista.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/machista1.0/libmachista.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -42,14 +42,17 @@
 #include <err.h>
 #include <string.h>
 
+#ifdef __MACH__
 #include <mach-o/fat.h>
 #include <mach-o/loader.h>
 
 #include <libkern/OSAtomic.h>
+#endif
 
 #include "libmachista.h"
 #include "hashmap.h"
 
+#ifdef __MACH__
 /* Tiger compatibility */
 #ifndef LC_RPATH
 #define LC_RPATH       (0x1c | LC_REQ_DYLD)    /* runpath additions */
@@ -66,6 +69,7 @@
 #ifndef LC_REEXPORT_DYLIB
 #define LC_REEXPORT_DYLIB (0x1f | LC_REQ_DYLD) /* load and re-export dylib */
 #endif
+#endif /* __MACH__ */
 
 typedef struct macho_input {
     const void *data;
@@ -77,6 +81,7 @@
     HashMap *result_map;
 };
 
+#ifdef __MACH__
 /* Verify that the given range is within bounds. */
 static const void *macho_read (macho_input_t *input, const void *address, size_t length) {
     if ((((uint8_t *) address) - ((uint8_t *) input->data)) + length > input->length) {
@@ -92,6 +97,7 @@
     void *result = ((uint8_t *) address) + offset;
     return macho_read(input, result, length);
 }
+#endif
 
 /* return a human readable formatted version number. the result must be free()'d. */
 char *macho_format_dylib_version (uint32_t version) {
@@ -101,13 +107,18 @@
 }
 
 const char *macho_get_arch_name (cpu_type_t cputype) {
+#ifdef __MACH__
     const NXArchInfo *archInfo = NXGetArchInfoFromCpuType(cputype, CPU_SUBTYPE_MULTIPLE);	
     if (!archInfo) {
         return NULL;
     }
     return archInfo->name;
+#else
+    return NULL;
+#endif
 }
 
+#ifdef __MACH__
 /* Some byteswap wrappers */
 static uint32_t macho_swap32 (uint32_t input) {
     return OSSwapInt32(input);
@@ -149,6 +160,7 @@
     memset(mlt, 0, sizeof(macho_loadcmd_t));
     return mlt;
 }
+#endif
 
 /* Frees a previously allocated macho_loadcmd_t and all it's associated resources */
 static void free_macho_loadcmd_t (macho_loadcmd_t *mlt) {
@@ -191,6 +203,7 @@
     free(mt);
 }
 
+#ifdef __MACH__
 /* Creates a new element in the architecture list of a macho_t (mt_archs), increases the counter of
  * architectures (mt_arch_count) and returns a pointer to the newly allocated element or NULL on
  * error */
@@ -220,9 +233,11 @@
 
     return mat->mat_loadcmds;
 }
+#endif
 
 /* Parse a Mach-O header */
 static int parse_macho (macho_t *mt, macho_input_t *input) {
+#ifdef __MACH__
     /* Read the file type. */
     const uint32_t *magic = macho_read(input, input->data, sizeof(uint32_t));
     if (magic == NULL)
@@ -418,10 +433,14 @@
     }
 
     return MACHO_SUCCESS;
+#else
+    return 0;
+#endif
 }
 
 /* Parse a (possible Mach-O) file. For a more detailed description, see the header */
 int macho_parse_file(macho_handle_t *handle, const char *filepath, const macho_t **res) {
+#ifdef __MACH__
     int fd;
     struct stat st;
     void *data;
@@ -481,6 +500,9 @@
     close(fd);
 
     return ret;
+#else
+    return 0;
+#endif
 }
 
 /* Create a new macho_handle_t. More information on this function is available in the header */

Modified: branches/new-help-system/base/src/machista1.0/libmachista.h
===================================================================
--- branches/new-help-system/base/src/machista1.0/libmachista.h	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/machista1.0/libmachista.h	2012-12-15 00:33:09 UTC (rev 100533)
@@ -38,7 +38,11 @@
  * The name a pun: machista is the spanish translation of "macho".
  */
 
+#ifdef __MACH__
 #include <mach-o/arch.h>
+#else
+typedef int cpu_type_t;
+#endif
 #include <inttypes.h>
 
 #define MACHO_SUCCESS   (0x00)

Modified: branches/new-help-system/base/src/machista1.0/machista.i
===================================================================
--- branches/new-help-system/base/src/machista1.0/machista.i	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/machista1.0/machista.i	2012-12-15 00:33:09 UTC (rev 100533)
@@ -6,7 +6,9 @@
 %}
 
 %inline %{
+#ifdef __MACH__
     #include <mach-o/arch.h>
+#endif
     #include <inttypes.h>
     #include <stdint.h>
 %}

Modified: branches/new-help-system/base/src/machista1.0/machista_wrap.c
===================================================================
--- branches/new-help-system/base/src/machista1.0/machista_wrap.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/machista1.0/machista_wrap.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1674,7 +1674,9 @@
     #include "libmachista.h"
 
 
+#ifdef __MACH__
     #include <mach-o/arch.h>
+#endif
     #include <inttypes.h>
     #include <stdint.h>
 

Modified: branches/new-help-system/base/src/machista1.0/tests/libmachista-test.c
===================================================================
--- branches/new-help-system/base/src/machista1.0/tests/libmachista-test.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/machista1.0/tests/libmachista-test.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,3 +1,5 @@
+#ifdef __MACH__
+
 #include <libmachista.h>
 #include <limits.h>
 #include <mach-o/arch.h>
@@ -340,13 +342,18 @@
 	free(version_string);
 	return false;
 }
+#endif
 
 int main() {
+#ifdef __MACH__
 	bool result = true;
 	result &= test_destroy_null();
 	result &= test_handle();
 	result &= test_format_dylib_version();
 	result &= test_libsystem();
-	exit(!result);
+	return !result;
+#else
+	return 0;
+#endif
 }
 

Modified: branches/new-help-system/base/src/macports1.0/macports.tcl
===================================================================
--- branches/new-help-system/base/src/macports1.0/macports.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/macports1.0/macports.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -51,7 +51,7 @@
         master_site_local patch_site_local archive_site_local buildfromsource \
         revupgrade_autorun revupgrade_mode revupgrade_check_id_loadcmds \
         host_blacklist preferred_hosts\
-        packagemaker_path"
+        packagemaker_path default_compiler"
     variable user_options "submitter_name submitter_email submitter_key"
     variable portinterp_options "\
         portdbpath porturl portpath portbuildpath auto_path prefix prefix_frozen portsharepath \
@@ -61,7 +61,7 @@
         mp_remote_url mp_remote_submit_url configureccache ccache_dir ccache_size configuredistcc configurepipe buildnicevalue buildmakejobs \
         applications_dir current_phase frameworks_dir developer_dir universal_archs build_arch \
         os_arch os_endian os_version os_major os_platform macosx_version macosx_deployment_target \
-        packagemaker_path $user_options"
+        packagemaker_path default_compiler $user_options"
 
     # deferred options are only computed when needed.
     # they are not exported to the trace thread.
@@ -425,7 +425,7 @@
     global macports::developer_dir macports::os_major macports::xcodeversion
 
     trace remove variable macports::developer_dir read macports::set_developer_dir
-
+    
     # Look for xcodeselect, and make sure it has a valid value
     if {![catch {findBinary xcode-select $macports::autoconf::xcode_select_path} xcodeselect]} {
 
@@ -443,10 +443,7 @@
         # searching by bundle identifier for various Xcode versions (3.x and 4.x)
         set installed_xcodes {}
         if {![catch {findBinary mdfind $macports::autoconf::mdfind_path} mdfind]} {
-            set installed_xcodes [concat \
-                [exec $mdfind "kMDItemCFBundleIdentifier == 'com.apple.Xcode'"] \
-                [exec $mdfind "kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"] \
-                ]
+            set installed_xcodes [exec $mdfind "kMDItemCFBundleIdentifier == 'com.apple.Xcode' || kMDItemCFBundleIdentifier == 'com.apple.dt.Xcode'"]
         }
         
         # In case mdfind metadata wasn't complete, also look in two well-known locations for Xcode.app
@@ -468,9 +465,16 @@
             foreach xcode $installed_xcodes {
                 set vers [exec $mdls -raw -name kMDItemVersion $xcode]
                 if {$vers == "(null)"} { set vers "unknown" }
-                if {[vercmp $vers 4.3] >= 0 || [_is_valid_developer_dir "${xcode}/Contents/Developer"]} {
+                if {[_is_valid_developer_dir "${xcode}/Contents/Developer"]} {
+                    # Though xcode-select shipped with xcode 4.3 supports and encourages
+                    # direct use of the app path, older xcode-select does not.
+                    # Specify the Contents/Developer directory if it exists
+                    ui_error "    sudo xcode-select -switch ${xcode}/Contents/Developer # version ${vers}"
+                } elseif {[vercmp $vers 4.3] >= 0} {
+                    # Future proofing: fall back to the app-path only for xcode >= 4.3, since Contents/Developer doesn't exist
                     ui_error "    sudo xcode-select -switch ${xcode} # version ${vers}"
                 } elseif {[_is_valid_developer_dir "${xcode}/../.."]} {
+                    # Older xcode (< 4.3) is below the developer directory
                     ui_error "    sudo xcode-select -switch [file normalize ${xcode}/../..] # version ${vers}"
                 } else {
                     ui_error "    # malformed Xcode at ${xcode}, version ${vers}"
@@ -478,7 +482,7 @@
             }
         } else {
             ui_error "No Xcode installation was found."
-            ui_error "Please install Xcode and run xcode-select to specify its location."
+            ui_error "Please install Xcode and/or run xcode-select to specify its location."
         }
         ui_error
     }
@@ -502,7 +506,7 @@
     }
 
     # Verify that the directory has some key subdirectories
-    foreach subdir {Headers Library usr} {
+    foreach subdir {Library usr} {
         if {![file isdirectory "${dir}/${subdir}"]} {
             return 0
         }
@@ -636,7 +640,7 @@
             set fd [open $file r]
             while {[gets $fd line] >= 0} {
                 if {[regexp {^(\w+)([ \t]+(.*))?$} $line match option ignore val] == 1} {
-                    if {[lsearch $bootstrap_options $option] >= 0} {
+                    if {[lsearch -exact $bootstrap_options $option] >= 0} {
                         set macports::$option [string trim $val]
                         global macports::$option
                     }
@@ -652,7 +656,7 @@
         set fd [open $per_user r]
         while {[gets $fd line] >= 0} {
             if {[regexp {^(\w+)([ \t]+(.*))?$} $line match option ignore val] == 1} {
-                if {[lsearch $user_options $option] >= 0} {
+                if {[lsearch -exact $user_options $option] >= 0} {
                     set macports::$option $val
                     global macports::$option
                 }
@@ -1041,9 +1045,16 @@
         } else {
             set macports::developer_dir ""
         }
+    } else {
+        if {$os_platform == "darwin" && ![file isdirectory $developer_dir]} {
+            ui_warn "Your developer_dir setting in macports.conf points to a non-existing directory.\
+                Since this is known to cause problems, please correct the setting or comment it and let\
+                macports auto-discover the correct path."
+        }
     }
 
-    if {[getuid] == 0 && $os_major >= 11 && $os_platform == "darwin" && [vercmp $xcodeversion 4.3] >= 0} {
+    if {[getuid] == 0 && $os_major >= 11 && $os_platform == "darwin" && 
+            [file isfile "${macports::user_home}/Library/Preferences/com.apple.dt.Xcode.plist"]} {
         macports::copy_xcode_plist $env(HOME)
     }
 
@@ -1132,7 +1143,7 @@
         if {[macports::getprotocol $default_source_url] == "file" || [macports::getprotocol $default_source_url] == "rsync"} {
             set default_portindex [macports::getindex $default_source_url]
             if {[file exists $default_portindex] && [expr [clock seconds] - [file mtime $default_portindex]] > 1209600} {
-                ui_warn "port definitions are more than two weeks old, consider using selfupdate"
+                ui_warn "port definitions are more than two weeks old, consider updating them by running 'port selfupdate'."
             }
         }
     }
@@ -1288,6 +1299,9 @@
     $workername alias get_pingtime macports::get_pingtime
     $workername alias set_pingtime macports::set_pingtime
 
+    # archive_sites.conf handling
+    $workername alias get_archive_sites_conf_values macports::get_archive_sites_conf_values
+
     foreach opt $portinterp_options {
         if {![info exists $opt]} {
             global macports::$opt
@@ -1863,7 +1877,7 @@
         ui_error "Failed to install $portname"
         ui_debug "$::errorInfo"
         if {[info exists ::logenabled] && $::logenabled && [info exists ::debuglogname]} {
-            ui_notice "Please see the log file for $portname for details:\n    $::debuglogname"
+            ui_notice "Please see the log file for port $portname for details:\n    $::debuglogname"
         }
         macports::pop_log
         return 1
@@ -2012,7 +2026,7 @@
 
     foreach deptype $deptypes {
         if {![info exists portinfo($deptype)]} {
-            set portinfo($deptype) ""
+            continue
         }
         foreach depspec $portinfo($deptype) {
             set dep_portname [$workername eval _get_dep_port $depspec]
@@ -2039,7 +2053,7 @@
                         }
                     }
                     if {[llength $missing] > 0} {
-                        if {[info exists dep_portinfo(variants)] && [lsearch $dep_portinfo(variants) universal] != -1} {
+                        if {[info exists dep_portinfo(variants)] && [lsearch -exact $dep_portinfo(variants) universal] != -1} {
                             # dep offers a universal variant
                             if {[llength $active_archs] == 1} {
                                 # not installed universal
@@ -2187,6 +2201,8 @@
                 set portdir [macports::getportdir $source]
                 set svn_cmd ""
                 catch {set svn_cmd [macports::findBinary svn]}
+                set git_cmd ""
+                catch {set git_cmd [macports::findBinary git]}
                 if {$svn_cmd != "" && ([file exists $portdir/.svn] || ![catch {exec $svn_cmd info $portdir > /dev/null 2>@1}])} {
                     set svn_commandline "$svn_cmd update --non-interactive ${portdir}"
                     ui_debug $svn_commandline
@@ -2211,6 +2227,30 @@
                         incr numfailed
                         continue
                     }
+                } elseif {$git_cmd != "" && [file exists $portdir/.git]} {
+                    set git_commandline "pushd $portdir ; $git_cmd pull --rebase ; popd"
+                    ui_debug $git_commandline
+                    if {
+                        [catch {
+                            if {[getuid] == 0} {
+                                set euid [geteuid]
+                                set egid [getegid]
+                                ui_debug "changing euid/egid - current euid: $euid - current egid: $egid"
+                                setegid [name_to_gid [file attributes $portdir -group]]
+                                seteuid [name_to_uid [file attributes $portdir -owner]]
+                            }
+                            system $git_commandline
+                            if {[getuid] == 0} {
+                                seteuid $euid
+                                setegid $egid
+                            }
+                        }]
+                    } {
+                        ui_debug "$::errorInfo"
+                        ui_error "Synchronization of the local ports tree failed doing a git pull --rebase"
+                        incr numfailed
+                        continue
+                    }
                 }
                 set needs_portindex 1
             }
@@ -2538,7 +2578,7 @@
         }
     }
     if {!$found} {
-        return -code error "No index(es) found! Have you synced your source indexes?"
+        return -code error "No index(es) found! Have you synced your port definitions? Try running 'port selfupdate'."
     }
 
     return $matches
@@ -2695,7 +2735,7 @@
         }
     }
     if {!$found} {
-        return -code error "No index(es) found! Have you synced your source indexes?"
+        return -code error "No index(es) found! Have you synced your port definitions? Try running 'port selfupdate'."
     }
 
     return $matches
@@ -2716,11 +2756,13 @@
         set source [lindex $source 0]
         set index [macports::getindex $source]
         if {![file exists ${index}]} {
+            incr sourceno
             continue
         }
         if {![file exists ${index}.quick]} {
             ui_warn "No quick index file found, attempting to generate one for source: $source"
             if {[catch {set quicklist [mports_generate_quickindex ${index}]}]} {
+                incr sourceno
                 continue
             }
         }
@@ -2728,6 +2770,7 @@
         if {![info exists quicklist]} {
             if {[catch {set fd [open ${index}.quick r]} result]} {
                 ui_warn "Can't open quick index file for source: $source"
+                incr sourceno
                 continue
             } else {
                 set quicklist [read $fd]
@@ -2740,7 +2783,7 @@
         incr sourceno 1
     }
     if {!$sourceno} {
-        ui_warn "No index(es) found! Have you synced your source indexes?"
+        ui_warn "No index(es) found! Have you synced your port definitions? Try running 'port selfupdate'."
     }
 }
 
@@ -2831,11 +2874,10 @@
 proc mportdepends {mport {target ""} {recurseDeps 1} {skipSatisfied 1} {accDeps 0}} {
 
     array set portinfo [mportinfo $mport]
-    set deptypes {}
     if {$accDeps} {
-        upvar depspec_seen depspec_seen
+        upvar port_seen port_seen
     } else {
-        array set depspec_seen {}
+        array set port_seen {}
     }
 
     # progress indicator
@@ -2870,17 +2912,19 @@
             continue
         }
         foreach depspec $portinfo($deptype) {
-            # skip depspec/archs combos we've already seen, and ones with less archs than ones we've seen
-            set seenkey "${depspec},[join $required_archs ,]"
+            # get the portname that satisfies the depspec
+            set dep_portname [$workername eval _get_dep_port $depspec]
+            # skip port/archs combos we've already seen, and ones with the same port but less archs than ones we've seen (or noarch)
+            set seenkey "${dep_portname},[join $required_archs ,]"
             set seen 0
-            if {[info exists depspec_seen($seenkey)]} {
+            if {[info exists port_seen($seenkey)]} {
                 set seen 1
             } else {
-                set prev_seenkeys [array names depspec_seen ${depspec},*]
+                set prev_seenkeys [array names port_seen ${dep_portname},*]
                 set nrequired [llength $required_archs]
                 foreach key $prev_seenkeys {
                     set key_archs [lrange [split $key ,] 1 end]
-                    if {[llength $key_archs] > $nrequired} {
+                    if {$key_archs == "noarch" || $required_archs == "noarch" || [llength $key_archs] > $nrequired} {
                         set seen 1
                         set seenkey $key
                         break
@@ -2888,9 +2932,9 @@
                 }
             }
             if {$seen} {
-                if {$depspec_seen($seenkey) != 0} {
+                if {$port_seen($seenkey) != 0} {
                     # nonzero means the dep is not satisfied, so we have to record it
-                    ditem_append_unique $mport requires $depspec_seen($seenkey)
+                    ditem_append_unique $mport requires $port_seen($seenkey)
                 }
                 continue
             }
@@ -2899,8 +2943,6 @@
             # If we don't skip or if it is not, add it to the list.
             set present [_mportispresent $mport $depspec]
 
-            # get the portname that satisfies the depspec
-            set dep_portname [$workername eval _get_dep_port $depspec]
             if {!$skipSatisfied && $dep_portname == ""} {
                 set dep_portname [lindex [split $depspec :] end]
             }
@@ -2936,15 +2978,16 @@
                 } elseif {[info exists dep_portinfo(installs_libs)] && !$dep_portinfo(installs_libs)} {
                     set check_archs 0
                 }
-                lappend options subport $dep_portinfo(name)
+                set dep_options $options
+                lappend dep_options subport $dep_portinfo(name)
                 # Figure out the depport. Check the open_mports list first, since
                 # we potentially leak mport references if we mportopen each time,
                 # because mportexec only closes each open mport once.
-                set depport [dlist_match_multi $macports::open_mports [list porturl $dep_portinfo(porturl) options $options variations $variations]]
-                
+                set depport [dlist_match_multi $macports::open_mports [list porturl $dep_portinfo(porturl) options $dep_options]]
+
                 if {$depport == {}} {
                     # We haven't opened this one yet.
-                    set depport [mportopen $dep_portinfo(porturl) $options $variations]
+                    set depport [mportopen $dep_portinfo(porturl) $dep_options $variations]
                 }
             }
 
@@ -2953,18 +2996,18 @@
                 && ![macports::_mport_supports_archs $depport $required_archs]} {
 
                 set supported_archs [_mportkey $depport supported_archs]
+                array unset variation_array
+                array set variation_array [[ditem_key $depport workername] eval "array get variations"]
                 mportclose $depport
                 set arch_mismatch 1
                 set has_universal 0
                 if {[info exists dep_portinfo(variants)] && [lsearch -exact $dep_portinfo(variants) universal] != -1} {
                     # a universal variant is offered
                     set has_universal 1
-                    array unset variation_array
-                    array set variation_array $variations
                     if {![info exists variation_array(universal)] || $variation_array(universal) != "+"} {
                         set variation_array(universal) +
                         # try again with +universal
-                        set depport [mportopen $dep_portinfo(porturl) $options [array get variation_array]]
+                        set depport [mportopen $dep_portinfo(porturl) $dep_options [array get variation_array]]
                         if {[macports::_mport_supports_archs $depport $required_archs]} {
                             set arch_mismatch 0
                         }
@@ -2985,9 +3028,11 @@
                 # Append the sub-port's provides to the port's requirements list.
                 set depport_provides "[ditem_key $depport provides]"
                 ditem_append_unique $mport requires $depport_provides
-                set depspec_seen($seenkey) $depport_provides
-            } else {
-                set depspec_seen($seenkey) 0
+                # record actual archs we ended up getting
+                set port_seen(${dep_portname},[join [macports::_mport_archs $depport] ,]) $depport_provides
+            } elseif {$present && $dep_portname != ""} {
+                # record actual installed archs
+                set port_seen(${dep_portname},[join [macports::_active_archs $dep_portname] ,]) 0
             }
         }
     }
@@ -3011,8 +3056,7 @@
     if {$required_archs == "noarch"} {
         return 1
     }
-    set workername [ditem_key $mport workername]
-    set provided_archs [$workername eval get_canonical_archs]
+    set provided_archs [_mport_archs $mport]
     if {$provided_archs == "noarch"} {
         return 1
     }
@@ -3024,17 +3068,21 @@
     return 1
 }
 
+# return the archs of the given mport
+proc macports::_mport_archs {mport} {
+    set workername [ditem_key $mport workername]
+    return [$workername eval get_canonical_archs]
+}
+
 # check if the active version of a port supports the given archs
 proc macports::_active_supports_archs {portname required_archs} {
     if {$required_archs == "noarch"} {
         return 1
     }
-    if {[catch {set ilist [registry::active $portname]}]} {
+    if {[catch {registry::active $portname}]} {
         return 0
     }
-    set i [lindex $ilist 0]
-    set regref [registry::open_entry $portname [lindex $i 1] [lindex $i 2] [lindex $i 3] [lindex $i 5]]
-    set provided_archs [registry::property_retrieve $regref archs]
+    set provided_archs [_active_archs $portname]
     if {$provided_archs == "noarch" || $provided_archs == "" || $provided_archs == 0} {
         return 1
     }
@@ -3046,6 +3094,16 @@
     return 1
 }
 
+# get the archs for a given active port
+proc macports::_active_archs {portname} {
+    if {[catch {set ilist [registry::active $portname]}]} {
+        return ""
+    }
+    set i [lindex $ilist 0]
+    set regref [registry::open_entry $portname [lindex $i 1] [lindex $i 2] [lindex $i 3] [lindex $i 5]]
+    return [registry::property_retrieve $regref archs]
+}
+
 # print an error message explaining why a port's archs are not provided by a dependency
 proc macports::_explain_arch_mismatch {port dep required_archs supported_archs has_universal} {
     global macports::universal_archs
@@ -3130,7 +3188,8 @@
         mpkg        -
         rpm         -
         dpkg        {
-            if {[$workername eval _archive_available]} {
+            if {[global_option_isset ports_binary_only] ||
+                (![global_option_isset ports_source_only] && [$workername eval _archive_available])} {
                 return "depends_lib depends_run"
             } else {
                 return "depends_fetch depends_extract depends_build depends_lib depends_run"
@@ -3139,8 +3198,9 @@
         install     -
         activate    -
         ""          {
-            if {[$workername eval registry_exists \$subport \$version \$revision \$portvariants]
-                || [$workername eval _archive_available]} {
+            if {[global_option_isset ports_binary_only] ||
+                [$workername eval registry_exists \$subport \$version \$revision \$portvariants]
+                || (![global_option_isset ports_source_only] && [$workername eval _archive_available])} {
                 return "depends_lib depends_run"
             } else {
                 return "depends_fetch depends_extract depends_build depends_lib depends_run"
@@ -3344,12 +3404,16 @@
 }
 
 # upgrade API wrapper procedure
-# return codes: 0 = success, 1 = general failure, 2 = port name not found in index
+# return codes:
+#   0 = success
+#   1 = general failure
+#   2 = port name not found in index
+#   3 = port not installed
 proc macports::upgrade {portname dspec variationslist optionslist {depscachename ""}} {
     # only installed ports can be upgraded
     if {![registry::entry_exists_for_name $portname]} {
         ui_error "$portname is not installed"
-        return 1
+        return 3
     }
     if {![string match "" $depscachename]} {
         upvar $depscachename depscache
@@ -3390,11 +3454,11 @@
 
     # Is this a rev-upgrade-called run?
     set is_revupgrade no
-    if {[macports::global_option_isset ports_revupgrade]} {
+    if {[info exists options(ports_revupgrade)] && $options(ports_revupgrade)} {
         set is_revupgrade yes
     }
     set is_revupgrade_second_run no
-    if {[macports::global_option_isset ports_revupgrade_second_run]} {
+    if {[info exists options(ports_revupgrade_second_run)] && $options(ports_revupgrade_second_run)} {
         set is_revupgrade_second_run yes
     }
 
@@ -3445,7 +3509,7 @@
                 array set portinfo [mportinfo $workername]
                 
                 # upgrade its dependencies first
-                set status [_upgrade_dependencies portinfo depscache variationslist options yes]
+                set status [_upgrade_dependencies portinfo depscache variationslist options]
                 if {$status != 0 && $status != 2 && ![ui_isset ports_processall]} {
                     catch {mportclose $workername}
                     return $status
@@ -3654,8 +3718,10 @@
             ui_debug "platform mismatch ... upgrading!"
             set build_override 1
         } elseif {$is_revupgrade_second_run} {
+            ui_debug "rev-upgrade override ... upgrading (from source)!"
             set build_override 1
         } elseif {$is_revupgrade} {
+            ui_debug "rev-upgrade override ... upgrading!"
             # in the first run of rev-upgrade, only activate possibly already existing files and check for missing dependencies
             set will_install yes
         } else {
@@ -3673,17 +3739,19 @@
     }
 
     set will_build no
+    set already_installed [registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]
     # avoid building again unnecessarily
     if {$will_install &&
         ([info exists options(ports_upgrade_force)]
             || $build_override == 1
-            || ![registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)])} {
+            || !$already_installed)} {
         set will_build yes
     }
 
     # first upgrade dependencies
     if {![info exists options(ports_nodeps)] && !$is_revupgrade} {
-        set status [_upgrade_dependencies portinfo depscache variationslist options $will_build]
+        # the last arg is because we might have to build from source if a rebuild is being forced
+        set status [_upgrade_dependencies portinfo depscache variationslist options [expr $will_build && $already_installed]]
         if {$status != 0 && $status != 2 && ![ui_isset ports_processall]} {
             catch {mportclose $workername}
             return $status
@@ -3735,7 +3803,7 @@
     }
 
     # are we installing an existing version due to force or epoch override?
-    if {[registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]
+    if {$already_installed
         && ([info exists options(ports_upgrade_force)] || $build_override == 1)} {
          ui_debug "Uninstalling $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants)"
         # we have to force the uninstall in case of dependents
@@ -3867,7 +3935,7 @@
 # upgrade_dependencies: helper proc for upgrade
 # Calls upgrade on each dependency listed in the PortInfo.
 # Uses upvar to access the variables.
-proc macports::_upgrade_dependencies {portinfoname depscachename variationslistname optionsname {build_needed yes}} {
+proc macports::_upgrade_dependencies {portinfoname depscachename variationslistname optionsname {build_needed no}} {
     upvar $portinfoname portinfo $depscachename depscache \
           $variationslistname variationslist \
           $optionsname options
@@ -3885,17 +3953,18 @@
     set saved_do_dependents [info exists options(ports_do_dependents)]
     unset -nocomplain options(ports_do_dependents)
 
-    set status 0
+    set parent_interp [ditem_key $parentworker workername]
     # each required dep type is upgraded
-    if {$build_needed} {
-        set dtypes {depends_fetch depends_extract depends_build depends_lib depends_run}
+    if {$build_needed && ![global_option_isset ports_binary_only]} {
+        set dtypes [_deptypes_for_target destroot $parent_interp]
     } else {
-        set dtypes {depends_lib depends_run}
+        set dtypes [_deptypes_for_target install $parent_interp]
     }
+
+    set status 0
     foreach dtype $dtypes {
         if {[info exists portinfo($dtype)]} {
             foreach i $portinfo($dtype) {
-                set parent_interp [ditem_key $parentworker workername]
                 set d [$parent_interp eval _get_dep_port $i]
                 if {![llength [array get depscache port:${d}]] && ![llength [array get depscache $i]]} {
                     if {$d != ""} {
@@ -4070,29 +4139,31 @@
     array set options $opts
 
     set files [registry::file search active 1 binary -null]
-    if {[llength $files] > 0} {
-        set files_count [llength $files]
+    set files_count [llength $files]
+    set fancy_output [expr ![macports::ui_isset ports_debug] && [isatty stdout]]
+    if {$files_count > 0} {
         registry::write {
             try {
                 ui_msg -nonewline "$macports::ui_prefix Updating database of binaries"
                 set i 1
                 foreach f $files {
-                    if {![macports::ui_isset ports_debug]} {
+                    if {$fancy_output} {
                         if {$files_count < 10000 || $i % 10 == 1 || $i == $files_count} {
                             ui_msg -nonewline "\r$macports::ui_prefix Updating database of binaries: [expr ($i * 1000 / $files_count) / 10.0]%"
                             flush stdout
                         }
                     }
-                    ui_debug "Updating binary flag for file $i of [llength $files]: [$f path]"
+                    set fpath [$f actual_path]
+                    ui_debug "Updating binary flag for file $i of $files_count: $fpath"
                     incr i
 
-                    if {0 != [catch {$f binary [fileIsBinary [$f path]]} fileIsBinaryError]} {
+                    if {0 != [catch {$f binary [fileIsBinary $fpath]} fileIsBinaryError]} {
                         # handle errors (e.g. file not found, permission denied) gracefully
-                        if {![macports::ui_isset ports_debug]} {
+                        if {$fancy_output} {
                             ui_msg ""
                         }
-                        ui_warn "Error determining file type of `[$f path]': $fileIsBinaryError"
-                        ui_warn "A file belonging to the `[[registry::entry owner [$f path]] name]' port is missing or unreadable. Consider reinstalling it."
+                        ui_warn "Error determining file type of `$fpath': $fileIsBinaryError"
+                        ui_warn "A file belonging to the `[[registry::entry owner $fpath] name]' port is missing or unreadable. Consider reinstalling it."
                     }
                 }
             } catch {*} {
@@ -4106,7 +4177,8 @@
     set broken_files {};
     set binaries [registry::file search active 1 binary 1]
     ui_msg -nonewline "$macports::ui_prefix Scanning binaries for linking errors"
-    if {[llength $binaries] > 0} {
+    set binary_count [llength $binaries]
+    if {$binary_count > 0} {
         set handle [machista::create_handle]
         if {$handle == "NULL"} {
             error "Error creating libmachista handle"
@@ -4115,18 +4187,18 @@
         array set files_warned_about [list]
 
         set i 1
-        set binary_count [llength $binaries]
         foreach b $binaries {
-            if {![macports::ui_isset ports_debug]} {
+            if {$fancy_output} {
                 if {$binary_count < 10000 || $i % 10 == 1 || $i == $binary_count} {
                     ui_msg -nonewline "\r$macports::ui_prefix Scanning binaries for linking errors: [expr ($i * 1000 / $binary_count) / 10.0]%"
                     flush stdout
                 }
             }
-            #ui_debug "$i/[llength $binaries]: [$b path]"
+            set bpath [$b actual_path]
+            #ui_debug "$i/$binary_count: $bpath"
             incr i
 
-            set resultlist [machista::parse_file $handle [$b path]]
+            set resultlist [machista::parse_file $handle $bpath]
             set returncode [lindex $resultlist 0]
             set result     [lindex $resultlist 1]
 
@@ -4134,12 +4206,12 @@
                 if {$returncode == $machista::EMAGIC} {
                     # not a Mach-O file
                     # ignore silently, these are only static libs anyway
-                    #ui_debug "Error parsing file [$b path]: [machista::strerror $returncode]"
+                    #ui_debug "Error parsing file ${bpath}: [machista::strerror $returncode]"
                 } else {
-                    if {![macports::ui_isset ports_debug]} {
+                    if {$fancy_output} {
                         ui_msg ""
                     }
-                    ui_warn "Error parsing file [$b path]: [machista::strerror $returncode]"
+                    ui_warn "Error parsing file ${bpath}: [machista::strerror $returncode]"
                 }
                 continue;
             }
@@ -4150,46 +4222,46 @@
                     if {[$architecture cget -mat_install_name] != "NULL" && [$architecture cget -mat_install_name] != ""} {
                         # check if this lib's install name actually refers to this file itself
                         # if this is not the case software linking against this library might have erroneous load commands
-                        if {0 == [catch {set idloadcmdpath [revupgrade_handle_special_paths [$b path] [$architecture cget -mat_install_name]]}]} {
+                        if {0 == [catch {set idloadcmdpath [revupgrade_handle_special_paths $bpath [$architecture cget -mat_install_name]]}]} {
                             if {[string index $idloadcmdpath 0] != "/"} {
-                                set port [registry::entry owner [$b path]]
+                                set port [registry::entry owner $bpath]
                                 if {$port != ""} {
                                     set portname [$port name]
                                 } else {
                                     set portname "<unknown-port>"
                                 }
-                                if {![macports::ui_isset ports_debug]} {
+                                if {$fancy_output} {
                                     ui_msg ""
                                 }
-                                ui_warn "ID load command in [$b path], arch [machista::get_arch_name [$architecture cget -mat_arch]] (belonging to port $portname) contains relative path"
+                                ui_warn "ID load command in ${bpath}, arch [machista::get_arch_name [$architecture cget -mat_arch]] (belonging to port $portname) contains relative path"
                             } elseif {![file exists $idloadcmdpath]} {
-                                set port [registry::entry owner [$b path]]
+                                set port [registry::entry owner $bpath]
                                 if {$port != ""} {
                                     set portname [$port name]
                                 } else {
                                     set portname "<unknown-port>"
                                 }
-                                if {![macports::ui_isset ports_debug]} {
+                                if {$fancy_output} {
                                     ui_msg ""
                                 }
-                                ui_warn "ID load command in [$b path], arch [machista::get_arch_name [$architecture cget -mat_arch]] refers to non-existant file $idloadcmdpath"
+                                ui_warn "ID load command in ${bpath}, arch [machista::get_arch_name [$architecture cget -mat_arch]] refers to non-existant file $idloadcmdpath"
                                 ui_warn "This is probably a bug in the $portname port and might cause problems in libraries linking against this file"
                             } else {
     
-                                set hash_this [sha256 file [$b path]]
+                                set hash_this [sha256 file $bpath]
                                 set hash_idloadcmd [sha256 file $idloadcmdpath]
     
                                 if {$hash_this != $hash_idloadcmd} {
-                                    set port [registry::entry owner [$b path]]
+                                    set port [registry::entry owner $bpath]
                                     if {$port != ""} {
                                         set portname [$port name]
                                     } else {
                                         set portname "<unknown-port>"
                                     }
-                                    if {![macports::ui_isset ports_debug]} {
+                                    if {$fancy_output} {
                                         ui_msg ""
                                     }
-                                    ui_warn "ID load command in [$b path], arch [machista::get_arch_name [$architecture cget -mat_arch]] refers to file $idloadcmdpath, which is a different file"
+                                    ui_warn "ID load command in ${bpath}, arch [machista::get_arch_name [$architecture cget -mat_arch]] refers to file $idloadcmdpath, which is a different file"
                                     ui_warn "This is probably a bug in the $portname port and might cause problems in libraries linking against this file"
                                 }
                             }
@@ -4199,7 +4271,7 @@
 
                 set archname [machista::get_arch_name [$architecture cget -mat_arch]]
                 if {![arch_runnable $archname]} {
-                    ui_debug "skipping $archname in [$b path] since this system can't run it anyway"
+                    ui_debug "skipping $archname in $bpath since this system can't run it anyway"
                     set architecture [$architecture cget -next]
                     continue
                 }
@@ -4207,7 +4279,7 @@
                 set loadcommand [$architecture cget -mat_loadcmds]
 
                 while {$loadcommand != "NULL"} {
-                    if {0 != [catch {set filepath [revupgrade_handle_special_paths [$b path] [$loadcommand cget -mlt_install_name]]}]} {
+                    if {0 != [catch {set filepath [revupgrade_handle_special_paths $bpath [$loadcommand cget -mlt_install_name]]}]} {
                         set loadcommand [$loadcommand cget -next]
                         continue;
                     }
@@ -4218,15 +4290,15 @@
 
                     if {$libreturncode != $machista::SUCCESS} {
                         if {![info exists files_warned_about($filepath)]} {
-                            if {![macports::ui_isset ports_debug]} {
+                            if {[macports::ui_isset ports_verbose]} {
                                 ui_msg ""
                             }
-                            ui_warn "Could not open $filepath: [machista::strerror $libreturncode]"
+                            ui_info "Could not open $filepath: [machista::strerror $libreturncode] (referenced from $bpath)"
                             set files_warned_about($filepath) yes
                         }
                         if {$libreturncode == $machista::EFILE} {
-                            ui_debug "Marking [$b path] as broken"
-                            lappend broken_files [$b path]
+                            ui_debug "Marking $bpath as broken"
+                            lappend broken_files $bpath
                         }
                         set loadcommand [$loadcommand cget -next]
                         continue;
@@ -4241,12 +4313,12 @@
                         }
 
                         if {[$loadcommand cget -mlt_version] != [$libarchitecture cget -mat_version] && [$loadcommand cget -mlt_comp_version] > [$libarchitecture cget -mat_comp_version]} {
-                            if {![macports::ui_isset ports_debug]} {
+                            if {[macports::ui_isset ports_verbose]} {
                                 ui_msg ""
                             }
-                            ui_warn "Incompatible library version of file [$loadcommand cget -mlt_install_name]: Expected [$loadcommand cget -mlt_comp_version], but got [$libarchitecture cget -mat_comp_version]"
-                            ui_debug "Marking [$b path] as broken"
-                            lappend broken_files [$b path]
+                            ui_info "Incompatible library version: $bpath requires version [machista::format_dylib_version [$loadcommand cget -mlt_comp_version]] or later, but $filepath provides version [machista::format_dylib_version [$libarchitecture cget -mat_comp_version]]"
+                            ui_debug "Marking $bpath as broken"
+                            lappend broken_files $bpath
                         }
 
                         set libarch_found true;
@@ -4256,10 +4328,10 @@
                     if {$libarch_found == false} {
                         ui_debug "Missing architecture [machista::get_arch_name [$architecture cget -mat_arch]] in file $filepath"
                         if {[path_is_in_prefix $filepath]} {
-                            ui_debug "Marking [$b path] as broken"
-                            lappend broken_files [$b path]
+                            ui_debug "Marking $bpath as broken"
+                            lappend broken_files $bpath
                         } else {
-                            ui_debug "Missing architecture [machista::get_arch_name [$architecture cget -mat_arch]] in file outside prefix referenced from [$b path]"
+                            ui_debug "Missing architecture [machista::get_arch_name [$architecture cget -mat_arch]] in file outside prefix referenced from $bpath"
                             # ui_debug "   How did you get that compiled anyway?"
                         }
                     }
@@ -4291,19 +4363,39 @@
         }
         set broken_ports [lsort -unique $broken_ports]
 
-        foreach port $broken_ports {
-            if {![info exists broken_port_counts([$port name])]} {
-                set broken_port_counts([$port name]) 0
+        set temp_broken_ports $broken_ports
+        set broken_ports {}
+
+        foreach port $temp_broken_ports {
+            set portname [$port name]
+            # don't try to rebuild ports that don't exist in the tree
+            if {${macports::revupgrade_mode} == "rebuild"} {
+                if {[catch {mportlookup $portname} result]} {
+                    ui_debug "$::errorInfo"
+                    error "lookup of portname $portname failed: $result"
+                }
+                if {[llength $result] < 2} {
+                    ui_warn "No port $portname found in the index; can't rebuild"
+                    ui_warn "Either your portindex is corrupt or $portname has been removed; consider uninstalling it."
+                    error "Port $portname not found in index"
+                }
             }
-            incr broken_port_counts([$port name])
-            if {$broken_port_counts([$port name]) > 3} {
-                ui_error "Port [$port name] is still broken after rebuiling it more than 3 times."
-                if {![macports::ui_isset ports_debug]} {
+            if {![info exists broken_port_counts($portname)]} {
+                set broken_port_counts($portname) 0
+            }
+            incr broken_port_counts($portname)
+            if {$broken_port_counts($portname) > 3} {
+                ui_error "Port $portname is still broken after rebuiling it more than 3 times."
+                if {$fancy_output} {
                     ui_error "Please run port -d -y rev-upgrade and use the output to report a bug."
                 }
-                error "Port [$port name] still broken after rebuilding [expr $broken_port_counts([$port name]) - 1] time(s)"
+                error "Port $portname still broken after rebuilding [expr $broken_port_counts($portname) - 1] time(s)"
+            } elseif {$broken_port_counts($portname) > 1 && [global_option_isset ports_binary_only]} {
+                error "Port $portname still broken after reinstalling -- can't rebuild due to binary-only mode"
             }
+            lappend broken_ports $port
         }
+        unset temp_broken_ports
 
         if {${macports::revupgrade_mode} != "rebuild"} {
             ui_msg "$macports::ui_prefix Found [llength $broken_ports] broken port(s):"
@@ -4323,6 +4415,7 @@
             # initialize with empty list
             set adjlist($port) {}
             set revadjlist($port) {}
+            ui_debug "Broken: [$port name]"
         }
 
         array set visited {}
@@ -4347,6 +4440,7 @@
                 set len [llength $adjlist($port)]
                 if {$len < $lowest_adj_number} {
                     set lowest_adj_port $port
+                    set lowest_adj_number $len
                 }
                 if {$len == 0} {
                     # this node has no further dependencies
@@ -4361,10 +4455,9 @@
                         set index [lsearch -exact $adjlist($target) $port]
                         set adjlist($target) [lreplace $adjlist($target) $index $index]
                     }
+
+                    break;
                 }
-
-                # start anew
-                break;
             }
 
             # if we arrive here and lowest_adj_number is larger than 0, then we
@@ -4391,40 +4484,27 @@
         # shared depscache for all ports that are going to be rebuilt
         array set depscache {}
         set status 0
+        array set my_options [array get macports::global_options]
         foreach port $topsort_ports {
-            if {![info exists depscache(port:[$port name])]} {
-
-                # convert variations into the format macports::upgrade needs
-                set minusvariant [lrange [split [$port negated_variants] "-"] 1 end]
-                set plusvariant  [lrange [split [$port variants]         "+"] 1 end]
-                set variants     [list]
-                foreach v $minusvariant {
-                    lappend variants $v "-"
-                }
-                foreach v $plusvariant {
-                    lappend variants $v "+"
-                }
-                array unset variations
-                array set variations $variants
-
+            set portname [$port name]
+            if {![info exists depscache(port:$portname)]} {
                 # set rev-upgrade options and nodeps if this is not the first run
-                set macports::global_options(ports_revupgrade) "yes"
-                unset -nocomplain macports::global_options(ports_nodeps)
-                unset -nocomplain macports::global_options(ports_revupgrade_second_run)
-                unset -nocomplain macports::global_options(ports_source_only)
-                if {$broken_port_counts([$port name]) > 1} {
-                    set macports::global_options(ports_revupgrade_second_run) yes
-                    set macports::global_options(ports_nodeps) yes
+                set my_options(ports_revupgrade) "yes"
+                unset -nocomplain my_options(ports_nodeps)
+                unset -nocomplain my_options(ports_revupgrade_second_run)
+                if {$broken_port_counts($portname) > 1} {
+                    set my_options(ports_revupgrade_second_run) yes
+                    set my_options(ports_nodeps) yes
                     # build from source only until the buildbot has some method of rev-upgrade, too
-                    set macports::global_options(ports_source_only) yes
+                    set my_options(ports_source_only) yes
                 }
 
                 # call macports::upgrade with ports_revupgrade option to rebuild the port
-                set status [macports::upgrade [$port name] "port:[$port name]" \
-                    [array get variations] [array get macports::global_options] depscache]
-                ui_debug "Rebuilding port [$port name] finished with status $status"
+                set status [macports::upgrade $portname "port:$portname" \
+                    {} [array get my_options] depscache]
+                ui_debug "Rebuilding port $portname finished with status $status"
                 if {$status != 0} {
-                    error "Error rebuilding [$port name]"
+                    error "Error rebuilding $portname"
                 }
             }
         }
@@ -4490,18 +4570,16 @@
     upvar $revadjlistname revadjlist
     upvar $visitedname visited
 
+    set visited($port) true
+
     ui_debug "Processing port [$port name] @[$port epoch]:[$port version]_[$port revision] [$port variants] [$port negated_variants]"
     set dependent_ports [$port dependents]
     foreach dep $dependent_ports {
-        if {[info exists visited($dep)]} {
-            continue
-        }
-        set visited($dep) true
         set is_broken_port false
 
         if {[info exists adjlist($dep)]} {
-            #ui_debug "Dependency [$dep name] is broken, adding edge from [[lindex $stack 0] name] to [$dep name]"
-            #ui_debug "Making [$dep name] new head of stack"
+            ui_debug "Dependent [$dep name] is broken, adding edge from [$dep name] to [[lindex $stack 0] name]"
+            ui_debug "Making [$dep name] new head of stack"
             # $dep is one of the broken ports
             # add an edge to the last broken port in the DFS
             lappend revadjlist([lindex $stack 0]) $dep
@@ -4511,9 +4589,11 @@
             
             set is_broken_port true
         }
-        revupgrade_buildgraph $dep stack adjlist revadjlist visited
+        if {![info exists visited($dep)]} {
+            revupgrade_buildgraph $dep stack adjlist revadjlist visited
+        }
         if {$is_broken_port} {
-            #ui_debug "Removing [$dep name] from stack"
+            ui_debug "Removing [$dep name] from stack"
             # remove $dep from the stack
             set stack [lrange $stack 1 end]
         }
@@ -4541,3 +4621,66 @@
     global macports::ping_cache
     set ping_cache($host) [list $ms [clock seconds]]
 }
+
+# read and cache archive_sites.conf (called from port1.0 code)
+proc macports::get_archive_sites_conf_values {} {
+    global macports::archive_sites_conf_values macports::autoconf::macports_conf_path
+    if {![info exists archive_sites_conf_values]} {
+        set archive_sites_conf_values {}
+        set all_names {}
+        array set defaults {applications_dir /Applications/MacPorts prefix /opt/local type tbz2}
+        set conf_file "${macports_conf_path}/archive_sites.conf"
+        set conf_options {applications_dir frameworks_dir name prefix type urls}
+        if {[file isfile $conf_file]} {
+            set fd [open $conf_file r]
+            while {[gets $fd line] >= 0} {
+                if {[regexp {^(\w+)([ \t]+(.*))?$} $line match option ignore val] == 1} {
+                    if {[lsearch -exact $conf_options $option] >= 0} {
+                        if {$option == "name"} {
+                            set cur_name $val
+                            lappend all_names $val
+                        } elseif {[info exists cur_name]} {
+                            set trimmedval [string trim $val]
+                            if {$option == "urls"} {
+                                set processed_urls {}
+                                foreach url $trimmedval {
+                                    lappend processed_urls ${url}:nosubdir
+                                }
+                                lappend archive_sites_conf_values portfetch::mirror_sites::sites($cur_name) $processed_urls
+                                set sites($cur_name) $processed_urls
+                            } else {
+                                lappend archive_sites_conf_values portfetch::mirror_sites::archive_${option}($cur_name) $trimmedval
+                                set archive_${option}($cur_name) $trimmedval
+                            }
+                        } else {
+                            ui_warn "archive_sites.conf: ignoring '$option' occurring before name"
+                        }
+                    } else {
+                        ui_warn "archive_sites.conf: ignoring unknown key '$option'"
+                    }
+                }
+            }
+            close $fd
+
+            # check for unspecified values and set to defaults
+            foreach cur_name $all_names {
+                foreach key [array names defaults] {
+                    if {![info exists archive_${key}($cur_name)]} {
+                        set archive_${key}($cur_name) $defaults($key)
+                        lappend archive_sites_conf_values portfetch::mirror_sites::archive_${key}($cur_name) $defaults($key)
+                    }
+                }
+                if {![info exists archive_frameworks_dir($cur_name)]} {
+                    set archive_frameworks_dir($cur_name) $archive_prefix($cur_name)/Library/Frameworks
+                    lappend archive_sites_conf_values portfetch::mirror_sites::archive_frameworks_dir($cur_name) $archive_frameworks_dir($cur_name)
+                }
+                if {![info exists sites($cur_name)]} {
+                    ui_warn "archive_sites.conf: no urls set for $cur_name"
+                    set sites($cur_name) ""
+                    lappend archive_sites_conf_values portfetch::mirror_sites::sites($cur_name) ""
+                }
+            }
+        }
+    }
+    return $archive_sites_conf_values
+}

Modified: branches/new-help-system/base/src/macports1.0/macports_dlist.tcl
===================================================================
--- branches/new-help-system/base/src/macports1.0/macports_dlist.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/macports1.0/macports_dlist.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -306,8 +306,11 @@
 	# Loop for as long as there are ditems in the dlist.
 	while {1} {
 		set ditem [$selector $dlist statusdict]
-		
+
 		if {$ditem == {}} {
+		    if {[llength $dlist] > 0} {
+		        ui_debug "dlist_eval: all entries in dependency list have unsatisfied dependencies; can't process"
+		    }
 			break
 		} else {
 			# $handler should return a unix status code, 0 for success.

Modified: branches/new-help-system/base/src/package1.0/package.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/package.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/package1.0/package.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -17,7 +17,7 @@
 # 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 "AS IS"
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

Modified: branches/new-help-system/base/src/package1.0/portarchivefetch.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portarchivefetch.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/package1.0/portarchivefetch.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -2,7 +2,7 @@
 # $Id$
 #
 # Copyright (c) 2002 - 2003 Apple Inc.
-# Copyright (c) 2004 - 2011 The MacPorts Project
+# Copyright (c) 2004 - 2012 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,7 @@
 package require Pextlib 1.0
 
 set org.macports.archivefetch [target_new org.macports.archivefetch portarchivefetch::archivefetch_main]
-target_init ${org.macports.archivefetch} portarchivefetch::archivefetch_init
+#target_init ${org.macports.archivefetch} portarchivefetch::archivefetch_init
 target_provides ${org.macports.archivefetch} archivefetch
 target_requires ${org.macports.archivefetch} main
 target_prerun ${org.macports.archivefetch} portarchivefetch::archivefetch_start
@@ -65,19 +65,46 @@
 default archive.subdir {${subport}}
 
 proc portarchivefetch::filter_sites {} {
-    global prefix porturl
+    global prefix frameworks_dir applications_dir porturl \
+        portfetch::mirror_sites::sites portfetch::mirror_sites::archive_type \
+        portfetch::mirror_sites::archive_prefix \
+        portfetch::mirror_sites::archive_frameworks_dir \
+        portfetch::mirror_sites::archive_applications_dir
+
+    # get defaults from ports tree resources
     set mirrorfile [get_full_archive_sites_path]
     if {[file exists $mirrorfile]} {
         source $mirrorfile
     }
+    # get archive_sites.conf values
+    foreach {key val} [get_archive_sites_conf_values] {
+        set $key $val
+    }
+
     set ret {}
     foreach site [array names portfetch::mirror_sites::archive_prefix] {
-        if {$portfetch::mirror_sites::archive_prefix($site) == $prefix} {
-            lappend ret $site
+        set missing 0
+        foreach var {archive_frameworks_dir archive_applications_dir archive_type} {
+            if {![info exists portfetch::mirror_sites::${var}($site)]} {
+                ui_warn "no $var configured for site '$site'"
+                set missing 1
+            }
         }
+        if {$missing} {
+            continue
+        }
+        if {$portfetch::mirror_sites::archive_prefix($site) == $prefix &&
+            $portfetch::mirror_sites::archive_frameworks_dir($site) == $frameworks_dir &&
+            $portfetch::mirror_sites::archive_applications_dir($site) == $applications_dir &&
+            ![catch {archiveTypeIsSupported $portfetch::mirror_sites::archive_type($site)}]} {
+            # using the archive type as a tag
+            lappend ret ${site}::$portfetch::mirror_sites::archive_type($site)
+        }
     }
-    if {[file rootname [file tail $porturl]] == [file rootname [file tail [get_portimage_path]]]} {
-        lappend ret [string range $porturl 0 end-[string length [file tail $porturl]]]
+
+    # check if porturl itself points to an archive
+    if {[file rootname [file tail $porturl]] == [file rootname [get_portimage_name]] && [file extension $porturl] != ""} {
+        lappend ret [string range $porturl 0 end-[string length [file tail $porturl]]]:[string range [file extension $porturl] 1 end]
         archive.subdir
     }
     return $ret
@@ -87,21 +114,22 @@
 
 # Checks possible archive files to assemble url lists for later fetching
 proc portarchivefetch::checkarchivefiles {urls} {
-    global all_archive_files archivefetch.fulldestpath portarchivetype \
-           version revision portvariants archive_sites
+    global all_archive_files archivefetch.fulldestpath archive_sites
     upvar $urls fetch_urls
 
     # Define archive directory path
-    set archive.path [get_portimage_path]
-    set archivefetch.fulldestpath [file dirname ${archive.path}]
+    set archivefetch.fulldestpath [file join [option portdbpath] incoming/verified]
+    set archive.rootname [file rootname [get_portimage_name]]
 
-    # throws an error if unsupported
-    archiveTypeIsSupported $portarchivetype
-
-    set archive.file [file tail ${archive.path}]
-    lappend all_archive_files ${archive.file}
-    if {[info exists archive_sites]} {
-        lappend fetch_urls archive_sites ${archive.file}
+    foreach entry [option archive_sites] {
+        # the archive type is used as a tag
+        set type [lindex [split $entry :] end]
+        if {![info exists seen($type)]} {
+            set archive.file "${archive.rootname}.${type}"
+            lappend all_archive_files ${archive.file}
+            lappend fetch_urls $type ${archive.file}
+            set seen($type) 1
+        }
     }
 }
 
@@ -141,16 +169,6 @@
         }
     }
     set incoming_path [file join [option portdbpath] incoming]
-    if {![file isdirectory $incoming_path]} {
-        if {[catch {file mkdir $incoming_path} result]} {
-            elevateToRoot "archivefetch"
-            set elevated yes
-            if {[catch {file mkdir $incoming_path} result]} {
-                return -code error [format [msgcat::mc "Unable to create archive fetch path: %s"] $result]
-            }
-        }
-    }
-    chownAsRoot ${archivefetch.fulldestpath}
     chownAsRoot $incoming_path
     if {[info exists elevated] && $elevated == yes} {
         dropPrivileges
@@ -172,8 +190,10 @@
     }
     set sorted no
 
+    set existing_archive [find_portarchive_path]
+
     foreach {url_var archive} $archivefetch_urls {
-        if {![file isfile ${archivefetch.fulldestpath}/${archive}]} {
+        if {![file isfile ${archivefetch.fulldestpath}/${archive}] && $existing_archive == ""} {
             ui_info "$UI_PREFIX [format [msgcat::mc "%s doesn't seem to exist in %s"] $archive ${archivefetch.fulldestpath}]"
             if {![file writable ${archivefetch.fulldestpath}]} {
                 return -code error [format [msgcat::mc "%s must be writable"] ${archivefetch.fulldestpath}]
@@ -237,9 +257,11 @@
                 }
                 file delete -force $signature
                 set archive_exists 1
+                break
             }
         } else {
             set archive_exists 1
+            break
         }
     }
     if {[info exists archive_exists]} {
@@ -258,24 +280,22 @@
 }
 
 # Initialize archivefetch target and call checkfiles.
-proc portarchivefetch::archivefetch_init {args} {
-    global porturl portarchivetype
-    # installing straight from a binary archive
-    if {[file rootname [file tail $porturl]] == [file rootname [file tail [get_portimage_path]]] && [file extension $porturl] != ""} {
-        set portarchivetype [string range [file extension $porturl] 1 end]
-    }
-    return 0
-}
+#proc portarchivefetch::archivefetch_init {args} {
+#    return 0
+#}
 
 proc portarchivefetch::archivefetch_start {args} {
     variable archivefetch_urls
-    global UI_PREFIX subport all_archive_files ports_source_only
-    if {![tbool ports_source_only]} {
+    global UI_PREFIX subport all_archive_files destroot target_state_fd \
+           ports_source_only ports_binary_only
+    if {![tbool ports_source_only] && ([tbool ports_binary_only] ||
+            !([check_statefile target org.macports.destroot $target_state_fd] && [file isdirectory $destroot]))} {
         portarchivefetch::checkfiles archivefetch_urls
     }
     if {[info exists all_archive_files] && [llength $all_archive_files] > 0} {
         ui_msg "$UI_PREFIX [format [msgcat::mc "Fetching archive for %s"] $subport]"
     }
+    portfetch::check_dns
 }
 
 # Main archive fetch routine

Modified: branches/new-help-system/base/src/package1.0/portdmg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portdmg.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/package1.0/portdmg.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -17,7 +17,7 @@
 # 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 "AS IS"
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -36,7 +36,7 @@
 
 set org.macports.dmg [target_new org.macports.dmg portdmg::dmg_main]
 target_runtype ${org.macports.dmg} always
-target_provides ${org.macports.dmg} dmg 
+target_provides ${org.macports.dmg} dmg
 target_requires ${org.macports.dmg} pkg
 
 namespace eval portdmg {
@@ -59,17 +59,17 @@
 proc portdmg::package_dmg {portname portversion portrevision} {
     global UI_PREFIX package.destpath portpath
     global os.platform os.arch os.version os.major
-    
+
     if {[expr (${portrevision} > 0)]} {
         set imagename "${portname}-${portversion}-${portrevision}"
     } else {
         set imagename "${portname}-${portversion}"
     }
-    
+
     set tmp_image ${package.destpath}/${imagename}.tmp.dmg
     set final_image ${package.destpath}/${imagename}.dmg
     set pkgpath ${package.destpath}/${portname}-${portversion}.pkg
-    
+
     if {[file readable $final_image] && ([file mtime ${final_image}] >= [file mtime ${portpath}/Portfile])} {
         ui_msg "$UI_PREFIX [format [msgcat::mc "Disk Image for %s-%s is up-to-date"] ${portname} ${portversion}]"
         return 0
@@ -83,7 +83,13 @@
         # Apple_partition_scheme (Apple_partition_map is at s1)
         set subdev 2
     }
-    
+
+    if {![file isdirectory $pkgpath]} {
+        file mkdir ${package.destpath}/${imagename}
+        file copy $pkgpath ${package.destpath}/${imagename}
+        set pkgpath ${package.destpath}/${imagename}
+    }
+
     set hdiutil [findBinary hdiutil $portutil::autoconf::hdiutil_path]
     if {[system "$hdiutil create -quiet -fs HFS+ -volname ${imagename} -srcfolder ${pkgpath} ${tmp_image}"] != ""} {
         return -code error [format [msgcat::mc "Failed to create temporary image: %s"] ${imagename}]
@@ -95,6 +101,6 @@
         return -code error [format [msgcat::mc "Failed to internet-enable: %s"] ${final_image}]
     }
     file delete -force "${tmp_image}"
-    
+
     return 0
 }

Modified: branches/new-help-system/base/src/package1.0/portdpkg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portdpkg.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/package1.0/portdpkg.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -18,7 +18,7 @@
 # 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 "AS IS"
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -54,7 +54,7 @@
 
 proc portdpkg::main {args} {
 	global UI_PREFIX destpath os.arch os.platform supported_archs configure.build_arch
-    
+
 	ui_msg "$UI_PREFIX [format [msgcat::mc "Creating dpkg for %s-%s"] [option subport] [option version]]"
 
 	# get deplist
@@ -95,7 +95,7 @@
 			set pkg_depends [join ${dependencies} ", "]
 		}
 	}
-	
+
 	# Create dpkg version number
 	if {[expr [option epoch] != 0]} {
 		set pkg_version "[option epoch]:[option version]"
@@ -125,11 +125,11 @@
 
 	# Discern correct architecture
 	# From http://www.debian.org/doc/debian-policy/ch-customized-programs.html#fr55:
-	# The following architectures and operating systems are currently recognised   
-	# by dpkg-archictecture. The architecture, arch, is one of the following:      
-	# alpha, arm, hppa, i386, ia64, m68k, mips, mipsel, powerpc, s390, sh, sheb,   
-	# sparc and sparc64. The operating system, os, is one of: linux, gnu,          
-	# freebsd and openbsd. Use of gnu in this string is reserved for the           
+	# The following architectures and operating systems are currently recognised
+	# by dpkg-archictecture. The architecture, arch, is one of the following:
+	# alpha, arm, hppa, i386, ia64, m68k, mips, mipsel, powerpc, s390, sh, sheb,
+	# sparc and sparc64. The operating system, os, is one of: linux, gnu,
+	# freebsd and openbsd. Use of gnu in this string is reserved for the
 	# GNU/Hurd operating system.
 	switch -regex ${configure.build_arch} {
 		i[3-9]86 { set pkg_arch "i386" }
@@ -144,7 +144,7 @@
 	} elseif {${pkg_arch} == "x86_64"} {
 		set pkg_arch "amd64"
 	}
-	
+
 	# An architecture-independent package
 	if {$supported_archs == "noarch"} {
 		set pkg_arch "all"
@@ -182,7 +182,7 @@
 	}
 	foreach {name array} $res {
 		array set portinfo $array
-	
+
 		if {[info exists portinfo(depends_run)] || [info exists portinfo(depends_lib)]} {
 			# get the union of depends_run and depends_lib
 			# xxx: only examines the portfile component of the depspec

Modified: branches/new-help-system/base/src/package1.0/portmdmg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portmdmg.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/package1.0/portmdmg.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -17,7 +17,7 @@
 # 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 "AS IS"
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -36,7 +36,7 @@
 
 set org.macports.mdmg [target_new org.macports.mdmg portmdmg::mdmg_main]
 target_runtype ${org.macports.mdmg} always
-target_provides ${org.macports.mdmg} mdmg 
+target_provides ${org.macports.mdmg} mdmg
 target_requires ${org.macports.mdmg} mpkg
 
 namespace eval portmdmg {
@@ -59,17 +59,17 @@
 proc portmdmg::package_mdmg {portname portversion portrevision} {
     global UI_PREFIX package.destpath portpath
     global os.platform os.arch os.version os.major
-    
+
     if {[expr (${portrevision} > 0)]} {
         set imagename "${portname}-${portversion}-${portrevision}"
     } else {
         set imagename "${portname}-${portversion}"
     }
-    
+
     set tmp_image ${package.destpath}/${imagename}.tmp.dmg
     set final_image ${package.destpath}/${imagename}.dmg
     set mpkgpath ${package.destpath}/${portname}-${portversion}.mpkg
-    
+
     if {[file readable $final_image] && ([file mtime ${final_image}] >= [file mtime ${portpath}/Portfile])} {
         ui_msg "$UI_PREFIX [format [msgcat::mc "Disk Image for %s-%s is up-to-date"] ${portname} ${portversion}]"
         return 0
@@ -84,6 +84,12 @@
         set subdev 2
     }
 
+    if {![file isdirectory $mpkgpath]} {
+        file mkdir ${package.destpath}/${imagename}
+        file copy $mpkgpath ${package.destpath}/${imagename}
+        set mpkgpath ${package.destpath}/${imagename}
+    }
+
     set hdiutil [findBinary hdiutil $portutil::autoconf::hdiutil_path]
     if {[system "$hdiutil create -quiet -fs HFS+ -volname ${imagename} -srcfolder ${mpkgpath} ${tmp_image}"] != ""} {
         return -code error [format [msgcat::mc "Failed to create temporary image: %s"] ${imagename}]
@@ -95,6 +101,6 @@
         return -code error [format [msgcat::mc "Failed to internet-enable: %s"] ${final_image}]
     }
     file delete -force "${tmp_image}"
-    
+
     return 0
 }

Modified: branches/new-help-system/base/src/package1.0/portmpkg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portmpkg.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/package1.0/portmpkg.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -2,7 +2,7 @@
 # portmpkg.tcl
 # $Id$
 #
-# Copyright (c) 2005, 2007 - 2011 The MacPorts Project
+# Copyright (c) 2005, 2007 - 2012 The MacPorts Project
 # Copyright (c) 2002 - 2004 Apple Inc.
 # All rights reserved.
 #
@@ -17,7 +17,7 @@
 # 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 "AS IS"
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -48,36 +48,38 @@
 set_ui_prefix
 
 proc portmpkg::mpkg_main {args} {
-    global subport version revision package.destpath package.flat UI_PREFIX
+    global subport version revision os.major package.destpath package.flat UI_PREFIX
 
-    # Make sure the destination path exists.
-    file mkdir ${package.destpath}
+    if {!${package.flat} || ${os.major} < 10} {
+        # Make sure the destination path exists.
+        file mkdir ${package.destpath}
+    }
 
     return [package_mpkg $subport $version $revision]
 }
 
 proc portmpkg::make_dependency_list {portname destination} {
     global variations prefix package.destpath package.flat
-	set result {}
-	if {[catch {set res [mport_lookup $portname]} error]} {
-		global errorInfo
-		ui_debug "$errorInfo"
-		return -code error "port lookup failed: $error"
-	}
-	array set portinfo [lindex $res 1]
+    set result {}
+    if {[catch {set res [mport_lookup $portname]} error]} {
+        global errorInfo
+        ui_debug "$errorInfo"
+        return -code error "port lookup failed: $error"
+    }
+    array set portinfo [lindex $res 1]
 
-	if {[getuid] == 0 && [geteuid] != 0} {
-		setegid 0; seteuid 0
-		set deprivileged 1
-	}
+    if {[getuid] == 0 && [geteuid] != 0} {
+        setegid 0; seteuid 0
+        set deprivileged 1
+    }
 
-	set mport [mport_open $portinfo(porturl) [list prefix $prefix package.destpath ${destination} package.flat ${package.flat} subport $portinfo(name)] [array get variations]]
+    set mport [mport_open $portinfo(porturl) [list prefix $prefix package.destpath ${destination} package.flat ${package.flat} subport $portinfo(name)] [array get variations]]
 
     if {[info exists deprivileged]} {
-	    global macportsuser
-		setegid [uname_to_gid "$macportsuser"]
-		seteuid [name_to_uid "$macportsuser"]
-	}
+        global macportsuser
+        setegid [uname_to_gid "$macportsuser"]
+        seteuid [name_to_uid "$macportsuser"]
+    }
 
     unset portinfo
     array set portinfo [mport_info $mport]
@@ -95,57 +97,79 @@
     }
 
     lappend result [list $portinfo(name) $portinfo(version) $mport]
-	ui_debug "dependencies for ${portname}: $result"
-	return $result
+    return $result
 }
 
 proc portmpkg::make_one_package {portname portversion mport} {
-	if {[getuid] == 0 && [geteuid] != 0} {
-		setegid 0; seteuid 0
-		set deprivileged 1
-	}
+    if {[getuid] == 0 && [geteuid] != 0} {
+        setegid 0; seteuid 0
+        set deprivileged 1
+    }
 
     ui_debug "building dependency package: $portname"
-    mport_exec $mport pkg
+    set result [mport_exec $mport pkg]
     mport_close $mport
+    if {$result} {
+        error "Processing of port $portname failed"
+    }
 
-	if {[info exists deprivileged]} {
-	    global macportsuser
-		setegid [uname_to_gid "$macportsuser"]
-		seteuid [name_to_uid "$macportsuser"]
-	}
+    if {[info exists deprivileged]} {
+        global macportsuser
+        setegid [uname_to_gid "$macportsuser"]
+        seteuid [name_to_uid "$macportsuser"]
+    }
 }
 
 proc portmpkg::package_mpkg {portname portversion portrevision} {
-    global portdbpath destpath workpath prefix porturl description package.destpath package.flat long_description homepage depends_run depends_lib
+    global portdbpath os.major destpath workpath prefix porturl description package.destpath package.flat long_description homepage depends_run depends_lib
 
-	set pkgpath ${package.destpath}/${portname}-${portversion}.pkg
-	set mpkgpath ${package.destpath}/${portname}-${portversion}.mpkg
-	system "mkdir -p -m 0755 ${mpkgpath}/Contents/Resources"
-	system "mkdir -p -m 0755 ${mpkgpath}/Contents/Packages"
+    set mpkgpath ${package.destpath}/${portname}-${portversion}.mpkg
 
-	set dependencies {}
-	# get deplist
-	set deps [make_dependency_list $portname ${mpkgpath}/Contents/Packages]
-	set deps [lsort -unique $deps]
-	foreach dep $deps {
-		set name [lindex $dep 0]
-		set vers [lindex $dep 1]
-		set mport [lindex $dep 2]
-		# don't re-package ourself
-		if {$name != $portname} {
-			make_one_package $name $vers $mport
-			lappend dependencies ${name}-${vers}.pkg
-		}
-	}
+    if {${package.flat} && ${os.major} >= 10} {
+        set pkgpath ${package.destpath}/${portname}-${portversion}-component.pkg
+        set packages_path ${workpath}/mpkg_packages
+        set resources_path ${workpath}/mpkg_resources
+    } else {
+        set pkgpath ${package.destpath}/${portname}-${portversion}.pkg
+        set packages_path ${mpkgpath}/Contents/Packages
+        set resources_path ${mpkgpath}/Contents/Resources
+    }
+    system "mkdir -p -m 0755 ${packages_path}"
+    system "mkdir -p -m 0755 ${resources_path}"
 
-	# copy our own pkg into the mpkg
-	system "cp -PR ${pkgpath} ${mpkgpath}/Contents/Packages/"
-	lappend dependencies ${portname}-${portversion}.pkg
-	
-    portpkg::write_PkgInfo ${mpkgpath}/Contents/PkgInfo
-    mpkg_write_info_plist ${mpkgpath}/Contents/Info.plist $portname $portversion $portrevision $prefix $dependencies
-    portpkg::write_description_plist ${mpkgpath}/Contents/Resources/Description.plist $portname $portversion $description
+    set dependencies {}
+    # get deplist
+    set deps [make_dependency_list $portname $packages_path]
+    set deps [lsort -unique $deps]
+    foreach dep $deps {
+        set name [lindex $dep 0]
+        set vers [lindex $dep 1]
+        set mport [lindex $dep 2]
+        # don't re-package ourself
+        if {$name != $portname} {
+            make_one_package $name $vers $mport
+            if {${package.flat} && ${os.major} >= 10} {
+                lappend dependencies org.macports.${name} ${name}-${vers}-component.pkg
+            } else {
+                lappend dependencies ${name}-${vers}.pkg
+            }
+        }
+    }
+    if {${package.flat} && ${os.major} >= 10} {
+        lappend dependencies org.macports.${portname} ${portname}-${portversion}-component.pkg
+    } else {
+        lappend dependencies ${portname}-${portversion}.pkg
+    }
+
+    # copy our own pkg into the mpkg
+    system "cp -PR ${pkgpath} ${packages_path}"
+
+    if {!${package.flat} || ${os.major} < 10} {
+        portpkg::write_PkgInfo ${mpkgpath}/Contents/PkgInfo
+        mpkg_write_info_plist ${mpkgpath}/Contents/Info.plist $portname $portversion $portrevision $prefix $dependencies
+        portpkg::write_description_plist ${mpkgpath}/Contents/Resources/Description.plist $portname $portversion $description
+        set resources_path ${mpkgpath}/Contents/Resources
+    }
     # long_description, description, or homepage may not exist
     foreach variable {long_description description homepage} {
         if {![info exists $variable]} {
@@ -154,68 +178,109 @@
             set pkg_$variable [set $variable]
         }
     }
-    portpkg::write_welcome_html ${mpkgpath}/Contents/Resources/Welcome.html $portname $portversion $pkg_long_description $pkg_description $pkg_homepage
-    file copy -force -- [getportresourcepath $porturl "port1.0/package/background.tiff"] ${mpkgpath}/Contents/Resources/background.tiff
+    portpkg::write_welcome_html ${resources_path}/Welcome.html $portname $portversion $pkg_long_description $pkg_description $pkg_homepage
+    file copy -force -- [getportresourcepath $porturl "port1.0/package/background.tiff"] ${resources_path}/background.tiff
 
-	return 0
+    if {${package.flat} && ${os.major} >= 10} {
+        write_distribution ${workpath}/Distribution $portname $dependencies
+        set productbuild [findBinary productbuild]
+        set cmdline "$productbuild --resources ${resources_path} --identifier org.macports.mpkg.${portname} --distribution ${workpath}/Distribution --package-path ${packages_path} ${mpkgpath}"
+        ui_debug "Running command line: $cmdline"
+        system $cmdline
+    }
+
+    return 0
 }
 
+proc portmpkg::write_distribution {dfile portname dependencies} {
+    global macosx_deployment_target
+    set portname [xml_escape $portname]
+    set dfd [open $dfile w+]
+    puts $dfd "<?xml version=\"1.0\" encoding=\"utf-8\"?>
+<installer-gui-script minSpecVersion=\"1\">
+    <title>${portname}</title>
+    <options customize=\"never\"/>
+    <allowed-os-versions><os-version min=\"${macosx_deployment_target}\"/></allowed-os-versions>
+    <background file=\"background.tiff\" mime-type=\"image/tiff\" alignment=\"bottomleft\" scaling=\"none\"/>
+    <welcome mime-type=\"text/html\" file=\"Welcome.html\"/>
+    <choices-outline>
+    <line choice=\"default\">
+        <line choice=\"org.macports.mpkg.${portname}\"/>
+    </line>
+    </choices-outline>
+    <choice id=\"default\"/>
+    <choice id=\"org.macports.mpkg.${portname}\" visible=\"false\">
+"
+    foreach {identifier package} $dependencies {
+        set id [xml_escape $identifier]
+        set pkg [xml_escape $package]
+        puts $dfd "        <pkg-ref id=\"${id}\"/>"
+        lappend pkgrefs "<pkg-ref id=\"${id}\">${pkg}</pkg-ref>"
+    }
+    puts $dfd "    </choice>"
+    foreach pkgref $pkgrefs {
+        puts $dfd "    $pkgref"
+    }
+    puts $dfd "</installer-gui-script>"
+    close $dfd
+}
+
 proc portmpkg::xml_escape {s} {
-	regsub -all {&} $s {\&amp;} s
-	regsub -all {<} $s {\&lt;} s
-	regsub -all {>} $s {\&gt;} s
-	return $s
+    regsub -all {&} $s {\&amp;} s
+    regsub -all {<} $s {\&lt;} s
+    regsub -all {>} $s {\&gt;} s
+    return $s
 }
 
 proc portmpkg::mpkg_write_info_plist {infofile portname portversion portrevision destination dependencies} {
-	set vers [split $portversion "."]
-	
-	if {[string index $destination end] != "/"} {
-		append destination /
-	}
-	
-	set depxml ""
-	foreach dep $dependencies {
-		set dep [xml_escape $dep]
-		append depxml "<dict>
-			<key>IFPkgFlagPackageLocation</key>
-			<string>${dep}</string>
-			<key>IFPkgFlagPackageSelection</key>
-			<string>selected</string>
-		</dict>
-		"
-	}
+    set vers [split $portversion "."]
 
-	set portname [xml_escape $portname]
-	set portversion [xml_escape $portversion]
-	set portrevision [xml_escape $portrevision]
+    if {[string index $destination end] != "/"} {
+        append destination /
+    }
 
-	set infofd [open ${infofile} w+]
-	puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
+    set depxml ""
+    foreach dep $dependencies {
+        set dep [xml_escape $dep]
+        append depxml "<dict>
+            <key>IFPkgFlagPackageLocation</key>
+            <string>${dep}</string>
+            <key>IFPkgFlagPackageSelection</key>
+            <string>selected</string>
+        </dict>
+        "
+    }
+
+    set portname [xml_escape $portname]
+    set portversion [xml_escape $portversion]
+    set portrevision [xml_escape $portrevision]
+
+    set infofd [open ${infofile} w+]
+    puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 }
-	puts $infofd "<dict>
-	<key>CFBundleGetInfoString</key>
-	<string>${portname} ${portversion}</string>
-	<key>CFBundleIdentifier</key>
-	<string>org.macports.mpkg.${portname}</string>
-	<key>CFBundleName</key>
-	<string>${portname}</string>
-	<key>CFBundleShortVersionString</key>
-	<string>${portversion}</string>
-	<key>IFMajorVersion</key>
-	<integer>${portrevision}</integer>
-	<key>IFMinorVersion</key>
-	<integer>0</integer>
-	<key>IFPkgFlagComponentDirectory</key>
-	<string>./Contents/Packages</string>
-	<key>IFPkgFlagPackageList</key>
-	<array>
-		${depxml}</array>
-	<key>IFPkgFormatVersion</key>
-	<real>0.10000000149011612</real>
+    puts $infofd "<dict>
+    <key>CFBundleGetInfoString</key>
+    <string>${portname} ${portversion}</string>
+    <key>CFBundleIdentifier</key>
+    <string>org.macports.mpkg.${portname}</string>
+    <key>CFBundleName</key>
+    <string>${portname}</string>
+    <key>CFBundleShortVersionString</key>
+    <string>${portversion}</string>
+    <key>IFMajorVersion</key>
+    <integer>${portrevision}</integer>
+    <key>IFMinorVersion</key>
+    <integer>0</integer>
+    <key>IFPkgFlagComponentDirectory</key>
+    <string>./Contents/Packages</string>
+    <key>IFPkgFlagPackageList</key>
+    <array>
+        ${depxml}</array>
+    <key>IFPkgFormatVersion</key>
+    <real>0.10000000149011612</real>
 </dict>
 </plist>"
-	close $infofd
+    close $infofd
 }

Modified: branches/new-help-system/base/src/package1.0/portpkg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portpkg.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/package1.0/portpkg.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -2,7 +2,7 @@
 # portpkg.tcl
 # $Id$
 #
-# Copyright (c) 2005, 2007 - 2011 The MacPorts Project
+# Copyright (c) 2005, 2007 - 2012 The MacPorts Project
 # Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
@@ -17,7 +17,7 @@
 # 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 "AS IS"
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -38,43 +38,29 @@
 target_runtype ${org.macports.pkg} always
 target_provides ${org.macports.pkg} pkg
 target_requires ${org.macports.pkg} archivefetch unarchive destroot
+target_prerun ${org.macports.pkg} portpkg::pkg_start
 
 namespace eval portpkg {
 }
 
 # define options
-options package.type package.destpath package.flat
+options package.type package.destpath package.flat package.resources package.scripts
 
 # Set defaults
 default package.destpath {${workpath}}
-default package.flat     false
+default package.resources {${workpath}/pkg_resources}
+default package.scripts  {${workpath}/pkg_scripts}
+# Need productbuild to make flat packages really work
+default package.flat     {[expr [vercmp $macosx_deployment_target 10.6] >= 0]}
 
 set_ui_prefix
 
-proc portpkg::pkg_main {args} {
-    global subport version revision package.type package.destpath package.flat UI_PREFIX
+proc portpkg::pkg_start {args} {
+    global packagemaker_path portpkg::packagemaker \
+           portpkg::language xcodeversion portpath porturl \
+           package.resources package.scripts package.flat \
+           subport version description long_description homepage workpath os.major
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating pkg for %s-%s"] ${subport} ${version}]"
-
-    if {[getuid] == 0 && [geteuid] != 0} {
-        elevateToRoot "pkg"
-    }
-
-    return [package_pkg $subport $version $revision]
-}
-
-proc portpkg::package_pkg {portname portversion portrevision} {
-    global UI_PREFIX portdbpath destpath workpath prefix description \
-    package.destpath package.flat long_description homepage portpath porturl \
-    os.version os.major xcodeversion packagemaker_path
-
-    set pkgpath ${package.destpath}/${portname}-${portversion}.pkg
-
-    if {[file readable $pkgpath] && ([file mtime ${pkgpath}] >= [file mtime ${portpath}/Portfile])} {
-        ui_msg "$UI_PREFIX [format [msgcat::mc "Package for %s-%s is up-to-date"] ${portname} ${portversion}]"
-        return 0
-    }
-
     if {![info exists packagemaker_path]} {
         if {[vercmp $xcodeversion 4.3] >= 0} {
             set packagemaker_path /Applications/PackageMaker.app
@@ -86,16 +72,13 @@
         }
     }
     set packagemaker "${packagemaker_path}/Contents/MacOS/PackageMaker"
-    if ([file exists "$packagemaker"]) {
-        set resourcepath ${workpath}/pkg_resources
-    } else {
-        set resourcepath "${pkgpath}/Contents/Resources"
-    }
 
     set language "English"
-    file mkdir "${resourcepath}/${language}.lproj"
-    file attributes "${resourcepath}/${language}.lproj" -permissions 0755
-	
+    file mkdir "${package.resources}/${language}.lproj"
+    file attributes "${package.resources}/${language}.lproj" -permissions 0755
+    file mkdir ${package.scripts}
+    file attributes ${package.scripts} -permissions 0755
+
     # long_description, description, or homepage may not exist
     foreach variable {long_description description homepage} {
         if {![info exists $variable]} {
@@ -104,9 +87,37 @@
             set pkg_$variable [set $variable]
         }
     }
-    write_welcome_html ${resourcepath}/${language}.lproj/Welcome.html $portname $portversion $pkg_long_description $pkg_description $pkg_homepage
-    file copy -force -- [getportresourcepath $porturl "port1.0/package/background.tiff"] ${resourcepath}/${language}.lproj/background.tiff
+    write_welcome_html ${package.resources}/${language}.lproj/Welcome.html $subport $version $pkg_long_description $pkg_description $pkg_homepage
+    file copy -force -- [getportresourcepath $porturl "port1.0/package/background.tiff"] ${package.resources}/${language}.lproj/background.tiff
 
+    if {${package.flat} && ${os.major} >= 9} {
+        write_distribution "${workpath}/Distribution" $subport $version
+    }
+}
+
+proc portpkg::pkg_main {args} {
+    global subport version revision UI_PREFIX
+
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating pkg for %s-%s"] ${subport} ${version}]"
+
+    if {[getuid] == 0 && [geteuid] != 0} {
+        elevateToRoot "pkg"
+    }
+
+    return [package_pkg $subport $version $revision]
+}
+
+proc portpkg::package_pkg {portname portversion portrevision} {
+    global UI_PREFIX portdbpath destpath workpath prefix description \
+    package.flat package.destpath portpath os.version os.major \
+    package.resources package.scripts portpkg::packagemaker portpkg::language
+
+    set pkgpath "${package.destpath}/${portname}-${portversion}.pkg"
+    if {[file readable $pkgpath] && ([file mtime ${pkgpath}] >= [file mtime ${portpath}/Portfile])} {
+        ui_msg "$UI_PREFIX [format [msgcat::mc "Package for %s-%s is up-to-date"] ${portname} ${portversion}]"
+        return 0
+    }
+
     foreach dir {etc var tmp} {
         if ([file exists "${destpath}/$dir"]) {
             # certain toplevel directories really are symlinks. leaving them as directories make pax lose the symlinks. that's bad.
@@ -122,42 +133,63 @@
         if {${os.major} >= 9} {
             if {${package.flat}} {
                 set pkgtarget "10.5"
-                set pkgresources ""
+                set pkgresources " --scripts ${package.scripts}"
                 set infofile "${workpath}/PackageInfo"
-                write_package_info ${workpath}/PackageInfo $portname $portversion $portrevision
+                write_package_info $infofile
             } else {
                 set pkgtarget "10.3"
-                set pkgresources " --resources ${resourcepath} --title \"$portname-$portversion\""
+                set pkgresources " --resources ${package.resources} --title \"$portname-$portversion\""
                 set infofile "${workpath}/Info.plist"
-                write_info_plist ${workpath}/Info.plist $portname $portversion $portrevision
+                write_info_plist $infofile $portname $portversion $portrevision
             }
-            set cmdline "PMResourceLocale=${language} $packagemaker -AppleLanguages \"(${language})\" --root ${destpath} --out ${pkgpath} ${pkgresources} --info $infofile --target $pkgtarget --domain system --id org.macports.$portname"
+            set cmdline "PMResourceLocale=${language} $packagemaker --root ${destpath} --out ${pkgpath} ${pkgresources} --info $infofile --target $pkgtarget --domain system --id org.macports.$portname"
             if {${os.major} >= 10} {
                 append cmdline " --no-relocate"
+            } else {
+                # 10.5 Leopard does not use current language, manually specify
+                append cmdline " -AppleLanguages \"(${language})\""
             }
             ui_debug "Running command line: $cmdline"
             system $cmdline
+
+            if {${package.flat} && ${os.major} >= 10} {
+                # the package we just built is just a component
+                set componentpath "[file rootname ${pkgpath}]-component.pkg"
+                file rename -force ${pkgpath} ${componentpath}
+                # Generate a distribution
+                set productbuild [findBinary productbuild]
+                set cmdline "$productbuild --resources ${package.resources} --identifier org.macports.${portname} --distribution ${workpath}/Distribution --package-path ${package.destpath} ${pkgpath}"
+                ui_debug "Running command line: $cmdline"
+                system $cmdline
+            }
         } else {
             write_info_plist ${workpath}/Info.plist $portname $portversion $portrevision
             write_description_plist ${workpath}/Description.plist $portname $portversion $description
-            system "$packagemaker -build -f ${destpath} -p ${pkgpath} -r ${resourcepath} -i ${workpath}/Info.plist -d ${workpath}/Description.plist"
+            system "$packagemaker -build -f ${destpath} -p ${pkgpath} -r ${package.resources} -i ${workpath}/Info.plist -d ${workpath}/Description.plist"
         }
 
-        file delete ${workpath}/Info.plist
-        file delete ${workpath}/PackageInfo
-        file delete ${workpath}/Description.plist
-        file delete -force ${workpath}/pkg_resources
+        file delete ${workpath}/Info.plist \
+                    ${workpath}/PackageInfo \
+                    ${workpath}/Distribution \
+                    ${workpath}/Description.plist
+        file delete -force ${package.resources} \
+                           ${package.scripts}
 
     } else {
 
+        file mkdir ${pkgpath}/Contents/Resources
+        foreach f [glob -directory ${package.resources} *] {
+            file copy -force -- $f ${pkgpath}/Contents/Resources
+        }
+
         write_PkgInfo ${pkgpath}/Contents/PkgInfo
         write_info_plist ${pkgpath}/Contents/Info.plist $portname $portversion $portrevision
 
         system "[findBinary mkbom $portutil::autoconf::mkbom_path] ${destpath} ${pkgpath}/Contents/Archive.bom"
-        system "cd ${destpath} && [findBinary pax $portutil::autoconf::pax_path] -x [findBinary cpio $portutil::autoconf::cpio_path] -w -z . > ${pkgpath}/Contents/Archive.pax.gz"
+        system "cd ${destpath} && [findBinary pax $portutil::autoconf::pax_path] -x cpio -w -z . > ${pkgpath}/Contents/Archive.pax.gz"
 
-        write_description_plist ${resourcepath}/Description.plist $portname $portversion $description
-        write_sizes_file ${resourcepath}/Archive.sizes ${portname} ${portversion} ${pkgpath} ${destpath}
+        write_description_plist ${pkgpath}/Contents/Resources/Description.plist $portname $portversion $description
+        write_sizes_file ${pkgpath}/Contents/Resources/Archive.sizes ${portname} ${portversion} ${pkgpath} ${destpath}
 
     }
 
@@ -268,12 +300,12 @@
     set long_description [xml_escape $long_description]
     set description [xml_escape $description]
     set homepage [xml_escape $homepage]
-	
+
     puts $fd "
 <html lang=\"en\">
 <head>
-	<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\">
-	<title>Install ${portname}</title>
+    <meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\">
+    <title>Install ${portname}</title>
 </head>
 <body>
 <font face=\"Helvetica\"><b>Welcome to the ${portname} for Mac OS X Installer</b></font>
@@ -293,7 +325,7 @@
 }
 
 proc portpkg::write_sizes_file {sizesfile portname portversion pkgpath destpath} {
-    
+
     if {[catch {set numFiles [llength [split [exec [findBinary lsbom $portutil::autoconf::lsbom_path] -s ${pkgpath}/Contents/Archive.bom] "\n"]]} result]} {
         return -code error [format [msgcat::mc "Reading package bom failed: %s"] $result]
     }
@@ -311,7 +343,7 @@
     }
     incr installedSize $infoSize
     incr installedSize $bomSize
-	
+
     set fd [open ${sizesfile} w+]
     puts $fd "NumFiles $numFiles
 InstalledSize $installedSize
@@ -319,14 +351,37 @@
     close $fd
 }
 
-proc portpkg::write_package_info {infofile portname portversion portrevision} {
-    set portname [xml_escape $portname]
-    set portversion [xml_escape $portversion]
-    set portrevision [xml_escape $portrevision]
-
+proc portpkg::write_package_info {infofile} {
     set infofd [open ${infofile} w+]
     puts $infofd "
 <pkg-info install-location=\"/\" relocatable=\"false\" auth=\"root\">
 </pkg-info>"
     close $infofd
 }
+
+proc portpkg::write_distribution {dfile portname portversion} {
+    global macosx_deployment_target
+    set portname [xml_escape $portname]
+    set portversion [xml_escape $portversion]
+    set dfd [open $dfile w+]
+    puts $dfd "<?xml version=\"1.0\" encoding=\"utf-8\"?>
+<installer-gui-script minSpecVersion=\"1\">
+    <title>${portname}</title>
+    <options customize=\"never\"/>
+    <allowed-os-versions><os-version min=\"${macosx_deployment_target}\"/></allowed-os-versions>
+    <background file=\"background.tiff\" mime-type=\"image/tiff\" alignment=\"bottomleft\" scaling=\"none\"/>
+    <welcome mime-type=\"text/html\" file=\"Welcome.html\"/>
+    <choices-outline>
+        <line choice=\"default\">
+            <line choice=\"org.macports.${portname}\"/>
+        </line>
+    </choices-outline>
+    <choice id=\"default\"/>
+    <choice id=\"org.macports.${portname}\" visible=\"false\">
+        <pkg-ref id=\"org.macports.${portname}\"/>
+    </choice>
+    <pkg-ref id=\"org.macports.${portname}\">${portname}-${portversion}-component.pkg</pkg-ref>
+</installer-gui-script>
+"
+    close $dfd
+}

Modified: branches/new-help-system/base/src/package1.0/portportpkg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portportpkg.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/package1.0/portportpkg.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -16,7 +16,7 @@
 # 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 "AS IS"
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,7 +35,7 @@
 
 set org.macports.portpkg [target_new org.macports.portpkg portportpkg::portpkg_main]
 target_runtype ${org.macports.portpkg} always
-target_provides ${org.macports.portpkg} portpkg 
+target_provides ${org.macports.portpkg} portpkg
 target_requires ${org.macports.portpkg} main
 
 namespace eval portportpkg {
@@ -58,7 +58,7 @@
     	ui_error "Please install the xar port before proceeding."
 		return -code error [msgcat::mc "Portpkg failed"]
     }
-    
+
     return $xar
 }
 
@@ -93,13 +93,13 @@
     global name prefix UI_PREFIX workpath portpath
 
 	set xar [xar_path]
-	
+
     set dirname "portpkg"
     set dirpath "${workpath}/${dirname}"
     set pkgpath "${workpath}/${name}.portpkg"
     set metaname "portpkg_meta.xml"
     set metapath "${workpath}/${metaname}"
-    
+
     # Expose and default some global variables
     set vars " maintainers categories description \
     	long_description master_sites homepage epoch version revision \
@@ -110,49 +110,49 @@
 	foreach var $vars {
 		if {![info exists $var]} { set $var {} }
 	}
-	
+
 	# Unobscure the maintainer addresses
 	set maintainers [unobscure_maintainers $maintainers]
 
     # Make sure our workpath is clean
     file delete -force $dirpath $metapath $pkgpath
-    
+
     # Create the portpkg directory
     file mkdir $dirpath
 
     # Move in the Portfile
     file copy Portfile ${dirpath}
-    
-    # Move in files    
+
+    # Move in files
     if {[file isdirectory "files"]} {
         file copy files ${dirpath}
     }
-    
+
     # Create the metadata subdoc
     set sd [open ${metapath} w]
     puts $sd "<portpkg version='1'>"
-    
+
 		puts $sd "<submitter>"
 			putel $sd name $submitter_name
 			putel $sd email $submitter_email
-			
+
 			# TODO provide means to set notes?
 			putel $sd notes ""
 		puts $sd "</submitter>"
-		
+
 		puts $sd "<package>"
 			putel $sd name $name
 			putel $sd homepage $homepage
 			putlist $sd categories category $categories
 			putlist $sd maintainers maintainer $maintainers
-			
+
 			putel $sd epoch $epoch
 			putel $sd version $version
 			putel $sd revision $revision
-			
+
 			putel $sd description [join $description]
 			putel $sd long_description [join $long_description]
-		
+
 			# TODO: variants has platforms in it
 			if {[info exists PortInfo(variants)]} {
 				if {[info exists PortInfo(variant_desc)]} {
@@ -160,7 +160,7 @@
 				} else {
 					array set descs ""
 				}
-	
+
 				puts $sd "<variants>"
 				foreach v $PortInfo(variants) {
 					puts $sd "<variant>"
@@ -174,36 +174,36 @@
 			} else {
 				putel $sd variants ""
 			}
-			
+
 			# TODO: Dependencies and platforms
 			#putel $sd dependencies ""
 			#putel $sd platforms ""
-			
+
 		puts $sd "</package>"
-		
+
     puts $sd "</portpkg>"
     close $sd
-    
+
     # Create portpkg.xar, including the metadata and the portpkg directory contents
     set cmd "cd ${workpath}; ${xar} -cf ${pkgpath} --exclude \\.DSStore --exclude \\.svn ${dirname} -s ${metapath} -n ${metaname}"
     if {[system $cmd] != ""} {
 		return -code error [format [msgcat::mc "Failed to create portpkg for port : %s"] $name]
     }
-    
+
     return ${pkgpath}
 }
 
 
 proc portportpkg::portpkg_main {args} {
     global name version portverbose prefix UI_PREFIX workpath portpath
-    
+
     ui_msg "$UI_PREFIX [format [msgcat::mc "Creating portpkg for %s-%s"] ${name} ${version}]"
 
     # Make sure we have a work directory
     file mkdir ${workpath}
-  
+
     # Create portpkg.xar in the work directory
     set pkgpath [create_portpkg]
- 
+
     return 0
 }

Modified: branches/new-help-system/base/src/package1.0/portrpm.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portrpm.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/package1.0/portrpm.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -17,7 +17,7 @@
 # 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 "AS IS"
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -53,16 +53,16 @@
 
 proc portrpm::rpm_main {args} {
     global subport version revision UI_PREFIX
-    
+
     ui_msg "$UI_PREFIX [format [msgcat::mc "Creating RPM package for %s-%s"] ${subport} ${version}]"
-    
+
     return [rpm_pkg $subport $version $revision]
 }
 
 proc portrpm::rpm_pkg {portname portversion portrevision} {
     global UI_PREFIX rpm.asroot package.destpath portdbpath destpath workpath prefix categories maintainers description long_description homepage epoch portpath
 	global os.platform os.arch os.version os.major supported_archs configure.build_arch license
-    
+
     set rpmdestpath ""
     if {![string equal ${package.destpath} ${workpath}] && ![string equal ${package.destpath} ""]} {
         set rpm.asroot no
@@ -83,7 +83,7 @@
     } elseif {${configure.build_arch} != ""} {
         set rpmbuildarch "--target ${configure.build_arch}"
     }
-    
+
     foreach dir [list "${prefix}/src/macports/RPMS" "${prefix}/src/apple/RPMS" "/usr/src/apple/RPMS" "/macports/rpms/RPMS"] {
         foreach arch [list ${configure.build_arch} ${os.arch} "fat" "noarch"] {
             set rpmpath "$dir/${arch}/${portname}-${portversion}-${portrevision}.${arch}.rpm"
@@ -94,7 +94,7 @@
             }
         }
     }
-    
+
     set specpath ${workpath}/${portname}.spec
     # long_description, description, or homepage may not exist
     foreach variable {long_description description homepage categories maintainers} {
@@ -106,7 +106,7 @@
     }
     set category   [lindex [split $categories " "] 0]
     set maintainer $maintainers
-    
+
     set dependencies {}
     # get deplist
     set deps [make_dependency_list $portname]
@@ -122,7 +122,7 @@
 
 	# depend on system (virtual packages for apple stuff)
 	lappend dependencies "org.macports.${os.platform}${os.major}"
-    
+
     set listpath ${workpath}/${portname}.filelist
     system "rm -f '${workpath}/${portname}.filelist' && touch '${workpath}/${portname}.filelist'"
     #system "cd '${destpath}' && find . -type d | grep -v -E '^.$' | sed -e 's/\"/\\\"/g' -e 's/^./%dir \"/' -e 's/$/\"/' > '${workpath}/${portname}.filelist'"
@@ -130,7 +130,7 @@
     system "cd '${destpath}' && find . ! -type d | grep /etc/ | sed -e 's/\"/\\\"/g' -e 's/^./%config \"/' -e 's/$/\"/' >> '${workpath}/${portname}.filelist'"
     write_spec ${specpath} ${destpath} ${listpath} $portname $portversion $portrevision $pkg_description $pkg_long_description $pkg_homepage $category $license $maintainer $dependencies $epoch
     system "MP_USERECEIPTS='${portdbpath}/receipts' rpmbuild -bb -v ${rpmbuildarch} ${rpmdestpath} ${specpath}"
-    
+
     return 0
 }
 
@@ -144,17 +144,17 @@
     }
     foreach {name array} $res {
         array set portinfo $array
-	
+
         if {[info exists portinfo(depends_run)] || [info exists portinfo(depends_lib)]} {
             # get the union of depends_run and depends_lib
             # xxx: only examines the portfile component of the depspec
             set depends {}
             if {[info exists portinfo(depends_run)]} { eval "lappend depends $portinfo(depends_run)" }
             if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
-	    
+
             foreach depspec $depends {
                 set dep [lindex [split $depspec :] end]
-		
+
                 # xxx: nasty hack
                 if {$dep != "XFree86"} {
                     eval "lappend result [make_dependency_list $dep]"

Modified: branches/new-help-system/base/src/package1.0/portsrpm.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portsrpm.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/package1.0/portsrpm.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -17,7 +17,7 @@
 # 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 "AS IS"
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -49,16 +49,16 @@
 
 proc portsrpm::srpm_main {args} {
     global subport version revision UI_PREFIX
-    
+
     ui_msg "$UI_PREFIX [format [msgcat::mc "Creating SRPM package for %s-%s"] ${subport} ${version}]"
-    
+
     return [srpm_pkg $subport $version $revision]
 }
 
 proc portsrpm::srpm_pkg {portname portversion portrevision} {
     global UI_PREFIX package.destpath portdbpath destpath workpath distpath prefix categories maintainers description long_description homepage epoch portpath distfiles fetch_urls
 	global os.platform os.arch os.version os.major
-    
+
     set rpmdestpath ""
     if {![string equal ${package.destpath} ${workpath}] && ![string equal ${package.destpath} ""]} {
         set pkgpath ${package.destpath}
@@ -69,7 +69,7 @@
                    ${pkgpath}/SRPMS
         set rpmdestpath "--define '_topdir ${pkgpath}'"
     }
-    
+
     foreach dir [list "${prefix}/src/macports/SRPMS" "${prefix}/src/apple/SRPMS" "/usr/src/apple/SRPMS" "/macports/rpms/SRPMS"] {
         foreach arch {"src" "nosrc"} {
             set rpmpath "$dir/${portname}-${portversion}-${portrevision}.${arch}.rpm"
@@ -80,7 +80,7 @@
             }
         }
     }
-    
+
     set specpath ${workpath}/${portname}-port.spec
     # long_description, description, or homepage may not exist
     foreach variable {long_description description homepage categories maintainers} {
@@ -93,7 +93,7 @@
     set category   [lindex [split $categories " "] 0]
     set license    "Unknown"
     set maintainer $maintainers
-    
+
     set dependencies {}
     # get deplist
     set deps [make_dependency_list $portname]
@@ -118,10 +118,10 @@
     foreach dist $distfiles {
         system "cp -p ${distpath}/${dist} ${sourcespath}/${dist}"
     }
-    
+
     write_port_spec ${specpath} $portname $portversion $portrevision $pkg_description $pkg_long_description $pkg_homepage $category $license $maintainer $distfiles $fetch_urls $dependencies $epoch $src
     system "rpmbuild -bs -v --nodeps ${rpmdestpath} ${specpath}"
-    
+
     return 0
 }
 
@@ -135,7 +135,7 @@
     }
     foreach {name array} $res {
         array set portinfo $array
-	
+
         if {[info exists portinfo(depends_fetch)] || [info exists portinfo(depends_extract)]
             || [info exists portinfo(depends_build)] || [info exists portinfo(depends_lib)]} {
             # get the union of depends_fetch, depends_extract, depends_build and depends_lib
@@ -145,10 +145,10 @@
             if {[info exists portinfo(depends_extract)]} { eval "lappend depends $portinfo(depends_extract)" }
             if {[info exists portinfo(depends_build)]} { eval "lappend depends $portinfo(depends_build)" }
             if {[info exists portinfo(depends_lib)]} { eval "lappend depends $portinfo(depends_lib)" }
-	    
+
             foreach depspec $depends {
                 set dep [lindex [split $depspec :] end]
-		
+
                 # xxx: nasty hack
                 if {$dep != "XFree86"} {
                     eval "lappend result [make_dependency_list $dep]"
@@ -219,7 +219,7 @@
     set count $first
     puts $specfd "#distfiles"
     foreach file ${distfiles} {
-    
+
         puts -nonewline $specfd "Source${count}: "
         if {![info exists $fetch_urls]} {
         foreach {url_var distfile}  ${fetch_urls} {

Modified: branches/new-help-system/base/src/package1.0/portunarchive.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portunarchive.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/package1.0/portunarchive.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -2,7 +2,7 @@
 # portunarchive.tcl
 # $Id$
 #
-# Copyright (c) 2005, 2007-2011 The MacPorts Project
+# Copyright (c) 2005, 2007-2012 The MacPorts Project
 # Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
 # Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
@@ -18,7 +18,7 @@
 # 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 "AS IS"
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -82,19 +82,10 @@
         ui_debug "Skipping unarchive ($subport) since force is set"
         set skipped 1
     } else {
-        set found 0
-        set rootname [file rootname [get_portimage_path]]
-        foreach unarchive.type [supportedArchiveTypes] {
-            set unarchive.path "${rootname}.${unarchive.type}"
-            set unarchive.file [file tail ${unarchive.path}]
-            if {[file isfile ${unarchive.path}]} {
-                set found 1
-                break
-            } else {
-                ui_debug "No [string toupper ${unarchive.type}] archive: ${unarchive.path}"
-            }
-        }
-        if {$found == 1} {
+        set unarchive.path [find_portarchive_path]
+        set unarchive.file [file tail ${unarchive.path}]
+        set unarchive.type [string range [file extension ${unarchive.file}] 1 end]
+        if {${unarchive.path} != ""} {
             ui_debug "Found [string toupper ${unarchive.type}] archive: ${unarchive.path}"
         } else {
             if {[info exists ports_binary_only] && $ports_binary_only == "yes"} {

Modified: branches/new-help-system/base/src/pextlib1.0/Pextlib.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/Pextlib.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/pextlib1.0/Pextlib.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -46,6 +46,7 @@
 #include <fcntl.h>
 #include <grp.h>
 #include <limits.h>
+#include <netdb.h>
 #include <pwd.h>
 #include <stdbool.h>
 #include <stdint.h>
@@ -568,6 +569,34 @@
 }
 #endif
 
+/* Check if the configured DNS server(s) incorrectly return a result for
+   a nonexistent hostname. Returns true if broken, false if OK. */
+int CheckBrokenDNSCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc UNUSED, Tcl_Obj *CONST objv[] UNUSED)
+{
+    static int already_checked = 0;
+    Tcl_Obj *tcl_result;
+    int broken = 0;
+    struct addrinfo *res = NULL;
+    int error;
+
+    /* Only do the actual test once per run. */
+    if (!already_checked) {
+        error = getaddrinfo("invalid-host.macports.org", NULL, NULL, &res);
+        if (!error) {
+            broken = 1;
+        }
+        if (res) {
+            freeaddrinfo(res);
+        }
+    
+        already_checked = 1;
+    }
+
+    tcl_result = Tcl_NewBooleanObj(broken);
+    Tcl_SetObjResult(interp, tcl_result);
+    return TCL_OK;
+}
+
 int Pextlib_Init(Tcl_Interp *interp)
 {
     if (Tcl_InitStubs(interp, "8.4", 0) == NULL)
@@ -630,6 +659,8 @@
     Tcl_CreateObjCommand(interp, "isatty", IsattyCmd, NULL, NULL);
     Tcl_CreateObjCommand(interp, "term_get_size", TermGetSizeCmd, NULL, NULL);
 
+    Tcl_CreateObjCommand(interp, "check_broken_dns", CheckBrokenDNSCmd, NULL, NULL);
+
     if (Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK)
         return TCL_ERROR;
 

Modified: branches/new-help-system/base/src/pextlib1.0/base32cmd.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/base32cmd.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/pextlib1.0/base32cmd.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -42,11 +42,11 @@
 #include "base32cmd.h"
 
 /* This package provides commands for encoding and decoding of hexstrings
-   into and out of the extended hex base32 encoding as specified in RFC 3548.
+   into and out of the standard base32 encoding as specified in RFC 4648.
 
    Based on public domain base32 code from tcllib, by Andreas Kupries */
 
-#define BASE32HEX 1
+#undef BASE32HEX
 
 static __inline__ int hex2dec(int data)
 {

Modified: branches/new-help-system/base/src/pextlib1.0/md_wrappers.h
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/md_wrappers.h	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/pextlib1.0/md_wrappers.h	2012-12-15 00:33:09 UTC (rev 100533)
@@ -79,5 +79,15 @@
     return algo##End(&ctx, buf);						\
 }
 
+#define CHECKSUMData(algo, ctxtype)						\
+static char *algo##Data(const u_char *str, u_int32_t len, char *buf)		\
+{														\
+    ctxtype ctx;										\
+														\
+    algo##Init(&ctx);									\
+    algo##Update(&ctx,str,len);					        \
+    return algo##End(&ctx, buf);						\
+}
+
 #endif
 /* _MD_WRAPPERS_H */

Modified: branches/new-help-system/base/src/pextlib1.0/rmd160cmd.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/rmd160cmd.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/pextlib1.0/rmd160cmd.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -55,6 +55,7 @@
 #include "md_wrappers.h"
 CHECKSUMEnd(RIPEMD160_, RIPEMD160_CTX, RIPEMD160_DIGEST_LENGTH)
 CHECKSUMFile(RIPEMD160_, RIPEMD160_CTX)
+CHECKSUMData(RIPEMD160_, RIPEMD160_CTX)
 #else
 /*
  * let's use our own version of rmd160* libraries.
@@ -64,18 +65,22 @@
 #include "rmd160.c"
 #define RIPEMD160_DIGEST_LENGTH 20
 #define RIPEMD160_File(x,y) RMD160File(x,y)
+#define RIPEMD160_Data(x,y,z) RMD160Data(x,y,z)
 
 #include "md_wrappers.h"
 CHECKSUMEnd(RMD160, RMD160_CTX, RIPEMD160_DIGEST_LENGTH)
 CHECKSUMFile(RMD160, RMD160_CTX)
+CHECKSUMData(RMD160, RMD160_CTX)
 #endif
 
 int RMD160Cmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
-	char *file, *action;
+	char *file, *instr, *action;
+	int inlen;
 	char buf[2*RIPEMD160_DIGEST_LENGTH + 1];
 	const char usage_message[] = "Usage: rmd160 file";
-	const char error_message[] = "Could not open file: ";
+	const char file_error_message[] = "Could not open file: ";
+	const char string_error_message[] = "Could not process string: ";
 	Tcl_Obj *tcl_result;
 
 	if (objc != 3) {
@@ -84,22 +89,33 @@
 	}
 
 	/*
-	 * Only the 'file' action is currently supported
+	 * 'file' and 'string' actions are currently supported
 	 */
 	action = Tcl_GetString(objv[1]);
-	if (strcmp(action, "file") != 0) {
+	if (strcmp(action, "file") == 0) {
+	    file = Tcl_GetString(objv[2]);
+
+        if (!RIPEMD160_File(file, buf)) {
+            tcl_result = Tcl_NewStringObj(file_error_message, sizeof(file_error_message) - 1);
+            Tcl_AppendObjToObj(tcl_result, Tcl_NewStringObj(file, -1));
+            Tcl_SetObjResult(interp, tcl_result);
+            return TCL_ERROR;
+        }
+	} else if (strcmp(action, "string") == 0) {
+	    instr = Tcl_GetStringFromObj(objv[2], &inlen);
+
+	    if (!RIPEMD160_Data((u_char *)instr, (u_int32_t)inlen, buf)) {
+            tcl_result = Tcl_NewStringObj(string_error_message, sizeof(string_error_message) - 1);
+            Tcl_AppendObjToObj(tcl_result, Tcl_NewStringObj(instr, -1));
+            Tcl_SetObjResult(interp, tcl_result);
+            return TCL_ERROR;
+        }
+	} else {
 		tcl_result = Tcl_NewStringObj(usage_message, sizeof(usage_message) - 1);
 		Tcl_SetObjResult(interp, tcl_result);
 		return TCL_ERROR;
 	}
-	file = Tcl_GetString(objv[2]);
-
-	if (!RIPEMD160_File(file, buf)) {
-		tcl_result = Tcl_NewStringObj(error_message, sizeof(error_message) - 1);
-		Tcl_AppendObjToObj(tcl_result, Tcl_NewStringObj(file, -1));
-		Tcl_SetObjResult(interp, tcl_result);
-		return TCL_ERROR;
-	}
+	
 	tcl_result = Tcl_NewStringObj(buf, sizeof(buf) - 1);
 	Tcl_SetObjResult(interp, tcl_result);
 	return TCL_OK;

Modified: branches/new-help-system/base/src/pextlib1.0/system.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/system.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/pextlib1.0/system.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -3,7 +3,8 @@
  * system.c
  * $Id$
  *
- * Copyright (c) 2009 The MacPorts Project
+ * Copyright (c) 2002 - 2003 Apple, Inc.
+ * Copyright (c) 2008 - 2010, 2012 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -76,14 +77,42 @@
     char *line;
 };
 
+static int check_sandboxing(Tcl_Interp *interp, char **sandbox_exec_path, char **profilestr)
+{
+    Tcl_Obj *tcl_result;
+    int supported;
+    int len;
+
+    tcl_result = Tcl_GetVar2Ex(interp, "portsandbox_supported", NULL, TCL_GLOBAL_ONLY);
+    if (!tcl_result || Tcl_GetBooleanFromObj(interp, tcl_result, &supported) != TCL_OK || !supported) {
+        return 0;
+    }
+
+    tcl_result = Tcl_GetVar2Ex(interp, "portutil::autoconf::sandbox_exec_path", NULL, TCL_GLOBAL_ONLY);
+    if (!tcl_result || !(*sandbox_exec_path = Tcl_GetString(tcl_result))) {
+        return 0;
+    }
+
+    tcl_result = Tcl_GetVar2Ex(interp, "portsandbox_profile", NULL, TCL_GLOBAL_ONLY);
+    if (!tcl_result || !(*profilestr = Tcl_GetStringFromObj(tcl_result, &len)) 
+        || len == 0) {
+        return 0;
+    }
+
+    return 1;
+}
+
 /* usage: system ?-notty? ?-nice value? ?-W path? command */
 int SystemCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
     char *buf;
     struct linebuf circbuf[CBUFSIZ];
     size_t linelen;
-    char *args[4];
+    char *args[7];
     char *cmdstring;
+    int sandbox = 0;
+    char *sandbox_exec_path;
+    char *profilestr;
     FILE *pdes;
     int fdset[2], nullfd;
     int fline, pos, ret;
@@ -127,6 +156,9 @@
         }
     }
 
+    /* check if and how we should use sandbox-exec */
+    sandbox = check_sandboxing(interp, &sandbox_exec_path, &profilestr);
+
     /*
      * Fork a child to run the command, in a popen() like fashion -
      * popen() itself is not used because stderr is also desired.
@@ -177,11 +209,22 @@
         }
 
         /* XXX ugly string constants */
-        args[0] = "sh";
-        args[1] = "-c";
-        args[2] = cmdstring;
-        args[3] = NULL;
-        execve("/bin/sh", args, environ);
+        if (sandbox) {
+            args[0] = "sandbox-exec";
+            args[1] = "-p";
+            args[2] = profilestr;
+            args[3] = "sh";
+            args[4] = "-c";
+            args[5] = cmdstring;
+            args[6] = NULL;
+            execve(sandbox_exec_path, args, environ);
+        } else {
+            args[0] = "sh";
+            args[1] = "-c";
+            args[2] = cmdstring;
+            args[3] = NULL;
+            execve("/bin/sh", args, environ);
+        }
         _exit(1);
         break;
     default: /* parent */
@@ -251,6 +294,7 @@
         } else {
             char *errorstr;
             size_t errorstrlen;
+            Tcl_Obj* errorCode;
 
             /* print error */
             /* get buffer large enough for additional message or the error code */
@@ -265,7 +309,7 @@
             }
 
             /* set errorCode [list CHILDSTATUS <pid> <code>] */
-            Tcl_Obj* errorCode = Tcl_NewListObj(0, NULL);
+            errorCode = Tcl_NewListObj(0, NULL);
             Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewStringObj("CHILDSTATUS", -1));
             Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewIntObj(pid));
             Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewIntObj(WEXITSTATUS(ret)));

Modified: branches/new-help-system/base/src/pextlib1.0/tests/base32.tcl
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/tests/base32.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/pextlib1.0/tests/base32.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -5,13 +5,13 @@
 proc main {pextlibname} {
 	load $pextlibname
 	
-	if {[base32encode "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"] != "SEOC8GKOVGE196NRUJ49IRTP4GJQSGF4CIDP6J54IMCHMU2IN1AG===="} {
-		puts {[base32encode "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"] != "SEOC8GKOVGE196NRUJ49IRTP4GJQSGF4CIDP6J54IMCHMU2IN1AG===="}
+	if {[base32encode "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"] != "4OYMIQUY7QOBJGX36TEJS35ZEQT24QPEMSNZGTFESWMRW6CSXBKQ===="} {
+		puts {[base32encode "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"] != "4OYMIQUY7QOBJGX36TEJS35ZEQT24QPEMSNZGTFESWMRW6CSXBKQ===="}
 		exit 1
 	}
 
-	if {[base32decode "SEOC8GKOVGE196NRUJ49IRTP4GJQSGF4CIDP6J54IMCHMU2IN1AG===="] != "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} {
-		puts {[base32decode "SEOC8GKOVGE196NRUJ49IRTP4GJQSGF4CIDP6J54IMCHMU2IN1AG===="] != "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}
+	if {[base32decode "4OYMIQUY7QOBJGX36TEJS35ZEQT24QPEMSNZGTFESWMRW6CSXBKQ===="] != "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} {
+		puts {[base32decode "4OYMIQUY7QOBJGX36TEJS35ZEQT24QPEMSNZGTFESWMRW6CSXBKQ===="] != "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}
 		exit 1
 	}
 }

Modified: branches/new-help-system/base/src/pextlib1.0/tracelib.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/tracelib.c	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/pextlib1.0/tracelib.c	2012-12-15 00:33:09 UTC (rev 100533)
@@ -93,6 +93,7 @@
 static void sandbox_violation(int sock, const char * path);
 static void ui_warn(const char * format, ...);
 static void ui_info(const char * format, ...);
+static void ui_error(const char *format, ...);
 
 #define MAX_SOCKETS ((FD_SETSIZE)-1)
 
@@ -321,43 +322,47 @@
 	char * port=0;
 	size_t len=1;
 	char resolution='!';
+	int tcl_retval;
 		
 	Tcl_SetVar(interp, "path", path, 0);
-	Tcl_Eval(interp, "registry::file_registered $path");
-	port=strdup(Tcl_GetStringResult(interp));
+	/* FIXME: Use C registry API */
+	tcl_retval = Tcl_Eval(interp, "registry::file_registered $path");
+	port = strdup(Tcl_GetStringResult(interp));
 	if (!port) {
 		ui_warn("dep_check: memory allocation failed");
 	    return;
 	}
+	if (tcl_retval != TCL_OK) {
+		ui_error("failed to run registry::file_registered \"%s\": %s", path, port);
+	}
 	Tcl_UnsetVar(interp, "path", 0);
 	
-	if(*port!='0'||port[1])
-	{
-		char * t;
+	if (tcl_retval == TCL_OK && (*port != '0' || port[1])) {
+		char *t;
 	
-		t=depends;
-		for(;*t;t+=strlen(t)+1)
-		{
-			if(!strcmp(t, port))
-			{
-				resolution='+';
+		t = depends;
+		for (; *t; t += strlen(t) + 1) {
+			/* fprintf(stderr, "trace: %s =?= %s\n", t, port); */
+			if (!strcmp(t, port)) {
+				resolution = '+';
 				break;
 			}
 		}
 	}
-	
-	if(resolution!='+') {
-	    if(*port=='0'&&!port[1])
+
+	if (resolution != '+') {
+	    if (*port == '0' && !port[1]) {
 		    ui_info("trace: access denied to %s (*unknown*)", path);
-		else
+		} else {
 		    ui_info("trace: access denied to %s (%s)", path, port);
+		}
     }
 
 	free(port);
 	
-	if(send(sock, &len, sizeof(len), 0)==-1)
+	if (send(sock, &len, sizeof(len), 0) == -1)
 		ui_warn("tracelib send failed");
-	if(send(sock, &resolution, 1, 0)==-1)
+	if (send(sock, &resolution, 1, 0) == -1)
 		ui_warn("tracelib send failed");
 }
 
@@ -370,8 +375,9 @@
 	snprintf(tclcmd, sizeof(tclcmd), "ui_%s $warn", severity);
 	
 	Tcl_SetVar(interp, "warn", buf, 0);
-	
-	Tcl_Eval(interp, tclcmd);
+	if (TCL_OK != Tcl_Eval(interp, tclcmd)) {
+		fprintf(stderr, "Error evaluating tcl statement `%s': %s\n", tclcmd, Tcl_GetStringResult(interp));
+	}
 	Tcl_UnsetVar(interp, "warn", 0);
 	
 }
@@ -381,7 +387,7 @@
 	va_list va;
 	
 	va_start(va, format);
-		ui_msg("warn", format, va);
+	ui_msg("warn", format, va);
 	va_end(va);
 }
 
@@ -390,10 +396,17 @@
 	va_list va;
 	
 	va_start(va, format);
-		ui_msg("msg", format, va);
+	ui_msg("info", format, va);
 	va_end(va);
 }
 
+static void ui_error(const char *format, ...) {
+	va_list va;
+	va_start(va, format);
+	ui_msg("error", format, va);
+	va_end(va);
+}
+
 static int TracelibOpenSocketCmd(Tcl_Interp * in)
 {
 	struct sockaddr_un sun;

Modified: branches/new-help-system/base/src/port/port-help.tcl
===================================================================
--- branches/new-help-system/base/src/port/port-help.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port/port-help.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -179,7 +179,9 @@
 }
 
 set porthelp(install) {
-Installs the given ports
+Installs the given ports.
+    --no-rev-upgrade    Do not run rev-upgrade after the installation.
+    --unrequested       Do not mark the port as requested.
 }
 
 set porthelp(installed) {
@@ -345,7 +347,14 @@
 set porthelp(uninstall) {
 Uninstall the given ports
 
---no-exec   Do not execute any stored pre- or post-uninstall procedures
+--follow-dependents     Recursively uninstall all ports that depend on the
+                        specified port before uninstalling the port itself.
+--follow-dependencies   Also recursively uninstall all ports that the
+                        specified port depended on. This will not uninstall
+                        dependencies that are marked as requested or that
+                        have other dependents.
+--no-exec               Do not execute any stored pre- or post-uninstall
+                        procedures.
 }
 
 set porthelp(unload) $porthelp(load)

Modified: branches/new-help-system/base/src/port/port.tcl
===================================================================
--- branches/new-help-system/base/src/port/port.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port/port.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -5,7 +5,7 @@
 # port.tcl
 # $Id$
 #
-# Copyright (c) 2004-2011 The MacPorts Project
+# Copyright (c) 2004-2012 The MacPorts Project
 # Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
 # Copyright (c) 2002-2003 Apple Inc.
 # All rights reserved.
@@ -297,7 +297,8 @@
     switch -- $field {
         variant -
         platform -
-        maintainer {
+        maintainer -
+        subport {
             set field "${field}s"
         }
         category {
@@ -1140,7 +1141,43 @@
     return [portlist_sort $results]
 }
 
+proc get_subports {portname} {
+    global global_variations
 
+    # look up portname
+    if {[catch {mportlookup $portname} result]} {
+        ui_debug "$::errorInfo"
+        return -code error "lookup of portname $portname failed: $result"
+    }
+    if {[llength $result] < 2} {
+        return -code error "Port $portname not found"
+    }
+    array unset portinfo
+    array set portinfo [lindex $result 1]
+    set porturl $portinfo(porturl)
+
+    # open portfile
+    if {[catch {set mport [mportopen $porturl [list subport $portinfo(name)] [array get global_variations]]} result]} {
+        ui_debug "$::errorInfo"
+        return -code error "Unable to open port: $result"
+    }
+    array unset portinfo
+    array set portinfo [mportinfo $mport]
+    mportclose $mport
+
+    # gather its subports
+    set results {}
+
+    if {[info exists portinfo(subports)]} {
+        foreach subport $portinfo(subports) {
+            add_to_portlist results [list name $subport]
+        }
+    }
+
+    return [portlist_sort $results]
+}
+
+
 ##########################################
 # Port expressions
 ##########################################
@@ -1325,6 +1362,8 @@
         ^depends_fetch:     -
         ^replaced_by:       -
         ^revision:          -
+        ^subport:           -
+        ^subports:          -
         ^license:           { # Handle special port selectors
             advance
 
@@ -1379,6 +1418,17 @@
             set el 1
         }
 
+        ^subportof:         {
+            advance
+
+            # Break up the token, because older Tcl switch doesn't support -matchvar
+            regexp {^(\w+):(.*)} $token matchvar selector portname
+
+            add_multiple_ports reslist [get_subports $portname]
+
+            set el 1
+        }
+
         [][?*]              { # Handle portname glob patterns
             advance; add_multiple_ports reslist [get_matching_ports $token no glob]
             set el 1
@@ -1822,6 +1872,7 @@
             array set portinfo [lindex $result 1]
             set porturl $portinfo(porturl)
             set portdir $portinfo(portdir)
+            set portname $portinfo(name)
         } elseif {$porturl ne "file://."} {
             # Extract the portdir from porturl and use it to search PortIndex.
             # Only the last two elements of the path (porturl) make up the
@@ -1839,7 +1890,14 @@
                 break_softcontinue "Portdir $portdir not found" 1 status
             }
             array unset portinfo
-            array set portinfo [lindex $result 1]
+            set matchindex [lsearch -exact -nocase $result $portname]
+            if {$matchindex != -1} {
+                array set portinfo [lindex $result [incr matchindex]]
+            } else {
+                ui_warn "Portdir $portdir doesn't seem to belong to portname $portname"
+                array set portinfo [lindex $result 1]
+            }
+            set portname $portinfo(name)
         }
         set portpath [macports::getportdir $porturl]
         set logfile [file join [macports::getportlogpath $portpath $portname] "main.log"]
@@ -2585,18 +2643,19 @@
     foreachport $portlist {
         if {![info exists depscache(port:$portname)]} {
             set status [macports::upgrade $portname "port:$portname" [array get requested_variations] [array get options] depscache]
-            # status 2 means the port was not found in the index
-            if {$status != 0 && $status != 2 && ![macports::ui_isset ports_processall]} {
+            # status 2 means the port was not found in the index,
+            # status 3 means the port is not installed
+            if {$status != 0 && $status != 2 && $status != 3 && ![macports::ui_isset ports_processall]} {
                 break
             }
         }
     }
     
-    if {$status != 0} {
+    if {$status != 0 && $status != 2 && $status != 3} {
         print_tickets_url
-    } else {
+    } elseif {$status == 0} {
         array set options $opts
-        if {![info exists options(ports_upgrade_no-rev-upgrade)] && ${macports::revupgrade_autorun}} {
+        if {![info exists options(ports_upgrade_no-rev-upgrade)] && ${macports::revupgrade_autorun} && ![macports::global_option_isset ports_dryrun]} {
             set status [action_revupgrade $action $portlist $opts]
         }
     }
@@ -2781,7 +2840,13 @@
             if {[llength $result] < 2} {
                 break_softcontinue "Portdir $portdir not found" 1 status
             }
-            array set portinfo [lindex $result 1]
+            set matchindex [lsearch -exact -nocase $result $portname]
+            if {$matchindex != -1} {
+                array set portinfo [lindex $result [incr matchindex]]
+            } else {
+                ui_warn "Portdir $portdir doesn't seem to belong to portname $portname"
+                array set portinfo [lindex $result 1]
+            }
         }
 
         if {!([info exists options(ports_${action}_index)] && $options(ports_${action}_index) eq "yes")} {
@@ -3684,6 +3749,7 @@
             }
             array set portinfo [lindex $res 1]
             set porturl $portinfo(porturl)
+            set portname $portinfo(name)
         }
         
         
@@ -3894,7 +3960,9 @@
         }
         # if installing, mark the port as explicitly requested
         if {$action == "install"} {
-            set options(ports_requested) 1
+            if {![info exists options(ports_install_unrequested)]} {
+                set options(ports_requested) 1
+            }
             # we actually activate as well
             set target activate
         } elseif {$action == "archive"} {
@@ -3930,7 +3998,7 @@
         }
     }
     
-    if {$status == 0 && $action == "install"} {
+    if {$status == 0 && $action == "install" && ![macports::global_option_isset ports_dryrun]} {
         array set options $opts
         if {![info exists options(ports_nodeps)] && ![info exists options(ports_install_no-rev-upgrade)] && ${macports::revupgrade_autorun}} {
             set status [action_revupgrade $action $portlist $opts]
@@ -4172,7 +4240,7 @@
     space       {{units 1}}
     activate    {no-exec}
     deactivate  {no-exec}
-    install     {no-rev-upgrade}
+    install     {no-rev-upgrade unrequested}
     uninstall   {follow-dependents follow-dependencies no-exec}
     variants    {index}
     clean       {all dist work logs}
@@ -4300,7 +4368,7 @@
                         set global_options(ports_force) yes
                     }
                     o {
-                        set global_options(ports_ignore_older) yes
+                        set global_options(ports_ignore_different) yes
                     }
                     n {
                         set global_options(ports_nodeps) yes

Modified: branches/new-help-system/base/src/port/portindex.tcl
===================================================================
--- branches/new-help-system/base/src/port/portindex.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port/portindex.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -187,6 +187,10 @@
                 set os_platform [lindex $platlist 0]
                 set os_major [lindex $platlist 1]
                 set os_arch [lindex $platlist 2]
+                if {$os_platform == "macosx"} {
+                    lappend port_options os.subplatform $os_platform os.universal_supported yes
+                    set os_platform darwin
+                }
                 lappend port_options os.platform $os_platform os.major $os_major os.arch $os_arch
             } elseif {$arg == "-f"} { # Completely rebuild index
                 set full_reindex 1

Modified: branches/new-help-system/base/src/port1.0/Makefile
===================================================================
--- branches/new-help-system/base/src/port1.0/Makefile	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/Makefile	2012-12-15 00:33:09 UTC (rev 100533)
@@ -6,7 +6,8 @@
 	portlint.tcl portclean.tcl porttest.tcl portactivate.tcl \
 	portdeactivate.tcl portsubmit.tcl port_autoconf.tcl portstartupitem.tcl \
 	porttrace.tcl portlivecheck.tcl portdistcheck.tcl portmirror.tcl \
-	portload.tcl portunload.tcl portdistfiles.tcl fetch_common.tcl
+	portload.tcl portunload.tcl portdistfiles.tcl fetch_common.tcl \
+	portsandbox.tcl
 
 include ../../Mk/macports.subdir.mk
 include ../../Mk/macports.autoconf.mk
@@ -33,3 +34,5 @@
 
 test::
 	${TCLSH} tests/portutil.tcl ${macports_tcl_dir}
+	${TCLSH} tests/portdestroot.tcl ${macports_tcl_dir}
+	${TCLSH} tests/portfetch.tcl ${macports_tcl_dir}

Modified: branches/new-help-system/base/src/port1.0/fetch_common.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/fetch_common.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/fetch_common.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -2,7 +2,7 @@
 # $Id$
 #
 # Copyright (c) 2002 - 2003 Apple Inc.
-# Copyright (c) 2004 - 2011 The MacPorts Project
+# Copyright (c) 2004 - 2012 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -103,10 +103,17 @@
 
         # here we have the chance to take a look at tags, that possibly
         # have been assigned in mirror_sites.tcl
-        set splitlist [split $element :]
-        # every element is a URL, so we'll always have multiple elements. no need to check
-        set element "[lindex $splitlist 0]:[lindex $splitlist 1]"
-        set mirror_tag "[lindex $splitlist 2]"
+        # tag will be after the last colon after the
+        # first slash after the ://
+        set lastcolon [string last : $element]
+        set aftersep [expr [string first : $element] + 3]
+        set firstslash [string first / $element $aftersep]
+        if {$firstslash != -1 && $firstslash < $lastcolon} {
+            set mirror_tag [string range $element [expr $lastcolon + 1] end]
+            set element [string range $element 0 [expr $lastcolon - 1]]
+        } else {
+            set mirror_tag ""
+        }
 
         set name_re {\$(?:name\y|\{name\})}
         # if the URL has $name embedded, kill any mirror_tag that may have been added
@@ -332,3 +339,11 @@
 
     return $urls
 }
+
+# warn if DNS is broken
+proc portfetch::check_dns {} {
+    # check_broken_dns returns true at most once, so we don't have to worry about spamming this message
+    if {[check_broken_dns]} {
+        ui_warn "Your DNS server(s) incorrectly claim to know the address of nonexistent hosts. This may cause checksum mismatches for some ports."
+    }
+}

Modified: branches/new-help-system/base/src/port1.0/port.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/port.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/port.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -58,3 +58,4 @@
 package require portunload 1.0
 
 package require portdistfiles 1.0
+package require portsandbox 1.0

Modified: branches/new-help-system/base/src/port1.0/port_autoconf.tcl.in
===================================================================
--- branches/new-help-system/base/src/port1.0/port_autoconf.tcl.in	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/port_autoconf.tcl.in	2012-12-15 00:33:09 UTC (rev 100533)
@@ -65,6 +65,7 @@
 	variable xcode_select_path "@XCODE_SELECT@"
 	variable xcodebuild_path "@XCODEBUILD@"
 	variable xcrun_path "@XCRUN@"
+	variable sandbox_exec_path "@SANDBOX_EXEC@"
 	variable sed_command "@SED@"
 	variable sed_ext_flag "@SED_EXT@"
 	variable tar_command "@TAR_CMD@"

Modified: branches/new-help-system/base/src/port1.0/portbuild.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portbuild.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portbuild.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -2,7 +2,7 @@
 # portbuild.tcl
 # $Id$
 #
-# Copyright (c) 2007 - 2011 The MacPorts Project
+# Copyright (c) 2007 - 2012 The MacPorts Project
 # Copyright (c) 2002 - 2004 Apple Inc.
 # All rights reserved.
 #
@@ -43,9 +43,10 @@
 }
 
 # define options
+options build.asroot
+options build.jobs
 options build.target
-options build.jobs
-options build.asroot
+options build.type
 options use_parallel_build
 commands build
 # defaults
@@ -56,12 +57,38 @@
 default build.jobs {[portbuild::build_getjobs]}
 default build.pre_args {[portbuild::build_getargs]}
 default build.target "all"
+default build.type "default"
 default use_parallel_build yes
 
+# proc to add dependency on bsdmake, if necessary
+option_proc build.type portbuild::set_build_type
+
 set_ui_prefix
 
+proc portbuild::set_build_type {option action args} {
+    array set build_type_map {
+        bsd     {bin:bsdmake:bsdmake}
+    }
+
+    if {$action == "set"} {
+        switch $option {
+            build.type {
+                # using [exists foo] doesn't work with arrays!
+                if {[info exists build_type_map([option build.type])]} {
+                    # remove dependencies added before when setting build.type more than once
+                    eval depends_build-delete $build_type_map([option build.type])
+                }
+                if {[info exists build_type_map($args)]} {
+                    # add dependency if needed
+                    eval depends_build-append $build_type_map($args)
+                }
+            }
+        }
+    }
+}
+
 proc portbuild::build_getmaketype {args} {
-    if {![exists build.type]} {
+    if {[option build.type] == "default"} {
         return [findBinary make $portutil::autoconf::make_path]
     }
     switch -exact -- [option build.type] {
@@ -124,7 +151,8 @@
 }
 
 proc portbuild::build_getargs {args} {
-    if {((![exists build.type] && [option os.platform] != "freebsd") || ([exists build.type] && [option build.type] == "gnu")) \
+    if {(([option build.type] == "default" && [option os.platform] != "freebsd") || \
+         ([option build.type] == "gnu")) \
         && [regexp "^(/\\S+/|)(g|gnu|)make(\\s+.*|)$" [option build.cmd]]} {
         # Print "Entering directory" lines for better log debugging
         return "-w [option build.target]"

Modified: branches/new-help-system/base/src/port1.0/portchecksum.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portchecksum.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portchecksum.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -280,6 +280,8 @@
                     && "text/html" == $mimetype} {
                     # file --mime-type would be preferable to file --mime and strsed, but is only available as of Snow Leopard
                     set wrong_mimetype yes
+                    set htmlfile_path ${fullpath}.html
+                    file rename -force $fullpath $htmlfile_path
                 }
             }
 
@@ -291,10 +293,6 @@
 
     if {[tbool fail]} {
 
-        # Show the desired checksum line for easy cut-paste
-        ui_info "The correct checksum line may be:"
-        ui_info [format "%-20s%s" "checksums" [join $sums [format " \\\n%-20s" ""]]]
-
         if {[tbool wrong_mimetype]} {
             # We got an HTML file, though the distfile name does not suggest that one was
             # expected. Probably a helpful DNS server sent us to its search results page
@@ -305,6 +303,11 @@
             ui_notice "for the checksum mismatch:"
             ui_notice "<https://trac.macports.org/wiki/MisbehavingServers>"
             ui_notice "***"
+            ui_notice "The file has been moved to: $htmlfile_path"
+        } else {
+            # Show the desired checksum line for easy cut-paste
+            ui_info "The correct checksum line may be:"
+            ui_info [format "%-20s%s" "checksums" [join $sums [format " \\\n%-20s" ""]]]
         }
 
         return -code error "[msgcat::mc "Unable to verify file checksums"]"

Modified: branches/new-help-system/base/src/port1.0/portconfigure.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portconfigure.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portconfigure.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -2,7 +2,7 @@
 # portconfigure.tcl
 # $Id$
 #
-# Copyright (c) 2007 - 2011 The MacPorts Project
+# Copyright (c) 2007 - 2012 The MacPorts Project
 # Copyright (c) 2007 Markus W. Weissmann <mww at macports.org>
 # Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
@@ -210,35 +210,46 @@
         apple-gcc-4.0 { set name "MacPorts Apple gcc 4.0" }
         apple-gcc-4.2 { set name "MacPorts Apple gcc 4.2" }
         macports-gcc     { set name "MacPorts gcc (port select)" }
-        macports-gcc-4.0 { set name "MacPorts gcc 4.0" }
-        macports-gcc-4.1 { set name "MacPorts gcc 4.1" }
         macports-gcc-4.2 { set name "MacPorts gcc 4.2" }
         macports-gcc-4.3 { set name "MacPorts gcc 4.3" }
         macports-gcc-4.4 { set name "MacPorts gcc 4.4" }
         macports-gcc-4.5 { set name "MacPorts gcc 4.5" }
         macports-gcc-4.6 { set name "MacPorts gcc 4.6" }
+        macports-gcc-4.7 { set name "MacPorts gcc 4.7" }
+        macports-gcc-4.8 { set name "MacPorts gcc 4.8" }
         macports-llvm-gcc-4.2 { set name "MacPorts llvm-gcc 4.2" }
         macports-clang { set name "MacPorts clang (port select)" }
         macports-clang-2.9 { set name "MacPorts clang 2.9" }
         macports-clang-3.0 { set name "MacPorts clang 3.0" }
         macports-clang-3.1 { set name "MacPorts clang 3.1" }
+        macports-clang-3.2 { set name "MacPorts clang 3.2" }
         default { return -code error "Invalid value for configure.compiler" }
     }
     ui_debug "Using compiler '$name'"
 
     # Additional ccache directory setup
-    global configureccache ccache_dir ccache_size macportsuser
-    if {${configureccache}} {
+    global configure.ccache ccache_dir ccache_size macportsuser
+    if {${configure.ccache}} {
+        # Create ccache directory with correct permissions with root privileges
         elevateToRoot "configure ccache"
         if [catch {
                 file mkdir ${ccache_dir}
                 file attributes ${ccache_dir} -owner ${macportsuser} -permissions 0755
+            } result] {
+            ui_warn "ccache_dir ${ccache_dir} could not be created; disabling ccache: $result"
+            set configure.ccache no
+        }
+        dropPrivileges
+
+        # Initialize ccache directory with the given maximum size
+        if {${configure.ccache}} {
+            if [catch {
                 exec ccache -M ${ccache_size} >/dev/null
             } result] {
-            ui_warn "ccache_dir ${ccache_dir} could not be initialized; disabling ccache: $result"
-            set configureccache no
+                ui_warn "ccache_dir ${ccache_dir} could not be initialized; disabling ccache: $result"
+                set configure.ccache no
+            }
         }
-        dropPrivileges
     }
 }
 
@@ -356,6 +367,10 @@
         clang -
         apple-gcc-4.0 -
         apple-gcc-4.2 -
+        macports-clang-2.9 -
+        macports-clang-3.0 -
+        macports-clang-3.1 -
+        macports-clang-3.2 -
         macports-clang {
             return yes
         }
@@ -386,10 +401,13 @@
         macports-gcc-4.4        gcc44
         macports-gcc-4.5        gcc45
         macports-gcc-4.6        gcc46
+        macports-gcc-4.7        gcc47
+        macports-gcc-4.8        gcc48
         macports-llvm-gcc-4.2   llvm-gcc42
         macports-clang-2.9      clang-2.9
         macports-clang-3.0      clang-3.0
         macports-clang-3.1      clang-3.1
+        macports-clang-3.2      clang-3.2
 }
 
 # internal function to determine the default compiler
@@ -414,19 +432,27 @@
 
 # internal function to choose compiler fallback list based on platform
 proc portconfigure::get_compiler_fallback {} {
-    global xcodeversion macosx_deployment_target
-    if {$xcodeversion == "none" || $xcodeversion == ""} {
+    global xcodeversion macosx_deployment_target default_compiler
+    if {[info exists default_compiler]} {
+        return $default_compiler
+    } elseif {$xcodeversion == "none" || $xcodeversion == ""} {
         return {cc}
     } elseif {[vercmp $xcodeversion 4.2] >= 0} {
         return {clang llvm-gcc-4.2 apple-gcc-4.2}
     } elseif {[vercmp $xcodeversion 4.0] >= 0} {
         return {llvm-gcc-4.2 clang gcc-4.2}
-    } elseif {[vercmp $xcodeversion 3.2] >= 0 && $macosx_deployment_target != "10.4"} {
-        return {gcc-4.2 clang llvm-gcc-4.2 gcc-4.0 apple-gcc-4.0}
-    } elseif {$macosx_deployment_target != "10.4"} {
-        return {gcc-4.0 gcc-4.2 llvm-gcc-4.2 gcc-3.3 apple-gcc-4.0}
+    } elseif {[vercmp $xcodeversion 3.2] >= 0} {
+        if {$macosx_deployment_target == "10.4"} {
+            # It's not the deployment target that is the issue, it's the
+            # 10.4u SDK which base chooses if the deployment_target is set
+            return {gcc-4.0}
+        } else {
+            return {gcc-4.2 clang llvm-gcc-4.2 gcc-4.0}
+        }
+    } elseif {[vercmp $xcodeversion 3.0] >= 0} {
+        return {gcc-4.2 apple-gcc-4.2 macports-clang-3.0 gcc-4.0}
     } else {
-        return {gcc-4.0 gcc-3.3 apple-gcc-4.0}
+        return {gcc-4.0 apple-gcc-4.2 macports-clang-3.0 gcc-3.3}
     }
 }
 
@@ -460,15 +486,16 @@
     if {$compiler == {}} {
         set compiler ${configure.compiler}
     }
+
+    # Set defaults
+    switch -exact ${type} {
+        cc   { set ret [find_developer_tool cc] }
+        objc { set ret [find_developer_tool cc] }
+        cxx  { set ret [find_developer_tool c++] }
+        cpp  { set ret [find_developer_tool cpp] }
+    }
+
     switch -exact ${compiler} {
-        cc {
-            switch -exact ${type} {
-                cc   { set ret [find_developer_tool cc] }
-                objc { set ret [find_developer_tool cc] }
-                cxx  { set ret [find_developer_tool c++] }
-                cpp  { set ret [find_developer_tool cpp] }
-            }
-        }
         gcc {
             switch -exact ${type} {
                 cc   { set ret [find_developer_tool gcc] }
@@ -514,7 +541,7 @@
                 cc   { set ret [find_developer_tool clang] }
                 objc { set ret [find_developer_tool clang] }
                 cxx  {
-					set clangpp [find_developer_tool clang++]
+                    set clangpp [find_developer_tool clang++]
                     if {[file executable ${clangpp}]} {
                         set ret ${clangpp}
                     } else {
@@ -549,28 +576,6 @@
                 f90  { set ret ${prefix}/bin/gfortran }
             }
         }
-        macports-gcc-4.0 {
-            switch -exact ${type} {
-                cc   { set ret ${prefix}/bin/gcc-mp-4.0 }
-                objc { set ret ${prefix}/bin/gcc-mp-4.0 }
-                cxx  { set ret ${prefix}/bin/g++-mp-4.0 }
-                cpp  { set ret ${prefix}/bin/cpp-mp-4.0 }
-                fc   { set ret ${prefix}/bin/gfortran-mp-4.0 }
-                f77  { set ret ${prefix}/bin/gfortran-mp-4.0 }
-                f90  { set ret ${prefix}/bin/gfortran-mp-4.0 }
-            }
-        }
-        macports-gcc-4.1 {
-            switch -exact ${type} {
-                cc   { set ret ${prefix}/bin/gcc-mp-4.1 }
-                objc { set ret ${prefix}/bin/gcc-mp-4.1 }
-                cxx  { set ret ${prefix}/bin/g++-mp-4.1 }
-                cpp  { set ret ${prefix}/bin/cpp-mp-4.1 }
-                fc   { set ret ${prefix}/bin/gfortran-mp-4.1 }
-                f77  { set ret ${prefix}/bin/gfortran-mp-4.1 }
-                f90  { set ret ${prefix}/bin/gfortran-mp-4.1 }
-            }
-        }
         macports-gcc-4.2 {
             switch -exact ${type} {
                 cc   { set ret ${prefix}/bin/gcc-mp-4.2 }
@@ -626,6 +631,28 @@
                 f90  { set ret ${prefix}/bin/gfortran-mp-4.6 }
             }
         }
+        macports-gcc-4.7 {
+            switch -exact ${type} {
+                cc   { set ret ${prefix}/bin/gcc-mp-4.7 }
+                objc { set ret ${prefix}/bin/gcc-mp-4.7 }
+                cxx  { set ret ${prefix}/bin/g++-mp-4.7 }
+                cpp  { set ret ${prefix}/bin/cpp-mp-4.7 }
+                fc   { set ret ${prefix}/bin/gfortran-mp-4.7 }
+                f77  { set ret ${prefix}/bin/gfortran-mp-4.7 }
+                f90  { set ret ${prefix}/bin/gfortran-mp-4.7 }
+            }
+        }
+        macports-gcc-4.8 {
+            switch -exact ${type} {
+                cc   { set ret ${prefix}/bin/gcc-mp-4.8 }
+                objc { set ret ${prefix}/bin/gcc-mp-4.8 }
+                cxx  { set ret ${prefix}/bin/g++-mp-4.8 }
+                cpp  { set ret ${prefix}/bin/cpp-mp-4.8 }
+                fc   { set ret ${prefix}/bin/gfortran-mp-4.8 }
+                f77  { set ret ${prefix}/bin/gfortran-mp-4.8 }
+                f90  { set ret ${prefix}/bin/gfortran-mp-4.8 }
+            }
+        }
         macports-llvm-gcc-4.2 {
             switch -exact ${type} {
                 cc   { set ret ${prefix}/bin/llvm-gcc-4.2 }
@@ -665,6 +692,13 @@
                 cxx  { set ret ${prefix}/bin/clang++-mp-3.1 }
             }
         }
+        macports-clang-3.2 {
+            switch -exact ${type} {
+                cc   { set ret ${prefix}/bin/clang-mp-3.2 }
+                objc { set ret ${prefix}/bin/clang-mp-3.2 }
+                cxx  { set ret ${prefix}/bin/clang++-mp-3.2 }
+            }
+        }
     }
     return $ret
 }

Modified: branches/new-help-system/base/src/port1.0/portdestroot.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portdestroot.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portdestroot.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 2002 - 2003 Apple Inc.
 # Copyright (c) 2004 - 2005 Robert Shaw <rshaw at opendarwin.org>
-# Copyright (c) 2004-2005, 2007-2011 The MacPorts Project
+# Copyright (c) 2004-2005, 2007-2012 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -90,7 +90,8 @@
 set_ui_prefix
 
 proc portdestroot::destroot_getargs {args} {
-    if {((![exists build.type] && [option os.platform] != "freebsd") || ([exists build.type] && [option build.type] == "gnu")) \
+    if {(([option build.type] == "default" && [option os.platform] != "freebsd") || \
+         ([option build.type] == "gnu")) \
         && [regexp "^(/\\S+/|)(g|gnu|)make(\\s+.*|)$" [option destroot.cmd]]} {
         # Print "Entering directory" lines for better log debugging
         return "-w [option destroot.target]"

Modified: branches/new-help-system/base/src/port1.0/portdistcheck.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portdistcheck.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portdistcheck.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -91,7 +91,7 @@
                         ui_warn "couldn't fetch $file_url for $subport ($error)"
                     } else {
                         if {$urlnewer} {
-                            ui_warn "port $subport: $file_url is newer than portfile"
+                            ui_warn "port $subport: $file_url is newer than Portfile"
                         }
                         incr count
                     }

Modified: branches/new-help-system/base/src/port1.0/portfetch.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portfetch.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portfetch.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -2,7 +2,7 @@
 # portfetch.tcl
 # $Id$
 #
-# Copyright (c) 2004 - 2011 The MacPorts Project
+# Copyright (c) 2004 - 2012 The MacPorts Project
 # Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
@@ -279,11 +279,40 @@
 
 # Perform a bzr fetch
 proc portfetch::bzrfetch {args} {
-    global patchfiles
-    if {[catch {command_exec bzr "" "2>&1"} result]} {
-        return -code error [msgcat::mc "Bazaar checkout failed"]
+    global env patchfiles
+
+    # Behind a proxy bzr will fail with the following error if proxies
+    # listed in macports.conf appear in the environment in their
+    # unmodified form:
+    #   bzr: ERROR: Invalid url supplied to transport:
+    #   "proxy.example.com:8080": No host component
+    # Set the "http_proxy" and "HTTPS_PROXY" environmental variables
+    # to valid URLs by prepending "http://" and appending "/".
+    if {   [info exists env(http_proxy)]
+        && [string compare -length 7 {http://} $env(http_proxy)] != 0} {
+        set orig_http_proxy $env(http_proxy)
+        set env(http_proxy) http://${orig_http_proxy}/
     }
 
+    if {   [info exists env(HTTPS_PROXY)]
+        && [string compare -length 7 {http://} $env(HTTPS_PROXY)] != 0} {
+        set orig_https_proxy $env(HTTPS_PROXY)
+        set env(HTTPS_PROXY) http://${orig_https_proxy}/
+    }
+
+    try {
+        if {[catch {command_exec bzr "" "2>&1"} result]} {
+            return -code error [msgcat::mc "Bazaar checkout failed"]
+        }
+    } finally {
+        if ([info exists orig_http_proxy]) {
+            set env(http_proxy) ${orig_http_proxy}
+        }
+        if ([info exists orig_https_proxy]) {
+            set env(HTTPS_PROXY) ${orig_https_proxy}
+        }
+    }
+
     if {[info exists patchfiles]} {
         return [portfetch::fetchfiles]
     }
@@ -337,6 +366,31 @@
     return 0
 }
 
+# Given a URL to a Subversion repository, if the URL is http:// or
+# https:// and MacPorts has been configured with a proxy for that URL
+# type, then return command line options that should be passed to the
+# svn command line client to enable use of that proxy.  There are no
+# proxies for Subversion's native protocol, identified by svn:// URLs.
+proc portfetch::svn_proxy_args {url} {
+    global env
+
+    if {   [string compare -length 7 {http://} ${url}] == 0
+        && [info exists env(http_proxy)]} {
+        set proxy_str $env(http_proxy)
+    } elseif {   [string compare -length 8 {https://} ${url}] == 0
+              && [info exists env(HTTPS_PROXY)]} {
+        set proxy_str $env(HTTPS_PROXY)
+    } else {
+        return ""
+    }
+    regexp {(.*://)?([[:alnum:].-]+)(:(\d+))?} $proxy_str - - proxy_host - proxy_port
+    set ret "--config-option servers:global:http-proxy-host=${proxy_host}"
+    if {$proxy_port != ""} {
+        append ret " --config-option servers:global:http-proxy-port=${proxy_port}"
+    }
+    return $ret
+}
+
 # Perform an svn fetch
 proc portfetch::svnfetch {args} {
     global svn.args svn.method svn.revision svn.url patchfiles
@@ -348,8 +402,11 @@
     if {[string length ${svn.revision}]} {
         append svn.url "@${svn.revision}"
     }
-    set svn.args "${svn.method} ${svn.args} ${svn.url}"
 
+    set proxy_args [svn_proxy_args ${svn.url}]
+
+    set svn.args "${svn.method} ${svn.args} ${proxy_args} ${svn.url}"
+
     if {[catch {command_exec svn "" "2>&1"} result]} {
         return -code error [msgcat::mc "Subversion check out failed"]
     }
@@ -395,10 +452,15 @@
 
 # Perform a mercurial fetch.
 proc portfetch::hgfetch {args} {
-    global worksrcpath prefix_frozen patchfiles
-    global hg.url hg.tag hg.cmd
+    global worksrcpath prefix_frozen patchfiles hg.url hg.tag hg.cmd \
+           fetch.ignore_sslcert
 
-    set cmdstring "${hg.cmd} clone --rev ${hg.tag} ${hg.url} ${worksrcpath} 2>&1"
+    set insecureflag ""
+    if {${fetch.ignore_sslcert}} {
+        set insecureflag " --insecure"
+    }
+
+    set cmdstring "${hg.cmd} clone${insecureflag} --rev \"${hg.tag}\" ${hg.url} ${worksrcpath} 2>&1"
     ui_debug "Executing: $cmdstring"
     if {[catch {system $cmdstring} result]} {
         return -code error [msgcat::mc "Mercurial clone failed"]
@@ -470,7 +532,7 @@
                     set fetched 1
                     break
                 } else {
-                    ui_debug "[msgcat::mc "Fetching failed:"]: $result"
+                    ui_debug "[msgcat::mc "Fetching distfile failed"]: $result"
                     file delete -force "${distpath}/${distfile}.TMP"
                 }
             }
@@ -514,22 +576,30 @@
 proc portfetch::fetch_start {args} {
     global UI_PREFIX subport distpath
 
-    ui_notice "$UI_PREFIX [format [msgcat::mc "Fetching %s"] $subport]"
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Fetching distfiles for %s"] $subport]"
 
     # create and chown $distpath
     if {![file isdirectory $distpath]} {
         if {[catch {file mkdir $distpath} result]} {
             elevateToRoot "fetch"
-            set elevated yes
             if {[catch {file mkdir $distpath} result]} {
                 return -code error [format [msgcat::mc "Unable to create distribution files path: %s"] $result]
             }
+            chownAsRoot $distpath
+            dropPrivileges
         }
     }
-    chownAsRoot $distpath
-    if {[info exists elevated] && $elevated == yes} {
-        dropPrivileges
+    if {![file owned $distpath]} {
+        if {[catch {chownAsRoot $distpath} result]} {
+            if {[file writable $distpath]} {
+                ui_warn "$UI_PREFIX [format [msgcat::mc "Couldn't change ownership of distribution files path to macports user: %s"] $result]"
+            } else {
+                return -code error [format [msgcat::mc "Distribution files path %s not writable and could not be chowned: %s"] $distpath $result]
+            }
+        }
     }
+
+    portfetch::check_dns
 }
 
 # Main fetch routine

Modified: branches/new-help-system/base/src/port1.0/portinstall.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portinstall.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portinstall.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 2002 - 2004 Apple Inc.
 # Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
-# Copyright (c) 2005, 2007 - 2011 The MacPorts Project
+# Copyright (c) 2005, 2007 - 2012 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -298,12 +298,12 @@
                  set depname [lindex [split $depspec :] end]
                  set dep [mport_lookup $depname]
                  if {[llength $dep] < 2} {
-                     ui_error "Dependency $dep not found"
+                     ui_debug "Dependency $depname not found"
                  } else {
                      array set portinfo [lindex $dep 1]
                      set depver $portinfo(version)
                      set deprev $portinfo(revision)
-                     puts $fd "@pkgdep ${depname}-${depver}_${deprev}"
+                     puts $fd "@pkgdep $portinfo(name)-${depver}_${deprev}"
                  }
              }
          }
@@ -423,19 +423,19 @@
     switch -- $type {
         tbz -
         tbz2 {
-            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOj${qflag}f $location +CONTENTS]
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOj${qflag}f $location ./+CONTENTS]
         }
         tgz {
-            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOz${qflag}f $location +CONTENTS]
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOz${qflag}f $location ./+CONTENTS]
         }
         tar {
-            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location +CONTENTS]
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location ./+CONTENTS]
         }
         txz {
-            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary xz ""] +CONTENTS]
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary xz ""] ./+CONTENTS]
         }
         tlz {
-            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary lzma ""] +CONTENTS]
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary lzma ""] ./+CONTENTS]
         }
         xar {
             system "cd ${workpath} && [findBinary xar ${portutil::autoconf::xar_path}] -xf $location +CONTENTS"
@@ -491,19 +491,22 @@
         set oldpwd $portpath
     }
 
-    # throws an error if an unsupported value has been configured
-    archiveTypeIsSupported $portarchivetype
-
     set location [get_portimage_path]
-    if {![file isfile $location]} {
+    set archive_path [find_portarchive_path]
+    if {$archive_path != ""} {
+        set install_dir [file dirname $location]
+        file mkdir $install_dir
+        file rename -force $archive_path $install_dir
+        set location [file join $install_dir [file tail $archive_path]]
+        set current_archive_type [string range [file extension $location] 1 end]
+        set installPlist [extract_contents $location $current_archive_type]
+    } else {
+        # throws an error if an unsupported value has been configured
+        archiveTypeIsSupported $portarchivetype
         # create archive from the destroot
         create_archive $location $portarchivetype
     }
 
-    if {![info exists installPlist]} {
-        set installPlist [extract_contents $location $portarchivetype]
-    }
-
     # can't do this inside the write transaction due to deadlock issues with _get_dep_port
     set dep_portnames [list]
     foreach deplist {depends_lib depends_run} {

Modified: branches/new-help-system/base/src/port1.0/portlint.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portlint.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portlint.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -191,7 +191,7 @@
 
         if {[string match "PortSystem*" $line]} {
             if {$seen_portsystem} {
-                ui_error "Line $lineno repeats PortSystem information"
+                ui_error "Line $lineno repeats PortSystem declaration"
                 incr errors
             }
             regexp {PortSystem\s+([0-9.]+)} $line -> portsystem
@@ -204,13 +204,13 @@
             set require_after "PortSystem"
         }
         if {[string match "PortGroup*" $line]} {
-            regexp {PortGroup\s+([a-z0-9]+)\s+([0-9.]+)} $line -> portgroup portgroupversion
+            regexp {PortGroup\s+([a-z0-9_]+)\s+([0-9.]+)} $line -> portgroup portgroupversion
             if {![info exists portgroup]} {
                 ui_error "Line $lineno has unrecognized PortGroup"
                 incr errors
             }
             if {[info exists portgroups($portgroup)]} {
-                ui_error "Line $lineno repeats PortGroup information"
+                ui_error "Line $lineno repeats inclusion of PortGroup $portgroup"
                 incr errors
             } else {
                 set portgroups($portgroup) $portgroupversion
@@ -291,16 +291,13 @@
 
     ###################################################################
 
-    global os.platform os.arch os.version
-    global version revision epoch
+    global os.platform os.arch os.version version revision epoch \
+           description long_description platforms categories all_variants \
+           maintainers license homepage master_sites checksums patchfiles \
+           depends_fetch depends_extract depends_lib depends_build \
+           depends_run distfiles fetch.type lint_portsystem lint_platforms \
+           lint_required lint_optional
     set portarch [get_canonical_archs]
-    global description long_description platforms categories all_variants
-    global maintainers license homepage master_sites checksums patchfiles
-    global depends_fetch depends_extract depends_lib depends_build depends_run distfiles fetch.type
-    global livecheck.type subport name
-    
-    global lint_portsystem lint_platforms
-    global lint_required lint_optional
 
     if (!$seen_portsystem) {
         ui_error "Didn't find PortSystem specification"
@@ -501,8 +498,8 @@
                 $addr == "openmaintainer at macports.org"} {
             ui_warn "Using full email address for no/open maintainer"
             incr warnings
-        } elseif [regexp "^(.+)@macports.org$" $addr -> name] {
-            ui_warn "Maintainer email address for $name includes @macports.org"
+        } elseif [regexp "^(.+)@macports.org$" $addr -> localpart] {
+            ui_warn "Maintainer email address for $localpart includes @macports.org"
             incr warnings
         } elseif {$addr == "darwinports at opendarwin.org"} {
             ui_warn "Using legacy email address for no/open maintainer"
@@ -546,30 +543,22 @@
                 }
             }
 
-            # BSD-2 => BSD
             if {[string equal -nocase "BSD-2" $test]} {
+                # BSD-2 => BSD
                 ui_error "Invalid license '${test}': use BSD instead"
-            }
-    
-            # BSD-3 => BSD
-            if {[string equal -nocase "BSD-3" $test]} {
+            } elseif {[string equal -nocase "BSD-3" $test]} {
+                # BSD-3 => BSD
                 ui_error "Invalid license '${test}': use BSD instead"
-            }
-    
-            # BSD-4 => BSD-old
-            if {[string equal -nocase "BSD-4" $test]} {
+            } elseif {[string equal -nocase "BSD-4" $test]} {
+                # BSD-4 => BSD-old
                 ui_error "Invalid license '${test}': use BSD-old instead"
             }
-    
+
             set prev $test
         }
 
     }
 
-    if {$subport != $name && ${livecheck.type} != "none"} {
-        ui_warn "livecheck set for subport $subport"
-    }
-
     # these checks are only valid for ports stored in the regular tree directories
     if {[info exists category] && $portcatdir != $category} {
         ui_error "Portfile parent directory $portcatdir does not match primary category $category"

Modified: branches/new-help-system/base/src/port1.0/portlivecheck.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portlivecheck.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portlivecheck.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -177,7 +177,7 @@
                                 set updated_version $upver
                             }
                             ui_debug "The regex matched \"$matched\", extracted \"$upver\""
-                            lassign $offsets firstoff lastoff
+                            set lastoff [lindex $offsets end]
                         }
                     }
                     if {$foundmatch == 1} {

Modified: branches/new-help-system/base/src/port1.0/portmain.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portmain.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portmain.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -2,7 +2,7 @@
 # portmain.tcl
 # $Id$
 #
-# Copyright (c) 2004 - 2005, 2007 - 2011 The MacPorts Project
+# Copyright (c) 2004 - 2005, 2007 - 2012 The MacPorts Project
 # Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #

Copied: branches/new-help-system/base/src/port1.0/portsandbox.tcl (from rev 100531, trunk/base/src/port1.0/portsandbox.tcl)
===================================================================
--- branches/new-help-system/base/src/port1.0/portsandbox.tcl	                        (rev 0)
+++ branches/new-help-system/base/src/port1.0/portsandbox.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -0,0 +1,92 @@
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
+# $Id$
+#
+# Copyright (c) 2012 The MacPorts Project
+#
+# 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 The MacPorts Project 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
+# "AS IS" 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 portsandbox 1.0
+
+namespace eval portsandbox {
+}
+
+options portsandbox_supported portsandbox_profile
+default portsandbox_supported {[file executable $portutil::autoconf::sandbox_exec_path]}
+default portsandbox_profile {}
+
+# set up a suitable profile to pass to sandbox-exec, based on the target
+# command line usage would be:
+# sandbox-exec -p '(version 1) (allow default) (deny file-write*) (allow file-write* <filter>)' some-command
+proc portsandbox::set_profile {target} {
+    global os.major portsandbox_profile workpath distpath altprefix \
+        package.destpath configure.ccache ccache_dir
+
+    switch $target {
+        activate -
+        deactivate -
+        dmg -
+        mdmg -
+        load -
+        unload {
+            set portsandbox_profile ""
+            return
+        }
+        install -
+        uninstall {
+            set allow_dirs [list [file dirname [get_portimage_path]]]
+        }
+        fetch -
+        mirror -
+        clean {
+            set allow_dirs [list $distpath]
+        }
+        pkg {
+            set allow_dirs [list ${package.destpath}]
+        }
+    }
+
+    # TODO: remove altprefix support
+    lappend allow_dirs $workpath $altprefix
+    if {${configure.ccache}} {
+        lappend allow_dirs $ccache_dir
+    }
+
+    set portsandbox_profile "(version 1) (allow default) (deny file-write*) \
+(allow file-write-data (literal \"/dev/null\") (literal \"/dev/zero\") \
+(literal \"/dev/dtracehelper\") (literal \"/dev/tty\") \
+(literal \"/dev/stdin\") (literal \"/dev/stdout\") (literal \"/dev/stderr\") \
+(regex #\"^/dev/fd/\")) (allow file-write* \
+(regex #\"^(/private)?(/var)?/tmp/\" #\"^(/private)?/var/folders/\"))"
+
+    foreach dir $allow_dirs {
+        append portsandbox_profile " (allow file-write* ("
+        if {${os.major} > 9} {
+            append portsandbox_profile "subpath \"${dir}\"))"
+        } else {
+            append portsandbox_profile "regex #\"^${dir}/\"))"
+        }
+    }
+}

Modified: branches/new-help-system/base/src/port1.0/portstartupitem.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portstartupitem.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portstartupitem.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -3,7 +3,7 @@
 #
 # $Id$
 #
-# Copyright (c) 2004-2011 The MacPorts Project
+# Copyright (c) 2004-2012 The MacPorts Project
 # Copyright (c) 2006-2007 James D. Berry
 # Copyright (c) 2004,2005 Markus W. Weissman <mww at macports.org>
 # All rights reserved.

Modified: branches/new-help-system/base/src/port1.0/portsubmit.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portsubmit.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portsubmit.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -137,7 +137,7 @@
     }
 
     if {[system $cmd] != ""} {
-    return -code error [format [msgcat::mc "Failed to archive port : %s"] $name]
+    return -code error [format [msgcat::mc "Failed to archive port %s"] $name]
     }
 
     set portsource ""
@@ -197,7 +197,7 @@
 
     ui_debug $cmd
     if {[system $cmd] != ""} {
-    return -code error [format [msgcat::mc "Failed to submit port : %s"] $name]
+    return -code error [format [msgcat::mc "Failed to submit port %s"] $name]
     }
 
     #

Modified: branches/new-help-system/base/src/port1.0/porttrace.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/porttrace.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/porttrace.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -141,7 +141,7 @@
     # Get the list of violations.
     set violations [slave_send porttrace::slave_get_sandbox_violations]
 
-    foreach violation [lsort $violations] {
+    foreach violation [lsort -unique $violations] {
         ui_warn "An activity was attempted outside sandbox: $violation"
     }
 }
@@ -175,18 +175,25 @@
 # Private
 # Create the slave thread.
 proc porttrace::create_slave {workpath trace_fifo} {
-    global trace_thread prefix developer_dir
+    global trace_thread prefix developer_dir registry.path
     # Create the thread.
     set trace_thread [macports_create_thread]
 
-    # The slave thread requires the registry package.
-    thread::send $trace_thread "package require registry 1.0"
-    # and this file as well.
+    # The slave thred needs this file and macports 1.0
     thread::send $trace_thread "package require porttrace 1.0"
-    # slave needs ui_warn and ui_debug...
-    thread::send $trace_thread "macports::ui_init warn; macports::ui_init debug"
+    thread::send $trace_thread "package require macports 1.0"
+    # slave needs ui_{info,warn,debug,error}...
+    # make sure to sync this with ../pextlib1.0/tracelib.c!
+    thread::send $trace_thread "macports::ui_init debug"
+    thread::send $trace_thread "macports::ui_init info"
+    thread::send $trace_thread "macports::ui_init warn"
+    thread::send $trace_thread "macports::ui_init error"
     # and these variables
     thread::send $trace_thread "set prefix \"$prefix\"; set developer_dir \"$developer_dir\""
+    # The slave thread requires the registry package.
+    thread::send $trace_thread "package require registry 1.0"
+    # and an open registry
+    thread::send $trace_thread "registry::open [file join ${registry.path} registry registry.db]"
 
     # Initialize the slave
     thread::send $trace_thread "porttrace::slave_init $trace_fifo $workpath"

Modified: branches/new-help-system/base/src/port1.0/portutil.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portutil.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/port1.0/portutil.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -208,7 +208,7 @@
             set PortInfo($option) $value
         }
         delete {
-            unset PortInfo($option)
+            unset -nocomplain PortInfo($option)
         }
     }
 }
@@ -407,10 +407,6 @@
         set ${varprefix}.env_array(LIBRARY_PATH) [join [option compiler.library_path] :]
     }
 
-    # When building, g-ir-scanner should not save its cache to $HOME
-    # See: https://trac.macports.org/ticket/26783
-    set ${varprefix}.env_array(GI_SCANNER_DISABLE_CACHE) "1"
-
     # Debug that.
     ui_debug "Environment: [environment_array_to_string ${varprefix}.env_array]"
 
@@ -448,7 +444,7 @@
     array set env [array get saved_env]
 
     # Return as if system had been called directly.
-    return -code $code -errorcode $errcode -errorInfo $errinfo $result
+    return -code $code -errorcode $errcode -errorinfo $errinfo $result
 }
 
 # default
@@ -792,8 +788,9 @@
 # This executes the given code in 'body' if we were opened as the specified
 # subport, and also adds it to the list of subports that are defined.
 proc subport {subname body} {
-    global subport PortInfo
-    if {![info exists PortInfo(subports)] || [lsearch -exact $PortInfo(subports) $subname] == -1} {
+    global subport name PortInfo
+    if {$subport == $name && $subname != $name && 
+        (![info exists PortInfo(subports)] || [lsearch -exact $PortInfo(subports) $subname] == -1)} {
         lappend PortInfo(subports) $subname
     }
     if {[string equal -nocase $subname $subport]} {
@@ -918,13 +915,13 @@
 # reinplace
 # Provides "sed in place" functionality
 proc reinplace {args}  {
-
-    global env
+    global env worksrcpath
     set extended 0
     set suppress 0
     set oldlocale_exists 0
     set oldlocale "" 
     set locale ""
+    set dir ${worksrcpath}
     while 1 {
         set arg [lindex $args 0]
         if {[string index $arg 0] eq "-"} {
@@ -944,6 +941,10 @@
                 n {
                     set suppress 1
                 }
+                W {
+                    set dir [lindex $args 0]
+                    set args [lrange $args 1 end]
+                }
                 - {
                     break
                 }
@@ -956,12 +957,16 @@
         }
     }
     if {[llength $args] < 2} {
-        error "reinplace ?-E? pattern file ..."
+        error "reinplace ?-E? ?-n? ?-W dir? pattern file ..."
     }
     set pattern [lindex $args 0]
     set files [lrange $args 1 end]
 
     foreach file $files {
+        # if $file is an absolute path already, file join will just return the
+        # absolute path, otherwise it is $dir/$file
+        set file [file join $dir $file]
+
         if {[catch {set tmpfile [mkstemp "/tmp/[file tail $file].sed.XXXXXXXX"]} error]} {
             global errorInfo
             ui_debug "$errorInfo"
@@ -989,6 +994,7 @@
         if {$locale != ""} {
             set env(LC_CTYPE) $locale
         }
+        ui_debug "Executing reinplace: $cmdline"
         if {[catch {eval exec $cmdline} error]} {
             global errorInfo
             ui_debug "$errorInfo"
@@ -1320,6 +1326,7 @@
     if {$procedure != ""} {
         set targetname [ditem_key $ditem name]
         set target [ditem_key $ditem provides]
+        portsandbox::set_profile $target
         global ${target}.asroot
         if { [tbool ${target}.asroot] } {
             elevateToRoot $targetname
@@ -1631,7 +1638,7 @@
 # open_statefile
 # open file to store name of completed targets
 proc open_statefile {args} {
-    global workpath worksymlink place_worksymlink subport portpath ports_ignore_older ports_dryrun \
+    global workpath worksymlink place_worksymlink subport portpath ports_ignore_different ports_dryrun \
            usealtworkpath altprefix env applications_dir subbuildpath
 
     if {$usealtworkpath} {
@@ -1674,22 +1681,75 @@
 
     # flock Portfile
     set statefile [file join $workpath .macports.${subport}.state]
+    set fresh_build yes
+    set checksum_portfile [sha256 file ${portpath}/Portfile]
     if {[file exists $statefile]} {
+        set fresh_build no
         if {![file writable $statefile] && ![tbool ports_dryrun]} {
             return -code error "$statefile is not writable - check permission on port directory"
         }
         if {[file mtime ${portpath}/Portfile] > [clock seconds]} {
             return -code error "Portfile is from the future - check date and time of your system"
         }
-        if {!([info exists ports_ignore_older] && $ports_ignore_older == "yes") && [file mtime $statefile] < [file mtime ${portpath}/Portfile]} {
-            if {![tbool ports_dryrun]} {
-                ui_notice "Portfile changed since last build; discarding previous state."
-                chownAsRoot $subbuildpath
-                delete $workpath
-                file mkdir $workpath
-            } else {
-                ui_notice "Portfile changed since last build but not discarding previous state (dry run)"
+        if {![tbool ports_ignore_different]} {
+            # start by assuming the statefile is current
+            set portfile_changed no
+
+            # open the statefile, determine the statefile version
+            set readfd [open $statefile r]
+            set statefile_version 1
+            if {[get_statefile_value "version" $readfd result] != 0} {
+                set statefile_version $result
             }
+
+            # check for outdated statefiles depending on what version the
+            # statefile is; we explicitly support older statefiles here, because
+            # all previously built archives would be invalidated (e.g., when
+            # using mpkg) if we didn't
+            switch $statefile_version {
+                1 {
+                    # statefile version 1
+                    # this statefile doesn't have a checksum, fall back to
+                    # comparing the Portfile modification date with the
+                    # statefile modification date
+                    if {[file mtime $statefile] < [file mtime ${portpath}/Portfile]} {
+                        ui_debug "Statefile has version 1 and is older than Portfile"
+                        set portfile_changed yes
+                    }
+                }
+                2 {
+                    # statefile version 2
+                    # this statefile has a sha256 checksum of the Portfile in
+                    # the "checksum" key
+                    set checksum_statefile ""
+                    if {[get_statefile_value "checksum" $readfd checksum_statefile] == 0} {
+                        ui_warn "Statefile has version 2 but didn't contain a checksum"
+                        set portfile_changed yes
+                    } else {
+                        if {$checksum_portfile != $checksum_statefile} {
+                            ui_debug "Checksum recorded in statefile '$checksum_statefile' \
+                                differs from Portfile checksum '$checksum_portfile'"
+                            set portfile_changed yes
+                        }
+                    }
+                }
+                default {
+                    ui_warn "Unsupported statefile version '$statefile_version'"
+                    ui_warn "Please run 'port selfupdate' to update to the latest version of MacPorts"
+                }
+            }
+            if {[tbool portfile_changed]} {
+                if {![tbool ports_dryrun]} {
+                    ui_notice "Portfile changed since last build; discarding previous state."
+                    chownAsRoot $subbuildpath
+                    delete $workpath
+                    file mkdir $workpath
+                    set fresh_build yes
+                } else {
+                    ui_notice "Portfile changed since last build but not discarding previous state (dry run)"
+                }
+            }
+            close $readfd
         }
     } elseif {[tbool ports_dryrun]} {
         set statefile /dev/null
@@ -1709,9 +1769,28 @@
             }
         }
     }
+    if {[tbool fresh_build]} {
+        write_statefile "version" 2 $fd
+        write_statefile "checksum" $checksum_portfile $fd
+    }
     return $fd
 }
 
+# get_statefile_value
+# Check for a given $class in the statefile $fd and write the first match to
+# $result, if any. Returns 1 if a line matched, 0 otherwise
+proc get_statefile_value {class fd result} {
+    upvar $result upresult
+    seek $fd 0
+    while {[gets $fd line] >= 0} {
+        if {[regexp "$class: (.*)" $line match value]} {
+            set upresult $value
+            return 1
+        }
+    }
+    return 0
+}
+
 # check_statefile
 # Check completed/selected state of target/variant $name
 proc check_statefile {class name fd} {
@@ -1748,19 +1827,24 @@
 
     array set upoldvariations {}
 
-    seek $fd 0 end
-    if {[tell $fd] == 0} {
-        # Statefile is empty, skipping further tests
-        return 0
-    }
-
+    set variants_found no
+    set targets_found no
     seek $fd 0
     while {[gets $fd line] >= 0} {
         if {[regexp "variant: (.*)" $line match name]} {
             set upoldvariations([string range $name 1 end]) [string range $name 0 0]
+            set variants_found yes
         }
+        if {[regexp "target: .*" $line]} {
+            set targets_found yes
+        }
     }
 
+    if {![tbool variants_found] && ![tbool targets_found]} {
+        # Statefile is "empty", skipping further tests
+        return 0
+    }
+
     set mismatch 0
     if {[array size upoldvariations] != [array size upvariations]} {
         set mismatch 1
@@ -1869,13 +1953,13 @@
     foreach key [array names upvariations *] {
         if {![info exists PortInfo(variants)] ||
             [lsearch $PortInfo(variants) $key] == -1} {
-            ui_debug "Requested variant $key is not provided by port $portname."
+            ui_debug "Requested variant $upvariations($key)$key is not provided by port $portname."
             array unset upvariations $key
         }
     }
 
     # now that we've selected variants, change all provides [a b c] to [a-b-c]
-    # this will eliminate ambiguity between item a, b, and a-b while fulfilling requirments.
+    # this will eliminate ambiguity between item a, b, and a-b while fulfilling requirements.
     #foreach obj $dlist {
     #    $obj set provides [list [join [$obj get provides] -]]
     #}
@@ -2311,10 +2395,26 @@
     }
 }
 
-# return path where the image/archive for this port will be stored
+# return filename of the archive for this port
+proc get_portimage_name {} {
+    global portdbpath subport version revision portvariants os.platform os.major portarchivetype
+    set ret "${subport}-${version}_${revision}${portvariants}.${os.platform}_${os.major}.[join [get_canonical_archs] -].${portarchivetype}"
+    # should really look up NAME_MAX here, but it's 255 for all OS X so far
+    # (leave 10 chars for an extension like .rmd160 on the sig file)
+    if {[string length $ret] > 245 && ${portvariants} != ""} {
+        # try hashing the variants
+        set ret "${subport}-${version}_${revision}+[rmd160 string ${portvariants}].${os.platform}_${os.major}.[join [get_canonical_archs] -].${portarchivetype}"
+    }
+    if {[string length $ret] > 245} {
+        error "filename too long: $ret"
+    }
+    return $ret
+}
+
+# return path where a newly created image/archive for this port will be stored
 proc get_portimage_path {} {
-    global registry.path subport version revision portvariants os.platform os.major portarchivetype
-    return [file join ${registry.path} software ${subport} "${subport}-${version}_${revision}${portvariants}.${os.platform}_${os.major}.[join [get_canonical_archs] -].${portarchivetype}"]
+    global portdbpath subport
+    return [file join ${portdbpath} software ${subport} [get_portimage_name]]
 }
 
 # return list of archive types that we can extract
@@ -2331,6 +2431,28 @@
     return $supported_archive_types
 }
 
+# return path to a downloaded or installed archive for this port
+proc find_portarchive_path {} {
+    global portdbpath subport version revision portvariants
+    set installed 0
+    if {[registry_exists $subport $version $revision $portvariants]} {
+        set installed 1
+    }
+    set archiverootname [file rootname [get_portimage_name]]
+    foreach unarchive.type [supportedArchiveTypes] {
+        set fullarchivename "${archiverootname}.${unarchive.type}"
+        if {$installed} {
+            set fullarchivepath [file join $portdbpath software $subport $fullarchivename]
+        } else {
+            set fullarchivepath [file join $portdbpath incoming/verified $fullarchivename]
+        }
+        if {[file isfile $fullarchivepath]} {
+            return $fullarchivepath
+        }
+    }
+    return ""
+}
+
 # check if archive type is supported by current system
 # returns an error code if it is not
 proc archiveTypeIsSupported {type} {
@@ -2848,28 +2970,64 @@
 
 # check if we can unarchive this port
 proc _archive_available {} {
-    global subport version revision portvariants ports_source_only workpath \
-           registry.path os.platform os.major porturl
+    global ports_source_only porturl portutil::archive_available_result
 
+    if {[info exists archive_available_result]} {
+        return $archive_available_result
+    }
+
     if {[tbool ports_source_only]} {
+        set archive_available_result 0
         return 0
     }
 
-    set found 0
-    foreach unarchive.type [supportedArchiveTypes] {
-        set fullarchivepath [file join ${registry.path} software ${subport} "${subport}-${version}_${revision}${portvariants}.${os.platform}_${os.major}.[join [get_canonical_archs] -].${unarchive.type}"]
-        if {[file isfile $fullarchivepath]} {
-            set found 1
-            break
-        }
+    if {[find_portarchive_path] != ""} {
+        set archive_available_result 1
+        return 1
     }
 
-    if {!$found && [file rootname [file tail $porturl]] == [file rootname [file tail [get_portimage_path]]] && [file extension $porturl] != ""} {
-        set found 1
+    set archiverootname [file rootname [get_portimage_name]]
+    if {[file rootname [file tail $porturl]] == $archiverootname && [file extension $porturl] != ""} {
+        set archive_available_result 1
+        return 1
     }
 
-    # TODO: maybe check if there's an archive available on the server - this
-    # is much less useful otherwise now that archive == installed image
+    # check if there's an archive available on the server
+    global archive_sites
+    set mirrors macports_archives
+    if {[lsearch $archive_sites macports_archives::*] == -1} {
+        set mirrors [lindex [split [lindex $archive_sites 0] :] 0]
+    }
+    if {$mirrors == {}} {
+        set archive_available_result 0
+        return 0
+    }
+    set archivetype $portfetch::mirror_sites::archive_type($mirrors)
+    set archivename "${archiverootname}.${archivetype}"
+    # grab first site, should conventionally be the master mirror
+    set sites_entry [lindex $portfetch::mirror_sites::sites($mirrors) 0]
+    # look for and strip off any tag, which will start with the first colon after the
+    # first slash after the ://
+    set lastcolon [string last : $sites_entry]
+    set aftersep [expr [string first : $sites_entry] + 3]
+    set firstslash [string first / $sites_entry $aftersep]
+    if {$firstslash != -1 && $firstslash < $lastcolon} {
+        incr lastcolon -1
+        set site [string range $sites_entry 0 $lastcolon]
+    } else {
+        set site $sites_entry
+    }
+    if {[string index $site end] != "/"} {
+        append site "/[option archive.subdir]"
+    } else {
+        append site [option archive.subdir]
+    }
+    set url [portfetch::assemble_url $site $archivename]
+    if {![catch {curl getsize $url} result]} {
+        set archive_available_result 1
+        return 1
+    }
 
-    return $found
+    set archive_available_result 0
+    return 0
 }

Copied: branches/new-help-system/base/src/port1.0/tests/common.tcl (from rev 100531, trunk/base/src/port1.0/tests/common.tcl)
===================================================================
--- branches/new-help-system/base/src/port1.0/tests/common.tcl	                        (rev 0)
+++ branches/new-help-system/base/src/port1.0/tests/common.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -0,0 +1,18 @@
+proc test_equal {statement value} {
+    uplevel 1 "\
+        puts -nonewline {checking if $statement == \"$value\"... }
+        if {\[catch {
+                set actual $statement
+                if {\$actual == \[subst {$value}\]} { \n\
+                    puts yes
+                } else { \n\
+                    puts \"no (was \$actual)\" \n\
+                    exit 1 \n\
+                } \n\
+            } msg\]} { \n\
+                puts \"caught error: \$msg\" \n\
+                exit 1 \n\
+            }"
+}
+
+

Copied: branches/new-help-system/base/src/port1.0/tests/portdestroot.tcl (from rev 100531, trunk/base/src/port1.0/tests/portdestroot.tcl)
===================================================================
--- branches/new-help-system/base/src/port1.0/tests/portdestroot.tcl	                        (rev 0)
+++ branches/new-help-system/base/src/port1.0/tests/portdestroot.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -0,0 +1,40 @@
+source [file join [lindex $argv 0] macports1.0 macports_fastload.tcl]
+package require macports
+mportinit
+
+source [file dirname [info script]]/../portdestroot.tcl
+source [file dirname [info script]]/common.tcl
+
+namespace eval tests {
+
+proc "when destroot cmd is not gmake no -w argument is added" {} {
+    global build.type build.cmd destroot.cmd destroot.target
+
+    set build.type "gnu"
+    set build.cmd "gmake"
+    set destroot.cmd "_destroot_cmd_"
+    set destroot.target "_target_"
+
+    test_equal {[portdestroot::destroot_getargs]} "_target_"
+}
+
+proc "when destroot cmd is gmake a -w argument is added" {} {
+    global build.type build.cmd destroot.cmd destroot.target
+
+    set build.type "gnu"
+    set build.cmd "_build_cmd_"
+    set destroot.cmd "gmake"
+    set destroot.target "_target_"
+
+    test_equal {[portdestroot::destroot_getargs]} "-w _target_"
+}
+
+
+# run all tests
+foreach proc [info procs *] {
+    puts "* ${proc}"
+    $proc
+}
+
+# namespace eval tests
+}

Copied: branches/new-help-system/base/src/port1.0/tests/portfetch.tcl (from rev 100531, trunk/base/src/port1.0/tests/portfetch.tcl)
===================================================================
--- branches/new-help-system/base/src/port1.0/tests/portfetch.tcl	                        (rev 0)
+++ branches/new-help-system/base/src/port1.0/tests/portfetch.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -0,0 +1,58 @@
+source [file join [lindex $argv 0] macports1.0 macports_fastload.tcl]
+package require macports
+mportinit
+
+set scriptdir [file dirname [info script]]
+source ${scriptdir}/../portfetch.tcl
+source ${scriptdir}/common.tcl
+
+namespace eval tests {
+
+proc "mirror tags are parsed correctly" {} {
+    global distfiles master_sites name dist_subdir filespath scriptdir
+
+    set name test
+    set filespath $scriptdir
+    set dist_subdir tset
+    set portfetch::mirror_sites::sites(macports_test) {
+        http://distfiles.macports.org/:mirror
+        http://distfiles2.macports.org:80/:mirror
+        http://distfiles3.macports.org:80/
+        http://distfiles4.macports.org:80/some/subdir/
+        http://distfiles5.macports.org:80/some/subdir/:mirror
+    }
+    set distfiles test.tar.bz2
+    set master_sites macports_test
+    set fetch_urls {}
+    portfetch::checksites [list master_sites {}] ""
+    portfetch::checkdistfiles fetch_urls
+
+    global portfetch::urlmap
+    foreach {url_var distfile} $fetch_urls {
+        if {![info exists urlmap($url_var)]} {
+            set urlmap($url_var) $urlmap(master_sites)
+        }
+        foreach site $urlmap($url_var) {
+            set file_url [portfetch::assemble_url $site $distfile]
+            lappend all_file_urls $file_url
+        }
+    }
+    set all_file_urls [lsort $all_file_urls]
+
+    set expected [list http://distfiles.macports.org/tset/test.tar.bz2 \
+                       http://distfiles2.macports.org:80/tset/test.tar.bz2 \
+                       http://distfiles3.macports.org:80/test/test.tar.bz2 \
+                       http://distfiles4.macports.org:80/some/subdir/test/test.tar.bz2 \
+                       http://distfiles5.macports.org:80/some/subdir/tset/test.tar.bz2]
+
+    test_equal {$all_file_urls} {$expected}
+}
+
+# run all tests
+foreach proc [info procs *] {
+    puts "* ${proc}"
+    $proc
+}
+
+# namespace eval tests
+}

Modified: branches/new-help-system/base/src/registry2.0/portuninstall.tcl
===================================================================
--- branches/new-help-system/base/src/registry2.0/portuninstall.tcl	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/src/registry2.0/portuninstall.tcl	2012-12-15 00:33:09 UTC (rev 100533)
@@ -217,7 +217,9 @@
         # files so just ignore the failure
         catch {file delete [::file dirname $imagefile]}
 
-        registry::entry delete $port
+        registry::write {
+            registry::entry delete $port
+        }
     }
     
     # uninstall dependencies if requested

Modified: branches/new-help-system/base/tests/Makefile
===================================================================
--- branches/new-help-system/base/tests/Makefile	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/tests/Makefile	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,6 +1,6 @@
 include ../Mk/macports.autoconf.mk
 
-TESTS?=checksums-1 svn-and-patchsites envvariables site-tags trace universal universal-2 xcodeversion dependencies-c dependencies-d dependencies-e case-insensitive-deactivate variants
+TESTS?=checksums-1 svn-and-patchsites envvariables site-tags trace universal universal-2 xcodeversion dependencies-c dependencies-d dependencies-e case-insensitive-deactivate variants statefile-version1 statefile-version1-outdated statefile-version2 statefile-version2-outdated statefile-version2-invalid statefile-unknown-version
 
 PWD=$(shell pwd)
 
@@ -64,6 +64,10 @@
 				rm -f difference output.sed; \
 			fi) && \
 			success=$$(( success + 1 )); \
+			if [ -n "`PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -q echo installed`" ]; then \
+			    PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -f clean --all installed > /dev/null && \
+			    PORTSRC=$(PWD)/test-macports.conf $(bindir)/port -f uninstall installed > /dev/null; \
+			fi; \
 		fi; \
 		num=$$(( num + 1 )); \
 	done; \

Modified: branches/new-help-system/base/tests/test/checksums-1/master
===================================================================
--- branches/new-help-system/base/tests/test/checksums-1/master	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/tests/test/checksums-1/master	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,4 +1,4 @@
---->  Fetching checksum
+--->  Fetching distfiles for checksum
 --->  Verifying checksum(s) for checksum
 --->  Extracting checksum
 --->  Configuring checksum

Modified: branches/new-help-system/base/tests/test/dependencies-c/master
===================================================================
--- branches/new-help-system/base/tests/test/dependencies-c/master	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/tests/test/dependencies-c/master	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,7 +1,6 @@
 --->  Computing dependencies for dependencies-c
 --->  Dependencies to be installed: dependencies-a dependencies-b
---->  Fetching archive for dependencies-b
---->  Fetching dependencies-b
+--->  Fetching distfiles for dependencies-b
 --->  Verifying checksum(s) for dependencies-b
 --->  Extracting dependencies-b
 --->  Configuring dependencies-b
@@ -10,8 +9,7 @@
 --->  Installing dependencies-b @1_0
 --->  Activating dependencies-b @1_0
 --->  Cleaning dependencies-b
---->  Fetching archive for dependencies-a
---->  Fetching dependencies-a
+--->  Fetching distfiles for dependencies-a
 --->  Verifying checksum(s) for dependencies-a
 --->  Extracting dependencies-a
 --->  Configuring dependencies-a
@@ -20,7 +18,7 @@
 --->  Installing dependencies-a @1_0+i_want_b
 --->  Activating dependencies-a @1_0+i_want_b
 --->  Cleaning dependencies-a
---->  Fetching dependencies-c
+--->  Fetching distfiles for dependencies-c
 --->  Verifying checksum(s) for dependencies-c
 --->  Extracting dependencies-c
 --->  Configuring dependencies-c

Modified: branches/new-help-system/base/tests/test/dependencies-d/master
===================================================================
--- branches/new-help-system/base/tests/test/dependencies-d/master	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/tests/test/dependencies-d/master	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,7 +1,8 @@
 Warning: depends option is not handled yet
 Warning: depends option is not handled yet
 --->  Computing dependencies for dependencies-d
---->  Fetching dependencies-b
+--->  Dependencies to be installed: dependencies-a dependencies-b
+--->  Fetching distfiles for dependencies-b
 --->  Verifying checksum(s) for dependencies-b
 --->  Extracting dependencies-b
 --->  Configuring dependencies-b
@@ -10,7 +11,7 @@
 --->  Installing dependencies-b @1_0
 --->  Activating dependencies-b @1_0
 --->  Cleaning dependencies-b
---->  Fetching dependencies-a
+--->  Fetching distfiles for dependencies-a
 --->  Verifying checksum(s) for dependencies-a
 --->  Extracting dependencies-a
 --->  Configuring dependencies-a
@@ -19,7 +20,7 @@
 --->  Installing dependencies-a @1_0+i_want_b
 --->  Activating dependencies-a @1_0+i_want_b
 --->  Cleaning dependencies-a
---->  Fetching dependencies-d
+--->  Fetching distfiles for dependencies-d
 --->  Verifying checksum(s) for dependencies-d
 --->  Extracting dependencies-d
 --->  Configuring dependencies-d

Modified: branches/new-help-system/base/tests/test/dependencies-e/master
===================================================================
--- branches/new-help-system/base/tests/test/dependencies-e/master	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/tests/test/dependencies-e/master	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,4 +1,5 @@
 --->  Computing dependencies for dependencies-e
 Error: Dependency 'docbook-xml-4.1.2' not found.
-Error: Status 1 encountered during processing.
-To report a bug, see <http://guide.macports.org/#project.tickets>
+To report a bug, follow the instructions in the guide:
+    http://guide.macports.org/#project.tickets
+Error: Processing of port dependencies-e failed

Modified: branches/new-help-system/base/tests/test/envvariables/master
===================================================================
--- branches/new-help-system/base/tests/test/envvariables/master	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/tests/test/envvariables/master	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,4 +1,4 @@
---->  Fetching envvariables
+--->  Fetching distfiles for envvariables
 --->  Verifying checksum(s) for envvariables
 --->  Extracting envvariables
 --->  Configuring envvariables

Modified: branches/new-help-system/base/tests/test/site-tags/master
===================================================================
--- branches/new-help-system/base/tests/test/site-tags/master	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/tests/test/site-tags/master	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,4 +1,4 @@
---->  Fetching site-tags
+--->  Fetching distfiles for site-tags
 --->  Attempting to fetch app-bm.tar.gz from http://www.douglas.stebila.ca/files/code/vim/app/
 --->  Attempting to fetch doc.tar.gz from http://www.douglas.stebila.ca/files/code/vim/doc/
 --->  Verifying checksum(s) for site-tags

Modified: branches/new-help-system/base/tests/test/svn-and-patchsites/master
===================================================================
--- branches/new-help-system/base/tests/test/svn-and-patchsites/master	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/tests/test/svn-and-patchsites/master	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,4 +1,4 @@
---->  Fetching svn-and-patchsites
+--->  Fetching distfiles for svn-and-patchsites
 --->  Attempting to fetch patch-1.5.14.dgc.xlabel_ext.9 from http://home.uchicago.edu/~dgc/sw/mutt/
 --->  Verifying checksum(s) for svn-and-patchsites
 --->  Extracting svn-and-patchsites

Modified: branches/new-help-system/base/tests/test/trace/master
===================================================================
--- branches/new-help-system/base/tests/test/trace/master	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/tests/test/trace/master	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,4 +1,4 @@
---->  Fetching trace
+--->  Fetching distfiles for trace
 --->  Verifying checksum(s) for trace
 --->  Extracting trace
 --->  Configuring trace

Modified: branches/new-help-system/base/tests/test/variants/master
===================================================================
--- branches/new-help-system/base/tests/test/variants/master	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/tests/test/variants/master	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,6 +1,6 @@
 Utopia variant -- 2
 Utopia variant -- 2
---->  Fetching variants
+--->  Fetching distfiles for variants
 --->  Verifying checksum(s) for variants
 --->  Extracting variants
 --->  Configuring variants

Modified: branches/new-help-system/base/tests/test/xcodeversion/master
===================================================================
--- branches/new-help-system/base/tests/test/xcodeversion/master	2012-12-15 00:25:16 UTC (rev 100532)
+++ branches/new-help-system/base/tests/test/xcodeversion/master	2012-12-15 00:33:09 UTC (rev 100533)
@@ -1,4 +1,4 @@
---->  Fetching xcodeversion
+--->  Fetching distfiles for xcodeversion
 --->  Verifying checksum(s) for xcodeversion
 --->  Extracting xcodeversion
 --->  Configuring xcodeversion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20121214/7bec9eca/attachment-0001.html>


More information about the macports-changes mailing list