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

raimue at macports.org raimue at macports.org
Sat Mar 3 06:11:24 PST 2012


Revision: 90356
          http://trac.macports.org/changeset/90356
Author:   raimue at macports.org
Date:     2012-03-03 06:11:19 -0800 (Sat, 03 Mar 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/Mk/macports.autoconf.mk.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/macports.conf.in
    branches/new-help-system/base/doc/portfile.7
    branches/new-help-system/base/doc/portgroup.7
    branches/new-help-system/base/doc/porthier.7
    branches/new-help-system/base/doc/prefix.mtree.in
    branches/new-help-system/base/doc/sources.conf
    branches/new-help-system/base/m4/tcl.m4
    branches/new-help-system/base/macports-pubkey.pem
    branches/new-help-system/base/portmgr/ReleaseProcess
    branches/new-help-system/base/portmgr/dmg/InstallationCheck
    branches/new-help-system/base/portmgr/dmg/License.html
    branches/new-help-system/base/portmgr/dmg/ReadMe.rtf
    branches/new-help-system/base/portmgr/dmg/postflight
    branches/new-help-system/base/portmgr/freebsd/Makefile.in
    branches/new-help-system/base/portmgr/jobs/GuideRegen.sh
    branches/new-help-system/base/portmgr/jobs/PortIndex2MySQL.tcl
    branches/new-help-system/base/portmgr/jobs/mirror_macports.sh
    branches/new-help-system/base/portmgr/jobs/mprsyncup
    branches/new-help-system/base/portmgr/jobs/org.macports.PortIndex2MySQL.plist
    branches/new-help-system/base/portmgr/jobs/org.macports.mprsyncup.plist
    branches/new-help-system/base/portmgr/jobs/portfile_lint.pl
    branches/new-help-system/base/portmgr/jobs/portfile_mirror.pl
    branches/new-help-system/base/portmgr/packaging/dpkgall.tcl
    branches/new-help-system/base/portmgr/packaging/mpkgall.tcl
    branches/new-help-system/base/portmgr/packaging/packageall.tcl
    branches/new-help-system/base/portmgr/packaging/rpmall.tcl
    branches/new-help-system/base/src/Makefile.in
    branches/new-help-system/base/src/config.h.in
    branches/new-help-system/base/src/cregistry/Makefile
    branches/new-help-system/base/src/cregistry/entry.c
    branches/new-help-system/base/src/cregistry/entry.h
    branches/new-help-system/base/src/cregistry/registry.c
    branches/new-help-system/base/src/cregistry/registry.h
    branches/new-help-system/base/src/cregistry/sql.c
    branches/new-help-system/base/src/cregistry/sql.h
    branches/new-help-system/base/src/cregistry/vercomp.c
    branches/new-help-system/base/src/darwintracelib1.0/Makefile
    branches/new-help-system/base/src/darwintracelib1.0/darwintrace.c
    branches/new-help-system/base/src/macports1.0/Makefile
    branches/new-help-system/base/src/macports1.0/macports.tcl
    branches/new-help-system/base/src/macports1.0/macports_autoconf.tcl.in
    branches/new-help-system/base/src/macports1.0/macports_dlist.tcl
    branches/new-help-system/base/src/macports1.0/macports_fastload.tcl.in
    branches/new-help-system/base/src/macports1.0/macports_index.tcl
    branches/new-help-system/base/src/macports1.0/macports_util.tcl
    branches/new-help-system/base/src/macports1.0/tests/macports_dlist.tcl
    branches/new-help-system/base/src/package1.0/Makefile
    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/Makefile
    branches/new-help-system/base/src/pextlib1.0/Pextlib.c
    branches/new-help-system/base/src/pextlib1.0/curl.c
    branches/new-help-system/base/src/pextlib1.0/fs-traverse.c
    branches/new-help-system/base/src/pextlib1.0/fs-traverse.h
    branches/new-help-system/base/src/pextlib1.0/md5cmd.c
    branches/new-help-system/base/src/pextlib1.0/md5cmd.h
    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/rmd160cmd.h
    branches/new-help-system/base/src/pextlib1.0/sha1cmd.c
    branches/new-help-system/base/src/pextlib1.0/sha1cmd.h
    branches/new-help-system/base/src/pextlib1.0/sha256cmd.c
    branches/new-help-system/base/src/pextlib1.0/sha256cmd.h
    branches/new-help-system/base/src/pextlib1.0/system.c
    branches/new-help-system/base/src/pextlib1.0/tests/curl.tcl
    branches/new-help-system/base/src/pextlib1.0/tty.c
    branches/new-help-system/base/src/pextlib1.0/tty.h
    branches/new-help-system/base/src/pextlib1.0/vercomp.c
    branches/new-help-system/base/src/pextlib1.0/vercomp.h
    branches/new-help-system/base/src/pextlib1.0/xinstall.c
    branches/new-help-system/base/src/pkg_mkindex.sh.in
    branches/new-help-system/base/src/port/Makefile
    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/port/portmirror.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/portactivate.tcl
    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/portclean.tcl
    branches/new-help-system/base/src/port1.0/portconfigure.tcl
    branches/new-help-system/base/src/port1.0/portdeactivate.tcl
    branches/new-help-system/base/src/port1.0/portdepends.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/portdistfiles.tcl
    branches/new-help-system/base/src/port1.0/portextract.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/portload.tcl
    branches/new-help-system/base/src/port1.0/portmain.tcl
    branches/new-help-system/base/src/port1.0/portmirror.tcl
    branches/new-help-system/base/src/port1.0/portpatch.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/porttest.tcl
    branches/new-help-system/base/src/port1.0/porttrace.tcl
    branches/new-help-system/base/src/port1.0/portuninstall.tcl
    branches/new-help-system/base/src/port1.0/portunload.tcl
    branches/new-help-system/base/src/port1.0/portutil.tcl
    branches/new-help-system/base/src/port1.0/tests/portutil.tcl
    branches/new-help-system/base/src/portindex/Makefile
    branches/new-help-system/base/src/portindex/portregister.pl
    branches/new-help-system/base/src/portindex/portsubmit.pl
    branches/new-help-system/base/src/programs/daemondo/Makefile.in
    branches/new-help-system/base/src/programs/daemondo/main.c
    branches/new-help-system/base/src/registry2.0/Makefile
    branches/new-help-system/base/src/registry2.0/entry.c
    branches/new-help-system/base/src/registry2.0/graph.c
    branches/new-help-system/base/src/registry2.0/item.c
    branches/new-help-system/base/src/registry2.0/itemobj.c
    branches/new-help-system/base/src/registry2.0/portimage.tcl
    branches/new-help-system/base/src/registry2.0/portuninstall.tcl
    branches/new-help-system/base/src/registry2.0/receipt_flat.tcl
    branches/new-help-system/base/src/registry2.0/receipt_sqlite.tcl
    branches/new-help-system/base/src/registry2.0/registry.c
    branches/new-help-system/base/src/registry2.0/registry.tcl
    branches/new-help-system/base/src/registry2.0/registry_autoconf.tcl.in
    branches/new-help-system/base/src/registry2.0/registry_util.tcl
    branches/new-help-system/base/src/registry2.0/util.c
    branches/new-help-system/base/src/registry2.0/util.h
    branches/new-help-system/base/src/upgrade_sources_conf_default.tcl
    branches/new-help-system/base/tests/Makefile
    branches/new-help-system/base/tests/test/case-insensitive-deactivate/Makefile
    branches/new-help-system/base/tests/test/case-insensitive-deactivate/Portfile.in
    branches/new-help-system/base/tests/test/case-insensitive-deactivate/README
    branches/new-help-system/base/tests/test/checksums-1/master
    branches/new-help-system/base/tests/test/dependencies-a/Portfile
    branches/new-help-system/base/tests/test/dependencies-b/Portfile
    branches/new-help-system/base/tests/test/dependencies-c/Portfile
    branches/new-help-system/base/tests/test/dependencies-c/master
    branches/new-help-system/base/tests/test/dependencies-d/Portfile
    branches/new-help-system/base/tests/test/dependencies-e/Portfile
    branches/new-help-system/base/tests/test/dependencies-e/master
    branches/new-help-system/base/tests/test/envvariables/Makefile
    branches/new-help-system/base/tests/test/envvariables/Portfile
    branches/new-help-system/base/tests/test/envvariables/master
    branches/new-help-system/base/tests/test/site-tags/Portfile
    branches/new-help-system/base/tests/test/site-tags/master
    branches/new-help-system/base/tests/test/trace/Makefile
    branches/new-help-system/base/tests/test/trace/Portfile
    branches/new-help-system/base/tests/test/trace/master
    branches/new-help-system/base/tests/test/universal/Makefile
    branches/new-help-system/base/tests/test/universal/Portfile
    branches/new-help-system/base/tests/test/universal-2/Makefile
    branches/new-help-system/base/tests/test/universal-2/Portfile
    branches/new-help-system/base/tests/test/variants/Portfile
    branches/new-help-system/base/tests/test/variants/master
    branches/new-help-system/base/tests/test/xcodeversion/Portfile
    branches/new-help-system/base/tests/test/xcodeversion/master
    branches/new-help-system/base/tests/test-macports.conf

Added Paths:
-----------
    branches/new-help-system/base/doc/base.mtree.in
    branches/new-help-system/base/portmgr/fedora/macports.spec
    branches/new-help-system/base/portmgr/jobs/port_binary_distributable.tcl
    branches/new-help-system/base/src/cregistry/file.c
    branches/new-help-system/base/src/cregistry/file.h
    branches/new-help-system/base/src/cregistry/util.c
    branches/new-help-system/base/src/cregistry/util.h
    branches/new-help-system/base/src/images_to_archives.tcl
    branches/new-help-system/base/src/machista1.0/
    branches/new-help-system/base/src/pextlib1.0/base32cmd.c
    branches/new-help-system/base/src/pextlib1.0/base32cmd.h
    branches/new-help-system/base/src/pextlib1.0/setmode.h
    branches/new-help-system/base/src/pextlib1.0/tests/base32.tcl
    branches/new-help-system/base/src/pextlib1.0/tests/vercomp.tcl
    branches/new-help-system/base/src/registry2.0/file.c
    branches/new-help-system/base/src/registry2.0/file.h
    branches/new-help-system/base/src/registry2.0/fileobj.c
    branches/new-help-system/base/src/registry2.0/fileobj.h
    branches/new-help-system/base/tests/test/svn-and-patchsites/

Removed Paths:
-------------
    branches/new-help-system/base/src/dep_map_clean.tcl
    branches/new-help-system/base/src/package1.0/portarchive.tcl
    branches/new-help-system/base/tests/test/cvs-and-patchsites/

Property Changed:
----------------
    branches/new-help-system/base/
    branches/new-help-system/base/doc/
    branches/new-help-system/base/src/machista1.0/tests/
    branches/new-help-system/base/src/pextlib1.0/sha2.c
    branches/new-help-system/base/src/pextlib1.0/sha2.h
    branches/new-help-system/base/src/pextlib1.0/sha256cmd.c
    branches/new-help-system/base/src/pextlib1.0/sha256cmd.h
    branches/new-help-system/base/src/registry2.0/receipt_sqlite.tcl


Property changes on: branches/new-help-system/base
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base:37343-46937
/branches/gsoc09-logging/base:51231-60371
/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-70794
/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-90355
/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-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/ChangeLog	2012-03-03 14:11:19 UTC (rev 90356)
@@ -5,11 +5,249 @@
 
 Unreleased changes:
 
+    - 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)
+
+    - 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)
+
+    - 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)
+    - Xcode 4.3 support: Change home directory for MacPorts user to
+      ${prefix}/var/macports/home.
+      (jberry, jmr in r89988, r89993, r90002, r90010, r90011)
+
+    - set env(HOME) to ${workpath}/.home when building ports
+      (#31827, jmr in r89994, r90004)
+
+    - Added configure.cxx setting when configure.compiler is apple-gcc-4.2
+      (jeremyhu in r80248)
+
+    - Xcode 4.3 support: added packagemaker_path macports.conf setting
+      (jmr in r90058)
+
+    - Resolve ambiguity in selection in portlists
+      (jberry in r88179, r88185)
+
+    - Xcode 4.3 support: updated default developer_dir location for 4.3
+      (jmr in r90016)
+
+    - Xcode 4.3 support: use compilers in /usr/bin instead of developer_dir
+      when possible, as the latter has proven to be volatile.
+      (jmr in r90015)
+
+    - Xcode 4.3 support: updated SDK paths for 4.3 (jmr in r90000)
+
+    - Work around broken FTP proxy support in some versions of libcurl
+      (jmr in r84351, r88045)
+
+Release 2.0.3 (2011-09-05 by raimue)
+    - Fix a regression introduced in 2.0.2 when fetching with a VCS
+      (#31073, jmr in r83471)
+
+Release 2.0.2 (2011-09-01 by jmr):
+    - Messages recommending running selfupdate will no longer be printed when
+      selfupdate is being run. (#23094, jmr in r83270, r83391)
+
+    - The PortIndex will not be regenerated during selfupdate when base is
+      outdated. This avoids failure to index ports that use features only
+      available in the current version. (#30739, jmr in r83271)
+
+    - Fixed build failures when the TMPDIR environment variable is set to a
+      directory that is not writable by the macports user.
+      (#30749, jmr in r83267)
+
+    - Fixed error when checksumming distfiles with names containing spaces.
+      (#28568, jmr in r83149)
+
+    - The uninstall and deactivate actions now sort the port list so that
+      dependents are processed before the ports they depend on.
+      (#8431, jmr in r82947)
+
+    - Fixed an issue where a non-universal version of a port could be
+      installed as a dependency as well as the universal version, with
+      unpredictable results, when some ports in the dependency graph needed
+      the universal version but others didn't. (jmr in r82924)
+
+    - Now using a temp dir inside ${prefix} when activating, as /tmp or
+      /var/folders may be on a different volume. (jmr in r82767)
+
+    - Fixed extracting portfile-only archives. (#31033, jmr in r81830)
+
+    - Fixed adduser and addgroup procedures not re-dropping privileges when
+      done. (jmr in r81630)
+
+    - Fixed error activating ports with names containing the string "cpio".
+      (#30532, jmr in r81577)
+
+Release 2.0.1 (2011-08-02 by jmr):
+    - Fixed errors when installing some archives built on a case-sensitive
+      filesystem onto a case-insensitive one. (#30373, jmr in r81562)
+
+    - Fixed users created by MacPorts showing up in the GUI in some places on
+      Lion. (#30168, jeremyhu in r81558)
+
+    - Added replaced_by pseudo-portname selector. (afb in r81475)
+
+    - Added progress output to port image conversion script.
+      (#30347, jmr in r81464)
+
+    - Now doing a better job of avoiding UID conflicts with non-local users
+      when creating the 'macports' user. (#30464, jmr in r81414, r81415) Also
+      improved Tiger compatibility in this area. (jmr in r81454, r81467)
+
+    - Fixed 'port selfupdate' exiting with non-zero status after installing a
+      new version of base. (jmr in r81371)
+
+    - Added --subports to options accepted by 'port info'. (jmr in r81234)
+
+    - Fixed incorrect info sometimes being added to PortIndex entries when
+      using subports. (#30463, jmr in r81361)
+
+    - Fixed descriptions not being shown for default variants. (jmr in r80971)
+
+    - Fixed 'port variants --index'. (jmr in r80969)
+
+Release 2.0.0 (2011-07-22 by jmr):
+
+    - Multiple ports can now be defined in one Portfile using the 'subport'
+      procedure. This reduces code duplication when several ports use very
+      similar code. (jmr in r78062)
+
+    - Privilege dropping is now on by default. The runtime user can be changed
+      when building from source but defaults to 'macports'; this user is
+      created at install time. (jmr in r79025)
+
+    - Fetching from some extremely slow or partially unresponsive servers
+      should now time out as expected. (raimue in r71038)
+
+    - The registry is now "vacuumed" (compacted/defragmented) after
+      uninstalling ports. (jmr in r70608)
+
+    - Downloaded archives are now checked for integrity using digital
+      signatures. Sync and selfupdate can also use a signed tarball. New
+      pubkeys.conf file allows configuring keys to trust.
+      (jmr in r68996, r79093)
+
+    - Added 'actinact' pseudo-portname that expands to installed ports with an
+      active version and at least one inactive version.
+      (#27666, jmr in r79421, based on patch from gmail.com:ww.galen)
+
+    - Added --size option for 'contents' action that makes it print the size
+      of each file. (#27245, jmr in r79365, based on patch from
+      gmail.com:ww.galen)
+
+    - Added 'space' action to show the disk space used by ports' active files.
+      (#27244, jmr in r79349, based on patch from gmail.com:ww.galen)
+
+    - Actions can be abbreviated to an unambiguous prefix of the full name.
+      (#27242, patch from gmail.com:ww.galen committed in r79259)
+
+    - Fixed error when activating ports whose version contains an underscore
+      followed by an integer and a dash. (#28084, jmr in r79167)
+
+    - Deactivating a port that has dependents no longer needs to be forced
+      when the dependents are all inactive. (#29505, jmr in r78086)
+
+    - New option 'add_users' has been added. Setting it will ensure that the
+      listed users are created before all operations that may require them to
+      exist. (#11563, jmr in r78660)
+
+    - 'port info --index' should be much faster and will work with the
+      'current' pseudo-port provided the port has been indexed.
+      (#13673, jmr in r78621)
+
+    - Relocation is explicitly disabled when building pkgs on 10.6, so Apple's
+      Installer won't attempt to overwrite other copies of the same software
+      not installed by MacPorts. (#25174, jmr in r78178)
+
+    - Non-Darwin platforms can once again build base against OpenSSL for
+      checksum support. (#26813, afb in r77865)
+
+    - It is now safe to set svn.post_args, rather than that option being
+      reserved for svn.url. (#27454, jmr in r73825)
+
+    - Variants specified when running 'port mpkg' are now set in the
+      dependencies as well. (#27231, jmr in r73303)
+
+    - Fixed various issues with privilege dropping.
+      (#26899, jmr in r69453 etc.)
+
+    - Trace mode no longer fails on 10.6. (#21582, jmr in r74318, r74369)
+
+    - Ports that create StartupItems (aka launchd plists) should now be
+      installable by unprivileged users. (#10879, jmr in r66700, r75143)
+
+    - Fixed incorrect output from 'port dependents' when using newer SQLite
+      versions. (#27506, patch from gmail.com:mmpestorich committed in r76827)
+
+    - The flat registry format is no longer available. Setting portdbformat to
+      'flat' in macports.conf will result in the sqlite registry being used.
+      (jmr in r77681)
+
+    - Port images are now stored as archives. Archive mode is now effectively
+      always on. Among other benefits, this fixes some bugs with the handling
+      of hard links installed by ports (e.g. #13601).
+
+      Direct mode is no longer available. Existing port image directories, and
+      installed files for direct mode, will be converted to archives when
+      upgrading.
+
+      (#19458, branch by blb, merged by jmr in r77511)
+
+    - master_site_local, patch_site_local, and archive_site_local can be set
+      in macports.conf, with the same effects as the corresponding environment
+      variables. (jmr in r74924)
+
+    - Added 'logfile' action that prints the path to a port's log file.
+      (jmr in r74655)
+
+    - 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)
+
+    - Add '-n' option to reinplace (#26406, ryandesign in r73227)
+
+    - Add new ccache_dir and ccache_size options, default path is
+      ${portdbpath}/build/.ccache and a size of 2 GB.
+      (raimue in r71604, r71606)
+
+    - Add 'system -W path' which changes to the given directory before
+      executing the command.
+      (raimue in r71380, r71389)
+
+    - Add -w to build.cmd and destroot.cmd if using gnumake
+      (raimue in r71370)
+
+    - Add livecheck.ignore_sslcert; setting fetch.ignore_sslcert does no
+      longer apply to livecheck. distcheck now respects fetch.ignore_sslcert.
+      (#17063, raimue in r70975, r70979, r70982)
+
     - Add SHA256 checksums in addition to MD5, SHA1 and RIPEMD160.
       (afb in r57888, r57913; snc in r68955)
 
-Release 1.9.2 (future):
+    - Add @pkgdep lines to archives, with build-time dependencies.
+      (afb in r76919)
 
+Release 1.9.2 (2010-11-07 by jmr):
+
     - Added more locking to avoid TOCTOU errors when running multiple port(1)
       instances (#19935, jmr in r70174)
 
@@ -35,7 +273,7 @@
       only in epoch (jmr in r69436)
 
     - Fixed [un]setrequested when using the flat registry format
-      (jmr in r69387)
+      (#26352, jmr in r69387)
 
     - Fixed checking for conflicting ports before installation
       (#25386, jmr in r69105)
@@ -48,7 +286,7 @@
 
     - Fixed premature privilege dropping (#25331, jmr in r68952)
 
-Release 1.9.1 (2010-06-18):
+Release 1.9.1 (2010-06-18 by jmr):
     - Fixed a couple of problems with new 1.9 features when using the flat
       registry format (jmr in r68910, r68913)
 

Modified: branches/new-help-system/base/LICENSE
===================================================================
--- branches/new-help-system/base/LICENSE	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/LICENSE	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,5 +1,5 @@
 Copyright (c) 2002 - 2003, Apple Inc.
-Copyright (c) 2004 - 2010, The MacPorts Project.
+Copyright (c) 2004 - 2011, 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-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/Makefile.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,14 +1,14 @@
 # $Id$
 
 PATH		= @PATH_CLEANED@
-SUBDIR		= doc src
+SUBDIR		= doc src tests
 DISTDIR		= dist
 DISTVER		=
 DISTTAG		= release_${subst .,_,${DISTVER}}
 DISTNAME	= MacPorts-${DISTVER}
 DISTARCTAG	= ${DISTTAG}-archive
 DISTARCNAME	= ${DISTNAME}-archive
-SVNURL		= http://svn.macports.org/repository/macports
+SVNURL		= https://svn.macports.org/repository/macports
 
 
 include Mk/macports.autoconf.mk
@@ -18,7 +18,7 @@
 
 Mk/macports.autoconf.mk: Mk/macports.autoconf.mk.in src/config.h.in Makefile.in config.status
 	./config.status
-	make clean
+	${MAKE} clean
 
 config.status: configure
 	@if test -f ./config.status ; then	\
@@ -37,14 +37,70 @@
 	$(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
+	@if test -n "${DSCL}" -a -n "${DSEDITGROUP}" ; then \
+        if ! ${DSCL} -q . -read /Groups/${RUNUSR} > /dev/null 2>&1 ; then \
+            if test `id -u` -eq 0; then \
+                echo "Creating group \"${RUNUSR}\"" ; \
+                ${DSEDITGROUP} -q -o create ${RUNUSR} ; \
+            else \
+                echo "Not creating group \"${RUNUSR}\" (not root)" ; \
+            fi ; \
+        fi ; \
+        if ! ${DSCL} -q . -list /Users/${RUNUSR} > /dev/null 2>&1 ; then \
+            if test `id -u` -eq 0; then \
+                echo "Creating user \"${RUNUSR}\"" ; \
+                NEXTUID=501; \
+                while test -n "`${DSCL} -q /Search -search /Users UniqueID $$NEXTUID`"; do \
+                    let "NEXTUID=NEXTUID+1"; \
+                done; \
+                ${DSCL} -q . -create /Users/${RUNUSR} UniqueID $$NEXTUID ; \
+                \
+                ${DSCL} -q . -delete /Users/${RUNUSR} AuthenticationAuthority ; \
+                ${DSCL} -q . -delete /Users/${RUNUSR} PasswordPolicyOptions ; \
+                ${DSCL} -q . -delete /Users/${RUNUSR} dsAttrTypeNative:KerberosKeys ; \
+                ${DSCL} -q . -delete /Users/${RUNUSR} dsAttrTypeNative:ShadowHashData ; \
+                \
+                ${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} UserShell /usr/bin/false ; \
+            else \
+                echo "Not creating user \"${RUNUSR}\" (not root)" ; \
+            fi ; \
+        fi ; \
+        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 ; \
+            else \
+                echo "Not updating home directory location for user \"${RUNUSR}\" (not root)" ; \
+            fi ; \
+        fi ; \
+        if test `sw_vers -productVersion | /usr/bin/awk -F . '{print $$2}'` -eq 4 -a `id -u` -eq 0; then \
+            GID=`${DSCL} -q . -read /Groups/${RUNUSR} PrimaryGroupID | /usr/bin/awk '{print $$2}'` ; \
+            if test "`${DSCL} -q . -read /Users/${RUNUSR} PrimaryGroupID 2>/dev/null | /usr/bin/awk '{print $$2}'`" != "$$GID"; then \
+                echo "Fixing PrimaryGroupID for user \"${RUNUSR}\"" ; \
+                ${DSCL} -q . -create /Users/${RUNUSR} PrimaryGroupID $$GID ; \
+                ${DSCL} -q . -create /Users/${RUNUSR} RealName MacPorts ; \
+            fi ; \
+        fi ; \
+    else \
+        echo "Can't find ${DSCL} / ${DSEDITGROUP}, not creating user \"${RUNUSR}\"" ; \
+    fi
 # Add [default] tag to the central MacPorts repository, if it isn't already
-	$(TCLSH) src/upgrade_sources_conf_default.tcl ${prefix}
-# Remove duplicate entries from the dependency map (could occur with 1.6 and earlier):
-	$(TCLSH) src/dep_map_clean.tcl "${macports_tcl_dir}"
+	$(TCLSH) src/upgrade_sources_conf_default.tcl "${prefix}"
+# Convert image directories (and direct mode installs) to image archives
+	$(TCLSH) src/images_to_archives.tcl "${macports_tcl_dir}"
 endif
+ifndef SELFUPDATING
 	@echo ""; echo "Congratulations, you have successfully installed the MacPorts system. To get the Portfiles and update the system, add ${prefix}/bin to your PATH and run:"; echo ""
 	@echo "sudo port -v selfupdate"; echo ""
-	@echo "Please read \"man port\", the MacPorts guide at http://guide.macports.org/ and Wiki at http://trac.macports.org/ for full documentation."; echo ""
+	@echo "Please read \"man port\", the MacPorts guide at http://guide.macports.org/ and Wiki at https://trac.macports.org/ for full documentation."; echo ""
+else
+	@echo ""; echo "Congratulations, you have successfully upgraded the MacPorts system."; echo ""
+endif
 
 group::
 	@echo "creating a macports group..." && sudo dseditgroup -o create -n . macports && echo "done! use './configure --with-install-group=macports --with-shared-directory' if you haven't already"
@@ -71,7 +127,7 @@
 	cd ${DISTDIR}; COPY_EXTENDED_ATTRIBUTES_DISABLE=true tar -c ${PKGNAME} | gzip > ${PKGNAME}.tar.gz
 	cd ${DISTDIR}; COPY_EXTENDED_ATTRIBUTES_DISABLE=true tar -c ${PKGNAME} | bzip2 > ${PKGNAME}.tar.bz2
 	cd ${DISTDIR}; for tarball in ${PKGNAME}.tar.*; do { \
-		for type in -md5 -sha1 -ripemd160; do { \
+		for type in -md5 -sha1 -ripemd160 -sha256; do { \
 			openssl dgst $$type $$tarball; \
 		}; done >> ${DISTNAME}.chk.txt; \
 	}; done

Modified: branches/new-help-system/base/Mk/macports.autoconf.mk.in
===================================================================
--- branches/new-help-system/base/Mk/macports.autoconf.mk.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/Mk/macports.autoconf.mk.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -7,12 +7,13 @@
 VPATH			= @srcdir@
 
 CC			= @CC@
-CFLAGS			= @CFLAGS@ $(CFLAGS_QUICHEEATERS) $(CFLAGS_WERROR)
-OBJCFLAGS		= @OBJCFLAGS@ $(CFLAGS_QUICHEEATERS) $(CFLAGS_WERROR)
+CFLAGS			= @CFLAGS@ $(CFLAGS_QUICHEEATERS) $(CFLAGS_PEDANTIC) $(CFLAGS_WERROR)
+OBJCFLAGS		= @OBJCFLAGS@ $(CFLAGS_QUICHEEATERS) $(CFLAGS_PEDANTIC) $(CFLAGS_WERROR)
 CPPFLAGS		= @CPPFLAGS@ @DEFS@ @INCLUDES@ @TCL_INCLUDES@
 TCL_DEFS		= @TCL_DEFS@
 SHLIB_CFLAGS		= @SHLIB_CFLAGS@
 CFLAGS_QUICHEEATERS	= @CFLAGS_QUICHEEATERS@
+CFLAGS_PEDANTIC		= @CFLAGS_PEDANTIC@
 CFLAGS_WERROR		= @CFLAGS_WERROR@
 
 READLINE_CFLAGS		=
@@ -52,11 +53,13 @@
 TCL_PACKAGE_DIR		= @TCL_PACKAGE_DIR@
 macports_tcl_dir	= @macports_tcl_dir@
 
+DSCL			= @DSCL@
+DSEDITGROUP		= @DSEDITGROUP@
 DSTUSR			= @DSTUSR@
 DSTGRP			= @DSTGRP@
 DSTMODE			= @DSTMODE@
+RUNUSR			= @RUNUSR@
 
-
 prefix			= @prefix@
 sysconfdir		= @sysconfdir@
 exec_prefix		= @exec_prefix@

Modified: branches/new-help-system/base/NEWS
===================================================================
--- branches/new-help-system/base/NEWS	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/NEWS	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,3 +1,29 @@
+== Overview of changes from MacPorts 1.9.2 to 2.0.0 ==
+
+# For regular users:
+
+*) Downloaded archives are now checked for integrity using digital signatures.
+   New pubkeys.conf file allows configuring keys to trust.
+
+*) Actions can be abbreviated to an unambiguous prefix of the full name.
+
+*) Ports that create StartupItems (aka launchd plists) should now be
+   installable by unprivileged users.
+
+*) Port images are now stored as archives. Archive mode is now effectively
+   always on. Direct mode and the flat registry format are no longer
+   available. Conversion will happen automatically.
+
+# For Portfile writers:
+
+*) Multiple ports can now be defined in one Portfile using the 'subport'
+   procedure.
+
+*) New option 'add_users' can be set to ensure that the listed users are
+   created at the right times during the install process.
+
+*) SHA256 checksums are now supported.
+
 == Overview of changes from MacPorts 1.8.2 to 1.9.0 ==
 
 # For regular users:

Modified: branches/new-help-system/base/aclocal.m4
===================================================================
--- branches/new-help-system/base/aclocal.m4	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/aclocal.m4	2012-03-03 14:11:19 UTC (rev 90356)
@@ -327,9 +327,15 @@
 		AC_MSG_RESULT([$DSTGRP])
 		AC_SUBST(DSTGRP)
 
+		# Set run-user to current user
+		AC_MSG_CHECKING([for macports user])
+		RUNUSR=`id -un`
+		AC_MSG_RESULT([$RUNUSR])
+		AC_SUBST(RUNUSR)
+
 		# Set Tcl package directory to ~/Library/Tcl
 	    AC_MSG_CHECKING(for Tcl package directory)
-		ac_cv_c_tclpkgd="~$DSTUSR/Library/Tcl"
+		ac_cv_c_tclpkgd=`eval echo ~$DSTUSR/Library/Tcl`
 	    # Convert to a native path and substitute into the output files.
 	    PACKAGE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclpkgd}`
 	    TCL_PACKAGE_DIR=${PACKAGE_DIR_NATIVE}
@@ -354,7 +360,7 @@
 	
 	AC_MSG_CHECKING([for macports user])
 	if test "x$RUNUSR" = "x" ; then
-	   RUNUSR=nobody
+	   RUNUSR=macports
 	fi
 
 	AC_MSG_RESULT([$RUNUSR])
@@ -524,25 +530,37 @@
 # Check for an md5 implementation
 AC_DEFUN([MP_LIB_MD5],[
 
-	# Check for libmd, which is prefered
-	AC_CHECK_LIB([md], [MD5Update],[
-		AC_CHECK_HEADERS([md5.h], ,[
-			case $host_os in
-				darwin*)	
-					AC_MSG_NOTICE([Please install the BSD SDK package from the Xcode Developer Tools CD.])
-					;;
-				*)	
-					AC_MSG_NOTICE([Please install the libmd developer headers for your platform.])
-					;;
-			esac
-			AC_MSG_ERROR([libmd was found, but md5.h is missing.])
+	# Check for libmd from FreeBSD, which is preferred
+	AC_CHECK_LIB([md], [MD5File],[
+		AC_CHECK_HEADERS([md5.h sha.h], ,[
+			AC_MSG_ERROR([libmd was found, but md5.h or sha.h is missing.])
 		])
+		ac_save_LIBS="$LIBS"
+		LIBS="-lmd $LIBS"
+		AC_CHECK_FUNCS([SHA1_File])
+		LIBS="$ac_save_LIBS"
+		AC_CHECK_HEADERS([ripemd.h sha256.h])
 		AC_DEFINE([HAVE_LIBMD], ,[Define if you have the `md' library (-lmd).])
 		MD5_LIBS="-lmd"]
 	)
 	if test "x$MD5_LIBS" = "x"; then
-		AC_MSG_ERROR([Neither CommonCrypto nor libmd were found. A working md5 implementation is required.])
+		# If libmd is not found, check for libcrypto from OpenSSL
+		AC_CHECK_LIB([crypto], [MD5_Update],[
+			AC_CHECK_HEADERS([openssl/md5.h openssl/sha.h], ,[
+				AC_MSG_ERROR([libcrypto was found, but openssl/md5.h or openssl/sha.h is missing.])
+			])
+			AC_CHECK_HEADERS([openssl/ripemd.h])
+			ac_save_LIBS="$LIBS"
+			LIBS="-lcrypto $LIBS"
+			AC_CHECK_FUNCS([SHA256_Update])
+			LIBS="$ac_save_LIBS"
+			AC_DEFINE([HAVE_LIBCRYPTO], ,[Define if you have the `crypto' library (-lcrypto).])
+			MD5_LIBS="-lcrypto"]
+		)
 	fi
+	if test "x$MD5_LIBS" = "x"; then
+		AC_MSG_ERROR([Neither CommonCrypto, libmd nor libcrypto were found. A working md5 implementation is required.])
+	fi
 	AC_SUBST([MD5_LIBS])
 ])
 
@@ -628,7 +646,7 @@
 			        fi
 			    fi
 			elif test "$path" = "~/Library/Tcl"; then
-			    ac_cv_c_tclpkgd="~$DSTUSR/Library/Tcl"
+			    ac_cv_c_tclpkgd=`eval echo ~$DSTUSR/Library/Tcl`
 			    break
 			fi
 			done
@@ -919,6 +937,21 @@
 	AC_SUBST(SED_EXT)
 ])
 
+dnl This macro tests for tar support of -q (BSD) or not (GNU)
+AC_DEFUN([MP_TAR_FAST_READ],[
+	AC_PATH_PROG(TAR, [tar])
+	
+	AC_MSG_CHECKING([whether tar supports -q])
+	if $TAR -t -q -f - </dev/null 2>/dev/null ; then
+		AC_MSG_RESULT([yes (bsdtar)])
+		TAR_Q='q'
+	else
+		AC_MSG_RESULT([no (gnutar)])
+		TAR_Q=
+	fi
+	AC_SUBST(TAR_Q)
+])
+
 dnl This macro tests for tar support of --no-same-owner
 AC_DEFUN([MP_TAR_NO_SAME_OWNER],[
 	AC_PATH_PROG(TAR, [tar])
@@ -1031,3 +1064,75 @@
 	fi
 	AC_SUBST([CFLAGS_WERROR])
 ])
+
+#------------------------------------------------------------------------
+# MP_CHECK_SQLITE_VERSION --
+#
+#	Check for a specific SQLite version and execute commands depending on availability
+#
+# Arguments:
+#       Required SQLite version for the test to succeed in the form of SQLITE_VERSION_NUMBER
+#
+# Requires:
+#       MP_SQLITE3_FLAGS
+#
+# Depends:
+#		AC_LANG_SOURCE
+#
+# Results:
+#		Result is cached.
+#
+#       sets mp_sqlite_version_ge_$1 to yes or no
+#
+#------------------------------------------------------------------------
+AC_DEFUN(MP_CHECK_SQLITE_VERSION, [
+	AC_REQUIRE([MP_SQLITE3_FLAGS])
+
+	AC_MSG_CHECKING([for SQLite >= $1])
+
+	mp_check_sqlite_version_cppflags_save=$CPPFLAGS
+	CPPFLAGS="$CPPFLAGS $CFLAGS_SQLITE3"
+
+	AC_CACHE_VAL(mp_cv_sqlite_version_defined, [
+		AC_PREPROC_IFELSE(
+			[AC_LANG_SOURCE(
+				[[
+					#include <sqlite3.h>
+					#ifndef SQLITE_VERSION_NUMBER
+					#  error "SQLITE_VERSION_NUMBER undefined"
+					#endif
+				]]
+			)],
+			[mp_cv_sqlite_version_defined="yes"],
+			[AC_MSG_ERROR("SQLITE_VERSION_NUMBER undefined or sqlite3.h not found")]
+		)
+	])
+
+	if test x"${mp_cv_sqlite_version_defined}" = "xno"; then
+		AC_MSG_RESULT([SQLite version not found])
+		mp_sqlite_version_ge_$1="no"
+	else
+		AC_CACHE_VAL(mp_cv_sqlite_version_ge_$1, [
+			AC_PREPROC_IFELSE(
+				[AC_LANG_SOURCE(
+					[[
+						#include <sqlite3.h>
+						#if (SQLITE_VERSION_NUMBER >= $1)
+						/* Everything is fine */
+						#else
+						#  error "SQLite version too old"
+						#endif
+					]]
+				)],
+				[mp_cv_sqlite_version_ge_$1="yes"],
+				[mp_cv_sqlite_version_ge_$1="no"]
+			)
+		])
+
+		AC_MSG_RESULT(${mp_cv_sqlite_version_ge_$1})
+		mp_sqlite_version_ge_$1=${mp_cv_sqlite_version_ge_$1}
+	fi
+
+	CPPFLAGS=$mp_check_sqlite_version_cppflags_save
+])
+

Modified: branches/new-help-system/base/config/RELEASE_URL
===================================================================
--- branches/new-help-system/base/config/RELEASE_URL	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/config/RELEASE_URL	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1 +1 @@
-http://svn.macports.org/repository/macports/tags/release_1_9_1/base
+https://svn.macports.org/repository/macports/tags/release_2_0_4/base

Modified: branches/new-help-system/base/config/macports_version
===================================================================
--- branches/new-help-system/base/config/macports_version	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/config/macports_version	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1 +1 @@
-1.9.99
+2.0.99

Modified: branches/new-help-system/base/configure
===================================================================
--- branches/new-help-system/base/configure	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/configure	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.67 for MacPorts 1.9.99.
+# Generated by GNU Autoconf 2.68 for MacPorts 2.0.99.
 #
 # Report bugs to <macports-dev at lists.macosforge.org>.
 #
@@ -91,6 +91,7 @@
 IFS=" ""	$as_nl"
 
 # Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
 case $0 in #((
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -216,11 +217,18 @@
   # 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
-	exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+	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+"$@"}
 fi
 
     if test x$as_have_required = xno; then :
@@ -552,8 +560,8 @@
 # Identity of this package.
 PACKAGE_NAME='MacPorts'
 PACKAGE_TARNAME='macports'
-PACKAGE_VERSION='1.9.99'
-PACKAGE_STRING='MacPorts 1.9.99'
+PACKAGE_VERSION='2.0.99'
+PACKAGE_STRING='MacPorts 2.0.99'
 PACKAGE_BUGREPORT='macports-dev at lists.macosforge.org'
 PACKAGE_URL=''
 
@@ -639,8 +647,8 @@
 MPFRAMEWORKSDIR
 MPAPPLICATIONSDIR
 DSTMODE
+TCL_PACKAGE_DIR
 RUNUSR
-TCL_PACKAGE_DIR
 DSTGRP
 DSTUSR
 MPCONFIGDIR
@@ -666,54 +674,63 @@
 PTHREAD_LIBS
 acx_pthread_config
 CFLAGS_WERROR
+CFLAGS_PEDANTIC
 CFLAGS_QUICHEEATERS
 TAR_CMD
+TAR_Q
 SED_EXT
-OPEN
-XAR
-PAX
-MKBOM
-LSBOM
-BZIP2
-GNUPATCH
-GNUMAKE
-GNUTAR
-XCODEBUILD
-LAUNCHCTL
 HAVE_LAUNCHD
-HDIUTIL
-MAKE
-BSDMAKE
 ZIP
+XZ
+XCRUN
+XCODEBUILD
+XAR
 UNZIP
 TAR
+SWIG
+SVN
 SED
-OPENSSL
 RSYNC
 RMDIR
+PAX
 PATCH
+OPENSSL
+OPEN
+MTREE
+MKBOM
+MDLS
+MDFIND
+MAKE
+LZMA
+LSBOM
 LIPO
+LAUNCHCTL
+HG
+HDIUTIL
 GZIP
-HG
+GNUTAR
+GNUPATCH
+GNUMAKE
 GIT
-SVN
-CVS
-BZR
 FILE
+DSEDITGROUP
 DSCL
 DIFF
+CVS
 CPIO
 CP
 CHOWN
-MTREE
+BZR
+BZIP2
+BSDMAKE
+ac_ct_OBJC
+OBJCFLAGS
+OBJC
+SET_MAKE
 LN_S
-SET_MAKE
 INSTALL_DATA
 INSTALL_SCRIPT
 INSTALL_PROGRAM
-ac_ct_OBJC
-OBJCFLAGS
-OBJC
 OBJEXT
 EXEEXT
 ac_ct_CC
@@ -783,6 +800,7 @@
 enable_werror
 with_objc_runtime
 with_objc_foundation
+with_unsupported_prefix
 with_ports_dir
 with_no_root_privileges
 with_install_user
@@ -814,20 +832,23 @@
 CPPFLAGS
 OBJC
 OBJCFLAGS
+BSDMAKE
+BZIP2
+CVS
+GNUMAKE
+GNUTAR
+LZMA
+MAKE
 MTREE
-CVS
-SVN
+OPEN
 OPENSSL
 RSYNC
 SED
+SVN
+SWIG
 TAR
-MAKE
-GNUTAR
-BSDMAKE
-GNUMAKE
-BZIP2
 XAR
-OPEN
+XZ
 OBJCPP
 CPP'
 ac_subdirs_all='src/thread2.6'
@@ -1234,7 +1255,7 @@
     $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
     expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
       $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
     ;;
 
   esac
@@ -1372,7 +1393,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 1.9.99 to adapt to many kinds of systems.
+\`configure' configures MacPorts 2.0.99 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1438,7 +1459,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of MacPorts 1.9.99:";;
+     short | recursive ) echo "Configuration of MacPorts 2.0.99:";;
    esac
   cat <<\_ACEOF
 
@@ -1456,6 +1477,9 @@
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-objc-runtime     Specify either "GNU" or "apple"
   --with-objc-foundation  Specify either "GNUstep" or "apple"
+  --with-unsupported-prefix
+                          Acknowledge that you accept the consequences of
+                          using an unsupported prefix.
   --with-ports-dir=DIR    Specify alternate ports directory
   --with-no-root-privileges
                           Specify that MacPorts should be installed in your
@@ -1495,20 +1519,23 @@
               you have headers in a nonstandard directory <include dir>
   OBJC        Objective C compiler command
   OBJCFLAGS   Objective C compiler flags
+  BSDMAKE     path to bsdmake/pmake command
+  BZIP2       path to bzip2 command
+  CVS         path to cvs command
+  GNUMAKE     path to gnumake command
+  GNUTAR      path to gnutar command
+  LZMA        path to lzma command
+  MAKE        path to make command
   MTREE       path to mtree command
-  CVS         path to cvs command
-  SVN         path to svn command
+  OPEN        path to open command
   OPENSSL     path to openssl command
   RSYNC       path to rsync command
   SED         path to sed command
+  SVN         path to svn command
+  SWIG        path to swig command
   TAR         path to tar command
-  MAKE        path to make command
-  GNUTAR      path to gnutar command
-  BSDMAKE     path to bsdmake/pmake command
-  GNUMAKE     path to gnumake command
-  BZIP2       path to bzip2 command
   XAR         path to xar command
-  OPEN        path to open command
+  XZ          path to xz command
   OBJCPP      Objective C preprocessor
   CPP         C preprocessor
 
@@ -1578,8 +1605,8 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-MacPorts configure 1.9.99
-generated by GNU Autoconf 2.67
+MacPorts configure 2.0.99
+generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
 This configure script is free software; the Free Software Foundation
@@ -1625,7 +1652,7 @@
 
 	ac_retval=1
 fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_compile
@@ -1663,7 +1690,7 @@
 
 	ac_retval=1
 fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_objc_try_compile
@@ -1709,7 +1736,7 @@
   # interfere with the next link command; also delete a directory that is
   # left behind by Apple's compiler.  We do this before executing the actions.
   rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_link
@@ -1746,7 +1773,7 @@
 
     ac_retval=1
 fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_objc_try_cpp
@@ -1759,10 +1786,10 @@
 ac_fn_objc_check_header_mongrel ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if eval "test \"\${$3+set}\"" = set; then :
+  if eval \${$3+:} false; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 fi
 eval ac_res=\$$3
@@ -1829,7 +1856,7 @@
 esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   eval "$3=\$ac_header_compiler"
@@ -1838,7 +1865,7 @@
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
 fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_objc_check_header_mongrel
 
@@ -1879,7 +1906,7 @@
        ac_retval=$ac_status
 fi
   rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_objc_try_run
@@ -1893,7 +1920,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -1911,7 +1938,7 @@
 eval ac_res=\$$3
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_objc_check_header_compile
 
@@ -1956,7 +1983,7 @@
   # interfere with the next link command; also delete a directory that is
   # left behind by Apple's compiler.  We do this before executing the actions.
   rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_objc_try_link
@@ -1993,7 +2020,7 @@
 
     ac_retval=1
 fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_cpp
@@ -2035,7 +2062,7 @@
        ac_retval=$ac_status
 fi
   rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_try_run
@@ -2048,10 +2075,10 @@
 ac_fn_c_check_header_mongrel ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if eval "test \"\${$3+set}\"" = set; then :
+  if eval \${$3+:} false; then :
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 fi
 eval ac_res=\$$3
@@ -2118,7 +2145,7 @@
 esac
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   eval "$3=\$ac_header_compiler"
@@ -2127,7 +2154,7 @@
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
 fi
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_header_mongrel
 
@@ -2139,7 +2166,7 @@
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
 $as_echo_n "checking for $2... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -2194,7 +2221,7 @@
 eval ac_res=\$$3
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_func
 
@@ -2209,7 +2236,7 @@
   as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
 $as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval "test \"\${$3+set}\"" = set; then :
+if eval \${$3+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -2240,15 +2267,15 @@
 eval ac_res=\$$3
 	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
 $as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 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 1.9.99, which was
-generated by GNU Autoconf 2.67.  Invocation command line was
+It was created by MacPorts $as_me 2.0.99, which was
+generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
 
@@ -2634,7 +2661,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
 $as_echo_n "checking build system type... " >&6; }
-if test "${ac_cv_build+set}" = set; then :
+if ${ac_cv_build+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_build_alias=$build_alias
@@ -2668,7 +2695,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
 $as_echo_n "checking host system type... " >&6; }
-if test "${ac_cv_host+set}" = set; then :
+if ${ac_cv_host+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test "x$host_alias" = x; then
@@ -2701,7 +2728,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
 $as_echo_n "checking target system type... " >&6; }
-if test "${ac_cv_target+set}" = set; then :
+if ${ac_cv_target+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test "x$target_alias" = x; then
@@ -2742,7 +2769,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=1.9.99
+MACPORTS_VERSION=2.0.99
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MACPORTS_VERSION" >&5
 $as_echo "$MACPORTS_VERSION" >&6; }
 
@@ -2778,7 +2805,7 @@
 set dummy sw_vers; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_SW_VERS+set}" = set; then :
+if ${ac_cv_path_SW_VERS+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $SW_VERS in
@@ -2818,7 +2845,7 @@
 set dummy defaults; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_DEFAULTS+set}" = set; then :
+if ${ac_cv_path_DEFAULTS+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $DEFAULTS in
@@ -2858,7 +2885,7 @@
 set dummy xcode-select; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_XCODE_SELECT+set}" = set; then :
+if ${ac_cv_path_XCODE_SELECT+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $XCODE_SELECT in
@@ -2908,13 +2935,13 @@
     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-1])
+  10.4.[0-9]|10.4.10|10.5.[0-7]|10.6.[0-7])
     { $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
 $as_echo "$as_me: WARNING: Please run Software Update to update it" >&2;}
     ;;
-  10.4*|10.5*|10.6*)
+  10.4*|10.5*|10.6*|10.7*)
         ;;
   *)
     ;;
@@ -2958,7 +2985,7 @@
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Please consider upgrading as some ports fail compiling" >&5
 $as_echo "$as_me: WARNING: Please consider upgrading as some ports fail compiling" >&2;}
     ;;
-  2.*|3.*)
+  2.*|3.*|4.*)
         ;;
   *)
     ;;
@@ -2975,7 +3002,7 @@
 set dummy ${ac_tool_prefix}gcc; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3015,7 +3042,7 @@
 set dummy gcc; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
@@ -3068,7 +3095,7 @@
 set dummy ${ac_tool_prefix}cc; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3108,7 +3135,7 @@
 set dummy cc; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3167,7 +3194,7 @@
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_CC+set}" = set; then :
+if ${ac_cv_prog_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$CC"; then
@@ -3211,7 +3238,7 @@
 set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_CC"; then
@@ -3494,7 +3521,7 @@
 ac_clean_files=$ac_clean_files_save
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
 $as_echo_n "checking for suffix of object files... " >&6; }
-if test "${ac_cv_objext+set}" = set; then :
+if ${ac_cv_objext+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -3545,7 +3572,7 @@
 ac_objext=$OBJEXT
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+if ${ac_cv_c_compiler_gnu+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -3582,7 +3609,7 @@
 ac_save_CFLAGS=$CFLAGS
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
 $as_echo_n "checking whether $CC accepts -g... " >&6; }
-if test "${ac_cv_prog_cc_g+set}" = set; then :
+if ${ac_cv_prog_cc_g+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_save_c_werror_flag=$ac_c_werror_flag
@@ -3660,7 +3687,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if test "${ac_cv_prog_cc_c89+set}" = set; then :
+if ${ac_cv_prog_cc_c89+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_cv_prog_cc_c89=no
@@ -3755,6 +3782,141 @@
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if ${ac_cv_path_install+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+  ./ | .// | /[cC]/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # 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 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.
+	    :
+	  elif test $ac_prog = install &&
+	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+	    # program-specific install script used by HP pwplus--don't use.
+	    :
+	  else
+	    rm -rf conftest.one conftest.two conftest.dir
+	    echo one > conftest.one
+	    echo two > conftest.two
+	    mkdir conftest.dir
+	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+	      test -s conftest.one && test -s conftest.two &&
+	      test -s conftest.dir/conftest.one &&
+	      test -s conftest.dir/conftest.two
+	    then
+	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+	      break 3
+	    fi
+	  fi
+	fi
+      done
+    done
+    ;;
+esac
+
+  done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+	@echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
 ac_ext=m
 ac_cpp='$OBJCPP $CPPFLAGS'
 ac_compile='$OBJC -c $OBJCFLAGS $CPPFLAGS conftest.$ac_ext >&5'
@@ -3767,7 +3929,7 @@
 set dummy $ac_tool_prefix$ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_OBJC+set}" = set; then :
+if ${ac_cv_prog_OBJC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$OBJC"; then
@@ -3811,7 +3973,7 @@
 set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_ac_ct_OBJC+set}" = set; then :
+if ${ac_cv_prog_ac_ct_OBJC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$ac_ct_OBJC"; then
@@ -3887,7 +4049,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Objective C compiler" >&5
 $as_echo_n "checking whether we are using the GNU Objective C compiler... " >&6; }
-if test "${ac_cv_objc_compiler_gnu+set}" = set; then :
+if ${ac_cv_objc_compiler_gnu+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -3924,7 +4086,7 @@
 ac_save_OBJCFLAGS=$OBJCFLAGS
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $OBJC accepts -g" >&5
 $as_echo_n "checking whether $OBJC accepts -g... " >&6; }
-if test "${ac_cv_prog_objc_g+set}" = set; then :
+if ${ac_cv_prog_objc_g+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_save_objc_werror_flag=$ac_objc_werror_flag
@@ -4006,162 +4168,112 @@
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-# Find a good install program.  We prefer a C program (faster),
-# so one script is as good as another.  But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-# Reject install programs that cannot install multiple files.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
-$as_echo_n "checking for a BSD-compatible install... " >&6; }
-if test -z "$INSTALL"; then
-if test "${ac_cv_path_install+set}" = set; then :
+
+for ac_prog in bsdmake pmake
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; 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_BSDMAKE+:} false; then :
   $as_echo_n "(cached) " >&6
 else
+  case $BSDMAKE in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_BSDMAKE="$BSDMAKE" # Let the user override the test with a path.
+  ;;
+  *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in #((
-  ./ | .// | /[cC]/* | \
-  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
-  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
-  /usr/ucb/* ) ;;
-  *)
-    # OSF1 and SCO ODT 3.0 have their own names for install.
-    # Don't use installbsd from OSF since it installs stuff as root
-    # 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 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.
-	    :
-	  elif test $ac_prog = install &&
-	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-	    # program-specific install script used by HP pwplus--don't use.
-	    :
-	  else
-	    rm -rf conftest.one conftest.two conftest.dir
-	    echo one > conftest.one
-	    echo two > conftest.two
-	    mkdir conftest.dir
-	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
-	      test -s conftest.one && test -s conftest.two &&
-	      test -s conftest.dir/conftest.one &&
-	      test -s conftest.dir/conftest.two
-	    then
-	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
-	      break 3
-	    fi
-	  fi
-	fi
-      done
-    done
-    ;;
-esac
-
+    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
+    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
+  fi
+done
   done
 IFS=$as_save_IFS
 
-rm -rf conftest.one conftest.two conftest.dir
-
+  ;;
+esac
 fi
-  if test "${ac_cv_path_install+set}" = set; then
-    INSTALL=$ac_cv_path_install
-  else
-    # As a last resort, use the slow shell script.  Don't cache a
-    # value for INSTALL within a source directory, because that will
-    # break other packages using the cache if that directory is
-    # removed, or if the value is a relative name.
-    INSTALL=$ac_install_sh
-  fi
+BSDMAKE=$ac_cv_path_BSDMAKE
+if test -n "$BSDMAKE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BSDMAKE" >&5
+$as_echo "$BSDMAKE" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
-$as_echo "$INSTALL" >&6; }
 
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
 
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+  test -n "$BSDMAKE" && break
+done
 
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
-$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
-set x ${MAKE-make}
-ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then :
+# Extract the first word of "bzip2", so it can be a program name with args.
+set dummy bzip2; 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_BZIP2+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  cat >conftest.make <<\_ACEOF
-SHELL = /bin/sh
-all:
-	@echo '@@@%%%=$(MAKE)=@@@%%%'
-_ACEOF
-# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
-case `${MAKE-make} -f conftest.make 2>/dev/null` in
-  *@@@%%%=?*=@@@%%%*)
-    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  case $BZIP2 in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_BZIP2="$BZIP2" # Let the user override the test with a path.
+  ;;
   *)
-    eval ac_cv_prog_make_${ac_make}_set=no;;
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  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
+    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
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
 esac
-rm -f conftest.make
 fi
-if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-  SET_MAKE=
+BZIP2=$ac_cv_path_BZIP2
+if test -n "$BZIP2"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BZIP2" >&5
+$as_echo "$BZIP2" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-  SET_MAKE="MAKE=${MAKE-make}"
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
-$as_echo_n "checking whether ln -s works... " >&6; }
-LN_S=$as_ln_s
-if test "$LN_S" = "ln -s"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
-$as_echo "no, using $LN_S" >&6; }
-fi
 
-# Extract the first word of "mtree", so it can be a program name with args.
-set dummy mtree; ac_word=$2
+# Extract the first word of "bzr", so it can be a program name with args.
+set dummy bzr; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_MTREE+set}" = set; then :
+if ${ac_cv_path_BZR+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $MTREE in
+  case $BZR in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_MTREE="$MTREE" # Let the user override the test with a path.
+  ac_cv_path_BZR="$BZR" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_dummy="$PATH:/usr/sbin"
-for as_dir in $as_dummy
+for as_dir in $PATH
 do
   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
-    ac_cv_path_MTREE="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4172,10 +4284,10 @@
   ;;
 esac
 fi
-MTREE=$ac_cv_path_MTREE
-if test -n "$MTREE"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MTREE" >&5
-$as_echo "$MTREE" >&6; }
+BZR=$ac_cv_path_BZR
+if test -n "$BZR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BZR" >&5
+$as_echo "$BZR" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -4186,7 +4298,7 @@
 set dummy chown; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CHOWN+set}" = set; then :
+if ${ac_cv_path_CHOWN+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $CHOWN in
@@ -4227,7 +4339,7 @@
 set dummy cp; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CP+set}" = set; then :
+if ${ac_cv_path_CP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $CP in
@@ -4267,7 +4379,7 @@
 set dummy cpio; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CPIO+set}" = set; then :
+if ${ac_cv_path_CPIO+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $CPIO in
@@ -4303,11 +4415,51 @@
 fi
 
 
+# Extract the first word of "cvs", so it can be a program name with args.
+set dummy cvs; 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_CVS+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CVS in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CVS="$CVS" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  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
+    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
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CVS=$ac_cv_path_CVS
+if test -n "$CVS"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CVS" >&5
+$as_echo "$CVS" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
 # Extract the first word of "diff", so it can be a program name with args.
 set dummy diff; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_DIFF+set}" = set; then :
+if ${ac_cv_path_DIFF+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $DIFF in
@@ -4347,7 +4499,7 @@
 set dummy dscl; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_DSCL+set}" = set; then :
+if ${ac_cv_path_DSCL+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $DSCL in
@@ -4383,11 +4535,51 @@
 fi
 
 
+# Extract the first word of "dseditgroup", so it can be a program name with args.
+set dummy dseditgroup; 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_DSEDITGROUP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $DSEDITGROUP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_DSEDITGROUP="$DSEDITGROUP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  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
+    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
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+DSEDITGROUP=$ac_cv_path_DSEDITGROUP
+if test -n "$DSEDITGROUP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSEDITGROUP" >&5
+$as_echo "$DSEDITGROUP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
 # Extract the first word of "file", so it can be a program name with args.
 set dummy file; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_FILE+set}" = set; then :
+if ${ac_cv_path_FILE+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $FILE in
@@ -4423,16 +4615,16 @@
 fi
 
 
-# Extract the first word of "bzr", so it can be a program name with args.
-set dummy bzr; ac_word=$2
+# Extract the first word of "git", so it can be a program name with args.
+set dummy git; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_BZR+set}" = set; then :
+if ${ac_cv_path_GIT+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $BZR in
+  case $GIT in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_BZR="$BZR" # Let the user override the test with a path.
+  ac_cv_path_GIT="$GIT" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -4442,7 +4634,7 @@
   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
-    ac_cv_path_BZR="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4453,36 +4645,39 @@
   ;;
 esac
 fi
-BZR=$ac_cv_path_BZR
-if test -n "$BZR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BZR" >&5
-$as_echo "$BZR" >&6; }
+GIT=$ac_cv_path_GIT
+if test -n "$GIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GIT" >&5
+$as_echo "$GIT" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "cvs", so it can be a program name with args.
-set dummy cvs; ac_word=$2
+for ac_prog in gnumake gmake
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CVS+set}" = set; then :
+if ${ac_cv_path_GNUMAKE+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $CVS in
+  case $GNUMAKE in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_CVS="$CVS" # Let the user override the test with a path.
+  ac_cv_path_GNUMAKE="$GNUMAKE" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
+as_dummy="$PATH:/usr/local/bin"
+for as_dir in $as_dummy
 do
   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
-    ac_cv_path_CVS="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4493,36 +4688,131 @@
   ;;
 esac
 fi
-CVS=$ac_cv_path_CVS
-if test -n "$CVS"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CVS" >&5
-$as_echo "$CVS" >&6; }
+GNUMAKE=$ac_cv_path_GNUMAKE
+if test -n "$GNUMAKE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GNUMAKE" >&5
+$as_echo "$GNUMAKE" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "svn", so it can be a program name with args.
-set dummy svn; ac_word=$2
+  test -n "$GNUMAKE" && break
+done
+
+for ac_prog in gnupatch gpatch
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_SVN+set}" = set; then :
+if ${ac_cv_path_GNUPATCH+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $SVN in
+  case $GNUPATCH in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_SVN="$SVN" # Let the user override the test with a path.
+  ac_cv_path_GNUPATCH="$GNUPATCH" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_dummy="$PATH:/usr/local/bin"
+for as_dir in $as_dummy
+do
+  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
+    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
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+GNUPATCH=$ac_cv_path_GNUPATCH
+if test -n "$GNUPATCH"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GNUPATCH" >&5
+$as_echo "$GNUPATCH" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$GNUPATCH" && break
+done
+
+for ac_prog in gnutar gtar
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; 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_GNUTAR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GNUTAR in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GNUTAR="$GNUTAR" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_dummy="$PATH:/usr/local/bin"
+for as_dir in $as_dummy
+do
+  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
+    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
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+GNUTAR=$ac_cv_path_GNUTAR
+if test -n "$GNUTAR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GNUTAR" >&5
+$as_echo "$GNUTAR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$GNUTAR" && break
+done
+
+# Extract the first word of "gzip", so it can be a program name with args.
+set dummy gzip; 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_GZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GZIP="$GZIP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   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
-    ac_cv_path_SVN="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4533,26 +4823,26 @@
   ;;
 esac
 fi
-SVN=$ac_cv_path_SVN
-if test -n "$SVN"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SVN" >&5
-$as_echo "$SVN" >&6; }
+GZIP=$ac_cv_path_GZIP
+if test -n "$GZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP" >&5
+$as_echo "$GZIP" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "git", so it can be a program name with args.
-set dummy git; ac_word=$2
+# Extract the first word of "hdiutil", so it can be a program name with args.
+set dummy hdiutil; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_GIT+set}" = set; then :
+if ${ac_cv_path_HDIUTIL+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $GIT in
+  case $HDIUTIL in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_GIT="$GIT" # Let the user override the test with a path.
+  ac_cv_path_HDIUTIL="$HDIUTIL" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -4562,7 +4852,7 @@
   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
-    ac_cv_path_GIT="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4573,10 +4863,10 @@
   ;;
 esac
 fi
-GIT=$ac_cv_path_GIT
-if test -n "$GIT"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GIT" >&5
-$as_echo "$GIT" >&6; }
+HDIUTIL=$ac_cv_path_HDIUTIL
+if test -n "$HDIUTIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HDIUTIL" >&5
+$as_echo "$HDIUTIL" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -4587,7 +4877,7 @@
 set dummy hg; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_HG+set}" = set; then :
+if ${ac_cv_path_HG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $HG in
@@ -4623,16 +4913,16 @@
 fi
 
 
-# Extract the first word of "gzip", so it can be a program name with args.
-set dummy gzip; ac_word=$2
+# Extract the first word of "launchctl", so it can be a program name with args.
+set dummy launchctl; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_GZIP+set}" = set; then :
+if ${ac_cv_path_LAUNCHCTL+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $GZIP in
+  case $LAUNCHCTL in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_GZIP="$GZIP" # Let the user override the test with a path.
+  ac_cv_path_LAUNCHCTL="$LAUNCHCTL" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -4642,7 +4932,7 @@
   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
-    ac_cv_path_GZIP="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4653,10 +4943,10 @@
   ;;
 esac
 fi
-GZIP=$ac_cv_path_GZIP
-if test -n "$GZIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP" >&5
-$as_echo "$GZIP" >&6; }
+LAUNCHCTL=$ac_cv_path_LAUNCHCTL
+if test -n "$LAUNCHCTL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LAUNCHCTL" >&5
+$as_echo "$LAUNCHCTL" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -4667,7 +4957,7 @@
 set dummy lipo; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_LIPO+set}" = set; then :
+if ${ac_cv_path_LIPO+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $LIPO in
@@ -4703,16 +4993,16 @@
 fi
 
 
-# Extract the first word of "patch", so it can be a program name with args.
-set dummy patch; ac_word=$2
+# Extract the first word of "lsbom", so it can be a program name with args.
+set dummy lsbom; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PATCH+set}" = set; then :
+if ${ac_cv_path_LSBOM+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $PATCH in
+  case $LSBOM in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_PATCH="$PATCH" # Let the user override the test with a path.
+  ac_cv_path_LSBOM="$LSBOM" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -4722,7 +5012,7 @@
   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
-    ac_cv_path_PATCH="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4733,26 +5023,26 @@
   ;;
 esac
 fi
-PATCH=$ac_cv_path_PATCH
-if test -n "$PATCH"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PATCH" >&5
-$as_echo "$PATCH" >&6; }
+LSBOM=$ac_cv_path_LSBOM
+if test -n "$LSBOM"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LSBOM" >&5
+$as_echo "$LSBOM" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "rmdir", so it can be a program name with args.
-set dummy rmdir; ac_word=$2
+# Extract the first word of "lzma", so it can be a program name with args.
+set dummy lzma; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_RMDIR+set}" = set; then :
+if ${ac_cv_path_LZMA+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $RMDIR in
+  case $LZMA in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_RMDIR="$RMDIR" # Let the user override the test with a path.
+  ac_cv_path_LZMA="$LZMA" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -4762,7 +5052,7 @@
   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
-    ac_cv_path_RMDIR="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4773,26 +5063,26 @@
   ;;
 esac
 fi
-RMDIR=$ac_cv_path_RMDIR
-if test -n "$RMDIR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RMDIR" >&5
-$as_echo "$RMDIR" >&6; }
+LZMA=$ac_cv_path_LZMA
+if test -n "$LZMA"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LZMA" >&5
+$as_echo "$LZMA" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "rsync", so it can be a program name with args.
-set dummy rsync; ac_word=$2
+# Extract the first word of "make", so it can be a program name with args.
+set dummy make; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_RSYNC+set}" = set; then :
+if ${ac_cv_path_MAKE+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $RSYNC in
+  case $MAKE in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_RSYNC="$RSYNC" # Let the user override the test with a path.
+  ac_cv_path_MAKE="$MAKE" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -4802,7 +5092,7 @@
   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
-    ac_cv_path_RSYNC="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4813,26 +5103,26 @@
   ;;
 esac
 fi
-RSYNC=$ac_cv_path_RSYNC
-if test -n "$RSYNC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RSYNC" >&5
-$as_echo "$RSYNC" >&6; }
+MAKE=$ac_cv_path_MAKE
+if test -n "$MAKE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKE" >&5
+$as_echo "$MAKE" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "openssl", so it can be a program name with args.
-set dummy openssl; ac_word=$2
+# Extract the first word of "mdfind", so it can be a program name with args.
+set dummy mdfind; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_OPENSSL+set}" = set; then :
+if ${ac_cv_path_MDFIND+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $OPENSSL in
+  case $MDFIND in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_OPENSSL="$OPENSSL" # Let the user override the test with a path.
+  ac_cv_path_MDFIND="$MDFIND" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -4842,7 +5132,7 @@
   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
-    ac_cv_path_OPENSSL="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4853,26 +5143,26 @@
   ;;
 esac
 fi
-OPENSSL=$ac_cv_path_OPENSSL
-if test -n "$OPENSSL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENSSL" >&5
-$as_echo "$OPENSSL" >&6; }
+MDFIND=$ac_cv_path_MDFIND
+if test -n "$MDFIND"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MDFIND" >&5
+$as_echo "$MDFIND" >&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
+# Extract the first word of "mdls", so it can be a program name with args.
+set dummy mdls; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_SED+set}" = set; then :
+if ${ac_cv_path_MDLS+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $SED in
+  case $MDLS in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_SED="$SED" # Let the user override the test with a path.
+  ac_cv_path_MDLS="$MDLS" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -4882,7 +5172,7 @@
   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
-    ac_cv_path_SED="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4893,26 +5183,26 @@
   ;;
 esac
 fi
-SED=$ac_cv_path_SED
-if test -n "$SED"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SED" >&5
-$as_echo "$SED" >&6; }
+MDLS=$ac_cv_path_MDLS
+if test -n "$MDLS"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MDLS" >&5
+$as_echo "$MDLS" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "tar", so it can be a program name with args.
-set dummy tar; ac_word=$2
+# Extract the first word of "mkbom", so it can be a program name with args.
+set dummy mkbom; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_TAR+set}" = set; then :
+if ${ac_cv_path_MKBOM+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $TAR in
+  case $MKBOM in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_TAR="$TAR" # Let the user override the test with a path.
+  ac_cv_path_MKBOM="$MKBOM" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -4922,7 +5212,7 @@
   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
-    ac_cv_path_TAR="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4933,36 +5223,37 @@
   ;;
 esac
 fi
-TAR=$ac_cv_path_TAR
-if test -n "$TAR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAR" >&5
-$as_echo "$TAR" >&6; }
+MKBOM=$ac_cv_path_MKBOM
+if test -n "$MKBOM"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKBOM" >&5
+$as_echo "$MKBOM" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "unzip", so it can be a program name with args.
-set dummy unzip; ac_word=$2
+# Extract the first word of "mtree", so it can be a program name with args.
+set dummy mtree; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_UNZIP+set}" = set; then :
+if ${ac_cv_path_MTREE+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $UNZIP in
+  case $MTREE in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_UNZIP="$UNZIP" # Let the user override the test with a path.
+  ac_cv_path_MTREE="$MTREE" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
+as_dummy="$PATH:/usr/sbin"
+for as_dir in $as_dummy
 do
   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
-    ac_cv_path_UNZIP="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -4973,26 +5264,26 @@
   ;;
 esac
 fi
-UNZIP=$ac_cv_path_UNZIP
-if test -n "$UNZIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNZIP" >&5
-$as_echo "$UNZIP" >&6; }
+MTREE=$ac_cv_path_MTREE
+if test -n "$MTREE"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MTREE" >&5
+$as_echo "$MTREE" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "zip", so it can be a program name with args.
-set dummy zip; ac_word=$2
+# Extract the first word of "open", so it can be a program name with args.
+set dummy open; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_ZIP+set}" = set; then :
+if ${ac_cv_path_OPEN+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $ZIP in
+  case $OPEN in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_ZIP="$ZIP" # Let the user override the test with a path.
+  ac_cv_path_OPEN="$OPEN" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5002,7 +5293,7 @@
   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
-    ac_cv_path_ZIP="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5013,28 +5304,26 @@
   ;;
 esac
 fi
-ZIP=$ac_cv_path_ZIP
-if test -n "$ZIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5
-$as_echo "$ZIP" >&6; }
+OPEN=$ac_cv_path_OPEN
+if test -n "$OPEN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPEN" >&5
+$as_echo "$OPEN" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-for ac_prog in bsdmake pmake
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
+# Extract the first word of "openssl", so it can be a program name with args.
+set dummy openssl; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_BSDMAKE+set}" = set; then :
+if ${ac_cv_path_OPENSSL+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $BSDMAKE in
+  case $OPENSSL in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_BSDMAKE="$BSDMAKE" # Let the user override the test with a path.
+  ac_cv_path_OPENSSL="$OPENSSL" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5044,7 +5333,7 @@
   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
-    ac_cv_path_BSDMAKE="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5055,29 +5344,26 @@
   ;;
 esac
 fi
-BSDMAKE=$ac_cv_path_BSDMAKE
-if test -n "$BSDMAKE"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BSDMAKE" >&5
-$as_echo "$BSDMAKE" >&6; }
+OPENSSL=$ac_cv_path_OPENSSL
+if test -n "$OPENSSL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPENSSL" >&5
+$as_echo "$OPENSSL" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-  test -n "$BSDMAKE" && break
-done
-
-# Extract the first word of "make", so it can be a program name with args.
-set dummy make; ac_word=$2
+# Extract the first word of "patch", so it can be a program name with args.
+set dummy patch; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_MAKE+set}" = set; then :
+if ${ac_cv_path_PATCH+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $MAKE in
+  case $PATCH in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_MAKE="$MAKE" # Let the user override the test with a path.
+  ac_cv_path_PATCH="$PATCH" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5087,7 +5373,7 @@
   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
-    ac_cv_path_MAKE="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5098,26 +5384,26 @@
   ;;
 esac
 fi
-MAKE=$ac_cv_path_MAKE
-if test -n "$MAKE"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKE" >&5
-$as_echo "$MAKE" >&6; }
+PATCH=$ac_cv_path_PATCH
+if test -n "$PATCH"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PATCH" >&5
+$as_echo "$PATCH" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "hdiutil", so it can be a program name with args.
-set dummy hdiutil; ac_word=$2
+# Extract the first word of "pax", so it can be a program name with args.
+set dummy pax; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_HDIUTIL+set}" = set; then :
+if ${ac_cv_path_PAX+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $HDIUTIL in
+  case $PAX in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_HDIUTIL="$HDIUTIL" # Let the user override the test with a path.
+  ac_cv_path_PAX="$PAX" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5127,7 +5413,7 @@
   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
-    ac_cv_path_HDIUTIL="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5138,34 +5424,36 @@
   ;;
 esac
 fi
-HDIUTIL=$ac_cv_path_HDIUTIL
-if test -n "$HDIUTIL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HDIUTIL" >&5
-$as_echo "$HDIUTIL" >&6; }
+PAX=$ac_cv_path_PAX
+if test -n "$PAX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PAX" >&5
+$as_echo "$PAX" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "launchd", so it can be a program name with args.
-set dummy launchd; ac_word=$2
+# Extract the first word of "rmdir", so it can be a program name with args.
+set dummy rmdir; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_HAVE_LAUNCHD+set}" = set; then :
+if ${ac_cv_path_RMDIR+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$HAVE_LAUNCHD"; then
-  ac_cv_prog_HAVE_LAUNCHD="$HAVE_LAUNCHD" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+  case $RMDIR in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_RMDIR="$RMDIR" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   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
-    ac_cv_prog_HAVE_LAUNCHD="yes"
+    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
   fi
@@ -5173,28 +5461,29 @@
   done
 IFS=$as_save_IFS
 
+  ;;
+esac
 fi
-fi
-HAVE_LAUNCHD=$ac_cv_prog_HAVE_LAUNCHD
-if test -n "$HAVE_LAUNCHD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_LAUNCHD" >&5
-$as_echo "$HAVE_LAUNCHD" >&6; }
+RMDIR=$ac_cv_path_RMDIR
+if test -n "$RMDIR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RMDIR" >&5
+$as_echo "$RMDIR" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "launchctl", so it can be a program name with args.
-set dummy launchctl; ac_word=$2
+# Extract the first word of "rsync", so it can be a program name with args.
+set dummy rsync; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_LAUNCHCTL+set}" = set; then :
+if ${ac_cv_path_RSYNC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $LAUNCHCTL in
+  case $RSYNC in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_LAUNCHCTL="$LAUNCHCTL" # Let the user override the test with a path.
+  ac_cv_path_RSYNC="$RSYNC" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5204,7 +5493,7 @@
   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
-    ac_cv_path_LAUNCHCTL="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5215,26 +5504,26 @@
   ;;
 esac
 fi
-LAUNCHCTL=$ac_cv_path_LAUNCHCTL
-if test -n "$LAUNCHCTL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LAUNCHCTL" >&5
-$as_echo "$LAUNCHCTL" >&6; }
+RSYNC=$ac_cv_path_RSYNC
+if test -n "$RSYNC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RSYNC" >&5
+$as_echo "$RSYNC" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "xcodebuild", so it can be a program name with args.
-set dummy xcodebuild; ac_word=$2
+# 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
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_XCODEBUILD+set}" = set; then :
+if ${ac_cv_path_SED+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $XCODEBUILD in
+  case $SED in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_XCODEBUILD="$XCODEBUILD" # Let the user override the test with a path.
+  ac_cv_path_SED="$SED" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5244,7 +5533,7 @@
   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
-    ac_cv_path_XCODEBUILD="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5255,39 +5544,36 @@
   ;;
 esac
 fi
-XCODEBUILD=$ac_cv_path_XCODEBUILD
-if test -n "$XCODEBUILD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XCODEBUILD" >&5
-$as_echo "$XCODEBUILD" >&6; }
+SED=$ac_cv_path_SED
+if test -n "$SED"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SED" >&5
+$as_echo "$SED" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-for ac_prog in gnutar gtar
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
+# Extract the first word of "svn", so it can be a program name with args.
+set dummy svn; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_GNUTAR+set}" = set; then :
+if ${ac_cv_path_SVN+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $GNUTAR in
+  case $SVN in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_GNUTAR="$GNUTAR" # Let the user override the test with a path.
+  ac_cv_path_SVN="$SVN" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_dummy="$PATH:/usr/local/bin"
-for as_dir in $as_dummy
+for as_dir in $PATH
 do
   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
-    ac_cv_path_GNUTAR="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5298,31 +5584,26 @@
   ;;
 esac
 fi
-GNUTAR=$ac_cv_path_GNUTAR
-if test -n "$GNUTAR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GNUTAR" >&5
-$as_echo "$GNUTAR" >&6; }
+SVN=$ac_cv_path_SVN
+if test -n "$SVN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SVN" >&5
+$as_echo "$SVN" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-  test -n "$GNUTAR" && break
-done
-
-for ac_prog in gnumake gmake
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
+# Extract the first word of "swig", so it can be a program name with args.
+set dummy swig; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_GNUMAKE+set}" = set; then :
+if ${ac_cv_path_SWIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $GNUMAKE in
+  case $SWIG in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_GNUMAKE="$GNUMAKE" # Let the user override the test with a path.
+  ac_cv_path_SWIG="$SWIG" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5333,7 +5614,7 @@
   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
-    ac_cv_path_GNUMAKE="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5344,42 +5625,36 @@
   ;;
 esac
 fi
-GNUMAKE=$ac_cv_path_GNUMAKE
-if test -n "$GNUMAKE"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GNUMAKE" >&5
-$as_echo "$GNUMAKE" >&6; }
+SWIG=$ac_cv_path_SWIG
+if test -n "$SWIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SWIG" >&5
+$as_echo "$SWIG" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-  test -n "$GNUMAKE" && break
-done
-
-for ac_prog in gnupatch gpatch
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
+# Extract the first word of "tar", so it can be a program name with args.
+set dummy tar; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_GNUPATCH+set}" = set; then :
+if ${ac_cv_path_TAR+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $GNUPATCH in
+  case $TAR in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_GNUPATCH="$GNUPATCH" # Let the user override the test with a path.
+  ac_cv_path_TAR="$TAR" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_dummy="$PATH:/usr/local/bin"
-for as_dir in $as_dummy
+for as_dir in $PATH
 do
   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
-    ac_cv_path_GNUPATCH="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5390,29 +5665,26 @@
   ;;
 esac
 fi
-GNUPATCH=$ac_cv_path_GNUPATCH
-if test -n "$GNUPATCH"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GNUPATCH" >&5
-$as_echo "$GNUPATCH" >&6; }
+TAR=$ac_cv_path_TAR
+if test -n "$TAR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAR" >&5
+$as_echo "$TAR" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-  test -n "$GNUPATCH" && break
-done
-
-# Extract the first word of "bzip2", so it can be a program name with args.
-set dummy bzip2; ac_word=$2
+# Extract the first word of "unzip", so it can be a program name with args.
+set dummy unzip; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_BZIP2+set}" = set; then :
+if ${ac_cv_path_UNZIP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $BZIP2 in
+  case $UNZIP in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_BZIP2="$BZIP2" # Let the user override the test with a path.
+  ac_cv_path_UNZIP="$UNZIP" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5422,7 +5694,7 @@
   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
-    ac_cv_path_BZIP2="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5433,26 +5705,26 @@
   ;;
 esac
 fi
-BZIP2=$ac_cv_path_BZIP2
-if test -n "$BZIP2"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BZIP2" >&5
-$as_echo "$BZIP2" >&6; }
+UNZIP=$ac_cv_path_UNZIP
+if test -n "$UNZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNZIP" >&5
+$as_echo "$UNZIP" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "lsbom", so it can be a program name with args.
-set dummy lsbom; ac_word=$2
+# Extract the first word of "xar", so it can be a program name with args.
+set dummy xar; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_LSBOM+set}" = set; then :
+if ${ac_cv_path_XAR+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $LSBOM in
+  case $XAR in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_LSBOM="$LSBOM" # Let the user override the test with a path.
+  ac_cv_path_XAR="$XAR" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5462,7 +5734,7 @@
   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
-    ac_cv_path_LSBOM="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5473,26 +5745,26 @@
   ;;
 esac
 fi
-LSBOM=$ac_cv_path_LSBOM
-if test -n "$LSBOM"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LSBOM" >&5
-$as_echo "$LSBOM" >&6; }
+XAR=$ac_cv_path_XAR
+if test -n "$XAR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XAR" >&5
+$as_echo "$XAR" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "mkbom", so it can be a program name with args.
-set dummy mkbom; ac_word=$2
+# Extract the first word of "xcodebuild", so it can be a program name with args.
+set dummy xcodebuild; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_MKBOM+set}" = set; then :
+if ${ac_cv_path_XCODEBUILD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $MKBOM in
+  case $XCODEBUILD in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_MKBOM="$MKBOM" # Let the user override the test with a path.
+  ac_cv_path_XCODEBUILD="$XCODEBUILD" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5502,7 +5774,7 @@
   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
-    ac_cv_path_MKBOM="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5513,26 +5785,26 @@
   ;;
 esac
 fi
-MKBOM=$ac_cv_path_MKBOM
-if test -n "$MKBOM"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKBOM" >&5
-$as_echo "$MKBOM" >&6; }
+XCODEBUILD=$ac_cv_path_XCODEBUILD
+if test -n "$XCODEBUILD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XCODEBUILD" >&5
+$as_echo "$XCODEBUILD" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "pax", so it can be a program name with args.
-set dummy pax; ac_word=$2
+# Extract the first word of "xcrun", so it can be a program name with args.
+set dummy xcrun; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PAX+set}" = set; then :
+if ${ac_cv_path_XCRUN+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $PAX in
+  case $XCRUN in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_PAX="$PAX" # Let the user override the test with a path.
+  ac_cv_path_XCRUN="$XCRUN" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5542,7 +5814,7 @@
   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
-    ac_cv_path_PAX="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5553,26 +5825,26 @@
   ;;
 esac
 fi
-PAX=$ac_cv_path_PAX
-if test -n "$PAX"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PAX" >&5
-$as_echo "$PAX" >&6; }
+XCRUN=$ac_cv_path_XCRUN
+if test -n "$XCRUN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XCRUN" >&5
+$as_echo "$XCRUN" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "xar", so it can be a program name with args.
-set dummy xar; ac_word=$2
+# Extract the first word of "xz", so it can be a program name with args.
+set dummy xz; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_XAR+set}" = set; then :
+if ${ac_cv_path_XZ+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $XAR in
+  case $XZ in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_XAR="$XAR" # Let the user override the test with a path.
+  ac_cv_path_XZ="$XZ" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5582,7 +5854,7 @@
   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
-    ac_cv_path_XAR="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5593,26 +5865,26 @@
   ;;
 esac
 fi
-XAR=$ac_cv_path_XAR
-if test -n "$XAR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XAR" >&5
-$as_echo "$XAR" >&6; }
+XZ=$ac_cv_path_XZ
+if test -n "$XZ"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XZ" >&5
+$as_echo "$XZ" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
-# Extract the first word of "open", so it can be a program name with args.
-set dummy open; ac_word=$2
+# Extract the first word of "zip", so it can be a program name with args.
+set dummy zip; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_OPEN+set}" = set; then :
+if ${ac_cv_path_ZIP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $OPEN in
+  case $ZIP in
   [\\/]* | ?:[\\/]*)
-  ac_cv_path_OPEN="$OPEN" # Let the user override the test with a path.
+  ac_cv_path_ZIP="$ZIP" # Let the user override the test with a path.
   ;;
   *)
   as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -5622,7 +5894,7 @@
   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
-    ac_cv_path_OPEN="$as_dir/$ac_word$ac_exec_ext"
+    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
   fi
@@ -5633,10 +5905,10 @@
   ;;
 esac
 fi
-OPEN=$ac_cv_path_OPEN
-if test -n "$OPEN"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OPEN" >&5
-$as_echo "$OPEN" >&6; }
+ZIP=$ac_cv_path_ZIP
+if test -n "$ZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5
+$as_echo "$ZIP" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -5644,6 +5916,44 @@
 
 
 
+# Extract the first word of "launchd", so it can be a program name with args.
+set dummy launchd; 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_prog_HAVE_LAUNCHD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$HAVE_LAUNCHD"; then
+  ac_cv_prog_HAVE_LAUNCHD="$HAVE_LAUNCHD" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  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
+    ac_cv_prog_HAVE_LAUNCHD="yes"
+    $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
+
+fi
+fi
+HAVE_LAUNCHD=$ac_cv_prog_HAVE_LAUNCHD
+if test -n "$HAVE_LAUNCHD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_LAUNCHD" >&5
+$as_echo "$HAVE_LAUNCHD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
 # Define some precious variables allowing user to override PATH for some programs
 
 
@@ -5661,11 +5971,14 @@
 
 
 
+
+
+
 	# 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
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_SED+set}" = set; then :
+if ${ac_cv_path_SED+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $SED in
@@ -5735,7 +6048,7 @@
 set dummy tar; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_TAR+set}" = set; then :
+if ${ac_cv_path_TAR+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $TAR in
@@ -5771,11 +6084,66 @@
 fi
 
 
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether tar supports -q" >&5
+$as_echo_n "checking whether tar supports -q... " >&6; }
+	if $TAR -t -q -f - </dev/null 2>/dev/null ; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (bsdtar)" >&5
+$as_echo "yes (bsdtar)" >&6; }
+		TAR_Q='q'
+	else
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no (gnutar)" >&5
+$as_echo "no (gnutar)" >&6; }
+		TAR_Q=
+	fi
+
+
+
+	# Extract the first word of "tar", so it can be a program name with args.
+set dummy tar; 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_TAR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $TAR in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_TAR="$TAR" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  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
+    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
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+TAR=$ac_cv_path_TAR
+if test -n "$TAR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAR" >&5
+$as_echo "$TAR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
 	# Extract the first word of "gnutar", so it can be a program name with args.
 set dummy gnutar; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_GNUTAR+set}" = set; then :
+if ${ac_cv_path_GNUTAR+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $GNUTAR in
@@ -5840,7 +6208,7 @@
 set dummy patch; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_PATCH+set}" = set; then :
+if ${ac_cv_path_PATCH+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PATCH in
@@ -5880,7 +6248,7 @@
 set dummy gpatch; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_GNUPATCH+set}" = set; then :
+if ${ac_cv_path_GNUPATCH+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $GNUPATCH in
@@ -5937,11 +6305,13 @@
 
 # Quiche eaters options.
 if test x$GCC = xyes; then
-	CFLAGS_QUICHEEATERS='-W -Wall -pedantic'
+	CFLAGS_QUICHEEATERS='-Wextra -Wall'
+	CFLAGS_PEDANTIC='-pedantic'
 fi
 
 
 
+
 	# Check whether --enable-werror was given.
 if test "${enable_werror+set}" = set; then :
   enableval=$enable_werror; enable_werror=${enableval}
@@ -5982,7 +6352,7 @@
 
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc symbol visibility attribute" >&5
 $as_echo_n "checking for gcc symbol visibility attribute... " >&6; }
-	if test "${mp_cv_attribute_mp_private+set}" = set; then :
+	if ${mp_cv_attribute_mp_private+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -6158,7 +6528,7 @@
 set dummy pthread-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_acx_pthread_config+set}" = set; then :
+if ${ac_cv_prog_acx_pthread_config+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -n "$acx_pthread_config"; then
@@ -6337,7 +6707,7 @@
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the Objective C preprocessor" >&5
 $as_echo_n "checking how to run the Objective C preprocessor... " >&6; }
 if test -z "$OBJCPP"; then
-  if test "${ac_cv_prog_OBJCPP+set}" = set; then :
+  if ${ac_cv_prog_OBJCPP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
       # Double quotes because OBJCPP needs to be expanded
@@ -6465,7 +6835,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
 $as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if test "${ac_cv_path_GREP+set}" = set; then :
+if ${ac_cv_path_GREP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if test -z "$GREP"; then
@@ -6528,7 +6898,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
 $as_echo_n "checking for egrep... " >&6; }
-if test "${ac_cv_path_EGREP+set}" = set; then :
+if ${ac_cv_path_EGREP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
@@ -6595,7 +6965,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
 $as_echo_n "checking for ANSI C header files... " >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then :
+if ${ac_cv_header_stdc+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -6758,7 +7128,7 @@
 	for ac_header in objc/objc.h
 do :
   ac_fn_objc_check_header_mongrel "$LINENO" "objc/objc.h" "ac_cv_header_objc_objc_h" "$ac_includes_default"
-if test "x$ac_cv_header_objc_objc_h" = x""yes; then :
+if test "x$ac_cv_header_objc_objc_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_OBJC_OBJC_H 1
 _ACEOF
@@ -6784,7 +7154,7 @@
 
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if linking libobjc requires pthreads" >&5
 $as_echo_n "checking if linking libobjc requires pthreads... " >&6; }
-	if test "${mp_cv_objc_req_pthread+set}" = set; then :
+	if ${mp_cv_objc_req_pthread+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -6884,7 +7254,7 @@
 	if test x"${with_objc_runtime}" = x || test x"${with_objc_runtime}" = x"apple"; then
 		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Apple Objective-C runtime" >&5
 $as_echo_n "checking for Apple Objective-C runtime... " >&6; }
-		if test "${mp_cv_objc_runtime_apple+set}" = set; then :
+		if ${mp_cv_objc_runtime_apple+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -6935,7 +7305,7 @@
 	if test x"${with_objc_runtime}" = x || test x"${with_objc_runtime}" = x"GNU"; then
 		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU Objective C runtime" >&5
 $as_echo_n "checking for GNU Objective C runtime... " >&6; }
-		if test "${mp_cv_objc_runtime_gnu+set}" = set; then :
+		if ${mp_cv_objc_runtime_gnu+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -7076,7 +7446,7 @@
 		APPLE_FOUNDATION_CFLAGS=""
 		APPLE_FOUNDATION_LIBS="-framework Foundation"
 
-		if test "${ac_cv_objc_foundation_apple+set}" = set; then :
+		if ${ac_cv_objc_foundation_apple+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -7154,7 +7524,7 @@
 			GNUSTEP_LIBS="-lgnustep-base"
 			fi
 
-			if test "${ac_cv_objc_foundation_gnustep+set}" = set; then :
+			if ${ac_cv_objc_foundation_gnustep+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -7261,7 +7631,7 @@
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CoreFoundation framework" >&5
 $as_echo_n "checking for CoreFoundation framework... " >&6; }
 
-	if test "${mp_cv_have_framework_corefoundation+set}" = set; then :
+	if ${mp_cv_have_framework_corefoundation+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -7321,7 +7691,7 @@
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SystemConfiguration framework" >&5
 $as_echo_n "checking for SystemConfiguration framework... " >&6; }
 
-	if test "${mp_cv_have_framework_systemconfiguration+set}" = set; then :
+	if ${mp_cv_have_framework_systemconfiguration+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -7381,7 +7751,7 @@
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for IOKit framework" >&5
 $as_echo_n "checking for IOKit framework... " >&6; }
 
-	if test "${mp_cv_have_framework_iokit+set}" = set; then :
+	if ${mp_cv_have_framework_iokit+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -7441,7 +7811,7 @@
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFNotificationCenterGetDarwinNotifyCenter" >&5
 $as_echo_n "checking for CFNotificationCenterGetDarwinNotifyCenter... " >&6; }
 
-	if test "${mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter+set}" = set; then :
+	if ${mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -7528,13 +7898,23 @@
 
 # Check for paths
 
-if test x$prefix = x/usr/local; then
-    as_fn_error $? "Installing MacPorts into /usr/local is not supported" "$LINENO" 5
+
+# Check whether --with-unsupported-prefix was given.
+if test "${with_unsupported_prefix+set}" = set; then :
+  withval=$with_unsupported_prefix; with_unsupported_prefix=$withval
+else
+  with_unsupported_prefix=no
 fi
 
+if test x$prefix = x/usr/local -o x$prefix = x/usr && test x$with_unsupported_prefix != xyes; then
+    as_fn_error $? "Installing MacPorts into $prefix is not supported. If \
+you understand this and wish to do so anyway, pass --with-unsupported-prefix \
+to configure." "$LINENO" 5
+fi
 
 
 
+
 # Check whether --with-ports-dir was given.
 if test "${with_ports_dir+set}" = set; then :
   withval=$with_ports_dir;  portsdir="$withval"
@@ -7612,10 +7992,18 @@
 $as_echo "$DSTGRP" >&6; }
 
 
+		# Set run-user to current user
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for macports user" >&5
+$as_echo_n "checking for macports user... " >&6; }
+		RUNUSR=`id -un`
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUNUSR" >&5
+$as_echo "$RUNUSR" >&6; }
+
+
 		# Set Tcl package directory to ~/Library/Tcl
 	    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl package directory" >&5
 $as_echo_n "checking for Tcl package directory... " >&6; }
-		ac_cv_c_tclpkgd="~$DSTUSR/Library/Tcl"
+		ac_cv_c_tclpkgd=`eval echo ~$DSTUSR/Library/Tcl`
 	    # Convert to a native path and substitute into the output files.
 	    PACKAGE_DIR_NATIVE=`${CYGPATH} ${ac_cv_c_tclpkgd}`
 	    TCL_PACKAGE_DIR=${PACKAGE_DIR_NATIVE}
@@ -7698,7 +8086,7 @@
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for macports user" >&5
 $as_echo_n "checking for macports user... " >&6; }
 	if test "x$RUNUSR" = "x" ; then
-	   RUNUSR=nobody
+	   RUNUSR=macports
 	fi
 
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUNUSR" >&5
@@ -7844,7 +8232,7 @@
   CPP=
 fi
 if test -z "$CPP"; then
-  if test "${ac_cv_prog_CPP+set}" = set; then :
+  if ${ac_cv_prog_CPP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
       # Double quotes because CPP needs to be expanded
@@ -7972,7 +8360,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
 $as_echo_n "checking for ANSI C header files... " >&6; }
-if test "${ac_cv_header_stdc+set}" = set; then :
+if ${ac_cv_header_stdc+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -8087,7 +8475,7 @@
   as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
-if eval "test \"\${$as_ac_Header+set}\"" = set; then :
+if eval \${$as_ac_Header+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -8127,7 +8515,7 @@
 if test $ac_header_dirent = dirent.h; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
 $as_echo_n "checking for library containing opendir... " >&6; }
-if test "${ac_cv_search_opendir+set}" = set; then :
+if ${ac_cv_search_opendir+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
@@ -8161,11 +8549,11 @@
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext
-  if test "${ac_cv_search_opendir+set}" = set; then :
+  if ${ac_cv_search_opendir+:} false; then :
   break
 fi
 done
-if test "${ac_cv_search_opendir+set}" = set; then :
+if ${ac_cv_search_opendir+:} false; then :
 
 else
   ac_cv_search_opendir=no
@@ -8184,7 +8572,7 @@
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
 $as_echo_n "checking for library containing opendir... " >&6; }
-if test "${ac_cv_search_opendir+set}" = set; then :
+if ${ac_cv_search_opendir+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
@@ -8218,11 +8606,11 @@
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext
-  if test "${ac_cv_search_opendir+set}" = set; then :
+  if ${ac_cv_search_opendir+:} false; then :
   break
 fi
 done
-if test "${ac_cv_search_opendir+set}" = set; then :
+if ${ac_cv_search_opendir+:} false; then :
 
 else
   ac_cv_search_opendir=no
@@ -8242,7 +8630,7 @@
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5
 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; }
-if test "${ac_cv_header_sys_wait_h+set}" = set; then :
+if ${ac_cv_header_sys_wait_h+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -8315,7 +8703,7 @@
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if readlink conforms to POSIX 1003.1a" >&5
 $as_echo_n "checking if readlink conforms to POSIX 1003.1a... " >&6; }
 
-	if test "${mp_cv_readlink_is_posix_1003_1a+set}" = set; then :
+	if ${mp_cv_readlink_is_posix_1003_1a+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -8365,17 +8753,17 @@
 
 # Check for md5 implementation
 ac_fn_c_check_header_mongrel "$LINENO" "CommonCrypto/CommonDigest.h" "ac_cv_header_CommonCrypto_CommonDigest_h" "$ac_includes_default"
-if test "x$ac_cv_header_CommonCrypto_CommonDigest_h" = x""yes; then :
+if test "x$ac_cv_header_CommonCrypto_CommonDigest_h" = xyes; then :
 
 $as_echo "#define HAVE_COMMONCRYPTO_COMMONDIGEST_H 1" >>confdefs.h
 
 else
 
 
-	# Check for libmd, which is prefered
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5Update in -lmd" >&5
-$as_echo_n "checking for MD5Update in -lmd... " >&6; }
-if test "${ac_cv_lib_md_MD5Update+set}" = set; then :
+	# Check for libmd from FreeBSD, which is preferred
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5File in -lmd" >&5
+$as_echo_n "checking for MD5File in -lmd... " >&6; }
+if ${ac_cv_lib_md_MD5File+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -8389,55 +8777,73 @@
 #ifdef __cplusplus
 extern "C"
 #endif
-char MD5Update ();
+char MD5File ();
 int
 main ()
 {
-return MD5Update ();
+return MD5File ();
   ;
   return 0;
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_md_MD5Update=yes
+  ac_cv_lib_md_MD5File=yes
 else
-  ac_cv_lib_md_MD5Update=no
+  ac_cv_lib_md_MD5File=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
 LIBS=$ac_check_lib_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_md_MD5Update" >&5
-$as_echo "$ac_cv_lib_md_MD5Update" >&6; }
-if test "x$ac_cv_lib_md_MD5Update" = x""yes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_md_MD5File" >&5
+$as_echo "$ac_cv_lib_md_MD5File" >&6; }
+if test "x$ac_cv_lib_md_MD5File" = xyes; then :
 
-		for ac_header in md5.h
+		for ac_header in md5.h sha.h
 do :
-  ac_fn_c_check_header_mongrel "$LINENO" "md5.h" "ac_cv_header_md5_h" "$ac_includes_default"
-if test "x$ac_cv_header_md5_h" = x""yes; then :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_MD5_H 1
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
 _ACEOF
 
 else
 
-			case $host_os in
-				darwin*)
-					{ $as_echo "$as_me:${as_lineno-$LINENO}: Please install the BSD SDK package from the Xcode Developer Tools CD." >&5
-$as_echo "$as_me: Please install the BSD SDK package from the Xcode Developer Tools CD." >&6;}
-					;;
-				*)
-					{ $as_echo "$as_me:${as_lineno-$LINENO}: Please install the libmd developer headers for your platform." >&5
-$as_echo "$as_me: Please install the libmd developer headers for your platform." >&6;}
-					;;
-			esac
-			as_fn_error $? "libmd was found, but md5.h is missing." "$LINENO" 5
+			as_fn_error $? "libmd was found, but md5.h or sha.h is missing." "$LINENO" 5
 
 fi
 
 done
 
+		ac_save_LIBS="$LIBS"
+		LIBS="-lmd $LIBS"
+		for ac_func in SHA1_File
+do :
+  ac_fn_c_check_func "$LINENO" "SHA1_File" "ac_cv_func_SHA1_File"
+if test "x$ac_cv_func_SHA1_File" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SHA1_FILE 1
+_ACEOF
 
+fi
+done
+
+		LIBS="$ac_save_LIBS"
+		for ac_header in ripemd.h sha256.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
 $as_echo "#define HAVE_LIBMD /**/" >>confdefs.h
 
 		MD5_LIBS="-lmd"
@@ -8445,8 +8851,99 @@
 fi
 
 	if test "x$MD5_LIBS" = "x"; then
-		as_fn_error $? "Neither CommonCrypto nor libmd were found. A working md5 implementation is required." "$LINENO" 5
+		# If libmd is not found, check for libcrypto from OpenSSL
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for MD5_Update in -lcrypto" >&5
+$as_echo_n "checking for MD5_Update in -lcrypto... " >&6; }
+if ${ac_cv_lib_crypto_MD5_Update+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcrypto  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char MD5_Update ();
+int
+main ()
+{
+return MD5_Update ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_crypto_MD5_Update=yes
+else
+  ac_cv_lib_crypto_MD5_Update=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_MD5_Update" >&5
+$as_echo "$ac_cv_lib_crypto_MD5_Update" >&6; }
+if test "x$ac_cv_lib_crypto_MD5_Update" = xyes; then :
+
+			for ac_header in openssl/md5.h openssl/sha.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+else
+
+				as_fn_error $? "libcrypto was found, but openssl/md5.h or openssl/sha.h is missing." "$LINENO" 5
+
+fi
+
+done
+
+			for ac_header in openssl/ripemd.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "openssl/ripemd.h" "ac_cv_header_openssl_ripemd_h" "$ac_includes_default"
+if test "x$ac_cv_header_openssl_ripemd_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_OPENSSL_RIPEMD_H 1
+_ACEOF
+
+fi
+
+done
+
+			ac_save_LIBS="$LIBS"
+			LIBS="-lcrypto $LIBS"
+			for ac_func in SHA256_Update
+do :
+  ac_fn_c_check_func "$LINENO" "SHA256_Update" "ac_cv_func_SHA256_Update"
+if test "x$ac_cv_func_SHA256_Update" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SHA256_UPDATE 1
+_ACEOF
+
+fi
+done
+
+			LIBS="$ac_save_LIBS"
+
+$as_echo "#define HAVE_LIBCRYPTO /**/" >>confdefs.h
+
+			MD5_LIBS="-lcrypto"
+
+fi
+
 	fi
+	if test "x$MD5_LIBS" = "x"; then
+		as_fn_error $? "Neither CommonCrypto, libmd nor libcrypto were found. A working md5 implementation is required." "$LINENO" 5
+	fi
 
 
 fi
@@ -8459,7 +8956,7 @@
   enableval=$enable_readline;
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5
 $as_echo_n "checking for readline in -lreadline... " >&6; }
-if test "${ac_cv_lib_readline_readline+set}" = set; then :
+if ${ac_cv_lib_readline_readline+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_check_lib_save_LIBS=$LIBS
@@ -8493,7 +8990,7 @@
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5
 $as_echo "$ac_cv_lib_readline_readline" >&6; }
-if test "x$ac_cv_lib_readline_readline" = x""yes; then :
+if test "x$ac_cv_lib_readline_readline" = xyes; then :
 
 				  READLINE_LIBS=-lreadline
 
@@ -8509,7 +9006,7 @@
 	#endif
 
 "
-if test "x$ac_cv_have_decl_rl_username_completion_function" = x""yes; then :
+if test "x$ac_cv_have_decl_rl_username_completion_function" = xyes; then :
   ac_have_decl=1
 else
   ac_have_decl=0
@@ -8525,7 +9022,7 @@
 	#endif
 
 "
-if test "x$ac_cv_have_decl_rl_filename_completion_function" = x""yes; then :
+if test "x$ac_cv_have_decl_rl_filename_completion_function" = xyes; then :
   ac_have_decl=1
 else
   ac_have_decl=0
@@ -8541,7 +9038,7 @@
 	#endif
 
 "
-if test "x$ac_cv_have_decl_rl_completion_matches" = x""yes; then :
+if test "x$ac_cv_have_decl_rl_completion_matches" = xyes; then :
   ac_have_decl=1
 else
   ac_have_decl=0
@@ -8557,7 +9054,7 @@
 	#endif
 
 "
-if test "x$ac_cv_have_decl_username_completion_function" = x""yes; then :
+if test "x$ac_cv_have_decl_username_completion_function" = xyes; then :
   ac_have_decl=1
 else
   ac_have_decl=0
@@ -8573,7 +9070,7 @@
 	#endif
 
 "
-if test "x$ac_cv_have_decl_filename_completion_function" = x""yes; then :
+if test "x$ac_cv_have_decl_filename_completion_function" = xyes; then :
   ac_have_decl=1
 else
   ac_have_decl=0
@@ -8589,7 +9086,7 @@
 	#endif
 
 "
-if test "x$ac_cv_have_decl_completion_matches" = x""yes; then :
+if test "x$ac_cv_have_decl_completion_matches" = xyes; then :
   ac_have_decl=1
 else
   ac_have_decl=0
@@ -8631,7 +9128,7 @@
 
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl configuration" >&5
 $as_echo_n "checking for Tcl configuration... " >&6; }
-	if test "${ac_cv_c_tclconfig+set}" = set; then :
+	if ${ac_cv_c_tclconfig+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -8779,7 +9276,7 @@
 	    as_fn_error $? "${with_tclinclude} directory does not contain Tcl public header file tcl.h" "$LINENO" 5
 	fi
     else
-	if test "${ac_cv_c_tclh+set}" = set; then :
+	if ${ac_cv_c_tclh+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -8837,7 +9334,7 @@
 set dummy tclsh${TCL_VERSION}-threads tclsh${TCL_VERSION} tclsh; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_TCLSH+set}" = set; then :
+if ${ac_cv_path_TCLSH+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $TCLSH in
@@ -8880,7 +9377,7 @@
 set dummy tclsh tclsh${TCL_VERSION}; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_TCLSH+set}" = set; then :
+if ${ac_cv_path_TCLSH+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $TCLSH in
@@ -8942,7 +9439,7 @@
     if test x"${with_tclpackagedir}" != x ; then
 	ac_cv_c_tclpkgd=${with_tclpackagedir}
     else
-	if test "${ac_cv_c_tclpkgd+set}" = set; then :
+	if ${ac_cv_c_tclpkgd+:} false; then :
   $as_echo_n "(cached) " >&6
 else
 
@@ -8969,7 +9466,7 @@
 			        fi
 			    fi
 			elif test "$path" = "~/Library/Tcl"; then
-			    ac_cv_c_tclpkgd="~$DSTUSR/Library/Tcl"
+			    ac_cv_c_tclpkgd=`eval echo ~$DSTUSR/Library/Tcl`
 			    break
 			fi
 			done
@@ -9034,7 +9531,7 @@
 set dummy curl-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CURL_CONFIG+set}" = set; then :
+if ${ac_cv_path_CURL_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $CURL_CONFIG in
@@ -9075,7 +9572,7 @@
 set dummy curl-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_path_CURL_CONFIG+set}" = set; then :
+if ${ac_cv_path_CURL_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $CURL_CONFIG in
@@ -9147,7 +9644,7 @@
 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; }
-if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+if ${ac_cv_path_PKG_CONFIG+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   case $PKG_CONFIG in
@@ -9186,7 +9683,7 @@
 		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" = x""yes; then :
+if test "x$ac_cv_header_sqlite3_h" = xyes; then :
 
 else
   as_fn_error $? "cannot find sqlite3 header" "$LINENO" 5
@@ -9215,7 +9712,7 @@
     for ac_header in sqlite3ext.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "sqlite3ext.h" "ac_cv_header_sqlite3ext_h" "$ac_includes_default"
-if test "x$ac_cv_header_sqlite3ext_h" = x""yes; then :
+if test "x$ac_cv_header_sqlite3ext_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
 #define HAVE_SQLITE3EXT_H 1
 _ACEOF
@@ -9253,7 +9750,7 @@
 
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Tcl sqlite3 location" >&5
 $as_echo_n "checking for Tcl sqlite3 location... " >&6; }
-if test "${mp_cv_sqlite3_dir+set}" = set; then :
+if ${mp_cv_sqlite3_dir+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   mp_cv_sqlite3_dir=
@@ -9267,6 +9764,85 @@
 
 
 
+
+
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SQLite >= 3003011" >&5
+$as_echo_n "checking for SQLite >= 3003011... " >&6; }
+
+	mp_check_sqlite_version_cppflags_save=$CPPFLAGS
+	CPPFLAGS="$CPPFLAGS $CFLAGS_SQLITE3"
+
+	if ${mp_cv_sqlite_version_defined+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+		cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+					#include <sqlite3.h>
+					#ifndef SQLITE_VERSION_NUMBER
+					#  error "SQLITE_VERSION_NUMBER undefined"
+					#endif
+
+
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  mp_cv_sqlite_version_defined="yes"
+else
+  as_fn_error $? "\"SQLITE_VERSION_NUMBER undefined or sqlite3.h not found\"" "$LINENO" 5
+
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+fi
+
+
+	if test x"${mp_cv_sqlite_version_defined}" = "xno"; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: SQLite version not found" >&5
+$as_echo "SQLite version not found" >&6; }
+		mp_sqlite_version_ge_3003011="no"
+	else
+		if ${mp_cv_sqlite_version_ge_3003011+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+			cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+						#include <sqlite3.h>
+						#if (SQLITE_VERSION_NUMBER >= 3003011)
+						/* Everything is fine */
+						#else
+						#  error "SQLite version too old"
+						#endif
+
+
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  mp_cv_sqlite_version_ge_3003011="yes"
+else
+  mp_cv_sqlite_version_ge_3003011="no"
+
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+fi
+
+
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${mp_cv_sqlite_version_ge_3003011}" >&5
+$as_echo "${mp_cv_sqlite_version_ge_3003011}" >&6; }
+		mp_sqlite_version_ge_3003011=${mp_cv_sqlite_version_ge_3003011}
+	fi
+
+	CPPFLAGS=$mp_check_sqlite_version_cppflags_save
+
+if test "x${mp_sqlite_version_ge_3003011}" = "xno"; then
+
+$as_echo "#define sqlite3_prepare_v2 sqlite3_prepare" >>confdefs.h
+
+fi
+
 # Determine if we need to install some bundled packages
 OUR_INCLUDED_PACKAGES=
 
@@ -9413,7 +9989,7 @@
 
 
 # Output
-ac_config_files="$ac_config_files Doxyfile Makefile Mk/macports.autoconf.mk doc/prefix.mtree doc/macosx.mtree doc/macports.conf doc/pubkeys.conf portmgr/freebsd/Makefile src/Makefile src/macports1.0/macports_autoconf.tcl src/port1.0/port_autoconf.tcl src/registry2.0/registry_autoconf.tcl src/programs/Makefile src/macports1.0/macports_fastload.tcl setupenv.bash"
+ac_config_files="$ac_config_files Doxyfile Makefile Mk/macports.autoconf.mk doc/base.mtree doc/prefix.mtree doc/macosx.mtree doc/macports.conf doc/pubkeys.conf portmgr/freebsd/Makefile src/Makefile src/machista1.0/Makefile src/macports1.0/macports_autoconf.tcl src/port1.0/port_autoconf.tcl src/registry2.0/registry_autoconf.tcl src/programs/Makefile src/macports1.0/macports_fastload.tcl setupenv.bash"
 
 
 ac_config_files="$ac_config_files src/pkg_mkindex.sh"
@@ -9483,10 +10059,21 @@
      :end' >>confcache
 if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
   if test -w "$cache_file"; then
-    test "x$cache_file" != "x/dev/null" &&
+    if test "x$cache_file" != "x/dev/null"; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
 $as_echo "$as_me: updating cache $cache_file" >&6;}
-    cat confcache >$cache_file
+      if test ! -f "$cache_file" || test -h "$cache_file"; then
+	cat confcache >"$cache_file"
+      else
+        case $cache_file in #(
+        */* | ?:*)
+	  mv -f confcache "$cache_file"$$ &&
+	  mv -f "$cache_file"$$ "$cache_file" ;; #(
+        *)
+	  mv -f confcache "$cache_file" ;;
+	esac
+      fi
+    fi
   else
     { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
@@ -9518,7 +10105,7 @@
 
 
 
-: ${CONFIG_STATUS=./config.status}
+: "${CONFIG_STATUS=./config.status}"
 ac_write_fail=0
 ac_clean_files_save=$ac_clean_files
 ac_clean_files="$ac_clean_files $CONFIG_STATUS"
@@ -9619,6 +10206,7 @@
 IFS=" ""	$as_nl"
 
 # Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
 case $0 in #((
   *[\\/]* ) as_myself=$0 ;;
   *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
@@ -9925,8 +10513,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 1.9.99, which was
-generated by GNU Autoconf 2.67.  Invocation command line was
+This file was extended by MacPorts $as_me 2.0.99, which was
+generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
   CONFIG_HEADERS  = $CONFIG_HEADERS
@@ -9987,8 +10575,8 @@
 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 1.9.99
-configured by $0, generated by GNU Autoconf 2.67,
+MacPorts config.status 2.0.99
+configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -10114,12 +10702,14 @@
     "Doxyfile") CONFIG_FILES="$CONFIG_FILES Doxyfile" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "Mk/macports.autoconf.mk") CONFIG_FILES="$CONFIG_FILES Mk/macports.autoconf.mk" ;;
+    "doc/base.mtree") CONFIG_FILES="$CONFIG_FILES doc/base.mtree" ;;
     "doc/prefix.mtree") CONFIG_FILES="$CONFIG_FILES doc/prefix.mtree" ;;
     "doc/macosx.mtree") CONFIG_FILES="$CONFIG_FILES doc/macosx.mtree" ;;
     "doc/macports.conf") CONFIG_FILES="$CONFIG_FILES doc/macports.conf" ;;
     "doc/pubkeys.conf") CONFIG_FILES="$CONFIG_FILES doc/pubkeys.conf" ;;
     "portmgr/freebsd/Makefile") CONFIG_FILES="$CONFIG_FILES portmgr/freebsd/Makefile" ;;
     "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
+    "src/machista1.0/Makefile") CONFIG_FILES="$CONFIG_FILES src/machista1.0/Makefile" ;;
     "src/macports1.0/macports_autoconf.tcl") CONFIG_FILES="$CONFIG_FILES src/macports1.0/macports_autoconf.tcl" ;;
     "src/port1.0/port_autoconf.tcl") CONFIG_FILES="$CONFIG_FILES src/port1.0/port_autoconf.tcl" ;;
     "src/registry2.0/registry_autoconf.tcl") CONFIG_FILES="$CONFIG_FILES src/registry2.0/registry_autoconf.tcl" ;;
@@ -10150,9 +10740,10 @@
 # after its creation but before its name has been assigned to `$tmp'.
 $debug ||
 {
-  tmp=
+  tmp= ac_tmp=
   trap 'exit_status=$?
-  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+  : "${ac_tmp:=$tmp}"
+  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
 ' 0
   trap 'as_fn_exit 1' 1 2 13 15
 }
@@ -10160,12 +10751,13 @@
 
 {
   tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
-  test -n "$tmp" && test -d "$tmp"
+  test -d "$tmp"
 }  ||
 {
   tmp=./conf$$-$RANDOM
   (umask 077 && mkdir "$tmp")
 } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
 
 # Set up the scripts for CONFIG_FILES section.
 # No need to generate them if there are no CONFIG_FILES.
@@ -10187,7 +10779,7 @@
   ac_cs_awk_cr=$ac_cr
 fi
 
-echo 'BEGIN {' >"$tmp/subs1.awk" &&
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
 _ACEOF
 
 
@@ -10215,7 +10807,7 @@
 rm -f conf$$subs.sh
 
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
 _ACEOF
 sed -n '
 h
@@ -10263,7 +10855,7 @@
 rm -f conf$$subs.awk
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 _ACAWK
-cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
   for (key in S) S_is_set[key] = 1
   FS = ""
 
@@ -10295,7 +10887,7 @@
   sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
 else
   cat
-fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
   || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
 _ACEOF
 
@@ -10329,7 +10921,7 @@
 # No need to generate them if there are no CONFIG_HEADERS.
 # This happens for instance with `./config.status Makefile'.
 if test -n "$CONFIG_HEADERS"; then
-cat >"$tmp/defines.awk" <<\_ACAWK ||
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
 BEGIN {
 _ACEOF
 
@@ -10341,8 +10933,8 @@
 # handling of long lines.
 ac_delim='%!_!# '
 for ac_last_try in false false :; do
-  ac_t=`sed -n "/$ac_delim/p" confdefs.h`
-  if test -z "$ac_t"; then
+  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_tt"; then
     break
   elif $ac_last_try; then
     as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
@@ -10462,7 +11054,7 @@
     for ac_f
     do
       case $ac_f in
-      -) ac_f="$tmp/stdin";;
+      -) ac_f="$ac_tmp/stdin";;
       *) # Look for the file first in the build tree, then in the source tree
 	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
 	 # because $ac_f cannot contain `:'.
@@ -10497,7 +11089,7 @@
     esac
 
     case $ac_tag in
-    *:-:* | *:-) cat >"$tmp/stdin" \
+    *:-:* | *:-) cat >"$ac_tmp/stdin" \
       || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
     esac
     ;;
@@ -10628,21 +11220,22 @@
 s&@INSTALL@&$ac_INSTALL&;t t
 $ac_datarootdir_hack
 "
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
-  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
-  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
+      "$ac_tmp/out"`; test -z "$ac_out"; } &&
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
 which seems to be undefined.  Please make sure it is defined" >&5
 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
 which seems to be undefined.  Please make sure it is defined" >&2;}
 
-  rm -f "$tmp/stdin"
+  rm -f "$ac_tmp/stdin"
   case $ac_file in
-  -) cat "$tmp/out" && rm -f "$tmp/out";;
-  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
   esac \
   || as_fn_error $? "could not create $ac_file" "$LINENO" 5
  ;;
@@ -10653,20 +11246,20 @@
   if test x"$ac_file" != x-; then
     {
       $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
-    } >"$tmp/config.h" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+    } >"$ac_tmp/config.h" \
       || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
       { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
 $as_echo "$as_me: $ac_file is unchanged" >&6;}
     else
       rm -f "$ac_file"
-      mv "$tmp/config.h" "$ac_file" \
+      mv "$ac_tmp/config.h" "$ac_file" \
 	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
     fi
   else
     $as_echo "/* $configure_input  */" \
-      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
       || as_fn_error $? "could not create -" "$LINENO" 5
   fi
  ;;

Modified: branches/new-help-system/base/configure.ac
===================================================================
--- branches/new-help-system/base/configure.ac	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/configure.ac	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 dnl $Id$
 AC_PREREQ(2.63)
-AC_DEFUN([MACPORTS_VERSION_MACRO], [esyscmd(cat config/macports_version | tr -d '\n')])
+AC_DEFUN([MACPORTS_VERSION_MACRO], [esyscmd(<config/macports_version tr -d '\n')])
 AC_INIT([MacPorts],MACPORTS_VERSION_MACRO,[macports-dev at lists.macosforge.org],[macports])
 AC_CONFIG_SRCDIR([src/pextlib1.0/Pextlib.c])
 AC_CONFIG_HEADERS([src/config.h])
@@ -32,11 +32,11 @@
     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-1]])
+  10.4.[[0-9]]|10.4.10|10.5.[[0-7]]|10.6.[[0-7]])
     AC_MSG_WARN([This version of Mac OS X is out of date])
     AC_MSG_WARN([Please run Software Update to update it])
     ;;
-  10.4*|10.5*|10.6*)
+  10.4*|10.5*|10.6*|10.7*)
     dnl Supported version
     ;;
   *)
@@ -73,7 +73,7 @@
     AC_MSG_WARN([This version of Xcode Tools is out of date])
     AC_MSG_WARN([Please consider upgrading as some ports fail compiling])
     ;;
-  2.*|3.*)
+  2.*|3.*|4.*)
     dnl Supported version
     ;;
   *)
@@ -82,73 +82,88 @@
 
 # Checks for programs.
 AC_PROG_CC
-AC_PROG_OBJC
 AC_PROG_INSTALL
+AC_PROG_LN_S
 AC_PROG_MAKE_SET
-AC_PROG_LN_S
-AC_PATH_PROG(MTREE, [mtree], [], [$PATH:/usr/sbin])
+AC_PROG_OBJC
+
+AC_PATH_PROGS(BSDMAKE, [bsdmake pmake], [])
+AC_PATH_PROG(BZIP2, [bzip2], [])
+AC_PATH_PROG(BZR, [bzr], [])
 AC_PATH_PROG(CHOWN, [chown], [], [$PATH:/usr/sbin])
 AC_PATH_PROG(CP, [cp], [])
 AC_PATH_PROG(CPIO, [cpio], [])
+AC_PATH_PROG(CVS, [cvs], [])
 AC_PATH_PROG(DIFF, [diff], [])
 AC_PATH_PROG(DSCL, [dscl], [])
+AC_PATH_PROG(DSEDITGROUP, [dseditgroup], [])
 AC_PATH_PROG(FILE, [file], [])
-AC_PATH_PROG(BZR, [bzr], [])
-AC_PATH_PROG(CVS, [cvs], [])
-AC_PATH_PROG(SVN, [svn], [])
 AC_PATH_PROG(GIT, [git], [])
+AC_PATH_PROGS(GNUMAKE, [gnumake gmake], [], [$PATH:/usr/local/bin])
+AC_PATH_PROGS(GNUPATCH, [gnupatch gpatch], [], [$PATH:/usr/local/bin])
+AC_PATH_PROGS(GNUTAR, [gnutar gtar], [], [$PATH:/usr/local/bin])
+AC_PATH_PROG(GZIP, [gzip], [])
+AC_PATH_PROG(HDIUTIL, [hdiutil], [])
 AC_PATH_PROG(HG, [hg], [])
-AC_PATH_PROG(GZIP, [gzip], [])
+AC_PATH_PROG(LAUNCHCTL, [launchctl], [])
 AC_PATH_PROG(LIPO, [lipo], [])
+AC_PATH_PROG(LSBOM, [lsbom], [])
+AC_PATH_PROG(LZMA, [lzma], [])
+AC_PATH_PROG(MAKE, [make])
+AC_PATH_PROG(MDFIND, [mdfind], [])
+AC_PATH_PROG(MDLS, [mdls], [])
+AC_PATH_PROG(MKBOM, [mkbom], [])
+AC_PATH_PROG(MTREE, [mtree], [], [$PATH:/usr/sbin])
+AC_PATH_PROG(OPEN, [open], [])
+AC_PATH_PROG(OPENSSL, [openssl], [])
 AC_PATH_PROG(PATCH, [patch], [])
+AC_PATH_PROG(PAX, [pax], [])
 AC_PATH_PROG(RMDIR, [rmdir], [])
 AC_PATH_PROG(RSYNC, [rsync], [])
-AC_PATH_PROG(OPENSSL, [openssl], [])
 AC_PATH_PROG(SED, [sed])
+AC_PATH_PROG(SVN, [svn], [])
+AC_PATH_PROG(SWIG, [swig], [], [$PATH:/usr/local/bin])
 AC_PATH_PROG(TAR, [tar])
 AC_PATH_PROG(UNZIP, [unzip])
+AC_PATH_PROG(XAR, [xar], [])
+AC_PATH_PROG(XCODEBUILD, [xcodebuild], [])
+AC_PATH_PROG(XCRUN, [xcrun], [])
+AC_PATH_PROG(XZ, [xz], [])
 AC_PATH_PROG(ZIP, [zip])
-AC_PATH_PROGS(BSDMAKE, [bsdmake pmake], [])
-AC_PATH_PROG(MAKE, [make])
-AC_PATH_PROG(HDIUTIL, [hdiutil], [])
+
 AC_CHECK_PROG(HAVE_LAUNCHD, [launchd], [yes], [])
-AC_PATH_PROG(LAUNCHCTL, [launchctl], [])
-AC_PATH_PROG(XCODEBUILD, [xcodebuild], [])
-AC_PATH_PROGS(GNUTAR, [gnutar gtar], [], [$PATH:/usr/local/bin])
-AC_PATH_PROGS(GNUMAKE, [gnumake gmake], [], [$PATH:/usr/local/bin])
-AC_PATH_PROGS(GNUPATCH, [gnupatch gpatch], [], [$PATH:/usr/local/bin])
-AC_PATH_PROG(BZIP2, [bzip2], [])
-AC_PATH_PROG(LSBOM, [lsbom], [])
-AC_PATH_PROG(MKBOM, [mkbom], [])
-AC_PATH_PROG(PAX, [pax], [])
-AC_PATH_PROG(XAR, [xar], [])
-AC_PATH_PROG(OPEN, [open], [])
 
 # Define some precious variables allowing user to override PATH for some programs
+AC_ARG_VAR(BSDMAKE, [path to bsdmake/pmake command])
+AC_ARG_VAR(BZIP2, [path to bzip2 command])
+AC_ARG_VAR(CVS, [path to cvs command])
+AC_ARG_VAR(GNUMAKE, [path to gnumake command])
+AC_ARG_VAR(GNUTAR, [path to gnutar command])
+AC_ARG_VAR(LZMA, [path to lzma command])
+AC_ARG_VAR(MAKE, [path to make command])
 AC_ARG_VAR(MTREE, [path to mtree command])
-AC_ARG_VAR(CVS, [path to cvs command])
-AC_ARG_VAR(SVN, [path to svn command])
+AC_ARG_VAR(OPEN, [path to open command])
 AC_ARG_VAR(OPENSSL, [path to openssl command])
 AC_ARG_VAR(RSYNC, [path to rsync command])
 AC_ARG_VAR(SED, [path to sed command])
+AC_ARG_VAR(SVN, [path to svn command])
+AC_ARG_VAR(SWIG, [path to swig command])
 AC_ARG_VAR(TAR, [path to tar command])
-AC_ARG_VAR(MAKE, [path to make command])
-AC_ARG_VAR(GNUTAR, [path to gnutar command])
-AC_ARG_VAR(BSDMAKE, [path to bsdmake/pmake command])
-AC_ARG_VAR(GNUMAKE, [path to gnumake command])
-AC_ARG_VAR(BZIP2, [path to bzip2 command])
 AC_ARG_VAR(XAR, [path to xar command])
-AC_ARG_VAR(OPEN, [path to open command])
+AC_ARG_VAR(XZ, [path to xz command])
 
 MP_SED_EXTENDED_REGEXP
+MP_TAR_FAST_READ
 MP_TAR_NO_SAME_OWNER
 MP_PATCH_GNU_VERSION
 
 # Quiche eaters options.
 if test x$GCC = xyes; then
-	CFLAGS_QUICHEEATERS='-W -Wall -pedantic'
+	CFLAGS_QUICHEEATERS='-Wextra -Wall'
+	CFLAGS_PEDANTIC='-pedantic'
 fi
 AC_SUBST(CFLAGS_QUICHEEATERS)
+AC_SUBST(CFLAGS_PEDANTIC)
 MP_WERROR
 
 MP_COMPILER_ATTRIBUTE_UNUSED
@@ -168,8 +183,16 @@
 
 # Check for paths
 AC_PREFIX_DEFAULT(/opt/local)
-if test x$prefix = x/usr/local; then
-    AC_MSG_ERROR([Installing MacPorts into /usr/local is not supported])
+AC_ARG_WITH(
+		unsupported-prefix,
+		AS_HELP_STRING([--with-unsupported-prefix],
+		[Acknowledge that you accept the consequences of using an unsupported prefix.]),
+		[with_unsupported_prefix=$withval],
+		[with_unsupported_prefix=no])
+if test x$prefix = x/usr/local -o x$prefix = x/usr && test x$with_unsupported_prefix != xyes; then
+    AC_MSG_ERROR([Installing MacPorts into $prefix is not supported. If \
+you understand this and wish to do so anyway, pass --with-unsupported-prefix \
+to configure.])
 fi
 MP_PATH_PORTSDIR([$PORTS_DIR_DEFAULT])
 MP_PATH_MPCONFIGDIR
@@ -212,7 +235,7 @@
 [
 	AC_CHECK_LIB([readline], [readline], [
 				  READLINE_LIBS=-lreadline
-				  AC_DEFINE([HAVE_LIBREADLINE], [1], [Define to 1 if you have the `readline' library (-lreadline).])
+				  AC_DEFINE([HAVE_LIBREADLINE], [1], [Define to 1 if you have the 'readline' library (-lreadline).])
 				  ])
 	AC_CHECK_DECLS([rl_username_completion_function,rl_filename_completion_function,rl_completion_matches,username_completion_function,filename_completion_function,completion_matches], [], [],
 	[
@@ -252,6 +275,11 @@
 ## sqlite3
 MP_SQLITE3_FLAGS
 
+MP_CHECK_SQLITE_VERSION(3003011)
+if test "x${mp_sqlite_version_ge_3003011}" = "xno"; then
+	AC_DEFINE([sqlite3_prepare_v2], [sqlite3_prepare], [define sqlite3_prepare to sqlite_prepare_v2 if the latter is not available])
+fi
+
 # Determine if we need to install some bundled packages
 OUR_INCLUDED_PACKAGES=
 
@@ -345,12 +373,14 @@
 	Doxyfile
 	Makefile
 	Mk/macports.autoconf.mk
+	doc/base.mtree
 	doc/prefix.mtree
 	doc/macosx.mtree
 	doc/macports.conf
 	doc/pubkeys.conf
 	portmgr/freebsd/Makefile
 	src/Makefile
+	src/machista1.0/Makefile
 	src/macports1.0/macports_autoconf.tcl
 	src/port1.0/port_autoconf.tcl
 	src/registry2.0/registry_autoconf.tcl


Property changes on: branches/new-help-system/base/doc
___________________________________________________________________
Modified: svn:ignore
   - macports.conf
pubkeys.conf
prefix.mtree
macosx.mtree
asciidoc.conf
*[0-9].gz
*[0-9].xml
*[0-9].html
.dep

   + macports.conf
pubkeys.conf
base.mtree
prefix.mtree
macosx.mtree
asciidoc.conf
*[0-9].gz
*[0-9].xml
*[0-9].html
.dep


Modified: branches/new-help-system/base/doc/Makefile
===================================================================
--- branches/new-help-system/base/doc/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/doc/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -51,7 +51,7 @@
 test:
 
 distclean: clean
-	rm -f macports.conf macosx.mtree prefix.mtree pubkeys.conf
+	rm -f macports.conf base.mtree macosx.mtree prefix.mtree pubkeys.conf
 
 %.1.gz: %.1
 	gzip -c $^ > $@
@@ -81,7 +81,8 @@
 	$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} ${INSTALLDIR}
 	$(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} ${DESTDIR}${mpconfigdir}
 
-	cat prefix.mtree | $(MTREE) -U -e -p ${INSTALLDIR} > /dev/null
+	< 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
@@ -104,6 +105,7 @@
 	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/
 	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 644 prefix.mtree ${INSTALLDIR}/share/macports/install/
 	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 644 macosx.mtree ${INSTALLDIR}/share/macports/install/
 	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 port.1.gz ${INSTALLDIR}/share/man/man1

Copied: branches/new-help-system/base/doc/base.mtree.in (from rev 90355, trunk/base/doc/base.mtree.in)
===================================================================
--- branches/new-help-system/base/doc/base.mtree.in	                        (rev 0)
+++ branches/new-help-system/base/doc/base.mtree.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,28 @@
+# $Id$
+#
+# MacPorts filesystem hierarchy, for internal use only. Changes to this file will not stick across installations.
+#
+
+/set type=dir uname=@DSTUSR@ gname=@DSTGRP@ mode=@DSTMODE@
+.
+    var
+        macports
+            build
+            ..
+            distfiles
+            ..
+            home
+                Library
+                    Preferences
+                    ..
+                ..
+            ..
+            logs
+            ..
+            registry
+            ..
+            software
+            ..
+        ..
+    ..
+..

Modified: branches/new-help-system/base/doc/macports.conf.in
===================================================================
--- branches/new-help-system/base/doc/macports.conf.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/doc/macports.conf.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -10,13 +10,6 @@
 # Where to store MacPorts working data
 portdbpath		@localstatedir_expanded@/macports
 
-# Type of storage to use for the port registry information, "flat" or "sqlite"
-# default is sqlite, flat is legacy
-#portdbformat		sqlite
-
-# Type of installation to do for ports, "direct" or "image".  See macports.conf(5) and online documentation.
-#portinstalltype		image
-
 # 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.
 #binpath		@prefix_expanded@/bin:@prefix_expanded@/sbin:/bin:/sbin:/usr/bin:/usr/sbin
@@ -24,6 +17,14 @@
 # Directory containing Xcode Tools (default is to ask xcode-select)
 #developer_dir       @DEVELOPER_DIR@
 
+# Path to PackageMaker.app
+# It may be necessary to set this with Xcode >= 4.3, as that version
+# requires PackageMaker to be installed manually from the Auxiliary Tools for
+# Xcode disk image. The default is /Applications/PackageMaker.app with Xcode
+# 4.3 and ${developer_dir}/Applications/Utilities/PackageMaker.app with older
+# versions.
+#packagemaker_path /Applications/PackageMaker.app
+
 # Directory containing Applications from ports.
 applications_dir	@MPAPPLICATIONSDIR@
 
@@ -36,27 +37,20 @@
 # Where to find global variants definition file (optional)
 variants_conf		@MPCONFIGDIR_EXPANDED@/variants.conf
 
-# Create and use binary archive packages for installation/reinstallation ease
-#portarchivemode		no
+# 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
 
-# Where to store/retrieve ports binary archive files
-#portarchivepath		@localstatedir_expanded@/macports/packages
-
-# Type of binary archive packages to create when using archive mode
+# Type of archives to use for port images
 #
-# Note: Multiple types ARE allowed and must be a colon or comma
-# separated list of choices (NO spaces). Use of multiple types will
-# cause archive creation to build all the specified types in one step.
-# Unarchive uses multiple types as a search list to locate the archive,
-# first archive to match one of the specified types in order is used.
-#
-# Supported types: tgz (default), tar, tbz, tbz2, tlz, txz, xar, zip, cpgz, cpio
-#portarchivetype		tgz
+# Supported types: tgz, tar, tbz, tbz2 (default), tlz, txz, xar, zip, cpgz, cpio
+#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			@host_cpu@
+#build_arch			i386
 
 # CPU architectures to use for Universal Binaries (+universal variant)
 universal_archs		@UNIVERSAL_ARCHS@
@@ -64,6 +58,13 @@
 # Use ccache (C/C++ compiler cache) - see http://ccache.samba.org/
 #configureccache		no
 
+# Location where ccache stores its files
+#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
+
 # Use distcc (distributed compiler) - see http://distcc.samba.org/
 #configuredistcc		no
 
@@ -90,14 +91,16 @@
 
 # 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.
-# Known mirrors at time of writing (see http://trac.macports.org/wiki/Mirrors
+# Known mirrors at time of writing (see https://trac.macports.org/wiki/Mirrors
 # for the current list):
 #   rsync.macports.org        - California, USA (master)
 #   trd.no.rsync.macports.org - Trondheim, Norway
 #rsync_server		rsync.macports.org
 
 # Rsync directory from which to pull the base/ component (infrastructure) of MacPorts
-#rsync_dir			release/base/
+# 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 options
 #rsync_options		-rtzv --delete-after
@@ -111,6 +114,12 @@
 # are installed.
 #startupitem_type	default
 
+# Option to install symlinks into /Library/LaunchAgents or /Library/LaunchDaemons
+# 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
+
 # Extra environment variables to keep. Any variables listed here are added
 # to the list of variables that are not removed from the environment used
 # while processing ports. As with binpath, setting extra_env is intended for
@@ -141,3 +150,10 @@
 # hosts not to go through the proxy (comma-separated, applies to HTTP, HTTPS,
 # and FTP, but not rsync):
 #proxy_skip            internal1, internal2, internal3
+
+# 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

Modified: branches/new-help-system/base/doc/portfile.7
===================================================================
--- branches/new-help-system/base/doc/portfile.7	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/doc/portfile.7	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,6 +1,7 @@
 .\" portfile.7
 .\"
-.\" Copyright (c) 2002 Apple Computer, Inc.
+.\" Copyright (c) 2004-2011 The MacPorts Project
+.\" Copyright (c) 2002-2003 Apple Inc.
 .\" All rights reserved.
 .\"
 .\" Redistribution and use in source and binary forms, with or without
@@ -11,7 +12,7 @@
 .\" 2. Redistributions in binary form must reproduce the above copyright
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of Apple Computer, Inc. nor the names of its
+.\" 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.
 .\"
@@ -83,9 +84,14 @@
 If a port's version numbering changes such that a newer version looks
 older than the previous version, the
 .Ic epoch
-should be increased. Often the
+should be increased. Some
+.Nm Portfile
+authors have used large
 .Ic epoch
-is formatted like a date.
+values that look like a date, but there is no reason to do so. The
+.Ic epoch
+is simply an unsigned integer, and the only requirement is that it never be
+decreased.
 .br
 .Sy Type:
 .Em optional
@@ -94,7 +100,7 @@
 .Em 0
 .br
 .Sy Example:
-.Dl epoch 20041231
+.Dl epoch 1
 .It Ic description
 One line description of the software and what it does.  To appear in the
 description, brackets and semi-colons need to be escaped with a backslash (i.e.
@@ -200,6 +206,28 @@
 .br
 .Sy Example:
 .Dl platforms darwin
+.It Ic supported_archs
+The CPU architectures for which this port can be built. Archs currently
+supported by Mac OS X are: i386, ppc, ppc64, x86_64. If this option is not set,
+it is assumed that the port can build for all archs. If a port does not install
+any architecture-specific files, use the special value noarch.
+.br
+If the building architecture isn't among supported_archs, port fails with an
+error message except when building on x86_64 (or ppc64) and supported_archs
+contains i386 (or ppc). In this case, the port will be built in 32-bit mode.
+.br
+.Sy Type:
+.Em optional
+.br
+.Sy Values:
+.Em i386 x86_64 ppc ppc64 noarch
+.br
+.Sy Default:
+.Em i386 x86_64 ppc ppc64
+.br
+.Sy Examples:
+.Dl supported_archs i386 x86_64
+.Dl supported_archs noarch
 .It Ic homepage
 Project homepage for the port.
 .br
@@ -256,7 +284,7 @@
 .Ic distfiles .
 The checksum
 .Ar type
-can currently be md5, rmd160 or sha1. The
+can currently be md5, sha1, rmd160 or sha256. The
 .Ar filename
 can be omitted if there is only one distfile.
 .br
@@ -300,10 +328,10 @@
 .Em optional
 .br
 .Sy Default:
-.Em no
+.Em yes
 .br
 .Sy Example:
-.Dl use_parallel_build yes
+.Dl use_parallel_build no
 .It Ic use_automake
 If set to yes, run the
 .Cm automake
@@ -382,6 +410,62 @@
 .br
 .Sy Example:
 .Dl replaced_by xorg-renderproto
+.It Ic add_users
+Consists of a list of usernames and settings. At appropriate times during the
+port installation process, a user will be created for each username with the
+corresponding settings. Settings are of the form name=value. A setting
+applies to the username that appeared most recently before it in the list.
+.sp
+Applicable options are: group, gid (may be used instead of group), passwd,
+realname, home, and shell.
+.sp
+.Sy Type:
+.Em optional
+.br
+.Sy Default:
+.Em none (empty)
+.br
+.Sy Example:
+.Dl add_users squid group=squid realname=Squid\e Proxy home=${prefix}/var/squid
+.sp
+.Dl add_users user1 group=mygroup user2 group=mygroup
+.It Ic installs_libs
+By default, it is assumed that ports may install libraries or headers that can
+be incorporated into their dependents. If this is not the case, set
+.Cm installs_libs
+to
+.Em no .
+This means that this port's dependents need not check that it is installed
+for the same architectures as them; that it is permissible to distribute
+binaries of the dependents even if their licenses conflict with the license
+of this port; and that updates to this port can never result in broken dynamic
+linking in its dependents.
+.br
+.Sy Type:
+.Em optional
+.br
+.Sy Default:
+.Em none
+.br
+.Sy Example:
+.Dl installs_libs no
+.It Ic license_noconflict
+By default, it is assumed that ports may use libraries or headers from their
+dependencies and thus form a derivative work. A dependency with an
+incompatible license thus prevents the port from being distributed in binary
+form. If a dependency with an incompatible license is not used in such a way
+that a derivative work is formed, or should not prevent binary distribution
+for any other reason, add its name to this list.
+.br
+.Sy Type:
+.Em optional
+.br
+.Sy Default:
+.Em none
+.br
+.Sy Example:
+.Dl license_noconflict openssl
+.Dl license_noconflict readline gdbm
 .El
 .Sh TARGET HOOKS
 A number of hooks are available for customizing many of the standard
@@ -419,7 +503,7 @@
 basis.
 .br
 .Sy Example:
-.Dl configure.env CPP=/usr/bin/cpp-4.0
+.Dl build.env CC="${configure.cc} [get_canonical_archflags]"
 .It Va target Ns Ic .pre_args
 Additional arguments passed before the main arguments.
 .br
@@ -555,7 +639,7 @@
 .Em read-only
 .br
 .Sy Default:
-.Em /Applications/Macports
+.Em /Applications/MacPorts
 .It Ic frameworks_dir
 Absolute path to the final location to install Mac OS X framework
 bundles (.framework directories).
@@ -567,7 +651,7 @@
 .Em ${prefix}/Library/Frameworks
 .El
 .Sh DEPENDENCY OPTIONS
-Port dependencies should refer to other MacPort ports
+Port dependencies should refer to other MacPorts ports
 whenever possible, therefore each dependency should be
 expressed in the format:
 .Bl -tag -width ls
@@ -630,7 +714,7 @@
 .Em optional
 .br
 .Sy Example:
-.Dl depends_extract port:xz-devel
+.Dl depends_extract path:bin/xz:xz
 .It Ic depends_build
 List of dependencies to check before
 .Cm configure ,
@@ -748,7 +832,7 @@
 .Em optional
 .br
 .Sy Example:
-.Dl patchfiles japanese-widechar-fix.diff japanese-localization.diff
+.Dl patchfiles patch-Makefile.in.diff patch-main.c.diff
 .It Ic use_zip
 Use zip.
 .br
@@ -925,9 +1009,9 @@
 .Em none
 .br
 .Sy Example:
-.Dl svn.url http://www.domain.com/svn-repo/mydirectory
-      svn.url svn://www.domain.com/svn-repo/mydirectory
-.It Ic svn.tag
+.Dl svn.url https://www.example.com/svn/project/tags/1.2.3
+      svn.url svn://www.example.com/svn/project/tags/1.2.3
+.It Ic svn.revision
 Specify a tag from which svn should fetch files. This
 corresponds to the -r option to the svn cli.  Note that you
 will need to use backslashes to escape characters that have
@@ -941,8 +1025,8 @@
 .Em none
 .br
 .Sy Example:
-.Dl svn.tag 37192
-      svn.tag \\{\\"2006-02-17 15:30 +0230\\"\\}
+.Dl svn.revision 37192
+      svn.revision \\{\\"2006-02-17 15:30 +0230\\"\\}
 .El
 .Ss FETCHING FROM GIT
 As an alternative to fetching distribution files, pulling the sources
@@ -1153,32 +1237,28 @@
 .Em gcc-3.3
 .Em gcc-4.0
 .Em gcc-4.2
-use the standard system compiler suites,
 .Em llvm-gcc-4.2
 .Em clang
-use the newer, non-default compilers installed by Xcode,
-.Em apple-gcc-3.3
+use the standard Xcode compiler suites,
 .Em apple-gcc-4.0
 .Em apple-gcc-4.2
 use Apple's gcc suite installed via MacPorts,
-.Em macports-gcc-3.3
-.Em macports-gcc-3.4
-.Em macports-gcc-4.0
-.Em macports-gcc-4.1
 .Em macports-gcc-4.2
 .Em macports-gcc-4.3
 .Em macports-gcc-4.4
 .Em macports-gcc-4.5
-use the vanilla gcc installed via MacPorts.
+.Em macports-gcc-4.6
+.Em macports-llvm-gcc-4.2
+use the vanilla compiler suites installed via MacPorts.
 .br
 .Sy Type:
 .Em optional
 .br
 .Sy Values:
-.Em gcc-3.3 gcc-4.0 gcc-4.2 llvm-gcc-4.2 clang apple-gcc-3.3 apple-gcc-4.0 apple-gcc-4.2 macports-gcc-3.3 macports-gcc-3.4 macports-gcc-4.0 macports-gcc-4.1 macports-gcc-4.2 macports-gcc-4.3 macports-gcc-4.4 macports-gcc-4.5
+.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
 .br
 .Sy Example:
-.Dl configure.compiler gcc-4.0
+.Dl configure.compiler llvm-gcc-4.2
 .\" FOOBAR
 .El
 .Ss UNIVERSAL TARGET HOOKS
@@ -1592,8 +1672,8 @@
 .It Ic livecheck.type
 What kind of check to perform to figure out if the software has been updated.
 Can be
-.Em freshmeat
-(uses the date_updated tag of the freshmeat XML file),
+.Em freecode
+(uses the date_updated tag of the freecode XML file),
 .Em sourceforge
 (uses the version of the latest file release of the project),
 .Em googlecode
@@ -1617,19 +1697,19 @@
 or
 .Em googlecode
 if the master_sites is one of these, else
-.Em freshmeat
+.Em freecode
 .br
 .Sy Values:
-.Em freshmeat sourceforge googlecode moddate regex regexm md5 none
+.Em freecode sourceforge googlecode moddate regex regexm md5 none
 .It Ic livecheck.name
-Name of the project for live checks (used for freshmeat, sourceforge, and googlecode checks).
+Name of the project for live checks (used for freecode, sourceforge, and googlecode checks).
 .br
 .Sy Type:
 .Em optional
 .br
 .Sy Default:
 .Em ${name}
-or the sourceforge/freshmeat/googlecode project name if it can be guessed by looking at the master_sites.
+or the sourceforge/freecode/googlecode project name if it can be guessed by looking at the master_sites.
 .It Ic livecheck.distname
 Name of the file release (used for sourceforge and googlecode checks).
 For sourceforge releases use the name of the package release.
@@ -1661,7 +1741,7 @@
 .Sy Default:
 .Em ${homepage}
 or
-.Em http://freshmeat.net/projects-xml/${livecheck.name}/${livecheck.name}.xml
+.Em http://freecode.com/projects/${livecheck.name}/releases.atom
 or
 .Em http://sourceforge.net/export/rss2_projfiles.php?project=${livecheck.name}
 or
@@ -1707,7 +1787,7 @@
 .Bd -literal -offset indent -compact
 variant gnome requires glib { configure.args-append --with-gnome \e\
 
-    depends_lib-append lib:gnome-session:gnome-session }
+    depends_lib-append port:gnome-session }
 .Ed
 .It Ic default_variants
 If variants are defined, then the
@@ -1756,7 +1836,7 @@
 .Xc
 The body is executed if the given platform/version/arch combination matches
 os.platform or os.subplatform and/or os.major and/or os.arch.
-The following examples are from the databases/db4 and devel/libidl1
+The following examples are from the lang/php5, audio/flac and sysutils/getopt
 .Nm Portfiles
 respectively.
 .br
@@ -1765,20 +1845,18 @@
 .br
 .Sy Example:
 .Bd -literal -offset indent -compact
-platform darwin 6 { configure.args-append   --enable-tcl \e\
-
-        --with-tcl=/System/Library/Tcl/8.3 }
+platform darwin 10 { configure.env-append LIBS=-lresolv }
 .Ed
 .br
 .Sy Example:
 .Bd -literal -offset indent -compact
-platform darwin powerpc { configure.args-append \e\
-
-        --host=${os.arch}-apple-rhapsody${os.version} }
-platform darwin i386 { configure.args-append \e\
-
-        --host=i386-gnu-rhapsody${os.version} }
+platform darwin i386 { configure.args-append --disable-asm-optimizations }
 .Ed
+.br
+.Sy Example:
+.Bd -literal -offset indent -compact
+platform darwin 8 powerpc { configure.universal_ldflags-append -liconv }
+.Ed
 .El
 .Sh PORTGROUP
 To factorize the work with similar ports, MacPorts provides the notion of
@@ -1952,7 +2030,10 @@
 .Op Cm shell Ns = Ns shell
 .Xc
 Add a new local user to the system with the specified uid, gid,
-password, real name, home directory and login shell.
+password, real name, home directory and login shell. Note that it is usually
+preferable to set the add_users option rather than call adduser directly,
+since it may need to be called in multiple places to handle all cases (e.g.
+installing from a binary archive).
 .It Ic existsuser Ar username
 Check if a local user exists.
 .It Ic nextuid
@@ -2010,7 +2091,11 @@
 .It Ic ln
 .br
 Built-in command mimicking the BSD ln command.
-.It Ic system Ar commandline
+.It Xo
+.Ic system
+.Op Fl W Ar dir
+.Ar commandline
+.Xc
 Execute a program. See
 .Xr system 3 .
 For calls to
@@ -2024,6 +2109,12 @@
 or similar, please use the built-in commands or
 .Nm file
 if they don't meet your requirements.
+.Bl -tag -width indent
+.It Fl W
+Change to
+.Ar dir
+before working.
+.El
 .It Ic variant_isset Ar variant
 Checks if the given
 .Ar variant
@@ -2076,10 +2167,10 @@
 .Xr mkdtemp 3 .
 .It Ic md5 Ar
 Compute the MD5 hashes of the file(s).
-.It Ic rpm-vercomp Ar versionA Ar versionB
-Compare two RPM-format versions for equality.  The return value is like
+.It Ic vercmp Ar versionA Ar versionB
+Compare two EVR-format versions for equality.  The return value is like
 strcmp(), returning -1, 0, or 1 when versionA is earlier, equal to, or
-later than versionB, respectively.  Note that some comparisions featuring
+later than versionB, respectively.  Note that some comparisons featuring
 floating-point notation may compare incorrectly, e.g. 2.101 is considered
 later than 2.2 (101 is larger than 2) which may be incorrect per some
 projects versioning methods (see ticket #11873).

Modified: branches/new-help-system/base/doc/portgroup.7
===================================================================
--- branches/new-help-system/base/doc/portgroup.7	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/doc/portgroup.7	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,7 +11,7 @@
 .\" 2. Redistributions in binary form must reproduce the above copyright
 .\"    notice, this list of conditions and the following disclaimer in the
 .\"    documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of Apple Computer, Inc. nor the names of its
+.\" 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.
 .\"

Modified: branches/new-help-system/base/doc/porthier.7
===================================================================
--- branches/new-help-system/base/doc/porthier.7	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/doc/porthier.7	2012-03-03 14:11:19 UTC (rev 90356)
@@ -95,16 +95,17 @@
 MacPorts runtime data
 .Bl -tag -width "build/" -compact
 .It Pa build/
-Where ports are build and destrooted
+Where ports are built and destrooted
 .It Pa distfiles/
 Holds the distfiles of the fetched ports
-.It Pa packages/
-Contains archives (packages) of installed ports
 .It Pa receipts/
-Holds the registry information and receipts for the installed ports
+Obsolete. Formerly held the registry information and receipts for the installed ports,
+in flat-file format.
+.It Pa registry/
+Contains the registry database in sqlite format.
 .It Pa software/
-In Image-mode (which is default) Holds the installed files. These
-are linked to ${prefix}.
+Holds compressed images of the installed ports. These
+are extracted to ${prefix} when activated.
 .It Pa sources/
 Holds the sources of both the porttree (the Portfiles) and the
 sources for the base system

Modified: branches/new-help-system/base/doc/prefix.mtree.in
===================================================================
--- branches/new-help-system/base/doc/prefix.mtree.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/doc/prefix.mtree.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -240,20 +240,6 @@
     src
     ..
     var
-        macports
-            build
-            ..
-            distfiles
-            ..
-            logs
-            ..
-            packages
-            ..
-            receipts
-            ..
-            registry
-            ..
-        ..
     ..
     www
     ..

Modified: branches/new-help-system/base/doc/sources.conf
===================================================================
--- branches/new-help-system/base/doc/sources.conf	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/doc/sources.conf	2012-03-03 14:11:19 UTC (rev 90356)
@@ -23,5 +23,9 @@
 #      rsync://rsync.macports.org/release/ports/
 #  To get it from the mirror in Trondheim, Norway use:
 #      rsync://trd.no.rsync.macports.org/release/ports/
-#  A current list of mirrors is available at http://trac.macports.org/wiki/Mirrors
-rsync://rsync.macports.org/release/ports/ [default]
+#  A current list of mirrors is available at https://trac.macports.org/wiki/Mirrors
+
+# If an rsync URL 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://rsync.macports.org/release/tarballs/ports.tar [default]

Modified: branches/new-help-system/base/m4/tcl.m4
===================================================================
--- branches/new-help-system/base/m4/tcl.m4	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/m4/tcl.m4	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,5 +1,5 @@
 # This file is based on the tcl.m4 file distributed with Tcl 8.4
-# Portions Copyright (2003) Apple Computer, Inc.
+# Portions Copyright (2003) Apple Inc.
 #
 # Copyright and License for this file, copied verbatim from the official
 # Tcl distribution, follows:

Modified: branches/new-help-system/base/macports-pubkey.pem
===================================================================
--- branches/new-help-system/base/macports-pubkey.pem	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/macports-pubkey.pem	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,9 +1,14 @@
 -----BEGIN PUBLIC KEY-----
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxPlw2FSMEavmtuHq5O+f
-XPUXndBnUyoX8iJvQ7NlsNY+hleE307kOAly79WFq2aAGIyKB/Ob8V+qCLW4FGOO
-4NfvOnte1WxQP8oVxOM9ai3CeN6AnUxDWUTYVJ1R+a5ZQVnJyGBKkV+jLlj0PD/z
-d8PCJ/j7Wzizw3d4s9uBIR1zpLY8lVgTivsj5FM3RP6hS7ww7I47goQshoL+YFVg
-NhE9I63oZXqFF130l9jJI9axHUqza7a42WCv04J8iv8SQhgv6fY9ZQnIBMQ4hPDH
-klGusdf4HlCbUViKhxmUpfj6FJabh2jV48ymaoTZB767GJyACF4mvnNDkenEXf41
-/wIDAQAB
+MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAv2bUqZgZmQNtkInIcery
+c/DQIbGdKgrdJ2+x45jOCITEf7QubgNmJAtw4OSNt30EXWGOrJXGD5Vb81o4ycEr
+f+bdTgCAG9fOipMxxDhT8AbSkAzYx9vGIcEwQP6VX5QhPlFxJJweeefEINNHkrm5
+KdmGpGxwe5AtTzxJiabWmJookKuoPxdy+5Am/EaCOIU6+HyM8i163L+DYDT+MF+e
+LFUVtpoZ4xVzvHhLMDwIsZWdpBrJcj9MVv3TOL0PQDAjyo/Gp2TWWRbiMaQ8vkfO
+NVSDAfvtOUlTBFcdt0oeLYL0F5Yj8wt5HYdL9GE6u+JOl+ee/dEUUhcmoFew9x9W
+YznHujitbmbQVPV1IYi4qIE4MyZPlmPmSyVg1bnt9UIgSTccqwUV6VzxF2fpwjvP
+tTo/sNLdtI3S/mprvzxTgv/gaB//1JAHXDKgUAtsgUyb6+RREjF2mFnAJb99H7sN
+5E89dIbI9v9CW5gJr0BoPYiDIZ1+HTUhW3+FCw+eNvPET+p8H5b9E+VXG/ctjac2
+7Lkexo4TOVJCN0p9kTdgCNzHrsJpyMkvsP8sR1SVvv94uC1X7sspIgFNcf/+YQ9t
+hzq+5L7GZgAyYy06xi+DYL4xR4oAOkirp/va1Yu4PaYGqly/Fbuw8ibJH1lmnu0G
+u3jRn1M2GBkVDNlb9oUHiecCAwEAAQ==
 -----END PUBLIC KEY-----

Modified: branches/new-help-system/base/portmgr/ReleaseProcess
===================================================================
--- branches/new-help-system/base/portmgr/ReleaseProcess	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/ReleaseProcess	2012-03-03 14:11:19 UTC (rev 90356)
@@ -31,17 +31,17 @@
 
 === Create a Release Branch ===
 
-For each major release (i.e. 1.5.x, 1.6.x, etc.) an appropriate branch is created with a
+For each major release (i.e. 1.9.x, 2.0.x, etc.) an appropriate branch is created with a
 consistent name. To do this, two things are required:
 
  * Choose the svn revision from which to create the branch, most likely based off trunk.
- * Create the branch (e.g. release_1_6) through the svn "copy" command for history preservation,
+ * Create the branch (e.g. release_2_0) through the svn "copy" command for history preservation,
    first creating the needed branch directory to preserve the required directory structure
    (the 'base' directory level *needs* to exist in each release branch, otherwise selfupdate breaks):
 
- svn mkdir -m "commit-message" http://svn.macports.org/repository/macports/branches/release_1_6
- svn cp [-r<rev>] -m "commit-message" http://svn.macports.org/repository/macports/trunk/base \
-     http://svn.macports.org/repository/macports/branches/release_1_6
+ svn mkdir -m "commit-message" https://svn.macports.org/repository/macports/branches/release_2_0
+ svn cp [-r<rev>] -m "commit-message" https://svn.macports.org/repository/macports/trunk/base \
+     https://svn.macports.org/repository/macports/branches/release_2_0
 
 The actual release, alpha or beta releases, release candidates, and any point releases will all
 live on this branch, and tagged appropriately and if necessary (a must for the actual releases,
@@ -81,19 +81,20 @@
 
 Tagging conventions:
 
- * release_1_6_0-rc1 (release candidate 1 for release 1.6.0)
- * release_1_6_0 (tagged release 1.6.0)
- * release_1_6_0-archive (tagged release 1.6.0 -- complete archive)
- * release_1_6_1 (1.6.1 release)
+ * release_2_0_0-beta2 (beta 2 for release 2.0.0)
+ * release_2_0_0-rc1 (release candidate 1 for release 2.0.0)
+ * release_2_0_0 (tagged release 2.0.0)
+ * release_2_0_0-archive (tagged release 2.0.0 -- complete archive)
+ * release_2_0_1 (2.0.1 release)
 
 We first tag the branched base directory to make up the final release:
 
- svn cp -m "commit-message" http://svn.macports.org/repository/macports/branches/release_1_6 \
-     http://svn.macports.org/repository/macports/tags/release_1_6_0
+ svn cp -m "commit-message" https://svn.macports.org/repository/macports/branches/release_2_0 \
+     https://svn.macports.org/repository/macports/tags/release_2_0_0
 
 Although only the base subdirectory is branched and tagged for a given major release, we also create a
 separate tag for the entire tree (base sources and full ports tree) at the time the final release tag is
-created (only for major releases, 1.x.0), in order to provide a stake in the ground that specifies a set
+created (only for major releases, x.y.0), in order to provide a stake in the ground that specifies a set
 of ports intended to work with that release. Note that this tag incorporates the entire svn trunk directory
 at the revision number at which the final release was tagged.
 
@@ -101,14 +102,14 @@
 revision of the final tagging of base and then switching the base directory to the appropriate release
 tag URL. For instance:
 
- svn co [-r<rev>] http://svn.macports.org/repository/macports/trunk release_1.6.0-archive
- cd release_1.6.0-archive/base
- svn switch http://svn.macports.org/repository/macports/tags/release_1_6_0/base
+ svn co [-r<rev>] https://svn.macports.org/repository/macports/trunk release_2.0.0-archive
+ cd release_2.0.0-archive/base
+ svn switch https://svn.macports.org/repository/macports/tags/release_2_0_0/base
 
-And finally we tag the entire directory as release_1_6_0-archive:
+And finally we tag the entire directory as release_2_0_0-archive:
 
  cd ../../
- svn cp -m "commit-message" release_1.6.0-archive http://svn.macports.org/repository/macports/tags/release_1_6_0-archive
+ svn cp -m "commit-message" release_2.0.0-archive https://svn.macports.org/repository/macports/tags/release_2_0_0-archive
 
 
 === Create & Post Release Tarballs ===
@@ -116,22 +117,22 @@
 The release tarballs are tar.bz2 and tar.gz archives of the base directory only and of the entire svn tree
 for a particular release. They are named with the following naming convention:
 
- MacPorts-1.6.0.tar.{bz2,gz} (base directory only, corresponding to tag release_1_6_0)
- MacPorts-1.6.0-archive.tar.{bz2,gz} (complete archives corresponding to tag release_1_6_0-archive)
+ MacPorts-2.0.0.tar.{bz2,gz} (base directory only, corresponding to tag release_2_0_0)
+ MacPorts-2.0.0-archive.tar.{bz2,gz} (complete archives corresponding to tag release_2_0_0-archive)
 
 The following commands issued to the top level Makefile will generate all the tarballs and checksums:
 
- make ARC=yes DISTVER=1.6.0 distfromsvn
+ make ARC=yes DISTVER=2.0.0 distfromsvn
 
 Note that if you omit the "ARC=yes" flag at the start of the make call then the full archive tarballs will not be produced.
 
 All these tarballs are uploaded to the http://distfiles.macports.org/MacPorts/ directory. At present, this must
 be done with the help of the MacOSForge sysadmin.
 
-Additionally, a file is created, and posted to the same location, that contains md5, sha1, and rmd160 checksums
+Additionally, a file is created, and posted to the same location, that contains md5, sha1, rmd160, and sha256 checksums
 for each of the files:
 
- MacPorts-1.6.0.chk.txt
+ MacPorts-2.0.0.chk.txt
  (We should have a way to sign these checksums, and have the signer's keys posted somewhere.
  Security experts in the project, would you be interested in leading this effort? Eric? Mark? Anyone else?)
 
@@ -139,11 +140,12 @@
 === Create Release 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 (1.x.0), named in a consistent fashion and incorporating the OS version for which it
+MacPorts releases (x.y.0), named in a consistent fashion and incorporating the OS version for which it
 was built.
 
- MacPorts-1.6.0-10.4-Tiger.dmg
- MacPorts-1.6.0-10.5-Leopard.dmg
+ MacPorts-2.0.0-10.5-Leopard.dmg
+ MacPorts-2.0.0-10.6-SnowLeopard.dmg
+ MacPorts-2.0.0-10.7-Lion.dmg
 
 To create a disk image, 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
@@ -156,8 +158,8 @@
 file in the downloads directory:
 
  cd work
- mv MacPorts-1.6.0.dmg MacPorts-1.6.0-10.5-Leopard.dmg
- for dmg in MacPorts-1.6.0-*.dmg; do for type in -md5 -sha1 -ripemd160; do openssl dgst $type $dmg; done >> MacPorts-1.6.0.chk.txt; done
+ 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
 
 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
@@ -206,8 +208,9 @@
 
 
 === Update trunk's version for next release ===
+
 Once trunk is to be used for development of the next major version, increase its version information to
-indicate it's moved past the release version by setting the patch-level version to 99, e.g., 1.8.99 (in
+indicate it's moved past the release version by setting the patch-level version to 99, e.g. 2.0.99 (in
 trunk/base/config/macports_version).
 
 
@@ -217,11 +220,19 @@
 
  * 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.
- * [http://trac.macports.org/news/] The MacOSforge news section (submitter: portmgr@)
- * [http://www.apple.com/downloads/macosx/unix_open_source/macports.html Apple's downloads page] (submitter: jmpp@)
- * [http://freshmeat.net/projects/macports/ Freshmeat] (submitter: mww@)
+ * [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@)
  * [http://sourceforge.net/projects/macports/ sourceforge] (submitted: rhwood@)
  * [http://www.macupdate.com/info.php/id/21309/macports MacUpdate] (submitter: ???)
  * [http://twitter.com/macports twitter] (submitter: raimue@)
  * (Where else?)
+
+
+=== Use of new features in Portfiles ===
+
+Using new features introduced by a release should be delayed for 14 days. This
+should allow users to upgrade their installations to the new release. This
+delay matches the warning about outdated ports tree sources.
+
+

Modified: branches/new-help-system/base/portmgr/dmg/InstallationCheck
===================================================================
--- branches/new-help-system/base/portmgr/dmg/InstallationCheck	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/dmg/InstallationCheck	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # $Id$
 #

Modified: branches/new-help-system/base/portmgr/dmg/License.html
===================================================================
--- branches/new-help-system/base/portmgr/dmg/License.html	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/dmg/License.html	2012-03-03 14:11:19 UTC (rev 90356)
@@ -15,7 +15,7 @@
 
     <body>
     
-        <p>Copyright (c) 2002 - 2003, Apple Computer, Inc.<br>Copyright (c) 2004 - 2010, The MacPorts Project.</p>
+        <p>Copyright (c) 2002 - 2003, Apple Inc.<br>Copyright (c) 2004 - 2011, The MacPorts Project.</p>
         <p>All rights reserved.</p>
         <p><br></p>
         
@@ -26,7 +26,7 @@
             <li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</li>
             <li>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.</li>
-            <li>Neither the name of Apple Computer, Inc., The MacPorts Project nor the names of its contributors may be used to endorse or
+            <li>Neither the name of Apple Inc., 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.</li>
         </ol>
         <p><br></p>

Modified: branches/new-help-system/base/portmgr/dmg/ReadMe.rtf
===================================================================
--- branches/new-help-system/base/portmgr/dmg/ReadMe.rtf	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/dmg/ReadMe.rtf	2012-03-03 14:11:19 UTC (rev 90356)
@@ -18,7 +18,7 @@
 System Requirements:
 \f0\b0 \
 \
-This disk image is built for Mac OS X __XVERS__.x and requires valid TCL, curl and OpenSSL installations to function - all present by default on Mac OS X. Also required is the installation of Apple's Xcode programing suite, available as a separate installation from your OS X CDs or DVD, or preferably the latest version from Apple's Developer site: {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/tools/xcode/index.html"}}{\fldrslt http://developer.apple.com/tools/xcode/index.html}}.\
+This disk image is built for Mac OS X __XVERS__.x and requires valid Tcl, cURL and OpenSSL installations to function - all present by default on Mac OS X. Also required is the installation of Apple's Xcode programing suite, available as a separate installation from your OS X CDs or DVD, or preferably the latest version from Apple's Developer site: {\field{\*\fldinst{HYPERLINK "http://developer.apple.com/tools/xcode/index.html"}}{\fldrslt http://developer.apple.com/tools/xcode/index.html}}.\
 \
 \
 
@@ -99,7 +99,7 @@
 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
 
 \f0\b0 \cf0 \
-The MacPorts Wiki is available at: {\field{\*\fldinst{HYPERLINK "http://trac.macports.org/projects/macports/wiki/"}}{\fldrslt http://trac.macports.org}} and should be consulted for further documentation and support. Also provided are man pages for 
+The MacPorts Wiki is available at: {\field{\*\fldinst{HYPERLINK "https://trac.macports.org/wiki"}}{\fldrslt https://trac.macports.org}} and should be consulted for further documentation and support. Also provided are man pages for 
 \f2\i port
 \f0\i0 , 
 \f2\i macports.conf

Modified: branches/new-help-system/base/portmgr/dmg/postflight
===================================================================
--- branches/new-help-system/base/portmgr/dmg/postflight	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/dmg/postflight	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,6 +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) 2002-2007 Juan Manuel Palacios <jmpp at macports.org>, The MacPorts Project.
 # All rights reserved.
 #
@@ -12,7 +13,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple, Inc., The MacPorts Project nor the
+# 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.
 #
@@ -35,7 +36,7 @@
 #set -x
 
 # Script identification ('cause more often than not the svn Id is not expanded):
-VERSION=1.9.0
+VERSION=2.0.0
 
 # Abstraction variables:
 PREFIX=__PREFIX__
@@ -45,6 +46,8 @@
 MANPAGES=${PREFIX}/share/man
 MACPORTS_TCL_DIR=${PREFIX}/share/macports/Tcl
 REG1DIR=${MACPORTS_TCL_DIR}/registry1.0
+DSCL=/usr/bin/dscl
+RUNUSR=macports
 TCLSH=/usr/bin/tclsh
 TCL_PACKAGE_DIR=/Library/Tcl
 TIMESTAMP=$(date +"%Y-%m-%d_at_%H:%M:%S")
@@ -53,8 +56,8 @@
 
 # Create config files from defaults if not present
 function setup_configs {
-    for f in macports.conf sources.conf variants.conf ; do
-        if [ ! -f ${CONFIGPATH}/${f} ]; then
+    for f in 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}
             /bin/chmod 644 ${CONFIGPATH}/${f}
@@ -64,6 +67,13 @@
 
 # Command to update the MacPorts installation through "selfupdate":
 function update_macports {
+    # 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}
+    # 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}
+
     echo "Synchronizing the MacPorts installation with the project's rsync server..."
     if ! ${BINPATH}/port -v selfupdate; then 
         echo "An attempt to synchronize your recent MacPorts installation with the project's rsync server failed!"
@@ -71,30 +81,25 @@
     else
         echo "Successful!"
     fi
-    
-    # Add [default] tag to the central MacPorts repository, if it isn't already
-    ${TCLSH} ${PACKAGE_PATH}/Contents/Resources/upgrade_sources_conf_default.tcl ${PREFIX}
-    # Remove any duplicates from the dep map (could occur with 1.6 and earlier)
-    ${TCLSH} ${PACKAGE_PATH}/Contents/Resources/dep_map_clean.tcl ${MACPORTS_TCL_DIR}
 }
 
 # Through this command we write an environment variable to an appropriate shell configuration file,
 # backing up the original only if it exists and if it doesn't contain the ${OUR_STRING} identification string,
 # which hints that we've already tweaked it and therefore already backed it up.
 function write_setting () {
-    if [ -f ${HOME}/.${CONF_FILE} ] && ! grep "${OUR_STRING}" ${HOME}/.${CONF_FILE} > /dev/null; then
+    if [[ -f "${HOME}/.${CONF_FILE}" ]] && ! grep "${OUR_STRING}" "${HOME}/.${CONF_FILE}" > /dev/null; then
         echo "Backing up your ${HOME}/.${CONF_FILE} shell confguration file as ${HOME}/.${CONF_FILE}.${BACKUP_SUFFIX} before adapting it for MacPorts."
-        /bin/cp -fp ${HOME}/.${CONF_FILE} "${HOME}/.${CONF_FILE}.${BACKUP_SUFFIX}" || {
+        /bin/cp -fp "${HOME}/.${CONF_FILE}" "${HOME}/.${CONF_FILE}.${BACKUP_SUFFIX}" || {
             echo "An attempt to backup your original configuration file failed! Please set your MacPorts compatible environment manually."
             update_macports
             exit 1
         }
-        echo -e "\n##\n# Your previous ${HOME}/.${CONF_FILE} file was backed up as ${HOME}/.${CONF_FILE}.${BACKUP_SUFFIX}\n##" >> ${HOME}/.${CONF_FILE}
+        echo -e "\n##\n# Your previous ${HOME}/.${CONF_FILE} file was backed up as ${HOME}/.${CONF_FILE}.${BACKUP_SUFFIX}\n##" >> "${HOME}/.${CONF_FILE}"
     fi
-    echo -e "\n# ${OUR_STRING}: adding an appropriate ${1} variable for use with MacPorts." >> ${HOME}/.${CONF_FILE}
-    echo "${ENV_COMMAND} ${1}${ASSIGN}${2}" >> ${HOME}/.${CONF_FILE}
-    echo -e "# Finished adapting your ${1} environment variable for use with MacPorts.\n" >> ${HOME}/.${CONF_FILE}
-    chown ${USER} ${HOME}/.${CONF_FILE} || echo "Warning: unable to adapt permissions on your ${HOME}/.${CONF_FILE} shell configuration file!"
+    echo -e "\n# ${OUR_STRING}: adding an appropriate ${1} variable for use with MacPorts." >> "${HOME}/.${CONF_FILE}"
+    echo "${ENV_COMMAND} ${1}${ASSIGN}${2}" >> "${HOME}/.${CONF_FILE}"
+    echo -e "# Finished adapting your ${1} environment variable for use with MacPorts.\n" >> "${HOME}/.${CONF_FILE}"
+    chown ${USER} "${HOME}/.${CONF_FILE}" || echo "Warning: unable to adapt permissions on your ${HOME}/.${CONF_FILE} shell configuration file!"
     echo "An appropriate ${1} variable has been added to your shell environment by the MacPorts installer."
 }
 
@@ -112,7 +117,7 @@
 
 # Delete the old registry1.0 directory
 function delete_reg1 {
-    if [ -d ${REG1DIR} ]; then
+    if [[ -d ${REG1DIR} ]]; then
         rm -vrf ${REG1DIR}
     fi
 }
@@ -120,16 +125,67 @@
 # link macports1.0 into tcl package dir if possible
 function link_tcl_package {
     # delete old directory if present
-    if ! test -L "${TCL_PACKAGE_DIR}/macports1.0" && test -d "${TCL_PACKAGE_DIR}/macports1.0"; then
-        rm -vrf "${TCL_PACKAGE_DIR}/macports1.0" || true
-    fi
-    if ! test -e "${TCL_PACKAGE_DIR}/macports1.0" && test -w "${TCL_PACKAGE_DIR}"; then
-		ln -vs "${MACPORTS_TCL_DIR}/macports1.0" "${TCL_PACKAGE_DIR}/macports1.0" || true
+    if [[ ! -L "${TCL_PACKAGE_DIR}/macports1.0" ]]; then
+        if [[ ! -e "${TCL_PACKAGE_DIR}" ]]; then
+            /usr/bin/install -d "${TCL_PACKAGE_DIR}" || true
+        fi
+        if [[ -d "${TCL_PACKAGE_DIR}/macports1.0" ]]; then
+            rm -vrf "${TCL_PACKAGE_DIR}/macports1.0" || true
+        fi
+        if [[ ! -e "${TCL_PACKAGE_DIR}/macports1.0" && -d "${TCL_PACKAGE_DIR}" ]]; then
+            ln -vs "${MACPORTS_TCL_DIR}/macports1.0" "${TCL_PACKAGE_DIR}/macports1.0" || true
+        fi
 	fi
 }
 
+# create the user to use for privilege dropping
+function create_run_user {
+    DSEDITGROUP=/usr/sbin/dseditgroup
+    if ! ${DSCL} -q . -read /Groups/${RUNUSR} > /dev/null 2>&1 ; then
+        echo "Creating group \"${RUNUSR}\""
+        ${DSEDITGROUP} -q -o create ${RUNUSR}
+    fi
+    if ! ${DSCL} -q . -list /Users/${RUNUSR} > /dev/null 2>&1 ; then
+        echo "Creating user \"${RUNUSR}\""
+        NEXTUID=501
+        while [[ -n "`${DSCL} -q /Search -search /Users UniqueID $NEXTUID`" ]]; do
+            let "NEXTUID=NEXTUID+1"
+        done
+        ${DSCL} -q . -create /Users/${RUNUSR} UniqueID $NEXTUID
+
+        # These are implicitly added on Mac OSX Lion.  AuthenticationAuthority
+        # causes the user to be visible in the Users & Groups Preference Pane,
+        # and the others are just noise, so delete them.
+        # https://trac.macports.org/ticket/30168
+        ${DSCL} -q . -delete /Users/${RUNUSR} AuthenticationAuthority
+        ${DSCL} -q . -delete /Users/${RUNUSR} PasswordPolicyOptions
+        ${DSCL} -q . -delete /Users/${RUNUSR} dsAttrTypeNative:KerberosKeys
+        ${DSCL} -q . -delete /Users/${RUNUSR} dsAttrTypeNative:ShadowHashData
+
+        ${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 ${PREFIX}/var/macports/home
+        ${DSCL} -q . -create /Users/${RUNUSR} UserShell /usr/bin/false
+    fi
+    if [[ $(sw_vers -productVersion | /usr/bin/awk -F . '{print $2}') -eq 4 ]]; then
+        GID=$(${DSCL} -q . -read /Groups/${RUNUSR} PrimaryGroupID | /usr/bin/awk '{print $2}')
+        if [[ "$(${DSCL} -q . -read /Users/${RUNUSR} PrimaryGroupID 2>/dev/null | /usr/bin/awk '{print $2}')" != "$GID" ]]; then
+            echo "Fixing PrimaryGroupID for user \"${RUNUSR}\""
+            ${DSCL} -q . -create /Users/${RUNUSR} PrimaryGroupID $GID
+            ${DSCL} -q . -create /Users/${RUNUSR} RealName MacPorts
+        fi
+    fi
+    if [[ "$(${DSCL} -q . -read /Users/${RUNUSR} NFSHomeDirectory)" = "NFSHomeDirectory: /var/empty" ]]; then
+        echo "Updating home directory location for user \"${RUNUSR}\""
+        ${DSCL} -q . -create /Users/${RUNUSR} NFSHomeDirectory ${PREFIX}/var/macports/home
+    fi
+}
+
 echo "The MacPorts Project, postflight script version ${VERSION}: checking the shell environment for user \"${USER}\"."
 
+# create macports user
+create_run_user
 # Set up config files
 setup_configs
 # link macports1.0 pkg
@@ -141,7 +197,7 @@
 
 # Determine the user's shell, in order to choose an appropriate configuration file we'll be tweaking.
 # Exit nicely if the shell is any other than bash or tcsh, as that's considered non-standard.
-USHELL=$(dscl . -read /users/${USER} shell | awk -F'/' '{print $NF}') || {
+USHELL=$(${DSCL} . -read /Users/${USER} shell | awk -F'/' '{print $NF}') || {
     echo "An attempt to determine your shell name failed! Please set your MacPorts compatible environment manually."
     update_macports
     exit 1
@@ -152,9 +208,9 @@
         LOGIN_FLAG=""
         ENV_COMMAND="setenv"
         ASSIGN=" "
-        if [ -f ${HOME}/.tcshrc ]; then
+        if [[ -f "${HOME}/.tcshrc" ]]; then
             CONF_FILE=tcshrc
-        elif [ -f ${HOME}/.cshrc ]; then
+        elif [[ -f "${HOME}/.cshrc" ]]; then
             CONF_FILE=cshrc
         else
             CONF_FILE=tcshrc
@@ -165,9 +221,9 @@
         LOGIN_FLAG="-l"
         ENV_COMMAND="export"
         ASSIGN="="
-        if [ -f ${HOME}/.bash_profile ]; then
+        if [[ -f "${HOME}/.bash_profile" ]]; then
             CONF_FILE=bash_profile
-        elif [ -f ${HOME}/.bash_login ]; then
+        elif [[ -f "${HOME}/.bash_login" ]]; then
             CONF_FILE=bash_login
         else
             CONF_FILE=profile
@@ -193,15 +249,15 @@
 # Adding our setting to the MANPATH variable only if it exists:
 if ! ${SHELL} ${LOGIN_FLAG} -c "/usr/bin/env | grep MANPATH" > /dev/null || \
 # and following that, if it's not empty:
-  [ -z "${ORIGINAL_MANPATH}" ] || \
+  [[ -z "${ORIGINAL_MANPATH}" ]] || \
 # or if it doesn't already contain our path:
   echo "${ORIGINAL_MANPATH}" | grep ${MANPAGES} > /dev/null || \
 # or if there's no empty component somewhere in the middle of it:
   echo "${ORIGINAL_MANPATH}" | grep :: > /dev/null || \
 # or at the start of it:
-  [ -z "$(echo "${ORIGINAL_MANPATH}" | awk -F : '{print $1}')" ] || \
+  [[ -z "$(echo "${ORIGINAL_MANPATH}" | awk -F : '{print $1}')" ]] || \
 # or at the end of it:
-  [ -z "$(echo "${ORIGINAL_MANPATH}" | awk -F : '{print $NF}')" ]; then
+  [[ -z "$(echo "${ORIGINAL_MANPATH}" | awk -F : '{print $NF}')" ]]; then
     echo "Your shell already has the right MANPATH environment variable for use with MacPorts!"
 else
     write_setting MANPATH "${MANPAGES}:\$MANPATH"
@@ -217,6 +273,7 @@
 
 # Postflight script is done with its job, update MacPorts and exit gracefully!
 update_macports
-echo "You have succesfully installed the MacPorts system, launch a terminal and try it out!"
-echo "Read the port(1) manual page and http://guide.macports.org for help, http://www.macports.org/contact.php if you need to get in touch with The MacPorts Project."
+echo "You have successfully installed the MacPorts system. Launch a terminal and try it out!"
+echo "Read the port(1) manual page and http://guide.macports.org/ for help."
+echo "See http://www.macports.org/contact.php if you need to get in touch with The MacPorts Project."
 exit 0

Added: branches/new-help-system/base/portmgr/fedora/macports.spec
===================================================================
--- branches/new-help-system/base/portmgr/fedora/macports.spec	                        (rev 0)
+++ branches/new-help-system/base/portmgr/fedora/macports.spec	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,100 @@
+Summary: MacPorts allows installing software on Mac OS X (and other platforms)
+Name: macports
+Version: 1.6.0
+Release: 0%{?dist}
+License: BSD
+Group: System Environment/Base
+URL: http://www.macports.org/
+Source: https://svn.macports.org/repository/macports/distfiles/MacPorts/MacPorts-%{version}.tar.bz2
+Prefix: /opt/local
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
+
+Requires: curl tcl rsync coreutils make
+BuildRequires: curl-devel tcl-devel tcl-thread sqlite-devel gcc-objc gnustep-base
+BuildRequires: mtree fakeroot /usr/GNUstep/System/Library/Makefiles/GNUstep.sh 
+BuildRequires: openssl-devel
+
+%description
+MacPorts is a system for compiling, installing, and managing free and
+open source software. A MacPorts "port" is a set of specifications
+contained in a Portfile that defines an application, its characteristics,
+and any files or special instructions required to install it, so MacPorts
+may automatically fetch, patch, compile, and install ported software.
+
+MacPorts may also be used to pre-compile ported software into binaries
+that may be installed on remote computers. Binaries of ported software
+may be installed very quickly since the steps required to install ports
+from source code have all been performed in advance.
+
+%prep
+%setup -n MacPorts-%{version}
+# avoid the whole upgrade and information procedure
+perl -pe 's/^install::/interactive::/' -i Makefile.in
+
+%define _prefix         %{prefix}
+%define _bindir         %{prefix}/bin
+%define _sysconfdir     %{prefix}/etc
+%define _datadir        %{prefix}/share
+%define _mandir         %{prefix}/share/man
+%define _infodir        %{prefix}/share/info
+%define _localstatedir  %{prefix}/var
+
+%build
+source /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
+%configure \
+	--without-included-tclthread --without-included-sqlite3 \
+	--with-objc-runtime=GNU --with-objc-foundation=GNUstep
+make
+
+%install
+source /usr/GNUstep/System/Library/Makefiles/GNUstep.sh
+rm -rf $RPM_BUILD_ROOT
+make install \
+	DESTDIR="$RPM_BUILD_ROOT" INSTALL="fakeroot install"
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-, root, root)
+%doc LICENSE ChangeLog
+%{_bindir}/port
+%{_bindir}/portf
+%{_bindir}/portindex
+%{_bindir}/portmirror
+%config(noreplace) %{_sysconfdir}/macports
+%doc %{_mandir}/man1/port.1*
+%doc %{_mandir}/man5/macports.conf.5*
+%doc %{_mandir}/man7/portfile.7*
+%doc %{_mandir}/man7/portgroup.7*
+%doc %{_mandir}/man7/porthier.7*
+%doc %{_mandir}/man7/portstyle.7*
+%{_datadir}/macports
+%{_localstatedir}/macports
+/usr/share/tcl8.4/macports1.0
+#### mtree
+%dir %{prefix}
+%dir %{prefix}/bin
+%dir %{prefix}/etc
+%dir %{prefix}/include
+%dir %{prefix}/lib
+%dir %{prefix}/libexec
+     %{prefix}/man
+%dir %{prefix}/sbin
+%dir %{prefix}/share
+%dir %{prefix}/share/info
+%dir %{prefix}/share/man
+%dir %{prefix}/share/man/cat?
+%dir %{prefix}/share/man/man?
+%dir %{prefix}/share/nls
+%dir %{prefix}/share/nls/*
+#dir %{prefix}/skel
+#dir %{prefix}/src
+%dir %{prefix}/var
+
+%changelog
+* Sun Aug 12 2007 Anders F Bjorklund <afb at macports.org> - 1.5.0
+- Updated to version 1.5.0
+
+* Sun Aug 12 2007 Anders F Bjorklund <afb at macports.org> - 1.4.0
+- Initial Fedora packaging

Modified: branches/new-help-system/base/portmgr/freebsd/Makefile.in
===================================================================
--- branches/new-help-system/base/portmgr/freebsd/Makefile.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/freebsd/Makefile.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -54,8 +54,6 @@
 pre-configure:
 	@# foundation.m4 is somewhat bashist (MacPorts Bug #12252)
 	@${REINPLACE_CMD} -e 's|#! /bin/sh|#!/usr/bin/env bash|' ${WRKSRC}/configure
-	@# should really have been #!/bin/sh
-	@${REINPLACE_CMD} -e 's|#!/bin/bash|#!/usr/bin/env bash|' ${WRKSRC}/src/pkg_mkindex.sh.in
 post-configure:
 	@# Makefile only works with GNU make (MacPorts Bug #12247)
 	@${LN} -s Makefile ${WRKSRC}/GNUmakefile

Modified: branches/new-help-system/base/portmgr/jobs/GuideRegen.sh
===================================================================
--- branches/new-help-system/base/portmgr/jobs/GuideRegen.sh	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/jobs/GuideRegen.sh	2012-03-03 14:11:19 UTC (rev 90356)
@@ -17,7 +17,7 @@
 
 # Other settings (probably don't need to be changed).
 SVN_CONFIG_DIR=${ROOT}/svnconfig
-REPO_BASE=http://svn.macports.org/repository/macports
+REPO_BASE=https://svn.macports.org/repository/macports
 SVN="/opt/local/bin/svn -q --non-interactive --config-dir $SVN_CONFIG_DIR"
 # Where to checkout the source code. This needs to exist!
 SRCTREE=${ROOT}/source

Modified: branches/new-help-system/base/portmgr/jobs/PortIndex2MySQL.tcl
===================================================================
--- branches/new-help-system/base/portmgr/jobs/PortIndex2MySQL.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/jobs/PortIndex2MySQL.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -9,7 +9,7 @@
 # $Id$
 #
 # Copyright (c) 2007 Juan Manuel Palacios, The MacPorts Project.
-# Copyright (c) 2003 Apple Computer, Inc.
+# Copyright (c) 2003 Apple Inc.
 # Copyright (c) 2002 Kevin Van Vechten. 
 # All rights reserved.
 #
@@ -21,7 +21,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 

Modified: branches/new-help-system/base/portmgr/jobs/mirror_macports.sh
===================================================================
--- branches/new-help-system/base/portmgr/jobs/mirror_macports.sh	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/jobs/mirror_macports.sh	2012-03-03 14:11:19 UTC (rev 90356)
@@ -7,7 +7,7 @@
 ####
 
 # regexp of ports that we do not mirror
-EXCLUSIONS='^(molden)$'
+EXCLUSIONS='^(molden|metis)$'
 
 # macports really wants this, so lets appease it
 export COLUMNS=80

Modified: branches/new-help-system/base/portmgr/jobs/mprsyncup
===================================================================
--- branches/new-help-system/base/portmgr/jobs/mprsyncup	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/jobs/mprsyncup	2012-03-03 14:11:19 UTC (rev 90356)
@@ -20,7 +20,7 @@
 #
 # Lastly, it is required of every 3rd party mirrors to keep track of this script
 # and the base/portmgr/rsync.repos file and always maintain local copies in as
-# close sync as possible. 
+# close sync as possible.
 #
 #
 # Created by fkr at opendarwin.org, jberry at macports.org and yeled at macports.org,
@@ -38,10 +38,11 @@
 RM="/bin/rm"
 MKDIR="/bin/mkdir"
 LN="/bin/ln"
+TAR="/usr/bin/tar"
+OPENSSL="/usr/bin/openssl"
 
 # Paths we'll work on:
 ROOT=/var/tmp/macports
-TMPDIR=mp_trunk/base
 PREFIX=${ROOT}/opt/local
 TCLPKG=${PREFIX}/lib/tcl
 SVNROOT=/var/tmp/macports
@@ -54,17 +55,18 @@
 PATH=${PREFIX}/bin:/bin:/usr/bin:/usr/sbin:/opt/local/bin
 
 # platforms we generate indexes for
-PLATFORMS="8_ppc 8_i386 9_ppc 9_i386 10_i386"
+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"
 
-MP_USER=nobody
-MP_GROUP=nobody
-
 # Sources information:
-SVNURL=http://svn.macports.org/repository/macports
+SVNURL=https://svn.macports.org/repository/macports
 RELEASE_URL_FILE=config/RELEASE_URL
 
+# private key to use for signing
+# XXX set real path
+PRIVKEY=""
+
 # cleanup up the working copy if it is locked
 if [ -f ${TBASE}/.svn/lock ]; then
     ${CLEANUP} ${TBASE}
@@ -97,7 +99,7 @@
 if [ ! -d ${RSYNCROOT}/release/base ]; then
     ${MKDIR} -p ${RSYNCROOT}/release/base
 fi
-${RSYNC} -aIC --delete ${RBASE}/ ${RSYNCROOT}/release/base 
+${RSYNC} -aIC --delete ${RBASE}/ ${RSYNCROOT}/release/base
 
 # clean up the working copy if it is locked
 if [ -f ${PORTS}/.svn/lock ]; then
@@ -106,7 +108,7 @@
 
 # Update/checkout the ports tree, export it and rsync it to ${RSYNCROOT}/release/ports:
 if [ -d ${PORTS}/.svn ]; then
-    ${SVN} update ${PORTS}  
+    ${SVN} update ${PORTS}
 else
     ${SVN} checkout ${SVNURL}/trunk/dports ${PORTS}
 fi
@@ -114,16 +116,14 @@
 # generate platform-specific indexes
 pushd ${PORTS} >> /dev/null
 # build MP trunk in a private location for indexing
-pushd ${ROOT}/${TMPDIR} >> /dev/null
-mkdir -p ${TCLPKG} 
+pushd ${TBASE} >> /dev/null
+${MKDIR} -p ${TCLPKG}
 ./configure \
     --prefix=${PREFIX} \
-    --with-tclpackage=${TCLPKG} \
-    --with-install-user=${MP_USER} \
-    --with-install-group=${MP_GROUP} 
-make clean 
+    --with-tclpackage=${TCLPKG}
+make clean
 make
-make install 
+make install
 popd
 
 for PLATFORM in $PLATFORMS; do
@@ -146,3 +146,22 @@
     ${RM} -rf dports && ${LN} -s ../release/ports dports
 fi
 
+# generate and sign tarballs of base and dports
+# the signature always needs to match, so we try to make this look atomic to
+# clients by switching a symlink target
+
+TAR_CURDIR=${RSYNCROOT}/release/tarballs_current
+${MKDIR} -p ${TAR_CURDIR}
+cp -pR ${TAR_CURDIR} ${RSYNCROOT}/release/tarballs_old
+${LN} -sfh tarballs_old ${RSYNCROOT}/release/tarballs
+${TAR} -C ${RSYNCROOT}/release/ -cf ${TAR_CURDIR}/base.tar base
+${TAR} --exclude 'PortIndex*' -C ${RSYNCROOT}/release/ -cf ${TAR_CURDIR}/ports.tar ports
+cp -pR ${RSYNCROOT}/release/ports/PortIndex_* ${TAR_CURDIR}
+# XXX needs PRIVKEY to be set above
+#${OPENSSL} dgst -ripemd160 -sign ${PRIVKEY} -out ${TAR_CURDIR}/base.tar.rmd160 ${TAR_CURDIR}/base.tar
+#${OPENSSL} dgst -ripemd160 -sign ${PRIVKEY} -out ${TAR_CURDIR}/ports.tar.rmd160 ${TAR_CURDIR}/ports.tar
+for index in ${TAR_CURDIR}/PortIndex_*/PortIndex; do
+    #${OPENSSL} dgst -ripemd160 -sign ${PRIVKEY} -out ${index}.rmd160 ${index}
+done
+${LN} -sfh tarballs_current ${RSYNCROOT}/release/tarballs
+${RM} -rf ${RSYNCROOT}/release/tarballs_old

Modified: branches/new-help-system/base/portmgr/jobs/org.macports.PortIndex2MySQL.plist
===================================================================
--- branches/new-help-system/base/portmgr/jobs/org.macports.PortIndex2MySQL.plist	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/jobs/org.macports.PortIndex2MySQL.plist	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
     <dict>
         <key>Label</key>
@@ -11,17 +11,17 @@
         <key>StartCalendarInterval</key>
         <array>
             <dict>
-	        <key>Hour</key>
-	        <integer>4</integer>
-	        <key>Minute</key>
-	        <integer>15</integer>
-	    </dict>
-	    <dict>
-	        <key>Hour</key>
-		<integer>16</integer>
-		<key>Minute</key>
-		<integer>15</integer>
-	    </dict>
+                <key>Hour</key>
+                <integer>4</integer>
+                <key>Minute</key>
+                <integer>15</integer>
+            </dict>
+            <dict>
+                <key>Hour</key>
+                <integer>16</integer>
+                <key>Minute</key>
+                <integer>15</integer>
+            </dict>
         </array>
         <key>UserName</key>
         <string>mysql</string>

Modified: branches/new-help-system/base/portmgr/jobs/org.macports.mprsyncup.plist
===================================================================
--- branches/new-help-system/base/portmgr/jobs/org.macports.mprsyncup.plist	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/jobs/org.macports.mprsyncup.plist	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
     <dict>
         <key>Label</key>
@@ -11,13 +11,13 @@
         <key>StartCalendarInterval</key>
         <array>
             <dict>
-	        <key>Minute</key>
-	        <integer>00</integer>
-	    </dict>
-	    <dict>
-		<key>Minute</key>
-		<integer>30</integer>
-	    </dict>
+                <key>Minute</key>
+                <integer>00</integer>
+            </dict>
+            <dict>
+                <key>Minute</key>
+                <integer>30</integer>
+            </dict>
         </array>
     </dict>
 </plist>

Copied: branches/new-help-system/base/portmgr/jobs/port_binary_distributable.tcl (from rev 90355, trunk/base/portmgr/jobs/port_binary_distributable.tcl)
===================================================================
--- branches/new-help-system/base/portmgr/jobs/port_binary_distributable.tcl	                        (rev 0)
+++ branches/new-help-system/base/portmgr/jobs/port_binary_distributable.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,327 @@
+#!/usr/bin/tclsh
+# -*- 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$
+#
+# Check that binaries of a port are distributable by looking at its license
+# and the licenses of its dependencies.
+#
+# Expected format: A {B C} means the license is A plus either B or C.
+#
+# Exit status:
+# 0: distributable
+# 1: non-distributable
+# 2: error
+
+
+set MY_VERSION 0.1
+
+array set portsSeen {}
+
+set check_deptypes {depends_build depends_lib}
+
+
+# Notes:
+# 'Restrictive/Distributable' means a non-free license that nonetheless allows
+# distributing binaries.
+# 'Restrictive' means a non-free license that does not allow distributing
+# binaries, and is thus not in the list.
+# 'Permissive' is a catchall for other licenses that allow
+# modification and distribution of source and binaries.
+# 'Copyleft' means a license that requires source code to be made available,
+# and derivative works to be licensed the same as the original.
+# 'GPLConflict' should be added if the license conflicts with the GPL (and its
+# variants like CeCILL and the AGPL) and is not in the list of licenses known
+# 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 \
+                   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}
+foreach lic $good_licenses {
+    set license_good($lic) 1
+}
+
+proc all_licenses_except { args } {
+    global good_licenses
+    set remaining $good_licenses
+    foreach arg $args {
+        set remaining [lsearch -inline -all -not -exact $remaining $arg]
+    }
+    return [list $remaining]
+}
+
+# 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}
+    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}
+    opensslexception [all_licenses_except openssl ssleay]
+    php {cecill gpl}
+    qpl {cecill gpl}
+    restrictive/distributable {agpl cecill gpl}
+    ruby {cecill gpl}
+    ssleay {cecill gpl}
+    zpl-1 {cecill gpl}"
+
+proc printUsage {} {
+    puts "Usage: $::argv0 \[-hvV\] \[-t macports-tcl-path\] port-name \[variants...\]"
+    puts "  -h    This help"
+    puts "  -t    Give a different location for the base MacPorts Tcl"
+    puts "        file (defaults to /Library/Tcl)"
+    puts "  -v    verbose output"
+    puts "  -V    show version and MacPorts version being used"
+    puts ""
+    puts "port-name is the name of a port to check"
+    puts "variants is the list of variants to enable/disable: +one -two..."
+}
+
+
+# return deps and license for given port
+proc infoForPort {portName variantInfo} {
+    global check_deptypes
+    set dependencyList {}
+    set portSearchResult [mportlookup $portName]
+    if {[llength $portSearchResult] < 1} {
+        puts "Warning: port \"$portName\" not found"
+        return {}
+    }
+    array set portInfo [lindex $portSearchResult 1]
+    set mport [mportopen $portInfo(porturl) [list subport $portName] $variantInfo]
+    array unset portInfo
+    array set portInfo [mportinfo $mport]
+    mportclose $mport
+
+    foreach dependencyType $check_deptypes {
+        if {[info exists portInfo($dependencyType)] && [string length $portInfo($dependencyType)] > 0} {
+            foreach dependency $portInfo($dependencyType) {
+                set afterColon [expr {[string last ":" $dependency] + 1}]
+                lappend dependencyList [string range $dependency $afterColon end]
+            }
+        }
+    }
+
+    set ret [list $dependencyList $portInfo(license)]
+    if {[info exists portInfo(installs_libs)]} {
+        lappend ret $portInfo(installs_libs)
+    } else {
+        # when in doubt, assume code from the dep is incorporated
+        lappend ret yes
+    }
+    if {[info exists portInfo(license_noconflict)]} {
+        lappend ret $portInfo(license_noconflict)
+    }
+    return $ret
+}
+
+# return license with any trailing dash followed by a number and/or plus sign removed
+proc remove_version {license} {
+    set dash [string last - $license]
+    if {$dash != -1 && [regexp {[0-9.+]+} [string range $license [expr $dash + 1] end]]} {
+        return [string range $license 0 [expr $dash - 1]]
+    } else {
+        return $license
+    }
+}
+
+proc check_licenses {portName variantInfo verbose} {
+    global license_good license_conflicts
+    array set portSeen {}
+    set top_info [infoForPort $portName $variantInfo]
+    set top_license [lindex $top_info 1]
+    foreach noconflict_port [lindex $top_info 3] {
+        set noconflict_ports($noconflict_port) 1
+    }
+    set top_license_names {}
+    # check that top-level port's license(s) are good
+    foreach sublist $top_license {
+        # each element may be a list of alternatives (i.e. only one need apply)
+        set any_good 0
+        set sub_names {}
+        foreach full_lic $sublist {
+            # chop off any trailing version number
+            set lic [remove_version [string tolower $full_lic]]
+            # add name to the list for later
+            lappend sub_names $lic
+            if {[info exists license_good($lic)]} {
+                set any_good 1
+            }
+        }
+        lappend top_license_names $sub_names
+        if {!$any_good} {
+            if {$verbose} {
+                puts "'$portName' has license '$lic' which is not known to be distributable"
+            }
+            return 1
+        }
+    }
+
+    # start with deps of top-level port
+    set portList [lindex $top_info 0]
+    while {[llength $portList] > 0} {
+        set aPort [lindex $portList 0]
+        # mark as seen and remove from the list
+        set portSeen($aPort) 1
+        set portList [lreplace $portList 0 0]
+        if {[info exists noconflict_ports($aPort)]} {
+            continue
+        }
+
+        set aPortInfo [infoForPort $aPort $variantInfo]
+        set aPortLicense [lindex $aPortInfo 1]
+        set installs_libs [lindex $aPortInfo 2]
+        if {!$installs_libs} {
+            continue
+        }
+        foreach sublist $aPortLicense {
+            set any_good 0
+            set any_compatible 0
+            # check that this dependency's license(s) are good
+            foreach full_lic $sublist {
+                set lic [remove_version [string tolower $full_lic]]
+                if {[info exists license_good($lic)]} {
+                    set any_good 1
+                } else {
+                    # no good being compatible with other licenses if it's not distributable itself
+                    continue
+                }
+
+                # ... and that they don't conflict with the top-level port's
+                set any_conflict 0
+                foreach top_sublist [concat $top_license $top_license_names] {
+                    set any_sub_compatible 0
+                    foreach top_lic $top_sublist {
+                        if {![info exists license_conflicts([string tolower $top_lic])]
+                            || ([lsearch -sorted $license_conflicts([string tolower $top_lic]) $lic] == -1
+                            && [lsearch -sorted $license_conflicts([string tolower $top_lic]) [string tolower $full_lic]] == -1)} {
+                            set any_sub_compatible 1
+                            break
+                        }
+                    }
+                    if {!$any_sub_compatible} {
+                        set any_conflict 1
+                        break
+                    }
+                }
+                if {!$any_conflict} {
+                    set any_compatible 1
+                    break
+                }
+            }
+
+            if {!$any_good} {
+                if {$verbose} {
+                    puts "${portName}'s dependency '$aPort' has license '$lic' which is not known to be distributable"
+                }
+                return 1
+            }
+            if {!$any_compatible} {
+                if {$verbose} {
+                    puts "dependency '$aPort' has license '$full_lic' which conflicts with license '$top_lic' from '$portName'"
+                }
+                return 1
+            }
+        }
+
+        # add its deps to the list
+        foreach possiblyNewPort [lindex $aPortInfo 0] {
+            if {![info exists portSeen($possiblyNewPort)]} {
+                lappend portList $possiblyNewPort
+            }
+        }
+    }
+
+    if {$verbose} {
+        puts "$portName is distributable"
+    }
+    return 0
+}
+
+
+# Begin
+
+set macportsTclPath /Library/Tcl
+set verbose 0
+set showVersion 0
+
+while {[string index [lindex $::argv 0] 0] == "-" } {
+    switch [string range [lindex $::argv 0] 1 end] {
+        h {
+            printUsage
+            exit 0
+        }
+        t {
+            if {[llength $::argv] < 2} {
+                puts "-t needs a path"
+                printUsage
+                exit 2
+            }
+            set macportsTclPath [lindex $::argv 1]
+            set ::argv [lrange $::argv 1 end]
+        }
+        v {
+             set verbose 1
+        }
+        V {
+            set showVersion 1
+        }
+        default {
+            puts "Unknown option [lindex $::argv 0]"
+            printUsage
+            exit 2
+        }
+    }
+    set ::argv [lrange $::argv 1 end]
+}
+
+source ${macportsTclPath}/macports1.0/macports_fastload.tcl
+package require macports
+mportinit
+
+if {$showVersion} {
+    puts "Version $MY_VERSION"
+    puts "MacPorts version [macports::version]"
+    exit 0
+}
+
+if {[llength $::argv] == 0} {
+    puts "Error: missing port-name"
+    printUsage
+    exit 2
+}
+set portName [lindex $::argv 0]
+set ::argv [lrange $::argv 1 end]
+
+array set variantInfo {}
+foreach variantSetting $::argv {
+    set flag [string index $variantSetting 0]
+    set variantName [string range $variantSetting 1 end]
+    set variantInfo($variantName) $flag
+}
+
+exit [check_licenses $portName [array get variantInfo] $verbose]

Modified: branches/new-help-system/base/portmgr/jobs/portfile_lint.pl
===================================================================
--- branches/new-help-system/base/portmgr/jobs/portfile_lint.pl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/jobs/portfile_lint.pl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -10,10 +10,16 @@
 use strict;
 use Mail::Sendmail;
 
+$ENV{'HOME'} = '/tmp/mp_lint/';
+$ENV{'LANG'} = 'en_US.UTF-8';
+
 my $REPOPATH = "/svn/repositories/macports/";
-my $REPOHOST = "http://svn.macosforge.org/repository/macports";
+my $REPOHOST = "https://svn.macports.org/repository/macports";
 my $SVNLOOK = "/opt/local/bin/svnlook";
+
+# use a release (non-trunk) version of port
 my $PORTCMD = "/opt/local/bin/port";
+
 my $SVN = "/opt/local/bin/svn -Nq --non-interactive";
 my $MKDIR = "/bin/mkdir -p";
 
@@ -29,10 +35,10 @@
 _log("Rev: $rev");
 
 foreach my $change (@changes) {
-    if ($change =~ /Portfile/) { 
+    if ($change =~ /[AU][\sU]\s\s[\/\w\-_]+Portfile$/) { 
 	# remove svn status and whitespace
 	chop($change);
-	$change =~ s/\w\s+([\/\w]+)/$1/g; 
+	$change =~ s/[ADU_][\sU]\s\s([\/\w\-_]+)/$1/g; 
 	# extract the portname from parent dir of Portfile
 	my $port = $change;
 	$port =~ s/^.*\/([^\/]+)\/Portfile$/$1/g;
@@ -41,12 +47,16 @@
 	my $group = $change;
 	$group =~ s/^.*\/([^\/]+)\/[^\/]+\/Portfile$/$1/g;	
 
+	# get the parent directory of the Portfile
+	my $parent = $change;
+	$parent =~ s/Portfile//;
+
 	_log("Port: $group / $port ");
 
 	# make a temporary work area
 	`$MKDIR $TMPROOT/$group/$port`;
 	chdir("$TMPROOT/$group/$port") or die("Failed to change dir for port: $port");	
-	`$SVN co $REPOHOST/trunk/dports/$group/$port/ .`;
+	`$SVN co -r $rev $REPOHOST/$parent .`;
 	# test the port
 	_lint($port);
     }
@@ -79,11 +89,14 @@
 sub _mail {
     my ($port, $maintainers, $errors) = @_;
 
+    # remove duplicates, such as a maintainer being the author of the commit
+    $maintainers =~ s/$author//g;
+
     my %mail = (
 	     To => "$author, $maintainers",
 	     From => 'noreply at macports.org',
 	     Subject => "[$rev] $port Lint Report",
-	     Message => "Portfile: $port\n\n\n$errors \n\n",
+	     Message => "Change: https://trac.macports.org/changeset/$rev\nPortfile: $port\n\n$errors \n\n",
 	     smtp => 'relay.apple.com',
 	     );
 

Modified: branches/new-help-system/base/portmgr/jobs/portfile_mirror.pl
===================================================================
--- branches/new-help-system/base/portmgr/jobs/portfile_mirror.pl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/jobs/portfile_mirror.pl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,7 +11,7 @@
 my $EXCLUSIONS = ('molden');
 
 my $REPOPATH = "/svn/repositories/macports/";
-my $REPOHOST = "http://svn.macosforge.org/repository/macports";
+my $REPOHOST = "https://svn.macports.org/repository/macports";
 my $SVNLOOK = "/opt/local/bin/svnlook";
 my $PORTCMD = "/opt/local/bin/port";
 my $SVN = "/opt/local/bin/svn -q --non-interactive";
@@ -20,7 +20,7 @@
 my $rev = $ARGV[0] or usage();
 my $TMPROOT = "/tmp/mp_mirror/$rev";
 
-my @changes = `$SVNLOOK changed $REPOPATH -r $rev`;
+my @changes = `$SVNLOOK changed $REPOPATH -r $rev | grep '/Portfile' | grep -vE '^[ ]+D'`;
 
 foreach my $change (@changes) {
     if ($change =~ /Portfile/) { 

Modified: branches/new-help-system/base/portmgr/packaging/dpkgall.tcl
===================================================================
--- branches/new-help-system/base/portmgr/packaging/dpkgall.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/packaging/dpkgall.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,9 +2,10 @@
 # dpkgbuild.tcl
 # $Id$
 #
+# Copyright (c) 2009-2011 The MacPorts Project
 # Copyright (c) 2004 Landon Fuller <landonf at macports.org>
 # Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
+# Copyright (c) 2002 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -439,6 +440,9 @@
 			continue
 		}
 
+        # open correct subport
+        set options(subport) $portinfo(name)
+
 		# Skip un-supported ports
 		if {[info exists portinfo(platforms)] && ${anyplatform_flag} != "true"} {
 			if {[lsearch $portinfo(platforms) $platformString] == -1} {
@@ -690,6 +694,7 @@
 	set variations ""
 
 	foreach port [get_required_ports] {
+	    set options(subport) $port
 		if {[catch {do_portexec $port [array get options] [array get variants] activate} result]} {
 			global errorInfo
 			ui_debug "$errorInfo"
@@ -704,7 +709,7 @@
 			set port [lindex $portlist 0]
 
 			ui_msg "Uninstalling $port."
-			if { [catch {registry_uninstall::uninstall $portname $portversion} result] } {
+			if { [catch {registry_uninstall::uninstall $portname $portversion "" 0 [array get options]} result] } {
 				global errorInfo
 				ui_debug "$errorInfo"
 				ui_noisy_errorr "Fatal error: Uninstalling $port failed: $result"

Modified: branches/new-help-system/base/portmgr/packaging/mpkgall.tcl
===================================================================
--- branches/new-help-system/base/portmgr/packaging/mpkgall.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/packaging/mpkgall.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,7 +3,7 @@
 # $Id$
 #
 # Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
+# Copyright (c) 2002 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -102,7 +102,7 @@
 proc write_description_plist {infofile portname portversion description} {
 	set infofd [open ${infofile} w+]
 	puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!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>
@@ -174,7 +174,7 @@
 
 	set infofd [open ${infofile} w+]
 	puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!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>

Modified: branches/new-help-system/base/portmgr/packaging/packageall.tcl
===================================================================
--- branches/new-help-system/base/portmgr/packaging/packageall.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/packaging/packageall.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,8 +2,9 @@
 # packageall.tcl
 # $Id$
 #
+# Copyright (c) 2009-2011 The MacPorts Project
 # Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
+# Copyright (c) 2002 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -302,7 +303,7 @@
 		set logfd ""
 	}
 	#if {[file readable $logfilename]} {
-	#	if {[catch {system "cat $logfilename | /usr/sbin/sendmail -t"} error]} {
+	#	if {[catch {system "<$logfilename /usr/sbin/sendmail -t"} error]} {
 	#		puts stderr "Internal error: $error"
 	#	}
 	#}
@@ -398,6 +399,7 @@
 
 	# Turn on verbose output for the build
 	set ui_options(ports_verbose) yes
+	set options(subport) $name
 	if {[catch {set workername [mportopen $porturl [array get options] [array get variations] yes]} result] ||
 		$result == 1} {
 		global errorInfo

Modified: branches/new-help-system/base/portmgr/packaging/rpmall.tcl
===================================================================
--- branches/new-help-system/base/portmgr/packaging/rpmall.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/portmgr/packaging/rpmall.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,9 +2,10 @@
 # rpmall.tcl
 # $Id$
 #
+# Copyright (c) 2009-2011 The MacPorts Project
 # Copyright (c) 2003 Benjamin Reed <ranger at befunk.com>
 # Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
+# Copyright (c) 2002 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -364,7 +365,7 @@
 		set logfd ""
 	}
 	#if {[file readable $logfilename]} {
-	#	if {[catch {system "cat $logfilename | /usr/sbin/sendmail -t"} error]} {
+	#	if {[catch {system "<$logfilename /usr/sbin/sendmail -t"} error]} {
 	#		puts stderr "Internal error: $error"
 	#	}
 	#}
@@ -450,6 +451,7 @@
 			}
 			array set prebuildinfo [lindex $search 1]
 			set ui_options(ports_verbose) yes
+			set options(subport) ${prebuild}
 			if {[catch {set workername [mportopen $prebuildinfo(porturl) [array get options] [array get variations] yes]} result] ||
 				$result == 1} {
 				global errorInfo
@@ -470,6 +472,7 @@
 
 	# Turn on verbose output for the build
 	set ui_options(ports_verbose) yes
+	set options(subport) $name
 	if {[catch {set workername [mportopen $porturl [array get options] [array get variations]]} result] ||
 		$result == 1} {
 		global errorInfo

Modified: branches/new-help-system/base/src/Makefile.in
===================================================================
--- branches/new-help-system/base/src/Makefile.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/Makefile.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -5,7 +5,8 @@
 			package1.0 \
 			pextlib1.0 \
 			registry2.0 \
-			darwintracelib1.0
+			darwintracelib1.0 \
+			machista1.0
 SUBDIR=		${TCLPKG} port programs
 
 all::

Modified: branches/new-help-system/base/src/config.h.in
===================================================================
--- branches/new-help-system/base/src/config.h.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/config.h.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -83,10 +83,13 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
+/* Define if you have the `crypto' library (-lcrypto). */
+#undef HAVE_LIBCRYPTO
+
 /* Define if you have the `md' library (-lmd). */
 #undef HAVE_LIBMD
 
-/* Define to 1 if you have the `readline' library (-lreadline). */
+/* Define to 1 if you have the 'readline' library (-lreadline). */
 #undef HAVE_LIBREADLINE
 
 /* Define to 1 if you have the <limits.h> header file. */
@@ -110,6 +113,15 @@
 /* Define to 1 if you have the <objc/objc.h> header file. */
 #undef HAVE_OBJC_OBJC_H
 
+/* Define to 1 if you have the <openssl/md5.h> header file. */
+#undef HAVE_OPENSSL_MD5_H
+
+/* Define to 1 if you have the <openssl/ripemd.h> header file. */
+#undef HAVE_OPENSSL_RIPEMD_H
+
+/* Define to 1 if you have the <openssl/sha.h> header file. */
+#undef HAVE_OPENSSL_SHA_H
+
 /* Define to 1 if you have the <paths.h> header file. */
 #undef HAVE_PATHS_H
 
@@ -125,9 +137,24 @@
 /* Define to 1 if you have the <readline/readline.h> header file. */
 #undef HAVE_READLINE_READLINE_H
 
+/* Define to 1 if you have the <ripemd.h> header file. */
+#undef HAVE_RIPEMD_H
+
 /* Define to 1 if you have the `setmode' function. */
 #undef HAVE_SETMODE
 
+/* Define to 1 if you have the `SHA1_File' function. */
+#undef HAVE_SHA1_FILE
+
+/* Define to 1 if you have the <sha256.h> header file. */
+#undef HAVE_SHA256_H
+
+/* Define to 1 if you have the `SHA256_Update' function. */
+#undef HAVE_SHA256_UPDATE
+
+/* Define to 1 if you have the <sha.h> header file. */
+#undef HAVE_SHA_H
+
 /* Define to 1 if you have the <sqlite3ext.h> header file. */
 #undef HAVE_SQLITE3EXT_H
 
@@ -242,3 +269,7 @@
 
 /* Attribute to mark unused variables */
 #undef UNUSED
+
+/* define sqlite3_prepare to sqlite_prepare_v2 if the latter is not available
+   */
+#undef sqlite3_prepare_v2

Modified: branches/new-help-system/base/src/cregistry/Makefile
===================================================================
--- branches/new-help-system/base/src/cregistry/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/cregistry/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,6 +1,6 @@
 # $Id$
 
-OBJS = registry.o entry.o sql.o vercomp.o
+OBJS = registry.o entry.o sql.o vercomp.o util.o file.o
 STLIB_NAME = cregistry.a
 RANLIB = ranlib
 

Modified: branches/new-help-system/base/src/cregistry/entry.c
===================================================================
--- branches/new-help-system/base/src/cregistry/entry.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/cregistry/entry.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,6 +2,7 @@
  * entry.c
  * $Id$
  *
+ * Copyright (c) 2010-2011 The MacPorts Project
  * Copyright (c) 2007 Chris Pickel <sfiera at macports.org>
  * All rights reserved.
  *
@@ -33,10 +34,11 @@
 #include "entry.h"
 #include "registry.h"
 #include "sql.h"
+#include "util.h"
 
-#include <string.h>
-#include <stdlib.h>
 #include <sqlite3.h>
+#include <stdlib.h>
+#include <string.h>
 
 /*
  * TODO: possibly, allow reg_entry_search to take different matching strategies
@@ -52,9 +54,6 @@
  *       always have very discrete values. These could be more efficiently dealt
  *       with as integers.
  *
- * TODO: move the utility functions to util.h or something. Not important until
- *       there are more types in the registry than entry, though.
- *
  * TODO: considering a "weak" flag in registry.files. The meaning of this would
  *       be "I wish for my version of this file to be activated when I am, but
  *       not to be deactivated when I am; nor should other ports be prevented
@@ -68,85 +67,6 @@
  */
 
 /**
- * Concatenates `src` to string `dst`. Simple concatenation. Only guaranteed to
- * work with strings that have been allocated with `malloc`. Amortizes cost of
- * expanding string buffer for O(N) concatenation and such. Uses `memcpy` in
- * favor of `strcpy` in hopes it will perform a bit better.
- *
- * @param [in,out] dst       a reference to a null-terminated string
- * @param [in,out] dst_len   number of characters currently in `dst`
- * @param [in,out] dst_space number of characters `dst` can hold
- * @param [in] src           string to concatenate to `dst`
- */
-static int reg_strcat(char** dst, size_t* dst_len, size_t* dst_space, char* src) {
-    size_t src_len = strlen(src);
-    size_t result_len = *dst_len + src_len;
-    if (result_len > *dst_space) {
-        char* new_dst;
-        *dst_space *= 2;
-        if (*dst_space < result_len) {
-            *dst_space = result_len;
-        }
-        new_dst = realloc(*dst, *dst_space * sizeof(char) + 1);
-        if (!new_dst)
-            return 0;
-        else
-            *dst = new_dst;
-    }
-    memcpy(*dst + *dst_len, src, src_len+1);
-    *dst_len = result_len;
-    return 1;
-}
-
-/**
- * Appends element `src` to the list `dst`. It's like `reg_strcat`, except `src`
- * represents a single element and not a sequence of `char`s.
- *
- * @param [in,out] dst       a reference to a list of pointers
- * @param [in,out] dst_len   number of elements currently in `dst`
- * @param [in,out] dst_space number of elements `dst` can hold
- * @param [in] src           elements to append to `dst`
- */
-static int reg_listcat(void*** dst, int* dst_len, int* dst_space, void* src) {
-    if (*dst_len == *dst_space) {
-        void** new_dst;
-        *dst_space *= 2;
-        new_dst = realloc(*dst, *dst_space * sizeof(void*));
-        if (!new_dst)
-            return 0;
-        else
-            *dst = new_dst;
-    }
-    (*dst)[*dst_len] = src;
-    (*dst_len)++;
-    return 1;
-}
-
-/**
- * Returns an expression to use for the given strategy. This should be passed as
- * the `fmt` argument of `sqlite3_mprintf`, with the key and value following.
- *
- * @param [in] strategy a strategy (one of the `reg_strategy_*` constants)
- * @param [out] errPtr  on error, a description of the error that occurred
- * @return              a sqlite3 expression if success; NULL if failure
- */
-static char* reg_strategy_op(reg_strategy strategy, reg_error* errPtr) {
-    switch (strategy) {
-        case reg_strategy_exact:
-            return "%q = '%q'";
-        case reg_strategy_glob:
-            return "%q GLOB '%q'";
-        case reg_strategy_regexp:
-            return "REGEXP(%q, '%q')";
-        default:
-            errPtr->code = REG_INVALID;
-            errPtr->description = "invalid matching strategy specified";
-            errPtr->free = NULL;
-            return NULL;
-    }
-}
-
-/**
  * Converts a `sqlite3_stmt` into a `reg_entry`. The first column of the stmt's
  * row must be the id of an entry; the second either `SQLITE_NULL` or the
  * address of the entry in memory.
@@ -158,7 +78,7 @@
  * @return              true if success; false if failure
  */
 static int reg_stmt_to_entry(void* userdata, void** entry, void* stmt,
-        reg_error* errPtr UNUSED) {
+        void* calldata UNUSED, reg_error* errPtr UNUSED) {
     int is_new;
     reg_registry* reg = (reg_registry*)userdata;
     sqlite_int64 id = sqlite3_column_int64(stmt, 0);
@@ -201,7 +121,7 @@
     reg_entry* entry = NULL;
     char* query = "INSERT INTO registry.ports "
         "(name, version, revision, variants, epoch) VALUES (?, ?, ?, ?, ?)";
-    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_text(stmt, 1, name, -1, SQLITE_STATIC)
                 == SQLITE_OK)
             && (sqlite3_bind_text(stmt, 2, version, -1, SQLITE_STATIC)
@@ -261,9 +181,16 @@
         char* revision, char* variants, char* epoch, reg_error* errPtr) {
     sqlite3_stmt* stmt = NULL;
     reg_entry* entry = NULL;
-    char* query = "SELECT id FROM registry.ports WHERE name=? AND version=? "
+    int lower_bound = 0;
+    char* query;
+    if (strlen(epoch) > 0) {
+        query = "SELECT id FROM registry.ports WHERE name=? AND version=? "
         "AND revision=? AND variants=? AND epoch=?";
-    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+    } else {
+        query = "SELECT id FROM registry.ports WHERE name=? AND version=? "
+        "AND revision=? AND variants=? AND epoch!=?";
+    }
+    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_text(stmt, 1, name, -1, SQLITE_STATIC)
                 == SQLITE_OK)
             && (sqlite3_bind_text(stmt, 2, version, -1, SQLITE_STATIC)
@@ -279,7 +206,7 @@
             r = sqlite3_step(stmt);
             switch (r) {
                 case SQLITE_ROW:
-                    reg_stmt_to_entry(reg, (void**)&entry, stmt, errPtr);
+                    reg_stmt_to_entry(reg, (void**)&entry, stmt, &lower_bound, errPtr);
                     break;
                 case SQLITE_DONE:
                     errPtr->code = REG_NOT_FOUND;
@@ -322,12 +249,12 @@
     char* ports_query = "DELETE FROM registry.ports WHERE id=?";
     char* files_query = "DELETE FROM registry.files WHERE id=?";
     char* dependencies_query = "DELETE FROM registry.dependencies WHERE id=?";
-    if ((sqlite3_prepare(reg->db, ports_query, -1, &ports, NULL) == SQLITE_OK)
+    if ((sqlite3_prepare_v2(reg->db, ports_query, -1, &ports, NULL) == SQLITE_OK)
             && (sqlite3_bind_int64(ports, 1, entry->id) == SQLITE_OK)
-            && (sqlite3_prepare(reg->db, files_query, -1, &files, NULL)
+            && (sqlite3_prepare_v2(reg->db, files_query, -1, &files, NULL)
                 == SQLITE_OK)
             && (sqlite3_bind_int64(files, 1, entry->id) == SQLITE_OK)
-            && (sqlite3_prepare(reg->db, dependencies_query, -1, &dependencies,
+            && (sqlite3_prepare_v2(reg->db, dependencies_query, -1, &dependencies,
                     NULL) == SQLITE_OK)
             && (sqlite3_bind_int64(dependencies, 1, entry->id) == SQLITE_OK)) {
         int r;
@@ -409,72 +336,6 @@
 }
 
 /**
- * Convenience method for returning all objects of a given type from the
- * registry.
- *
- * @param [in] reg       registry to select objects from
- * @param [in] query     the select query to execute
- * @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 [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
- */
-static int reg_all_objects(reg_registry* reg, char* query, int query_len,
-        void*** objects, cast_function* fn, free_function* del,
-        reg_error* errPtr) {
-    void** results = malloc(10*sizeof(void*));
-    int result_count = 0;
-    int result_space = 10;
-    sqlite3_stmt* stmt = NULL;
-    if (!results) {
-        return -1;
-    }
-    if (sqlite3_prepare(reg->db, query, query_len, &stmt, NULL) == SQLITE_OK) {
-        int r;
-        reg_entry* entry;
-        do {
-            r = sqlite3_step(stmt);
-            switch (r) {
-                case SQLITE_ROW:
-                    if (fn(reg, (void**)&entry, stmt, errPtr)) {
-                        if (!reg_listcat(&results, &result_count, &result_space, entry)) {
-                            r = SQLITE_ERROR;
-                        }
-                    } else {
-                        r = SQLITE_ERROR;
-                    }
-                    break;
-                case SQLITE_DONE:
-                case SQLITE_BUSY:
-                    break;
-                default:
-                    reg_sqlite_error(reg->db, errPtr, query);
-                    break;
-            }
-        } while (r == SQLITE_ROW || r == SQLITE_BUSY);
-        sqlite3_finalize(stmt);
-        if (r == SQLITE_DONE) {
-            *objects = results;
-            return result_count;
-        } else {
-            int i;
-            for (i=0; i<result_count; i++) {
-                del(NULL, results[i]);
-            }
-        }
-    } else {
-        if (stmt) {
-            sqlite3_finalize(stmt);
-        }
-        reg_sqlite_error(reg->db, errPtr, query);
-    }
-    free(results);
-    return -1;
-}
-
-/**
  * Type-safe version of `reg_all_objects` for `reg_entry`.
  *
  * @param [in] reg       registry to select entries from
@@ -486,8 +347,9 @@
  */
 static int reg_all_entries(reg_registry* reg, char* query, int query_len,
         reg_entry*** objects, reg_error* errPtr) {
+    int lower_bound = 0;
     return reg_all_objects(reg, query, query_len, (void***)objects,
-            reg_stmt_to_entry, NULL, errPtr);
+            reg_stmt_to_entry, &lower_bound, NULL, errPtr);
 }
 
 /**
@@ -633,7 +495,8 @@
     int result = 0;
     sqlite3_stmt* stmt = NULL;
     char* query = "SELECT id FROM registry.files WHERE actual_path=? AND active";
-    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+    int lower_bound = 0;
+    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_text(stmt, 1, path, -1, SQLITE_STATIC)
                 == SQLITE_OK)) {
         int r;
@@ -642,7 +505,7 @@
             switch (r) {
                 case SQLITE_ROW:
                     result = reg_stmt_to_entry(reg, (void**)entry, stmt,
-                            errPtr);
+                            &lower_bound, errPtr);
                     break;
                 case SQLITE_DONE:
                     *entry = NULL;
@@ -680,7 +543,7 @@
     sqlite3_stmt* stmt = NULL;
     sqlite_int64 result = 0;
     char* query = "SELECT id FROM registry.files WHERE actual_path=? AND active";
-    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_text(stmt, 1, path, -1, SQLITE_STATIC)
                 == SQLITE_OK)) {
         int r;
@@ -717,7 +580,7 @@
     const char *text;
     query = sqlite3_mprintf("SELECT %q FROM registry.ports WHERE id=%lld", key,
             entry->id);
-    if (sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
+    if (sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
         int r;
         do {
             r = sqlite3_step(stmt);
@@ -775,7 +638,7 @@
     char* query;
     query = sqlite3_mprintf("UPDATE registry.ports SET %q = '%q' WHERE id=%lld",
             key, value, entry->id);
-    if (sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
+    if (sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
         int r;
         do {
             r = sqlite3_step(stmt);
@@ -823,7 +686,7 @@
     sqlite3_stmt* stmt = NULL;
     char* insert = "INSERT INTO registry.files (id, path, mtime, active) "
         "VALUES (?, ?, 0, 0)";
-    if ((sqlite3_prepare(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
+    if ((sqlite3_prepare_v2(reg->db, insert, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
         int i;
         for (i=0; i<file_count && result; i++) {
@@ -875,7 +738,7 @@
     int result = 1;
     sqlite3_stmt* stmt = NULL;
     char* query = "DELETE FROM registry.files WHERE path=? AND id=?";
-    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_int64(stmt, 2, entry->id) == SQLITE_OK)) {
         int i;
         for (i=0; i<file_count && result; i++) {
@@ -932,7 +795,7 @@
     reg_registry* reg = entry->reg;
     sqlite3_stmt* stmt = NULL;
     char* query = "SELECT path FROM registry.files WHERE id=? ORDER BY path";
-    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
         char** result = malloc(10*sizeof(char*));
         int result_count = 0;
@@ -1000,7 +863,7 @@
     sqlite3_stmt* stmt = NULL;
     char* query = "SELECT actual_path FROM registry.files WHERE id=? "
         "AND active ORDER BY actual_path";
-    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)) {
         char** result = malloc(10*sizeof(char*));
         int result_count = 0;
@@ -1083,8 +946,8 @@
         as_files = files;
     }
 
-    if (sqlite3_prepare(reg->db, select_query, -1, &select, NULL) == SQLITE_OK){
-        if ((sqlite3_prepare(reg->db, update_query, -1, &update, NULL)
+    if (sqlite3_prepare_v2(reg->db, select_query, -1, &select, NULL) == SQLITE_OK){
+        if ((sqlite3_prepare_v2(reg->db, update_query, -1, &update, NULL)
                 == SQLITE_OK)
                 && (sqlite3_bind_int64(update, 3, entry->id) == SQLITE_OK)) {
             for (i=0; i<file_count && result; i++) {
@@ -1175,7 +1038,7 @@
     int i;
     sqlite3_stmt* stmt = NULL;
     char* query = "UPDATE registry.files SET active=0 WHERE actual_path=? AND id=?";
-    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_int64(stmt, 2, entry->id) == SQLITE_OK)) {
         for (i=0; i<file_count && result; i++) {
             if (sqlite3_bind_text(stmt, 1, files[i], -1, SQLITE_STATIC)
@@ -1229,7 +1092,7 @@
 int reg_entry_dependents(reg_entry* entry, reg_entry*** dependents,
         reg_error* errPtr) {
     reg_registry* reg = entry->reg;
-    char* query = sqlite3_mprintf("SELECT dependent.id FROM ports port "
+    char* query = sqlite3_mprintf("SELECT dependencies.id FROM ports port "
             "INNER JOIN dependencies USING(name) INNER JOIN ports dependent "
             "USING(id) WHERE port.id=%lld ORDER BY dependent.name,"
             "dependent.epoch, dependent.version, dependent.revision,"
@@ -1276,7 +1139,7 @@
     int result = 0;
     sqlite3_stmt* stmt = NULL;
     char* query = "INSERT INTO registry.dependencies (id, name) VALUES (?,?)";
-    if ((sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
             && (sqlite3_bind_int64(stmt, 1, entry->id) == SQLITE_OK)
             && (sqlite3_bind_text(stmt, 2, name, -1, SQLITE_STATIC)
                 == SQLITE_OK)) {

Modified: branches/new-help-system/base/src/cregistry/entry.h
===================================================================
--- branches/new-help-system/base/src/cregistry/entry.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/cregistry/entry.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,6 +3,7 @@
  * $Id$
  *
  * Copyright (c) 2007 Chris Pickel <sfiera at macports.org>
+ * Copyright (c) 2012 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,12 +37,6 @@
 
 #include <sqlite3.h>
 
-typedef enum {
-    reg_strategy_exact = 1,
-    reg_strategy_glob = 2,
-    reg_strategy_regexp = 3
-} reg_strategy;
-
 typedef struct {
     sqlite_int64 id; /* rowid in database */
     reg_registry* reg; /* associated registry */

Copied: branches/new-help-system/base/src/cregistry/file.c (from rev 90355, trunk/base/src/cregistry/file.c)
===================================================================
--- branches/new-help-system/base/src/cregistry/file.c	                        (rev 0)
+++ branches/new-help-system/base/src/cregistry/file.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,353 @@
+/*
+ * file.c
+ * vim:tw=80:expandtab
+ * $Id$
+ *
+ * Copyright (c) 2011 Clemens Lang <cal at macports.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "file.h"
+#include "util.h"
+#include "registry.h"
+#include "sql.h"
+
+#include <sqlite3.h>
+#include <stdlib.h>
+#include <string.h>
+
+/**
+ * Converts a `sqlite3_stmt` into a `reg_file`. The first column of the stmt's
+ * row must be the id of a file; the second column must be the path of a file;
+ * the third either `SQLITE_NULL` or the address of the entry in memory.
+ *
+ * @param [in] userdata sqlite3 database
+ * @param [out] file    file described by `stmt`
+ * @param [in] stmt     `sqlite3_stmt` with appropriate columns
+ * @param [out] errPtr  unused
+ * @return              true if success; false if failure
+ */
+static int reg_stmt_to_file(void* userdata, void** file, void* stmt,
+        void* calldata UNUSED, reg_error* errPtr UNUSED) {
+    int is_new;
+    reg_registry* reg = (reg_registry*)userdata;
+    reg_file_pk key;
+    Tcl_HashEntry* hash;
+    char* hashkey;
+
+    key.id = sqlite3_column_int64(stmt, 0);
+    key.path = strdup((const char*) sqlite3_column_text(stmt, 1));
+    if (!key.path) {
+        return 0;
+    }
+
+    hashkey = sqlite3_mprintf("%lld:%s", key.id, key.path);
+    if (!hashkey) {
+        free(key.path);
+        return 0;
+    }
+    hash = Tcl_CreateHashEntry(&reg->open_files,
+            hashkey, &is_new);
+    sqlite3_free(hashkey);
+
+    if (is_new) {
+        reg_file* f = malloc(sizeof(reg_file));
+        if (!f) {
+            free(key.path);
+            return 0;
+        }
+        f->reg = reg;
+        f->key = key;
+        f->proc = NULL;
+        *file = f;
+        Tcl_SetHashValue(hash, f);
+    } else {
+        free(key.path);
+        *file = Tcl_GetHashValue(hash);
+    }
+    return 1;
+}
+
+/**
+ * Opens an existing file in the registry.
+ *
+ * @param [in] reg      registry to open entry in
+ * @param [in] id       port id in the dabatase
+ * @param [in] path     file path in the database
+ * @param [out] errPtr  on error, a description of the error that occures
+ * @return              the file if success, NULL if failure
+ */
+reg_file* reg_file_open(reg_registry* reg, char* id, char* name,
+        reg_error* errPtr) {
+    sqlite3_stmt* stmt = NULL;
+    reg_file* file = NULL;
+    char* query = "SELECT id, path FROM registry.files WHERE id=? AND path=?";
+    int lower_bound = 0;
+
+    if ((sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK)
+            && (sqlite3_bind_text(stmt, 1, id, -1, SQLITE_STATIC)
+                == SQLITE_OK)
+            && (sqlite3_bind_text(stmt, 2, name, -1, SQLITE_STATIC)
+                == SQLITE_OK)) {
+        int r;
+        do {
+            r = sqlite3_step(stmt);
+            switch (r) {
+                case SQLITE_ROW:
+                    reg_stmt_to_file(reg, (void**)&file, stmt, &lower_bound,
+                            errPtr);
+                    break;
+                case SQLITE_DONE:
+                    errPtr->code = REG_NOT_FOUND;
+                    errPtr->description = sqlite3_mprintf("no matching file found for: "
+                            "id=%s, name=%s", id, name);
+                    errPtr->free = (reg_error_destructor*) sqlite3_free;
+                    break;
+                case SQLITE_BUSY:
+                    continue;
+                default:
+                    reg_sqlite_error(reg->db, errPtr, query);
+                    break;
+            }
+        } while (r == SQLITE_BUSY);
+    } else {
+        reg_sqlite_error(reg->db, errPtr, query);
+    }
+    if (stmt) {
+        sqlite3_finalize(stmt);
+    }
+    return file;
+}
+
+/**
+ * Type-safe version of `reg_all_objects` for `reg_file`.
+ *
+ * @param [in] reg       registry to select entries from
+ * @param [in] query     the select query to execute
+ * @param [in] query_len length of the query (or -1 for automatic)
+ * @param [out] objects  the files selected
+ * @param [out] errPtr   on error, a description of the error that occurred
+ * @return               the number of entries if success; negative if failure
+ */
+static int reg_all_files(reg_registry* reg, char* query, int query_len,
+        reg_file*** objects, reg_error* errPtr) {
+    int lower_bound = 0;
+    return reg_all_objects(reg, query, query_len, (void***)objects,
+            reg_stmt_to_file, &lower_bound, NULL, errPtr);
+}
+
+/**
+ * Searches the registry for files for which each key's value is equal to the
+ * given value. To find all files, pass a key_count of 0.
+ *
+ * Bad keys should cause sqlite3 errors but not permit SQL injection attacks.
+ * Pass it good keys anyway.
+ *
+ * @param [in] reg       registry to search in
+ * @param [in] keys      a list of keys to search by
+ * @param [in] vals      a list of values to search by, matching keys
+ * @param [in] strats    a list of strategies to use when searching
+ * @param [in] key_count the number of key/value pairs passed
+ * @param [out] files    a list of matching files
+ * @param [out] errPtr   on error, a description of the error that occurred
+ * @return               the number of entries if success; false if failure
+ */
+int reg_file_search(reg_registry* reg, char** keys, char** vals, int* strats,
+        int key_count, reg_file*** files, reg_error* errPtr) {
+    int i;
+    char* kwd = " WHERE ";
+    char* query;
+    size_t query_len, query_space;
+    int result;
+
+    /* build the query */
+    query = strdup("SELECT id, path FROM registry.files");
+    if (!query) {
+        return -1;
+    }
+    query_len = query_space = strlen(query);
+
+    for (i = 0; i < key_count; i++) {
+        char* op;
+        char* cond;
+
+        /* get the strategy */
+        if ((op = reg_strategy_op(strats[i], errPtr)) == NULL) {
+            free(query);
+            return -1;
+        }
+
+        cond = sqlite3_mprintf(op, keys[i], vals[i]);
+        if (!cond || !reg_strcat(&query, &query_len, &query_space, kwd)
+            || !reg_strcat(&query, &query_len, &query_space, cond)) {
+            free(query);
+            return -1;
+        }
+        sqlite3_free(cond);
+        kwd = " AND ";
+    }
+
+    /* do the query */
+    result = reg_all_files(reg, query, -1, files, errPtr);
+    free(query);
+    return result;
+}
+
+/**
+ * Gets a named property of a file. That property can be set using
+ * `reg_file_propset`. The property named must be one that exists in the table
+ * and must not be one with internal meaning such as `id`.
+ *
+ * @param [in] file    file to get property from
+ * @param [in] key     property to get
+ * @param [out] value  the value of the property
+ * @param [out] errPtr on error, a description of the error that occurred
+ * @return             true if success; false if failure
+ */
+int reg_file_propget(reg_file* file, char* key, char** value,
+        reg_error* errPtr) {
+    reg_registry* reg = file->reg;
+    int result = 0;
+    sqlite3_stmt* stmt = NULL;
+    char* query;
+    const char *text;
+    query = sqlite3_mprintf("SELECT %q FROM registry.files WHERE id=%lld "
+            "AND path='%q'", key, file->key.id, file->key.path);
+    if (sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
+        int r;
+        do {
+            r = sqlite3_step(stmt);
+            switch (r) {
+                case SQLITE_ROW:
+                    text = (const char*)sqlite3_column_text(stmt, 0);
+                    if (text) {
+                        *value = strdup(text);
+                        result = 1;
+                    } else {
+                        reg_sqlite_error(reg->db, errPtr, query);
+                    }
+                    break;
+                case SQLITE_DONE:
+                    errPtr->code = REG_INVALID;
+                    errPtr->description = "an invalid file was passed";
+                    errPtr->free = NULL;
+                    break;
+                case SQLITE_BUSY:
+                    continue;
+                default:
+                    reg_sqlite_error(reg->db, errPtr, query);
+                    break;
+            }
+        } while (r == SQLITE_BUSY);
+    } else {
+        reg_sqlite_error(reg->db, errPtr, query);
+    }
+    if (stmt) {
+        sqlite3_finalize(stmt);
+    }
+    sqlite3_free(query);
+    return result;
+}
+
+/**
+ * Sets a named property of a file. That property can be later retrieved using
+ * `reg_file_propget`. The property named must be one that exists in the table
+ * and must not be one with internal meaning such as `id`.
+ *
+ * @param [in] file    file to set property for
+ * @param [in] key     property to set
+ * @param [in] value   the desired value of the property
+ * @param [out] errPtr on error, a description of the error that occurred
+ * @return             true if success; false if failure
+ */
+int reg_file_propset(reg_file* file, char* key, char* value,
+        reg_error* errPtr) {
+    reg_registry* reg = file->reg;
+    int result = 0;
+    sqlite3_stmt* stmt = NULL;
+    char* query;
+    query = sqlite3_mprintf("UPDATE registry.files SET %q = '%q' WHERE id=%lld "
+            "AND path='%q'", key, value, file->key.id, file->key.path);
+    if (sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
+        int r;
+        do {
+            r = sqlite3_step(stmt);
+            switch (r) {
+                case SQLITE_DONE:
+                    result = 1;
+                    break;
+                case SQLITE_BUSY:
+                    continue;
+                default:
+                    if (sqlite3_reset(stmt) == SQLITE_CONSTRAINT) {
+                        errPtr->code = REG_CONSTRAINT;
+                        errPtr->description = "a constraint was disobeyed";
+                        errPtr->free = NULL;
+                    } else {
+                        reg_sqlite_error(reg->db, errPtr, query);
+                    }
+                    break;
+            }
+        } while (r == SQLITE_BUSY);
+    } else {
+        reg_sqlite_error(reg->db, errPtr, query);
+    }
+    if (stmt) {
+        sqlite3_finalize(stmt);
+    }
+    sqlite3_free(query);
+    return result;
+}
+
+/**
+ * Fetches a list of all open files
+ *
+ * @param [in] reg      registry to fetch files from
+ * @param [out] files   a list of open files
+ * @return              the number of open entries, -1 on error
+ */
+int reg_all_open_files(reg_registry* reg, reg_file*** files) {
+    reg_file* file;
+    int file_count = 0;
+    int file_space = 10;
+    Tcl_HashEntry* hash;
+    Tcl_HashSearch search;
+    *files = malloc(10 * sizeof(void*));
+    if (!*files) {
+        return -1;
+    }
+    for (hash = Tcl_FirstHashEntry(&reg->open_files, &search); hash != NULL;
+            hash = Tcl_NextHashEntry(&search)) {
+        file = Tcl_GetHashValue(hash);
+        if (!reg_listcat((void***)files, &file_count, &file_space, file)) {
+            free(*files);
+            return -1;
+        }
+    }
+    return file_count;
+}
+

Copied: branches/new-help-system/base/src/cregistry/file.h (from rev 90355, trunk/base/src/cregistry/file.h)
===================================================================
--- branches/new-help-system/base/src/cregistry/file.h	                        (rev 0)
+++ branches/new-help-system/base/src/cregistry/file.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,66 @@
+/*
+ * file.h
+ * vim:tw=80:expandtab
+ * $Id$
+ *
+ * Copyright (c) 2011 Clemens Lang <cal at macports.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+#ifndef _CFILE_H
+#define _CFILE_H
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "registry.h"
+
+#include <sqlite3.h>
+
+typedef struct {
+    /* rowid and path form the primary key */
+    /* unfortunately, we don't have a surrogate key in this db */
+    sqlite_int64 id; /* rowid in the database */
+    char* path; /* path in the database */
+} reg_file_pk;
+
+typedef struct {
+    reg_file_pk key;
+    reg_registry* reg; /* associated registry */
+    char* proc; /* name of Tcl proc, if using Tcl */
+} reg_file;
+
+reg_file* reg_file_open(reg_registry* reg, char* id, char* path,
+        reg_error* errPtr);
+
+int reg_file_search(reg_registry* reg, char** keys, char** vals, int* strats,
+        int key_count, reg_file*** files, reg_error* errPtr);
+
+int reg_file_propget(reg_file* file, char* key, char** value,
+        reg_error* errPtr);
+int reg_file_propset(reg_file* file, char* key, char* value,
+        reg_error* errPtr);
+
+int reg_all_open_files(reg_registry* reg, reg_file*** files);
+
+#endif /* _CFILE_H */

Modified: branches/new-help-system/base/src/cregistry/registry.c
===================================================================
--- branches/new-help-system/base/src/cregistry/registry.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/cregistry/registry.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,8 +1,10 @@
 /*
  * registry.c
  * $Id$
+ * vim:expandtab:tw=80
  *
  * Copyright (c) 2007 Chris Pickel <sfiera at macports.org>
+ * Copyright (c) 2012 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -31,6 +33,7 @@
 #endif
 
 #include "entry.h"
+#include "file.h"
 #include "sql.h"
 
 #include <stdio.h>
@@ -109,6 +112,12 @@
         return 0;
     }
     if (sqlite3_open(NULL, &reg->db) == SQLITE_OK) {
+        /* Enable extended result codes, requires SQLite >= 3.3.8
+         * Check added for compatibility with Tiger. */
+#if SQLITE_VERSION_NUMBER >= 3003008
+        sqlite3_extended_result_codes(reg->db, 1);
+#endif
+
         if (init_db(reg->db, errPtr)) {
             reg->status = reg_none;
             *regPtr = reg;
@@ -187,10 +196,8 @@
             if (!(sb.st_mode & S_IWGRP)) {
                 can_write = 0;
             }
-        } else {
-            if (!(sb.st_mode & S_IWOTH)) {
-                can_write = 0;
-            }
+        } else if (!(sb.st_mode & S_IWOTH) && getuid() != 0) {
+            can_write = 0;
         }
     }
     if (initialized || can_write) {
@@ -198,7 +205,7 @@
         char* query = sqlite3_mprintf("ATTACH DATABASE '%q' AS registry", path);
         int r;
         do {
-            r = sqlite3_prepare(reg->db, query, -1, &stmt, NULL);
+            r = sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL);
         } while (r == SQLITE_BUSY);
         if (r == SQLITE_OK) {
             /* XXX: Busy waiting, consider using sqlite3_busy_handler/timeout */
@@ -210,6 +217,8 @@
                         if (initialized || (create_tables(reg->db, errPtr))) {
                             Tcl_InitHashTable(&reg->open_entries,
                                     sizeof(sqlite_int64)/sizeof(int));
+                            Tcl_InitHashTable(&reg->open_files,
+                                    TCL_STRING_KEYS);
                             reg->status |= reg_attached;
                             result = 1;
                         }
@@ -220,6 +229,13 @@
                         reg_sqlite_error(reg->db, errPtr, query);
                 }
             } while (r == SQLITE_BUSY);
+
+            sqlite3_finalize(stmt);
+            stmt = NULL;
+
+            if (result) {
+                result &= update_db(reg->db, errPtr);
+            }
         } else {
             reg_sqlite_error(reg->db, errPtr, query);
         }
@@ -251,7 +267,7 @@
         reg_throw(errPtr,REG_MISUSE,"no database is attached to this registry");
         return 0;
     }
-    if (sqlite3_prepare(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
+    if (sqlite3_prepare_v2(reg->db, query, -1, &stmt, NULL) == SQLITE_OK) {
         int r;
         reg_entry* entry;
         Tcl_HashEntry* curr;
@@ -271,6 +287,15 @@
                         free(entry);
                     }
                     Tcl_DeleteHashTable(&reg->open_entries);
+                    for (curr = Tcl_FirstHashEntry(&reg->open_files, &search);
+                            curr != NULL; curr = Tcl_NextHashEntry(&search)) {
+                        reg_file* file = Tcl_GetHashValue(curr);
+
+                        free(file->proc);
+                        free(file->key.path);
+                        free(file);
+                    }
+                    Tcl_DeleteHashTable(&reg->open_files);
                     reg->status &= ~reg_attached;
                     result = 1;
                     break;
@@ -350,7 +375,7 @@
 /**
  * Helper function for `reg_commit` and `reg_rollback`.
  */
-static int reg_end(reg_registry* reg, const char* query, reg_error* errPtr) {
+static int reg_end(reg_registry* reg, const char* query, reg_error* errPtr, int is_rollback) {
     if (!(reg->status & reg_transacting)) {
         reg_throw(errPtr, REG_MISUSE, "couldn't end transaction because no "
                 "transaction is open");
@@ -362,7 +387,7 @@
             if (r == SQLITE_OK) {
                 return 1;
             }
-        } while (r == SQLITE_BUSY);
+        } while (r == SQLITE_BUSY && !is_rollback);
         reg_sqlite_error(reg->db, errPtr, NULL);
         return 0;
     }
@@ -377,7 +402,7 @@
  * @return             true if success; false if failure
  */
 int reg_commit(reg_registry* reg, reg_error* errPtr) {
-    if (reg_end(reg, "COMMIT", errPtr)) {
+    if (reg_end(reg, "COMMIT", errPtr, 0)) {
         reg->status &= ~(reg_transacting | reg_can_write);
         return 1;
     } else {
@@ -394,7 +419,7 @@
  * @return             true if success; false if failure
  */
 int reg_rollback(reg_registry* reg, reg_error* errPtr) {
-    if (reg_end(reg, "ROLLBACK", errPtr)) {
+    if (reg_end(reg, "ROLLBACK", errPtr, 1)) {
         reg->status &= ~(reg_transacting | reg_can_write);
         return 1;
     } else {
@@ -425,7 +450,7 @@
         return 0;
     }
 
-    if (sqlite3_prepare(db, "VACUUM", -1, &stmt, NULL) == SQLITE_OK) {
+    if (sqlite3_prepare_v2(db, "VACUUM", -1, &stmt, NULL) == SQLITE_OK) {
         int r;
         /* XXX: Busy waiting, consider using sqlite3_busy_handler/timeout */
         do {

Modified: branches/new-help-system/base/src/cregistry/registry.h
===================================================================
--- branches/new-help-system/base/src/cregistry/registry.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/cregistry/registry.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,8 +1,10 @@
 /*
  * registry.h
+ * vim:tw=80:expandtab
  * $Id$
  *
  * Copyright (c) 2007 Chris Pickel <sfiera at macports.org>
+ * Copyright (c) 2012 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -56,7 +58,7 @@
 void reg_throw(reg_error* errPtr, char* code, char* fmt, ...);
 
 typedef int (cast_function)(void* userdata, void** dst, void* src,
-        reg_error* errPtr);
+        void* calldata, reg_error* errPtr);
 typedef void (free_function)(void* userdata, void* item);
 
 enum {
@@ -70,6 +72,7 @@
     sqlite3* db;
     int status;
     Tcl_HashTable open_entries;
+    Tcl_HashTable open_files;
 } reg_registry;
 
 int reg_open(reg_registry** regPtr, reg_error* errPtr);

Modified: branches/new-help-system/base/src/cregistry/sql.c
===================================================================
--- branches/new-help-system/base/src/cregistry/sql.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/cregistry/sql.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,6 +3,7 @@
  * $Id$
  *
  * Copyright (c) 2007 Chris Pickel <sfiera at macports.org>
+ * Copyright (c) 2012 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -34,8 +35,9 @@
 #include "sql.h"
 #include "vercomp.h"
 
+#include <sqlite3.h>
+#include <string.h>
 #include <tcl.h>
-#include <sqlite3.h>
 #include <time.h>
 
 /**
@@ -50,19 +52,38 @@
  */
 int do_queries(sqlite3* db, char** queries, reg_error* errPtr) {
     char** query;
+    sqlite3_stmt* stmt = NULL;
+    int r = SQLITE_OK;
+
     for (query = queries; *query != NULL; query++) {
-        sqlite3_stmt* stmt = NULL;
-        if ((sqlite3_prepare(db, *query, -1, &stmt, NULL) != SQLITE_OK)
-                || (sqlite3_step(stmt) != SQLITE_DONE)) {
-            reg_sqlite_error(db, errPtr, *query);
-            if (stmt) {
-                sqlite3_finalize(stmt);
-            }
-            return 0;
+        if ((r = sqlite3_prepare_v2(db, *query, -1, &stmt, NULL)) != SQLITE_OK) {
+            sqlite3_finalize(stmt);
+            break;
         }
+
+        do {
+            r = sqlite3_step(stmt);
+        } while (r == SQLITE_BUSY);
+
         sqlite3_finalize(stmt);
+
+        /* Either execution succeeded and r == SQLITE_DONE | SQLITE_ROW, or there was an error */
+        if (r != SQLITE_DONE && r != SQLITE_ROW) {
+            /* stop executing statements in case of errors */
+            break;
+        }
     }
-    return 1;
+
+    switch (r) {
+        case SQLITE_OK:
+        case SQLITE_DONE:
+        case SQLITE_ROW:
+            return 1;
+        default:
+            /* handle errors */
+            reg_sqlite_error(db, errPtr, *query);
+            return 0;
+    }
 }
 
 /**
@@ -108,7 +129,7 @@
 
         /* metadata table */
         "CREATE TABLE registry.metadata (key UNIQUE, value)",
-        "INSERT INTO registry.metadata (key, value) VALUES ('version', 1.000)",
+        "INSERT INTO registry.metadata (key, value) VALUES ('version', 1.100)",
         "INSERT INTO registry.metadata (key, value) VALUES ('created', strftime('%s', 'now'))",
 
         /* ports table */
@@ -130,11 +151,12 @@
 
         /* file map */
         "CREATE TABLE registry.files (id INTEGER, path TEXT, actual_path TEXT, "
-            "active INT, mtime DATETIME, md5sum TEXT, editable INT, "
+            "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)",
+        "CREATE INDEX registry.file_binary ON files(binary)",
 
         /* dependency map */
         "CREATE TABLE registry.dependencies (id INTEGER, name TEXT, variants TEXT, "
@@ -148,6 +170,152 @@
 }
 
 /**
+ * Tries to ROLLBACK a currently running transaction on the SQLite database.
+ * Errors are silently ignored to preserve errors that have been set before and
+ * are probably the root cause of why we did the rollback in the first place.
+ *
+ * @param [in] db    database to rollback
+ * @return           true if success, false on failure
+ */
+static int rollback_db(sqlite3* db) {
+    char* rollback = "ROLLBACK";
+    sqlite3_stmt* stmt = NULL;
+
+    /*puts("Attempting to ROLLBACK...");*/
+
+    if (sqlite3_prepare_v2(db, rollback, -1, &stmt, NULL) != SQLITE_OK) {
+        /*printf("failed prepare: %d: %s\n", sqlite3_errcode(db), sqlite3_errmsg(db));*/
+        return 0;
+    }
+
+    if (sqlite3_step(stmt) != SQLITE_DONE) {
+        /*printf("failed step: %d: %s\n", sqlite3_errcode(db), sqlite3_errmsg(db));*/
+        return 0;
+    }
+
+    /*puts("success.");*/
+
+    return 1;
+}
+
+/**
+ * Updates the database if necessary. This function queries the current database version
+ * from the metadata table and executes SQL to update the schema to newer versions if needed.
+ * After that, this function updates the database version number
+ *
+ * @param [in] db      database to update
+ * @param [out] errPtr on error, a description of the error that occurred
+ * @return             true if success; false if failure
+ */
+int update_db(sqlite3* db, reg_error* errPtr) {
+    const char* version;
+    int r;
+    int did_update = 0; /* true, if an update was done and the loop should be run again */
+    char* q_begin = "BEGIN";
+    char* q_version = "SELECT value FROM registry.metadata WHERE key = 'version'";
+    char* query = q_begin;
+    sqlite3_stmt* stmt = NULL;
+
+    do {
+        did_update = 0;
+
+        /* open a transaction to prevent a check-and-change race condition between
+         * multiple port(1) instances */
+        if ((r = sqlite3_prepare_v2(db, query, -1, &stmt, NULL)) != SQLITE_OK) {
+            break;
+        }
+
+        if ((r = sqlite3_step(stmt)) != SQLITE_DONE) {
+            break;
+        }
+
+        sqlite3_finalize(stmt);
+        stmt = NULL;
+
+        /* query current version number */
+        query = q_version;
+        if ((r = sqlite3_prepare_v2(db, query, -1, &stmt, NULL)) != SQLITE_OK) {
+            break;
+        }
+
+        r = sqlite3_step(stmt);
+        if (r == SQLITE_DONE) {
+            /* the version number was not found */
+            reg_throw(errPtr, REG_INVALID, "Version number in metadata table not found.");
+            sqlite3_finalize(stmt);
+            rollback_db(db);
+            return 0;
+        }
+        if (r != SQLITE_ROW) {
+            /* an error occured querying */
+            break;
+        }
+        if (NULL == (version = (const char *)sqlite3_column_text(stmt, 0))) {
+            reg_throw(errPtr, REG_INVALID, "Version number in metadata table is NULL.");
+            sqlite3_finalize(stmt);
+            rollback_db(db);
+            return 0;
+        }
+
+        /* we can't call rpm_vercomp 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[] = {
+                "ALTER TABLE registry.files ADD COLUMN binary BOOL",
+                "CREATE INDEX registry.file_binary ON files(binary)",
+
+                "UPDATE registry.metadata SET value = '1.100' WHERE key = 'version'",
+
+                "COMMIT",
+                NULL
+            };
+
+            /* don't forget to finalize the version query here, or it might
+             * cause "cannot commit transaction - SQL statements in progress",
+             * see #32686 */
+            sqlite3_finalize(stmt);
+            stmt = NULL;
+
+            if (!do_queries(db, version_1_1_queries, errPtr)) {
+                rollback_db(db);
+                return 0;
+            }
+
+            did_update = 1;
+            continue;
+        }
+
+        /* add new versions here, but remember to:
+         *  - finalize the version query statement and set stmt to NULL
+         *  - do _not_ use "BEGIN" in your query list, since a transaction has
+         *    already been started for you
+         *  - end your query list with "COMMIT", NULL
+         *  - set did_update = 1 and continue;
+         */
+
+        /* if we arrive here, no update was done and we should end the
+         * transaction. Using ROLLBACK here causes problems when rolling back
+         * other transactions later in the program. */
+        sqlite3_finalize(stmt);
+        stmt = NULL;
+        r = sqlite3_exec(db, "COMMIT", NULL, NULL, NULL);
+    } while (did_update);
+
+    sqlite3_finalize(stmt);
+    switch (r) {
+        case SQLITE_OK:
+        case SQLITE_DONE:
+        case SQLITE_ROW:
+            return 1;
+        default:
+            reg_sqlite_error(db, errPtr, query);
+            return 0;
+    }
+}
+
+/**
  * Initializes database connection. This function creates all the temporary
  * tables used by the registry. It also registers the user functions and
  * collations declared here, making them available.

Modified: branches/new-help-system/base/src/cregistry/sql.h
===================================================================
--- branches/new-help-system/base/src/cregistry/sql.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/cregistry/sql.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,6 +3,7 @@
  * $Id$
  *
  * Copyright (c) 2007 Chris Pickel <sfiera at macports.org>
+ * Copyright (c) 2012 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,5 +39,6 @@
 
 int create_tables(sqlite3* db, reg_error* errPtr);
 int init_db(sqlite3* db, reg_error* errPtr);
+int update_db(sqlite3* db, reg_error* errPtr);
 
 #endif /* _SQL_H */

Copied: branches/new-help-system/base/src/cregistry/util.c (from rev 90355, trunk/base/src/cregistry/util.c)
===================================================================
--- branches/new-help-system/base/src/cregistry/util.c	                        (rev 0)
+++ branches/new-help-system/base/src/cregistry/util.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,183 @@
+/*
+ * util.c
+ * vim:tw=80:expandtab
+ * $Id$
+ *
+ * Copyright (c) 2007 Chris Pickel <sfiera at macports.org>
+ * Copyright (c) 2012 The MacPorts Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#include "util.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+/**
+ * Concatenates `src` to string `dst`. Simple concatenation. Only guaranteed to
+ * work with strings that have been allocated with `malloc`. Amortizes cost of
+ * expanding string buffer for O(N) concatenation and such. Uses `memcpy` in
+ * favor of `strcpy` in hopes it will perform a bit better.
+ *
+ * @param [in,out] dst       a reference to a null-terminated string
+ * @param [in,out] dst_len   number of characters currently in `dst`
+ * @param [in,out] dst_space number of characters `dst` can hold
+ * @param [in] src           string to concatenate to `dst`
+ */
+int reg_strcat(char** dst, size_t* dst_len, size_t* dst_space, char* src) {
+    size_t src_len = strlen(src);
+    size_t result_len = *dst_len + src_len;
+    if (result_len > *dst_space) {
+        char* new_dst;
+        *dst_space *= 2;
+        if (*dst_space < result_len) {
+            *dst_space = result_len;
+        }
+        new_dst = realloc(*dst, *dst_space * sizeof(char) + 1);
+        if (!new_dst)
+            return 0;
+        else
+            *dst = new_dst;
+    }
+    memcpy(*dst + *dst_len, src, src_len+1);
+    *dst_len = result_len;
+    return 1;
+}
+
+/**
+ * Appends element `src` to the list `dst`. It's like `reg_strcat`, except `src`
+ * represents a single element and not a sequence of `char`s.
+ *
+ * @param [in,out] dst       a reference to a list of pointers
+ * @param [in,out] dst_len   number of elements currently in `dst`
+ * @param [in,out] dst_space number of elements `dst` can hold
+ * @param [in] src           elements to append to `dst`
+ */
+int reg_listcat(void*** dst, int* dst_len, int* dst_space, void* src) {
+    if (*dst_len == *dst_space) {
+        void** new_dst;
+        *dst_space *= 2;
+        new_dst = realloc(*dst, *dst_space * sizeof(void*));
+        if (!new_dst)
+            return 0;
+        else
+            *dst = new_dst;
+    }
+    (*dst)[*dst_len] = src;
+    (*dst_len)++;
+    return 1;
+}
+
+/**
+ * Returns an expression to use for the given strategy. This should be passed as
+ * the `fmt` argument of `sqlite3_mprintf`, with the key and value following.
+ *
+ * @param [in] strategy a strategy (one of the `reg_strategy_*` constants)
+ * @param [out] errPtr  on error, a description of the error that occurred
+ * @return              a sqlite3 expression if success; NULL if failure
+ */
+char* reg_strategy_op(reg_strategy strategy, reg_error* errPtr) {
+    switch (strategy) {
+        case reg_strategy_exact:
+            return "%q = '%q'";
+        case reg_strategy_glob:
+            return "%q GLOB '%q'";
+        case reg_strategy_regexp:
+            return "REGEXP(%q, '%q')";
+        case reg_strategy_null:
+            return "%q IS NULL";
+        default:
+            errPtr->code = REG_INVALID;
+            errPtr->description = "invalid matching strategy specified";
+            errPtr->free = NULL;
+            return NULL;
+    }
+}
+
+/**
+ * Convenience method for returning all objects of a given type from the
+ * registry.
+ *
+ * @param [in] reg       registry to select objects from
+ * @param [in] query     the select query to execute
+ * @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 [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
+ */
+int reg_all_objects(reg_registry* reg, char* query, int query_len,
+        void*** objects, cast_function* fn, void* castcalldata,
+        free_function* del, reg_error* errPtr) {
+    void** results = malloc(10*sizeof(void*));
+    int result_count = 0;
+    int result_space = 10;
+    sqlite3_stmt* stmt = NULL;
+    if (!results || !fn) {
+        return -1;
+    }
+    if (sqlite3_prepare_v2(reg->db, query, query_len, &stmt, NULL) == SQLITE_OK) {
+        int r;
+        void* row;
+        do {
+            r = sqlite3_step(stmt);
+            switch (r) {
+                case SQLITE_ROW:
+                    if (fn(reg, &row, stmt, castcalldata, errPtr)) {
+                        if (!reg_listcat(&results, &result_count, &result_space, row)) {
+                            r = SQLITE_ERROR;
+                        }
+                    } else {
+                        r = SQLITE_ERROR;
+                    }
+                    break;
+                case SQLITE_DONE:
+                    break;
+                case SQLITE_BUSY:
+                    continue;
+                default:
+                    reg_sqlite_error(reg->db, errPtr, query);
+                    break;
+            }
+        } while (r == SQLITE_ROW || r == SQLITE_BUSY);
+        sqlite3_finalize(stmt);
+        if (r == SQLITE_DONE) {
+            *objects = results;
+            return result_count;
+        } else if (del) {
+            int i;
+            for (i=0; i<result_count; i++) {
+                del(NULL, results[i]);
+            }
+        }
+    } else {
+        if (stmt) {
+            sqlite3_finalize(stmt);
+        }
+        reg_sqlite_error(reg->db, errPtr, query);
+    }
+    free(results);
+    return -1;
+}
+

Copied: branches/new-help-system/base/src/cregistry/util.h (from rev 90355, trunk/base/src/cregistry/util.h)
===================================================================
--- branches/new-help-system/base/src/cregistry/util.h	                        (rev 0)
+++ branches/new-help-system/base/src/cregistry/util.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,53 @@
+/*
+ * util.h
+ * vim:tw=80:expandtab
+ * $Id$
+ *
+ * Copyright (c) 2011 Clemens Lang <cal at macports.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+#ifndef _CUTIL_H
+#define _CUTIL_H
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "registry.h"
+
+typedef enum {
+    reg_strategy_exact = 1,
+    reg_strategy_glob = 2,
+    reg_strategy_regexp = 3,
+    reg_strategy_null = 4
+} reg_strategy;
+
+int reg_strcat(char** dst, size_t* dst_len, size_t* dst_space, char* src);
+int reg_listcat(void*** dst, int* dst_len, int* dst_space, void* src);
+int reg_all_objects(reg_registry* reg, char* query, int query_len,
+        void*** objects, cast_function* fn, void* castcalldata,
+        free_function* del, reg_error* errPtr);
+char* reg_strategy_op(reg_strategy strategy, reg_error* errPtr);
+
+#endif /* _CUTIL_H */
+

Modified: branches/new-help-system/base/src/cregistry/vercomp.c
===================================================================
--- branches/new-help-system/base/src/cregistry/vercomp.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/cregistry/vercomp.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -47,7 +47,7 @@
  */
 
 /**
- * RPM version comparison. Shamelessly copied from Pextlib, with some changes to
+ * EVR version comparison. Shamelessly copied from Pextlib, with some changes to
  * use string lengths instead of strlen by default. That's necessary to make it
  * work with sqlite3 collations. It should be shared with Pextlib, rather than
  * just copied though.
@@ -58,7 +58,7 @@
  * @param [in] lengthA  length of second version string, or -1 to use strlen
  * @return              -1 if A < B; 0 if A = B; 1 if A > B
  */
-static int rpm_vercomp (const char *versionA, int lengthA, const char *versionB,
+static int vercmp (const char *versionA, int lengthA, const char *versionB,
         int lengthB) {
     const char *endA, *endB;
 	const char *ptrA, *ptrB;
@@ -173,7 +173,7 @@
 
 /**
  * VERSION collation for sqlite3. This function collates text according to
- * pextlib's rpm-vercomp function. This allows direct comparison and sorting of
+ * pextlib's vercmp function. This allows direct comparison and sorting of
  * version columns, such as port.version and port.revision.
  *
  * @param [in] userdata unused
@@ -185,5 +185,5 @@
  */
 int sql_version(void* userdata UNUSED, int alen, const void* a, int blen,
         const void* b) {
-    return rpm_vercomp((const char*)a, alen, (const char*)b, blen);
+    return vercmp((const char*)a, alen, (const char*)b, blen);
 }

Modified: branches/new-help-system/base/src/darwintracelib1.0/Makefile
===================================================================
--- branches/new-help-system/base/src/darwintracelib1.0/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/darwintracelib1.0/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -6,7 +6,8 @@
 
 include ../../Mk/macports.autoconf.mk
 
-CFLAGS+= -fPIC
+CFLAGS+= -fPIC -Wno-deprecated-declarations
+CFLAGS_PEDANTIC=
 
 all:: ${SHLIB_NAME}
 

Modified: branches/new-help-system/base/src/darwintracelib1.0/darwintrace.c
===================================================================
--- branches/new-help-system/base/src/darwintracelib1.0/darwintrace.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/darwintracelib1.0/darwintrace.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2005 Apple Inc. All rights reserved.
  * Copyright (c) 2005-2006 Paul Guyot <pguyot at kallisys.net>,
  * All rights reserved.
  *
@@ -16,7 +16,7 @@
  * 2.  Redistributions in binary form must reproduce the above copyright
  *     notice, this list of conditions and the following disclaimer in the
  *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
  *     its contributors may be used to endorse or promote products derived
  *     from this software without specific prior written permission. 
  * 
@@ -38,6 +38,19 @@
 #include <config.h>
 #endif
 
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#if defined(_DARWIN_FEATURE_64_BIT_INODE) && !defined(_DARWIN_FEATURE_ONLY_64_BIT_INODE)
+/* The architecture we're building for has multiple versions of stat.
+   We need to undo sys/cdefs.h changes for _DARWIN_FEATURE_64_BIT_INODE */
+#undef  __DARWIN_64_BIT_INO_T
+#define __DARWIN_64_BIT_INO_T 0
+#undef  __DARWIN_SUF_64_BIT_INO_T
+#define __DARWIN_SUF_64_BIT_INO_T ""
+#undef _DARWIN_FEATURE_64_BIT_INODE
+#endif
+
 #ifdef HAVE_CRT_EXTERNS_H
 #include <crt_externs.h>
 #endif
@@ -150,15 +163,15 @@
 
 #if __STDC_VERSION__>=199901L
 #if DARWINTRACE_DEBUG_OUTPUT
-#define dprintf(...) fprintf(stderr, __VA_ARGS__)
+#define debug_printf(...) fprintf(stderr, __VA_ARGS__)
 #else
-#define dprintf(...)
+#define debug_printf(...)
 #endif
 #else
 #if DARWINTRACE_DEBUG_OUTPUT
 __attribute__ ((format (printf, 1, 2)))
 static inline
-int dprintf(const char *format, ...) {
+int debug_printf(const char *format, ...) {
     int ret;
     va_list args;
     va_start(args, format);
@@ -167,7 +180,7 @@
     return ret;
 }
 #else
-#define dprintf(format, param)
+#define debug_printf(format, param)
 #endif
 #endif
 
@@ -349,11 +362,11 @@
 			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)
 			{
-				dprintf("darwintrace: connect successful. socket %d\n", sock);
+				debug_printf("darwintrace: connect successful. socket %d\n", sock);
 				__darwintrace_fd=sock;
 				ask_for_filemap();
 			} else {
-				dprintf("connect failed: %s\n", strerror(errno));
+				debug_printf("connect failed: %s\n", strerror(errno));
 				abort();
 			}
 			errno = olderrno;
@@ -456,7 +469,7 @@
     }
   }
 
-  dprintf("darwintrace: cleanup resulted in %s\n", path);
+  debug_printf("darwintrace: cleanup resulted in %s\n", path);
 }
 
 /*
@@ -650,7 +663,7 @@
 		__darwintrace_setup();
 		isInSandbox = __darwintrace_is_in_sandbox(path, newpath);
 		if (isInSandbox == 0) {
-			dprintf("darwintrace: creation/writing was forbidden at %s\n", path);
+			debug_printf("darwintrace: creation/writing was forbidden at %s\n", path);
 			errno = EACCES;
 			result = -1;
 		}
@@ -796,10 +809,10 @@
 	int result = 0;
 	int isInSandbox = __darwintrace_is_in_sandbox(path, 0);
 	if (isInSandbox == 1) {
-		dprintf("darwintrace: unlink was allowed at %s\n", path);
+		debug_printf("darwintrace: unlink was allowed at %s\n", path);
 	} else if (isInSandbox == 0) {
 		/* outside sandbox, but sandbox is defined: forbid */
-		dprintf("darwintrace: unlink was forbidden at %s\n", path);
+		debug_printf("darwintrace: unlink was forbidden at %s\n", path);
 		errno = EACCES;
 		result = -1;
 	}
@@ -818,7 +831,7 @@
 	int result = 0;
 	int isInSandbox = __darwintrace_is_in_sandbox(path, 0);
 	if (isInSandbox == 1) {
-		dprintf("darwintrace: mkdir was allowed at %s\n", path);
+		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. */
@@ -827,7 +840,7 @@
 		err = lstat(path, &theInfo);
 		if ((err == -1) && (errno == ENOENT))
 		{
-			dprintf("darwintrace: mkdir was forbidden at %s\n", path);
+			debug_printf("darwintrace: mkdir was forbidden at %s\n", path);
 			errno = EACCES;
 			result = -1;
 		} /* otherwise, mkdir will do nothing (directory exists) or fail
@@ -848,10 +861,10 @@
 	int result = 0;
 	int isInSandbox = __darwintrace_is_in_sandbox(path, 0);
 	if (isInSandbox == 1) {
-		dprintf("darwintrace: rmdir was allowed at %s\n", path);
+		debug_printf("darwintrace: rmdir was allowed at %s\n", path);
 	} else if (isInSandbox == 0) {
 		/* outside sandbox, but sandbox is defined: forbid */
-		dprintf("darwintrace: removing directory %s was forbidden\n", path);
+		debug_printf("darwintrace: removing directory %s was forbidden\n", path);
 		errno = EACCES;
 		result = -1;
 	}
@@ -870,10 +883,10 @@
 	int result = 0;
 	int isInSandbox = __darwintrace_is_in_sandbox(from, 0);
 	if (isInSandbox == 1) {
-		dprintf("darwintrace: rename was allowed at %s\n", from);
+		debug_printf("darwintrace: rename was allowed at %s\n", from);
 	} else if (isInSandbox == 0) {
 		/* outside sandbox, but sandbox is defined: forbid */
-		dprintf("darwintrace: renaming from %s was forbidden\n", from);
+		debug_printf("darwintrace: renaming from %s was forbidden\n", from);
 		errno = EACCES;
 		result = -1;
 	}
@@ -881,10 +894,10 @@
 	if (result == 0) {
 		isInSandbox = __darwintrace_is_in_sandbox(to, 0);
 		if (isInSandbox == 1) {
-			dprintf("darwintrace: rename was allowed at %s\n", to);
+			debug_printf("darwintrace: rename was allowed at %s\n", to);
 		} else if (isInSandbox == 0) {
 			/* outside sandbox, but sandbox is defined: forbid */
-			dprintf("darwintrace: renaming to %s was forbidden\n", to);
+			debug_printf("darwintrace: renaming to %s was forbidden\n", to);
 			errno = EACCES;
 			result = -1;
 		}
@@ -920,9 +933,42 @@
 #undef stat
 }
 
+#if defined(__DARWIN_64_BIT_INO_T) && !defined(_DARWIN_FEATURE_ONLY_64_BIT_INODE)
+
+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);
+	}
+	
+	return result;
+#undef stat64
+}
+
+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)
 {
-#define stat(path, sb) syscall(SYS_lstat, path, sb)
+#define lstat(path, sb) syscall(SYS_lstat, path, sb)
 	int result=0;
 	char newpath[260];
 	
@@ -936,9 +982,41 @@
 		if(*newpath)
 			path=newpath;
 			
-		result=stat(path, sb);
+		result=lstat(path, sb);
 	}
 	
 	return result;
-#undef stat
+#undef lstat
 }
+
+#if defined(__DARWIN_64_BIT_INO_T) && !defined(_DARWIN_FEATURE_ONLY_64_BIT_INODE)
+
+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);
+	}
+	
+	return result;
+#undef lstat64
+}
+
+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) */

Deleted: branches/new-help-system/base/src/dep_map_clean.tcl
===================================================================
--- branches/new-help-system/base/src/dep_map_clean.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/dep_map_clean.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,21 +0,0 @@
-#!/usr/bin/env tclsh
-# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
-# $Id$
-
-# Removes any duplicate entries from the MacPorts registry's dependency map.
-# Takes one argument, which should be TCL_PACKAGE_DIR.
-
-source [file join [lindex $argv 0] macports1.0 macports_fastload.tcl]
-package require macports 1.0
-package require registry 1.0
-
-mportinit
-
-# Only the flat format had the bug which needs to be corrected
-if {${macports::registry.format} == "flat"} {
-    registry::open_dep_map
-    registry::clean_dep_map
-    registry::write_dep_map
-}
-
-exit 0

Copied: branches/new-help-system/base/src/images_to_archives.tcl (from rev 90355, trunk/base/src/images_to_archives.tcl)
===================================================================
--- branches/new-help-system/base/src/images_to_archives.tcl	                        (rev 0)
+++ branches/new-help-system/base/src/images_to_archives.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,158 @@
+#!/usr/bin/env tclsh
+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4
+# $Id$
+
+# convert existing port image directories into compressed archive versions
+# Takes one argument, which should be TCL_PACKAGE_DIR.
+
+source [file join [lindex $argv 0] macports1.0 macports_fastload.tcl]
+package require macports 1.0
+package require registry 1.0
+package require registry2 2.0
+package require Pextlib 1.0
+
+umask 022
+
+array set ui_options {ports_verbose yes}
+
+mportinit ui_options
+
+# always converting to tbz2 should be fine as both these programs are
+# needed elsewhere and assumed to be available
+set tarcmd [macports::findBinary tar ${macports::autoconf::tar_path}]
+set bzip2cmd [macports::findBinary bzip2 ${macports::autoconf::bzip2_path}]
+
+if {[catch {set ilist [registry::installed]}]} {
+    # no ports installed
+    puts "No ports installed to convert."
+    exit 0
+}
+
+puts "This could take a while..."
+
+# list of ports we successfully create an archive of, to be used to update
+# the registry only after we know all creation attempts were successful.
+set archived_list {}
+set installed_len [llength $ilist]
+set counter 0
+
+foreach installed $ilist {
+    incr counter
+    set iname [lindex $installed 0]
+    set iversion [lindex $installed 1]
+    set irevision [lindex $installed 2]
+    set ivariants [lindex $installed 3]
+    set iepoch [lindex $installed 5]
+    set iref [registry::open_entry $iname $iversion $irevision $ivariants $iepoch]
+    set installtype [registry::property_retrieve $iref installtype]
+    if {$installtype == "image"} {
+        set location [registry::property_retrieve $iref location]
+        if {$location == "0"} {
+            set location [registry::property_retrieve $iref imagedir]
+        }
+    } else {
+        set location ""
+    }
+
+    if {$location == "" || ![file isfile $location]} {
+        # no image archive present, so make one
+        set archs [registry::property_retrieve $iref archs]
+        if {$archs == "" || $archs == "0"} {
+            set archs ${macports::os_arch}
+        }
+        # look for any existing archive in the old location
+        set oldarchiverootname "${iname}-${iversion}_${irevision}${ivariants}.[join $archs -]"
+        set archivetype tbz2
+        set oldarchivedir [file join ${macports::portdbpath} packages ${macports::os_platform}_${macports::os_major}]
+        set olderarchivedir [file join ${macports::portdbpath} packages ${macports::os_platform}]
+        if {[llength $archs] == 1} {
+            set oldarchivedir [file join $oldarchivedir $archs $iname]
+            set olderarchivedir [file join $olderarchivedir $archs]
+        } else {
+            set oldarchivedir [file join $oldarchivedir universal $iname]
+            set olderarchivedir [file join $olderarchivedir universal]
+        }
+        set found 0
+        foreach adir [list $oldarchivedir $olderarchivedir] {
+            foreach type {tbz2 tbz tgz tar txz tlz xar xpkg zip cpgz cpio} {
+                set oldarchivefullpath "[file join $adir $oldarchiverootname].${type}"
+                if {[file isfile $oldarchivefullpath]} {
+                    set found 1
+                    set archivetype $type
+                    break
+                }
+            }
+            if {$found} {break}
+        }
+
+        # compute new name and location of archive
+        set archivename "${iname}-${iversion}_${irevision}${ivariants}.${macports::os_platform}_${macports::os_major}.[join $archs -].${archivetype}"
+        ui_msg "Processing ${counter} of ${installed_len}: ${archivename}"
+        if {$installtype == "image"} {
+            set targetdir [file dirname $location]
+        } else {
+            set targetdir [file join ${macports::registry.path} software ${iname}]
+            file mkdir $targetdir
+            set contents [$iref imagefiles]
+        }
+        set newlocation [file join $targetdir $archivename]
+
+        if {$found} {
+            file rename $oldarchivefullpath $newlocation
+        } elseif {$installtype == "image"} {
+            # create archive from image dir
+            system "cd $location && $tarcmd -cjf $newlocation * > ${targetdir}/error.log 2>&1"
+            file delete -force ${targetdir}/error.log
+        } else {
+            # direct mode, 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 {
+                puts $fd $entry
+            }
+            close $fd
+            system "$tarcmd -cjf $newlocation -T ${targetdir}/tarlist > ${targetdir}/error.log 2>&1"
+            file delete -force ${targetdir}/tarlist ${targetdir}/error.log
+        }
+
+        lappend archived_list [list $installtype $iref $location $newlocation]
+    }
+}
+
+set archived_len [llength $archived_list]
+set counter 0
+
+registry::write {
+    foreach archived $archived_list {
+        incr counter
+        ui_msg "Updating registry: ${counter} of ${archived_len}"
+        set installtype [lindex $archived 0]
+        set iref [lindex $archived 1]
+        set newlocation [lindex $archived 3]
+    
+        if {$installtype == "direct"} {
+            # change receipt to image
+            $iref installtype image
+            $iref state imaged
+            $iref activate [$iref imagefiles]
+            $iref state installed
+        }
+    
+        # set the new location in the registry and delete the old dir
+        $iref location $newlocation
+    }
+}
+
+set counter 0
+foreach archived $archived_list {
+    incr counter
+    set location [lindex $archived 2]
+    ui_msg "Deleting ${counter} of ${archived_len}: ${location}"
+    if {$location != "" && [file isdirectory $location]} {
+        if {[catch {file delete -force $location} result]} {
+            ui_warn "Failed to delete ${location}: $result"
+        }
+    }
+}
+
+exit 0


Property changes on: branches/new-help-system/base/src/machista1.0
___________________________________________________________________
Added: svn:ignore
   + machista.dylib
pkgIndex.tcl
Makefile


Modified: branches/new-help-system/base/src/macports1.0/Makefile
===================================================================
--- branches/new-help-system/base/src/macports1.0/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/macports1.0/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -32,11 +32,16 @@
 	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 pkgIndex.tcl ${INSTALLDIR}
 
 	echo "${TCL_PACKAGE_DIR}" > ${DESTDIR}${prefix}/var/macports/.tclpackage
-	if test -z "${DESTDIR}" && test "${INSTALLPKGLINK}" != "${INSTALLDIR}" && test -w "${TCL_PACKAGE_DIR}"; then \
-		if ! test -L "${INSTALLPKGLINK}" && test -d "${INSTALLPKGLINK}"; then \
-			rm -rf "${INSTALLPKGLINK}" || true; \
-		fi; \
-		if ! test -e "${INSTALLPKGLINK}"; then \
-			ln -s "${INSTALLDIR}" "${INSTALLPKGLINK}" || true; \
-		fi; \
+	if test -z "${DESTDIR}" -a "${INSTALLPKGLINK}" != "${INSTALLDIR}"; then \
+		if test ! -L "${INSTALLPKGLINK}"; then \
+            if test ! -e "${TCL_PACKAGE_DIR}"; then \
+                $(INSTALL) -d -o ${DSTUSR} -g ${DSTGRP} -m ${DSTMODE} "${TCL_PACKAGE_DIR}" || true; \
+            fi; \
+            if test -d "${INSTALLPKGLINK}"; then \
+                rm -vrf "${INSTALLPKGLINK}" || true; \
+            fi; \
+            if test ! -e "${INSTALLPKGLINK}"; then \
+                ln -vs "${INSTALLDIR}" "${INSTALLPKGLINK}" || true; \
+            fi; \
+        fi; \
 	fi

Modified: branches/new-help-system/base/src/macports1.0/macports.tcl
===================================================================
--- branches/new-help-system/base/src/macports1.0/macports.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/macports1.0/macports.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,10 +2,11 @@
 # macports.tcl
 # $Id$
 #
-# Copyright (c) 2002 Apple Computer, Inc.
+# Copyright (c) 2002 - 2003 Apple Inc.
 # Copyright (c) 2004 - 2005 Paul Guyot, <pguyot at kallisys.net>.
 # Copyright (c) 2004 - 2006 Ole Guldberg Jensen <olegb at opendarwin.org>.
 # Copyright (c) 2004 - 2005 Robert Shaw <rshaw at opendarwin.org>
+# Copyright (c) 2004 - 2012 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -16,7 +17,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #
@@ -41,32 +42,39 @@
     namespace export bootstrap_options user_options portinterp_options open_mports ui_priorities port_phases 
     variable bootstrap_options "\
         portdbpath libpath binpath auto_path extra_env sources_conf prefix portdbformat \
-        portinstalltype portarchivemode portarchivepath portarchivetype portautoclean \
+        portarchivetype portautoclean \
         porttrace portverbose keeplogs destroot_umask variants_conf rsync_server rsync_options \
-        rsync_dir startupitem_type place_worksymlink xcodeversion xcodebuildcmd \
-        mp_remote_url mp_remote_submit_url configureccache configuredistcc configurepipe buildnicevalue buildmakejobs \
+        rsync_dir startupitem_type startupitem_install place_worksymlink xcodeversion xcodebuildcmd \
+        mp_remote_url mp_remote_submit_url configureccache ccache_dir ccache_size configuredistcc configurepipe buildnicevalue buildmakejobs \
         applications_dir frameworks_dir developer_dir universal_archs build_arch macosx_deployment_target \
-        macportsuser proxy_override_env proxy_http proxy_https proxy_ftp proxy_rsync proxy_skip"
+        macportsuser proxy_override_env proxy_http proxy_https proxy_ftp proxy_rsync proxy_skip \
+        master_site_local patch_site_local archive_site_local buildfromsource \
+        revupgrade_autorun revupgrade_mode revupgrade_check_id_loadcmds \
+        host_blacklist preferred_hosts\
+        packagemaker_path"
     variable user_options "submitter_name submitter_email submitter_key"
     variable portinterp_options "\
         portdbpath porturl portpath portbuildpath auto_path prefix prefix_frozen portsharepath \
-        registry.path registry.format registry.installtype portarchivemode portarchivepath \
+        registry.path registry.format user_home \
         portarchivetype archivefetch_pubkeys portautoclean porttrace keeplogs portverbose destroot_umask \
-        rsync_server rsync_options rsync_dir startupitem_type place_worksymlink macportsuser \
-        mp_remote_url mp_remote_submit_url configureccache configuredistcc configurepipe buildnicevalue buildmakejobs \
+        rsync_server rsync_options rsync_dir startupitem_type startupitem_install place_worksymlink macportsuser \
+        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 $user_options"
+        os_arch os_endian os_version os_major os_platform macosx_version macosx_deployment_target \
+        packagemaker_path $user_options"
 
     # deferred options are only computed when needed.
     # they are not exported to the trace thread.
     # they are not exported to the interpreter in system_options array.
-    variable portinterp_deferred_options "xcodeversion xcodebuildcmd"
+    variable portinterp_deferred_options "xcodeversion xcodebuildcmd developer_dir"
 
     variable open_mports {}
 
     variable ui_priorities "error warn msg notice info debug any"
     variable port_phases "any fetch checksum"
     variable current_phase "main"
+
+    variable ui_prefix "---> "
 }
 
 # Provided UI instantiations
@@ -128,12 +136,12 @@
 proc macports::ch_logging {mport} {
     global ::debuglog ::debuglogname
 
-    set portname [_mportkey $mport name]
+    set portname [_mportkey $mport subport]
     set portpath [_mportkey $mport portpath]
 
     ui_debug "Starting logging for $portname"
 
-    set logname [macports::getportlogpath $portpath]
+    set logname [macports::getportlogpath $portpath $portname]
     file mkdir $logname
     set logname [file join $logname "main.log"]
 
@@ -360,7 +368,7 @@
     trace remove variable macports::xcodeversion read macports::setxcodeinfo
     trace remove variable macports::xcodebuildcmd read macports::setxcodeinfo
 
-    if {[catch {set xcodebuild [binaryInPath "xcodebuild"]}] == 0} {
+    if {![catch {findBinary xcodebuild $macports::autoconf::xcodebuild_path} xcodebuild]} {
         if {![info exists xcodeversion]} {
             # Determine xcode version
             set macports::xcodeversion "2.0orlower"
@@ -368,7 +376,13 @@
                 if {[regexp {Xcode ([0-9.]+)} $xcodebuildversion - xcode_v] == 1} {
                     set macports::xcodeversion $xcode_v
                 } elseif {[regexp "DevToolsCore-(.*);" $xcodebuildversion - devtoolscore_v] == 1} {
-                    if {$devtoolscore_v >= 921.0} {
+                    if {$devtoolscore_v >= 1809.0} {
+                        set macports::xcodeversion "3.2.6"
+                    } elseif {$devtoolscore_v >= 1204.0} {
+                        set macports::xcodeversion "3.1.4"
+                    } elseif {$devtoolscore_v >= 1100.0} {
+                        set macports::xcodeversion "3.1"
+                    } elseif {$devtoolscore_v >= 921.0} {
                         set macports::xcodeversion "3.0"
                     } elseif {$devtoolscore_v >= 798.0} {
                         set macports::xcodeversion "2.5"
@@ -406,6 +420,99 @@
     }
 }
 
+# deferred calculation of developer_dir
+proc macports::set_developer_dir {name1 name2 op} {
+    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]} {
+
+        # We have xcode-select: ask it where xcode is and check if it's valid.
+        # If no xcode is selected, xcode-select will fail, so catch that
+        if {![catch {exec $xcodeselect -print-path 2> /dev/null} devdir] &&
+            [_is_valid_developer_dir $devdir]} {
+            set macports::developer_dir $devdir
+            return
+        }
+
+        # The directory from xcode-select isn't correct.
+        
+        # Ask mdfind where Xcode is and make some suggestions for the user,
+        # 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'"] \
+                ]
+        }
+        
+        # In case mdfind metadata wasn't complete, also look in two well-known locations for Xcode.app
+        foreach app {/Applications/Xcode.app /Developer/Applications/Xcode.app} {
+            if {[file isdirectory $app]} {
+                lappend installed_xcodes $app
+            }
+        }
+        
+        # Form a list of unique xcode installations
+        set installed_xcodes [lsort -unique $installed_xcodes]
+
+        # Present instructions to the user
+        ui_error
+        if {[llength $installed_xcodes] > 0 && ![catch {findBinary mdls $macports::autoconf::mdls_path} mdls]} {
+            # One, or more than one, Xcode installations found
+            ui_error "No valid Xcode installation is properly selected."
+            ui_error "Please use xcode-select to select an Xcode installation:"
+            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"]} {
+                    ui_error "    sudo xcode-select -switch ${xcode} # version ${vers}"
+                } elseif {[_is_valid_developer_dir "${xcode}/../.."]} {
+                    ui_error "    sudo xcode-select -switch [file normalize ${xcode}/../..] # version ${vers}"
+                } else {
+                    ui_error "    # malformed Xcode at ${xcode}, version ${vers}"
+                }
+            }
+        } else {
+            ui_error "No Xcode installation was found."
+            ui_error "Please install Xcode and run xcode-select to specify its location."
+        }
+        ui_error
+    }
+
+    # Try the default
+    if {$os_major >= 11 && [vercmp $xcodeversion 4.3] >= 0} {
+        set devdir "/Applications/Xcode.app/Contents/Developer"
+    } else {
+        set devdir "/Developer"
+    }
+
+    set macports::developer_dir $devdir
+}
+
+proc macports::_is_valid_developer_dir {dir} {
+    # Check whether specified directory looks valid for an Xcode installation
+
+    # Verify that the directory exists
+    if {![file isdirectory $dir]} {
+        return 0
+    }
+
+    # Verify that the directory has some key subdirectories
+    foreach subdir {Headers Library usr} {
+        if {![file isdirectory "${dir}/${subdir}"]} {
+            return 0
+        }
+    }
+
+    # The specified directory seems valid for Xcode
+    return 1
+}
+
+
 proc mportinit {{up_ui_options {}} {up_options {}} {up_variations {}}} {
     if {$up_ui_options eq ""} {
         array set macports::ui_options {}
@@ -449,7 +556,6 @@
     global macports::prefix
     global macports::macportsuser
     global macports::prefix_frozen
-    global macports::registry.installtype
     global macports::rsync_dir
     global macports::rsync_options
     global macports::rsync_server
@@ -457,6 +563,8 @@
     global macports::xcodebuildcmd
     global macports::xcodeversion
     global macports::configureccache
+    global macports::ccache_dir
+    global macports::ccache_size
     global macports::configuredistcc
     global macports::configurepipe
     global macports::buildnicevalue
@@ -471,18 +579,13 @@
     global macports::macosx_version
     global macports::macosx_deployment_target
     global macports::archivefetch_pubkeys
+    global macports::ping_cache
+    global macports::host_blacklisted
+    global macports::host_preferred
 
     # Set the system encoding to utf-8
     encoding system utf-8
 
-    # Ensure that the macports user directory exists if HOME is defined
-    if {[info exists env(HOME)]} {
-        set macports::macports_user_dir [file normalize $macports::autoconf::macports_user_dir]
-    } else {
-        # Otherwise define the user directory as a direcotory that will never exist
-        set macports::macports_user_dir "/dev/null/NO_HOME_DIR"
-    }
-
     # set up platform info variables
     set os_arch $tcl_platform(machine)
     if {$os_arch == "Power Macintosh"} { set os_arch "powerpc" }
@@ -498,6 +601,23 @@
         set macosx_version [expr 10.0 + ($os_major - 4) / 10.0]
     }
 
+    # Ensure that the macports user directory (i.e. ~/.macports) exists if HOME is defined.
+    # Also save $HOME for later use before replacing it with our own.
+    if {[info exists env(HOME)]} {
+        set macports::user_home $env(HOME)
+        set macports::macports_user_dir [file normalize $macports::autoconf::macports_user_dir]
+    } elseif {[info exists env(SUDO_USER)] && $os_platform == "darwin"} {
+        set macports::user_home [exec dscl -q . -read /Users/$env(SUDO_USER) NFSHomeDirectory | cut -d ' ' -f 2]
+        set macports::macports_user_dir [file join ${macports::user_home} [string range $macports::autoconf::macports_user_dir 2 end]]
+    } elseif {[exec id -u] != 0 && $os_platform == "darwin"} {
+        set macports::user_home [exec dscl -q . -read /Users/[exec id -un] NFSHomeDirectory | cut -d ' ' -f 2]
+        set macports::macports_user_dir [file join ${macports::user_home} [string range $macports::autoconf::macports_user_dir 2 end]]
+    } else {
+        # Otherwise define the user directory as a directory that will never exist
+        set macports::macports_user_dir "/dev/null/NO_HOME_DIR"
+        set macports::user_home "/dev/null/NO_HOME_DIR"
+    }
+
     # Configure the search path for configuration files
     set conf_files ""
     lappend conf_files "${macports_conf_path}/macports.conf"
@@ -637,24 +757,15 @@
         }
     }
 
+    set env(HOME) [file join $portdbpath home]
     set registry.path $portdbpath
 
-    # Format for receipts, can currently be either "flat" or "sqlite"
-    if {[info exists portdbformat]} {
-        if {$portdbformat == "flat" || $portdbformat == "sqlite"} {
-            set registry.format receipt_${portdbformat}
-        } else {
-            return -code error "unknown registry format '$portdbformat' set in macports.conf"
-        }
-    } else {
+    # Format for receipts; currently only "sqlite" is allowed
+    # could previously be "flat", so we switch that to sqlite
+    if {![info exists portdbformat] || $portdbformat == "flat" || $portdbformat == "sqlite"} {
         set registry.format receipt_sqlite
-    }
-
-    # Installation type, whether to use port "images" or install "direct"
-    if {[info exists portinstalltype]} {
-        set registry.installtype $portinstalltype
     } else {
-        set registry.installtype image
+        return -code error "unknown registry format '$portdbformat' set in macports.conf"
     }
 
     # Autoclean mode, whether to automatically call clean after "install"
@@ -662,8 +773,8 @@
         set macports::portautoclean "yes"
         global macports::portautoclean
     }
-	# whether to keep logs after successful builds
-   	if {![info exists keeplogs]} {
+    # whether to keep logs after successful builds
+    if {![info exists keeplogs]} {
         set macports::keeplogs "no"
         global macports::keeplogs
     }
@@ -685,11 +796,29 @@
             set macports::porttrace $macports::global_options(ports_trace)
         }
     }
+    # Check command line override for source/binary only mode
+    if {![info exists macports::global_options(ports_binary_only)]
+        && ![info exists macports::global_options(ports_source_only)]
+        && [info exists macports::buildfromsource]} {
+        if {${macports::buildfromsource} == "never"} {
+            set macports::global_options(ports_binary_only) yes
+            set temp_options(ports_binary_only) yes
+        } elseif {${macports::buildfromsource} == "always"} {
+            set macports::global_options(ports_source_only) yes
+            set temp_options(ports_source_only) yes
+        } elseif {${macports::buildfromsource} != "ifneeded"} {
+            ui_warn "'buildfromsource' set to unknown value '${macports::buildfromsource}', using 'ifneeded' instead"
+        }
+    }
 
     # Duplicate prefix into prefix_frozen, so that port actions
     # can always get to the original prefix, even if a portfile overrides prefix
     set macports::prefix_frozen $prefix
 
+    if {![info exists macports::applications_dir]} {
+        set macports::applications_dir /Applications/MacPorts
+    }
+
     # Export verbosity.
     if {![info exists portverbose]} {
         set macports::portverbose "no"
@@ -701,36 +830,14 @@
         }
     }
 
-    # Archive mode, whether to create/use binary archive packages
-    if {![info exists portarchivemode]} {
-        set macports::portarchivemode "no"
-        global macports::portarchivemode
-    }
-
-    # Archive path, where to store/retrieve binary archive packages
-    if {![info exists portarchivepath]} {
-        set macports::portarchivepath [file join $portdbpath packages]
-        global macports::portarchivepath
-    }
-    if {$portarchivemode == "yes"} {
-        if {![file exists $portarchivepath] && [catch {file mkdir $portarchivepath} result]} {
-            ui_warn "portarchivepath $portarchivepath does not exist and could not be created; disabling archive mode"
-            set portarchivemode no
-        } elseif {![file isdirectory $portarchivepath]} {
-            return -code error "Archive dir $portarchivepath is not a directory. Please create the directory or reconfigure portarchivepath"
-        }
-    }
-
     # Archive type, what type of binary archive to use (CPIO, gzipped
     # CPIO, XAR, etc.)
+    global macports::portarchivetype
     if {![info exists portarchivetype]} {
-        set macports::portarchivetype "tgz"
-        global macports::portarchivetype
+        set macports::portarchivetype "tbz2"
+    } else {
+        set macports::portarchivetype [lindex $portarchivetype 0]
     }
-    # Convert archive type to a list for multi-archive support, colon or
-    # comma separators indicates to use multiple archive formats
-    # (reading and writing)
-    set macports::portarchivetype [split $portarchivetype {:,}]
 
     # Set rync options
     if {![info exists rsync_server]} {
@@ -738,7 +845,7 @@
         global macports::rsync_server
     }
     if {![info exists rsync_dir]} {
-        set macports::rsync_dir release/base/
+        set macports::rsync_dir release/tarballs/base.tar
         global macports::rsync_dir
     }
     if {![info exists rsync_options]} {
@@ -766,6 +873,11 @@
         set macports::startupitem_type "default"
     }
 
+    # Set whether startupitems are symlinked into system directories
+    if {![info exists macports::startupitem_install]} {
+        set macports::startupitem_install yes
+    }
+
     # Default place_worksymlink
     if {![info exists macports::place_worksymlink]} {
         set macports::place_worksymlink yes
@@ -783,6 +895,12 @@
     if {![info exists macports::configureccache]} {
         set macports::configureccache no
     }
+    if {![info exists macports::ccache_dir]} {
+        set macports::ccache_dir [file join $portdbpath build .ccache]
+    }
+    if {![info exists macports::ccache_size]} {
+        set macports::ccache_size "2G"
+    }
     if {![info exists macports::configuredistcc]} {
         set macports::configuredistcc no
     }
@@ -841,14 +959,29 @@
         set macports::macosx_deployment_target $macosx_version
     }
 
+    if {![info exists macports::revupgrade_autorun]} {
+        set macports::revupgrade_autorun yes
+    }
+    if {![info exists macports::revupgrade_mode]} {
+        set macports::revupgrade_mode "rebuild"
+    }
+    if {![info exists macports::global_options(ports_rev-upgrade_id-loadcmd-check)]
+         && [info exists macports::revupgrade_check_id_loadcmds]} {
+        set macports::global_options(ports_rev-upgrade_id-loadcmd-check) ${macports::revupgrade_check_id_loadcmds}
+        set temp_options(ports_rev-upgrade_id-loadcmd-check) ${macports::revupgrade_check_id_loadcmds}
+    }
+
+    # make tools we run operate in UTF-8 mode
+    set env(LANG) en_US.UTF-8
+
     # ENV cleanup.
     set keepenvkeys {
         DISPLAY DYLD_FALLBACK_FRAMEWORK_PATH
         DYLD_FALLBACK_LIBRARY_PATH DYLD_FRAMEWORK_PATH
         DYLD_LIBRARY_PATH DYLD_INSERT_LIBRARIES
         HOME JAVA_HOME MASTER_SITE_LOCAL ARCHIVE_SITE_LOCAL
-        PATCH_SITE_LOCAL PATH PORTSRC RSYNC_PROXY TMP TMPDIR
-        USER GROUP
+        PATCH_SITE_LOCAL PATH PORTSRC RSYNC_PROXY
+        USER GROUP LANG
         http_proxy HTTPS_PROXY FTP_PROXY ALL_PROXY NO_PROXY
         COLUMNS LINES
     }
@@ -856,6 +989,30 @@
         set keepenvkeys [concat ${keepenvkeys} ${extra_env}]
     }
 
+    if {[file isdirectory $libpath]} {
+        lappend auto_path $libpath
+        set macports::auto_path $auto_path
+
+        # XXX: not sure if this the best place, but it needs to happen
+        # early, and after auto_path has been set.  Or maybe Pextlib
+        # should ship with macports1.0 API?
+        package require Pextlib 1.0
+        package require registry 1.0
+        package require registry2 2.0
+        package require machista 1.0
+    } else {
+        return -code error "Library directory '$libpath' must exist"
+    }
+
+    # don't keep unusable TMPDIR/TMP values
+    foreach var {TMP TMPDIR} {
+        if {[info exists env($var)] && [file writable $env($var)] && 
+            ([getuid] != 0 || $macportsuser == "root" ||
+             [file attributes $env($var) -owner] == $macportsuser)} {
+            lappend keepenvkeys $var
+        }
+    }
+
     set env_names [array names env]
     foreach envkey $env_names {
         if {[lsearch -exact $keepenvkeys $envkey] == -1} {
@@ -863,12 +1020,33 @@
         }
     }
 
+    # unset environment an extra time, to work around bugs in Leopard Tcl
+    if {$macosx_version == "10.5"} {
+        foreach envkey $env_names {
+            if {[lsearch -exact $keepenvkeys $envkey] == -1} {
+                unsetenv $envkey
+            }
+        }
+    }
+
     if {![info exists xcodeversion] || ![info exists xcodebuildcmd]} {
         # We'll resolve these later (if needed)
         trace add variable macports::xcodeversion read macports::setxcodeinfo
         trace add variable macports::xcodebuildcmd read macports::setxcodeinfo
     }
 
+    if {![info exists developer_dir]} {
+        if {$os_platform == "darwin"} {
+            trace add variable macports::developer_dir read macports::set_developer_dir
+        } else {
+            set macports::developer_dir ""
+        }
+    }
+
+    if {[getuid] == 0 && $os_major >= 11 && $os_platform == "darwin" && [vercmp $xcodeversion 4.3] >= 0} {
+        macports::copy_xcode_plist $env(HOME)
+    }
+
     # Set the default umask
     if {![info exists destroot_umask]} {
         set destroot_umask 022
@@ -877,28 +1055,11 @@
     if {[info exists master_site_local] && ![info exists env(MASTER_SITE_LOCAL)]} {
         set env(MASTER_SITE_LOCAL) "$master_site_local"
     }
-
-    if {[file isdirectory $libpath]} {
-        lappend auto_path $libpath
-        set macports::auto_path $auto_path
-
-        # XXX: not sure if this the best place, but it needs to happen
-        # early, and after auto_path has been set.  Or maybe Pextlib
-        # should ship with macports1.0 API?
-        package require Pextlib 1.0
-        package require registry 1.0
-        package require registry2 2.0
-    } else {
-        return -code error "Library directory '$libpath' must exist"
+    if {[info exists patch_site_local] && ![info exists env(PATCH_SITE_LOCAL)]} {
+        set env(PATCH_SITE_LOCAL) "$patch_site_local"
     }
-
-    # unset environment an extra time, to work around bugs in Leopard Tcl
-    if {$macosx_version == "10.5"} {
-        foreach envkey $env_names {
-            if {[lsearch -exact $keepenvkeys $envkey] == -1} {
-                unsetenv $envkey
-            }
-        }
+    if {[info exists archive_site_local] && ![info exists env(ARCHIVE_SITE_LOCAL)]} {
+        set env(ARCHIVE_SITE_LOCAL) "$archive_site_local"
     }
 
     # Proxy handling (done this late since Pextlib is needed)
@@ -942,50 +1103,106 @@
         }
     }
 
+    # add ccache to environment
+    set env(CCACHE_DIR) ${macports::ccache_dir}
+
+    # load cached ping times
+    if {[catch {
+        set pingfile [open ${macports::portdbpath}/pingtimes r]
+        array set macports::ping_cache [gets $pingfile]
+        close $pingfile
+    }]} { array set macports::ping_cache {} }
+    # set up arrays of blacklisted and preferred hosts
+    if {[info exists macports::host_blacklist]} {
+        foreach host ${macports::host_blacklist} {
+            set macports::host_blacklisted($host) 1
+        }
+    }
+    if {[info exists macports::preferred_hosts]} {
+        foreach host ${macports::preferred_hosts} {
+            set macports::host_preferred($host) 1
+        }
+    }
+
     # load the quick index
     _mports_load_quickindex
 
-    set default_source_url [lindex ${sources_default} 0]
-    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"
+    if {![info exists macports::ui_options(ports_no_old_index_warning)]} {
+        set default_source_url [lindex ${sources_default} 0]
+        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"
+            }
         }
     }
-    
-    # init registry if needed
-    if {${registry.format} == "receipt_sqlite"} {
-        set db_path [file join ${registry.path} registry registry.db]
-        set db_exists [file exists $db_path]
-        registry::open $db_path
-        # for the benefit of the portimage code that is called from multiple interpreters
-        global registry_open
-        set registry_open yes
-        # convert any flat receipts if we just created a new db
-        if {$db_exists == 0 && [file writable $db_path]} {
-            ui_warn "Converting your registry to sqlite format, this might take a while..."
-            if {[catch {registry::convert_to_sqlite}]} {
-                ui_debug "$::errorInfo"
-                file delete -force $db_path
-                error "Failed to convert your registry to sqlite!"
-            } else {
-                ui_warn "Successfully converted your registry to sqlite!"
-            }
+
+    # init registry
+    set db_path [file join ${registry.path} registry registry.db]
+    set db_exists [file exists $db_path]
+    registry::open $db_path
+    # for the benefit of the portimage code that is called from multiple interpreters
+    global registry_open
+    set registry_open yes
+    # convert any flat receipts if we just created a new db
+    if {$db_exists == 0 && [file exists ${registry.path}/receipts] && [file writable $db_path]} {
+        ui_warn "Converting your registry to sqlite format, this might take a while..."
+        if {[catch {registry::convert_to_sqlite}]} {
+            ui_debug "$::errorInfo"
+            file delete -force $db_path
+            error "Failed to convert your registry to sqlite!"
+        } else {
+            ui_warn "Successfully converted your registry to sqlite!"
         }
     }
 }
 
 # call this just before you exit
 proc mportshutdown {} {
-    global macports::registry.format
-    if {${registry.format} == "receipt_sqlite"} {
-        # close it down so the cleanup stuff is called, e.g. vacuuming the db
-        registry::close
+    # save ping times
+    global macports::ping_cache macports::portdbpath
+    if {[file writable ${macports::portdbpath}]} {
+        catch {
+            foreach host [array names ping_cache] {
+                # don't save expired entries
+                if {[expr [clock seconds] - [lindex $ping_cache($host) 1]] < 86400} {
+                    lappend pinglist_fresh $host $ping_cache($host)
+                }
+            }
+            set pingfile [open ${macports::portdbpath}/pingtimes w]
+            puts $pingfile $pinglist_fresh
+            close $pingfile
+        }
     }
+    # close it down so the cleanup stuff is called, e.g. vacuuming the db
+    registry::close
 }
 
+# link plist for xcode 4.3's benefit
+proc macports::copy_xcode_plist {target_homedir} {
+    global macports::user_home macports::macportsuser
+    set user_plist "${user_home}/Library/Preferences/com.apple.dt.Xcode.plist"
+    set target_dir "${target_homedir}/Library/Preferences"
+    file delete -force "${target_dir}/com.apple.dt.Xcode.plist"
+    if {[file isfile $user_plist]} {
+        if {![file isdirectory "${target_dir}"]} {
+            if {[catch {file mkdir "${target_dir}"} result]} {
+                ui_warn "Failed to create Library/Preferences in ${target_homedir}: $result"
+                return
+            }
+        }
+        if {[file writable ${target_dir}] && [catch {
+            ui_debug "Copying $user_plist to ${target_dir}"
+            file copy -force $user_plist $target_dir
+            file attributes "${target_dir}/com.apple.dt.Xcode.plist" -owner $macportsuser -permissions 0644
+        } result]} {
+            ui_warn "Failed to copy com.apple.dt.Xcode.plist to ${target_dir}: $result"
+        }
+    }
+}
+
 proc macports::worker_init {workername portpath porturl portbuildpath options variations} {
-    global macports::portinterp_options macports::portinterp_deferred_options registry.installtype
+    global macports::portinterp_options macports::portinterp_deferred_options
 
     # Hide any Tcl commands that should be inaccessible to port1.0 and Portfiles
     # exit: It should not be possible to exit the interpreter
@@ -1012,6 +1229,7 @@
     $workername alias mport_open mportopen
     $workername alias mport_close mportclose
     $workername alias mport_lookup mportlookup
+    $workername alias mport_info mportinfo
     $workername alias set_phase set_phase
 
     # instantiate the UI call-backs
@@ -1053,16 +1271,23 @@
     $workername alias registry_exists_for_name registry::entry_exists_for_name
     $workername alias registry_activate portimage::activate
     $workername alias registry_deactivate portimage::deactivate
+    $workername alias registry_deactivate_composite portimage::deactivate_composite
     $workername alias registry_uninstall registry_uninstall::uninstall
     $workername alias registry_register_deps registry::register_dependencies
     $workername alias registry_fileinfo_for_index registry::fileinfo_for_index
+    $workername alias registry_fileinfo_for_file registry::fileinfo_for_file
     $workername alias registry_bulk_register_files registry::register_bulk_files
     $workername alias registry_active registry::active
     $workername alias registry_file_registered registry::file_registered
+    $workername alias registry_port_registered registry::port_registered
 
     # deferred options processing.
     $workername alias getoption macports::getoption
 
+    # ping cache
+    $workername alias get_pingtime macports::get_pingtime
+    $workername alias set_pingtime macports::set_pingtime
+
     foreach opt $portinterp_options {
         if {![info exists $opt]} {
             global macports::$opt
@@ -1096,10 +1321,6 @@
     foreach {var val} $variations {
         $workername eval set variations($var) $val
     }
-
-    if { [info exists registry.installtype] } {
-        $workername eval set installtype ${registry.installtype}
-    }
 }
 
 # Create a thread with most configuration options set.
@@ -1138,25 +1359,82 @@
     return $result
 }
 
-proc macports::fetch_port {url} {
-    global macports::portdbpath tcl_platform
+proc macports::get_tar_flags {suffix} {
+    switch -- $suffix {
+        .tbz -
+        .tbz2 {
+            return "-j"
+        }
+        .tgz {
+            return "-z"
+        }
+        .txz {
+            return "--use-compress-program [findBinary xz {}] -"
+        }
+        .tlz {
+            return "--use-compress-program [findBinary lzma {}] -"
+        }
+        default {
+            return "-"
+        }
+    }
+}
+
+proc macports::fetch_port {url {local 0}} {
+    global macports::portdbpath
     set fetchdir [file join $portdbpath portdirs]
-    set fetchfile [file tail $url]
     file mkdir $fetchdir
     if {![file writable $fetchdir]} {
         return -code error "Port remote fetch failed: You do not have permission to write to $fetchdir"
     }
-    if {[catch {curl fetch $url [file join $fetchdir $fetchfile]} result]} {
-        return -code error "Port remote fetch failed: $result"
+    if {$local} {
+        set fetchfile $url
+    } else {
+        set fetchfile [file tail $url]
+        if {[catch {curl fetch $url [file join $fetchdir $fetchfile]} result]} {
+            return -code error "Port remote fetch failed: $result"
+        }
     }
+    set oldpwd [pwd]
     cd $fetchdir
-    if {[catch {exec [findBinary tar $macports::autoconf::tar_path] -zxf $fetchfile} result]} {
+    # check if this is a binary archive or just the port dir
+    set tarcmd [findBinary tar $macports::autoconf::tar_path]
+    set tarflags [get_tar_flags [file extension $fetchfile]]
+    set qflag ${macports::autoconf::tar_q}
+    set cmdline "$tarcmd ${tarflags}${qflag}xOf \"$fetchfile\" +CONTENTS"
+    ui_debug "$cmdline"
+    if {![catch {set contents [eval exec $cmdline]}]} {
+        set binary 1
+        ui_debug "getting port name from binary archive"
+        # get the portname from the contents file
+        foreach line [split $contents "\n"] {
+            if {[lindex $line 0] == "@name"} {
+                # actually ${name}-${version}_${revision}
+                set portname [lindex $line 1]
+            }
+        }
+        ui_debug "port name is '$portname'"
+        file mkdir $portname
+        cd $portname
+    } else {
+        set binary 0
+        set portname [file rootname $fetchfile]
+    }
+
+    # extract the portfile (and possibly files dir if not a binary archive)
+    ui_debug "extracting port archive to [pwd]"
+    if {$binary} {
+        set cmdline "$tarcmd ${tarflags}${qflag}xOf \"$fetchfile\" +PORTFILE > Portfile"
+    } else {
+        set cmdline "$tarcmd ${tarflags}xf \"$fetchfile\""
+    }
+    ui_debug "$cmdline"
+    if {[catch {eval exec $cmdline} result]} {
         return -code error "Port extract failed: $result"
     }
-    if {[regexp {(.+).tgz} $fetchfile match portdir] != 1} {
-        return -code error "Can't decipher portdir from $fetchfile"
-    }
-    return [file join $fetchdir $portdir]
+
+    cd $oldpwd
+    return [file join $fetchdir $portname]
 }
 
 proc macports::getprotocol {url} {
@@ -1172,10 +1450,20 @@
 # fetched port will be downloaded to (currently only applies to
 # mports:// sources).
 proc macports::getportdir {url {destdir "."}} {
+    global macports::extracted_portdirs
     set protocol [macports::getprotocol $url]
     switch ${protocol} {
         file {
-            return [file normalize [string range $url [expr [string length $protocol] + 3] end]]
+            set path [file normalize [string range $url [expr [string length $protocol] + 3] end]]
+            if {![file isfile $path]} {
+                return $path
+            } else {
+                # need to create a local dir for the exracted port, but only once
+                if {![info exists macports::extracted_portdirs($url)]} {
+                    set macports::extracted_portdirs($url) [macports::fetch_port $path 1]
+                }
+                return $macports::extracted_portdirs($url)
+            }
         }
         mports {
             return [macports::index::fetch_port $url $destdir]
@@ -1183,7 +1471,10 @@
         https -
         http -
         ftp {
-            return [macports::fetch_port $url]
+            if {![info exists macports::extracted_portdirs($url)]} {
+                set macports::extracted_portdirs($url) [macports::fetch_port $url 0]
+            }
+            return $macports::extracted_portdirs($url)
         }
         default {
             return -code error "Unsupported protocol $protocol"
@@ -1257,14 +1548,15 @@
     global macports::portdbpath macports::portconf macports::open_mports auto_path
 
     # Look for an already-open MPort with the same URL.
-    # XXX: should compare options and variations here too.
     # if found, return the existing reference and bump the refcount.
     if {$nocache != ""} {
         set mport {}
     } else {
-        set mport [dlist_search $macports::open_mports porturl $porturl]
+        set mport [dlist_match_multi $macports::open_mports [list porturl $porturl variations $variations options $options]]
     }
     if {$mport != {}} {
+        # just in case more than one somehow matches
+        set mport [lindex $mport 0]
         set refcnt [ditem_key $mport refcnt]
         incr refcnt
         ditem_key $mport refcnt $refcnt
@@ -1277,9 +1569,6 @@
     } else {
         set portdir ""
     }
-    if {![info exists options_array(ports_requested)]} {
-        lappend options ports_requested 0
-    }
 
     set portpath [macports::getportdir $porturl $portdir]
     ui_debug "Changing to port directory: $portpath"
@@ -1313,7 +1602,7 @@
         error "Error evaluating variants"
     }
 
-    ditem_key $mport provides [$workername eval return \$name]
+    ditem_key $mport provides [$workername eval return \$subport]
 
     return $mport
 }
@@ -1321,10 +1610,7 @@
 # mportopen_installed
 # opens a portfile stored in the registry
 proc mportopen_installed {name version revision variants options} {
-    global macports::registry.format macports::registry.path
-    if {${registry.format} != "receipt_sqlite"} {
-        return -code error "mportopen_installed requires sqlite registry"
-    }
+    global macports::registry.path
     set regref [lindex [registry::entry imaged $name $version $revision $variants] 0]
     set portfile_dir [file join ${registry.path} registry portfiles $name "${version}_${revision}${variants}"]
     file mkdir $portfile_dir
@@ -1342,7 +1628,7 @@
     foreach v $minusvariant {
         lappend variations $v "-"
     }
-    
+    lappend options subport $name
     return [mportopen "file://${portfile_dir}/" $options $variations]
 }
 
@@ -1350,11 +1636,11 @@
 # close mport opened with mportopen_installed and clean up associated files
 proc mportclose_installed {mport} {
     global macports::registry.path
-    foreach key {name version revision portvariants} {
+    foreach key {subport version revision portvariants} {
         set $key [_mportkey $mport $key]
     }
     mportclose $mport
-    set portfiles_dir [file join ${registry.path} registry portfiles $name]
+    set portfiles_dir [file join ${registry.path} registry portfiles $subport]
     set portfile [file join $portfiles_dir "${version}_${revision}${portvariants}" Portfile]
     file delete -force $portfile [file dirname $portfile]
     if {[llength [glob -nocomplain -directory $portfiles_dir *]] == 0} {
@@ -1449,13 +1735,13 @@
 proc _mportinstalled {mport} {
     # Check for the presence of the port in the registry
     set workername [ditem_key $mport workername]
-    return [$workername eval registry_exists_for_name \${name}]
+    return [$workername eval registry_exists_for_name \${subport}]
 }
 
-# Determine if a port is active (only for image mode)
+# Determine if a port is active
 proc _mportactive {mport} {
     set workername [ditem_key $mport workername]
-    if {![catch {set reslist [$workername eval registry_active \${name}]}] && [llength $reslist] > 0} {
+    if {![catch {set reslist [$workername eval registry_active \${subport}]}] && [llength $reslist] > 0} {
         set i [lindex $reslist 0]
         set name [lindex $i 0]
         set version [lindex $i 1]
@@ -1470,7 +1756,7 @@
     return 0
 }
 
-# Determine if the named port is active (only for image mode)
+# Determine if the named port is active
 proc _portnameactive {portname} {
     if {[catch {set reslist [registry::active $portname]}]} {
         return 0
@@ -1482,7 +1768,7 @@
 ### _mportispresent is private; may change without notice
 
 # Determine if some depspec is satisfied or if the given port is installed
-# (and active, if we're in image mode).
+# and active.
 # We actually start with the registry (faster?)
 #
 # mport     the port declaring the dep (context in which to evaluate $prefix etc)
@@ -1490,11 +1776,7 @@
 proc _mportispresent {mport depspec} {
     set portname [lindex [split $depspec :] end]
     ui_debug "Searching for dependency: $portname"
-    if {[string equal ${macports::registry.installtype} "image"]} {
-        set res [_portnameactive $portname]
-    } else {
-        set res [registry::entry_exists_for_name $portname]
-    }
+    set res [_portnameactive $portname]
     if {$res != 0} {
         ui_debug "Found Dependency: receipt exists for $portname"
         return 1
@@ -1514,37 +1796,49 @@
     }
 }
 
-### _mportconflictsinstalled is private; may change without notice
+### _mporterrorifconflictsinstalled is private; may change without notice
 
-# Determine if the port, per the conflicts option, has any conflicts with
-# what is installed.
+# Determine if the port, per the conflicts option, has any conflicts
+# with what is installed. If it does, raises an error unless force
+# option is set.
 #
 # mport   the port to check for conflicts
-# Returns a list of which installed ports conflict, or an empty list if none
-proc _mportconflictsinstalled {mport conflictinfo} {
+proc _mporterrorifconflictsinstalled {mport} {
     set conflictlist {}
-    if {[llength $conflictinfo] > 0} {
-        ui_debug "Checking for conflicts against [_mportkey $mport name]"
-        foreach conflictport ${conflictinfo} {
+    array set portinfo [mportinfo $mport]
+
+    if {[info exists portinfo(conflicts)] &&
+        [llength $portinfo(conflicts)] > 0} {
+        ui_debug "Checking for conflicts against [_mportkey $mport subport]"
+        foreach conflictport $portinfo(conflicts) {
             if {[_mportispresent $mport port:${conflictport}]} {
                 lappend conflictlist $conflictport
             }
         }
     } else {
-        ui_debug "[_mportkey $mport name] has no conflicts"
+        ui_debug "[_mportkey $mport subport] has no conflicts"
     }
 
-    return $conflictlist
+    if {[llength ${conflictlist}] != 0} {
+        if {[macports::global_option_isset ports_force]} {
+            ui_warn "Force option set; installing $portinfo(name) despite conflicts with: ${conflictlist}"
+        } else {
+            if {![macports::ui_isset ports_debug]} {
+                ui_msg ""
+            }
+            return -code error "Can't install $portinfo(name) because conflicting ports are installed: ${conflictlist}"
+        }
+    }
 }
 
-
 ### _mportexec is private; may change without notice
 
 proc _mportexec {target mport} {
-    set portname [_mportkey $mport name]
+    set portname [_mportkey $mport subport]
     macports::push_log $mport
     # xxx: set the work path?
     set workername [ditem_key $mport workername]
+    $workername eval validate_macportsuser
     if {![catch {$workername eval check_variants $target} result] && $result == 0 &&
         ![catch {$workername eval check_supported_archs} result] && $result == 0 &&
         ![catch {$workername eval eval_targets $target} result] && $result == 0} {
@@ -1566,8 +1860,10 @@
     } else {
         # An error occurred.
         global ::logenabled ::debuglogname
+        ui_error "Failed to install $portname"
+        ui_debug "$::errorInfo"
         if {[info exists ::logenabled] && $::logenabled && [info exists ::debuglogname]} {
-            ui_notice "Log for $portname is at: $::debuglogname"
+            ui_notice "Please see the log file for $portname for details:\n    $::debuglogname"
         }
         macports::pop_log
         return 1
@@ -1577,34 +1873,40 @@
 # mportexec
 # Execute the specified target of the given mport.
 proc mportexec {mport target} {
-    global macports::registry.installtype
-
     set workername [ditem_key $mport workername]
 
+    # check for existence of macportsuser and use fallback if necessary
+    $workername eval validate_macportsuser
     # check variants
     if {[$workername eval check_variants $target] != 0} {
         return 1
     }
-    set portname [_mportkey $mport name]
+    set portname [_mportkey $mport subport]
     if {$target != "clean"} {
         macports::push_log $mport
     }
 
+    # Use _target_needs_deps as a proxy for whether we're going to
+    # build and will therefore need to check Xcode version and
+    # supported_archs.
+    if {[macports::_target_needs_deps $target]} {
+        # possibly warn or error out depending on how old xcode is
+        if {[$workername eval _check_xcode_version] != 0} {
+            return 1
+        }
+        # error out if selected arch(s) not supported by this port
+        if {[$workername eval check_supported_archs] != 0} {
+            return 1
+        }
+    }
+
     # Before we build the port, we must build its dependencies.
     set dlist {}
-    if {[macports::_target_needs_deps $target]} {
+    if {[macports::_target_needs_deps $target] && [macports::_mport_has_deptypes $mport [macports::_deptypes_for_target $target $workername]]} {
         registry::exclusive_lock
         # see if we actually need to build this port
         if {($target != "activate" && $target != "install") ||
-            ![$workername eval registry_exists \$name \$version \$revision \$portvariants]} {
-            # possibly warn or error out depending on how old xcode is
-            if {[$workername eval _check_xcode_version] != 0} {
-                return 1
-            }
-            # error out if selected arch(s) not supported by this port
-            if {[$workername eval check_supported_archs] != 0} {
-                return 1
-            }
+            ![$workername eval registry_exists \$subport \$version \$revision \$portvariants]} {
     
             # upgrade dependencies that are already installed
             if {![macports::global_option_isset ports_nodeps]} {
@@ -1612,7 +1914,7 @@
             }
         }
 
-        ui_msg -nonewline "--->  Computing dependencies for [_mportkey $mport name]"
+        ui_msg -nonewline "$macports::ui_prefix Computing dependencies for [_mportkey $mport subport]"
         if {[macports::ui_isset ports_debug]} {
             # play nice with debug messages
             ui_msg ""
@@ -1632,7 +1934,7 @@
         
         # print the dep list
         if {[llength $dlist] > 0} {
-            set depstring "--->  Dependencies to be installed:"
+            set depstring "$macports::ui_prefix Dependencies to be installed:"
             foreach ditem $dlist {
                 append depstring " [ditem_key $ditem provides]"
             }
@@ -1640,17 +1942,12 @@
         }
 
         # install them
-        # xxx: as with below, this is ugly.  and deps need to be fixed to
-        # understand Port Images before this can get prettier
-        if { [string equal ${macports::registry.installtype} "image"] } {
-            set result [dlist_eval $dlist _mportactive [list _mportexec "activate"]]
-        } else {
-            set result [dlist_eval $dlist _mportinstalled [list _mportexec "activate"]]
-        }
+        set result [dlist_eval $dlist _mportactive [list _mportexec "activate"]]
+
         registry::exclusive_unlock
 
         if {$result != {}} {
-            set errstring "The following dependencies failed to build:"
+            set errstring "The following dependencies were not installed:"
             foreach ditem $result {
                 append errstring " [ditem_key $ditem provides]"
             }
@@ -1665,6 +1962,11 @@
         foreach ditem $dlist {
             mportclose $ditem
         }
+    } else {
+        # No dependencies, but we still need to check for conflicts.
+        if {$target == "" || $target == "install" || $target == "activate"} {
+            _mporterrorifconflictsinstalled $mport
+        }
     }
 
     set clean 0
@@ -1687,7 +1989,7 @@
     global ::logenabled ::debuglogname
     if {[info exists ::logenabled] && $::logenabled && [info exists ::debuglogname]} {
         if {$result != 0} {
-            ui_notice "Log for $portname is at: $::debuglogname"
+            ui_notice "Please see the log file for port $portname for details:\n    $::debuglogname"
         }
         macports::pop_log
     }
@@ -1706,11 +2008,7 @@
     set required_archs [$workername eval get_canonical_archs]
     set depends_skip_archcheck [_mportkey $mport depends_skip_archcheck]
 
-    if {[string equal ${macports::registry.installtype} "image"]} {
-        set test _portnameactive
-    } else {
-        set test registry::entry_exists_for_name
-    }
+    set test _portnameactive
 
     foreach deptype $deptypes {
         if {![info exists portinfo($deptype)]} {
@@ -1736,6 +2034,11 @@
                         set res [mportlookup $dep_portname]
                         array unset dep_portinfo
                         array set dep_portinfo [lindex $res 1]
+                        if {[info exists dep_portinfo(installs_libs)] && !$dep_portinfo(installs_libs)} {
+                            set missing {}
+                        }
+                    }
+                    if {[llength $missing] > 0} {
                         if {[info exists dep_portinfo(variants)] && [lsearch $dep_portinfo(variants) universal] != -1} {
                             # dep offers a universal variant
                             if {[llength $active_archs] == 1} {
@@ -1747,7 +2050,7 @@
                                     }
                                 }
                                 if {[llength $missing] > 0} {
-                                    ui_error "Cannot install [_mportkey $mport name] for the arch(s) '$required_archs' because"
+                                    ui_error "Cannot install [_mportkey $mport subport] for the arch(s) '$required_archs' because"
                                     ui_error "its dependency $dep_portname is only installed for the arch '$active_archs'"
                                     ui_error "and the configured universal_archs '$macports::universal_archs' are not sufficient."
                                     return -code error "architecture mismatch"
@@ -1759,12 +2062,12 @@
                                 }
                             } else {
                                 # already universal
-                                ui_error "Cannot install [_mportkey $mport name] for the arch(s) '$required_archs' because"
+                                ui_error "Cannot install [_mportkey $mport subport] for the arch(s) '$required_archs' because"
                                 ui_error "its dependency $dep_portname is only installed for the archs '$active_archs'."
                                 return -code error "architecture mismatch"
                             }
                         } else {
-                            ui_error "Cannot install [_mportkey $mport name] for the arch(s) '$required_archs' because"
+                            ui_error "Cannot install [_mportkey $mport subport] for the arch(s) '$required_archs' because"
                             ui_error "its dependency $dep_portname is only installed for the arch '$active_archs'"
                             ui_error "and does not have a universal variant."
                             return -code error "architecture mismatch"
@@ -1784,11 +2087,7 @@
 
 # get the archs with which the active version of portname is installed
 proc macports::_get_registry_archs {portname} {
-    if {[string equal ${macports::registry.installtype} "image"]} {
-        set ilist [registry::active $portname]
-    } else {
-        set ilist [registry::installed $portname]
-    }
+    set ilist [registry::active $portname]
     set i [lindex $ilist 0]
     set regref [registry::open_entry [lindex $i 0] [lindex $i 1] [lindex $i 2] [lindex $i 3] [lindex $i 5]]
     set archs [registry::property_retrieve $regref archs]
@@ -1821,7 +2120,7 @@
     upvar $filename myfilename
     upvar $extension myextension
 
-    if {[regexp {^(?:https?|ftp)://.+/(.+\.(tar\.gz|tar\.bz2))$} $url -> f e]} {
+    if {[regexp {^(?:https?|ftp|rsync)://.+/(.+\.(tar\.gz|tar\.bz2|tar))$} $url -> f e]} {
         set myfilename $f
         set myextension $e
 
@@ -1831,26 +2130,26 @@
     return 0
 }
 
-proc macports::getportbuildpath {id} {
+proc macports::getportbuildpath {id {portname ""}} {
     global macports::portdbpath
     regsub {://} $id {.} port_path
     regsub -all {/} $port_path {_} port_path
-    return [file join $portdbpath build $port_path]
+    return [file join $portdbpath build $port_path $portname]
 }
 
-proc macports::getportlogpath {id} {
+proc macports::getportlogpath {id {portname ""}} {
     global macports::portdbpath
     regsub {://} $id {.} port_path
     regsub -all {/} $port_path {_} port_path
-    return [file join $portdbpath logs $port_path]
+    return [file join $portdbpath logs $port_path $portname]
 }
 
 proc macports::getportworkpath_from_buildpath {portbuildpath} {
     return [file join $portbuildpath work]
 }
 
-proc macports::getportworkpath_from_portdir {portpath} {
-    return [macports::getportworkpath_from_buildpath [macports::getportbuildpath $portpath]]
+proc macports::getportworkpath_from_portdir {portpath {portname ""}} {
+    return [macports::getportworkpath_from_buildpath [macports::getportbuildpath $portpath $portname]]
 }
 
 proc macports::getindex {source} {
@@ -1865,12 +2164,15 @@
 proc mportsync {{optionslist {}}} {
     global macports::sources macports::portdbpath macports::rsync_options tcl_platform
     global macports::portverbose
-    global macports::autoconf::rsync_path
+    global macports::autoconf::rsync_path macports::autoconf::tar_path macports::autoconf::openssl_path
     array set options $optionslist
+    if {[info exists options(no_reindex)]} {
+        upvar $options(needed_portindex_var) any_needed_portindex
+    }
 
     set numfailed 0
 
-    ui_debug "Synchronizing ports tree(s)"
+    ui_msg "$macports::ui_prefix Updating the ports tree"
     foreach source $sources {
         set flags [lrange $source 1 end]
         set source [lindex $source 0]
@@ -1883,8 +2185,10 @@
         switch -regexp -- [macports::getprotocol $source] {
             {^file$} {
                 set portdir [macports::getportdir $source]
-                if {[file exists $portdir/.svn]} {
-                    set svn_commandline "[macports::findBinary svn] update --non-interactive ${portdir}"
+                set svn_cmd ""
+                catch {set svn_cmd [macports::findBinary svn]}
+                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
                     if {
                         [catch {
@@ -1917,13 +2221,21 @@
                 # Where to, boss?
                 set indexfile [macports::getindex $source]
                 set destdir [file dirname $indexfile]
+                set is_tarball [_source_is_snapshot $source]
                 file mkdir $destdir
-                # Keep rsync happy with a trailing slash
-                if {[string index $source end] != "/"} {
-                    append source "/"
+
+                if {$is_tarball} {
+                    set exclude_option ""
+                    # need to do a few things before replacing the ports tree in this case
+                    set destdir [file dirname $destdir]
+                } else {
+                    # Keep rsync happy with a trailing slash
+                    if {[string index $source end] != "/"} {
+                        append source "/"
+                    }
+                    # don't sync PortIndex yet; we grab the platform specific one afterwards
+                    set exclude_option "'--exclude=/PortIndex*'"
                 }
-                # don't sync PortIndex yet; we grab the platform specific one afterwards
-                set exclude_option "'--exclude=/PortIndex*'"
                 # Do rsync fetch
                 set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} ${exclude_option} ${source} ${destdir}"
                 ui_debug $rsync_commandline
@@ -1932,21 +2244,110 @@
                     incr numfailed
                     continue
                 }
+
+                if {$is_tarball} {
+                    # verify signature for tarball
+                    global macports::archivefetch_pubkeys
+                    set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} ${exclude_option} ${source}.rmd160 ${destdir}"
+                    ui_debug $rsync_commandline
+                    if {[catch {system $rsync_commandline}]} {
+                        ui_error "Synchronization of the ports tree signature failed doing rsync"
+                        incr numfailed
+                        continue
+                    }
+                    set tarball "${destdir}/[file tail $source]"
+                    set signature "${tarball}.rmd160"
+                    set openssl [macports::findBinary openssl $macports::autoconf::openssl_path]
+                    set verified 0
+                    foreach pubkey ${macports::archivefetch_pubkeys} {
+                        if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature $signature $tarball} result]} {
+                            set verified 1
+                            ui_debug "successful verification with key $pubkey"
+                            break
+                        } else {
+                            ui_debug "failed verification with key $pubkey"
+                            ui_debug "openssl output: $result"
+                        }
+                    }
+                    if {!$verified} {
+                        ui_error "Failed to verify signature for ports tree!"
+                        incr numfailed
+                        continue
+                    }
+
+                    # extract tarball and move into place
+                    set tar [macports::findBinary tar $macports::autoconf::tar_path]
+                    file mkdir ${destdir}/tmp
+                    set tar_cmd "$tar -C ${destdir}/tmp -xf ${tarball}"
+                    ui_debug $tar_cmd
+                    if {[catch {system $tar_cmd}]} {
+                        ui_error "Failed to extract ports tree from tarball!"
+                        incr numfailed
+                        continue
+                    }
+                    # save the local PortIndex data
+                    if {[file isfile $indexfile]} {
+                        file copy -force $indexfile ${destdir}/
+                        file rename -force $indexfile ${destdir}/tmp/ports/
+                        if {[file isfile ${indexfile}.quick]} {
+                            file rename -force ${indexfile}.quick ${destdir}/tmp/ports/
+                        }
+                    }
+                    file delete -force ${destdir}/ports
+                    file rename ${destdir}/tmp/ports ${destdir}/ports
+                    file delete -force ${destdir}/tmp
+                }
+
+                set needs_portindex 1
                 # now sync the index if the local file is missing or older than a day
-                if {![file isfile $indexfile] || [expr [clock seconds] - [file mtime $indexfile]] > 86400} {
-                    set remote_indexfile "${source}PortIndex_${macports::os_platform}_${macports::os_major}_${macports::os_arch}/PortIndex"
+                if {![file isfile $indexfile] || [expr [clock seconds] - [file mtime $indexfile]] > 86400
+                      || [info exists options(no_reindex)]} {
+                    if {$is_tarball} {
+                        # chop ports.tar off the end
+                        set index_source [string range $source 0 end-[string length [file tail $source]]]
+                    } else {
+                        set index_source $source 
+                    }
+                    set remote_indexfile "${index_source}PortIndex_${macports::os_platform}_${macports::os_major}_${macports::os_arch}/PortIndex"
                     set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} $remote_indexfile ${destdir}"
                     ui_debug $rsync_commandline
                     if {[catch {system $rsync_commandline}]} {
                         ui_debug "Synchronization of the PortIndex failed doing rsync"
                     } else {
-                        mports_generate_quickindex $indexfile
+                        set ok 1
+                        set needs_portindex 0
+                        if {$is_tarball} {
+                            set ok 0
+                            set needs_portindex 1
+                            # verify signature for PortIndex
+                            set rsync_commandline "${macports::autoconf::rsync_path} ${rsync_options} ${remote_indexfile}.rmd160 ${destdir}"
+                            ui_debug $rsync_commandline
+                            if {![catch {system $rsync_commandline}]} {
+                                foreach pubkey ${macports::archivefetch_pubkeys} {
+                                    if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature ${destdir}/PortIndex.rmd160 ${destdir}/PortIndex} result]} {
+                                        set ok 1
+                                        set needs_portindex 0
+                                        ui_debug "successful verification with key $pubkey"
+                                        break
+                                    } else {
+                                        ui_debug "failed verification with key $pubkey"
+                                        ui_debug "openssl output: $result"
+                                    }
+                                }
+                                if {$ok} {
+                                    # move PortIndex into place
+                                    file rename -force ${destdir}/PortIndex ${destdir}/ports/
+                                }
+                            }
+                        }
+                        if {$ok} {
+                            mports_generate_quickindex $indexfile
+                        }
                     }
                 }
                 if {[catch {system "chmod -R a+r \"$destdir\""}]} {
                     ui_warn "Setting world read permissions on parts of the ports tree failed, need root?"
                 }
-                set needs_portindex 1
             }
             {^https?$|^ftp$} {
                 if {[_source_is_snapshot $source filename extension]} {
@@ -2008,8 +2409,6 @@
                     }
 
                     file delete $tarpath
-                    
-                    set needs_portindex 1
                 } else {
                     # sync just a PortIndex file
                     set indexfile [macports::getindex $source]
@@ -2024,10 +2423,13 @@
         }
         
         if {$needs_portindex} {
-            global macports::prefix
-            set indexdir [file dirname [macports::getindex $source]]
-            if {[catch {system "${macports::prefix}/bin/portindex $indexdir"}]} {
-                ui_error "updating PortIndex for $source failed"
+            set any_needed_portindex 1
+            if {![info exists options(no_reindex)]} {
+                global macports::prefix
+                set indexdir [file dirname [macports::getindex $source]]
+                if {[catch {system "${macports::prefix}/bin/portindex $indexdir"}]} {
+                    ui_error "updating PortIndex for $source failed"
+                }
             }
         }
     }
@@ -2426,10 +2828,15 @@
 #                  dependencies ports.
 # accDeps -> accumulator for recursive calls
 # return 0 if everything was ok, an non zero integer otherwise.
-proc mportdepends {mport {target ""} {recurseDeps 1} {skipSatisfied 1}} {
+proc mportdepends {mport {target ""} {recurseDeps 1} {skipSatisfied 1} {accDeps 0}} {
 
     array set portinfo [mportinfo $mport]
     set deptypes {}
+    if {$accDeps} {
+        upvar depspec_seen depspec_seen
+    } else {
+        array set depspec_seen {}
+    }
 
     # progress indicator
     if {![macports::ui_isset ports_debug]} {
@@ -2437,28 +2844,20 @@
         flush stdout
     }
     
-    if {[info exists portinfo(conflicts)] && ($target == "" || $target == "install" || $target == "activate")} {
-        set conflictports [_mportconflictsinstalled $mport $portinfo(conflicts)]
-        if {[llength ${conflictports}] != 0} {
-            if {[macports::global_option_isset ports_force]} {
-                ui_warn "Force option set; installing $portinfo(name) despite conflicts with: ${conflictports}"
-            } else {
-                if {![macports::ui_isset ports_debug]} {
-                    ui_msg ""
-                }
-                return -code error "Can't install $portinfo(name) because conflicting ports are installed: ${conflictports}"
-            }
-        }
+    if {$target == "" || $target == "install" || $target == "activate"} {
+        _mporterrorifconflictsinstalled $mport
     }
 
     set workername [ditem_key $mport workername]
     set deptypes [macports::_deptypes_for_target $target $workername]
 
-    set subPorts {}
+    set depPorts {}
     if {[llength $deptypes] > 0} {
         array set optionsarray [ditem_key $mport options]
         # avoid propagating requested flag from parent
-        set optionsarray(ports_requested) 0
+        unset -nocomplain optionsarray(ports_requested)
+        # subport will be different for deps
+        unset -nocomplain optionsarray(subport)
         set options [array get optionsarray]
         set variations [ditem_key $mport variations]
         set required_archs [$workername eval get_canonical_archs]
@@ -2471,6 +2870,31 @@
             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 ,]"
+            set seen 0
+            if {[info exists depspec_seen($seenkey)]} {
+                set seen 1
+            } else {
+                set prev_seenkeys [array names depspec_seen ${depspec},*]
+                set nrequired [llength $required_archs]
+                foreach key $prev_seenkeys {
+                    set key_archs [lrange [split $key ,] 1 end]
+                    if {[llength $key_archs] > $nrequired} {
+                        set seen 1
+                        set seenkey $key
+                        break
+                    }
+                }
+            }
+            if {$seen} {
+                if {$depspec_seen($seenkey) != 0} {
+                    # nonzero means the dep is not satisfied, so we have to record it
+                    ditem_append_unique $mport requires $depspec_seen($seenkey)
+                }
+                continue
+            }
+            
             # Is that dependency satisfied or this port installed?
             # If we don't skip or if it is not, add it to the list.
             set present [_mportispresent $mport $depspec]
@@ -2495,6 +2919,7 @@
                 # Find the porturl
                 if {[catch {set res [mportlookup $dep_portname]} error]} {
                     global errorInfo
+                    ui_msg ""
                     ui_debug "$errorInfo"
                     ui_error "Internal error: port lookup failed: $error"
                     return 1
@@ -2508,24 +2933,27 @@
                     }
                     ui_error "Dependency '$dep_portname' not found."
                     return 1
+                } elseif {[info exists dep_portinfo(installs_libs)] && !$dep_portinfo(installs_libs)} {
+                    set check_archs 0
                 }
-                # Figure out the subport. Check the open_mports list first, since
+                lappend 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 subport [dlist_search $macports::open_mports porturl $dep_portinfo(porturl)]
+                set depport [dlist_match_multi $macports::open_mports [list porturl $dep_portinfo(porturl) options $options variations $variations]]
                 
-                if {$subport == {}} {
+                if {$depport == {}} {
                     # We haven't opened this one yet.
-                    set subport [mportopen $dep_portinfo(porturl) $options $variations]
+                    set depport [mportopen $dep_portinfo(porturl) $options $variations]
                 }
             }
 
             # check archs
             if {$parse && $check_archs
-                && ![macports::_mport_supports_archs $subport $required_archs]} {
+                && ![macports::_mport_supports_archs $depport $required_archs]} {
 
-                set supported_archs [_mportkey $subport supported_archs]
-                mportclose $subport
+                set supported_archs [_mportkey $depport supported_archs]
+                mportclose $depport
                 set arch_mismatch 1
                 set has_universal 0
                 if {[info exists dep_portinfo(variants)] && [lsearch -exact $dep_portinfo(variants) universal] != -1} {
@@ -2536,14 +2964,14 @@
                     if {![info exists variation_array(universal)] || $variation_array(universal) != "+"} {
                         set variation_array(universal) +
                         # try again with +universal
-                        set subport [mportopen $dep_portinfo(porturl) $options [array get variation_array]]
-                        if {[macports::_mport_supports_archs $subport $required_archs]} {
+                        set depport [mportopen $dep_portinfo(porturl) $options [array get variation_array]]
+                        if {[macports::_mport_supports_archs $depport $required_archs]} {
                             set arch_mismatch 0
                         }
                     }
                 }
                 if {$arch_mismatch} {
-                    macports::_explain_arch_mismatch [_mportkey $mport name] $dep_portname $required_archs $supported_archs $has_universal
+                    macports::_explain_arch_mismatch [_mportkey $mport subport] $dep_portname $required_archs $supported_archs $has_universal
                     return -code error "architecture mismatch"
                 }
             }
@@ -2551,20 +2979,24 @@
             if {$parse} {
                 if {$recurseDeps} {
                     # Add to the list we need to recurse on.
-                    lappend subPorts $subport
+                    lappend depPorts $depport
                 }
-    
+
                 # Append the sub-port's provides to the port's requirements list.
-                ditem_append_unique $mport requires "[ditem_key $subport provides]"
+                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
             }
         }
     }
 
-    # Loop on the subports.
+    # Loop on the depports.
     if {$recurseDeps} {
-        foreach subport $subPorts {
+        foreach depport $depPorts {
             # Sub ports should be installed (all dependencies must be satisfied).
-            set res [mportdepends $subport "" $recurseDeps $skipSatisfied]
+            set res [mportdepends $depport "" $recurseDeps $skipSatisfied 1]
             if {$res != 0} {
                 return $res
             }
@@ -2644,6 +3076,17 @@
     ui_error "and does not have a universal variant."
 }
 
+# check if the given mport has any dependencies of the given types
+proc macports::_mport_has_deptypes {mport deptypes} {
+    array set portinfo [mportinfo $mport]
+    foreach type $deptypes {
+        if {[info exists portinfo($type)] && $portinfo($type) != ""} {
+            return 1
+        }
+    }
+    return 0
+}
+
 # check if the given target needs dependencies installed first
 proc macports::_target_needs_deps {target} {
     # XXX: need a better way than checking this hardcoded list
@@ -2657,7 +3100,6 @@
         test -
         destroot -
         install -
-        archive -
         activate -
         dmg -
         mdmg -
@@ -2682,7 +3124,6 @@
         test        -
         srpm        -
         destroot    { return "depends_fetch depends_extract depends_build depends_lib depends_run" }
-        archive     -
         dmg         -
         pkg         -
         mdmg        -
@@ -2698,7 +3139,7 @@
         install     -
         activate    -
         ""          {
-            if {[$workername eval registry_exists \$name \$version \$revision \$portvariants]
+            if {[$workername eval registry_exists \$subport \$version \$revision \$portvariants]
                 || [$workername eval _archive_available]} {
                 return "depends_lib depends_run"
             } else {
@@ -2713,6 +3154,7 @@
 proc macports::selfupdate {{optionslist {}} {updatestatusvar ""}} {
     global macports::prefix macports::portdbpath macports::libpath macports::rsync_server macports::rsync_dir macports::rsync_options
     global macports::autoconf::macports_version macports::autoconf::rsync_path tcl_platform
+    global macports::autoconf::openssl_path macports::autoconf::tar_path
     array set options $optionslist
     
     # variable that indicates whether we actually updated base
@@ -2721,27 +3163,68 @@
         set updatestatus no
     }
 
-    # syncing ports tree.
-    if {![info exists options(ports_selfupdate_nosync)] || $options(ports_selfupdate_nosync) != "yes"} {
-        ui_msg "--->  Updating the ports tree"
-        if {[catch {mportsync $optionslist} result]} {
-            return -code error "Couldn't sync the ports tree: $result"
+    # are we syncing a tarball? (implies detached signature)
+    set is_tarball 0
+    if {[string range ${rsync_dir} end-3 end] == ".tar"} {
+        set is_tarball 1
+        set mp_source_path [file join $portdbpath sources ${rsync_server} [file dirname ${rsync_dir}]]
+    } else {
+        if {[string index $rsync_dir end] != "/"} {
+            append rsync_dir "/"
         }
+        set mp_source_path [file join $portdbpath sources ${rsync_server} ${rsync_dir}]
     }
-
     # create the path to the to be downloaded sources if it doesn't exist
-    set mp_source_path [file join $portdbpath sources ${rsync_server} ${rsync_dir}/]
     if {![file exists $mp_source_path]} {
         file mkdir $mp_source_path
     }
     ui_debug "MacPorts sources location: $mp_source_path"
 
     # sync the MacPorts sources
-    ui_msg "--->  Updating MacPorts base sources using rsync"
+    ui_msg "$macports::ui_prefix Updating MacPorts base sources using rsync"
     if { [catch { system "$rsync_path $rsync_options rsync://${rsync_server}/${rsync_dir} $mp_source_path" } result ] } {
        return -code error "Error synchronizing MacPorts sources: $result"
     }
 
+    if {$is_tarball} {
+        # verify signature for tarball
+        global macports::archivefetch_pubkeys
+        if { [catch { system "$rsync_path $rsync_options rsync://${rsync_server}/${rsync_dir}.rmd160 $mp_source_path" } result ] } {
+            return -code error "Error synchronizing MacPorts source signature: $result"
+        }
+        set openssl [findBinary openssl $macports::autoconf::openssl_path]
+        set tarball "${mp_source_path}/[file tail $rsync_dir]"
+        set signature "${tarball}.rmd160"
+        set verified 0
+        foreach pubkey ${macports::archivefetch_pubkeys} {
+            if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature $signature $tarball} result]} {
+                set verified 1
+                ui_debug "successful verification with key $pubkey"
+                break
+            } else {
+                ui_debug "failed verification with key $pubkey"
+                ui_debug "openssl output: $result"
+            }
+        }
+        if {!$verified} {
+            return -code error "Failed to verify signature for MacPorts source!"
+        }
+        
+        # extract tarball and move into place
+        set tar [macports::findBinary tar $macports::autoconf::tar_path]
+        file mkdir ${mp_source_path}/tmp
+        set tar_cmd "$tar -C ${mp_source_path}/tmp -xf ${tarball}"
+        ui_debug $tar_cmd
+        if {[catch {system $tar_cmd}]} {
+            return -code error "Failed to extract MacPorts sources from tarball!"
+        }
+        file delete -force ${mp_source_path}/base
+        file rename ${mp_source_path}/tmp/base ${mp_source_path}/base
+        file delete -force ${mp_source_path}/tmp
+        # set the final extracted source path
+        set mp_source_path ${mp_source_path}/base
+    }
+
     # echo current MacPorts version
     ui_msg "MacPorts base version $macports::autoconf::macports_version installed,"
 
@@ -2767,12 +3250,25 @@
     }
 
     # check if we we need to rebuild base
-    set comp [rpm-vercomp $macports_version_new $macports::autoconf::macports_version]
+    set comp [vercmp $macports_version_new $macports::autoconf::macports_version]
+
+    # syncing ports tree.
+    if {![info exists options(ports_selfupdate_nosync)] || $options(ports_selfupdate_nosync) != "yes"} {
+        if {$comp > 0} {
+            # updated portfiles potentially need new base to parse - tell sync to try to 
+            # use prefabricated PortIndex files and signal if it couldn't
+            lappend optionslist no_reindex 1 needed_portindex_var needed_portindex
+        }
+        if {[catch {mportsync $optionslist} result]} {
+            return -code error "Couldn't sync the ports tree: $result"
+        }
+    }
+
     if {$use_the_force_luke == "yes" || $comp > 0} {
         if {[info exists options(ports_dryrun)] && $options(ports_dryrun) == "yes"} {
-            ui_msg "--->  MacPorts base is outdated, selfupdate would install $macports_version_new (dry run)"
+            ui_msg "$macports::ui_prefix MacPorts base is outdated, selfupdate would install $macports_version_new (dry run)"
         } else {
-            ui_msg "--->  MacPorts base is outdated, installing new version $macports_version_new"
+            ui_msg "$macports::ui_prefix MacPorts base is outdated, installing new version $macports_version_new"
 
             # get installation user/group and permissions
             set owner [file attributes ${prefix} -owner]
@@ -2802,16 +3298,19 @@
                 ui_warn "Disabling readline support due to readline in /usr/local"
             }
 
+            if {$prefix == "/usr/local" || $prefix == "/usr"} {
+                append configure_args " --with-unsupported-prefix"
+            }
+
+            # Choose a sane compiler
             set cc_arg ""
-            switch -glob -- $::macports::macosx_version {
-                10.{4,5} { set cc_arg "CC=/usr/bin/gcc-4.0 " }
-                10.6     { set cc_arg "CC=/usr/bin/gcc-4.2 " }
-                10.*     { set cc_arg "CC=/usr/bin/llvm-gcc-4.2 " }
+            if {$::macports::os_platform == "darwin"} {
+                set cc_arg "CC=/usr/bin/cc "
             }
 
             # do the actual configure, build and installation of new base
             ui_msg "Installing new MacPorts release in $prefix as $owner:$group; permissions $perms; Tcl-Package in $tclpackage\n"
-            if { [catch { system "cd $mp_source_path && ${cc_arg}./configure $configure_args && make && make install" } result] } {
+            if { [catch { system "cd $mp_source_path && ${cc_arg}./configure $configure_args && make && make install SELFUPDATING=1" } result] } {
                 return -code error "Error installing new MacPorts base: $result"
             }
             if {[info exists updatestatus]} {
@@ -2819,9 +3318,9 @@
             }
         }
     } elseif {$comp < 0} {
-        ui_msg "--->  MacPorts base is probably trunk or a release candidate"
+        ui_msg "$macports::ui_prefix MacPorts base is probably trunk or a release candidate"
     } else {
-        ui_msg "--->  MacPorts base is already the latest version"
+        ui_msg "$macports::ui_prefix MacPorts base is already the latest version"
     }
 
     # set the MacPorts sources to the right owner
@@ -2832,8 +3331,13 @@
     }
 
     if {![info exists options(ports_selfupdate_nosync)] || $options(ports_selfupdate_nosync) != "yes"} {
-        ui_msg "\nThe ports tree has been updated. To upgrade your installed ports, you should run"
-        ui_msg "  port upgrade outdated"
+        if {[info exists needed_portindex]} {
+            ui_msg "Not all sources could be fully synced using the old version of MacPorts."
+            ui_msg "Please run selfupdate again now that MacPorts base has been updated."
+        } else {
+            ui_msg "\nThe ports tree has been updated. To upgrade your installed ports, you should run"
+            ui_msg "  port upgrade outdated"
+        }
     }
 
     return 0
@@ -2865,13 +3369,12 @@
     if {!$orig_nodeps} {
         unset -nocomplain macports::global_options(ports_nodeps)
     }
+
     return $status
 }
 
 # main internal upgrade procedure
 proc macports::_upgrade {portname dspec variationslist optionslist {depscachename ""}} {
-    global macports::registry.installtype
-    global macports::portarchivemode
     global macports::global_variations
     array set options $optionslist
 
@@ -2885,6 +3388,16 @@
         set is_dryrun yes
     }
 
+    # Is this a rev-upgrade-called run?
+    set is_revupgrade no
+    if {[macports::global_option_isset ports_revupgrade]} {
+        set is_revupgrade yes
+    }
+    set is_revupgrade_second_run no
+    if {[macports::global_option_isset ports_revupgrade_second_run]} {
+        set is_revupgrade_second_run yes
+    }
+
     # check if the port is in tree
     if {[catch {mportlookup $portname} result]} {
         global errorInfo
@@ -2901,6 +3414,7 @@
     array set portinfo [lindex $result 1]
     # set portname again since the one we were passed may not have had the correct case
     set portname $portinfo(name)
+    set options(subport) $portname
 
     set ilist {}
     if { [catch {set ilist [registry::installed $portname ""]} result] } {
@@ -2987,10 +3501,10 @@
         set version [lindex $i 1]
         set revision [lindex $i 2]
         set epoch [lindex $i 5]
-        if { $version_installed == {} || $epoch > $epoch_installed ||
-                ($epoch == $epoch_installed && [rpm-vercomp $version $version_installed] > 0)
-                || ($epoch == $epoch_installed
-                    && [rpm-vercomp $version $version_installed] == 0
+        if { $version_installed == {} || ($epoch > $epoch_installed && $version != $version_installed) ||
+                ($epoch >= $epoch_installed && [vercmp $version $version_installed] > 0)
+                || ($epoch >= $epoch_installed
+                    && [vercmp $version $version_installed] == 0
                     && $revision > $revision_installed)} {
             set version_installed $version
             set revision_installed $revision
@@ -3077,7 +3591,7 @@
     
     # at this point we need to check if a different port will be replacing this one
     if {[info exists portinfo(replaced_by)] && ![info exists options(ports_upgrade_no-replace)]} {
-        ui_msg "--->  $portname is replaced by $portinfo(replaced_by)"
+        ui_msg "$macports::ui_prefix $portname is replaced by $portinfo(replaced_by)"
         if {[catch {mportlookup $portinfo(replaced_by)} result]} {
             global errorInfo
             ui_debug "$errorInfo"
@@ -3103,6 +3617,7 @@
 
     array set interp_options [array get options]
     set interp_options(ports_requested) $requestedflag
+    set interp_options(subport) $newname
 
     if {[catch {set workername [mportopen $porturl [array get interp_options] [array get variations]]} result]} {
         global errorInfo
@@ -3121,9 +3636,9 @@
     set build_override 0
     set will_install yes
     # check installed version against version in ports
-    if { ( [rpm-vercomp $version_installed $version_in_tree] > 0
-            || ([rpm-vercomp $version_installed $version_in_tree] == 0
-                && [rpm-vercomp $revision_installed $revision_in_tree] >= 0 ))
+    if { ( [vercmp $version_installed $version_in_tree] > 0
+            || ([vercmp $version_installed $version_in_tree] == 0
+                && [vercmp $revision_installed $revision_in_tree] >= 0 ))
         && ![info exists options(ports_upgrade_force)] } {
         if {$portname != $newname} { 
             ui_debug "ignoring versions, installing replacement port"
@@ -3138,6 +3653,11 @@
                   || [_mportkey $workername "{os.major}"] != $os_major_installed)} {
             ui_debug "platform mismatch ... upgrading!"
             set build_override 1
+        } elseif {$is_revupgrade_second_run} {
+            set build_override 1
+        } elseif {$is_revupgrade} {
+            # in the first run of rev-upgrade, only activate possibly already existing files and check for missing dependencies
+            set will_install yes
         } else {
             if {[info exists portinfo(canonical_active_variants)] && $portinfo(canonical_active_variants) != $oldvariant} {
                 if {[llength $variationslist] > 0} {
@@ -3154,13 +3674,15 @@
 
     set will_build no
     # 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)])} {
+    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)])} {
         set will_build yes
     }
 
     # first upgrade dependencies
-    if {![info exists options(ports_nodeps)]} {
+    if {![info exists options(ports_nodeps)] && !$is_revupgrade} {
         set status [_upgrade_dependencies portinfo depscache variationslist options $will_build]
         if {$status != 0 && $status != 2 && ![ui_isset ports_processall]} {
             catch {mportclose $workername}
@@ -3201,13 +3723,8 @@
     }
 
     if {$will_build} {
-        # build or unarchive version_in_tree
-        if {0 == [string compare "yes" ${macports::portarchivemode}]} {
-            set upgrade_action "archive"
-        } else {
-            set upgrade_action "destroot"
-        }
-        if {[catch {set result [mportexec $workername $upgrade_action]} result] || $result != 0} {
+        # install version_in_tree (but don't activate yet)
+        if {[catch {set result [mportexec $workername install]} result] || $result != 0} {
             if {[info exists ::errorInfo]} {
                 ui_debug "$::errorInfo"
             }
@@ -3217,82 +3734,59 @@
         }
     }
 
-    # always uninstall old port in direct mode
-    global macports::registry.format
-    if { 0 != [string compare "image" ${macports::registry.installtype}] } {
-        # uninstall old
-        ui_debug "Uninstalling $portname ${version_installed}_${revision_installed}${variant_installed}"
+    # 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)]
+        && ([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
         set force_cur [info exists options(ports_force)]
         set options(ports_force) yes
+        set existing_epoch [lindex [lindex [registry::installed $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants)] 0] 5]
+        set newregref [registry::open_entry $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants) $existing_epoch]
         if {$is_dryrun eq "yes"} {
-            ui_msg "Skipping uninstall $portname @${version_installed}_${revision_installed}${variant_installed} (dry run)"
-        } elseif {(${registry.format} != "receipt_sqlite" || ![registry::run_target $regref uninstall [array get options]])
-                  && [catch {registry_uninstall::uninstall $portname ${version_installed}_${revision_installed}${variant_installed} [array get options]} result]} {
+            ui_msg "Skipping uninstall $newname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)"
+        } elseif {![registry::run_target $newregref uninstall [array get options]]
+                  && [catch {registry_uninstall::uninstall $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants) [array get options]} result]} {
             global errorInfo
             ui_debug "$errorInfo"
-            ui_error "Uninstall $portname ${version_installed}_${revision_installed}${variant_installed} failed: $result"
+            ui_error "Uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) failed: $result"
             catch {mportclose $workername}
             return 1
         }
         if {!$force_cur} {
             unset options(ports_force)
         }
-    } else {
-        # 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)]
-            && ([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
-            set force_cur [info exists options(ports_force)]
-            set options(ports_force) yes
-            set existing_epoch [lindex [lindex [registry::installed $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants)] 0] 5]
-            set newregref [registry::open_entry $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants) $existing_epoch]
-            if {$is_dryrun eq "yes"} {
-                ui_msg "Skipping uninstall $newname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)"
-            } elseif {!(${registry.format} == "receipt_sqlite" && [registry::run_target $newregref uninstall [array get options]])
-                      && [catch {registry_uninstall::uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) [array get options]} result]} {
-                global errorInfo
-                ui_debug "$errorInfo"
-                ui_error "Uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) failed: $result"
-                catch {mportclose $workername}
-                return 1
-            }
-            if {!$force_cur} {
-                unset options(ports_force)
-            }
-            if {$anyactive && $version_in_tree == $version_active && $revision_in_tree == $revision_active
-                && $portinfo(canonical_active_variants) == $variant_active && $portname == $newname} {
-                set anyactive no
-            }
-        }
-        if {$anyactive && $portname != $newname} {
-            # replaced_by in effect, deactivate the old port
-            # we have to force the deactivate in case of dependents
-            set force_cur [info exists options(ports_force)]
-            set options(ports_force) yes
-            if {$is_dryrun eq "yes"} {
-                ui_msg "Skipping deactivate $portname @${version_active}_${revision_active}${variant_active} (dry run)"
-            } elseif {![catch {registry::active $portname}] &&
-                      !(${registry.format} == "receipt_sqlite" && [registry::run_target $regref deactivate [array get options]])
-                      && [catch {portimage::deactivate $portname ${version_active}_${revision_active}${variant_active} [array get options]} result]} {
-                global errorInfo
-                ui_debug "$errorInfo"
-                ui_error "Deactivating $portname @${version_active}_${revision_active}${variant_active} failed: $result"
-                catch {mportclose $workername}
-                return 1
-            }
-            if {!$force_cur} {
-                unset options(ports_force)
-            }
+        if {$anyactive && $version_in_tree == $version_active && $revision_in_tree == $revision_active
+            && $portinfo(canonical_active_variants) == $variant_active && $portname == $newname} {
             set anyactive no
         }
-        if {[info exists options(port_uninstall_old)] && $portname == $newname} {
-            # uninstalling now could fail due to dependents when not forced,
-            # because the new version is not installed
-            set uninstall_later yes
+    }
+    if {$anyactive && $portname != $newname} {
+        # replaced_by in effect, deactivate the old port
+        # we have to force the deactivate in case of dependents
+        set force_cur [info exists options(ports_force)]
+        set options(ports_force) yes
+        if {$is_dryrun eq "yes"} {
+            ui_msg "Skipping deactivate $portname @${version_active}_${revision_active}${variant_active} (dry run)"
+        } elseif {![catch {registry::active $portname}] &&
+                  ![registry::run_target $regref deactivate [array get options]]
+                  && [catch {portimage::deactivate $portname $version_active $revision_active $variant_active [array get options]} result]} {
+            global errorInfo
+            ui_debug "$errorInfo"
+            ui_error "Deactivating $portname @${version_active}_${revision_active}${variant_active} failed: $result"
+            catch {mportclose $workername}
+            return 1
         }
+        if {!$force_cur} {
+            unset options(ports_force)
+        }
+        set anyactive no
     }
+    if {[info exists options(port_uninstall_old)] && $portname == $newname} {
+        # uninstalling now could fail due to dependents when not forced,
+        # because the new version is not installed
+        set uninstall_later yes
+    }
 
     if {$is_dryrun eq "yes"} {
         if {$anyactive} {
@@ -3351,8 +3845,8 @@
             set regref [registry::open_entry $portname $version $revision $variant $epoch]
             if {$is_dryrun eq "yes"} {
                 ui_msg "Skipping uninstall $portname @${version}_${revision}${variant} (dry run)"
-            } elseif {!(${registry.format} == "receipt_sqlite" && [registry::run_target $regref uninstall $optionslist])
-                      && [catch {registry_uninstall::uninstall $portname ${version}_${revision}${variant} $optionslist} result]} {
+            } elseif {![registry::run_target $regref uninstall $optionslist]
+                      && [catch {registry_uninstall::uninstall $portname $version $revision $variant $optionslist} result]} {
                 global errorInfo
                 ui_debug "$errorInfo"
                 # replaced_by can mean that we try to uninstall all versions of the old port, so handle errors due to dependents
@@ -3461,7 +3955,7 @@
         }
         set {
             # Use $conf_path/$version to read in sources.
-            if {$version == "base" || $version == "current"
+            if {$version == "" || $version == "base" || $version == "current"
                     || [catch {set src_file [open "$conf_path/$version"]} result]} {
                 global errorInfo
                 ui_debug "$result: $errorInfo"
@@ -3533,3 +4027,517 @@
     }
     return
 }
+
+# Return a good temporary directory to use; /tmp if TMPDIR is not set
+# in the environment
+proc macports::gettmpdir {args} {
+    global env
+
+    if {[info exists env(TMPDIR)]} {
+        return $env(TMPDIR)
+    } else {
+        return "/tmp"
+    }
+}
+
+# check if the system we're on can run code of the given architecture
+proc macports::arch_runnable {arch} {
+    global macports::os_major macports::os_arch macports::os_platform
+    if {${macports::os_platform} == "darwin"} {
+        if {${macports::os_major} >= 11 && [string first "ppc" $arch] == 0} {
+            return no
+        } elseif {${macports::os_arch} == "i386" && $arch == "ppc64"} {
+            return no
+        } elseif {${macports::os_major} <= 8 && $arch == "x86_64"} {
+            return no
+        }
+    }
+    return yes
+}
+
+proc macports::revupgrade {opts} {
+    set run_loop 1
+    array set broken_port_counts {}
+    while {$run_loop == 1} {
+        set run_loop [revupgrade_scanandrebuild broken_port_counts $opts]
+    }
+    return 0
+}
+
+# returns 1 if ports were rebuilt and revupgrade_scanandrebuild should be called again
+proc macports::revupgrade_scanandrebuild {broken_port_counts_name opts} {
+    upvar $broken_port_counts_name broken_port_counts
+    array set options $opts
+
+    set files [registry::file search active 1 binary -null]
+    if {[llength $files] > 0} {
+        set files_count [llength $files]
+        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 {$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]"
+                    incr i
+
+                    if {0 != [catch {$f binary [fileIsBinary [$f path]]} fileIsBinaryError]} {
+                        # handle errors (e.g. file not found, permission denied) gracefully
+                        if {![macports::ui_isset ports_debug]} {
+                            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."
+                    }
+                }
+            } catch {*} {
+                ui_error "Updating database of binaries failed"
+                throw
+            }
+        }
+        ui_msg ""
+    }
+
+    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 handle [machista::create_handle]
+        if {$handle == "NULL"} {
+            error "Error creating libmachista handle"
+        }
+        array unset files_warned_about
+        array set files_warned_about [list]
+
+        set i 1
+        set binary_count [llength $binaries]
+        foreach b $binaries {
+            if {![macports::ui_isset ports_debug]} {
+                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]"
+            incr i
+
+            set resultlist [machista::parse_file $handle [$b path]]
+            set returncode [lindex $resultlist 0]
+            set result     [lindex $resultlist 1]
+
+            if {$returncode != $machista::SUCCESS} {
+                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]"
+                } else {
+                    if {![macports::ui_isset ports_debug]} {
+                        ui_msg ""
+                    }
+                    ui_warn "Error parsing file [$b path]: [machista::strerror $returncode]"
+                }
+                continue;
+            }
+
+            set architecture [$result cget -mt_archs]
+            while {$architecture != "NULL"} {
+                if {[info exists options(ports_rev-upgrade_id-loadcmd-check)] && $options(ports_rev-upgrade_id-loadcmd-check) == "yes"} {
+                    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 {[string index $idloadcmdpath 0] != "/"} {
+                                set port [registry::entry owner [$b path]]
+                                if {$port != ""} {
+                                    set portname [$port name]
+                                } else {
+                                    set portname "<unknown-port>"
+                                }
+                                if {![macports::ui_isset ports_debug]} {
+                                    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"
+                            } elseif {![file exists $idloadcmdpath]} {
+                                set port [registry::entry owner [$b path]]
+                                if {$port != ""} {
+                                    set portname [$port name]
+                                } else {
+                                    set portname "<unknown-port>"
+                                }
+                                if {![macports::ui_isset ports_debug]} {
+                                    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 "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_idloadcmd [sha256 file $idloadcmdpath]
+    
+                                if {$hash_this != $hash_idloadcmd} {
+                                    set port [registry::entry owner [$b path]]
+                                    if {$port != ""} {
+                                        set portname [$port name]
+                                    } else {
+                                        set portname "<unknown-port>"
+                                    }
+                                    if {![macports::ui_isset ports_debug]} {
+                                        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 "This is probably a bug in the $portname port and might cause problems in libraries linking against this file"
+                                }
+                            }
+                        }
+                    }
+                }
+
+                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"
+                    set architecture [$architecture cget -next]
+                    continue
+                }
+
+                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]]}]} {
+                        set loadcommand [$loadcommand cget -next]
+                        continue;
+                    }
+
+                    set libresultlist [machista::parse_file $handle $filepath]
+                    set libreturncode [lindex $libresultlist 0]
+                    set libresult     [lindex $libresultlist 1]
+
+                    if {$libreturncode != $machista::SUCCESS} {
+                        if {![info exists files_warned_about($filepath)]} {
+                            if {![macports::ui_isset ports_debug]} {
+                                ui_msg ""
+                            }
+                            ui_warn "Could not open $filepath: [machista::strerror $libreturncode]"
+                            set files_warned_about($filepath) yes
+                        }
+                        if {$libreturncode == $machista::EFILE} {
+                            ui_debug "Marking [$b path] as broken"
+                            lappend broken_files [$b path]
+                        }
+                        set loadcommand [$loadcommand cget -next]
+                        continue;
+                    }
+
+                    set libarchitecture [$libresult cget -mt_archs]
+                    set libarch_found false;
+                    while {$libarchitecture != "NULL"} {
+                        if {[$architecture cget -mat_arch] != [$libarchitecture cget -mat_arch]} {
+                            set libarchitecture [$libarchitecture cget -next]
+                            continue;
+                        }
+
+                        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]} {
+                                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]
+                        }
+
+                        set libarch_found true;
+                        break;
+                    }
+
+                    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]
+                        } else {
+                            ui_debug "Missing architecture [machista::get_arch_name [$architecture cget -mat_arch]] in file outside prefix referenced from [$b path]"
+                            # ui_debug "   How did you get that compiled anyway?"
+                        }
+                    }
+                    set loadcommand [$loadcommand cget -next]
+                }
+
+                set architecture [$architecture cget -next]
+            }
+        }
+        ui_msg ""
+
+        machista::destroy_handle $handle
+
+        if {[llength $broken_files] == 0} {
+            ui_msg "$macports::ui_prefix No broken files found."
+            return 0
+        }
+        ui_msg "$macports::ui_prefix Found [llength $broken_files] broken file(s), matching files to ports"
+        set broken_ports {}
+        set broken_files [lsort -unique $broken_files]
+        foreach file $broken_files {
+            set port [registry::entry owner $file]
+            if {$port != ""} {
+                lappend broken_ports $port
+                lappend broken_files_by_port($port) $file
+            } else {
+                ui_error "Broken file $file doesn't belong to any port."
+            }
+        }
+        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
+            }
+            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]} {
+                    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)"
+            }
+        }
+
+        if {${macports::revupgrade_mode} != "rebuild"} {
+            ui_msg "$macports::ui_prefix Found [llength $broken_ports] broken port(s):"
+            foreach port $broken_ports {
+                ui_msg "     [$port name] @[$port version] [$port variants][$port negated_variants]"
+                foreach f $broken_files_by_port($port) {
+                    ui_msg "         $f"
+                }
+            }
+            return 0
+        }
+
+        ui_msg "$macports::ui_prefix Found [llength $broken_ports] broken port(s), determining rebuild order"
+        # broken_ports are the nodes in our graph
+        # now we need adjacents
+        foreach port $broken_ports {
+            # initialize with empty list
+            set adjlist($port) {}
+            set revadjlist($port) {}
+        }
+
+        array set visited {}
+        foreach port $broken_ports {
+            # stack of broken nodes we've come across
+            set stack {}
+            lappend stack $port
+
+            # build graph
+            if {![info exists visited($port)]} {
+                revupgrade_buildgraph $port stack adjlist revadjlist visited
+            }
+        }
+
+        set unsorted_ports $broken_ports
+        set topsort_ports {}
+        while {[llength $unsorted_ports] > 0} {
+            set lowest_adj_number [llength $adjlist([lindex $unsorted_ports 0])]
+            set lowest_adj_port [lindex $unsorted_ports 0]
+
+            foreach port $unsorted_ports {
+                set len [llength $adjlist($port)]
+                if {$len < $lowest_adj_number} {
+                    set lowest_adj_port $port
+                }
+                if {$len == 0} {
+                    # this node has no further dependencies
+                    # add it to topsorted list
+                    lappend topsort_ports $port
+                    # remove from unsorted list
+                    set index [lsearch -exact $unsorted_ports $port]
+                    set unsorted_ports [lreplace $unsorted_ports $index $index]
+
+                    # remove edges 
+                    foreach target $revadjlist($port) {
+                        set index [lsearch -exact $adjlist($target) $port]
+                        set adjlist($target) [lreplace $adjlist($target) $index $index]
+                    }
+                }
+
+                # start anew
+                break;
+            }
+
+            # if we arrive here and lowest_adj_number is larger than 0, then we
+            # have a loop in the graph and need to break it somehow
+            if {$lowest_adj_number > 0} {
+                ui_debug "Breaking loop in dependency graph by starting with [$lowest_adj_port name], which has $lowest_adj_number dependencies"
+                lappend topsort_ports $lowest_adj_port
+
+                set index [lsearch -exact $unsorted_ports $lowest_adj_port]
+                set unsorted_ports [lreplace $unsorted_ports $index $index]
+
+                foreach target $revadjlist($port) {
+                    set index [lsearch -exact $adjlist($target) $lowest_adj_port]
+                    set adjlist($target) [lreplace $adjlist($target) $index $index]
+                }
+            }
+        }
+
+        ui_msg "$macports::ui_prefix Rebuilding in order"
+        foreach port $topsort_ports {
+            ui_msg "     [$port name] @[$port version] [$port variants][$port negated_variants]"
+        }
+
+        # shared depscache for all ports that are going to be rebuilt
+        array set depscache {}
+        set status 0
+        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 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
+                    # build from source only until the buildbot has some method of rev-upgrade, too
+                    set macports::global_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"
+                if {$status != 0} {
+                    error "Error rebuilding [$port name]"
+                }
+            }
+        }
+
+        if {[info exists options(ports_dryrun)] && $options(ports_dryrun) == "yes"} {
+            ui_warn "If this was no dry run, rev-upgrade would now run the checks again to find unresolved and newly created problems"
+            return 0
+        }
+        return 1
+    }
+
+    return 0
+}
+
+# Return whether a path is in the macports prefix
+# Usage: path_is_in_prefix path_to_test
+# Returns true if the path is in the prefix, false otherwise
+proc macports::path_is_in_prefix {path} {
+    global macports::prefix macports::applications_dir
+    if {[string first $macports::prefix $path] == 0} {
+        return yes
+    }
+    if {[string first $macports::applications_dir $path] == 0} {
+        return yes
+    }
+    return no
+}
+
+# Function to replace macros in loadcommand paths with their proper values (which are usually determined at load time)
+# Usage: revupgrade_handle_special_paths name_of_file path_from_loadcommand
+# Returns the corrected path on success or an error in case of failure.
+# Note that we can't reliably replace @executable_path, because it's only clear when executing a file where it was executed from.
+# Replacing @rpath does not work yet, but it might be possible to get it working using the rpath attribute in the file containing the
+# loadcommand
+proc macports::revupgrade_handle_special_paths {fname path} {
+    set corrected_path $path
+
+    set loaderpath_idx [string first "@loader_path" $corrected_path]
+    if {$loaderpath_idx != -1} {
+        set corrected_path [string replace $corrected_path $loaderpath_idx $loaderpath_idx+11 [file dirname $fname]]
+    }
+
+    set executablepath_idx [string first "@executable_path" $corrected_path]
+    if {$executablepath_idx != -1} {
+        ui_debug "Ignoring loadcommand containing @executable_path in $fname"
+        error "@executable_path in loadcommand"
+    }
+
+    set rpath_idx [string first "@rpath" $corrected_path]
+    if {$rpath_idx != -1} {
+        ui_debug "Ignoring loadcommand containing @rpath in $fname"
+        error "@rpath in loadcommand"
+    }
+
+    return $corrected_path
+}
+
+# Recursively build the dependency graph between broken ports
+# Usage: revupgrade_buildgraph start_port name_of_stack name_of_adjacency_list name_of_reverse_adjacency_list name_of_visited_map
+proc macports::revupgrade_buildgraph {port stackname adjlistname revadjlistname visitedname} {
+    upvar $stackname stack
+    upvar $adjlistname adjlist
+    upvar $revadjlistname revadjlist
+    upvar $visitedname visited
+
+    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"
+            # $dep is one of the broken ports
+            # add an edge to the last broken port in the DFS
+            lappend revadjlist([lindex $stack 0]) $dep
+            lappend adjlist($dep) [lindex $stack 0]
+            # make this port the new last broken port by prepending it to the stack
+            set stack [linsert $stack 0 $dep]
+            
+            set is_broken_port true
+        }
+        revupgrade_buildgraph $dep stack adjlist revadjlist visited
+        if {$is_broken_port} {
+            #ui_debug "Removing [$dep name] from stack"
+            # remove $dep from the stack
+            set stack [lrange $stack 1 end]
+        }
+    }
+}
+
+# get cached ping time for host, modified by blacklist and preferred list
+proc macports::get_pingtime {host} {
+    global macports::ping_cache macports::host_blacklisted macports::host_preferred
+    if {[info exists host_blacklisted($host)]} {
+        return -1
+    } elseif {[info exists host_preferred($host)]} {
+        return 1
+    } elseif {[info exists ping_cache($host)]} {
+        # expire entries after 1 day
+        if {[expr [clock seconds] - [lindex $ping_cache($host) 1]] <= 86400} {
+            return [lindex $ping_cache($host) 0]
+        }
+    }
+    return {}
+}
+
+# cache a ping time of ms for host
+proc macports::set_pingtime {host ms} {
+    global macports::ping_cache
+    set ping_cache($host) [list $ms [clock seconds]]
+}

Modified: branches/new-help-system/base/src/macports1.0/macports_autoconf.tcl.in
===================================================================
--- branches/new-help-system/base/src/macports1.0/macports_autoconf.tcl.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/macports1.0/macports_autoconf.tcl.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # macports-autoconf.tcl.in
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2006 - 2009, 2011 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -32,14 +33,24 @@
 package provide macports 1.0
 
 namespace eval macports::autoconf {
+    variable bzip2_path "@BZIP2@"
     variable chown_path "@CHOWN@"
     variable gzip_path "@GZIP@"
     variable macports_conf_path "@MPCONFIGDIR_EXPANDED@"
     variable macports_version "@MACPORTS_VERSION@"
     variable macports_user_dir "~/.macports"
     variable macportsuser "@RUNUSR@"
+    variable mdfind_path "@MDFIND@"
+    variable mdls_path "@MDLS@"
     variable open_path "@OPEN@"
+    variable openssl_path "@OPENSSL@"
+    variable pax_path "@PAX@"
     variable rsync_path "@RSYNC@"
     variable tar_command "@TAR_CMD@"
     variable tar_path "@TAR@"
+    variable tar_q "@TAR_Q@"
+    variable unzip_path "@UNZIP@"
+    variable xar_path "@XAR@"
+    variable xcode_select_path "@XCODE_SELECT@"
+    variable xcodebuild_path "@XCODEBUILD@"
 }

Modified: branches/new-help-system/base/src/macports1.0/macports_dlist.tcl
===================================================================
--- branches/new-help-system/base/src/macports1.0/macports_dlist.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/macports1.0/macports_dlist.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,8 +1,9 @@
 # macports1.0/macports_dlist.tcl
 # $Id$
 #
+# Copyright (c) 2004-2005, 2007, 2009, 2011 The MacPorts Project
 # Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
+# Copyright (c) 2002 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -52,6 +53,28 @@
 # Values in the status dict will be {-1, 0, 1} for {failure,
 # pending, success} respectively.
 
+# dlist_match_multi
+# Returns all dependency entries for which the entry's value for 'key' exactly matches the given 'value'.
+#	dlist - the dependency list to search
+#	criteria - the key/value pairs to compare
+
+proc dlist_match_multi {dlist criteria} {
+	set result {}
+	foreach ditem $dlist {
+	    set match 1
+	    foreach {key value} $criteria {
+		    if {[ditem_key $ditem $key] != $value} {
+			    set match 0
+			    break
+		    }
+		}
+		if {$match} {
+		    lappend result $ditem
+		}
+	}
+	return $result
+}
+
 # dlist_search
 # Returns all dependency entries whose 'key' contains 'value'.
 #	dlist - the dependency list to search

Modified: branches/new-help-system/base/src/macports1.0/macports_fastload.tcl.in
===================================================================
--- branches/new-help-system/base/src/macports1.0/macports_fastload.tcl.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/macports1.0/macports_fastload.tcl.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # macports_fastload.tcl.in
 # $Id$
 #
-# Copyright (c) 2004 Paul Guyot, The MacPorts Project.
+# Copyright (c) 2005-2007, 2009-2010 The MacPorts Project
+# Copyright (c) 2004-2005 Paul Guyot, The MacPorts Project.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 

Modified: branches/new-help-system/base/src/macports1.0/macports_index.tcl
===================================================================
--- branches/new-help-system/base/src/macports1.0/macports_index.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/macports1.0/macports_index.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,7 +1,7 @@
 # macports_index.tcl
 # $Id$
 #
-# Copyright (c) 2004 Apple Computer, Inc.
+# Copyright (c) 2004 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -12,7 +12,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 

Modified: branches/new-help-system/base/src/macports1.0/macports_util.tcl
===================================================================
--- branches/new-help-system/base/src/macports1.0/macports_util.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/macports1.0/macports_util.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -12,7 +12,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 

Modified: branches/new-help-system/base/src/macports1.0/tests/macports_dlist.tcl
===================================================================
--- branches/new-help-system/base/src/macports1.0/tests/macports_dlist.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/macports1.0/tests/macports_dlist.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,6 +2,7 @@
 # macports1.0/test_dlist.tcl
 # $Id$
 #
+# Copyright (c) 2007 The MacPorts Project
 # Copyright (c) 2003 Kevin Van Vechten <kevin at opendarwin.org>
 
 # Test suite for macports_dlist package.
@@ -70,7 +71,7 @@
 }
 
 # Replicate Shantonu's Bug #354 to test dlist functionality.
-# http://trac.macports.org/projects/macports/ticket/354
+# https://trac.macports.org/ticket/354
 # A depends on B, C.
 # B depends on C.
 # C has no dependencies.

Modified: branches/new-help-system/base/src/package1.0/Makefile
===================================================================
--- branches/new-help-system/base/src/package1.0/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,7 +1,7 @@
 INSTALLDIR=	${DESTDIR}${datadir}/macports/Tcl/package1.0
 
 SRCS=	package.tcl portdmg.tcl portmdmg.tcl portmpkg.tcl portpkg.tcl portportpkg.tcl \
-	portrpm.tcl portsrpm.tcl portdpkg.tcl portunarchive.tcl portarchive.tcl \
+	portrpm.tcl portsrpm.tcl portdpkg.tcl portunarchive.tcl \
 	portarchivefetch.tcl
 
 include ../../Mk/macports.autoconf.mk

Modified: branches/new-help-system/base/src/package1.0/package.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/package.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/package.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # package.tcl
 # $Id$
 #
-# Copyright (c) 2002 Apple Computer, Inc.
+# Copyright (c) 2004, 2007-2008, 2010 The MacPorts Project
+# Copyright (c) 2002-2004 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -42,4 +43,3 @@
 package require portportpkg 1.0
 package require portarchivefetch 1.0
 package require portunarchive 1.0
-package require portarchive 1.0

Deleted: branches/new-help-system/base/src/package1.0/portarchive.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portarchive.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/portarchive.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,504 +0,0 @@
-# -*- 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
-# portarchive.tcl
-# $Id$
-#
-# Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-# 1. Redistributions of source code must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-#    notice, this list of conditions and the following disclaimer in the
-#    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, 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
-# 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 portarchive 1.0
-package require portutil 1.0
-
-set org.macports.archive [target_new org.macports.archive portarchive::archive_main]
-target_init ${org.macports.archive} portarchive::archive_init
-target_provides ${org.macports.archive} archive
-target_requires ${org.macports.archive} main archivefetch unarchive fetch extract checksum patch configure build destroot
-target_prerun ${org.macports.archive} portarchive::archive_start
-target_postrun ${org.macports.archive} portarchive::archive_finish
-
-namespace eval portarchive {
-}
-
-# defaults
-default archive.dir {${destpath}}
-default archive.env {}
-default archive.cmd {}
-default archive.pre_args {}
-default archive.args {}
-default archive.post_args {}
-
-default archive.destpath {${portarchivepath}}
-default archive.type {}
-default archive.file {}
-default archive.path {}
-
-default archive.meta false
-default archive.metaname {}
-default archive.metapath {}
-
-set_ui_prefix
-
-proc portarchive::archive_init {args} {
-    global UI_PREFIX target_state_fd
-    global package.destpath workpath
-    global ports_force ports_source_only ports_binary_only
-    global name version revision portvariants
-    global archive.destpath archive.type archive.meta
-    global archive.file archive.path archive.fulldestpath
-
-    # Check mode in case archive called directly by user
-    if {[option portarchivemode] != "yes"} {
-        return -code error "Archive mode is not enabled!"
-    }
-
-    # Define archive destination directory and target filename
-    if {![string equal ${archive.destpath} ${workpath}] && ![string equal ${archive.destpath} ""]} {
-        set archive.fulldestpath [file join ${archive.destpath} [option archive.subdir]]
-    } else {
-        set archive.fulldestpath ${archive.destpath}
-    }
-
-    # Determine if archive should be skipped
-    set skipped 0
-    if {[check_statefile target org.macports.archive $target_state_fd]} {
-        return 0
-    } elseif {[check_statefile target org.macports.unarchive $target_state_fd] && ([info exists ports_binary_only] && $ports_binary_only == "yes")} {
-        ui_debug "Skipping archive ($name) since binary-only is set"
-        set skipped 1
-    } elseif {[info exists ports_source_only] && $ports_source_only == "yes"} {
-        ui_debug "Skipping archive ($name) since source-only is set"
-        set skipped 1
-    } else {
-        set unsupported 0
-        set any_missing no
-        foreach archive.type [option portarchivetype] {
-            if {[catch {archiveTypeIsSupported ${archive.type}} errmsg] == 0} {
-                set archstring [join [get_canonical_archs] -]
-                set archive.file "${name}-${version}_${revision}${portvariants}.${archstring}.${archive.type}"
-                set archive.path "[file join ${archive.fulldestpath} ${archive.file}]"
-                if {![file exists ${archive.path}]} {
-                    set any_missing yes
-                }
-            } else {
-                ui_debug "Skipping [string toupper ${archive.type}] archive: $errmsg"
-                incr unsupported
-            }
-        }
-        if {!$any_missing} {
-            # might be nice to allow forcing, but let's fix #16061 first
-            ui_debug "Skipping archive ($name) since archive(s) already exist"
-            set skipped 1
-        }
-        if {${archive.type} == "xpkg"} {
-            set archive.meta true
-        }
-        if {[llength [option portarchivetype]] == $unsupported} {
-            ui_debug "Skipping archive ($name) since specified archive types not supported"
-            set skipped 1
-        }
-    }
-    # Skip archive target by setting state
-    if {$skipped == 1} {
-        write_statefile target "org.macports.archive" $target_state_fd
-    }
-
-    return 0
-}
-
-proc portarchive::archive_start {args} {
-    global UI_PREFIX
-    global name version revision portvariants
-
-    if {[llength [option portarchivetype]] > 1} {
-        ui_msg "$UI_PREFIX [format [msgcat::mc "Packaging [join [option portarchivetype] {, }] archives for %s %s_%s%s"] $name $version $revision $portvariants]"
-    } else {
-        ui_msg "$UI_PREFIX [format [msgcat::mc "Packaging [option portarchivetype] archive for %s %s_%s%s"] $name $version $revision $portvariants]"
-    }
-
-    return 0
-}
-
-proc portarchive::archive_command_setup {args} {
-    global archive.env archive.cmd
-    global archive.pre_args archive.args archive.post_args
-    global archive.type archive.path
-    global archive.metaname archive.metapath
-    global os.platform os.version
-
-    # Define appropriate archive command and options
-    set archive.env {}
-    set archive.cmd {}
-    set archive.pre_args {}
-    set archive.args {}
-    set archive.post_args {}
-    switch -regex ${archive.type} {
-        cp(io|gz) {
-            set pax "pax"
-            if {[catch {set pax [findBinary $pax ${portutil::autoconf::pax_path}]} errmsg] == 0} {
-                ui_debug "Using $pax"
-                set archive.cmd "$pax"
-                set archive.pre_args {-w -v -x cpio}
-                if {[regexp {z$} ${archive.type}]} {
-                    set gzip "gzip"
-                    if {[catch {set gzip [findBinary $gzip ${portutil::autoconf::gzip_path}]} errmsg] == 0} {
-                        ui_debug "Using $gzip"
-                        set archive.args {.}
-                        set archive.post_args "| $gzip -c9 > ${archive.path}"
-                    } else {
-                        ui_debug $errmsg
-                        return -code error "No '$gzip' was found on this system!"
-                    }
-                } else {
-                    set archive.args "-f ${archive.path} ."
-                }
-            } else {
-                ui_debug $errmsg
-                return -code error "No '$pax' was found on this system!"
-            }
-        }
-        t(ar|bz|lz|xz|gz) {
-            set tar "tar"
-            if {[catch {set tar [findBinary $tar ${portutil::autoconf::tar_path}]} errmsg] == 0} {
-                ui_debug "Using $tar"
-                set archive.cmd "$tar"
-                set archive.pre_args {-cvf}
-                if {[regexp {z2?$} ${archive.type}]} {
-                    if {[regexp {bz2?$} ${archive.type}]} {
-                        set gzip "bzip2"
-                        set level 9
-                    } elseif {[regexp {lz$} ${archive.type}]} {
-                        set gzip "lzma"
-                        set level 7
-                    } elseif {[regexp {xz$} ${archive.type}]} {
-                        set gzip "xz"
-                        set level 6
-                    } else {
-                        set gzip "gzip"
-                        set level 9
-                    }
-                    if {[info exists portutil::autoconf::${gzip}_path]} {
-                        set hint [set portutil::autoconf::${gzip}_path]
-                    } else {
-                        set hint ""
-                    }
-                    if {[catch {set gzip [findBinary $gzip $hint]} errmsg] == 0} {
-                        ui_debug "Using $gzip"
-                        set archive.args {- .}
-                        set archive.post_args "| $gzip -c$level > ${archive.path}"
-                    } else {
-                        ui_debug $errmsg
-                        return -code error "No '$gzip' was found on this system!"
-                    }
-                } else {
-                    set archive.args "${archive.path} ."
-                }
-            } else {
-                ui_debug $errmsg
-                return -code error "No '$tar' was found on this system!"
-            }
-        }
-        xar {
-            set xar "xar"
-            if {[catch {set xar [findBinary $xar ${portutil::autoconf::xar_path}]} errmsg] == 0} {
-                ui_debug "Using $xar"
-                set archive.cmd "$xar"
-                set archive.pre_args {-cvf}
-                set archive.args "${archive.path} ."
-            } else {
-                ui_debug $errmsg
-                return -code error "No '$xar' was found on this system!"
-            }
-        }
-        xpkg {
-            set xar "xar"
-            set compression "bzip2"
-            if {[catch {set xar [findBinary $xar ${portutil::autoconf::xar_path}]} errmsg] == 0} {
-                ui_debug "Using $xar"
-                set archive.cmd "$xar"
-                set archive.pre_args "-cv --exclude='\./\+.*' --compression=${compression} -n ${archive.metaname} -s ${archive.metapath} -f"
-                set archive.args "${archive.path} ."
-            } else {
-                ui_debug $errmsg
-                return -code error "No '$xar' was found on this system!"
-            }
-        }
-        zip {
-            set zip "zip"
-            if {[catch {set zip [findBinary $zip ${portutil::autoconf::zip_path}]} errmsg] == 0} {
-                ui_debug "Using $zip"
-                set archive.cmd "$zip"
-                set archive.pre_args {-ry9}
-                set archive.args "${archive.path} ."
-            } else {
-                ui_debug $errmsg
-                return -code error "No '$zip' was found on this system!"
-            }
-        }
-        default {
-            return -code error "Invalid port archive type '${archive.type}' specified!"
-        }
-    }
-
-    return 0
-}
-
-proc portarchive::putel { fd el data } {
-    # Quote xml data
-    set quoted [string map  { & & < < > > } $data]
-    # Write the element
-    puts $fd "<${el}>${quoted}</${el}>"
-}
-
-proc portarchive::putlist { fd listel itemel list } {
-    puts $fd "<$listel>"
-    foreach item $list {
-        putel $fd $itemel $item
-    }
-    puts $fd "</$listel>"
-}
-
-proc portarchive::archive_main {args} {
-    global UI_PREFIX PortInfo
-    global workpath destpath portpath ports_force
-    global name epoch version revision portvariants
-    global archive.fulldestpath archive.type archive.file archive.path
-    global archive.meta archive.metaname archive.metapath
-    global os.platform
-
-    if {[getuid] == 0 && [geteuid] != 0} {
-        elevateToRoot "archive"
-    }
-
-    # Create archive destination path (if needed)
-    if {![file isdirectory ${archive.fulldestpath}]} {
-        file mkdir ${archive.fulldestpath}
-    }
-
-    # Create (if no files) destroot for archiving
-    if {![file isdirectory ${destpath}]} {
-        file mkdir ${destpath}
-    }
-
-    # Copy state file into destroot for archiving
-    # +STATE contains a copy of the MacPorts state information
-    set statefile [file join $workpath .macports.${name}.state]
-    file copy -force $statefile [file join $destpath "+STATE"]
-
-    # Copy Portfile into destroot for archiving
-    # +PORTFILE contains a copy of the MacPorts Portfile
-    set portfile [file join $portpath Portfile]
-    file copy -force $portfile [file join $destpath "+PORTFILE"]
-
-    # Create some informational files that we don't really use just yet,
-    # but we may in the future in order to allow port installation from
-    # archives without a full "ports" tree of Portfiles.
-    #
-    # Note: These have been modeled after FreeBSD type package files to
-    # start. We can change them however we want for actual future use if
-    # needed.
-    #
-    # +COMMENT contains the port description
-    set fd [open [file join $destpath "+COMMENT"] w]
-    if {[exists description]} {
-        puts $fd "[option description]"
-    }
-    close $fd
-    # +DESC contains the port long_description and homepage
-    set fd [open [file join $destpath "+DESC"] w]
-    if {[exists long_description]} {
-        puts $fd "[option long_description]"
-    }
-    if {[exists homepage]} {
-        puts $fd "\nWWW: [option homepage]"
-    }
-    close $fd
-    # +CONTENTS contains the port version/name info and all installed
-    # files and checksums
-    set control [list]
-    set fd [open [file join $destpath "+CONTENTS"] w]
-    puts $fd "@name ${name}-${version}_${revision}${portvariants}"
-    puts $fd "@portname ${name}"
-    puts $fd "@portepoch ${epoch}"
-    puts $fd "@portversion ${version}"
-    puts $fd "@portrevision ${revision}"
-    puts $fd "@archs [get_canonical_archs]"
-    array set ourvariations $PortInfo(active_variants)
-    set vlist [lsort -ascii [array names ourvariations]]
-    foreach v $vlist {
-        if {$ourvariations($v) == "+"} {
-            puts $fd "@portvariant +${v}"
-        }
-    }
-    fs-traverse -depth fullpath $destpath {
-        if {[file isdirectory $fullpath]} {
-            continue
-        }
-        set relpath [strsed $fullpath "s|^$destpath/||"]
-        if {![regexp {^[+]} $relpath]} {
-            puts $fd "$relpath"
-            if {[file isfile $fullpath]} {
-                ui_debug "checksum file: $fullpath"
-                set checksum [md5 file $fullpath]
-                puts $fd "@comment MD5:$checksum"
-            }
-        } else {
-            lappend control $relpath
-        }
-    }
-    foreach relpath $control {
-        puts $fd "@ignore"
-        puts $fd "$relpath"
-    }
-    close $fd
-
-    # the XML package metadata, for XAR package
-    # (doesn't contain any file list/checksums)
-    if {${archive.meta}} {
-        set archive.metaname "xpkg"
-        set archive.metapath [file join $workpath "${archive.metaname}.xml"]
-        set sd [open ${archive.metapath} w]
-        puts $sd "<xpkg version='0.2'>"
-        # TODO: split contents into <buildinfo> (new) and <package> (current)
-        #       see existing <portpkg> for the matching source package layout
-
-        putel $sd name ${name}
-        putel $sd epoch ${epoch}
-        putel $sd version ${version}
-        putel $sd revision ${revision}
-        putel $sd major 0
-        putel $sd minor 0
-
-        putel $sd platform ${os.platform}
-        if {[llength [get_canonical_archs]] > 1} {
-            putlist $sd archs arch [get_canonical_archs]
-        } else {
-            putel $sd arch [get_canonical_archs]
-        }
-        putlist $sd variants variant $vlist
-
-        if {[exists categories]} {
-            set primary [lindex [split [option categories] " "] 0]
-            putel $sd category $primary
-        }
-        if {[exists description]} {
-            putel $sd comment "[option description]"
-        }
-        if {[exists long_description]} {
-            putel $sd desc "[option long_description]"
-        }
-        if {[exists homepage]} {
-            putel $sd homepage "[option homepage]"
-        }
-
-            # Emit dependencies provided by this package
-            puts $sd "<provides>"
-                set name ${name}
-                puts $sd "<item>"
-                putel $sd name $name
-                putel $sd major 0
-                putel $sd minor 0
-                puts $sd "</item>"
-            puts $sd "</provides>"
-            
-    set res [mport_lookup $name]
-    if {[llength $res] < 2} {
-        ui_error "Dependency $name not found"
-    } else {
-    array set portinfo [lindex $res 1]
-
-            # Emit build, library, and runtime dependencies
-            puts $sd "<requires>"
-            foreach {key type} {
-                depends_fetch "fetch"
-                depends_extract "extract"
-                depends_build "build"
-                depends_lib "library"
-                depends_run "runtime"
-            } {
-                if {[info exists portinfo($key)]} {
-                    set name [lindex [split $portinfo($key) :] end]
-                    puts $sd "<item type=\"$type\">"
-                    putel $sd name $name
-                    putel $sd major 0
-                    putel $sd minor 0
-                    puts $sd "</item>"
-                }
-            }
-            puts $sd "</requires>"
-    }
-
-        puts $sd "</xpkg>"
-        close $sd
-    }
-
-    set archstring [join [get_canonical_archs] -]
-    # Now create the archive(s)
-    # Loop through archive types
-    foreach archive.type [option portarchivetype] {
-        if {[catch {archiveTypeIsSupported ${archive.type}} errmsg] == 0} {
-            # Define archive file/path
-            set archive.file "${name}-${version}_${revision}${portvariants}.${archstring}.${archive.type}"
-            set archive.path "[file join ${archive.fulldestpath} ${archive.file}]"
-
-            # Setup archive command
-            archive_command_setup
-
-            # Remove existing archive
-            if {[file exists ${archive.path}]} {
-                ui_info "$UI_PREFIX [format [msgcat::mc "Deleting previous %s"] ${archive.file}]"
-                file delete -force ${archive.path}
-            }
-
-            ui_info "$UI_PREFIX [format [msgcat::mc "Creating %s"] ${archive.file}]"
-            command_exec archive
-            ui_info "$UI_PREFIX [format [msgcat::mc "Archive %s packaged"] ${archive.file}]"
-        }
-    }
-
-    return 0
-}
-
-proc portarchive::archive_finish {args} {
-    global UI_PREFIX
-    global name version revision portvariants
-    global destpath
-
-    # Cleanup all control files when finished
-    set control_files [glob -nocomplain -types f [file join $destpath +*]]
-    foreach file $control_files {
-        ui_debug "removing file: $file"
-        file delete -force $file
-    }
-
-    if {[llength [option portarchivetype]] > 1} {
-        ui_info "$UI_PREFIX [format [msgcat::mc "Archives for %s %s_%s%s packaged"] $name $version $revision $portvariants]"
-    } else {
-        ui_info "$UI_PREFIX [format [msgcat::mc "Archive for %s %s_%s%s packaged"] $name $version $revision $portvariants]"
-    }
-    return 0
-}

Modified: branches/new-help-system/base/src/package1.0/portarchivefetch.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portarchivefetch.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/portarchivefetch.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
 # $Id$
 #
 # Copyright (c) 2002 - 2003 Apple Inc.
-# Copyright (c) 2004-2010 The MacPorts Project
+# Copyright (c) 2004 - 2011 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -59,59 +59,50 @@
 default archivefetch.ignore_sslcert no
 default archivefetch.pubkeys {$archivefetch_pubkeys}
 
-default archive_sites macports_archives
+default archive_sites {[portarchivefetch::filter_sites]}
 default archive_sites.listfile {"archive_sites.tcl"}
 default archive_sites.listpath {"port1.0/fetch"}
-default archive.subdir {[portarchivefetch::get_archive_subdir]}
+default archive.subdir {${subport}}
 
-set_ui_prefix
-
-proc portarchivefetch::get_archive_subdir {} {
-    set archs [get_canonical_archs]
-    if {[llength $archs] > 1} {
-        return [file join [option os.platform]_[option os.major] "universal" [option name]]
-    } else {
-        return [file join [option os.platform]_[option os.major] $archs [option name]]
+proc portarchivefetch::filter_sites {} {
+    global prefix porturl
+    set mirrorfile [get_full_archive_sites_path]
+    if {[file exists $mirrorfile]} {
+        source $mirrorfile
     }
+    set ret {}
+    foreach site [array names portfetch::mirror_sites::archive_prefix] {
+        if {$portfetch::mirror_sites::archive_prefix($site) == $prefix} {
+            lappend ret $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]]]
+        archive.subdir
+    }
+    return $ret
 }
 
+set_ui_prefix
+
 # Checks possible archive files to assemble url lists for later fetching
 proc portarchivefetch::checkarchivefiles {urls} {
-    global all_archive_files archivefetch.fulldestpath \
-           portarchivepath name version revision portvariants archive_sites
+    global all_archive_files archivefetch.fulldestpath portarchivetype \
+           version revision portvariants archive_sites
     upvar $urls fetch_urls
 
-    # Define archive directory, file, and path
-    set archivefetch.fulldestpath [file join ${portarchivepath} [option archive.subdir]]
+    # Define archive directory path
+    set archive.path [get_portimage_path]
+    set archivefetch.fulldestpath [file dirname ${archive.path}]
 
-    set unsupported 0
-    set found 0
-    foreach archive.type [option portarchivetype] {
-        if {[catch {archiveTypeIsSupported ${archive.type}} errmsg] == 0} {
-            set archstring [join [get_canonical_archs] -]
-            set archive.file "${name}-${version}_${revision}${portvariants}.${archstring}.${archive.type}"
-            set archive.path [file join ${archivefetch.fulldestpath} ${archive.file}]
-            if {[file exists ${archive.path}]} {
-                set found 1
-                break
-            } else {
-                lappend all_archive_files ${archive.file}
-                if {[info exists archive_sites]} {
-                    lappend fetch_urls archive_sites ${archive.file}
-                }
-            }
-        } else {
-            ui_debug "Skipping [string toupper ${archive.type}] archive: $errmsg"
-            incr unsupported
-        }
+    # 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}
     }
-    if {$found} {
-        ui_debug "Found [string toupper ${archive.type}] archive: ${archive.path}"
-        set all_archive_files {}
-        set fetch_urls {}
-    } elseif {[llength [option portarchivetype]] == $unsupported} {
-        return -code error "Unable to fetch archive ($name) since specified archive types not supported"
-    }
 }
 
 # returns full path to mirror list file
@@ -133,7 +124,7 @@
 # Perform a standard fetch, assembling fetch urls from
 # the listed url variable and associated archive file
 proc portarchivefetch::fetchfiles {args} {
-    global portarchivepath archivefetch.fulldestpath UI_PREFIX
+    global archivefetch.fulldestpath UI_PREFIX
     global archivefetch.user archivefetch.password archivefetch.use_epsv \
            archivefetch.ignore_sslcert
     global portverbose ports_binary_only
@@ -149,7 +140,7 @@
             }
         }
     }
-    set incoming_path [file join ${portarchivepath} incoming]
+    set incoming_path [file join [option portdbpath] incoming]
     if {![file isdirectory $incoming_path]} {
         if {[catch {file mkdir $incoming_path} result]} {
             elevateToRoot "archivefetch"
@@ -226,9 +217,9 @@
                     ui_debug "$::errorInfo"
                     return -code error "Failed to fetch signature for archive: $result"
                 }
+                set openssl [findBinary openssl $portutil::autoconf::openssl_path]
                 set verified 0
                 foreach pubkey [option archivefetch.pubkeys] {
-                    set openssl [findBinary openssl $portutil::autoconf::openssl_path]
                     if {![catch {exec $openssl dgst -ripemd160 -verify $pubkey -signature $signature "${incoming_path}/${archive}.TMP"} result]} {
                         set verified 1
                         break
@@ -245,14 +236,22 @@
                     return -code error "Failed to move downloaded archive into place: $result"
                 }
                 file delete -force $signature
-                return 0
+                set archive_exists 1
             }
         } else {
-            return 0
+            set archive_exists 1
         }
     }
+    if {[info exists archive_exists]} {
+        # modify state file to skip remaining phases up to destroot
+        global target_state_fd
+        foreach target {fetch checksum extract patch configure build destroot} {
+            write_statefile target "org.macports.${target}" $target_state_fd
+        }
+        return 0
+    }
     if {[info exists ports_binary_only] && $ports_binary_only == "yes"} {
-        return -code error "archivefetch failed for [option name] @[option version]_[option revision][option portvariants]"
+        return -code error "archivefetch failed for [option subport] @[option version]_[option revision][option portvariants]"
     } else {
         return 0
     }
@@ -260,19 +259,22 @@
 
 # Initialize archivefetch target and call checkfiles.
 proc portarchivefetch::archivefetch_init {args} {
-    if {[option portarchivemode] != "yes"} {
-        return -code error "Archive mode is not enabled!"
+    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_start {args} {
     variable archivefetch_urls
-    global UI_PREFIX name all_archive_files ports_source_only
+    global UI_PREFIX subport all_archive_files ports_source_only
     if {![tbool ports_source_only]} {
         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"] $name]"
+        ui_msg "$UI_PREFIX [format [msgcat::mc "Fetching archive for %s"] $subport]"
     }
 }
 
@@ -282,8 +284,7 @@
     global all_archive_files
     if {[info exists all_archive_files] && [llength $all_archive_files] > 0} {
         # Fetch the files
-        return [portarchivefetch::fetchfiles]
-    } else {
-        return 0
+        portarchivefetch::fetchfiles
     }
+    return 0
 }

Modified: branches/new-help-system/base/src/package1.0/portdmg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portdmg.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/portdmg.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portdmg.tcl
 # $Id$
 #
-# Copyright (c) 2003 Apple Computer, Inc.
+# Copyright (c) 2007, 2009-2011  The MacPorts Project
+# Copyright (c) 2003, 2005 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -44,11 +45,15 @@
 set_ui_prefix
 
 proc portdmg::dmg_main {args} {
-    global name version revision package.destpath UI_PREFIX
-    
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating disk image for %s-%s"] ${name} ${version}]"
-    
-    return [package_dmg $name $version $revision]
+    global subport version revision package.destpath UI_PREFIX
+
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating disk image for %s-%s"] ${subport} ${version}]"
+
+    if {[getuid] == 0 && [geteuid] != 0} {
+		setegid 0; seteuid 0
+	}
+
+    return [package_dmg $subport $version $revision]
 }
 
 proc portdmg::package_dmg {portname portversion portrevision} {

Modified: branches/new-help-system/base/src/package1.0/portdpkg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portdpkg.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/portdpkg.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,8 +2,9 @@
 # portdpkg.tcl
 # $Id$
 #
+# Copyright (c) 2005, 2007, 2009, 2011 The MacPorts Project
 # Copyright (c) 2004 Landon Fuller <landonf at macports.org>
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -37,29 +38,33 @@
 set org.macports.dpkg [target_new org.macports.dpkg portdpkg::main]
 target_runtype ${org.macports.dpkg} always
 target_provides ${org.macports.dpkg} dpkg
-target_requires ${org.macports.dpkg} destroot
+target_requires ${org.macports.dpkg} archivefetch unarchive destroot
 
 namespace eval portdpkg {
 }
 
 # Options
+options dpkg.asroot
 options package.destpath
 
+# Set up defaults
+default dpkg.asroot yes
+
 set_ui_prefix
 
 proc portdpkg::main {args} {
-	global UI_PREFIX destpath os.arch os.platform
+	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 name] [option version]]"
+	ui_msg "$UI_PREFIX [format [msgcat::mc "Creating dpkg for %s-%s"] [option subport] [option version]]"
 
 	# get deplist
-	set deps [make_dependency_list [option name]]
+	set deps [make_dependency_list [option subport]]
 	set deps [lsort -unique $deps]
 	foreach dep $deps {
 		set name [lindex [split $dep /] 0]
 		set vers [lindex [split $dep /] 1]
 		# don't re-package ourself
-		if {$name != [option name]} {
+		if {$name != [option subport]} {
 			lappend dependencies "${name} (>= ${vers})"
 		}
 	}
@@ -110,7 +115,7 @@
 	} elseif {[exists description]} {
 		set pkg_long_description " [option description]\n"
 	} else {
-		set pkg_long_description " [option name]\n"
+		set pkg_long_description " [option subport]\n"
 	}
 
 	if {[exists homepage]} {
@@ -126,8 +131,9 @@
 	# 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 ${os.arch} {
+	switch -regex ${configure.build_arch} {
 		i[3-9]86 { set pkg_arch "i386" }
+		x86_64 { set pkg_arch "x86_64" }
 		default { set pkg_arch ${os.arch} }
 	}
 
@@ -135,9 +141,16 @@
 	# the operating system name
 	if {${os.platform} != "linux"} {
 		set pkg_arch "${os.platform}-${pkg_arch}"
+	} elseif {${pkg_arch} == "x86_64"} {
+		set pkg_arch "amd64"
 	}
+	
+	# An architecture-independent package
+	if {$supported_archs == "noarch"} {
+		set pkg_arch "all"
+	}
 
-	puts $controlfd "Package: [option name]"
+	puts $controlfd "Package: [option subport]"
 	puts $controlfd "Architecture: ${pkg_arch}"
 	puts $controlfd "Version: ${pkg_version}"
 	puts $controlfd "Section: ${pkg_category}"

Modified: branches/new-help-system/base/src/package1.0/portmdmg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portmdmg.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/portmdmg.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portmdmg.tcl
 # $Id$
 #
-# Copyright (c) 2003 Apple Computer, Inc.
+# Copyright (c) 2005, 2007-2011 The MacPorts Project
+# Copyright (c) 2003-2004 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -44,11 +45,15 @@
 set_ui_prefix
 
 proc portmdmg::mdmg_main {args} {
-    global name version revision package.destpath UI_PREFIX
-    
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating disk image for %s-%s"] ${name} ${version}]"
-    
-    return [package_mdmg $name $version $revision]
+    global subport version revision package.destpath UI_PREFIX
+
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating disk image for %s-%s"] ${subport} ${version}]"
+
+    if {[getuid] == 0 && [geteuid] != 0} {
+		setegid 0; seteuid 0
+	}
+
+    return [package_mdmg $subport $version $revision]
 }
 
 proc portmdmg::package_mdmg {portname portversion portrevision} {

Modified: branches/new-help-system/base/src/package1.0/portmpkg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portmpkg.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/portmpkg.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portmpkg.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2005, 2007 - 2011 The MacPorts Project
+# Copyright (c) 2002 - 2004 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -47,67 +48,71 @@
 set_ui_prefix
 
 proc portmpkg::mpkg_main {args} {
-    global name version revision package.destpath package.flat UI_PREFIX
+    global subport version revision package.destpath package.flat UI_PREFIX
 
     # Make sure the destination path exists.
-    system "mkdir -p ${package.destpath}"
+    file mkdir ${package.destpath}
 
-    return [package_mpkg $name $version $revision]
+    return [package_mpkg $subport $version $revision]
 }
 
-proc portmpkg::make_dependency_list {portname} {
+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"
-		ui_error "port lookup failed: $error"
-		return 1
+		return -code error "port lookup failed: $error"
 	}
-	foreach {name array} $res {
-		array set portinfo $array
+	array set portinfo [lindex $res 1]
 
-		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)" }
+	if {[getuid] == 0 && [geteuid] != 0} {
+		setegid 0; seteuid 0
+		set deprivileged 1
+	}
 
-			foreach depspec $depends {
-				set dep [lindex [split $depspec :] end]
-	
-				# xxx: nasty hack
-				if {$dep != "XFree86"} {
-					eval "lappend result [make_dependency_list $dep]"
-				}
-			}
-		}
-		lappend result $portinfo(name)/$portinfo(version)
-		unset portinfo
+	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"]
 	}
+
+    unset portinfo
+    array set portinfo [mport_info $mport]
+
+    # get the union of depends_run and depends_lib
+    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 [_get_dep_port $depspec]
+        if {$dep != ""} {
+            eval "lappend result [make_dependency_list $dep $destination]"
+        }
+    }
+
+    lappend result [list $portinfo(name) $portinfo(version) $mport]
 	ui_debug "dependencies for ${portname}: $result"
 	return $result
 }
 
-proc portmpkg::make_one_package {portname portversion destination} {
-	global prefix package.destpath package.flat
-	if {[catch {set res [mport_lookup $portname]} result]} {
-		global errorInfo
-		ui_debug "$errorInfo"
-		ui_error "port lookup failed: $result"
-		return 1
+proc portmpkg::make_one_package {portname portversion mport} {
+	if {[getuid] == 0 && [geteuid] != 0} {
+		setegid 0; seteuid 0
+		set deprivileged 1
 	}
-	foreach {name array} $res {
-		array set portinfo $array
-		
-		if {[info exists portinfo(porturl)] && [info exists portinfo(version)] && $portinfo(version) == $portversion} {
-			# only the prefix gets passed to the worker.
-			ui_debug "building dependency package: $portname"
-			set worker [mport_open $portinfo(porturl) [list prefix $prefix package.destpath ${destination} package.flat ${package.flat}] {} yes]
-			mport_exec $worker pkg
-			mport_close $worker
-		}
-		unset portinfo
+
+    ui_debug "building dependency package: $portname"
+    mport_exec $mport pkg
+    mport_close $mport
+
+	if {[info exists deprivileged]} {
+	    global macportsuser
+		setegid [uname_to_gid "$macportsuser"]
+		seteuid [name_to_uid "$macportsuser"]
 	}
 }
 
@@ -121,18 +126,19 @@
 
 	set dependencies {}
 	# get deplist
-	set deps [make_dependency_list $portname]
+	set deps [make_dependency_list $portname ${mpkgpath}/Contents/Packages]
 	set deps [lsort -unique $deps]
 	foreach dep $deps {
-		set name [lindex [split $dep /] 0]
-		set vers [lindex [split $dep /] 1]
+		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 $mpkgpath/Contents/Packages
+			make_one_package $name $vers $mport
 			lappend dependencies ${name}-${vers}.pkg
 		}
 	}
-	
+
 	# copy our own pkg into the mpkg
 	system "cp -PR ${pkgpath} ${mpkgpath}/Contents/Packages/"
 	lappend dependencies ${portname}-${portversion}.pkg
@@ -142,11 +148,11 @@
     portpkg::write_description_plist ${mpkgpath}/Contents/Resources/Description.plist $portname $portversion $description
     # long_description, description, or homepage may not exist
     foreach variable {long_description description homepage} {
-	if {![info exists $variable]} {
-	    set pkg_$variable ""
-	} else {
-	    set pkg_$variable [set $variable]
-	}
+        if {![info exists $variable]} {
+            set pkg_$variable ""
+        } else {
+            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
@@ -186,7 +192,7 @@
 
 	set infofd [open ${infofile} w+]
 	puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!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>

Modified: branches/new-help-system/base/src/package1.0/portpkg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portpkg.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/portpkg.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portpkg.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2005, 2007 - 2011 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -36,11 +37,7 @@
 set org.macports.pkg [target_new org.macports.pkg portpkg::pkg_main]
 target_runtype ${org.macports.pkg} always
 target_provides ${org.macports.pkg} pkg
-if {[option portarchivemode] == "yes"} {
-    target_requires ${org.macports.pkg} archivefetch unarchive destroot
-} else {
-    target_requires ${org.macports.pkg} destroot
-}
+target_requires ${org.macports.pkg} archivefetch unarchive destroot
 
 namespace eval portpkg {
 }
@@ -55,16 +52,21 @@
 set_ui_prefix
 
 proc portpkg::pkg_main {args} {
-    global name version revision package.type package.destpath package.flat UI_PREFIX
+    global subport version revision package.type package.destpath package.flat UI_PREFIX
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating pkg for %s-%s"] ${name} ${version}]"
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating pkg for %s-%s"] ${subport} ${version}]"
 
-    return [package_pkg $name $version $revision]
+    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
-    global os.version os.major
+    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
 
@@ -73,7 +75,17 @@
         return 0
     }
 
-    set packagemaker "[option developer_dir]/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker"
+    if {![info exists packagemaker_path]} {
+        if {[vercmp $xcodeversion 4.3] >= 0} {
+            set packagemaker_path /Applications/PackageMaker.app
+            if {![file exists $packagemaker_path]} {
+                ui_warn "PackageMaker.app not found; you may need to install it or set packagemaker_path in macports.conf"
+            }
+        } else {
+            set packagemaker_path "[option developer_dir]/Applications/Utilities/PackageMaker.app"
+        }
+    }
+    set packagemaker "${packagemaker_path}/Contents/MacOS/PackageMaker"
     if ([file exists "$packagemaker"]) {
         set resourcepath ${workpath}/pkg_resources
     } else {
@@ -119,7 +131,12 @@
                 set infofile "${workpath}/Info.plist"
                 write_info_plist ${workpath}/Info.plist $portname $portversion $portrevision
             }
-            system "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 -AppleLanguages \"(${language})\" --root ${destpath} --out ${pkgpath} ${pkgresources} --info $infofile --target $pkgtarget --domain system --id org.macports.$portname"
+            if {${os.major} >= 10} {
+                append cmdline " --no-relocate"
+            }
+            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
@@ -175,7 +192,7 @@
 
     set infofd [open ${infofile} w+]
     puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!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>
@@ -223,7 +240,7 @@
 
     set infofd [open ${infofile} w+]
     puts $infofd {<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!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>

Modified: branches/new-help-system/base/src/package1.0/portportpkg.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portportpkg.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/portportpkg.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
 # portportpkg.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2004 Apple Computer, Inc.
+# Copyright (c) 2002 - 2004 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +13,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 

Modified: branches/new-help-system/base/src/package1.0/portrpm.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portrpm.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/portrpm.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portrpm.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2005 - 2007, 2009 - 2011 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -36,29 +37,35 @@
 set org.macports.rpm [target_new org.macports.rpm portrpm::rpm_main]
 target_runtype ${org.macports.rpm} always
 target_provides ${org.macports.rpm} rpm
-target_requires ${org.macports.rpm} destroot
+target_requires ${org.macports.rpm} archivefetch unarchive destroot
 
 namespace eval portrpm {
 }
 
+# Options
+options rpm.asroot
 options package.destpath
 
+# Set up defaults
+default rpm.asroot yes
+
 set_ui_prefix
 
 proc portrpm::rpm_main {args} {
-    global name version revision UI_PREFIX
+    global subport version revision UI_PREFIX
     
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating RPM package for %s-%s"] ${name} ${version}]"
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating RPM package for %s-%s"] ${subport} ${version}]"
     
-    return [rpm_pkg $name $version $revision]
+    return [rpm_pkg $subport $version $revision]
 }
 
 proc portrpm::rpm_pkg {portname portversion portrevision} {
-    global UI_PREFIX package.destpath portdbpath destpath workpath prefix categories maintainers description long_description homepage epoch portpath
+    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
         set pkgpath ${package.destpath}
         file mkdir ${pkgpath}/BUILD \
                    ${pkgpath}/RPMS \

Modified: branches/new-help-system/base/src/package1.0/portsrpm.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portsrpm.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/portsrpm.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portsrpm.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2007, 2009, 2011 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -47,11 +48,11 @@
 set_ui_prefix
 
 proc portsrpm::srpm_main {args} {
-    global name version revision UI_PREFIX
+    global subport version revision UI_PREFIX
     
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating SRPM package for %s-%s"] ${name} ${version}]"
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Creating SRPM package for %s-%s"] ${subport} ${version}]"
     
-    return [srpm_pkg $name $version $revision]
+    return [srpm_pkg $subport $version $revision]
 }
 
 proc portsrpm::srpm_pkg {portname portversion portrevision} {

Modified: branches/new-help-system/base/src/package1.0/portunarchive.tcl
===================================================================
--- branches/new-help-system/base/src/package1.0/portunarchive.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/package1.0/portunarchive.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,8 +2,9 @@
 # portunarchive.tcl
 # $Id$
 #
+# Copyright (c) 2005, 2007-2011 The MacPorts Project
 # Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -53,101 +54,88 @@
 default unarchive.args {}
 default unarchive.post_args {}
 
-default unarchive.srcpath {${portarchivepath}}
 default unarchive.type {}
 default unarchive.file {}
 default unarchive.path {}
+default unarchive.skip 0
 
 set_ui_prefix
 
 proc portunarchive::unarchive_init {args} {
-    global UI_PREFIX target_state_fd workpath
-    global ports_force ports_source_only ports_binary_only
-    global name version revision portvariants portpath
-    global unarchive.srcpath unarchive.type unarchive.file unarchive.path unarchive.fullsrcpath
+    global target_state_fd unarchive.skip destroot \
+           ports_force ports_source_only ports_binary_only \
+           subport version revision portvariants \
+           unarchive.type unarchive.file unarchive.path
 
-    # Check mode in case archive called directly by user
-    if {[option portarchivemode] != "yes"} {
-        return -code error "Archive mode is not enabled!"
-    }
-
-    # Define archive directory, file, and path
-    if {![string equal ${unarchive.srcpath} ${workpath}] && ![string equal ${unarchive.srcpath} ""]} {
-        set unarchive.fullsrcpath [file join ${unarchive.srcpath} [option archive.subdir]]
-    } else {
-        set unarchive.fullsrcpath ${unarchive.srcpath}
-    }
-
     # Determine if unarchive should be skipped
     set skipped 0
     if {[check_statefile target org.macports.unarchive $target_state_fd]} {
         return 0
     } elseif {[info exists ports_source_only] && $ports_source_only == "yes"} {
-        ui_debug "Skipping unarchive ($name) since source-only is set"
+        ui_debug "Skipping unarchive ($subport) since source-only is set"
         set skipped 1
-    } elseif {[check_statefile target org.macports.destroot $target_state_fd]} {
-        ui_debug "Skipping unarchive ($name) since destroot completed"
+    } elseif {[check_statefile target org.macports.destroot $target_state_fd]
+              && [file isdirectory $destroot]} {
+        ui_debug "Skipping unarchive ($subport) since destroot completed"
         set skipped 1
     } elseif {[info exists ports_force] && $ports_force == "yes"} {
-        ui_debug "Skipping unarchive ($name) since force is set"
+        ui_debug "Skipping unarchive ($subport) since force is set"
         set skipped 1
     } else {
         set found 0
-        set unsupported 0
-        foreach unarchive.type [option portarchivetype] {
-            if {[catch {archiveTypeIsSupported ${unarchive.type}} errmsg] == 0} {
-                set archstring [join [get_canonical_archs] -]
-                set unarchive.file "${name}-${version}_${revision}${portvariants}.${archstring}.${unarchive.type}"
-                set unarchive.path "[file join ${unarchive.fullsrcpath} ${unarchive.file}]"
-                if {[file isfile ${unarchive.path}]} {
-                    set found 1
-                    break
-                } else {
-                    ui_debug "No [string toupper ${unarchive.type}] archive: ${unarchive.path}"
-                }
+        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 "Skipping [string toupper ${unarchive.type}] archive: $errmsg"
-                incr unsupported
+                ui_debug "No [string toupper ${unarchive.type}] archive: ${unarchive.path}"
             }
         }
         if {$found == 1} {
             ui_debug "Found [string toupper ${unarchive.type}] archive: ${unarchive.path}"
         } else {
             if {[info exists ports_binary_only] && $ports_binary_only == "yes"} {
-                return -code error "Archive for ${name} ${version}_${revision}${portvariants} not found, required when binary-only is set!"
+                return -code error "Archive for ${subport} ${version}_${revision}${portvariants} not found, required when binary-only is set!"
             } else {
-                if {[llength [option portarchivetype]] == $unsupported} {
-                    ui_debug "Skipping unarchive ($name) since specified archive types not supported"
-                } else {
-                    ui_debug "Skipping unarchive ($name) since no archive found"
-                }
+                ui_debug "Skipping unarchive ($subport) since no suitable archive found"
                 set skipped 1
             }
         }
     }
-    # Skip unarchive target by setting state
-    if {$skipped == 1} {
-        write_statefile target "org.macports.unarchive" $target_state_fd
-    }
+    # Skip running the main body of this target
+    set unarchive.skip $skipped
 
     return 0
 }
 
 proc portunarchive::unarchive_start {args} {
-    global UI_PREFIX name version revision portvariants
-    global unarchive.type
+    global UI_PREFIX subport version revision portvariants \
+           unarchive.type unarchive.skip
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Unpacking ${unarchive.type} archive for %s %s_%s%s"] $name $version $revision $portvariants]"
+    if {${unarchive.skip}} {
+        return 0
+    }
 
+    if {[getuid] == 0 && [geteuid] != 0} {
+        # run as root if possible so file ownership can be preserved
+        elevateToRoot "unarchive"
+    }
+
+    # create any users and groups needed by the port
+    handle_add_users
+
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Unpacking ${unarchive.type} archive for %s %s_%s%s"] $subport $version $revision $portvariants]"
+
     return 0
 }
 
 proc portunarchive::unarchive_command_setup {args} {
-    global unarchive.env unarchive.cmd
-    global unarchive.pre_args unarchive.args unarchive.post_args
-    global unarchive.type unarchive.path
-    global unarchive.pipe_cmd
-    global os.platform os.version env
+    global unarchive.env unarchive.cmd unarchive.pre_args unarchive.args \
+           unarchive.post_args unarchive.type unarchive.path \
+           unarchive.pipe_cmd os.platform os.version env
 
     # Define appropriate unarchive command and options
     set unarchive.env {}
@@ -162,7 +150,7 @@
             if {[catch {set pax [findBinary $pax ${portutil::autoconf::pax_path}]} errmsg] == 0} {
                 ui_debug "Using $pax"
                 set unarchive.cmd "$pax"
-                if {[info exists env(USER)] && $env(USER) == "root"} {
+                if {[geteuid] == 0} {
                     set unarchive.pre_args {-r -v -p e}
                 } else {
                     set unarchive.pre_args {-r -v -p p}
@@ -222,7 +210,7 @@
                 return -code error "No '$tar' was found on this system!"
             }
         }
-        xar {
+        xar|xpkg {
             set xar "xar"
             if {[catch {set xar [findBinary $xar ${portutil::autoconf::xar_path}]} errmsg] == 0} {
                 ui_debug "Using $xar"
@@ -239,7 +227,7 @@
             if {[catch {set unzip [findBinary $unzip ${portutil::autoconf::unzip_path}]} errmsg] == 0} {
                 ui_debug "Using $unzip"
                 set unarchive.cmd "$unzip"
-                if {[info exists env(USER)] && $env(USER) == "root"} {
+                if {[geteuid] == 0} {
                     set unarchive.pre_args {-oX}
                 } else {
                     set unarchive.pre_args {-o}
@@ -259,9 +247,12 @@
 }
 
 proc portunarchive::unarchive_main {args} {
-    global UI_PREFIX
-    global unarchive.dir unarchive.file unarchive.pipe_cmd
+    global UI_PREFIX unarchive.dir unarchive.file unarchive.pipe_cmd unarchive.skip
 
+    if {${unarchive.skip}} {
+        return 0
+    }
+
     # Setup unarchive command
     unarchive_command_setup
 
@@ -282,17 +273,26 @@
 }
 
 proc portunarchive::unarchive_finish {args} {
-    global UI_PREFIX target_state_fd unarchive.file name workpath destpath
+    global UI_PREFIX target_state_fd unarchive.file subport workpath destpath unarchive.skip
 
+    if {${unarchive.skip}} {
+        return 0
+    }
+
     # Reset state file with archive version
-    close $target_state_fd
-    set statefile [file join $workpath .macports.${name}.state]
-    file copy -force [file join $destpath "+STATE"] $statefile
-    file mtime $statefile [clock seconds]
+    set statefile [file join $workpath .macports.${subport}.state]
+    set plus_state [file join $destpath "+STATE"]
+    if {[file isfile $plus_state]} {
+        close $target_state_fd
+        file copy -force $plus_state $statefile
+        file mtime $statefile [clock seconds]
+        chownAsRoot $statefile
+        set newstate 1
+    } else {
+        # fake it
+        write_statefile target org.macports.destroot $target_state_fd
+    }
 
-    # Update the state from unpacked archive version
-    set target_state_fd [open_statefile]
-
     # Cleanup all control files when finished
     set control_files [glob -nocomplain -types f [file join $destpath +*]]
     foreach file $control_files {
@@ -300,6 +300,11 @@
         file delete -force $file
     }
 
+    if {[info exists newstate]} {
+        # Update the state from unpacked archive version
+        set target_state_fd [open_statefile]
+    }
+
     ui_info "$UI_PREFIX [format [msgcat::mc "Archive %s unpacked"] ${unarchive.file}]"
     return 0
 }

Modified: branches/new-help-system/base/src/pextlib1.0/Makefile
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,6 +1,6 @@
 OBJS= \
 	Pextlib.o strsed.o fgetln.o md5cmd.o setmode.o xinstall.o \
-	fs-traverse.o strcasecmp.o vercomp.o filemap.o \
+	fs-traverse.o strcasecmp.o vercomp.o filemap.o base32cmd.o \
 	sha1cmd.o curl.o rmd160cmd.o sha256cmd.o readline.o uid.o \
 	tracelib.o tty.o readdir.o pipe.o flock.o \
 	system.o mktemp.o realpath.o
@@ -16,9 +16,10 @@
 .PHONY: test
 
 test:: ${SHLIB_NAME}
-	${TCLSH} tests/checksums.tcl ${SHLIB_NAME}
-	${TCLSH} tests/curl.tcl ${SHLIB_NAME}
-	${TCLSH} tests/filemap.tcl ${SHLIB_NAME}
-	${TCLSH} tests/fs-traverse.tcl ${SHLIB_NAME}
-	${TCLSH} tests/symlink.tcl ${SHLIB_NAME}
-	${TCLSH} tests/unsetenv.tcl ${SHLIB_NAME}
+	${TCLSH} tests/checksums.tcl ./${SHLIB_NAME}
+	${TCLSH} tests/curl.tcl ./${SHLIB_NAME}
+	${TCLSH} tests/filemap.tcl ./${SHLIB_NAME}
+	${TCLSH} tests/fs-traverse.tcl ./${SHLIB_NAME}
+	${TCLSH} tests/symlink.tcl ./${SHLIB_NAME}
+	${TCLSH} tests/unsetenv.tcl ./${SHLIB_NAME}
+	${TCLSH} tests/vercomp.tcl ./${SHLIB_NAME}

Modified: branches/new-help-system/base/src/pextlib1.0/Pextlib.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/Pextlib.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/Pextlib.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,9 +2,10 @@
  * Pextlib.c
  * $Id$
  *
- * Copyright (c) 2002 - 2003 Apple Computer, Inc.
+ * Copyright (c) 2002 - 2003 Apple Inc.
  * Copyright (c) 2004 - 2005 Paul Guyot <pguyot at kallisys.net>
  * Copyright (c) 2004 Landon Fuller <landonf at macports.org>
+ * Copyright (c) 2012 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 
@@ -46,6 +47,7 @@
 #include <grp.h>
 #include <limits.h>
 #include <pwd.h>
+#include <stdbool.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -53,6 +55,11 @@
 #include <strings.h>
 #include <unistd.h>
 
+#ifdef __MACH__
+#include <mach-o/loader.h>
+#include <mach-o/fat.h>
+#endif
+
 #include <tcl.h>
 
 #include "Pextlib.h"
@@ -61,6 +68,7 @@
 #include "sha1cmd.h"
 #include "rmd160cmd.h"
 #include "sha256cmd.h"
+#include "base32cmd.h"
 #include "fs-traverse.h"
 #include "filemap.h"
 #include "curl.h"
@@ -85,154 +93,154 @@
 extern char **environ;
 #endif
 
-#if !HAVE_FGETLN
-char *fgetln(FILE *stream, size_t *len);
+#if !HAVE_SETMODE
+#include "setmode.h"
 #endif
 
 static char *
 ui_escape(const char *source)
 {
-	char *d, *dest;
-	const char *s;
-	size_t dlen;
+    char *d, *dest;
+    const char *s;
+    size_t dlen;
 
-	s = source;
-	dlen = strlen(source) * 2 + 1;
-	d = dest = malloc(dlen);
-	if (dest == NULL) {
-		return NULL;
-	}
-	while(*s != '\0') {
-		switch(*s) {
-			case '\\':
-			case '}':
-			case '{':
-				*d = '\\';
-				d++;
-				*d = *s;
-				d++;
-				s++;
-				break;
-			case '\n':
-				s++;
-				break;
-			default:
-				*d = *s;
-				d++;
-				s++;
-				break;
-		}
-	}
-	*d = '\0';
-	return dest;
+    s = source;
+    dlen = strlen(source) * 2 + 1;
+    d = dest = malloc(dlen);
+    if (dest == NULL) {
+        return NULL;
+    }
+    while(*s != '\0') {
+        switch(*s) {
+            case '\\':
+            case '}':
+            case '{':
+                *d = '\\';
+                d++;
+                *d = *s;
+                d++;
+                s++;
+                break;
+            case '\n':
+                s++;
+                break;
+            default:
+                *d = *s;
+                d++;
+                s++;
+                break;
+        }
+    }
+    *d = '\0';
+    return dest;
 }
 
 int
 ui_info(Tcl_Interp *interp, char *mesg)
 {
-	const char ui_proc_start[] = "ui_info [subst -nocommands -novariables {";
-	const char ui_proc_end[] = "}]";
-	char *script, *string;
-	size_t scriptlen, len, remaining;
-	int rval;
+    const char ui_proc_start[] = "ui_info [subst -nocommands -novariables {";
+    const char ui_proc_end[] = "}]";
+    char *script, *string;
+    size_t scriptlen, len, remaining;
+    int rval;
 
-	string = ui_escape(mesg);
-	if (string == NULL)
-		return TCL_ERROR;
+    string = ui_escape(mesg);
+    if (string == NULL)
+        return TCL_ERROR;
 
-	len = strlen(string);
-	scriptlen = sizeof(ui_proc_start) + len + sizeof(ui_proc_end) - 1;
-	script = malloc(scriptlen);
-	if (script == NULL)
-		return TCL_ERROR;
+    len = strlen(string);
+    scriptlen = sizeof(ui_proc_start) + len + sizeof(ui_proc_end) - 1;
+    script = malloc(scriptlen);
+    if (script == NULL)
+        return TCL_ERROR;
 
-	memcpy(script, ui_proc_start, sizeof(ui_proc_start));
-	remaining = scriptlen - sizeof(ui_proc_start);
-	strncat(script, string, remaining);
-	remaining -= len;
-	strncat(script, ui_proc_end, remaining);
-	free(string);
-	rval = Tcl_EvalEx(interp, script, -1, 0);
-	free(script);
-	return rval;
+    memcpy(script, ui_proc_start, sizeof(ui_proc_start));
+    remaining = scriptlen - sizeof(ui_proc_start);
+    strncat(script, string, remaining);
+    remaining -= len;
+    strncat(script, ui_proc_end, remaining);
+    free(string);
+    rval = Tcl_EvalEx(interp, script, -1, 0);
+    free(script);
+    return rval;
 }
 
 int StrsedCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
-	char *pattern, *string, *res;
-	int range[2];
-	Tcl_Obj *tcl_result;
+    char *pattern, *string, *res;
+    int range[2];
+    Tcl_Obj *tcl_result;
 
-	if (objc != 3) {
-		Tcl_WrongNumArgs(interp, 1, objv, "string pattern");
-		return TCL_ERROR;
-	}
+    if (objc != 3) {
+        Tcl_WrongNumArgs(interp, 1, objv, "string pattern");
+        return TCL_ERROR;
+    }
 
-	string = Tcl_GetString(objv[1]);
-	pattern = Tcl_GetString(objv[2]);
-	res = strsed(string, pattern, range);
-	if (!res) {
-		Tcl_SetResult(interp, "strsed failed", TCL_STATIC);
-		return TCL_ERROR;
-	}
-	tcl_result = Tcl_NewStringObj(res, -1);
-	Tcl_SetObjResult(interp, tcl_result);
-	free(res);
-	return TCL_OK;
+    string = Tcl_GetString(objv[1]);
+    pattern = Tcl_GetString(objv[2]);
+    res = strsed(string, pattern, range);
+    if (!res) {
+        Tcl_SetResult(interp, "strsed failed", TCL_STATIC);
+        return TCL_ERROR;
+    }
+    tcl_result = Tcl_NewStringObj(res, -1);
+    Tcl_SetObjResult(interp, tcl_result);
+    free(res);
+    return TCL_OK;
 }
 
 int ExistsuserCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
-	Tcl_Obj *tcl_result;
-	struct passwd *pwent;
-	char *user;
+    Tcl_Obj *tcl_result;
+    struct passwd *pwent;
+    char *user;
 
-	if (objc != 2) {
-		Tcl_WrongNumArgs(interp, 1, objv, "user");
-		return TCL_ERROR;
-	}
+    if (objc != 2) {
+        Tcl_WrongNumArgs(interp, 1, objv, "user");
+        return TCL_ERROR;
+    }
 
-	user = strdup(Tcl_GetString(objv[1]));
-	if (isdigit(*(user)))
-		pwent = getpwuid(strtol(user, 0, 0));
-	else
-		pwent = getpwnam(user);
-	free(user);
+    user = strdup(Tcl_GetString(objv[1]));
+    if (isdigit(*(user)))
+        pwent = getpwuid(strtol(user, 0, 0));
+    else
+        pwent = getpwnam(user);
+    free(user);
 
-	if (pwent == NULL)
-		tcl_result = Tcl_NewIntObj(0);
-	else
-		tcl_result = Tcl_NewIntObj(pwent->pw_uid);
+    if (pwent == NULL)
+        tcl_result = Tcl_NewIntObj(0);
+    else
+        tcl_result = Tcl_NewIntObj(pwent->pw_uid);
 
-	Tcl_SetObjResult(interp, tcl_result);
-	return TCL_OK;
+    Tcl_SetObjResult(interp, tcl_result);
+    return TCL_OK;
 }
 
 int ExistsgroupCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
-	Tcl_Obj *tcl_result;
-	struct group *grent;
-	char *group;
+    Tcl_Obj *tcl_result;
+    struct group *grent;
+    char *group;
 
-	if (objc != 2) {
-		Tcl_WrongNumArgs(interp, 1, objv, "groupname");
-		return TCL_ERROR;
-	}
+    if (objc != 2) {
+        Tcl_WrongNumArgs(interp, 1, objv, "groupname");
+        return TCL_ERROR;
+    }
 
-	group = strdup(Tcl_GetString(objv[1]));
-	if (isdigit(*(group)))
-		grent = getgrgid(strtol(group, 0, 0));
-	else
-		grent = getgrnam(group);
-	free(group);
+    group = strdup(Tcl_GetString(objv[1]));
+    if (isdigit(*(group)))
+        grent = getgrgid(strtol(group, 0, 0));
+    else
+        grent = getgrnam(group);
+    free(group);
 
-	if (grent == NULL)
-		tcl_result = Tcl_NewIntObj(0);
-	else
-		tcl_result = Tcl_NewIntObj(grent->gr_gid);
+    if (grent == NULL)
+        tcl_result = Tcl_NewIntObj(0);
+    else
+        tcl_result = Tcl_NewIntObj(grent->gr_gid);
 
-	Tcl_SetObjResult(interp, tcl_result);
-	return TCL_OK;
+    Tcl_SetObjResult(interp, tcl_result);
+    return TCL_OK;
 }
 
 /* Find the first unused UID > 500
@@ -240,81 +248,81 @@
    but UIDs < 500 are reserved by Apple */
 int NextuidCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc UNUSED, Tcl_Obj *CONST objv[] UNUSED)
 {
-	Tcl_Obj *tcl_result;
-	int cur;
+    Tcl_Obj *tcl_result;
+    int cur;
 
-	cur = MIN_USABLE_UID;
+    cur = MIN_USABLE_UID;
 
-	while (getpwuid(cur) != NULL) {
-		cur++;
-	}
+    while (getpwuid(cur) != NULL) {
+        cur++;
+    }
 
-	tcl_result = Tcl_NewIntObj(cur);
-	Tcl_SetObjResult(interp, tcl_result);
-	return TCL_OK;
+    tcl_result = Tcl_NewIntObj(cur);
+    Tcl_SetObjResult(interp, tcl_result);
+    return TCL_OK;
 }
 
 /* Just as with NextuidCmd, return the first unused gid > 500 */
 int NextgidCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc UNUSED, Tcl_Obj *CONST objv[] UNUSED)
 {
-	Tcl_Obj *tcl_result;
-	int cur;
+    Tcl_Obj *tcl_result;
+    int cur;
 
-	cur = MIN_USABLE_GID;
+    cur = MIN_USABLE_GID;
 
-	while (getgrgid(cur) != NULL) {
-		cur++;
-	}
+    while (getgrgid(cur) != NULL) {
+        cur++;
+    }
 
-	tcl_result = Tcl_NewIntObj(cur);
-	Tcl_SetObjResult(interp, tcl_result);
-	return TCL_OK;
+    tcl_result = Tcl_NewIntObj(cur);
+    Tcl_SetObjResult(interp, tcl_result);
+    return TCL_OK;
 }
 
 int UmaskCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc UNUSED, Tcl_Obj *CONST objv[] UNUSED)
 {
-	Tcl_Obj *tcl_result;
-	char *tcl_mask, *p;
-	const size_t stringlen = 5; /* 4 digits & \0 */
-	int i;
-	mode_t *set;
-	mode_t newmode;
-	mode_t oldmode;
+    Tcl_Obj *tcl_result;
+    char *tcl_mask, *p;
+    const size_t stringlen = 5; /* 4 digits & \0 */
+    int i;
+    mode_t *set;
+    mode_t newmode;
+    mode_t oldmode;
 
-	if (objc != 2) {
-		Tcl_WrongNumArgs(interp, 1, objv, "mode");
-		return TCL_ERROR;
-	}
+    if (objc != 2) {
+        Tcl_WrongNumArgs(interp, 1, objv, "mode");
+        return TCL_ERROR;
+    }
 
-	tcl_mask = Tcl_GetString(objv[1]);
-	if ((set = setmode(tcl_mask)) == NULL) {
-		Tcl_SetResult(interp, "Invalid umask mode", TCL_STATIC);
-		return TCL_ERROR;
-	}
+    tcl_mask = Tcl_GetString(objv[1]);
+    if ((set = setmode(tcl_mask)) == NULL) {
+        Tcl_SetResult(interp, "Invalid umask mode", TCL_STATIC);
+        return TCL_ERROR;
+    }
 
-	newmode = getmode(set, 0);
-	free(set);
+    newmode = getmode(set, 0);
+    free(set);
 
-	oldmode = umask(newmode);
+    oldmode = umask(newmode);
 
-	tcl_mask = calloc(1, stringlen); /* 4 digits & \0 */
-	if (!tcl_mask) {
-		return TCL_ERROR;
-	}
+    tcl_mask = calloc(1, stringlen); /* 4 digits & \0 */
+    if (!tcl_mask) {
+        return TCL_ERROR;
+    }
 
-	/* Totally gross and cool */
-	p = tcl_mask + stringlen - 1;
-	for (i = stringlen - 1; i > 0; i--) {
-		p--;
-		*p = (oldmode & 7) + '0';
-		oldmode >>= 3;
-	}
+    /* Totally gross and cool */
+    p = tcl_mask + stringlen - 1;
+    for (i = stringlen - 1; i > 0; i--) {
+        p--;
+        *p = (oldmode & 7) + '0';
+        oldmode >>= 3;
+    }
 
-	tcl_result = Tcl_NewStringObj(p, -1);
-	free(tcl_mask);
+    tcl_result = Tcl_NewStringObj(p, -1);
+    free(tcl_mask);
 
-	Tcl_SetObjResult(interp, tcl_result);
-	return TCL_OK;
+    Tcl_SetObjResult(interp, tcl_result);
+    return TCL_OK;
 }
 
 /**
@@ -398,6 +406,7 @@
 #ifndef __APPLE__
         /* Crashes on Linux without this. */
         setenv("MACPORTS_DUMMY", "", 0);
+        unsetenv("MACPORTS_DUMMY");
 #endif
     } else {
         (void) unsetenv(name);
@@ -462,10 +471,107 @@
     return TCL_OK;
 }
 
+#ifdef __MACH__
+/**
+ * Tcl function to determine whether a file given by path is binary (in terms of being Mach-O)
+ * Defined on Mac-Systems only, because the necessary headers are only available there.
+ *
+ * Synopsis: fileIsBinary filename
+ */
+static int fileIsBinaryCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
+    const char *path;
+    FILE *file;
+    uint32_t magic;
+    struct stat st;
+
+    if (objc != 2) {
+        Tcl_WrongNumArgs(interp, 1, objv, "filename");
+        return TCL_ERROR;
+    }
+
+    path = Tcl_GetString(objv[1]);
+    if (-1 == lstat(path, &st)) {
+        /* an error occured */
+        Tcl_SetErrno(errno);
+        Tcl_ResetResult(interp);
+        Tcl_AppendResult(interp, "lstat(", path, "):", (char *)Tcl_PosixError(interp), NULL);
+        return TCL_ERROR;
+    }
+    if (!S_ISREG(st.st_mode)) {
+        /* not a regular file, haven't seen directories which are binaries yet */
+        Tcl_SetObjResult(interp, Tcl_NewBooleanObj(false));
+        return TCL_OK;
+    }
+    if (NULL == (file = fopen(path, "r"))) {
+        Tcl_SetErrno(errno);
+        Tcl_ResetResult(interp);
+        Tcl_AppendResult(interp, "fopen(", path, "): ", (char *)Tcl_PosixError(interp), NULL);
+        return TCL_ERROR;
+    }
+    if (1 != fread(&magic, sizeof(uint32_t), 1, file)) {
+        if (feof(file)) {
+            fclose(file);
+            /* file is shorter than 4 byte, probably not a binary */
+            Tcl_SetObjResult(interp, Tcl_NewBooleanObj(false));
+            return TCL_OK;
+        }
+        /* error while reading */
+        Tcl_SetErrno(errno);
+        Tcl_ResetResult(interp);
+        Tcl_AppendResult(interp, "fread(&magic, 4, 1, ", path, "): ", (char *)Tcl_PosixError(interp), NULL);
+        fclose(file);
+        return TCL_ERROR;
+    }
+    if (magic == MH_MAGIC || magic == MH_MAGIC_64) {
+        fclose(file);
+        /* this is a mach-o file */
+        Tcl_SetObjResult(interp, Tcl_NewBooleanObj(true));
+        return TCL_OK;
+    }
+    if (magic == htonl(FAT_MAGIC)) {
+        uint32_t archcount;
+        /* either universal binary or java class (FAT_MAGIC == 0xcafebabe)
+           see /use/share/file/magic/cafebabe for an explanation of what I'm doing here */
+        if (1 != fread(&archcount, sizeof(uint32_t), 1, file)) {
+            if (feof(file)) {
+                fclose(file);
+                /* file shorter than 8 byte, probably not a binary either */
+                Tcl_SetObjResult(interp, Tcl_NewBooleanObj(false));
+                return TCL_OK;
+            }
+            /* error while reading */
+            Tcl_SetErrno(errno);
+            Tcl_ResetResult(interp);
+            Tcl_AppendResult(interp, "fread(&archcount, 4, 1, ", path, "): ", (char *)Tcl_PosixError(interp), NULL);
+            fclose(file);
+            return TCL_ERROR;
+        }
+
+        /* universal binary header is always big endian */
+        archcount = ntohl(archcount);
+        if (archcount > 0 && archcount < 20) {
+            fclose(file);
+            /* universal binary */
+            Tcl_SetObjResult(interp, Tcl_NewBooleanObj(true));
+            return TCL_OK;
+        }
+
+        fclose(file);
+        /* probably java class */
+        Tcl_SetObjResult(interp, Tcl_NewBooleanObj(false));
+        return TCL_OK;
+    }
+    fclose(file);
+
+    Tcl_SetObjResult(interp, Tcl_NewBooleanObj(false));
+    return TCL_OK;
+}
+#endif
+
 int Pextlib_Init(Tcl_Interp *interp)
 {
-	if (Tcl_InitStubs(interp, "8.4", 0) == NULL)
-		return TCL_ERROR;
+    if (Tcl_InitStubs(interp, "8.4", 0) == NULL)
+        return TCL_ERROR;
 
 	Tcl_CreateObjCommand(interp, "system", SystemCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "flock", FlockCmd, NULL, NULL);
@@ -482,9 +588,15 @@
 	Tcl_CreateObjCommand(interp, "xinstall", InstallCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "fs-traverse", FsTraverseCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "filemap", FilemapCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "rpm-vercomp", RPMVercompCmd, NULL, NULL);
+#if 1
+	/* the name "rpm-vercomp" is deprecated, use "vercmp" instead */
+	Tcl_CreateObjCommand(interp, "rpm-vercomp", VercompCmd, NULL, NULL);
+#endif
+	Tcl_CreateObjCommand(interp, "vercmp", VercompCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "rmd160", RMD160Cmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "sha256", SHA256Cmd, NULL, NULL);
+	Tcl_CreateObjCommand(interp, "base32encode", Base32EncodeCmd, NULL, NULL);
+	Tcl_CreateObjCommand(interp, "base32decode", Base32DecodeCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "sha1", SHA1Cmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "umask", UmaskCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "pipe", PipeCmd, NULL, NULL);
@@ -493,30 +605,33 @@
 	Tcl_CreateObjCommand(interp, "unsetenv", UnsetEnvCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "lchown", lchownCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "realpath", RealpathCmd, NULL, NULL);
+#ifdef __MACH__
+    Tcl_CreateObjCommand(interp, "fileIsBinary", fileIsBinaryCmd, NULL, NULL);
+#endif
 
-	Tcl_CreateObjCommand(interp, "readline", ReadlineCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "rl_history", RLHistoryCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "readline", ReadlineCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "rl_history", RLHistoryCmd, NULL, NULL);
 
-	Tcl_CreateObjCommand(interp, "getuid", getuidCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "geteuid", geteuidCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "getgid", getgidCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "getegid", getegidCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "setuid", setuidCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "seteuid", seteuidCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "setgid", setgidCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "setegid", setegidCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "name_to_uid", name_to_uidCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "uid_to_name", uid_to_nameCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "uname_to_gid", uname_to_gidCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "name_to_gid", name_to_gidCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "gid_to_name", gid_to_nameCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "getuid", getuidCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "geteuid", geteuidCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "getgid", getgidCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "getegid", getegidCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "setuid", setuidCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "seteuid", seteuidCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "setgid", setgidCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "setegid", setegidCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "name_to_uid", name_to_uidCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "uid_to_name", uid_to_nameCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "uname_to_gid", uname_to_gidCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "name_to_gid", name_to_gidCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "gid_to_name", gid_to_nameCmd, NULL, NULL);
 
-	Tcl_CreateObjCommand(interp, "tracelib", TracelibCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "isatty", IsattyCmd, NULL, NULL);
-	Tcl_CreateObjCommand(interp, "term_get_size", TermGetSizeCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "tracelib", TracelibCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "isatty", IsattyCmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "term_get_size", TermGetSizeCmd, NULL, NULL);
 
-	if (Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK)
-		return TCL_ERROR;
+    if (Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK)
+        return TCL_ERROR;
 
-	return TCL_OK;
+    return TCL_OK;
 }

Copied: branches/new-help-system/base/src/pextlib1.0/base32cmd.c (from rev 90355, trunk/base/src/pextlib1.0/base32cmd.c)
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/base32cmd.c	                        (rev 0)
+++ branches/new-help-system/base/src/pextlib1.0/base32cmd.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,347 @@
+/*
+ * base32cmd.c
+ * $Id$
+ *
+ * Copyright (c) 2010 The MacPorts Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of 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.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <ctype.h>
+#include <string.h>
+
+#include <tcl.h>
+
+#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.
+
+   Based on public domain base32 code from tcllib, by Andreas Kupries */
+
+#define BASE32HEX 1
+
+static __inline__ int hex2dec(int data)
+{
+  if (data >= '0' && data <= '9')
+    return (data - '0');
+  else if (data >= 'a' && data <= 'f')
+    return (data - 'a' + 10);
+  else if (data >= 'A' && data <= 'F')
+    return (data - 'A' + 10);
+  else
+    return 0;
+}
+
+int Base32EncodeCmd(ClientData dummy UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+      unsigned char* digest;
+      int           ndigest;
+      unsigned char* buf;
+      int           nbuf;
+
+      unsigned char* start;
+      unsigned char* out;
+      unsigned char* at;
+      int           nout;
+
+	  Tcl_Obj *tcl_result;
+      int i;
+
+      /*
+       * The array used for encoding
+       */                     /* 123456789 123456789 123456789 12 */
+#ifdef BASE32HEX
+      static const char map[] = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
+#else
+      static const char map[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
+#endif
+
+      static const char odd_message[] = "string has odd number of chars";
+      static const char hex_message[] = "invalid hexadecimal character";
+
+#define USAGEE "hexstring"
+
+      if (objc != 2) {
+        Tcl_WrongNumArgs (interp, 1, objv, USAGEE);
+        return TCL_ERROR;
+      }
+
+      digest = Tcl_GetByteArrayFromObj (objv[1], &ndigest);
+      if (ndigest & 1) {
+		tcl_result = Tcl_NewStringObj(odd_message, sizeof(odd_message) - 1);
+		Tcl_SetObjResult(interp, tcl_result);
+      	return TCL_ERROR;
+      }
+      for (i = 0; i < ndigest; i++) {
+      	if (!isxdigit(digest[i])) {
+		    tcl_result = Tcl_NewStringObj(hex_message, sizeof(hex_message) - 1);
+		    Tcl_SetObjResult(interp, tcl_result);
+      	    return TCL_ERROR;
+      	}
+      }
+      nbuf = ndigest / 2;
+      buf = (unsigned char*) Tcl_Alloc (nbuf*sizeof(char));
+
+      for (i = 0; i < nbuf; i++) {
+        buf[i] = (hex2dec(digest[i+i]) << 4) | (hex2dec(digest[i+i+1]));
+      }
+
+      start = buf;
+
+      nout = ((nbuf+4)/5)*8;
+      out  = (unsigned char*) Tcl_Alloc (nout*sizeof(char));
+
+      for (at = out; nbuf >= 5; nbuf -= 5, buf += 5) {
+	*(at++) = map [         (buf[0]>>3)                ];
+	*(at++) = map [ 0x1f & ((buf[0]<<2) | (buf[1]>>6)) ];
+	*(at++) = map [ 0x1f &  (buf[1]>>1)                ];
+	*(at++) = map [ 0x1f & ((buf[1]<<4) | (buf[2]>>4)) ];
+	*(at++) = map [ 0x1f & ((buf[2]<<1) | (buf[3]>>7)) ];
+	*(at++) = map [ 0x1f &  (buf[3]>>2)                ];
+	*(at++) = map [ 0x1f & ((buf[3]<<3) | (buf[4]>>5)) ];
+	*(at++) = map [ 0x1f &  (buf[4])                   ];
+      }
+      if (nbuf > 0) {
+	/* Process partials at end. */
+	switch (nbuf) {
+	case 1:
+	  /* |01234567|		 2, padding 6
+	   *  xxxxx
+	   *       xxx 00
+	   */
+
+	  *(at++) = map [        (buf[0]>>3) ];
+	  *(at++) = map [ 0x1f & (buf[0]<<2) ];
+	  *(at++) = '=';
+	  *(at++) = '=';
+	  *(at++) = '=';
+	  *(at++) = '=';
+	  *(at++) = '=';
+	  *(at++) = '=';
+	  break;
+	case 2: /* x3/=4 */
+	  /* |01234567|01234567|	 4, padding 4
+	   *  xxxxx
+	   *       xxx xx
+	   *             xxxxx
+	   *                  x 0000
+	   */
+
+	  *(at++) = map [         (buf[0]>>3)                ];
+	  *(at++) = map [ 0x1f & ((buf[0]<<2) | (buf[1]>>6)) ];
+	  *(at++) = map [ 0x1f &  (buf[1]>>1)                ];
+	  *(at++) = map [ 0x1f &  (buf[1]<<4)                ];
+	  *(at++) = '=';
+	  *(at++) = '=';
+	  *(at++) = '=';
+	  *(at++) = '=';
+	  break;
+	case 3:
+	  /* |01234567|01234567|01234567|	 5, padding 3
+	   *  xxxxx
+	   *       xxx xx
+	   *             xxxxx
+	   *                  x xxxx
+	   *                        xxxx 0
+	   */
+
+	  *(at++) = map [         (buf[0]>>3)                ];
+	  *(at++) = map [ 0x1f & ((buf[0]<<2) | (buf[1]>>6)) ];
+	  *(at++) = map [ 0x1f &  (buf[1]>>1)                ];
+	  *(at++) = map [ 0x1f & ((buf[1]<<4) | (buf[2]>>4)) ];
+	  *(at++) = map [ 0x1f &  (buf[2]<<1)                ];
+	  *(at++) = '=';
+	  *(at++) = '=';
+	  *(at++) = '=';
+	  break;
+	case 4:
+	  /* |01234567|01234567|01234567|012334567|	 7, padding 1
+	   *  xxxxx
+	   *       xxx xx
+	   *             xxxxx
+	   *                  x xxxx
+	   *                        xxxx
+	   *                             xxxxx
+	   *                                  xxxx 0
+	   */
+
+	  *(at++) = map [         (buf[0]>>3)                ];
+	  *(at++) = map [ 0x1f & ((buf[0]<<2) | (buf[1]>>6)) ];
+	  *(at++) = map [ 0x1f &  (buf[1]>>1)                ];
+	  *(at++) = map [ 0x1f & ((buf[1]<<4) | (buf[2]>>4)) ];
+	  *(at++) = map [ 0x1f & ((buf[2]<<1) | (buf[3]>>7)) ];
+	  *(at++) = map [ 0x1f &  (buf[3]>>2)                ];
+	  *(at++) = map [ 0x1f &  (buf[3]<<3)                ];
+	  *(at++) = '=';
+	  break;
+	}
+      }
+
+      Tcl_SetObjResult (interp, Tcl_NewStringObj ((char *) out, nout));
+      Tcl_Free ((char*) out);
+      Tcl_Free ((char*) start);
+      return TCL_OK;
+    }
+
+
+int Base32DecodeCmd(ClientData dummy UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+{
+      unsigned char* buf;
+      int           nbuf;
+      unsigned char* digest;
+      int           ndigest;
+
+      unsigned char* out;
+      unsigned char* at;
+      unsigned char  x [8];
+      int           nout;
+
+      int i, j, a, pad;
+
+      /*
+       * An array for translating single base-32 characters into a value.
+       * Disallowed input characters have a value of 64.  Upper and lower
+       * case is the same. Only 128 chars, as everything above char(127)
+       * is 64.
+       */
+      static const char map [] = {
+#ifdef BASE32HEX
+	/* \00 */ 64, 64, 64, 64, 64, 64, 64, 64,  64, 64, 64, 64, 64, 64, 64, 64, 
+	/* DLE */ 64, 64, 64, 64, 64, 64, 64, 64,  64, 64, 64, 64, 64, 64, 64, 64, 
+	/* SPC */ 64, 64, 64, 64, 64, 64, 64, 64,  64, 64, 64, 64, 64, 64, 64, 64, 
+	/* '0' */  0,  1,  2,  3,  4,  5,  6,  7,   8,  9, 64, 64, 64, 64, 64, 64, 
+	/* '@' */ 64, 10, 11, 12, 13, 14, 15, 16,  17, 18, 19, 20, 21, 22, 23, 24,
+	/* 'P' */ 25, 26, 27, 28, 29, 30, 31, 64,  64, 64, 64, 64, 64, 64, 64, 64,
+	/* '`' */ 64, 10, 11, 12, 13, 14, 15, 16,  17, 18, 19, 20, 21, 22, 23, 24,
+	/* 'p' */ 25, 26, 27, 28, 29, 30, 31, 64,  64, 64, 64, 64, 64, 64, 64, 64
+#else
+	/* \00 */ 64, 64, 64, 64, 64, 64, 64, 64,  64, 64, 64, 64, 64, 64, 64, 64, 
+	/* DLE */ 64, 64, 64, 64, 64, 64, 64, 64,  64, 64, 64, 64, 64, 64, 64, 64, 
+	/* SPC */ 64, 64, 64, 64, 64, 64, 64, 64,  64, 64, 64, 64, 64, 64, 64, 64, 
+	/* '0' */ 64, 64, 26, 27, 28, 29, 30, 31,  64, 64, 64, 64, 64, 64, 64, 64, 
+	/* '@' */ 64,  0,  1,  2,  3,  4,  5,  6,   7,  8,  9, 10, 11, 12, 13, 14,
+	/* 'P' */ 15, 16, 17, 18, 19, 20, 21, 22,  23, 24, 25, 64, 64, 64, 64, 64,
+	/* '`' */ 64,  0,  1,  2,  3,  4,  5,  6,   7,  8,  9, 10, 11, 12, 13, 14,
+	/* 'p' */ 15, 16, 17, 18, 19, 20, 21, 22,  23, 24, 25, 64, 64, 64, 64, 64
+#endif
+      };
+
+    static const char hex[]="0123456789abcdef";
+
+#define USAGED "estring"
+
+      if (objc != 2) {
+        Tcl_WrongNumArgs (interp, 1, objv, USAGED);
+        return TCL_ERROR;
+      }
+
+      buf = (unsigned char *) Tcl_GetStringFromObj (objv[1], &nbuf);
+
+      if (nbuf % 8) {
+	Tcl_SetObjResult (interp, Tcl_NewStringObj ("Length is not a multiple of 8", -1));
+        return TCL_ERROR;
+      }
+
+      nout = (nbuf/8)*5 *TCL_UTF_MAX;
+      out  = (unsigned char*) Tcl_Alloc (nout*sizeof(char));
+
+#define HIGH(x) (((x) & 0x80) != 0)
+#define BADC(x) ((x) == 64)
+#define BADCHAR(a,j) (HIGH ((a)) || BADC (x [(j)] = map [(a)]))
+
+      for (pad = 0, i=0, at = out; i < nbuf; i += 8, buf += 8){
+	for (j=0; j < 8; j++){
+	  a = buf [j];
+
+	  if (a == '=') {
+	    x[j] = 0;
+	    pad++;
+	    continue;
+	  } else if (pad) {
+	    char     msg [120];
+	    sprintf (msg,
+		     "Invalid character at index %d: \"=\" (padding found in the middle of the input)",
+		     j-1);
+	    Tcl_Free ((char*) out);
+	    Tcl_SetObjResult (interp, Tcl_NewStringObj (msg, -1));
+	    return TCL_ERROR;
+	  }
+
+	  if (BADCHAR (a,j)) {
+	    char     msg [100];
+	    sprintf (msg,"Invalid character at index %d: \"%c\"",j,a);
+	    Tcl_Free ((char*) out);
+	    Tcl_SetObjResult (interp, Tcl_NewStringObj (msg, -1));
+	    return TCL_ERROR;
+	  }
+	}
+
+	*(at++) = (x[0]<<3) | (x[1]>>2)            ;
+	*(at++) = (x[1]<<6) | (x[2]<<1) | (x[3]>>4);
+	*(at++) = (x[3]<<4) | (x[4]>>1)            ;
+	*(at++) = (x[4]<<7) | (x[5]<<2) | (x[6]>>3);
+	*(at++) = (x[6]<<5) | x[7]                 ;
+      }
+
+      if (pad) {
+	if (pad == 1) {
+	  at -= 1;
+	} else if (pad == 3) {
+	  at -= 2;
+	} else if (pad == 4) {
+	  at -= 3;
+	} else if (pad == 6) {
+	  at -= 4;
+	} else {
+	  char     msg [100];
+	  sprintf (msg,"Invalid padding of length %d",pad);
+	  Tcl_Free ((char*) out);
+	  Tcl_SetObjResult (interp, Tcl_NewStringObj (msg, -1));
+	  return TCL_ERROR;
+	}
+      }
+
+      nout = at-out;
+      ndigest = nout * 2;
+      digest = (unsigned char*) Tcl_Alloc (ndigest*sizeof(char)+1);
+
+      for (i = 0; i < nout; i++) {
+        digest[i+i] = hex[out[i] >> 4];	
+        digest[i+i+1] = hex[out[i] & 0x0f];
+      }	
+      digest[i+i] = '\0';
+
+      Tcl_SetObjResult (interp, Tcl_NewByteArrayObj (digest, ndigest));
+      Tcl_Free ((char*) out);
+      Tcl_Free ((char*) digest);
+      return TCL_OK;
+    }
+

Copied: branches/new-help-system/base/src/pextlib1.0/base32cmd.h (from rev 90355, trunk/base/src/pextlib1.0/base32cmd.h)
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/base32cmd.h	                        (rev 0)
+++ branches/new-help-system/base/src/pextlib1.0/base32cmd.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,43 @@
+/*
+ * base32cmd.h
+ * $Id$
+ *
+ * Copyright (c) 2010 The MacPorts Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of 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.
+ */
+
+#ifndef _BASE32CMD_H
+#define _BASE32CMD_H
+
+#include <tcl.h>
+
+int Base32EncodeCmd(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST objv[]);
+
+int Base32DecodeCmd(ClientData, Tcl_Interp *, int, Tcl_Obj *CONST objv[]);
+
+#endif
+        /* _BASE32CMD_H */

Modified: branches/new-help-system/base/src/pextlib1.0/curl.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/curl.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/curl.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -190,10 +190,8 @@
 					break;
 				}
 			} else {
-				char theErrorString[512];
-				(void) snprintf(theErrorString, sizeof(theErrorString),
-					"curl fetch: unknown option %s", theOption);
-				Tcl_SetResult(interp, theErrorString, TCL_VOLATILE);
+				Tcl_ResetResult(interp);
+				Tcl_AppendResult(interp, "curl fetch: unknown option ", theOption, NULL);
 				theResult = TCL_ERROR;
 				break;
 			}
@@ -239,6 +237,20 @@
 			break;
 		}
 
+#if LIBCURL_VERSION_NUM >= 0x071304 && LIBCURL_VERSION_NUM <= 0x071307
+        /* FTP_PROXY workaround for Snow Leopard */
+        if (strncmp(theURL, "ftp:", 4) == 0) {
+            char *ftp_proxy = getenv("FTP_PROXY");
+            if (ftp_proxy) {
+                theCurlCode = curl_easy_setopt(theHandle, CURLOPT_PROXY, ftp_proxy);
+                if (theCurlCode != CURLE_OK) {
+                    theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+                    break;
+                }
+            }
+        }
+#endif
+
 		/* -L option */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_FOLLOWLOCATION, 1);
 		if (theCurlCode != CURLE_OK) {
@@ -274,6 +286,27 @@
 			break;
 		}
 
+		/* set timeout on connections */
+		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_CONNECTTIMEOUT, _CURL_CONNECTION_TIMEOUT);
+		if (theCurlCode != CURLE_OK) {
+			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+			break;
+		}
+
+		/* set minimum connection speed */
+		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_LOW_SPEED_LIMIT, _CURL_MINIMUM_XFER_SPEED);
+		if (theCurlCode != CURLE_OK) {
+			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+			break;
+		}
+
+		/* set timeout interval for connections < min xfer speed */
+		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_LOW_SPEED_TIME, _CURL_MINIMUM_XFER_TIMEOUT);
+		if (theCurlCode != CURLE_OK) {
+			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+			break;
+		}
+
 		/* skip the header data */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_HEADER, 0);
 		if (theCurlCode != CURLE_OK) {
@@ -452,24 +485,50 @@
 	FILE* theFile = NULL;
 
 	do {
+		int optioncrsr;
+		int lastoption;
+		int ignoresslcert = 0;
 		long theResponseCode = 0;
 		const char* theURL;
 		CURLcode theCurlCode;
 		long theModDate;
 		long userModDate;
 
+		optioncrsr = 2;
+		lastoption = objc - 3;
+		while (optioncrsr <= lastoption) {
+			/* get the option */
+			const char* theOption = Tcl_GetString(objv[optioncrsr]);
+
+			if (strcmp(theOption, "--ignore-ssl-cert") == 0) {
+				ignoresslcert = 1;
+			} else {
+				Tcl_ResetResult(interp);
+				Tcl_AppendResult(interp, "curl isnewer: unknown option ", theOption, NULL);
+				theResult = TCL_ERROR;
+				break;
+			}
+
+			optioncrsr++;
+                }
+
+		if (optioncrsr <= lastoption) {
+			/* something went wrong */
+			break;
+		}
+
 		/* first (second) parameter is the url, second (third) parameter is the date */
-		if (objc != 4) {
-			Tcl_WrongNumArgs(interp, 1, objv, "isnewer url date");
+		if (objc < 4 || objc > 5) {
+			Tcl_WrongNumArgs(interp, 1, objv, "isnewer [--ignore-ssl-cert] url date");
 			theResult = TCL_ERROR;
 			break;
 		}
 
 		/* Retrieve the url */
-		theURL = Tcl_GetString(objv[2]);
+		theURL = Tcl_GetString(objv[objc - 2]);
 
 		/* Get the date */
-		theResult = Tcl_GetLongFromObj(interp, objv[3], &userModDate);
+		theResult = Tcl_GetLongFromObj(interp, objv[objc - 1], &userModDate);
 		if (theResult != TCL_OK) {
 			break;
 		}
@@ -521,7 +580,7 @@
 		}
 
 		/* set timeout on connections */
-		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_TIMEOUT, _CURL_CONNECTION_TIMEOUT);
+		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_CONNECTTIMEOUT, _CURL_CONNECTION_TIMEOUT);
 		if (theCurlCode != CURLE_OK) {
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
@@ -548,6 +607,20 @@
 			break;
 		}
 
+		/* we may want to ignore ssl errors */
+		if (ignoresslcert) {
+			theCurlCode = curl_easy_setopt(theHandle, CURLOPT_SSL_VERIFYPEER, (long) 0);
+			if (theCurlCode != CURLE_OK) {
+				theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+				break;
+			}
+			theCurlCode = curl_easy_setopt(theHandle, CURLOPT_SSL_VERIFYHOST, (long) 0);
+			if (theCurlCode != CURLE_OK) {
+				theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+				break;
+			}
+		}
+
 		/* save the modification date */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_FILETIME, 1);
 		if (theCurlCode != CURLE_OK) {
@@ -647,20 +720,46 @@
 	FILE* theFile = NULL;
 
 	do {
+		int optioncrsr;
+		int lastoption;
+		int ignoresslcert = 0;
 		char theSizeString[32];
 		const char* theURL;
 		CURLcode theCurlCode;
 		double theFileSize;
 
+		optioncrsr = 2;
+		lastoption = objc - 2;
+		while (optioncrsr <= lastoption) {
+			/* get the option */
+			const char* theOption = Tcl_GetString(objv[optioncrsr]);
+
+			if (strcmp(theOption, "--ignore-ssl-cert") == 0) {
+				ignoresslcert = 1;
+			} else {
+				Tcl_ResetResult(interp);
+				Tcl_AppendResult(interp, "curl getsize: unknown option ", theOption, NULL);
+				theResult = TCL_ERROR;
+				break;
+			}
+
+			optioncrsr++;
+                }
+
+		if (optioncrsr <= lastoption) {
+			/* something went wrong */
+			break;
+		}
+
 		/* first (second) parameter is the url */
-		if (objc != 3) {
-			Tcl_WrongNumArgs(interp, 1, objv, "getsize url");
+		if (objc < 3 || objc > 4) {
+			Tcl_WrongNumArgs(interp, 1, objv, "getsize [--ignore-ssl-cert] url");
 			theResult = TCL_ERROR;
 			break;
 		}
 
 		/* Retrieve the url */
-		theURL = Tcl_GetString(objv[2]);
+		theURL = Tcl_GetString(objv[objc - 1]);
 
 		/* Open the file (dev/null) */
 		theFile = fopen( "/dev/null", "a" );
@@ -709,7 +808,7 @@
 		}
 
 		/* set timeout on connections */
-		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_TIMEOUT, _CURL_CONNECTION_TIMEOUT);
+		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_CONNECTTIMEOUT, _CURL_CONNECTION_TIMEOUT);
 		if (theCurlCode != CURLE_OK) {
 			theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
 			break;
@@ -736,6 +835,20 @@
 			break;
 		}
 
+		/* we may want to ignore ssl errors */
+		if (ignoresslcert) {
+			theCurlCode = curl_easy_setopt(theHandle, CURLOPT_SSL_VERIFYPEER, (long) 0);
+			if (theCurlCode != CURLE_OK) {
+				theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+				break;
+			}
+			theCurlCode = curl_easy_setopt(theHandle, CURLOPT_SSL_VERIFYHOST, (long) 0);
+			if (theCurlCode != CURLE_OK) {
+				theResult = SetResultFromCurlErrorCode(interp, theCurlCode);
+				break;
+			}
+		}
+
 		/* skip the header data */
 		theCurlCode = curl_easy_setopt(theHandle, CURLOPT_HEADER, 0);
 		if (theCurlCode != CURLE_OK) {

Modified: branches/new-help-system/base/src/pextlib1.0/fs-traverse.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/fs-traverse.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/fs-traverse.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -5,7 +5,7 @@
  * Find files and execute arbitrary expressions on them.
  * Author: Jordan K. Hubbard, Kevin Ballard, Rainer Mueller
  *
- * Copyright (c) 2004 Apple Computer, Inc.
+ * Copyright (c) 2004 Apple Inc.
  * Copyright (c) 2010 The MacPorts Project
  * All rights reserved.
  *
@@ -17,7 +17,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 
@@ -146,6 +146,8 @@
             xpath = ".";
         } else if (*(xpath + tlen) == '/') {
             xpath += tlen + 1;
+        } else if (*(target + tlen - 1) == '/') {
+            xpath += tlen;
         }
     }
 
@@ -247,8 +249,14 @@
         }
     }
     /* check errno before calling fts_close in case it sets errno to 0 on success */
-    if (errno != 0 || (fts_close(root_fts) != 0 && !(flags & F_IGNORE_ERRORS))) {
+    if (errno != 0) {
         Tcl_SetErrno(errno);
+        Tcl_ResetResult(interp);
+        Tcl_AppendResult(interp, root_fts->fts_path, ": ", (char *)Tcl_PosixError(interp), NULL);
+        fts_close(root_fts);
+        return TCL_ERROR;
+    } else if (fts_close(root_fts) != 0 && !(flags & F_IGNORE_ERRORS)) {
+        Tcl_SetErrno(errno);
         Tcl_SetResult(interp, (char *)Tcl_PosixError(interp), TCL_STATIC);
         return TCL_ERROR;
     }

Modified: branches/new-help-system/base/src/pextlib1.0/fs-traverse.h
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/fs-traverse.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/fs-traverse.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
  * fs-traverse.h
  * $Id$
  *
- * Copyright (c) 2002 - 2003 Apple Computer, Inc.
+ * Copyright (c) 2002 - 2003 Apple Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,7 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 

Modified: branches/new-help-system/base/src/pextlib1.0/md5cmd.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/md5cmd.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/md5cmd.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
  * md5cmd.c
  * $Id$
  *
- * Copyright (c) 2002 - 2003 Apple Computer, Inc.
+ * Copyright (c) 2004 - 2005, 2009, 2011 The MacPorts Project
+ * Copyright (c) 2002 - 2003 Apple Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 
@@ -58,11 +59,18 @@
 CHECKSUMEnd(MD5, MD5_CTX, MD5_DIGEST_LENGTH)
 CHECKSUMFile(MD5, MD5_CTX)
 
-#elif defined(HAVE_LIBMD)
+#elif defined(HAVE_LIBMD) && defined(HAVE_MD5_H)
 #include <sys/types.h>
 #include <md5.h>
+#elif defined(HAVE_LIBCRYPTO) && defined(HAVE_OPENSSL_MD5_H)
+#include <openssl/md5.h>
+
+#include "md_wrappers.h"
+CHECKSUMEnd(MD5_, MD5_CTX, MD5_DIGEST_LENGTH)
+CHECKSUMFile(MD5_, MD5_CTX)
+#define MD5File(x,y) MD5_File(x,y)
 #else
-#error CommonCrypto or libmd required
+#error CommonCrypto, libmd or libcrypto required
 #endif
 
 int MD5Cmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])

Modified: branches/new-help-system/base/src/pextlib1.0/md5cmd.h
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/md5cmd.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/md5cmd.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
  * md5cmd.h
  * $Id$
  *
- * Copyright (c) 2002 - 2003 Apple Computer, Inc.
+ * Copyright (c) 2002 - 2003 Apple Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,7 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 

Modified: branches/new-help-system/base/src/pextlib1.0/md_wrappers.h
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/md_wrappers.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/md_wrappers.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -13,7 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 

Modified: branches/new-help-system/base/src/pextlib1.0/rmd160cmd.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/rmd160cmd.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/rmd160cmd.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,6 +2,7 @@
  * rmd160cmd.c
  * $Id$
  *
+ * Copyright (c) 2006, 2009-2011 The MacPorts Project
  * Copyright (c) 2005 Paul Guyot <pguyot at kallisys.net>.
  * All rights reserved.
  *
@@ -13,7 +14,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 
@@ -35,30 +36,40 @@
 #endif
 
 #include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
 
 #include <tcl.h>
 
 #include "rmd160cmd.h"
 
+#if defined(HAVE_LIBMD) && defined(HAVE_RIPEMD_H)
+#include <sys/types.h>
+#include <ripemd.h>
+#elif defined(HAVE_LIBCRYPTO) && defined(HAVE_OPENSSL_RIPEMD_H)
+#include <openssl/ripemd.h>
+
+#include "md_wrappers.h"
+CHECKSUMEnd(RIPEMD160_, RIPEMD160_CTX, RIPEMD160_DIGEST_LENGTH)
+CHECKSUMFile(RIPEMD160_, RIPEMD160_CTX)
+#else
 /*
  * let's use our own version of rmd160* libraries.
  */
-#include <stdio.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-
 #include <sys/types.h>
-
 #include "rmd160.h"
 #include "rmd160.c"
 #define RIPEMD160_DIGEST_LENGTH 20
+#define RIPEMD160_File(x,y) RMD160File(x,y)
+
 #include "md_wrappers.h"
 CHECKSUMEnd(RMD160, RMD160_CTX, RIPEMD160_DIGEST_LENGTH)
 CHECKSUMFile(RMD160, RMD160_CTX)
+#endif
 
-
 int RMD160Cmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
 	char *file, *action;
@@ -83,7 +94,7 @@
 	}
 	file = Tcl_GetString(objv[2]);
 
-	if (!RMD160File(file, buf)) {
+	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);

Modified: branches/new-help-system/base/src/pextlib1.0/rmd160cmd.h
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/rmd160cmd.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/rmd160cmd.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -13,7 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 

Copied: branches/new-help-system/base/src/pextlib1.0/setmode.h (from rev 90355, trunk/base/src/pextlib1.0/setmode.h)
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/setmode.h	                        (rev 0)
+++ branches/new-help-system/base/src/pextlib1.0/setmode.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,6 @@
+/*
+ * $Id$
+ */
+
+mode_t getmode(const void *bbox, mode_t omode);
+void * setmode(const char *p);

Modified: branches/new-help-system/base/src/pextlib1.0/sha1cmd.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/sha1cmd.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/sha1cmd.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,7 +3,8 @@
  * $Id$
  * Copied from md5cmd.c 20040903 EH
  *
- * Copyright (c) 2002 - 2003 Apple Computer, Inc.
+ * Copyright (c) 2004 - 2005, 2009 - 2011 The MacPorts Project
+ * Copyright (c) 2002 - 2003 Apple Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 
@@ -54,13 +55,23 @@
 CHECKSUMEnd(SHA1_, SHA_CTX, SHA_DIGEST_LENGTH)
 CHECKSUMFile(SHA1_, SHA_CTX)
 
-#elif defined(HAVE_LIBMD)
+#elif defined(HAVE_LIBMD) && defined(HAVE_SHA_H)
 #include <sys/types.h>
 #include <sha.h>
-#define SHA_DIGEST_LENGTH (SHA_HASHBYTES)
+#ifndef SHA_DIGEST_LENGTH
+#define SHA_DIGEST_LENGTH 20
+#endif
+#ifndef HAVE_SHA1_FILE
 #define SHA1_File(x,y) SHAFile(x,y)
+#endif
+#elif defined(HAVE_LIBCRYPTO) && defined(HAVE_OPENSSL_SHA_H)
+#include <openssl/sha.h>
+
+#include "md_wrappers.h"
+CHECKSUMEnd(SHA1_, SHA_CTX, SHA_DIGEST_LENGTH)
+CHECKSUMFile(SHA1_, SHA_CTX)
 #else
-#error CommonCrypto or libmd required
+#error CommonCrypto, libmd or libcrypto required
 #endif
 
 int SHA1Cmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])

Modified: branches/new-help-system/base/src/pextlib1.0/sha1cmd.h
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/sha1cmd.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/sha1cmd.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,7 +3,7 @@
  * $Id$
  * Copied from md5cmd.h 20040903 EH
  *
- * Copyright (c) 2002 - 2003 Apple Computer, Inc.
+ * Copyright (c) 2002 - 2003 Apple Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 


Property changes on: branches/new-help-system/base/src/pextlib1.0/sha2.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base/src/pextlib1.0/sha2.c:37343-46937
/branches/universal-sanity/base/src/pextlib1.0/sha2.c:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/sha2.c:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base/src/pextlib1.0/sha2.c:57889-70794
/users/perry/base-bugs_and_notes/src/pextlib1.0/sha2.c:45682-46060
/users/perry/base-select/src/pextlib1.0/sha2.c:44044-44692
   + /branches/gsoc08-privileges/base/src/pextlib1.0/sha2.c:37343-46937
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/sha2.c:78828-88375
/branches/universal-sanity/base/src/pextlib1.0/sha2.c:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/sha2.c:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base/src/pextlib1.0/sha2.c:57888-90355
/users/perry/base-bugs_and_notes/src/pextlib1.0/sha2.c:45682-46060
/users/perry/base-select/src/pextlib1.0/sha2.c:44044-44692


Property changes on: branches/new-help-system/base/src/pextlib1.0/sha2.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/gsoc08-privileges/base/src/pextlib1.0/sha2.h:37343-46937
/branches/universal-sanity/base/src/pextlib1.0/sha2.h:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/sha2.h:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base/src/pextlib1.0/sha2.h:57889-70794
/users/perry/base-bugs_and_notes/src/pextlib1.0/sha2.h:45682-46060
/users/perry/base-select/src/pextlib1.0/sha2.h:44044-44692
   + /branches/gsoc08-privileges/base/src/pextlib1.0/sha2.h:37343-46937
/branches/gsoc11-rev-upgrade/base/src/pextlib1.0/sha2.h:78828-88375
/branches/universal-sanity/base/src/pextlib1.0/sha2.h:51872-52323
/branches/variant-descs-14482/base/src/pextlib1.0/sha2.h:34469-34855,34900-37508,37511-37512,41040-41463,42575-42626,42640-42659
/trunk/base/src/pextlib1.0/sha2.h:57888-90355
/users/perry/base-bugs_and_notes/src/pextlib1.0/sha2.h:45682-46060
/users/perry/base-select/src/pextlib1.0/sha2.h:44044-44692

Modified: branches/new-help-system/base/src/pextlib1.0/sha256cmd.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/sha256cmd.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/sha256cmd.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
  * sha256cmd.c
  * $Id$
  *
- * Copyright (c) 2009 The MacPorts Project
+ * Copyright (c) 2009, 2011 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -13,7 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 
@@ -58,18 +58,34 @@
 #define SHA256_Final(m, c)              CC_SHA256_Final(m,c)
 #endif
 
+#include "md_wrappers.h"
+CHECKSUMEnd(SHA256_, SHA256_CTX, SHA256_DIGEST_LENGTH)
+CHECKSUMFile(SHA256_, SHA256_CTX)
+
+#elif defined(HAVE_LIBMD) && defined(HAVE_SHA256_H) && !defined(__FreeBSD__) /*dumps core*/
+#include <sys/types.h>
+#include <sha256.h>
+#ifndef SHA256_DIGEST_LENGTH
+#define SHA256_DIGEST_LENGTH 32
+#endif
+#elif defined(HAVE_LIBCRYPTO) && defined(HAVE_OPENSSL_SHA_H) && defined(HAVE_SHA256_UPDATE)
+#include <openssl/sha.h>
+
+#include "md_wrappers.h"
+CHECKSUMEnd(SHA256_, SHA256_CTX, SHA256_DIGEST_LENGTH)
+CHECKSUMFile(SHA256_, SHA256_CTX)
 #else
-/* We do not have CommonCrypto.
-* let's use our own version of sha256* libraries.
-*/
+/*
+ * let's use our own version of sha256* libraries.
+ */
 #include <sys/types.h>
 #include "sha2.h"
 #include "sha2.c"
-#endif
 
 #include "md_wrappers.h"
 CHECKSUMEnd(SHA256_, SHA256_CTX, SHA256_DIGEST_LENGTH)
 CHECKSUMFile(SHA256_, SHA256_CTX)
+#endif
 
 int SHA256Cmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {


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

Modified: branches/new-help-system/base/src/pextlib1.0/sha256cmd.h
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/sha256cmd.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/sha256cmd.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -13,7 +13,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 


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

Modified: branches/new-help-system/base/src/pextlib1.0/system.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/system.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/system.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -49,6 +49,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <limits.h>
+#include <errno.h>
 
 #include "system.h"
 #include "Pextlib.h"
@@ -60,6 +61,10 @@
 extern char **environ;
 #endif
 
+#if !HAVE_FGETLN
+char *fgetln(FILE *stream, size_t *len);
+#endif
+
 #ifndef _PATH_DEVNULL
 #define _PATH_DEVNULL "/dev/null"
 #endif
@@ -71,7 +76,7 @@
     char *line;
 };
 
-/* usage: system ?-notty? ?-nice value? command */
+/* usage: system ?-notty? ?-nice value? ?-W path? command */
 int SystemCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
     char *buf;
@@ -84,6 +89,7 @@
     int fline, pos, ret;
     int osetsid = 0;
     int oniceval = INT_MAX; /* magic value indicating no change */
+    const char *path = NULL;
     pid_t pid;
     uid_t euid;
     Tcl_Obj *tcl_result;
@@ -91,7 +97,7 @@
     int i;
 
     if (objc < 2) {
-        Tcl_WrongNumArgs(interp, 1, objv, "?-notty? ?-nice value? command");
+        Tcl_WrongNumArgs(interp, 1, objv, "?-notty? ?-nice value? ?-W path? command");
         return TCL_ERROR;
     }
 
@@ -107,6 +113,12 @@
                 Tcl_SetResult(interp, "invalid value for -nice", TCL_STATIC);
                 return TCL_ERROR;
             }
+        } else if (strcmp(arg, "-W") == 0) {
+            i++;
+            if ((path = Tcl_GetString(objv[i])) == NULL) {
+                Tcl_SetResult(interp, "invalid value for -W", TCL_STATIC);
+                return TCL_ERROR;
+            }
         } else {
             tcl_result = Tcl_NewStringObj("bad option ", -1);
             Tcl_AppendObjToObj(tcl_result, Tcl_NewStringObj(arg, -1));
@@ -120,12 +132,14 @@
      * popen() itself is not used because stderr is also desired.
      */
     if (pipe(fdset) != 0) {
+        Tcl_SetResult(interp, strerror(errno), TCL_STATIC);
         return TCL_ERROR;
     }
 
     pid = fork();
     switch (pid) {
     case -1: /* error */
+        Tcl_SetResult(interp, strerror(errno), TCL_STATIC);
         return TCL_ERROR;
         break;
     case 0: /* child */
@@ -149,10 +163,19 @@
         }
         /* drop privileges entirely for child */
         if (getuid() == 0 && (euid = geteuid()) != 0) {
-            if (seteuid(0) || setuid(euid)) {
+            gid_t egid = getegid();
+            if (seteuid(0) || setgid(egid) || setuid(euid)) {
                 _exit(1);
             }
         }
+
+        if (path != NULL) {
+            if (chdir(path) == -1) {
+                printf("chdir: %s: %s\n", path, strerror(errno));
+                exit(1);
+            }
+        }
+
         /* XXX ugly string constants */
         args[0] = "sh";
         args[1] = "-c";
@@ -172,47 +195,52 @@
     pos = 0;
     memset(circbuf, 0, sizeof(circbuf));
     pdes = fdopen(fdset[0], "r");
-    while ((buf = fgetln(pdes, &linelen)) != NULL) {
-        char *sbuf;
-        int slen;
-
-        /*
-         * Allocate enough space to insert a terminating
-         * '\0' if the line is not terminated with a '\n'
-         */
-        if (buf[linelen - 1] == '\n')
-            slen = linelen;
-        else
-            slen = linelen + 1;
-
-        if (circbuf[pos].len == 0)
-            sbuf = malloc(slen);
-        else {
-            sbuf = realloc(circbuf[pos].line, slen);
+    if (pdes) {
+        while ((buf = fgetln(pdes, &linelen)) != NULL) {
+            char *sbuf;
+            int slen;
+    
+            /*
+             * Allocate enough space to insert a terminating
+             * '\0' if the line is not terminated with a '\n'
+             */
+            if (buf[linelen - 1] == '\n')
+                slen = linelen;
+            else
+                slen = linelen + 1;
+    
+            if (circbuf[pos].len == 0)
+                sbuf = malloc(slen);
+            else {
+                sbuf = realloc(circbuf[pos].line, slen);
+            }
+    
+            if (sbuf == NULL) {
+                read_failed = 1;
+                break;
+            }
+    
+            memcpy(sbuf, buf, linelen);
+            /* terminate line with '\0',replacing '\n' if it exists */
+            sbuf[slen - 1] = '\0';
+    
+            circbuf[pos].line = sbuf;
+            circbuf[pos].len = slen;
+    
+            if (pos++ == CBUFSIZ - 1) {
+                pos = 0;
+            }
+    
+            if (ui_info(interp, sbuf) != TCL_OK) {
+                read_failed = 1;
+                break;
+            }
         }
-
-        if (sbuf == NULL) {
-            read_failed = 1;
-            break;
-        }
-
-        memcpy(sbuf, buf, linelen);
-        /* terminate line with '\0',replacing '\n' if it exists */
-        sbuf[slen - 1] = '\0';
-
-        circbuf[pos].line = sbuf;
-        circbuf[pos].len = slen;
-
-        if (pos++ == CBUFSIZ - 1) {
-            pos = 0;
-        }
-
-        if (ui_info(interp, sbuf) != TCL_OK) {
-            read_failed = 1;
-            break;
-        }
+        fclose(pdes);
+    } else {
+        read_failed = 1;
+        Tcl_SetResult(interp, strerror(errno), TCL_STATIC);
     }
-    fclose(pdes);
 
     status = TCL_ERROR;
 
@@ -223,6 +251,19 @@
         } else {
             char *errorstr;
             size_t errorstrlen;
+
+            /* print error */
+            /* get buffer large enough for additional message or the error code */
+            errorstrlen = strlen(cmdstring) + strlen("Command failed: ") + 12;
+            errorstr = malloc(errorstrlen);
+            if (errorstr) {
+                snprintf(errorstr, errorstrlen, "Command failed: %s", cmdstring);
+                ui_info(interp, errorstr);
+                snprintf(errorstr, errorstrlen, "Exit code: %d", WEXITSTATUS(ret));
+                ui_info(interp, errorstr);
+                free(errorstr);
+            }
+
             /* set errorCode [list CHILDSTATUS <pid> <code>] */
             Tcl_Obj* errorCode = Tcl_NewListObj(0, NULL);
             Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewStringObj("CHILDSTATUS", -1));
@@ -230,16 +271,7 @@
             Tcl_ListObjAppendElement(interp, errorCode, Tcl_NewIntObj(WEXITSTATUS(ret)));
             Tcl_SetObjErrorCode(interp, errorCode);
 
-            /* print error */
-            errorstrlen = strlen("shell command \"")+strlen(cmdstring)+strlen("\" returned error ")+12;
-            errorstr = malloc(errorstrlen);
-            if (errorstr) {
-                *errorstr = '\0';
-                snprintf(errorstr, errorstrlen, "%s%s%s%d", "shell command \"", cmdstring, "\" returned error ", WEXITSTATUS(ret));
-                ui_info(interp, errorstr);
-                free(errorstr);
-            }
-            Tcl_SetObjResult(interp, Tcl_NewStringObj("shell command failed", -1));
+            Tcl_SetObjResult(interp, Tcl_NewStringObj("command execution failed", -1));
         }
     }
 

Copied: branches/new-help-system/base/src/pextlib1.0/tests/base32.tcl (from rev 90355, trunk/base/src/pextlib1.0/tests/base32.tcl)
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/tests/base32.tcl	                        (rev 0)
+++ branches/new-help-system/base/src/pextlib1.0/tests/base32.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,19 @@
+# Test file for Pextlib's base32 commands.
+# Syntax:
+# tclsh base32.tcl <Pextlib name>
+
+proc main {pextlibname} {
+	load $pextlibname
+	
+	if {[base32encode "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"] != "SEOC8GKOVGE196NRUJ49IRTP4GJQSGF4CIDP6J54IMCHMU2IN1AG===="} {
+		puts {[base32encode "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"] != "SEOC8GKOVGE196NRUJ49IRTP4GJQSGF4CIDP6J54IMCHMU2IN1AG===="}
+		exit 1
+	}
+
+	if {[base32decode "SEOC8GKOVGE196NRUJ49IRTP4GJQSGF4CIDP6J54IMCHMU2IN1AG===="] != "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"} {
+		puts {[base32decode "SEOC8GKOVGE196NRUJ49IRTP4GJQSGF4CIDP6J54IMCHMU2IN1AG===="] != "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"}
+		exit 1
+	}
+}
+
+main $argv

Modified: branches/new-help-system/base/src/pextlib1.0/tests/curl.tcl
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/tests/curl.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/tests/curl.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -24,8 +24,8 @@
 	test {![curl isnewer $dummyroot/dummy [clock scan 2007-06-17Z]]}
 	
 	# use --disable-epsv
-	curl fetch --disable-epsv ftp://ftp.cup.hp.com/dist/networking/benchmarks/netperf/archive/netperf-2.2pl5.tar.gz $tempfile
-	test {[md5 file $tempfile] == "a4b0f4a5fbd8bec23002ad8023e01729"}
+	#curl fetch --disable-epsv ftp://ftp.cup.hp.com/dist/networking/benchmarks/netperf/archive/netperf-2.2pl5.tar.gz $tempfile
+	#test {[md5 file $tempfile] == "a4b0f4a5fbd8bec23002ad8023e01729"}
 	
 	# use -u
 	# This URL does not work anymore, disabled the test

Copied: branches/new-help-system/base/src/pextlib1.0/tests/vercomp.tcl (from rev 90355, trunk/base/src/pextlib1.0/tests/vercomp.tcl)
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/tests/vercomp.tcl	                        (rev 0)
+++ branches/new-help-system/base/src/pextlib1.0/tests/vercomp.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,47 @@
+# Test file for Pextlib's vercmp command.
+# Syntax:
+# tclsh vercomp.tcl <Pextlib name>
+
+proc main {pextlibname} {
+	load $pextlibname
+	
+	# 2.0 > 1.0
+	if {[vercmp 2.0 1.0] <= 0} {
+		puts {[vercmp 2.0 1.0] <= 0}
+		exit 1
+	}
+	# 1.0 = 1.0
+	if {[vercmp 1.0 1.0] != 0} {
+		puts {[vercmp 1.0 1.0] != 0}
+		exit 1
+	}
+	# 1.0 < 2.0
+	if {[vercmp 1.0 2.0] >= 0} {
+		puts {[vercmp 1.0 2.0] >= 0}
+		exit 1
+	}
+
+	# def > abc
+	if {[vercmp def abc] <= 0} {
+		puts {[vercmp def abc] <= 0}
+		exit 1
+	}
+	# abc = abc
+	if {[vercmp abc abc] != 0} {
+		puts {[vercmp abc abc] != 0}
+		exit 1
+	}
+	# abc < def
+	if {[vercmp abc def] >= 0} {
+		puts {[vercmp abc def] >= 0}
+		exit 1
+	}
+
+	# a < 1 (digits beats alpha)
+	if {[vercmp a 1] >= 0} {
+		puts {[vercmp a 1] >= 0}
+		exit 1
+	}
+}
+
+main $argv

Modified: branches/new-help-system/base/src/pextlib1.0/tty.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/tty.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/tty.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -5,6 +5,7 @@
  *
  * Author: Rainer Mueller <raimue at macports.org>
  *
+ * Copyright (c) 2009 The MacPorts Project
  * Copyright (c) 2008 Rainer Mueller <raimue at macports.org>
  * All rights reserved.
  *
@@ -16,7 +17,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its
+ * 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.
  * 

Modified: branches/new-help-system/base/src/pextlib1.0/tty.h
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/tty.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/tty.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -16,7 +16,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its
+ * 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.
  * 

Modified: branches/new-help-system/base/src/pextlib1.0/vercomp.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/vercomp.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/vercomp.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,11 +1,11 @@
 /*
  * vercomp.c
  * $Id$
- * RPM compatible version comparison
+ * version comparison
  *
  * Author: Landon Fuller <landonf at macports.org>
  *
- * Copyright (c) 2002 - 2003 Apple Computer, Inc.
+ * Copyright (c) 2002 - 2003 Apple Inc.
  * Copyright (c) 2004 Landon Fuller <landonf at macports.org>
  * All rights reserved.
  *
@@ -17,7 +17,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its
+ * 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.
  * 
@@ -48,10 +48,10 @@
 /*
  * If A is newer than B, return an integer > 0
  * If A and B are equal, return 0
- * If B is newer than A, retun an integer < 0
+ * If B is newer than A, return an integer < 0
  */
 
-static int rpm_vercomp (const char *versionA, const char *versionB) {
+static int vercmp (const char *versionA, const char *versionB) {
 	const char *ptrA, *ptrB;
 	const char *eptrA, *eptrB;
 
@@ -155,7 +155,7 @@
 		return -1;
 }
 
-int RPMVercompCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
+int VercompCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[])
 {
 	Tcl_Obj *tcl_result;
 	const char *versionA, *versionB;
@@ -169,7 +169,7 @@
 	versionA = Tcl_GetString(objv[1]);
 	versionB = Tcl_GetString(objv[2]);
 
-	rval = rpm_vercomp(versionA, versionB);
+	rval = vercmp(versionA, versionB);
 
 	tcl_result = Tcl_NewIntObj(rval);
 	Tcl_SetObjResult(interp, tcl_result);

Modified: branches/new-help-system/base/src/pextlib1.0/vercomp.h
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/vercomp.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/vercomp.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,7 +3,7 @@
  * $Id$
  * Author: Landon Fuller <landonf at macports.org>
  *
- * Copyright (c) 2002 - 2003 Apple Computer, Inc.
+ * Copyright (c) 2002 - 2003 Apple Inc.
  * Copyright (c) 2004 Landon Fuller
  * All rights reserved.
  *
@@ -15,7 +15,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+ * 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.
  * 
@@ -32,4 +32,4 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-int RPMVercompCmd(ClientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]);
+int VercompCmd(ClientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]);

Modified: branches/new-help-system/base/src/pextlib1.0/xinstall.c
===================================================================
--- branches/new-help-system/base/src/pextlib1.0/xinstall.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pextlib1.0/xinstall.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -105,8 +105,7 @@
 #endif
 
 #if !HAVE_SETMODE
-void * setmode(const char *mode_str); 
-mode_t getmode(const void *set, mode_t mode);
+#include "setmode.h"
 #endif
 
 /* Bootstrap aid - this doesn't exist in most older releases */

Modified: branches/new-help-system/base/src/pkg_mkindex.sh.in
===================================================================
--- branches/new-help-system/base/src/pkg_mkindex.sh.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/pkg_mkindex.sh.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # pkg_mkindex.sh
 #
 # Copyright (c) 2009 The MacPorts Project
@@ -12,7 +12,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 

Modified: branches/new-help-system/base/src/port/Makefile
===================================================================
--- branches/new-help-system/base/src/port/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -22,7 +22,8 @@
 	${edit} port.tcl > $@
 
 mkdirs:
-	cat ../../doc/prefix.mtree | $(MTREE) -U -d -e -p ${INSTALLDIR} > /dev/null
+	< ../../doc/prefix.mtree $(MTREE) -U -d -e -p ${INSTALLDIR} > /dev/null
+	< ../../doc/base.mtree $(MTREE) -U -d -e -p ${INSTALLDIR} > /dev/null
 
 clean:
 	rm -f ${SCRIPTS}

Modified: branches/new-help-system/base/src/port/port-help.tcl
===================================================================
--- branches/new-help-system/base/src/port/port-help.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port/port-help.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -14,7 +14,7 @@
 }
 
 set porthelp(archive) {
-Archive the given ports
+Archive the given ports, i.e. install the port image but do not activate
 }
 
 set porthelp(archivefetch) {
@@ -42,7 +42,6 @@
 set porthelp(clean) {
 Removes files associated with the given ports
 
---archive     Removes created archives
 --dist        Removes downloaded distfiles
 --logs        Removes log files
 --work        Removes work directory (default)
@@ -136,8 +135,6 @@
 Edit given ports
 }
 
-set porthelp(ed) $porthelp(edit)
-
 set porthelp(exit) {
 Exit port
 
@@ -254,6 +251,22 @@
 
 set porthelp(quit) $porthelp(exit)
 
+set porthelp(rev-upgrade) {
+Scan for broken binaries in the installed ports and rebuild them as needed. Can
+be run with -y to only report broken ports, but not automatically rebuild them.
+
+You normally wouldn't have to run rev-upgrade manually; it is run automatically
+after each install and upgrade by default. Rev-upgrade doesn't honor package
+names, e.g.
+	upgrade outdated
+will not run rev-upgrade only on outdated, because ports not in outdated might
+have been broken by upgrade outdated. Rev-upgrade will always run on all your
+active ports.
+
+See man 1 port, section rev-upgrade, and man 5 macports.conf, directives
+starting with revupgrade_ for configuration and more information.
+}
+
 set porthelp(rpm) {
 Creates a rpm for each of the given ports
 }
@@ -278,7 +291,7 @@
 specifying any version.
 
 One example is the set of python ports, where there are (among others)
-python25, python26, and python30.  The select action lets you set which
+python25, python26, and python31.  The select action lets you set which
 of these becomes the version run when you simply use 'python'.
 
 <arguments> must include the group upon which to be acted, and may include
@@ -294,6 +307,13 @@
 Upgrade MacPorts itself and run the sync target
 }
 
+set porthelp(space) {
+Show the disk space used by the given ports
+
+--units <units> Specify units to use. Accepted units are: B, kB, KiB, MB, MiB,
+                GB, GiB. The 'B' may be omitted.
+}
+
 set porthelp(srpm) {
 Creates a srpm for each of the given ports
 }
@@ -319,7 +339,7 @@
 }
 
 set porthelp(unarchive) {
-Unarchive the given ports
+Unarchive the destroot of the given ports from installed images
 }
 
 set porthelp(uninstall) {

Modified: branches/new-help-system/base/src/port/port.tcl
===================================================================
--- branches/new-help-system/base/src/port/port.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port/port.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -5,9 +5,9 @@
 # port.tcl
 # $Id$
 #
-# Copyright (c) 2002-2007 The MacPorts Project.
+# Copyright (c) 2004-2011 The MacPorts Project
 # Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
+# Copyright (c) 2002-2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -18,7 +18,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -34,8 +34,7 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 
-catch {source \
-    [file join "@macports_tcl_dir@" macports1.0 macports_fastload.tcl]}
+source [file join "@macports_tcl_dir@" macports1.0 macports_fastload.tcl]
 package require macports
 package require Pextlib 1.0
 
@@ -88,21 +87,23 @@
 ----------------
 Pseudo-portnames are words that may be used in place of a portname, and
 which expand to some set of ports. The common pseudo-portnames are:
-all, current, active, inactive, installed, uninstalled, outdated, obsolete,
-requested, unrequested and leaves.
+all, current, active, inactive, actinact, installed, uninstalled, outdated,
+obsolete, requested, unrequested and leaves.
 These pseudo-portnames expand to the set of ports named.
 
-Additional pseudo-portnames start with...
-variants:, variant:, description:, depends:, depends_lib:, depends_run:,
-depends_build:, depends_fetch:, depends_extract:, portdir:, homepage:, epoch:,
-platforms:, platform:, name:, long_description:, maintainers:, maintainer:,
-categories:, category:, version:, revision:, license:, depof:, rdepof:,
-dependentof:, and rdependentof:.
-These each select a set of ports based on a regex search of metadata
+Pseudo-portnames starting with variants:, variant:, description:, depends:,
+depends_lib:, depends_run:, depends_build:, depends_fetch:, depends_extract:,
+portdir:, homepage:, epoch:, platforms:, platform:, name:, long_description:,
+maintainers:, maintainer:, categories:, category:, version:, revision:, and
+license: each select a set of ports based on a regex search of metadata
 about the ports. In all such cases, a standard regex pattern following
 the colon will be used to select the set of ports to which the
 pseudo-portname expands.
 
+Pseudo-portnames starting with depof:, rdepof:, dependentof:, and rdependentof:
+select ports that are direct or recursive dependencies or dependents of the
+following portname, respectively.
+
 Portnames that contain standard glob characters will be expanded to the
 set of ports matching the glob pattern.
     
@@ -153,7 +154,58 @@
 }
 
 
+# Format an integer representing bytes using given units
+proc bytesize {siz {unit {}}} {
+    if {$unit == {}} {
+        if {$siz > 0x40000000} {
+            set unit "GiB"
+        } elseif {$siz > 0x100000} {
+            set unit "MiB"
+        } elseif {$siz > 0x400} {
+            set unit "KiB"
+        } else {
+            set unit "B"
+        }
+    }
+    switch -- $unit {
+        KiB {
+            set siz [expr $siz / 1024.0]
+        }
+        kB {
+            set siz [expr $siz / 1000.0]
+        }
+        MiB {
+            set siz [expr $siz / 1048576.0]
+        }
+        MB {
+            set siz [expr $siz / 1000000.0]
+        }
+        GiB {
+            set siz [expr $siz / 1073741824.0]
+        }
+        GB {
+            set siz [expr $siz / 1000000000.0]
+        }
+        B { }
+        default {
+            ui_warn "Unknown file size unit '$unit' specified"
+            set unit "B"
+        }
+    }
+    if {[expr round($siz)] != $siz} {
+        set siz [format {%.3f} $siz]
+    }
+    return "$siz $unit"
+}
 
+proc filesize {fil {unit {}}} {
+    set siz {@}
+    catch {
+        set siz [bytesize [file size $fil] $unit]
+    }
+    return $siz
+}
+
 # Produce an error message, and exit, unless
 # we're handling errors in a soft fashion, in which
 # case we continue
@@ -184,10 +236,13 @@
 
 # show the URL for the ticket reporting instructions
 proc print_tickets_url {args} {
-    ui_notice "To report a bug, see <http://guide.macports.org/#project.tickets>"
+    if {${macports::prefix} != "/usr/local" && ${macports::prefix} != "/usr"} {
+        ui_notice "To report a bug, follow the instructions in the guide:\n    http://guide.macports.org/#project.tickets"
+    }
 }
 
 # Form a composite version as is sometimes used for registry functions
+# This function sorts the variants and presents them in a canonical representation
 proc composite_version {version variations {emptyVersionOkay 0}} {
     # Form a composite version out of the version and variations
     
@@ -279,11 +334,10 @@
 }
 
 
-proc add_to_portlist {listname portentry} {
-    upvar $listname portlist
+proc entry_for_portlist {portentry} {
     global global_options global_variations
 
-    # The portlist currently has the following elements in it:
+    # Each portlist entry currently has the following elements in it:
     #   url             if any
     #   name
     #   version         (version_revision)
@@ -311,15 +365,21 @@
         }
     }
 
-
-    # Form the fully descriminated portname: portname/version_revison+-variants
+    # Form the fully discriminated portname: portname/version_revison+-variants
     set port(fullname) "$port(name)/[composite_version $port(version) $port(variants)]"
     
-    # Add it to our portlist
-    lappend portlist [array get port]
+    return [array get port]
 }
 
 
+proc add_to_portlist {listname portentry} {
+    upvar $listname portlist
+    
+    # Form portlist entry and add to portlist
+    lappend portlist [entry_for_portlist $portentry]
+}
+
+
 proc add_ports_to_portlist {listname ports {overridelist ""}} {
     upvar $listname portlist
 
@@ -381,14 +441,14 @@
 
 
 # Execute the enclosed block once for every element in the portlist
-# When the block is entered, the variables portname, portversion, options, and variations
-# will have been set
+# When the block is entered, the following variables will have been set:
+#	portspec, porturl, portname, portversion, options, variations, requested_variations
 proc foreachport {portlist block} {
-    # Restore cwd after each port, since mportopen changes it, and relative
-    # urls will break on subsequent passes
     set savedir [pwd]
     foreach portspec $portlist {
-        uplevel 1 "array set portspec { $portspec }"
+    
+        # Set the variables for the block
+        uplevel 1 "array unset portspec; array set portspec { $portspec }"
         uplevel 1 {
             set porturl $portspec(url)
             set portname $portspec(name)
@@ -400,7 +460,12 @@
             array unset options
             array set options $portspec(options)
         }
+        
+        # Invoke block
         uplevel 1 $block
+        
+        # Restore cwd after each port, since mportopen changes it, and otherwise relative
+        # urls would break on subsequent passes
         if {[file exists $savedir]} {
             cd $savedir
         } else {
@@ -422,9 +487,9 @@
     }
     set avr_ [split $a_(version) "_"]
     set bvr_ [split $b_(version) "_"]
-    set vercmp [rpm-vercomp [lindex $avr_ 0] [lindex $bvr_ 0]]
-    if {$vercmp != 0} {
-        return $vercmp
+    set versioncmp [vercmp [lindex $avr_ 0] [lindex $bvr_ 0]]
+    if {$versioncmp != 0} {
+        return $versioncmp
     }
     set ar_ [lindex $avr_ 1]
     set br_ [lindex $bvr_ 1]
@@ -453,6 +518,43 @@
     return [lsort -command portlist_compareint $list]
 }
 
+# sort portlist so dependents come before their dependencies
+proc portlist_sortdependents { portlist } {
+    foreach p $portlist {
+        array set pvals $p
+        lappend entries($pvals(name)) $p
+        if {![info exists dependents($pvals(name))]} {
+            set dependents($pvals(name)) {}
+            foreach result [registry::list_dependents $pvals(name)] {
+                lappend dependents($pvals(name)) [lindex $result 2]
+            }
+        }
+        array unset pvals
+    }
+    set ret {}
+    foreach p $portlist {
+        portlist_sortdependents_helper $p entries dependents seen ret
+    }
+    return $ret
+}
+
+proc portlist_sortdependents_helper {p up_entries up_dependents up_seen up_retlist} {
+    upvar $up_seen seen
+    if {![info exists seen($p)]} {
+        set seen($p) 1
+        upvar $up_entries entries $up_dependents dependents $up_retlist retlist
+        array set pvals $p
+        foreach dependent $dependents($pvals(name)) {
+            if {[info exists entries($dependent)]} {
+                foreach entry $entries($dependent) {
+                    portlist_sortdependents_helper $entry entries dependents seen retlist
+                }
+            }
+        }
+        lappend retlist $p
+    }
+}
+
 proc regex_pat_sanitize { s } {
     set sanitized [regsub -all {[\\(){}+$.^]} $s {\\&}]
     return $sanitized
@@ -589,30 +691,35 @@
 ##########################################
 # Port selection
 ##########################################
+proc unique_results_to_portlist {infos} {
+    set result {}
+    array unset unique
+    foreach {name info} $infos {
+        array unset portinfo
+        array set portinfo $info
+        
+        set portentry [entry_for_portlist [list url $portinfo(porturl) name $name]]
+        
+        array unset entry
+        array set entry $portentry
+        
+        if {[info exists unique($entry(fullname))]} continue
+        set unique($entry(fullname)) 1
+        
+        lappend result $portentry
+    }
+    return $result
+}
+
+
 proc get_matching_ports {pattern {casesensitive no} {matchstyle glob} {field name}} {
     if {[catch {set res [mportsearch $pattern $casesensitive $matchstyle $field]} result]} {
         global errorInfo
         ui_debug "$errorInfo"
         fatal "search for portname $pattern failed: $result"
     }
-
-    set results {}
-    foreach {name info} $res {
-        array unset portinfo
-        array set portinfo $info
-
-        #set variants {}
-        #if {[info exists portinfo(variants)]} {
-        #   foreach variant $portinfo(variants) {
-        #       lappend variants $variant "+"
-        #   }
-        #}
-        # For now, don't include version or variants with all ports list
-        #"$portinfo(version)_$portinfo(revision)"
-        #$variants
-        add_to_portlist results [list url $portinfo(porturl) name $name]
-    }
-
+    set results [unique_results_to_portlist $res]
+    
     # Return the list of all ports, sorted
     return [portlist_sort $results]
 }
@@ -627,13 +734,7 @@
             ui_debug "$errorInfo"
             fatal "listing all ports failed: $result"
         }
-        set results {}
-        foreach {name info} $res {
-            array unset portinfo
-            array set portinfo $info
-            add_to_portlist results [list url $portinfo(porturl) name $name]
-        }
-
+        set results [unique_results_to_portlist $res]
         set all_ports_cache [portlist_sort $results]
     }
     return $all_ports_cache
@@ -706,11 +807,36 @@
     return [get_installed_ports no no]
 }
 
+proc get_actinact_ports {} {
+    set inactive_ports [get_inactive_ports]
+    set active_ports [get_active_ports]
+    set results {}
 
+    foreach port $inactive_ports {
+        array set portspec $port
+        set portname $portspec(name)
+        lappend inact($portname) $port
+    }
+
+    foreach port $active_ports {
+        array set portspec $port
+        set portname $portspec(name)
+
+        if {[info exists inact($portname)]} {
+            if {![info exists added_inact($portname)]} {
+                foreach inact_spec $inact($portname) {
+                    lappend results $inact_spec
+                }
+                set added_inact($portname) 1
+            }
+            lappend results $port
+        }
+    }
+    return $results
+}
+
+
 proc get_outdated_ports {} {
-    global macports::registry.installtype
-    set is_image_mode [expr 0 == [string compare "image" ${macports::registry.installtype}]]
-
     # Get the list of installed ports
     set ilist {}
     if { [catch {set ilist [registry::installed]} result] } {
@@ -734,7 +860,7 @@
             set installed_variants  [lindex $i 3]
 
             set is_active           [lindex $i 4]
-            if { $is_active == 0 && $is_image_mode } continue
+            if {$is_active == 0} continue
 
             set installed_epoch     [lindex $i 5]
 
@@ -766,13 +892,16 @@
             }
 
             # Compare versions, first checking epoch, then version, then revision
-            set comp_result [expr $installed_epoch - $latest_epoch]
-            if { $comp_result == 0 } {
-                set comp_result [rpm-vercomp $installed_version $latest_version]
+            set comp_result 0
+            if {$installed_version != $latest_version} {
+                set comp_result [expr $installed_epoch - $latest_epoch]
                 if { $comp_result == 0 } {
-                    set comp_result [rpm-vercomp $installed_revision $latest_revision]
+                    set comp_result [vercmp $installed_version $latest_version]
                 }
             }
+            if { $comp_result == 0 } {
+                set comp_result [expr $installed_revision - $latest_revision]
+            }
             if {$comp_result == 0} {
                 set regref [registry::open_entry $portname $installed_version $installed_revision $installed_variants $installed_epoch]
                 set os_platform_installed [registry::property_retrieve $regref os_platform]
@@ -926,7 +1055,7 @@
     set porturl $portinfo(porturl)
 
     # open portfile
-    if {[catch {set mport [mportopen $porturl {} [array get global_variations]]} result]} {
+    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"
     }
@@ -972,7 +1101,7 @@
                     set porturl $portinfo(porturl)
                 
                     # open its portfile
-                    if {[catch {set mport [mportopen $porturl {} [array get global_variations]]} result]} {
+                    if {[catch {set mport [mportopen $porturl [list subport $portinfo(name)] [array get global_variations]]} result]} {
                         ui_debug "$::errorInfo"
                         ui_error "Unable to open port: $result"
                         continue
@@ -1043,7 +1172,7 @@
             set reslist [opUnion $reslist $blist]
         }
     }
-
+    
     return $result
 }
 
@@ -1156,6 +1285,7 @@
         ^uninstalled(@.*)?$ -
         ^active(@.*)?$      -
         ^inactive(@.*)?$    -
+        ^actinact(@.*)?$    -
         ^leaves(@.*)?$      -
         ^outdated(@.*)?$    -
         ^obsolete(@.*)?$    -
@@ -1193,6 +1323,7 @@
         ^depends_run:       -
         ^depends_extract:   -
         ^depends_fetch:     -
+        ^replaced_by:       -
         ^revision:          -
         ^license:           { # Handle special port selectors
             advance
@@ -1264,11 +1395,11 @@
                   requested_variants [array get requested_variants] \
                   variants [array get requested_variants] \
                   options [array get options]]
+                set el 1
             } else {
                 ui_error "Can't open URL '$token' as a port"
                 set el 0
             }
-            set el 1
         }
 
         default             { # Treat anything else as a portspec (portname, version, variants, options
@@ -1310,31 +1441,28 @@
 }
 
 
-proc opUnion { a b } {
+proc unique_entries { entries } {
+    # Form the list of all the unique elements in the list a,
+    # considering only the port fullname, and taking the first
+    # found element first
     set result {}
-    
-    array unset onetime
-    
-    # Walk through each array, adding to result only those items that haven't
-    # been added before
-    foreach item $a {
+    array unset unique
+    foreach item $entries {
         array set port $item
-        if {[info exists onetime($port(fullname))]} continue
-        set onetime($port(fullname)) 1
+        if {[info exists unique($port(fullname))]} continue
+        set unique($port(fullname)) 1
         lappend result $item
     }
-
-    foreach item $b {
-        array set port $item
-        if {[info exists onetime($port(fullname))]} continue
-        set onetime($port(fullname)) 1
-        lappend result $item
-    }
-    
     return $result
 }
 
 
+proc opUnion { a b } {
+    # Return the unique elements in the combined two lists
+    return [unique_entries [concat $a $b]]
+}
+
+
 proc opIntersection { a b } {
     set result {}
     
@@ -1347,19 +1475,19 @@
     #   a/1.0, a/2.0    ==>
     #
     #   If there's an exact match, we take it.
-    #   If there's a match between simple and descriminated, we take the later.
+    #   If there's a match between simple and discriminated, we take the later.
     
-    # First create a list of the fully descriminated names in b
+    # First create a list of the fully discriminated names in b
     array unset bfull
     set i 0
-    foreach bitem $b {
+    foreach bitem [unique_entries $b] {
         array set port $bitem
         set bfull($port(fullname)) $i
         incr i
     }
     
     # Walk through each item in a, matching against b
-    foreach aitem $a {
+    foreach aitem [unique_entries $a] {
         array set port $aitem
         
         # Quote the fullname and portname to avoid special characters messing up the regexp
@@ -1393,7 +1521,7 @@
     
     # Return all elements of a not matching elements in b
     
-    # First create a list of the fully descriminated names in b
+    # First create a list of the fully discriminated names in b
     array unset bfull
     set i 0
     foreach bitem $b {
@@ -1403,10 +1531,6 @@
     }
     
     # Walk through each item in a, taking all those items that don't match b
-    #
-    # Note: -regexp may not be present in all versions of Tcl we need to work
-    #       against, in which case we may have to fall back to a slower alternative
-    #       for those cases. I'm not worrying about that for now, however. -jdb
     foreach aitem $a {
         array set port $aitem
         
@@ -1718,7 +1842,7 @@
             array set portinfo [lindex $result 1]
         }
         set portpath [macports::getportdir $porturl]
-        set logfile [file join [macports::getportlogpath $portpath] "main.log"]
+        set logfile [file join [macports::getportlogpath $portpath $portname] "main.log"]
         if {[file exists $logfile]} {
             if {[catch {set fp [open $logfile r]} result]} {
                 break_softcontinue "Could not open file $logfile: $result" 1 status
@@ -1767,10 +1891,15 @@
 
     set separator ""
     foreachport $portlist {
+        set index_only 0
+        if {[info exists options(ports_info_index)] && $options(ports_info_index)} {
+            set index_only 1
+        }
         puts -nonewline $separator
+        array unset portinfo
         # If we have a url, use that, since it's most specific
         # otherwise try to map the portname to a url
-        if {$porturl eq ""} {
+        if {$porturl == "" || $index_only} {
         # Verify the portname, getting portinfo to map to a porturl
             if {[catch {mportlookup $portname} result]} {
                 ui_debug "$::errorInfo"
@@ -1779,31 +1908,12 @@
             if {[llength $result] < 2} {
                 break_softcontinue "Port $portname not found" 1 status
             }
-            array unset portinfo
             array set portinfo [lindex $result 1]
             set porturl $portinfo(porturl)
             set portdir $portinfo(portdir)
-        } 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
-            # portdir.
-            set portdir [file split [macports::getportdir $porturl]]
-            set lsize [llength $portdir]
-            set portdir \
-                [file join [lindex $portdir [expr $lsize - 2]] \
-                           [lindex $portdir [expr $lsize - 1]]]
-            if {[catch {mportsearch $portdir no exact portdir} result]} {
-                ui_debug "$::errorInfo"
-                break_softcontinue "Portdir $portdir not found" 1 status
-            }
-            if {[llength $result] < 2} {
-                break_softcontinue "Portdir $portdir not found" 1 status
-            }
-            array unset portinfo
-            array set portinfo [lindex $result 1]
         }
 
-        if {!([info exists options(ports_info_index)] && $options(ports_info_index) eq "yes")} {
+        if {!$index_only} {
             # Add any global_variations to the variations
             # specified for the port (so we get e.g. dependencies right)
             array unset merged_variations
@@ -1813,11 +1923,19 @@
                     set merged_variations($variation) $value 
                 } 
             }
+            if {![info exists options(subport)]} {
+                if {[info exists portinfo(name)]} {
+                    set options(subport) $portinfo(name)
+                } else {
+                    set options(subport) $portname
+                }
+            }
  
             if {[catch {set mport [mportopen $porturl [array get options] [array get merged_variations]]} result]} {
                 ui_debug "$::errorInfo"
                 break_softcontinue "Unable to open port: $result" 1 status
             }
+            unset options(subport)
             array unset portinfo
             array set portinfo [mportinfo $mport]
             mportclose $mport
@@ -1825,7 +1943,7 @@
                 set portinfo(portdir) $portdir
             }
         } elseif {![info exists portinfo]} {
-            ui_warn "port info --index does not work with 'current' pseudo-port"
+            ui_warn "no PortIndex entry found for $portname"
             continue
         }
         array unset options ports_info_index
@@ -1844,6 +1962,7 @@
             platforms       1
             variants        1
             conflicts       1
+            subports        1
         "
 
         # Label map for pretty printing
@@ -1864,6 +1983,7 @@
             license     License
             conflicts   "Conflicts with"
             replaced_by "Replaced by"
+            subports    "Sub-ports"
         }
 
         # Wrap-length map for pretty printing
@@ -1883,6 +2003,7 @@
             license 22
             conflicts 22
             maintainers 22
+            subports 22
         }
 
         # Interpret a convenient field abbreviation
@@ -1902,7 +2023,7 @@
         set pretty_print 0
         
         # For human-readable summary, which is the default with no options
-        if {![array size options]} {
+        if {[llength [array get options ports_info_*]] == 0} {
             set pretty_print 1
         } elseif {[info exists options(ports_info_pretty)]} {
             set pretty_print 1
@@ -1912,6 +2033,7 @@
         # Tune for sort(1)
         if {[info exists options(ports_info_line)]} {
             array unset options ports_info_line
+            set noseparator 1
             set show_label 0
             set field_sep "\t"
             set subfield_sep ","
@@ -1935,6 +2057,7 @@
         if {![llength $opts_todo]} {
             set opts_todo {ports_info_heading
                 ports_info_replaced_by
+                ports_info_subports
                 ports_info_variants 
                 ports_info_skip_line
                 ports_info_long_description ports_info_homepage 
@@ -2021,7 +2144,7 @@
                             array unset variant
                             array set variant $vinfo($v)
                             if {[info exists variant(is_default)]} {
-                                set varmodifier "\[+]"
+                                set varmodifier "\[$variant(is_default)]"
                             }
                         }
                         lappend inf "$varmodifier$v"
@@ -2085,7 +2208,9 @@
                 puts [join $fields_tried ", "]
             }
         }
-        set separator "--\n"
+        if {![info exists noseparator]} {
+            set separator "--\n"
+        }
     }
     
     return $status
@@ -2112,13 +2237,9 @@
         }
 
         set ref [registry::open_entry $portname $version $revision $variants $epoch]
-        if { [string equal [registry::property_retrieve $ref installtype] "image"] } {
-            set imagedir [registry::property_retrieve $ref imagedir]
-            ui_notice "Port $portname ${version}_${revision}${variants} is installed as an image in:"
-            puts $imagedir
-        } else {
-            break_softcontinue "Port $portname is not installed as an image." 1 status
-        }
+        set imagedir [registry::property_retrieve $ref location]
+        ui_notice "Port $portname ${version}_${revision}${variants} is installed as an image in:"
+        puts $imagedir
     }
     
     return $status
@@ -2132,6 +2253,7 @@
 
     set status 0
     foreachport $portlist {
+        array unset portinfo
         if {$porturl eq ""} {
             # Look up the port.
             if {[catch {mportlookup $portname} result]} {
@@ -2144,7 +2266,6 @@
             }
 
             # Retrieve the port's URL.
-            array unset portinfo
             array set portinfo [lindex $result 1]
             set porturl $portinfo(porturl)
         }
@@ -2158,6 +2279,13 @@
                 set merged_variations($variation) $value 
             } 
         }
+        if {![info exists options(subport)]} {
+            if {[info exists portinfo(name)]} {
+                set options(subport) $portinfo(name)
+            } else {
+                set options(subport) $portname
+            }
+        }
 
         # Open the Portfile associated with this port.
         if {[catch {set mport [mportopen $porturl [array get options] \
@@ -2227,15 +2355,13 @@
 
 
 proc action_activate { action portlist opts } {
-    global macports::registry.format
     set status 0
     if {[require_portlist portlist] || [prefix_unwritable]} {
         return 1
     }
     foreachport $portlist {
         set composite_version [composite_version $portversion [array get variations]]
-        if {${macports::registry.format} == "receipt_sqlite"
-            && ![info exists options(ports_activate_no-exec)]
+        if {![info exists options(ports_activate_no-exec)]
             && ![catch {set ilist [registry::installed $portname $composite_version]}]
             && [llength $ilist] == 1} {
 
@@ -2246,7 +2372,7 @@
             }
         }
         if {![macports::global_option_isset ports_dryrun]} {
-            if { [catch {portimage::activate $portname $composite_version [array get options]} result] } {
+            if { [catch {portimage::activate_composite $portname $composite_version [array get options]} result] } {
                 global errorInfo
                 ui_debug "$errorInfo"
                 break_softcontinue "port activate failed: $result" 1 status
@@ -2261,15 +2387,14 @@
 
 
 proc action_deactivate { action portlist opts } {
-    global macports::registry.format
     set status 0
     if {[require_portlist portlist] || [prefix_unwritable]} {
         return 1
     }
+    set portlist [portlist_sortdependents $portlist]
     foreachport $portlist {
         set composite_version [composite_version $portversion [array get variations]]
-        if {${macports::registry.format} == "receipt_sqlite"
-            && ![info exists options(ports_deactivate_no-exec)]
+        if {![info exists options(ports_deactivate_no-exec)]
             && ![catch {set ilist [registry::active $portname]}]} {
 
             set i [lindex $ilist 0]
@@ -2284,7 +2409,7 @@
             }
         }
         if {![macports::global_option_isset ports_dryrun]} {
-            if { [catch {portimage::deactivate $portname $composite_version [array get options]} result] } {
+            if { [catch {portimage::deactivate_composite $portname $composite_version [array get options]} result] } {
                 global errorInfo
                 ui_debug "$errorInfo"
                 break_softcontinue "port deactivate failed: $result" 1 status
@@ -2308,7 +2433,9 @@
     }
     set group [lindex $portlist 0]
 
-    set commands [array names [array set {} $opts]]
+    array set opts_array $opts
+    set commands [array names opts_array ports_select_*]
+    array unset opts_array
     # If no command (--set, --show, --list) is specified *but* more than one
     # argument is specified, default to the set command.
     if {[llength $commands] < 1 && [llength $portlist] > 1} {
@@ -2422,7 +2549,6 @@
 
 
 proc action_setrequested { action portlist opts } {
-    global macports::registry.format
     set status 0
     if {[require_portlist portlist] || [prefix_unwritable]} {
         return 1
@@ -2436,9 +2562,6 @@
             foreach i $ilist {
                 set regref [registry::open_entry $portname [lindex $i 1] [lindex $i 2] [lindex $i 3] [lindex $i 5]]
                 registry::property_store $regref requested $val
-                if {${macports::registry.format} != "receipt_sqlite"} {
-                    registry::write_entry $regref
-                }
             }
         } else {
             global errorInfo
@@ -2452,16 +2575,18 @@
 
 
 proc action_upgrade { action portlist opts } {
-    if {[require_portlist portlist] || [prefix_unwritable]} {
+    if {[require_portlist portlist] || ([prefix_unwritable] && ![macports::global_option_isset ports_dryrun])} {
         return 1
     }
+
     # shared depscache for all ports in the list
     array set depscache {}
     set status 0
     foreachport $portlist {
         if {![info exists depscache(port:$portname)]} {
             set status [macports::upgrade $portname "port:$portname" [array get requested_variations] [array get options] depscache]
-            if {$status != 0 && ![macports::ui_isset ports_processall]} {
+            # status 2 means the port was not found in the index
+            if {$status != 0 && $status != 2 && ![macports::ui_isset ports_processall]} {
                 break
             }
         }
@@ -2469,12 +2594,25 @@
     
     if {$status != 0} {
         print_tickets_url
+    } else {
+        array set options $opts
+        if {![info exists options(ports_upgrade_no-rev-upgrade)] && ${macports::revupgrade_autorun}} {
+            set status [action_revupgrade $action $portlist $opts]
+        }
     }
 
     return $status
 }
 
+proc action_revupgrade { action portlist opts } {
+    set status [macports::revupgrade $opts]
+    if {$status != 0} {
+        print_tickets_url
+    }
+    return $status
+}
 
+
 proc action_version { action portlist opts } {
     puts "Version: [macports::version]"
     return 0
@@ -2612,7 +2750,8 @@
         } else {
             set deptypes {depends_fetch depends_extract depends_build depends_lib depends_run}
         }
-        
+
+        array unset portinfo
         # If we have a url, use that, since it's most specific
         # otherwise try to map the portname to a url
         if {$porturl eq ""} {
@@ -2624,7 +2763,6 @@
             if {[llength $result] < 2} {
                 break_softcontinue "Port $portname not found" 1 status
             }
-            array unset portinfo
             array set portinfo [lindex $result 1]
             set porturl $portinfo(porturl)
         } elseif {$porturl ne "file://."} {
@@ -2643,7 +2781,6 @@
             if {[llength $result] < 2} {
                 break_softcontinue "Portdir $portdir not found" 1 status
             }
-            array unset portinfo
             array set portinfo [lindex $result 1]
         }
 
@@ -2657,6 +2794,13 @@
                     set merged_variations($variation) $value 
                 } 
             }
+            if {![info exists options(subport)]} {
+                if {[info exists portinfo(name)]} {
+                    set options(subport) $portinfo(name)
+                } else {
+                    set options(subport) $portname
+                }
+            }
             if {[catch {set mport [mportopen $porturl [array get options] [array get merged_variations]]} result]} {
                 ui_debug "$::errorInfo"
                 break_softcontinue "Unable to open port: $result" 1 status
@@ -2735,6 +2879,7 @@
                     array unset portinfo
                     array set portinfo [lindex $result 1]
                     set porturl $portinfo(porturl)
+                    set options(subport) $portinfo(name)
                     
                     # open the portfile if requested
                     if {!([info exists options(ports_${action}_index)] && $options(ports_${action}_index) eq "yes")} {
@@ -2814,7 +2959,6 @@
 
 
 proc action_uninstall { action portlist opts } {
-    global macports::registry.format
     set status 0
     if {[macports::global_option_isset port_uninstall_old]} {
         # if -u then uninstall all inactive ports
@@ -2830,14 +2974,15 @@
         return 1
     }
 
+    set portlist [portlist_sortdependents $portlist]
+
     foreachport $portlist {
         if {![registry::entry_exists_for_name $portname]} {
             ui_info "$portname is already uninstalled"
             continue
         }
         set composite_version [composite_version $portversion [array get variations]]
-        if {${macports::registry.format} == "receipt_sqlite"
-            && ![info exists options(ports_uninstall_no-exec)]
+        if {![info exists options(ports_uninstall_no-exec)]
             && ![catch {set ilist [registry::installed $portname $composite_version]}]
             && [llength $ilist] == 1} {
 
@@ -2849,7 +2994,7 @@
             }
         }
 
-        if { [catch {registry_uninstall::uninstall $portname $composite_version [array get options]} result] } {
+        if { [catch {registry_uninstall::uninstall_composite $portname $composite_version [array get options]} result] } {
             global errorInfo
             ui_debug "$errorInfo"
             break_softcontinue "port uninstall failed: $result" 1 status
@@ -2931,9 +3076,7 @@
 
 
 proc action_outdated { action portlist opts } {
-    global macports::registry.installtype private_options
-    set is_image_mode [expr 0 == [string compare "image" ${macports::registry.installtype}]]
-
+    global private_options
     set status 0
 
     # If port names were supplied, limit ourselves to those ports, else check all installed ports
@@ -2975,7 +3118,7 @@
             set installed_compound "${installed_version}_${installed_revision}"
 
             set is_active [lindex $i 4]
-            if { $is_active == 0 && $is_image_mode } {
+            if {$is_active == 0} {
                 continue
             }
             set installed_epoch [lindex $i 5]
@@ -3013,12 +3156,12 @@
             
             # Compare versions, first checking epoch, then version, then revision
             set epoch_comp_result [expr $installed_epoch - $latest_epoch]
-            set comp_result [rpm-vercomp $installed_version $latest_version]
+            set comp_result [vercmp $installed_version $latest_version]
             if { $comp_result == 0 } {
-                set comp_result [rpm-vercomp $installed_revision $latest_revision]
+                set comp_result [expr $installed_revision - $latest_revision]
             }
             set reason ""
-            if {$epoch_comp_result != 0} {
+            if {$epoch_comp_result != 0 && $installed_version != $latest_version} {
                 if {($comp_result >= 0 && $epoch_comp_result < 0) || ($comp_result <= 0 && $epoch_comp_result > 0)} {
                     set reason { (epoch $installed_epoch $relation $latest_epoch)}
                 }
@@ -3075,10 +3218,20 @@
 
 
 proc action_contents { action portlist opts } {
-    set status 0
+    global global_options
     if {[require_portlist portlist]} {
         return 1
     }
+    if {[info exists global_options(ports_contents_size)]} {
+        set units {}
+        if {[info exists global_options(ports_contents_units)]} {
+            set units [complete_size_units $global_options(ports_contents_units)]
+        }
+        set outstring {[format "%12s $file" [filesize $file $units]]}
+    } else {
+        set outstring {  $file}
+    }
+
     foreachport $portlist {
         if { ![catch {set ilist [registry::installed $portname]} result] } {
             # set portname again since the one we were passed may not have had the correct case
@@ -3089,7 +3242,7 @@
             if { [llength $files] > 0 } {
                 ui_notice "Port $portname contains:"
                 foreach file $files {
-                    puts "  $file"
+                    puts [subst $outstring]
                 }
             } else {
                 ui_notice "Port $portname does not contain any files or is not active."
@@ -3100,9 +3253,67 @@
     }
     registry::close_file_map
 
-    return $status
+    return 0
 }
 
+# expand abbreviations of size units
+proc complete_size_units {units} {
+    if {$units == "K" || $units == "Ki"} {
+        return "KiB"
+    } elseif {$units == "k"} {
+        return "kB"
+    } elseif {$units == "Mi"} {
+        return "MiB"
+    } elseif {$units == "M"} {
+        return "MB"
+    } elseif {$units == "Gi"} {
+        return "GiB"
+    } elseif {$units == "G"} {
+        return "GB"
+    } else {
+        return $units
+    }
+}
+
+# Show space used by the given ports' files
+proc action_space {action portlist opts} {
+    global global_options
+    require_portlist portlist
+
+    set units {}
+    if {[info exists global_options(ports_space_units)]} {
+        set units [complete_size_units $global_options(ports_space_units)]
+    }
+    set spaceall 0.0
+    foreachport $portlist {
+        set space 0.0
+        set files [registry::port_registered $portname]
+        if { $files != 0 } {
+            if { [llength $files] > 0 } {
+                foreach file $files {
+                    catch {
+                        set space [expr $space + [file size $file] ]
+                    }
+                }
+                set msg "[bytesize $space $units] $portname"
+                if { $portversion != {} } {
+                    append msg " @$portversion"
+                }
+                puts $msg
+                set spaceall [expr $space + $spaceall]
+            } else {
+                puts "Port $portname does not contain any file or is not active."
+            }
+        } else {
+            puts "Port $portname is not installed."
+        }
+    }
+    if {[llength $portlist] > 1} {
+        puts "[bytesize $spaceall $units] total"
+    }
+    return 0
+}
+
 proc action_variants { action portlist opts } {
     global global_variations
     set status 0
@@ -3110,6 +3321,7 @@
         return 1
     }
     foreachport $portlist {
+        array unset portinfo
         if {$porturl eq ""} {
             # look up port
             if {[catch {mportlookup $portname} result]} {
@@ -3121,7 +3333,6 @@
                 break_softcontinue "Port $portname not found" 1 status
             }
 
-            array unset portinfo
             array set portinfo [lindex $result 1]
 
             set porturl $portinfo(porturl)
@@ -3129,6 +3340,13 @@
         }
 
         if {!([info exists options(ports_variants_index)] && $options(ports_variants_index) eq "yes")} {
+            if {![info exists options(subport)]} {
+                if {[info exists portinfo(name)]} {
+                    set options(subport) $portinfo(name)
+                } else {
+                    set options(subport) $portname
+                }
+            }
             if {[catch {set mport [mportopen $porturl [array get options] [array get variations]]} result]} {
                 ui_debug "$::errorInfo"
                 break_softcontinue "Unable to open port: $result" 1 status
@@ -3164,6 +3382,7 @@
             ui_notice "$portname has the variants:"
             foreach v [lsort $portinfo(variants)] {
                 unset -nocomplain vconflicts vdescription vrequires
+                set varmodifier "   "
                 # Retrieve variants' information from the new format.
                 if {[info exists vinfo]} {
                     array unset variant
@@ -3185,9 +3404,7 @@
                         # selected by variants.conf, prefixed with (+)/(-)
                         set varmodifier "($global_variations($v))"
                     } elseif {[info exists variant(is_default)]} {
-                        set varmodifier "\[+]"
-                    } else {
-                        set varmodifier "   "
+                        set varmodifier "\[$variant(is_default)\]"
                     }
                     if {[info exists variant(requires)]} {
                         set vrequires $variant(requires)
@@ -3330,7 +3547,13 @@
             } else {
                 if {[info exists options(ports_search_line)]
                         && $options(ports_search_line) == "yes"} {
-                    puts "$portinfo(name)\t$portinfo(version)\t$portinfo(categories)\t$portinfo(description)"
+                    # check for ports without category, e.g. replaced_by stubs
+                    if {[info exists portinfo(categories)]} {
+                        puts "$portinfo(name)\t$portinfo(version)\t$portinfo(categories)\t$portinfo(description)"
+                    } else {
+                        # keep two consecutive tabs in order to provide consistent columns' content
+                        puts "$portinfo(name)\t$portinfo(version)\t\t$portinfo(description)"
+                    }
                 } else {
                     puts -nonewline $joiner
 
@@ -3406,12 +3629,16 @@
 
 
 proc action_echo { action portlist opts } {
+    global global_options
+
     # Simply echo back the port specs given to this command
     foreachport $portlist {
         if {![macports::ui_isset ports_quiet]} {
             set opts {}
             foreach { key value } [array get options] {
-                lappend opts "$key=$value"
+                if ![info exists global_options($key)] {
+                    lappend opts "$key=$value"
+                }
             }
 
             set composite_version [composite_version $portversion [array get variations] 1]
@@ -3442,6 +3669,7 @@
         return 1
     }
     foreachport $portlist {
+        array unset portinfo
         # If we have a url, use that, since it's most specific, otherwise try to map the portname to a url
         if {$porturl == ""} {
         
@@ -3476,7 +3704,7 @@
                     close $f
                 }
                 
-                ed - edit {
+                edit {
                     # Edit the port's portfile with the user's editor
                     
                     # Restore our entire environment from start time.
@@ -3491,12 +3719,11 @@
                     
                     # Find an editor to edit the portfile
                     set editor ""
-                    if {[info exists local_options(ports_edit_editor)]} {
-                        set editor [join $local_options(ports_edit_editor)]
-                    } elseif {[info exists local_options(ports_ed_editor)]} {
-                        set editor [join $local_options(ports_ed_editor)]
+                    set editor_var "ports_${action}_editor"
+                    if {[info exists local_options($editor_var)]} {
+                        set editor [join $local_options($editor_var)]
                     } else {
-                        foreach ed { VISUAL EDITOR } {
+                        foreach ed { MP_EDITOR VISUAL EDITOR } {
                             if {[info exists env($ed)]} {
                                 set editor $env($ed)
                                 break
@@ -3504,8 +3731,10 @@
                         }
                     }
                     
-                    # Invoke the editor, with a reasonable canned default.
+                    # Use a reasonable canned default if no editor specified or set in env
                     if { $editor == "" } { set editor "/usr/bin/vi" }
+                    
+                    # Invoke the editor
                     if {[catch {eval exec >@stdout <@stdin 2>@stderr $editor {$portfile}} result]} {
                         global errorInfo
                         ui_debug "$errorInfo"
@@ -3527,7 +3756,7 @@
 
                 work {
                     # output the path to the port's work directory
-                    set workpath [macports::getportworkpath_from_portdir $portdir]
+                    set workpath [macports::getportworkpath_from_portdir $portdir $portname]
                     if {[file exists $workpath]} {
                         puts $workpath
                     }
@@ -3549,6 +3778,15 @@
                     puts $portfile
                 }
 
+                logfile {
+                    set logfile [file join [macports::getportlogpath $portdir $portname] "main.log"]
+                    if {[file isfile $logfile]} {
+                        puts $logfile
+                    } else {
+                        ui_error "Log file not found for port in $portdir"
+                    }
+                }
+
                 gohome {
                     set homepage ""
 
@@ -3608,10 +3846,11 @@
     if {[require_portlist portlist]} {
         return 1
     }
-    if {($action == "install" || $action == "archive") && [prefix_unwritable]} {
+    if {($action == "install" || $action == "archive") && [prefix_unwritable] && ![macports::global_option_isset ports_dryrun]} {
         return 1
     }
     foreachport $portlist {
+        array unset portinfo
         # If we have a url, use that, since it's most specific
         # otherwise try to map the portname to a url
         if {$porturl == ""} {
@@ -3630,7 +3869,6 @@
                     break_softcontinue "Port $portname not found" 1 status
                 }
             }
-            array unset portinfo
             array set portinfo [lindex $res 1]
             set porturl $portinfo(porturl)
         }
@@ -3659,9 +3897,18 @@
             set options(ports_requested) 1
             # we actually activate as well
             set target activate
+        } elseif {$action == "archive"} {
+            set target install
         } else {
             set target $action
         }
+        if {![info exists options(subport)]} {
+            if {[info exists portinfo(name)]} {
+                set options(subport) $portinfo(name)
+            } else {
+                set options(subport) $portname
+            }
+        }
         if {[catch {set workername [mportopen $porturl [array get options] [array get requested_variations]]} result]} {
             global errorInfo
             ui_debug "$errorInfo"
@@ -3678,12 +3925,16 @@
         
         # Process any error that wasn't thrown and handled already
         if {$result} {
-            break_softcontinue "Status $result encountered during processing." 1 status
+            print_tickets_url
+            break_softcontinue "Processing of port $portname failed" 1 status
         }
     }
     
-    if {$status != 0} {
-        print_tickets_url
+    if {$status == 0 && $action == "install"} {
+        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]
+        }
     }
     
     return $status
@@ -3767,6 +4018,7 @@
     unsetrequested [list action_setrequested  [ACTION_ARGS_PORTS]] \
     \
     upgrade     [list action_upgrade        [ACTION_ARGS_PORTS]] \
+    rev-upgrade [list action_revupgrade     [ACTION_ARGS_NONE]] \
     \
     version     [list action_version        [ACTION_ARGS_NONE]] \
     platform    [list action_platform       [ACTION_ARGS_NONE]] \
@@ -3776,6 +4028,7 @@
     installed   [list action_installed      [ACTION_ARGS_PORTS]] \
     outdated    [list action_outdated       [ACTION_ARGS_PORTS]] \
     contents    [list action_contents       [ACTION_ARGS_PORTS]] \
+    space       [list action_space          [ACTION_ARGS_PORTS]] \
     dependents  [list action_dependents     [ACTION_ARGS_PORTS]] \
     rdependents [list action_dependents     [ACTION_ARGS_PORTS]] \
     deps        [list action_deps           [ACTION_ARGS_PORTS]] \
@@ -3785,7 +4038,6 @@
     search      [list action_search         [ACTION_ARGS_STRINGS]] \
     list        [list action_list           [ACTION_ARGS_PORTS]] \
     \
-    ed          [list action_portcmds       [ACTION_ARGS_PORTS]] \
     edit        [list action_portcmds       [ACTION_ARGS_PORTS]] \
     cat         [list action_portcmds       [ACTION_ARGS_PORTS]] \
     dir         [list action_portcmds       [ACTION_ARGS_PORTS]] \
@@ -3793,6 +4045,7 @@
     cd          [list action_portcmds       [ACTION_ARGS_PORTS]] \
     url         [list action_portcmds       [ACTION_ARGS_PORTS]] \
     file        [list action_portcmds       [ACTION_ARGS_PORTS]] \
+    logfile     [list action_portcmds       [ACTION_ARGS_PORTS]] \
     gohome      [list action_portcmds       [ACTION_ARGS_PORTS]] \
     \
     fetch       [list action_target         [ACTION_ARGS_PORTS]] \
@@ -3814,8 +4067,8 @@
     unload      [list action_target         [ACTION_ARGS_PORTS]] \
     distfiles   [list action_target         [ACTION_ARGS_PORTS]] \
     \
+    archivefetch [list action_target         [ACTION_ARGS_PORTS]] \
     archive     [list action_target         [ACTION_ARGS_PORTS]] \
-    archivefetch [list action_target         [ACTION_ARGS_PORTS]] \
     unarchive   [list action_target         [ACTION_ARGS_PORTS]] \
     dmg         [list action_target         [ACTION_ARGS_PORTS]] \
     mdmg        [list action_target         [ACTION_ARGS_PORTS]] \
@@ -3830,17 +4083,51 @@
     exit        [list action_exit           [ACTION_ARGS_NONE]] \
 ]
 
+# Expand "action".
+# Returns an action proc, or a list of matching action procs, or the action passed in
+proc find_action { action } {
+    global action_array
+    
+    if { ! [info exists action_array($action)] } {
+        set guess [guess_action $action]
+        if { [info exists action_array($guess)] } {
+            return $guess
+        }
+        return $guess
+    }
+    
+    return $action
+}
+
+# Expand action
+# If there's more than one match, return the next possibility
 proc find_action_proc { action } {
     global action_array
     
     set action_proc ""
     if { [info exists action_array($action)] } {
         set action_proc [lindex $action_array($action) 0]
+    } else {
+        set action [complete_action $action]
+        if { [info exists action_array($action)] } {
+            set action_proc [lindex $action_array($action) 0]
+        }
     }
     
     return $action_proc
 }
 
+proc get_action_proc { action } {
+    global action_array
+    
+    set action_proc ""
+    if { [info exists action_array($action)] } {
+        set action_proc [lindex $action_array($action) 0]
+    }
+    
+    return $action_proc
+}
+
 # Returns whether an action expects text arguments at all,
 # expects text arguments or wants an expanded list of ports
 # Return values are constants:
@@ -3866,13 +4153,13 @@
 global cmd_opts_array
 array set cmd_opts_array {
     edit        {{editor 1}}
-    ed          {{editor 1}}
     info        {category categories depends_fetch depends_extract
                  depends_build depends_lib depends_run
                  depends description epoch fullname heading homepage index license
                  line long_description
                  maintainer maintainers name platform platforms portdir pretty
-                 replaced_by revision variant variants version}
+                 replaced_by revision subports variant variants version}
+    contents    {size {units 1}}
     deps        {index no-build}
     rdeps       {index no-build full}
     rdependents {full}
@@ -3882,22 +4169,25 @@
                  long_description maintainer maintainers name platform
                  platforms portdir regex revision variant variants version}
     selfupdate  {nosync}
+    space       {{units 1}}
     activate    {no-exec}
     deactivate  {no-exec}
+    install     {no-rev-upgrade}
     uninstall   {follow-dependents follow-dependencies no-exec}
     variants    {index}
-    clean       {all archive dist work logs}
+    clean       {all dist work logs}
     mirror      {new}
     lint        {nitpick}
     select      {list set show}
     log         {{phase 1} {level 1}}
-    upgrade     {force enforce-variants no-replace}
+    upgrade     {force enforce-variants no-replace no-rev-upgrade}
+    rev-upgrade {id-loadcmd-check}
 }
 
 ##
 # Checks whether the given option is valid
 #
-# œparam action for which action
+# @param action for which action
 # @param option the prefix of the option to check
 # @return list of pairs {name argc} for all matching options
 proc cmd_option_matches {action option} {
@@ -3966,7 +4256,7 @@
                         foreach e $kopts {
                             lappend errlst "--[lindex $e 0]"
                         }
-                        return -code error "${action} --${key} is ambiguous: \n  [join $errlst "\n  "]"
+                        return -code error "\"port ${action} --${key}\" is ambiguous: \n  port ${action} [join $errlst "\n  port ${action} "]"
                     }
                     set key   [lindex [lindex $kopts 0] 0]
                     set kargc [lindex [lindex $kopts 0] 1]
@@ -4001,8 +4291,6 @@
                     }
                     q {
                         set ui_options(ports_quiet) yes
-                        set ui_options(ports_verbose) no
-                        set ui_options(ports_debug) no
                     }
                     p {
                         # Ignore errors while processing within a command
@@ -4119,9 +4407,16 @@
         array set global_options $global_options_base
         
         # Find an action to execute
-        set action_proc [find_action_proc $action]
-        if { $action_proc == "" } {
-            puts "Unrecognized action \"$action\""
+        set actions [find_action $action]
+        if {[llength $actions] == 1} {
+            set action [lindex $actions 0]
+            set action_proc [get_action_proc $action]
+        } else {
+            if {[llength $actions] > 1} {
+                ui_error "\"port ${action}\" is ambiguous: \n  port [join $actions "\n  port "]"
+            } else {
+                ui_error "Unrecognized action \"port $action\""
+            }
             set action_status 1
             break
         }
@@ -4211,6 +4506,7 @@
 }
 
 
+# return text action beginning with $text
 proc complete_action { text state } {   
     global action_array
     global complete_choices complete_position
@@ -4226,7 +4522,19 @@
     return $word
 }
 
+# return all actions beginning with $text
+proc guess_action { text } {   
+    global action_array
 
+    return [array names action_array "[string tolower $text]*"]
+
+    if { [llength $complete_choices ] == 1 } {
+        return [lindex $complete_choices 0]
+    }
+
+    return {}
+}
+
 proc attempt_completion { text word start end } {
     # If the word starts with '~', or contains '.' or '/', then use the build-in
     # completion to complete the word
@@ -4432,6 +4740,9 @@
 # interactive mode
 if { [llength $remaining_args] == 0 && ![info exists ui_options(ports_commandfiles)] } {
     lappend ui_options(ports_commandfiles) -
+} elseif {[lookahead] == "selfupdate" || [lookahead] == "sync"} {
+    # tell mportinit not to tell the user they should selfupdate
+    set ui_options(ports_no_old_index_warning) 1
 }
 
 # Initialize mport
@@ -4465,6 +4776,9 @@
 if { ($exit_status == 0 || [macports::ui_isset ports_processall]) && [info exists ui_options(ports_commandfiles)] } {
     set exit_status [process_command_files $ui_options(ports_commandfiles)]
 }
+if {$exit_status == -999} {
+    set exit_status 0
+}
 
 # shut down macports1.0
 mportshutdown

Modified: branches/new-help-system/base/src/port/portindex.tcl
===================================================================
--- branches/new-help-system/base/src/port/portindex.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port/portindex.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -7,8 +7,7 @@
 # if requested
 # $Id$
 
-catch {source \
-    [file join "@macports_tcl_dir@" macports1.0 macports_fastload.tcl]}
+source [file join "@macports_tcl_dir@" macports1.0 macports_fastload.tcl]
 package require macports
 package require Pextlib
 
@@ -61,6 +60,26 @@
                 puts -nonewline $fd $line
 
                 incr stats(skipped)
+
+                # also reuse the entries for its subports
+                array set portinfo $line
+                if {![info exists portinfo(subports)]} {
+                    return
+                }
+                foreach sub $portinfo(subports) {
+                    set offset $qindex([string tolower $sub])
+                    seek $oldfd $offset
+                    gets $oldfd line
+                    set name [lindex $line 0]
+                    set len [lindex $line 1]
+                    set line [read $oldfd $len]
+    
+                    puts $fd [list $name $len]
+                    puts -nonewline $fd $line
+    
+                    incr stats(skipped)
+                }
+
                 return
             }
         } catch {*} {
@@ -101,7 +120,8 @@
         }
 
         foreach availkey [array names portinfo] {
-            if {![info exists keepkeys($availkey)]} {
+            # store list of subports for top-level ports only
+            if {![info exists keepkeys($availkey)] && $availkey != "subports"} {
                 unset portinfo($availkey)
             }
         }
@@ -113,10 +133,39 @@
         if {$mtime > $newest} {
             set newest $mtime
         }
+        # now index this portfile's subports (if any)
+        if {![info exists portinfo(subports)]} {
+            return
+        }
+        foreach sub $portinfo(subports) {
+            incr stats(total)
+            set prefix {\${prefix}}
+            if {[catch {set interp [mportopen file://[file join $directory $portdir] [concat $port_options subport $sub]]} result]} {
+                puts stderr "Failed to parse file $portdir/Portfile with subport '${sub}': $result"
+                set prefix $save_prefix
+                incr stats(failed)
+            } else {
+                set prefix $save_prefix
+                array unset portinfo
+                array set portinfo [mportinfo $interp]
+                mportclose $interp
+                set portinfo(portdir) $portdir
+                puts "Adding subport $sub"
+                foreach availkey [array names portinfo] {
+                    if {![info exists keepkeys($availkey)]} {
+                        unset portinfo($availkey)
+                    }
+                }
+                set output [array get portinfo]
+                set len [expr [string length $output] + 1]
+                puts $fd [list $portinfo(name) $len]
+                puts $fd $output
+            }
+        }
     }
 }
 
-if {[expr $argc > 4]} {
+if {[expr $argc > 8]} {
     print_usage
     exit 1
 }
@@ -211,7 +260,7 @@
 foreach key {categories depends_fetch depends_extract depends_build \
              depends_lib depends_run description epoch homepage \
              long_description maintainers name platforms revision variants \
-             version portdir portarchive replaced_by license} {
+             version portdir portarchive replaced_by license installs_libs} {
     set keepkeys($key) 1
 }
 mporttraverse pindex $directory

Modified: branches/new-help-system/base/src/port/portmirror.tcl
===================================================================
--- branches/new-help-system/base/src/port/portmirror.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port/portmirror.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,8 +11,7 @@
 # Updates the distfiles to current distfiles by deleting old stuff.
 # Uses the database.
 
-catch {source \
-    [file join "@macports_tcl_dir@" macports1.0 macports_fastload.tcl]}
+source [file join "@macports_tcl_dir@" macports1.0 macports_fastload.tcl]
 package require macports
 package require Pextlib
 

Modified: branches/new-help-system/base/src/port1.0/Makefile
===================================================================
--- branches/new-help-system/base/src/port1.0/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -32,4 +32,4 @@
 	$(INSTALL) -o ${DSTUSR} -g ${DSTGRP} -m 444 pkgIndex.tcl ${INSTALLDIR}
 
 test::
-	${TCLSH} tests/portutil.tcl
+	${TCLSH} tests/portutil.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-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/fetch_common.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
 # $Id$
 #
 # Copyright (c) 2002 - 2003 Apple Inc.
-# Copyright (c) 2004-2010 The MacPorts Project
+# Copyright (c) 2004 - 2011 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -241,13 +241,18 @@
         }
 
         foreach site $urllist {
+            if {[string range $site 0 6] == "file://"} {
+                set pingtimes(localhost) 0
+                continue
+            }
+            
             regexp $hostregex $site -> host
-
+            
             if { [info exists seen($host)] } {
                 continue
             }
             foreach fallback $fallback_mirror_list {
-                if {[string match [append fallback *] $site]} {
+                if {[string match ${fallback}* $site]} {
                     # don't bother pinging fallback mirrors
                     set seen($host) yes
                     # and make them sort to the very end of the list
@@ -256,25 +261,29 @@
                 }
             }
             if { ![info exists seen($host)] } {
-                if {[catch {set fds($host) [open "|ping -noq -c3 -t3 $host | grep round-trip | cut -d / -f 5"]}]} {
-                    ui_debug "Spawning ping for $host failed"
-                    # will end up after all hosts that were pinged OK but before those that didn't respond
-                    set pingtimes($host) 5000
-                } else {
-                    ui_debug "Pinging $host..."
-                    set seen($host) yes
-                    lappend hosts $host
+                # first check the persistent cache
+                set pingtimes($host) [get_pingtime $host]
+                if {$pingtimes($host) == {}} {
+                    if {[catch {set fds($host) [open "|ping -noq -c3 -t3 $host | grep round-trip | cut -d / -f 5"]}]} {
+                        ui_debug "Spawning ping for $host failed"
+                        # will end up after all hosts that were pinged OK but before those that didn't respond
+                        set pingtimes($host) 5000
+                    } else {
+                        set seen($host) yes
+                        lappend hosts $host
+                    }
                 }
             }
         }
 
         foreach host $hosts {
-            set len [gets $fds($host) pingtimes($host)]
+            gets $fds($host) pingtimes($host)
             if { [catch { close $fds($host) }] || ![string is double -strict $pingtimes($host)] } {
                 # ping failed, so put it last in the list (but before the fallback mirrors)
                 set pingtimes($host) 10000
             }
-            ui_debug "$host ping time is $pingtimes($host)"
+            # cache it
+            set_pingtime $host $pingtimes($host)
         }
 
         if {[info exists oldeuid]} {
@@ -284,8 +293,15 @@
 
         set pinglist {}
         foreach site $urllist {
-            regexp $hostregex $site -> host
-            lappend pinglist [ list $site $pingtimes($host) ]
+            if {[string range $site 0 6] == "file://"} {
+                set host localhost
+            } else {
+                regexp $hostregex $site -> host
+            }
+            # -1 means blacklisted
+            if {$pingtimes($host) != "-1"} {
+                lappend pinglist [ list $site $pingtimes($host) ]
+            }
         }
 
         set pinglist [ lsort -real -index 1 $pinglist ]

Modified: branches/new-help-system/base/src/port1.0/port.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/port.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/port.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
 # port.tcl
 # $Id$
 #
-# Copyright (c) 2002 Apple Computer, Inc.
+# Copyright (c) 2002 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +13,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 

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-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/port_autoconf.tcl.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,7 +1,8 @@
 # port_autoconf.tcl.in
 # $Id$
 #
-# Copyright (c) 2002 - 2004 Apple Computer, Inc.
+# Copyright (c) 2005 - 2011 The MacPorts Project
+# Copyright (c) 2002 - 2004 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -12,7 +13,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -32,6 +33,8 @@
 
 namespace eval portutil::autoconf {
 	variable bzip2_path "@BZIP2@"
+	variable lzma_path "@LZMA@"
+	variable xz_path "@XZ@"
 	variable cp_path "@CP@"
 	variable cpio_path "@CPIO@"
 	variable diff_path "@DIFF@"
@@ -59,11 +62,16 @@
 	variable mtree_path "@MTREE@"
 	variable pax_path "@PAX@"
 	variable xar_path "@XAR@"
+	variable xcode_select_path "@XCODE_SELECT@"
+	variable xcodebuild_path "@XCODEBUILD@"
+	variable xcrun_path "@XCRUN@"
 	variable sed_command "@SED@"
 	variable sed_ext_flag "@SED_EXT@"
 	variable tar_command "@TAR_CMD@"
 	variable tar_path "@TAR@"
+	variable tar_q "@TAR_Q@"
 	variable hdiutil_path "@HDIUTIL@"
+	variable swig_path "@SWIG@"
 	variable have_launchd "@HAVE_LAUNCHD@"
 	variable launchctl_path "@LAUNCHCTL@"
 	variable install_command "@INSTALL@"

Modified: branches/new-help-system/base/src/port1.0/portactivate.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portactivate.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portactivate.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,8 +2,9 @@
 # portactivate.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2005, 2007, 2009-2011 The MacPorts Project
 # Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #
@@ -40,11 +41,7 @@
 target_runtype ${org.macports.activate} always
 target_state ${org.macports.activate} no
 target_provides ${org.macports.activate} activate
-if {[option portarchivemode] == "yes"} {
-    target_requires ${org.macports.activate} main archivefetch unarchive fetch checksum extract patch configure build destroot archive install
-} else {
-    target_requires ${org.macports.activate} main fetch checksum extract patch configure build destroot install
-}
+target_requires ${org.macports.activate} main archivefetch fetch checksum extract patch configure build destroot install
 target_prerun ${org.macports.activate} portactivate::activate_start
 
 namespace eval portactivate {
@@ -54,24 +51,21 @@
 default activate.asroot no
 
 proc portactivate::activate_start {args} {
-    global prefix registry.installtype
-    if { (![file writable $prefix] || ([getuid] == 0 && [geteuid] != 0)) && ${registry.installtype} == "image"} {
+    global prefix
+    if {![file writable $prefix] || ([getuid] == 0 && [geteuid] != 0)} {
         # if install location is not writable, need root privileges
         elevateToRoot "activate"
     }
 }
 
 proc portactivate::activate_main {args} {
-    global env name version revision portvariants user_options PortInfo registry.installtype
+    global env subport version revision portvariants user_options PortInfo
 
-    # skip the actual activation in direct mode (we still want the notes and the pre/post procs)
-    if {${registry.installtype} == "image"} {
-        registry_activate $name "${version}_${revision}${portvariants}" [array get user_options]
-    }
+    registry_activate $subport $version $revision $portvariants [array get user_options]
 
     # Display notes at the end of the activation phase.
     if {[info exists PortInfo(notes)] && $PortInfo(notes) ne {}} {
-        ui_msg ""
+        ui_notice ""
         foreach note $PortInfo(notes) {
             # If env(COLUMNS) exists, limit each line's width to this width.
             if {[info exists env(COLUMNS)]} {
@@ -94,13 +88,13 @@
                     if {$newline ne {}} {
                         lappend lines $newline
                     }
-                    ui_msg [join $lines "\n"]
+                    ui_notice [join $lines "\n"]
                 }
             } else {
-                ui_msg $note
+                ui_notice $note
             }
         }
-        ui_msg ""
+        ui_notice ""
     }
 
     return 0

Modified: branches/new-help-system/base/src/port1.0/portbuild.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portbuild.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portbuild.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portbuild.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2007 - 2011 The MacPorts Project
+# Copyright (c) 2002 - 2004 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #
@@ -49,11 +50,11 @@
 commands build
 # defaults
 default build.asroot no
-default build.dir {${workpath}/${worksrcdir}}
+default build.dir {${worksrcpath}}
 default build.cmd {[portbuild::build_getmaketype]}
 default build.nice {${buildnicevalue}}
 default build.jobs {[portbuild::build_getjobs]}
-default build.pre_args {${build.target}}
+default build.pre_args {[portbuild::build_getargs]}
 default build.target "all"
 default use_parallel_build yes
 
@@ -122,6 +123,16 @@
     return $jobs
 }
 
+proc portbuild::build_getargs {args} {
+    if {((![exists build.type] && [option os.platform] != "freebsd") || ([exists build.type] && [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]"
+    }
+
+    return "[option build.target]"
+}
+
 proc portbuild::build_getjobsarg {args} {
     # check if port allows a parallel build
     global use_parallel_build
@@ -143,7 +154,7 @@
 proc portbuild::build_start {args} {
     global UI_PREFIX
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Building %s"] [option name]]"
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Building %s"] [option subport]]"
 }
 
 proc portbuild::build_main {args} {

Modified: branches/new-help-system/base/src/port1.0/portchecksum.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portchecksum.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portchecksum.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,8 +2,9 @@
 # portchecksum.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2004 Apple Computer, Inc.
+# Copyright (c) 2002 - 2004 Apple Inc.
 # Copyright (c) 2004 - 2005 Paul Guyot <pguyot at kallisys.net>
+# Copyright (c) 2006-2011 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #
@@ -58,7 +59,7 @@
 set checksum_types_count [llength $checksum_types]
 
 # types to recommend if none are specified in the portfile
-set default_checksum_types {sha1 rmd160}
+set default_checksum_types {rmd160 sha256}
 
 # Using global all_dist_files, parse the checksums and store them into the
 # global array checksums_array.
@@ -85,7 +86,7 @@
         && [expr $nb_checksum / 2] <= $checksum_types_count
         && [lsearch -exact $checksum_types [lindex $checksums_str 0]] >= 0} {
         # Convert to format #2
-        set checksums_str [linsert $checksums_str 0 $all_dist_files]
+        set checksums_str [linsert $checksums_str 0 [lindex $all_dist_files 0]]
         # We increased the size.
         incr nb_checksum
     }
@@ -191,7 +192,7 @@
 proc portchecksum::checksum_start {args} {
     global UI_PREFIX
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Verifying checksum(s) for %s"] [option name]]"
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Verifying checksum(s) for %s"] [option subport]]"
 }
 
 # checksum_main
@@ -220,6 +221,9 @@
     # Set the list of checksums as the option checksums.
     set checksums_str [option checksums]
 
+    # store the calculated checksums to avoid repeated calculations
+    set sums ""
+
     # if everything is fine with the syntax, keep on and check the checksum of
     # the distfiles.
     if {[parse_checksums $checksums_str] == "yes"} {
@@ -238,10 +242,20 @@
                 }
             }
 
+            if {[llength $all_dist_files] > 1} {
+                lappend sums $distfile
+            }
+
             # check that there is at least one checksum for the distfile.
             if {![info exists checksums_array($distfile)] || [llength $checksums_array($distfile)] < 1} {
                 ui_error "[format [msgcat::mc "No checksum set for %s"] $distfile]"
                 set fail yes
+
+                # no checksums specified; output the default set
+                foreach type $default_checksum_types {
+                    lappend sums [format "%-8s%s" $type [calc_$type $fullpath]]
+                }
+
             } else {
                 # retrieve the list of types/values from the array.
                 set portfile_checksums $checksums_array($distfile)
@@ -249,6 +263,7 @@
                 # iterate on this list to check the actual values.
                 foreach {type sum} $portfile_checksums {
                     set calculated_sum [calc_$type $fullpath]
+                    lappend sums [format "%-8s%s" $type $calculated_sum]
                     if {[string equal $sum $calculated_sum]} {
                         ui_debug "[format [msgcat::mc "Correct (%s) checksum for %s"] $type $distfile]"
                     } else {
@@ -277,28 +292,6 @@
     if {[tbool fail]} {
 
         # Show the desired checksum line for easy cut-paste
-        set sums ""
-        foreach distfile $all_dist_files {
-            if {[llength $all_dist_files] > 1} {
-                lappend sums $distfile
-            }
-
-            set fullpath [file join $distpath $distfile]
-            if {![file isfile $fullpath] && (!$usealtworkpath && [file isfile "${altprefix}${fullpath}"])} {
-                set fullpath "${altprefix}${fullpath}"
-            }
-            if {![info exists checksums_array($distfile)] || [llength $checksums_array($distfile)] < 1} {
-                # no checksums specified; output the default set
-                foreach type $default_checksum_types {
-                    lappend sums [format "%-8s%s" $type [calc_$type $fullpath]]
-                }
-            } else {
-                # output just the types that were already used
-                foreach {type sum} $checksums_array($distfile) {
-                    lappend sums [format "%-8s%s" $type [calc_$type $fullpath]]
-                }
-            }
-        }
         ui_info "The correct checksum line may be:"
         ui_info [format "%-20s%s" "checksums" [join $sums [format " \\\n%-20s" ""]]]
 
@@ -307,11 +300,11 @@
             # expected. Probably a helpful DNS server sent us to its search results page
             # instead of admitting that the server we asked for doesn't exist, or a mirror that
             # no longer has the file served its error page with a 200 response.
-            ui_msg "***"
-            ui_msg "The non-matching file appears to be HTML. See this page for possible reasons"
-            ui_msg "for the checksum mismatch:"
-            ui_msg "<http://trac.macports.org/wiki/MisbehavingServers>"
-            ui_msg "***"
+            ui_notice "***"
+            ui_notice "The non-matching file appears to be HTML. See this page for possible reasons"
+            ui_notice "for the checksum mismatch:"
+            ui_notice "<https://trac.macports.org/wiki/MisbehavingServers>"
+            ui_notice "***"
         }
 
         return -code error "[msgcat::mc "Unable to verify file checksums"]"

Modified: branches/new-help-system/base/src/port1.0/portclean.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portclean.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portclean.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,8 +2,9 @@
 # portclean.tcl
 # $Id$
 #
+# Copyright (c) 2005-2007, 2009-2011 The MacPorts Project
 # Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #
@@ -50,14 +51,18 @@
 set_ui_prefix
 
 proc portclean::clean_start {args} {
-    global UI_PREFIX
+    global UI_PREFIX prefix
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Cleaning %s"] [option name]]"
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Cleaning %s"] [option subport]]"
+
+    if {[getuid] == 0 && [geteuid] != 0} {
+        elevateToRoot "clean"
+    }
 }
 
 proc portclean::clean_main {args} {
     global UI_PREFIX
-    global ports_clean_dist ports_clean_work ports_clean_archive ports_clean_logs
+    global ports_clean_dist ports_clean_work ports_clean_logs
     global ports_clean_all keeplogs usealtworkpath
 
     if {$usealtworkpath} {
@@ -66,19 +71,13 @@
 
     if {[info exists ports_clean_all] && $ports_clean_all == "yes" || \
         [info exists ports_clean_dist] && $ports_clean_dist == "yes"} {
-        ui_info "$UI_PREFIX [format [msgcat::mc "Removing distfiles for %s"] [option name]]"
+        ui_info "$UI_PREFIX [format [msgcat::mc "Removing distfiles for %s"] [option subport]]"
         clean_dist
     }
-    if {([info exists ports_clean_all] && $ports_clean_all == "yes" || \
-        [info exists ports_clean_archive] && $ports_clean_archive == "yes")
-        && !$usealtworkpath} {
-        ui_info "$UI_PREFIX [format [msgcat::mc "Removing archives for %s"] [option name]]"
-        clean_archive
-    }
     if {[info exists ports_clean_all] && $ports_clean_all == "yes" || \
         [info exists ports_clean_work] && $ports_clean_work == "yes" || \
-        (!([info exists ports_clean_archive] && $ports_clean_archive == "yes"))} {
-         ui_info "$UI_PREFIX [format [msgcat::mc "Removing build directory for %s"] [option name]]"
+        !([info exists ports_clean_logs] && $ports_clean_logs == "yes")} {
+         ui_info "$UI_PREFIX [format [msgcat::mc "Removing work directory for %s"] [option subport]]"
          clean_work
     }
     if {(([info exists ports_clean_logs] && $ports_clean_logs == "yes") || ($keeplogs == "no"))
@@ -94,7 +93,7 @@
 # This is crude, but works.
 #
 proc portclean::clean_dist {args} {
-    global ports_force name distpath dist_subdir distfiles patchfiles usealtworkpath portdbpath altprefix
+    global name ports_force distpath dist_subdir distfiles patchfiles usealtworkpath portdbpath altprefix
 
     # remove known distfiles for sure (if they exist)
     set count 0
@@ -205,26 +204,29 @@
 }
 
 proc portclean::clean_work {args} {
-    global portbuildpath worksymlink usealtworkpath altprefix portpath
+    global portbuildpath subbuildpath worksymlink usealtworkpath altprefix portpath
 
-    if {[file isdirectory $portbuildpath]} {
-        ui_debug "Removing directory: ${portbuildpath}"
-        if {[catch {delete $portbuildpath} result]} {
+    if {[file isdirectory $subbuildpath]} {
+        ui_debug "Removing directory: ${subbuildpath}"
+        if {[catch {delete $subbuildpath} result]} {
             ui_debug "$::errorInfo"
             ui_error "$result"
         }
+        # silently fail if non-empty (other subports might be using portbuildpath)
+        catch {file delete $portbuildpath}
     } else {
-        ui_debug "No work directory found to remove at ${portbuildpath}"
+        ui_debug "No work directory found to remove at ${subbuildpath}"
     }
 
-    if {!$usealtworkpath && [file isdirectory ${altprefix}${portbuildpath}]} {
-        ui_debug "Removing directory: ${altprefix}${portbuildpath}"
-        if {[catch {delete ${altprefix}${portbuildpath}} result]} {
+    if {!$usealtworkpath && [file isdirectory ${altprefix}${subbuildpath}]} {
+        ui_debug "Removing directory: ${altprefix}${subbuildpath}"
+        if {[catch {delete ${altprefix}${subbuildpath}} result]} {
             ui_debug "$::errorInfo"
             ui_error "$result"
         }
+        catch {file delete ${altprefix}${portbuildpath}}
     } else {
-        ui_debug "No work directory found to remove at ${altprefix}${portbuildpath}"
+        ui_debug "No work directory found to remove at ${altprefix}${subbuildpath}"
     }
 
     # Clean symlink, if necessary
@@ -242,67 +244,18 @@
     return 0
 }
 proc portclean::clean_logs {args} {
-    global portpath portbuildpath worksymlink name portverbose keeplogs prefix
+    global portpath portbuildpath worksymlink portverbose keeplogs prefix subport
     set logpath [getportlogpath $portpath]
-  	if {[file isdirectory $logpath]} {
-        ui_debug "Removing directory: ${logpath}"
-        if {[catch {delete $logpath} result]} {
+    set subdir [file join $logpath $subport]
+  	if {[file isdirectory $subdir]} {
+        ui_debug "Removing directory: ${subdir}"
+        if {[catch {delete $subdir} result]} {
             ui_debug "$::errorInfo"
             ui_error "$result"
         }
+        catch {file delete $logpath}
     } else {
         ui_debug "No log directory found to remove at ${logpath}"
     }           	
     return 0
 }
-
-proc portclean::clean_archive {args} {
-    global workpath portarchivepath name version ports_version_glob
-
-    # Define archive destination directory, target filename, regex for archive name
-    if {$portarchivepath ne $workpath && $portarchivepath ne ""} {
-        set archivepath [file join $portarchivepath [option os.platform]_[option os.major]]
-        set regexstring "^$name-\[\\-_a-zA-Z0-9\\.\]+_\[0-9\]*\[+\\-_a-zA-Z0-9\]*\[\\.\].*\[\\.\]\[a-z2\]+\$"
-    }
-
-    if {[info exists ports_version_glob]} {
-        # Match all possible archive variants that match the version
-        # glob specified by the user for this OS.
-        set fileglob "$name-[option ports_version_glob]*.*.*"
-    } else {
-        # Match all possible archive variants for the current version on
-        # this OS. If you want to delete previous versions, use the
-        # version glob argument to clean.
-        #
-        # We do this because if we don't, then ports that match the
-        # first part of the name (e.g. trying to remove foo-* will
-        # pick up anything foo-bar-* as well, which is undesirable).
-        set fileglob "$name-$version*.*.*"
-    }
-
-    # Remove the archive files
-    set count 0
-    if {![catch {set archivelist [glob [file join $archivepath * $name $fileglob]]} result]} {
-        foreach path $archivelist {
-            set file [file tail $path]
-            # Make sure file is truly a port archive file, and not
-            # an accidental match with some other file that might exist.
-            if {[regexp $regexstring $file] && [file isfile $path]} {
-                ui_debug "Removing archive: $path"
-                if {[catch {delete $path} result]} {
-                    ui_debug "$::errorInfo"
-                    ui_error "$result"
-                }
-                incr count
-            }
-        }
-    }
-    if {$count > 0} {
-        ui_debug "$count archive(s) removed."
-    } else {
-        ui_debug "No archives found to remove at $archivepath"
-    }
-
-    return 0
-}
-

Modified: branches/new-help-system/base/src/port1.0/portconfigure.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portconfigure.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portconfigure.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,8 +2,9 @@
 # portconfigure.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2007 - 2011 The MacPorts Project
 # Copyright (c) 2007 Markus W. Weissmann <mww at macports.org>
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -170,7 +171,10 @@
 default configure.universal_ldflags     {[portconfigure::configure_get_universal_ldflags]}
 
 # Select a distinct compiler (C, C preprocessor, C++)
-options configure.ccache configure.distcc configure.pipe configure.cc configure.cxx configure.cpp configure.objc configure.f77 configure.f90 configure.fc configure.javac configure.compiler
+options configure.ccache configure.distcc configure.pipe configure.cc \
+        configure.cxx configure.cpp configure.objc configure.f77 \
+        configure.f90 configure.fc configure.javac configure.compiler \
+        compiler.blacklist compiler.whitelist compiler.fallback
 default configure.ccache        {${configureccache}}
 default configure.distcc        {${configuredistcc}}
 default configure.pipe          {${configurepipe}}
@@ -183,36 +187,59 @@
 default configure.fc            {[portconfigure::configure_get_compiler fc]}
 default configure.javac         {[portconfigure::configure_get_compiler javac]}
 default configure.compiler      {[portconfigure::configure_get_default_compiler]}
+default compiler.fallback       {[portconfigure::get_compiler_fallback]}
+default compiler.blacklist      {}
+default compiler.whitelist      {}
 
 set_ui_prefix
 
 proc portconfigure::configure_start {args} {
     global UI_PREFIX configure.compiler
     
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option name]]"
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Configuring %s"] [option subport]]"
 
     set name ""
     switch -exact ${configure.compiler} {
+        cc { set name "System cc" }
         gcc { set name "System gcc" }
         gcc-3.3 { set name "Mac OS X gcc 3.3" }
         gcc-4.0 { set name "Mac OS X gcc 4.0" }
         gcc-4.2 { set name "Mac OS X gcc 4.2" }
         llvm-gcc-4.2 { set name "Mac OS X llvm-gcc 4.2" }
         clang { set name "Mac OS X clang" }
-        apple-gcc-3.3 { set name "MacPorts Apple gcc 3.3" }
         apple-gcc-4.0 { set name "MacPorts Apple gcc 4.0" }
         apple-gcc-4.2 { set name "MacPorts Apple gcc 4.2" }
-        macports-gcc-3.3 { set name "MacPorts gcc 3.3" }
-        macports-gcc-3.4 { set name "MacPorts gcc 3.4" }
+        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-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" }
         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}} {
+        elevateToRoot "configure ccache"
+        if [catch {
+                file mkdir ${ccache_dir}
+                file attributes ${ccache_dir} -owner ${macportsuser} -permissions 0755
+                exec ccache -M ${ccache_size} >/dev/null
+            } result] {
+            ui_warn "ccache_dir ${ccache_dir} could not be initialized; disabling ccache: $result"
+            set configureccache no
+        }
+        dropPrivileges
+    }
 }
 
 # internal function to choose the default configure.build_arch and
@@ -275,13 +302,18 @@
 }
 
 proc portconfigure::configure_get_sdkroot {} {
-    global developer_dir macosx_deployment_target macosx_version os.arch os.platform
+    global developer_dir macosx_deployment_target macosx_version xcodeversion os.arch os.platform
     if {${os.platform} == "darwin" && ($macosx_deployment_target != $macosx_version
         || (${os.arch} == "powerpc" && $macosx_version == "10.4" && [variant_exists universal] && [variant_isset universal]))} {
+        if {[vercmp $xcodeversion 4.3] < 0} {
+            set sdks_dir "${developer_dir}/SDKs"
+        } else {
+            set sdks_dir "${developer_dir}/Platforms/MacOSX.platform/Developer/SDKs"
+        }
         if {$macosx_deployment_target == "10.4"} {
-            set sdk "${developer_dir}/SDKs/MacOSX10.4u.sdk"
+            set sdk "${sdks_dir}/MacOSX10.4u.sdk"
         } else {
-            set sdk "${developer_dir}/SDKs/MacOSX${macosx_deployment_target}.sdk"
+            set sdk "${sdks_dir}/MacOSX${macosx_deployment_target}.sdk"
         }
         if {[file exists $sdk]} {
             return $sdk
@@ -323,7 +355,8 @@
         llvm-gcc-4.2 -
         clang -
         apple-gcc-4.0 -
-        apple-gcc-4.2 {
+        apple-gcc-4.2 -
+        macports-clang {
             return yes
         }
         default {
@@ -332,75 +365,164 @@
     }
 }
 
+# check if a compiler comes from a port
+proc portconfigure::compiler_is_port {compiler} {
+    switch $compiler {
+        clang -
+        llvm-gcc-4.2 -
+        gcc-4.2 -
+        gcc-4.0 -
+        gcc-3.3 {return no}
+        default {return yes}
+    }
+}
+
+# maps compiler names to the port that provides them
+array set portconfigure::compiler_name_map {
+        apple-gcc-4.0           apple-gcc40
+        apple-gcc-4.2           apple-gcc42
+        macports-gcc-4.2        gcc42
+        macports-gcc-4.3        gcc43
+        macports-gcc-4.4        gcc44
+        macports-gcc-4.5        gcc45
+        macports-gcc-4.6        gcc46
+        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
+}
+
 # internal function to determine the default compiler
 proc portconfigure::configure_get_default_compiler {args} {
-    global macosx_deployment_target
-    switch -exact ${macosx_deployment_target} {
-        "10.4"      -
-        "10.5"      { return gcc-4.0 }
-        "10.6"      { return gcc-4.2 }
-        "10.7"      { return llvm-gcc-4.2 }
-        default     { return gcc }
+    global compiler.blacklist compiler.whitelist compiler.fallback
+    if {${compiler.whitelist} != {}} {
+        set search_list ${compiler.whitelist}
+    } else {
+        set search_list ${compiler.fallback}
     }
+    foreach compiler $search_list {
+        if {[lsearch -exact ${compiler.blacklist} $compiler] == -1} {
+            if {[file executable [configure_get_compiler cc $compiler]] 
+                || [compiler_is_port $compiler]} {
+                return $compiler
+            }
+        }
+    }
+    ui_warn "All compilers are either blacklisted or unavailable; using first fallback entry as last resort"
+    return [lindex ${compiler.fallback} 0]
 }
 
+# internal function to choose compiler fallback list based on platform
+proc portconfigure::get_compiler_fallback {} {
+    global xcodeversion macosx_deployment_target
+    if {$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}
+    } else {
+        return {gcc-4.0 gcc-3.3 apple-gcc-4.0}
+    }
+}
+
+# Find a developer tool
+proc portconfigure::find_developer_tool {name} {
+	global developer_dir
+
+    # first try /usr/bin since this doesn't move around
+    set toolpath "/usr/bin/${name}"
+    if {[file executable $toolpath]} {
+        return $toolpath
+    }
+
+	# Use xcode's xcrun to find the named tool.
+	if {![catch {exec [findBinary xcrun $portutil::autoconf::xcrun_path] -find ${name}} toolpath]} {
+		return ${toolpath}
+	}
+
+	# If xcrun failed to find the tool, return a path from
+	# the developer_dir.
+	# The tool may not be there, but we'll leave it up to
+	# the invoking code to figure out that it doesn't have
+	# a valid compiler
+	return "${developer_dir}/usr/bin/${name}"
+}
+
 # internal function to find correct compilers
-proc portconfigure::configure_get_compiler {type} {
-    global configure.compiler prefix developer_dir
+proc portconfigure::configure_get_compiler {type {compiler {}}} {
+    global configure.compiler prefix
     set ret ""
-    switch -exact ${configure.compiler} {
+    if {$compiler == {}} {
+        set compiler ${configure.compiler}
+    }
+    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 /usr/bin/gcc }
-                objc { set ret /usr/bin/gcc }
-                cxx  { set ret /usr/bin/g++ }
-                cpp  { set ret /usr/bin/cpp }
+                cc   { set ret [find_developer_tool gcc] }
+                objc { set ret [find_developer_tool gcc] }
+                cxx  { set ret [find_developer_tool g++] }
+                cpp  { set ret [find_developer_tool cpp] }
             }
         }
         gcc-3.3 {
             switch -exact ${type} {
-                cc   { set ret /usr/bin/gcc-3.3 }
-                objc { set ret /usr/bin/gcc-3.3 }
-                cxx  { set ret /usr/bin/g++-3.3 }
-                cpp  { set ret /usr/bin/cpp-3.3 }
+                cc   { set ret [find_developer_tool gcc-3.3] }
+                objc { set ret [find_developer_tool gcc-3.3] }
+                cxx  { set ret [find_developer_tool g++-3.3] }
+                cpp  { set ret [find_developer_tool cpp-3.3] }
             }
         }
         gcc-4.0 {
             switch -exact ${type} {
-                cc   { set ret /usr/bin/gcc-4.0 }
-                objc { set ret /usr/bin/gcc-4.0 }
-                cxx  { set ret /usr/bin/g++-4.0 }
-                cpp  { set ret /usr/bin/cpp-4.0 }
+                cc   { set ret [find_developer_tool gcc-4.0] }
+                objc { set ret [find_developer_tool gcc-4.0] }
+                cxx  { set ret [find_developer_tool g++-4.0] }
+                cpp  { set ret [find_developer_tool cpp-4.0] }
             }
         }
         gcc-4.2 {
             switch -exact ${type} {
-                cc   { set ret /usr/bin/gcc-4.2 }
-                objc { set ret /usr/bin/gcc-4.2 }
-                cxx  { set ret /usr/bin/g++-4.2 }
-                cpp  { set ret /usr/bin/cpp-4.2 }
+                cc   { set ret [find_developer_tool gcc-4.2] }
+                objc { set ret [find_developer_tool gcc-4.2] }
+                cxx  { set ret [find_developer_tool g++-4.2] }
+                cpp  { set ret [find_developer_tool cpp-4.2] }
             }
         }
         llvm-gcc-4.2 {
             switch -exact ${type} {
-                cc   { set ret ${developer_dir}/usr/bin/llvm-gcc-4.2 }
-                objc { set ret ${developer_dir}/usr/bin/llvm-gcc-4.2 }
-                cxx  { set ret ${developer_dir}/usr/bin/llvm-g++-4.2 }
-                cpp  { set ret ${developer_dir}/usr/bin/llvm-cpp-4.2 }
+                cc   { set ret [find_developer_tool llvm-gcc-4.2] }
+                objc { set ret [find_developer_tool llvm-gcc-4.2] }
+                cxx  { set ret [find_developer_tool llvm-g++-4.2] }
+                cpp  { set ret [find_developer_tool llvm-cpp-4.2] }
             }
         }
         clang {
             switch -exact ${type} {
-                cc   { set ret ${developer_dir}/usr/bin/clang }
-                objc { set ret ${developer_dir}/usr/bin/clang }
+                cc   { set ret [find_developer_tool clang] }
+                objc { set ret [find_developer_tool clang] }
+                cxx  {
+					set clangpp [find_developer_tool clang++]
+                    if {[file executable ${clangpp}]} {
+                        set ret ${clangpp}
+                    } else {
+                        set ret [find_developer_tool llvm-g++-4.2]
+                    }
+                }
             }
         }
-        apple-gcc-3.3 {
-            switch -exact ${type} {
-                cc  { set ret ${prefix}/bin/gcc-apple-3.3 }
-                cpp { set ret ${prefix}/bin/cpp-apple-3.3 }
-            }
-        }
         apple-gcc-4.0 {
             switch -exact ${type} {
                 cc   { set ret ${prefix}/bin/gcc-apple-4.0 }
@@ -413,22 +535,20 @@
                 cc   { set ret ${prefix}/bin/gcc-apple-4.2 }
                 objc { set ret ${prefix}/bin/gcc-apple-4.2 }
                 cpp  { set ret ${prefix}/bin/cpp-apple-4.2 }
+                cxx  { set ret ${prefix}/bin/g++-apple-4.2 }
             }
         }
-        macports-gcc-3.3 {
+        macports-gcc {
             switch -exact ${type} {
-                cc  { set ret ${prefix}/bin/gcc-mp-3.3 }
-                cxx { set ret ${prefix}/bin/g++-mp-3.3 }
-                cpp { set ret ${prefix}/bin/cpp-mp-3.3 }
+                cc   { set ret ${prefix}/bin/gcc }
+                objc { set ret ${prefix}/bin/gcc }
+                cxx  { set ret ${prefix}/bin/g++ }
+                cpp  { set ret ${prefix}/bin/cpp }
+                fc   { set ret ${prefix}/bin/gfortran }
+                f77  { set ret ${prefix}/bin/gfortran }
+                f90  { set ret ${prefix}/bin/gfortran }
             }
         }
-        macports-gcc-3.4 {
-            switch -exact ${type} {
-                cc  { set ret ${prefix}/bin/gcc-mp-3.4 }
-                cxx { set ret ${prefix}/bin/g++-mp-3.4 }
-                cpp { set ret ${prefix}/bin/cpp-mp-3.4 }
-            }
-        }
         macports-gcc-4.0 {
             switch -exact ${type} {
                 cc   { set ret ${prefix}/bin/gcc-mp-4.0 }
@@ -495,6 +615,56 @@
                 f90  { set ret ${prefix}/bin/gfortran-mp-4.5 }
             }
         }
+        macports-gcc-4.6 {
+            switch -exact ${type} {
+                cc   { set ret ${prefix}/bin/gcc-mp-4.6 }
+                objc { set ret ${prefix}/bin/gcc-mp-4.6 }
+                cxx  { set ret ${prefix}/bin/g++-mp-4.6 }
+                cpp  { set ret ${prefix}/bin/cpp-mp-4.6 }
+                fc   { set ret ${prefix}/bin/gfortran-mp-4.6 }
+                f77  { set ret ${prefix}/bin/gfortran-mp-4.6 }
+                f90  { set ret ${prefix}/bin/gfortran-mp-4.6 }
+            }
+        }
+        macports-llvm-gcc-4.2 {
+            switch -exact ${type} {
+                cc   { set ret ${prefix}/bin/llvm-gcc-4.2 }
+                objc { set ret ${prefix}/bin/llvm-gcc-4.2 }
+                cxx  { set ret ${prefix}/bin/llvm-g++-4.2 }
+                cpp  { set ret ${prefix}/bin/llvm-cpp-4.2 }
+                fc   { set ret ${prefix}/bin/llvm-gfortran-4.2 }
+                f77  { set ret ${prefix}/bin/llvm-gfortran-4.2 }
+                f90  { set ret ${prefix}/bin/llvm-gfortran-4.2 }
+            }
+        }
+        macports-clang {
+            switch -exact ${type} {
+                cc   { set ret ${prefix}/bin/clang }
+                objc { set ret ${prefix}/bin/clang }
+                cxx  { set ret ${prefix}/bin/clang++ }
+            }
+        }
+        macports-clang-2.9 {
+            switch -exact ${type} {
+                cc   { set ret ${prefix}/bin/clang-mp-2.9 }
+                objc { set ret ${prefix}/bin/clang-mp-2.9 }
+                cxx  { set ret ${prefix}/bin/clang++-mp-2.9 }
+            }
+        }
+        macports-clang-3.0 {
+            switch -exact ${type} {
+                cc   { set ret ${prefix}/bin/clang-mp-3.0 }
+                objc { set ret ${prefix}/bin/clang-mp-3.0 }
+                cxx  { set ret ${prefix}/bin/clang++-mp-3.0 }
+            }
+        }
+        macports-clang-3.1 {
+            switch -exact ${type} {
+                cc   { set ret ${prefix}/bin/clang-mp-3.1 }
+                objc { set ret ${prefix}/bin/clang-mp-3.1 }
+                cxx  { set ret ${prefix}/bin/clang++-mp-3.1 }
+            }
+        }
     }
     return $ret
 }
@@ -531,13 +701,17 @@
     }
 
     if {[tbool use_xmkmf]} {
+        parse_environment xmkmf
+        append_list_to_environment_value xmkmf "IMAKECPP" ${configure.cpp}
         if {[catch {command_exec xmkmf} result]} {
             return -code error "[format [msgcat::mc "%s failure: %s"] xmkmf $result]"
-        } else {
-            # XXX should probably use make command abstraction but we know that
-            # X11 will already set things up so that "make Makefiles" always works.
-            system "cd ${worksrcpath} && make Makefiles"
         }
+
+        parse_environment xmkmf
+        append_list_to_environment_value xmkmf "IMAKECPP" ${configure.cpp}
+        if {[catch {command_exec "cd ${worksrcpath} && make Makefiles" -varprefix xmkmf} result]} {
+            return -code error "[format [msgcat::mc "%s failure: %s"] "make Makefiles" $result]"
+        }
     } elseif {[tbool use_configure]} {
         # Merge (ld|c|cpp|cxx)flags into the environment variable.
         parse_environment configure

Modified: branches/new-help-system/base/src/port1.0/portdeactivate.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portdeactivate.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portdeactivate.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
 # portdeactivate.tcl
 # $Id$
 #
-# Copyright (c) 2010 The MacPorts Project
+# Copyright (c) 2010-2011 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -49,18 +49,15 @@
 default deactivate.asroot no
 
 proc portdeactivate::deactivate_start {args} {
-    global prefix registry.installtype
-    if { (![file writable $prefix] || ([getuid] == 0 && [geteuid] != 0)) && ${registry.installtype} == "image"} {
+    global prefix
+    if {![file writable $prefix] || ([getuid] == 0 && [geteuid] != 0)} {
         # if install location is not writable, need root privileges
         elevateToRoot "deactivate"
     }
 }
 
 proc portdeactivate::deactivate_main {args} {
-    global name version revision portvariants user_options registry.installtype
-    # we still want to be able to run this target in direct mode for the pre/post procs
-    if {${registry.installtype} == "image"} {
-        registry_deactivate $name "${version}_${revision}${portvariants}" [array get user_options]
-    }
+    global subport version revision portvariants user_options
+    registry_deactivate $subport $version $revision $portvariants [array get user_options]
     return 0
 }

Modified: branches/new-help-system/base/src/port1.0/portdepends.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portdepends.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portdepends.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portdepends.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2005, 2007-2009 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #

Modified: branches/new-help-system/base/src/port1.0/portdestroot.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portdestroot.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portdestroot.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,8 +2,9 @@
 # portdestroot.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# 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
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #
@@ -52,14 +53,14 @@
 options startupitem.name startupitem.start startupitem.stop startupitem.restart
 options startupitem.type startupitem.executable
 options startupitem.pidfile startupitem.logfile startupitem.logevents startupitem.netchange
-options startupitem.uniquename startupitem.plist startupitem.location
+options startupitem.uniquename startupitem.plist startupitem.location startupitem.install
 commands destroot
 
 # Set defaults
 default destroot.asroot no
 default destroot.dir {${build.dir}}
 default destroot.cmd {${build.cmd}}
-default destroot.pre_args {${destroot.target}}
+default destroot.pre_args {[portdestroot::destroot_getargs]}
 default destroot.target install
 default destroot.post_args {${destroot.destdir}}
 default destroot.destdir {DESTDIR=${destroot}}
@@ -69,7 +70,7 @@
 default destroot.keepdirs ""
 default destroot.violate_mtree no
 
-default startupitem.name        {${name}}
+default startupitem.name        {${subport}}
 default startupitem.uniquename  {org.macports.${startupitem.name}}
 default startupitem.plist       {${startupitem.uniquename}.plist}
 default startupitem.location    LaunchDaemons
@@ -84,16 +85,27 @@
 default startupitem.logfile     ""
 default startupitem.logevents   no
 default startupitem.netchange   no
+default startupitem.install     {$system_options(startupitem_install)}
 
 set_ui_prefix
 
+proc portdestroot::destroot_getargs {args} {
+    if {((![exists build.type] && [option os.platform] != "freebsd") || ([exists build.type] && [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]"
+    }
+
+    return "[option destroot.target]"
+}
+
 proc portdestroot::destroot_start {args} {
-    global UI_PREFIX prefix name porturl destroot os.platform destroot.clean portsharepath
+    global UI_PREFIX prefix subport porturl destroot os.platform destroot.clean portsharepath
     global destroot.umask destroot.asroot euid egid
     global applications_dir frameworks_dir
     variable oldmask
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Staging %s into destroot"] ${name}]"
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Staging %s into destroot"] ${subport}]"
 
     # start gsoc08-privileges
     if { [getuid] == 0 && [geteuid] != 0 } {
@@ -135,7 +147,7 @@
 }
 
 proc portdestroot::destroot_finish {args} {
-    global UI_PREFIX destroot prefix name startupitem.create destroot.violate_mtree
+    global UI_PREFIX destroot prefix subport startupitem.create destroot.violate_mtree
     global applications_dir frameworks_dir destroot.keepdirs
     global os.platform os.version
     variable oldmask
@@ -158,8 +170,8 @@
         if {![file isdirectory ${path}]} {
             xinstall -m 0755 -d ${path}
         }
-        if {![file exists ${path}/.turd_${name}]} {
-            xinstall -c -m 0644 /dev/null ${path}/.turd_${name}
+        if {![file exists ${path}/.turd_${subport}]} {
+            xinstall -c -m 0644 /dev/null ${path}/.turd_${subport}
         }
     }
     fs-traverse -depth dir ${destroot} {
@@ -175,7 +187,7 @@
                   alternative destroot mechanism in the Portfile."
         ui_error "Files might have been installed directly into your system,\
                   check before proceeding."
-        return -code error "Staging $name into destroot failed"
+        return -code error "Staging $subport into destroot failed"
     }
 
     # Compress all manpages with gzip (instead)
@@ -184,7 +196,7 @@
     set gunzip "$gzip -d"
     set bunzip2 "[findBinary bzip2 ${portutil::autoconf::bzip2_path}] -d"
     if {[file isdirectory ${manpath}] && [file type ${manpath}] == "directory"} {
-        ui_info "$UI_PREFIX [format [msgcat::mc "Compressing man pages for %s"] ${name}]"
+        ui_info "$UI_PREFIX [format [msgcat::mc "Compressing man pages for %s"] ${subport}]"
         set found 0
         set manlinks [list]
         foreach mandir [readdir "${manpath}"] {
@@ -332,12 +344,12 @@
 
         # abort here only so all violations can be observed
         if { ${mtree_violation} != "no" } {
-            ui_warn "[format [msgcat::mc "%s violates the layout of the ports-filesystems!"] [option name]]"
+            ui_warn "[format [msgcat::mc "%s violates the layout of the ports-filesystems!"] [option subport]]"
             ui_warn "Please fix or indicate this misbehavior (if it is intended), it will be an error in future releases!"
             # error "mtree violation!"
         }
     } else {
-        ui_msg "[format [msgcat::mc "Note: %s installs files outside the common directory structure."] [option name]]"
+        ui_warn "[format [msgcat::mc "%s installs files outside the common directory structure."] [option subport]]"
     }
 
     # Restore umask

Modified: branches/new-help-system/base/src/port1.0/portdistcheck.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portdistcheck.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portdistcheck.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,6 +3,7 @@
 #
 # $Id$
 #
+# Copyright (c) 2007-2011 The MacPorts Project
 # Copyright (c) 2005-2006 Paul Guyot <pguyot at kallisys.net>,
 # All rights reserved.
 #
@@ -15,7 +16,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its
+# 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.
 #
@@ -46,22 +47,28 @@
 }
 
 # define options
-options distcheck.check
+options distcheck.type
 
 # defaults
-default distcheck.check moddate
+default distcheck.type moddate
 
 proc portdistcheck::distcheck_main {args} {
-    global distcheck.check
+    global distcheck.type
     global fetch.type
-    global name portpath
+    global fetch.ignore_sslcert
+    global subport portpath
 
     set port_moddate [file mtime ${portpath}/Portfile]
 
     ui_debug "Portfile modification date is [clock format $port_moddate]"
 
+    set curl_options {}
+    if [tbool fetch.ignore_sslcert] {
+        lappend curl_options "--ignore-ssl-cert"
+    }
+
     # Check the distfiles if it's a regular fetch phase.
-    if {"${distcheck.check}" != "none"
+    if {"${distcheck.type}" != "none"
         && "${fetch.type}" == "standard"} {
         # portfetch 1.0::checkfiles sets fetch_urls list.
         set fetch_urls {}
@@ -75,49 +82,49 @@
                 ui_error [format [msgcat::mc "No defined site for tag: %s, using master_sites"] $url_var]
                 set urlmap($url_var) $master_sites
             }
-            if {${distcheck.check} == "moddate"} {
+            if {${distcheck.type} == "moddate"} {
                 set count 0
                 foreach site $urlmap($url_var) {
                     ui_debug [format [msgcat::mc "Checking %s from %s"] $distfile $site]
                     set file_url [portfetch::assemble_url $site $distfile]
-                    if {[catch {set urlnewer [curl isnewer $file_url $port_moddate]} error]} {
-                        ui_warn "couldn't fetch $file_url for $name ($error)"
+                    if {[catch {set urlnewer [eval curl isnewer $curl_options {$file_url} $port_moddate]} error]} {
+                        ui_warn "couldn't fetch $file_url for $subport ($error)"
                     } else {
                         if {$urlnewer} {
-                            ui_warn "port $name: $file_url is newer than portfile"
+                            ui_warn "port $subport: $file_url is newer than portfile"
                         }
                         incr count
                     }
                 }
                 if {$count == 0} {
-                    ui_error "no mirror had $distfile for $name"
+                    ui_error "no mirror had $distfile for $subport"
                 }
-            } elseif {${distcheck.check} == "filesize"} {
+            } elseif {${distcheck.type} == "filesize"} {
                 set count 0
                 foreach site $urlmap($url_var) {
                     ui_debug [format [msgcat::mc "Checking %s from %s"] $distfile $site]
                     set file_url [portfetch::assemble_url $site $distfile]
-                    if {[catch {set urlsize [curl getsize $file_url]} error]} {
-                        ui_warn "couldn't fetch $file_url for $name ($error)"
+                    if {[catch {set urlsize [eval curl getsize $curl_options {$file_url}]} error]} {
+                        ui_warn "couldn't fetch $file_url for $subport ($error)"
                     } else {
                         incr count
                         if {$urlsize > 0} {
-                            ui_info "port $name: $distfile $urlsize bytes"
+                            ui_info "port $subport: $distfile $urlsize bytes"
                             incr totalsize $urlsize
                             break
                         }
                     }
                 }
                 if {$count == 0} {
-                    ui_error "no mirror had $distfile for $name"
+                    ui_error "no mirror had $distfile for $subport"
                 }
             } else {
-                ui_error "unknown distcheck.check ${distcheck.check}"
+                ui_error "unknown distcheck.type ${distcheck.type}"
                 break
             }
         }
 
-        if {${distcheck.check} == "filesize" && $totalsize > 0} {
+        if {${distcheck.type} == "filesize" && $totalsize > 0} {
             if {$totalsize < 1024} {
                 set size $totalsize
                 set humansize "${size}"
@@ -131,7 +138,7 @@
                 set size [expr $totalsize / (1024.0*1024.0*1024.0)]
                 set humansize [format "%.1fG" $size]
             }
-            ui_msg "$name: $humansize"
+            ui_msg "$subport: $humansize"
         }
     }
 }

Modified: branches/new-help-system/base/src/port1.0/portdistfiles.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portdistfiles.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portdistfiles.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
 # portdistfiles.tcl
 # $Id$
 #
-# Copyright (c) 2008 MacPorts Project
+# Copyright (c) 2008-2011 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +13,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -48,15 +48,17 @@
 set_ui_prefix
 
 proc portdistfiles::distfiles_start {args} {
-    global UI_PREFIX name
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Distfiles for %s"] ${name}]"
+    global UI_PREFIX subport
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Distfiles for %s"] ${subport}]"
 }
 
 proc portdistfiles::distfiles_main {args} {
-    global UI_PREFIX master_sites checksums_array portdbpath dist_subdir
+    global UI_PREFIX master_sites patch_sites patchfiles checksums_array \
+           portdbpath dist_subdir all_dist_files
     
     # give up on ports that do not provide URLs
-    if {$master_sites == "{}"} {
+    if {(![info exists master_sites] || $master_sites == "{}")
+        && (![info exists patchfiles] || ![info exists patch_sites] || $patch_sites == "{}")} {
         return 0
     }
 
@@ -64,6 +66,11 @@
     set fetch_urls {}
     portfetch::checkfiles fetch_urls
 
+    # also give up on ports that don't have any distfiles
+    if {![info exists all_dist_files]} {
+        return 0
+    }
+
     # get checksum data from the portfile and parse it
     set checksums_str [option checksums]
     set result [portchecksum::parse_checksums $checksums_str]

Modified: branches/new-help-system/base/src/port1.0/portextract.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portextract.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portextract.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portextract.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2005, 2007-2011 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
 # Copyright (c) 2007 Markus W. Weissmann <mww at macports.org>
 # All rights reserved.
 #
@@ -14,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #
@@ -36,17 +37,18 @@
 
 set org.macports.extract [target_new org.macports.extract portextract::extract_main]
 target_provides ${org.macports.extract} extract
-target_requires ${org.macports.extract} fetch checksum
+target_requires ${org.macports.extract} main fetch checksum
 target_prerun ${org.macports.extract} portextract::extract_start
 
 namespace eval portextract {
 }
 
 # define options
-options extract.only extract.mkdir
+options extract.only extract.mkdir extract.asroot
 commands extract
 
 # Set up defaults
+default extract.asroot no
 # XXX call out to code in portutil.tcl XXX
 # This cleans the distfiles list of all site tags
 default extract.only {[portextract::disttagclean $distfiles]}
@@ -75,8 +77,11 @@
 proc portextract::extract_start {args} {
     global UI_PREFIX extract.dir extract.mkdir use_bzip2 use_lzma use_xz use_zip use_7z use_dmg
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Extracting %s"] [option name]]"
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Extracting %s"] [option subport]]"
 
+    # create any users and groups needed by the port
+    handle_add_users
+
     # should the distfiles be extracted to worksrcpath instead?
     if {[tbool extract.mkdir]} {
         global worksrcpath
@@ -87,9 +92,9 @@
     if {[tbool use_bzip2]} {
         option extract.cmd [findBinary bzip2 ${portutil::autoconf::bzip2_path}]
     } elseif {[tbool use_lzma]} {
-        option extract.cmd [binaryInPath "lzma"]
+        option extract.cmd [findBinary lzma ${portutil::autoconf::lzma_path}]
     } elseif {[tbool use_xz]} {
-        option extract.cmd [binaryInPath "xz"]
+        option extract.cmd [findBinary xz ${portutil::autoconf::xz_path}]
     } elseif {[tbool use_zip]} {
         option extract.cmd [findBinary unzip ${portutil::autoconf::unzip_path}]
         option extract.pre_args -q

Modified: branches/new-help-system/base/src/port1.0/portfetch.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portfetch.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portfetch.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portfetch.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2004 - 2011 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #
@@ -85,7 +86,6 @@
 default cvs.args ""
 default cvs.post_args {"${cvs.module}"}
 
-# we want the svn port so we know --trust-server-cert will work
 default svn.cmd {[portfetch::find_svn_path]}
 default svn.dir {${workpath}}
 default svn.method {export}
@@ -93,7 +93,7 @@
 default svn.env {}
 default svn.pre_args {"--non-interactive --trust-server-cert"}
 default svn.args ""
-default svn.post_args {"${svn.url}"}
+default svn.post_args ""
 
 default git.cmd {[findBinary git $portutil::autoconf::git_path]}
 default git.dir {${workpath}}
@@ -104,7 +104,7 @@
 default hg.tag {tip}
 
 # Set distfiles
-default distfiles {[portfetch::suffix $distname]}
+default distfiles {[list [portfetch::suffix $distname]]}
 default dist_subdir {${name}}
 
 # user name & password
@@ -122,9 +122,6 @@
 default mirror_sites.listfile {"mirror_sites.tcl"}
 default mirror_sites.listpath {"port1.0/fetch"}
 
-# Deprecation
-option_deprecate svn.tag svn.revision
-
 # Option-executed procedures
 option_proc use_bzip2 portfetch::set_extract_type
 option_proc use_lzma  portfetch::set_extract_type
@@ -144,11 +141,11 @@
             }
             use_lzma {
                 set extract.suffix .tar.lzma
-                depends_extract-append bin:lzma:lzmautils
+                depends_extract-append bin:lzma:xz
             }
             use_xz {
                 set extract.suffix .tar.xz
-                depends_extract-append bin:xz:xz-devel
+                depends_extract-append bin:xz:xz
             }
             use_zip {
                 set extract.suffix .zip
@@ -168,6 +165,9 @@
 proc portfetch::set_fetch_type {option action args} {
     global os.platform os.major
     if {[string equal ${action} "set"]} {
+        if {$args != "standard"} {
+            distfiles
+        }
         switch $args {
             bzr {
                 depends_fetch-append bin:bzr:bzr
@@ -194,6 +194,7 @@
 
 proc portfetch::find_svn_path {args} {
     global prefix os.platform os.major
+    # Snow Leopard is the first Mac OS X version to include a recent enough svn (1.6.x) to support the --trust-server-cert option.
     if {${os.platform} == "darwin" && ${os.major} >= 10} {
         return [findBinary svn $portutil::autoconf::svn_path]
     } else {
@@ -204,18 +205,10 @@
 set_ui_prefix
 
 
-# Given a distname, return a suffix based on the use_zip / use_bzip2 / use_dmg / extract.suffix options
+# Given a distname, return the distname with extract.suffix appended
 proc portfetch::suffix {distname} {
-    global extract.suffix fetch.type
-    switch -- "${fetch.type}" {
-        bzr         -
-        cvs         -
-        svn         -
-        git         -
-        hg          { return "" }
-        standard    -
-        default     { return "${distname}${extract.suffix}" }
-    }
+    global extract.suffix
+    return "${distname}${extract.suffix}"
 }
 # XXX import suffix into the global namespace as it is currently used from
 # Portfiles, but should better go somewhere else
@@ -228,7 +221,7 @@
 
     if {[info exists patchfiles]} {
         foreach file $patchfiles {
-            if {![file exists $filespath/$file]} {
+            if {![file exists "${filespath}/${file}"]} {
                 set distsite [getdisttag $file]
                 set file [getdistname $file]
                 lappend all_dist_files $file
@@ -251,7 +244,7 @@
 
     if {[info exists distfiles]} {
         foreach file $distfiles {
-            if {![file exists $filespath/$file]} {
+            if {![file exists "${filespath}/${file}"]} {
                 set distsite [getdisttag $file]
                 set file [getdistname $file]
                 lappend all_dist_files $file
@@ -286,6 +279,7 @@
 
 # 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"]
     }
@@ -345,16 +339,16 @@
 
 # Perform an svn fetch
 proc portfetch::svnfetch {args} {
-    global svn.args svn.method svn.revision svn.url
+    global svn.args svn.method svn.revision svn.url patchfiles
 
     if {[regexp {\s} ${svn.url}]} {
         return -code error [msgcat::mc "Subversion URL cannot contain whitespace"]
     }
 
-    set svn.args "${svn.method} ${svn.args}"
     if {[string length ${svn.revision}]} {
         append svn.url "@${svn.revision}"
     }
+    set svn.args "${svn.method} ${svn.args} ${svn.url}"
 
     if {[catch {command_exec svn "" "2>&1"} result]} {
         return -code error [msgcat::mc "Subversion check out failed"]
@@ -369,7 +363,7 @@
 
 # Perform a git fetch
 proc portfetch::gitfetch {args} {
-    global worksrcpath
+    global worksrcpath patchfiles
     global git.url git.branch git.sha1 git.cmd
 
     set options "-q"
@@ -401,7 +395,7 @@
 
 # Perform a mercurial fetch.
 proc portfetch::hgfetch {args} {
-    global worksrcpath prefix_frozen
+    global worksrcpath prefix_frozen patchfiles
     global hg.url hg.tag hg.cmd
 
     set cmdstring "${hg.cmd} clone --rev ${hg.tag} ${hg.url} ${worksrcpath} 2>&1"
@@ -426,20 +420,6 @@
     variable fetch_urls
     variable urlmap
 
-    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
-    if {[info exists elevated] && $elevated == yes} {
-        dropPrivileges
-    }
-
     set fetch_options {}
     if {[string length ${fetch.user}] || [string length ${fetch.password}]} {
         lappend fetch_options -u
@@ -532,9 +512,24 @@
 }
 
 proc portfetch::fetch_start {args} {
-    global UI_PREFIX name
+    global UI_PREFIX subport distpath
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Fetching %s"] $name]"
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Fetching %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
+    if {[info exists elevated] && $elevated == yes} {
+        dropPrivileges
+    }
 }
 
 # 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-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portinstall.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,8 +2,9 @@
 # portinstall.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2002 - 2004 Apple Inc.
 # Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
+# Copyright (c) 2005, 2007 - 2011 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -38,11 +39,7 @@
 set org.macports.install [target_new org.macports.install portinstall::install_main]
 target_provides ${org.macports.install} install
 target_runtype ${org.macports.install} always
-if {[option portarchivemode] == "yes"} {
-    target_requires ${org.macports.install} main archivefetch unarchive fetch checksum extract patch configure build destroot archive
-} else {
-    target_requires ${org.macports.install} main fetch checksum extract patch configure build destroot
-}
+target_requires ${org.macports.install} main archivefetch fetch checksum extract patch configure build destroot
 target_prerun ${org.macports.install} portinstall::install_start
 
 namespace eval portinstall {
@@ -57,9 +54,9 @@
 set_ui_prefix
 
 proc portinstall::install_start {args} {
-    global UI_PREFIX name version revision portvariants
-    global prefix registry_open registry.format registry.path
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Installing %s @%s_%s%s"] $name $version $revision $portvariants]"
+    global UI_PREFIX subport version revision portvariants
+    global prefix registry_open registry.path
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Installing %s @%s_%s%s"] $subport $version $revision $portvariants]"
     
     # start gsoc08-privileges
     if {![file writable $prefix] || ([getuid] == 0 && [geteuid] != 0)} {
@@ -70,206 +67,491 @@
     }
     # end gsoc08-privileges
     
-    if {${registry.format} == "receipt_sqlite" && ![info exists registry_open]} {
+    if {![info exists registry_open]} {
         registry::open [file join ${registry.path} registry registry.db]
         set registry_open yes
     }
+
+    # create any users and groups needed by the port
+    handle_add_users
 }
 
-proc portinstall::install_element {src_element dst_element} {
-    # don't recursively copy directories
-    if {[file isdirectory $src_element] && [file type $src_element] != "link"} {
-        file mkdir $dst_element
-    } else {
-        file copy -force $src_element $dst_element
-    }
-    
-    # if the file is a symlink, do not try to set file attributes
-    if {[file type $src_element] != "link"} {
-        # tclsh on 10.6 doesn't like the combination of 0444 perm and
-        # '-creator {}' (which is returned from 'file attributes <file>'; so
-        # instead just set the attributes which are needed
-        set wantedattrs {owner group permissions}
-        set file_attr_cmd {file attributes $dst_element}
-        foreach oneattr $wantedattrs {
-            set file_attr_cmd "$file_attr_cmd -$oneattr \[file attributes \$src_element -$oneattr\]"
-        }
-        eval $file_attr_cmd
-        # set mtime on installed element
-        file mtime $dst_element [file mtime $src_element]
-    }
+# fake some info for a list of files to match the format
+# used for contents in the flat registry
+# This list is a 6-tuple of the form:
+# 0: file path
+# 1: uid
+# 2: gid
+# 3: mode
+# 4: size
+# 5: md5 checksum information
+proc portinstall::_fake_fileinfo_for_index {flist} {
+    global 
+	set rval [list]
+	foreach file $flist {
+		lappend rval [list $file [getuid] [getgid] 0644 0 "MD5 ($fname) NONE"]
+	}
+	return $rval
 }
 
-proc portinstall::directory_dig {rootdir workdir imagedir {cwd ""} {prepend 1}} {
-    global installPlist
-    set pwd [pwd]
-    if {[catch {_cd $workdir} err]} {
-        puts $err
-        return
+proc portinstall::putel { fd el data } {
+    # Quote xml data
+    set quoted [string map  { & & < < > > } $data]
+    # Write the element
+    puts $fd "<${el}>${quoted}</${el}>"
+}
+
+proc portinstall::putlist { fd listel itemel list } {
+    puts $fd "<$listel>"
+    foreach item $list {
+        putel $fd $itemel $item
     }
+    puts $fd "</$listel>"
+}
 
-    set root [file join [file separator] $imagedir]
-    foreach name [readdir .] {
-        set element [file join $cwd $name]
+proc portinstall::create_archive {location archive.type} {
+    global workpath destpath portpath subport version revision portvariants \
+           epoch os.platform PortInfo installPlist \
+           archive.env archive.cmd archive.pre_args archive.args \
+           archive.post_args archive.dir \
+           depends_fetch depends_extract depends_build depends_lib depends_run
+    set archive.env {}
+    set archive.cmd {}
+    set archive.pre_args {}
+    set archive.args {}
+    set archive.post_args {}
+    set archive.dir ${destpath}
 
-        set dst_element [file join $root $element]
-        set src_element [file join $rootdir $element]
-        # overwrites files but not directories
-        if {![file exists $dst_element] || ![file isdirectory $dst_element]} {
-            if {[file type $src_element] == "link"} {
-                ui_debug "installing link: $dst_element"
-            } elseif {[file isdirectory $src_element]} {
-                ui_debug "installing directory: $dst_element"
+    switch -regex -- ${archive.type} {
+        cp(io|gz) {
+            set pax "pax"
+            if {[catch {set pax [findBinary $pax ${portutil::autoconf::pax_path}]} errmsg] == 0} {
+                ui_debug "Using $pax"
+                set archive.cmd "$pax"
+                set archive.pre_args {-w -v -x cpio}
+                if {[regexp {z$} ${archive.type}]} {
+                    set gzip "gzip"
+                    if {[catch {set gzip [findBinary $gzip ${portutil::autoconf::gzip_path}]} errmsg] == 0} {
+                        ui_debug "Using $gzip"
+                        set archive.args {.}
+                        set archive.post_args "| $gzip -c9 > ${location}"
+                    } else {
+                        ui_debug $errmsg
+                        return -code error "No '$gzip' was found on this system!"
+                    }
+                } else {
+                    set archive.args "-f ${location} ."
+                }
             } else {
-                ui_debug "installing file: $dst_element"
+                ui_debug $errmsg
+                return -code error "No '$pax' was found on this system!"
             }
-            install_element $src_element $dst_element
-            # only track files/links for registry, not directories
-            if {[file type $dst_element] != "directory"} {
-                if {$prepend} {
-                    lappend installPlist $dst_element
+        }
+        t(ar|bz|lz|xz|gz) {
+            set tar "tar"
+            if {[catch {set tar [findBinary $tar ${portutil::autoconf::tar_path}]} errmsg] == 0} {
+                ui_debug "Using $tar"
+                set archive.cmd "$tar"
+                set archive.pre_args {-cvf}
+                if {[regexp {z2?$} ${archive.type}]} {
+                    if {[regexp {bz2?$} ${archive.type}]} {
+                        set gzip "bzip2"
+                        set level 9
+                    } elseif {[regexp {lz$} ${archive.type}]} {
+                        set gzip "lzma"
+                        set level ""
+                    } elseif {[regexp {xz$} ${archive.type}]} {
+                        set gzip "xz"
+                        set level 6
+                    } else {
+                        set gzip "gzip"
+                        set level 9
+                    }
+                    if {[info exists portutil::autoconf::${gzip}_path]} {
+                        set hint [set portutil::autoconf::${gzip}_path]
+                    } else {
+                        set hint ""
+                    }
+                    if {[catch {set gzip [findBinary $gzip $hint]} errmsg] == 0} {
+                        ui_debug "Using $gzip"
+                        set archive.args {- .}
+                        set archive.post_args "| $gzip -c$level > ${location}"
+                    } else {
+                        ui_debug $errmsg
+                        return -code error "No '$gzip' was found on this system!"
+                    }
                 } else {
-                    lappend installPlist [file join [file separator] $element]
+                    set archive.args "${location} ."
                 }
+            } else {
+                ui_debug $errmsg
+                return -code error "No '$tar' was found on this system!"
             }
         }
-        if {[file isdirectory $name] && [file type $name] != "link"} {
-            directory_dig $rootdir $name $imagedir [file join $cwd $name] $prepend
+        xar {
+            set xar "xar"
+            if {[catch {set xar [findBinary $xar ${portutil::autoconf::xar_path}]} errmsg] == 0} {
+                ui_debug "Using $xar"
+                set archive.cmd "$xar"
+                set archive.pre_args {-cvf}
+                set archive.args "${location} ."
+            } else {
+                ui_debug $errmsg
+                return -code error "No '$xar' was found on this system!"
+            }
         }
+        xpkg {
+            set xar "xar"
+            set compression "bzip2"
+            set archive.meta yes
+            set archive.metaname "xpkg"
+            set archive.metapath [file join $workpath "${archive.metaname}.xml"]
+            if {[catch {set xar [findBinary $xar ${portutil::autoconf::xar_path}]} errmsg] == 0} {
+                ui_debug "Using $xar"
+                set archive.cmd "$xar"
+                set archive.pre_args "-cv --exclude='\./\+.*' --compression=${compression} -n ${archive.metaname} -s ${archive.metapath} -f"
+                set archive.args "${location} ."
+            } else {
+                ui_debug $errmsg
+                return -code error "No '$xar' was found on this system!"
+            }
+        }
+        zip {
+            set zip "zip"
+            if {[catch {set zip [findBinary $zip ${portutil::autoconf::zip_path}]} errmsg] == 0} {
+                ui_debug "Using $zip"
+                set archive.cmd "$zip"
+                set archive.pre_args {-ry9}
+                set archive.args "${location} ."
+            } else {
+                ui_debug $errmsg
+                return -code error "No '$zip' was found on this system!"
+            }
+        }
     }
-    _cd $pwd
-}
 
-proc portinstall::install_main {args} {
-    global name version portpath categories description long_description \
-    homepage depends_run installPlist package-install workdir workpath \
-    worksrcdir UI_PREFIX destroot revision maintainers user_options \
-    portvariants negated_variants targets depends_lib PortInfo epoch license \
-    registry.installtype registry.path registry.format \
-    os.platform os.major
+    set archive.fulldestpath [file dirname $location]
+    # Create archive destination path (if needed)
+    if {![file isdirectory ${archive.fulldestpath}]} {
+        file mkdir ${archive.fulldestpath}
+    }
 
-    set oldpwd [pwd]
-    if {$oldpwd == ""} {
-        set oldpwd $portpath
+    # Create (if no files) destroot for archiving
+    if {![file isdirectory ${destpath}]} {
+        return -code error "no destroot found at: ${destpath}"
     }
-    _cd $workpath
 
-    if {[string equal ${registry.format} "receipt_sqlite"]} {
-        # registry2.0
+    # Copy state file into destroot for archiving
+    # +STATE contains a copy of the MacPorts state information
+    set statefile [file join $workpath .macports.${subport}.state]
+    file copy -force $statefile [file join $destpath "+STATE"]
 
-        # 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} {
-            if {[info exists $deplist]} {
-                foreach dep [set $deplist] {
-                    set dep_portname [_get_dep_port $dep]
-                    if {$dep_portname != ""} {
-                        lappend dep_portnames $dep_portname
-                    }
-                }
-            }
+    # Copy Portfile into destroot for archiving
+    # +PORTFILE contains a copy of the MacPorts Portfile
+    set portfile [file join $portpath Portfile]
+    file copy -force $portfile [file join $destpath "+PORTFILE"]
+
+    # Create some informational files that we don't really use just yet,
+    # but we may in the future in order to allow port installation from
+    # archives without a full "ports" tree of Portfiles.
+    #
+    # Note: These have been modeled after FreeBSD type package files to
+    # start. We can change them however we want for actual future use if
+    # needed.
+    #
+    # +COMMENT contains the port description
+    set fd [open [file join $destpath "+COMMENT"] w]
+    if {[exists description]} {
+        puts $fd "[option description]"
+    }
+    close $fd
+    # +DESC contains the port long_description and homepage
+    set fd [open [file join $destpath "+DESC"] w]
+    if {[exists long_description]} {
+        puts $fd "[option long_description]"
+    }
+    if {[exists homepage]} {
+        puts $fd "\nWWW: [option homepage]"
+    }
+    close $fd
+    # +CONTENTS contains the port version/name info and all installed
+    # files and checksums
+    set control [list]
+    set fd [open [file join $destpath "+CONTENTS"] w]
+    puts $fd "@name ${subport}-${version}_${revision}${portvariants}"
+    puts $fd "@portname ${subport}"
+    puts $fd "@portepoch ${epoch}"
+    puts $fd "@portversion ${version}"
+    puts $fd "@portrevision ${revision}"
+    puts $fd "@archs [get_canonical_archs]"
+    array set ourvariations $PortInfo(active_variants)
+    set vlist [lsort -ascii [array names ourvariations]]
+    foreach v $vlist {
+        if {$ourvariations($v) == "+"} {
+            puts $fd "@portvariant +${v}"
         }
+    }
 
-        registry::write {
+    foreach key "depends_lib depends_run" {
+         if {[info exists $key]} {
+             foreach depspec [set $key] {
+                 set depname [lindex [split $depspec :] end]
+                 set dep [mport_lookup $depname]
+                 if {[llength $dep] < 2} {
+                     ui_error "Dependency $dep not found"
+                 } else {
+                     array set portinfo [lindex $dep 1]
+                     set depver $portinfo(version)
+                     set deprev $portinfo(revision)
+                     puts $fd "@pkgdep ${depname}-${depver}_${deprev}"
+                 }
+             }
+         }
+    }
 
-            set regref [registry::entry create $name $version $revision $portvariants $epoch]
-
-            $regref requested $user_options(ports_requested)
-            $regref os_platform ${os.platform}
-            $regref os_major ${os.major}
-            $regref archs [get_canonical_archs]
-            # Trick to have a portable GMT-POSIX epoch-based time.
-            $regref date [expr [clock scan now -gmt true] - [clock scan "1970-1-1 00:00:00" -gmt true]]
-            if {[info exists negated_variants]} {
-                $regref negated_variants $negated_variants
+    # also save the contents for our own use later
+    set installPlist {}
+    fs-traverse -depth fullpath $destpath {
+        if {[file type $fullpath] == "directory"} {
+            continue
+        }
+        set relpath [strsed $fullpath "s|^$destpath/||"]
+        if {![regexp {^[+]} $relpath]} {
+            puts $fd "$relpath"
+            lappend installPlist [file join [file separator] $relpath]
+            if {[file isfile $fullpath]} {
+                ui_debug "checksum file: $fullpath"
+                set checksum [md5 file $fullpath]
+                puts $fd "@comment MD5:$checksum"
             }
+        } else {
+            lappend control $relpath
+        }
+    }
+    foreach relpath $control {
+        puts $fd "@ignore"
+        puts $fd "$relpath"
+    }
+    close $fd
 
-            foreach dep_portname $dep_portnames {
-                $regref depends $dep_portname
-            }
+    # the XML package metadata, for XAR package
+    # (doesn't contain any file list/checksums)
+    if {[tbool archive.meta]} {
+        set sd [open ${archive.metapath} w]
+        puts $sd "<xpkg version='0.2'>"
+        # TODO: split contents into <buildinfo> (new) and <package> (current)
+        #       see existing <portpkg> for the matching source package layout
 
-            if {${registry.installtype} == "image"} {
-                $regref installtype image
-                $regref state imaged
-                set imagedir [file join ${registry.path} software ${name} ${version}_${revision}${portvariants}]
-            } else {
-                $regref installtype direct
-                $regref state installed
-                set imagedir ""
-            }
-            $regref location $imagedir
+        putel $sd name ${subport}
+        putel $sd epoch ${epoch}
+        putel $sd version ${version}
+        putel $sd revision ${revision}
+        putel $sd major 0
+        putel $sd minor 0
 
-            # Install the files, requesting that the list not have the image dir prepended
-            directory_dig ${destroot} ${destroot} ${imagedir} "" 0
-            
-            if {[info exists installPlist]} {
-                # register files
-                $regref map $installPlist
-            }
-            
-            # store portfile
-            set fd [open [file join ${portpath} Portfile]]
-            $regref portfile [read $fd]
-            close $fd
+        putel $sd platform ${os.platform}
+        if {[llength [get_canonical_archs]] > 1} {
+            putlist $sd archs arch [get_canonical_archs]
+        } else {
+            putel $sd arch [get_canonical_archs]
         }
-    } else {
-        # Begin the registry entry
-        set regref [registry_new $name $version $revision $portvariants $epoch]
-        if {[info exists negated_variants]} {
-            registry_prop_store $regref negated_variants $negated_variants
-        }
+        putlist $sd variants variant $vlist
 
-        set imagedir ""
-        if { [registry_prop_retr $regref installtype] == "image" } {
-            set imagedir [registry_prop_retr $regref imagedir]
+        if {[exists categories]} {
+            set primary [lindex [split [option categories] " "] 0]
+            putel $sd category $primary
         }
-        # Install the files
-        directory_dig ${destroot} ${destroot} ${imagedir}
+        if {[exists description]} {
+            putel $sd comment "[option description]"
+        }
+        if {[exists long_description]} {
+            putel $sd desc "[option long_description]"
+        }
+        if {[exists homepage]} {
+            putel $sd homepage "[option homepage]"
+        }
 
-        registry_prop_store $regref requested $user_options(ports_requested)
-        registry_prop_store $regref categories $categories
+            # Emit dependencies provided by this package
+            puts $sd "<provides>"
+                puts $sd "<item>"
+                putel $sd name $subport
+                putel $sd major 0
+                putel $sd minor 0
+                puts $sd "</item>"
+            puts $sd "</provides>"
 
-        registry_prop_store $regref os_platform ${os.platform}
-        registry_prop_store $regref os_major ${os.major}
-        registry_prop_store $regref archs [get_canonical_archs]
 
-        if {[info exists description]} {
-            registry_prop_store $regref description [string map {\n \\n} ${description}]
+            # Emit build, library, and runtime dependencies
+            puts $sd "<requires>"
+            foreach {key type} {
+                depends_fetch "fetch"
+                depends_extract "extract"
+                depends_build "build"
+                depends_lib "library"
+                depends_run "runtime"
+            } {
+                if {[info exists $key]} {
+                    set depname [lindex [split [set $key] :] end]
+                    puts $sd "<item type=\"$type\">"
+                    putel $sd name $depname
+                    putel $sd major 0
+                    putel $sd minor 0
+                    puts $sd "</item>"
+                }
+            }
+            puts $sd "</requires>"
+
+        puts $sd "</xpkg>"
+        close $sd
+    }
+
+    # Now create the archive
+    ui_debug "Creating [file tail $location]"
+    command_exec archive
+    ui_debug "Archive [file tail $location] packaged"
+
+    # Cleanup all control files when finished
+    set control_files [glob -nocomplain -types f [file join $destpath +*]]
+    foreach file $control_files {
+        ui_debug "removing file: $file"
+        file delete -force $file
+    }
+}
+
+proc portinstall::extract_contents {location type} {
+    set qflag ${portutil::autoconf::tar_q}
+    switch -- $type {
+        tbz -
+        tbz2 {
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOj${qflag}f $location +CONTENTS]
         }
-        if {[info exists long_description]} {
-            registry_prop_store $regref long_description [string map {\n \\n} ${long_description}]
+        tgz {
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOz${qflag}f $location +CONTENTS]
         }
-        if {[info exists license]} {
-            registry_prop_store $regref license ${license}
+        tar {
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location +CONTENTS]
         }
-        if {[info exists homepage]} {
-            registry_prop_store $regref homepage ${homepage}
+        txz {
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary xz ""] +CONTENTS]
         }
-        if {[info exists maintainers]} {
-            registry_prop_store $regref maintainers ${maintainers}
+        tlz {
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xO${qflag}f $location --use-compress-program [findBinary lzma ""] +CONTENTS]
         }
-        if {[info exists depends_run]} {
-            registry_prop_store $regref depends_run $depends_run
-            registry_register_deps $depends_run $name
+        xar {
+            system "cd ${workpath} && [findBinary xar ${portutil::autoconf::xar_path}] -xf $location +CONTENTS"
+            set twostep 1
         }
-        if {[info exists depends_lib]} {
-            registry_prop_store $regref depends_lib $depends_lib
-            registry_register_deps $depends_lib $name
+        xpkg {
+            system "cd ${workpath} && [findBinary xar ${portutil::autoconf::xar_path}] -xf $location --compression=bzip2 +CONTENTS"
+            set twostep 1
         }
-        if {[info exists installPlist]} {
-            registry_prop_store $regref contents [registry_fileinfo_for_index $installPlist]
-            if { [registry_prop_retr $regref installtype] != "image" } {
-                registry_bulk_register_files [registry_fileinfo_for_index $installPlist] $name
+        zip {
+            set raw_contents [exec [findBinary unzip ${portutil::autoconf::unzip_path}] -p $location +CONTENTS]
+        }
+        cpgz {
+            system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rzf $location +CONTENTS"
+            set twostep 1
+        }
+        cpio {
+            system "cd ${workpath} && [findBinary pax ${portutil::autoconf::pax_path}] -rf $location +CONTENTS"
+            set twostep 1
+        }
+    }
+    if {[info exists twostep]} {
+        set fd [open "${workpath}/+CONTENTS"]
+        set raw_contents [read $fd]
+        close $fd
+    }
+    set contents {}
+    set ignore 0
+    set sep [file separator]
+    foreach line [split $raw_contents \n] {
+        if {$ignore} {
+            set ignore 0
+            continue
+        }
+        if {[string index $line 0] != "@"} {
+            lappend contents "${sep}${line}"
+        } elseif {$line == "@ignore"} {
+            set ignore 1
+        }
+    }
+    return $contents
+}
+
+proc portinstall::install_main {args} {
+    global subport version portpath categories description long_description \
+    homepage depends_run package-install workdir workpath \
+    worksrcdir UI_PREFIX destroot revision maintainers user_options \
+    portvariants negated_variants targets depends_lib PortInfo epoch license \
+    os.platform os.major portarchivetype installPlist
+
+    set oldpwd [pwd]
+    if {$oldpwd == ""} {
+        set oldpwd $portpath
+    }
+
+    # throws an error if an unsupported value has been configured
+    archiveTypeIsSupported $portarchivetype
+
+    set location [get_portimage_path]
+    if {![file isfile $location]} {
+        # 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} {
+        if {[info exists $deplist]} {
+            foreach dep [set $deplist] {
+                set dep_portname [_get_dep_port $dep]
+                if {$dep_portname != ""} {
+                    lappend dep_portnames $dep_portname
+                }
             }
         }
-        if {[info exists package-install]} {
-            registry_prop_store $regref package-install ${package-install}
+    }
+
+    registry::write {
+
+        set regref [registry::entry create $subport $version $revision $portvariants $epoch]
+
+        if {[info exists user_options(ports_requested)]} {
+            $regref requested $user_options(ports_requested)
+        } else {
+            $regref requested 0
         }
-        if {[info proc pkg_uninstall] == "pkg_uninstall"} {
-            registry_prop_store $regref pkg_uninstall [proc_disasm pkg_uninstall]
+        $regref os_platform ${os.platform}
+        $regref os_major ${os.major}
+        $regref archs [get_canonical_archs]
+        # Trick to have a portable GMT-POSIX epoch-based time.
+        $regref date [expr [clock scan now -gmt true] - [clock scan "1970-1-1 00:00:00" -gmt true]]
+        if {[info exists negated_variants]} {
+            $regref negated_variants $negated_variants
         }
 
-        registry_write $regref
+        foreach dep_portname $dep_portnames {
+            $regref depends $dep_portname
+        }
+
+        $regref installtype image
+        $regref state imaged
+        $regref location $location
+
+        if {[info exists installPlist]} {
+            # register files
+            $regref map $installPlist
+        }
+        
+        # store portfile
+        set fd [open [file join ${portpath} Portfile]]
+        $regref portfile [read $fd]
+        close $fd
     }
 
     _cd $oldpwd

Modified: branches/new-help-system/base/src/port1.0/portlint.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portlint.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portlint.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -43,6 +43,7 @@
     "homepage" \
     "master_sites" \
     "checksums" \
+    "license"
     ]
 
 set lint_optional [list \
@@ -89,8 +90,8 @@
 
 
 proc portlint::lint_start {args} {
-    global UI_PREFIX name
-    ui_notice "$UI_PREFIX [format [msgcat::mc "Verifying Portfile for %s"] ${name}]"
+    global UI_PREFIX subport
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Verifying Portfile for %s"] ${subport}]"
 }
 
 proc portlint::lint_main {args} {
@@ -130,6 +131,7 @@
     # read binary (to check UTF-8)
     fconfigure $f -encoding binary
     set lineno 1
+    set hashline false
     while {1} {
         set line [gets $f]
         if {[eof $f]} {
@@ -248,19 +250,40 @@
             }
         }
 
+        if {[string match "*adduser*" $line]} {
+            ui_warn "Line $lineno calling adduser directly; consider setting add_users instead"
+            incr warnings
+        }
+
         if {[regexp {(^|\s)configure\s+\{\s*\}} $line]} {
             ui_warn "Line $lineno should say \"use_configure no\" instead of declaring an empty configure phase"
             incr warnings
         }
 
         # Check for hardcoded version numbers
-        if {![regexp {^PortSystem|^PortGroup|^version} $line]
-                && ![regexp {^[a-z0-9]+\.setup} $line]
-                && [string first [option version] $line] != -1} {
-            ui_warn "Line $lineno seems to hardcode the version number, consider using \${version} instead"
-            incr warnings
+        if {$nitpick} {
+            # Support for skipping checksums lines
+            if {[regexp {^checksums} $line]} {
+                # We enter a series of one or more lines containing checksums
+                set hashline true
+            }
+    
+            if {!$hashline
+                    && ![regexp {^PortSystem|^PortGroup|^version} $line]
+                    && ![regexp {^[a-z0-9]+\.setup} $line]
+                    && [string first [option version] $line] != -1} {
+                ui_warn "Line $lineno seems to hardcode the version number, consider using \${version} instead"
+                incr warnings
+            }
+    
+            if {$hashline &&
+                ![string match \\\\ [string index $line end]]} {
+                    # if the last character is not a backslash we're done with
+                    # line skipping
+                    set hashline false
+            }
         }
-
+            
         ### TODO: more checks to Portfile syntax
 
         incr lineno
@@ -272,8 +295,9 @@
     global version revision epoch
     set portarch [get_canonical_archs]
     global description long_description platforms categories all_variants
-    global maintainers homepage master_sites checksums patchfiles
+    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
@@ -472,17 +496,80 @@
         incr errors
     }
 
-    if {[string match "*darwinports at opendarwin.org*" $maintainers]} {
-        ui_warn "Using legacy email address for no/open maintainer"
-        incr warnings
+    foreach addr $maintainers {
+        if {$addr == "nomaintainer at macports.org" ||
+                $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"
+            incr warnings
+        } elseif {$addr == "darwinports at opendarwin.org"} {
+            ui_warn "Using legacy email address for no/open maintainer"
+            incr warnings
+        } elseif [regexp "^(.+)@(.+)$" $addr -> localpart domain] {
+            ui_warn "Maintainer email address should be obfuscated as $domain:$localpart"
+            incr warnings
+        }
     }
 
-    if {[string match "*nomaintainer at macports.org*" $maintainers] ||
-        [string match "*openmaintainer at macports.org*" $maintainers]} {
-        ui_warn "Using full email address for no/open maintainer"
+    if {$license == "unknown"} {
+        ui_warn "no license set"
         incr warnings
+    } else {
+
+        # If maintainer set license, it must follow correct format
+
+        set prev ''
+        foreach test [split [string map { \{ '' \} ''} $license] '\ '] {
+            ui_debug "Checking format of license '${test}'"
+
+            # space instead of hyphen
+            if {[string is double -strict $test]} {
+                ui_error "Invalid license '${prev} ${test}': missing hyphen between ${prev} ${test}"
+
+            # missing hyphen
+            } elseif {![string equal -nocase "X11" $test]} {
+                foreach subtest [split $test '-'] {
+                    ui_debug "testing ${subtest}"
+
+                    # license names start with letters: versions and empty strings need not apply
+                    if {[string is alpha -strict [string index $subtest 0]]} {
+
+                        # if the last character of license name is a number or plus sign
+                        # then a hyphen is missing
+                        set license_end [string index $subtest end]
+                        if {[string equal "+" $license_end] || [string is integer -strict $license_end]} {
+                            ui_error "invalid license '${test}': missing hyphen before version"
+                        }
+                    }
+                }
+            }
+
+            # BSD-2 => BSD
+            if {[string equal -nocase "BSD-2" $test]} {
+                ui_error "Invalid license '${test}': use BSD instead"
+            }
+    
+            # BSD-3 => BSD
+            if {[string equal -nocase "BSD-3" $test]} {
+                ui_error "Invalid license '${test}': use BSD instead"
+            }
+    
+            # BSD-4 => BSD-old
+            if {[string equal -nocase "BSD-4" $test]} {
+                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"
@@ -530,8 +617,35 @@
     ui_debug "Version: $version"
     ui_debug "Revision: $revision"
     ui_debug "Archs: $portarch"
+
     ###################################################################
 
+    set svn_cmd ""
+    catch {set svn_cmd [findBinary svn]}
+    if {$svn_cmd != "" && ([file exists $portpath/.svn] || ![catch {exec $svn_cmd info $portpath > /dev/null 2>@1}])} {
+        ui_debug "Checking svn properties"
+        if [catch {exec $svn_cmd propget svn:keywords $portfile 2>@1} output] {
+            ui_warn "Unable to check for svn:keywords property: $output"
+        } else {
+            ui_debug "Property svn:keywords is \"$output\", should be \"Id\""
+            if {$output != "Id"} {
+                ui_error "Missing subversion property on Portfile, please execute: svn ps svn:keywords Id Portfile"
+                incr errors
+            }
+        }
+        if [catch {exec $svn_cmd propget svn:eol-style $portfile 2>@1} output] {
+            ui_warn "Unable to check for svn:eol-style property: $output"
+        } else {
+            ui_debug "Property svn:eol-style is \"$output\", should be \"native\""
+            if {$output != "native"} {
+                ui_error "Missing subversion property on Portfile, please execute: svn ps svn:eol-style native Portfile"
+                incr errors
+            }
+        }
+    }
+
+    ###################################################################
+
     ui_notice "$UI_PREFIX [format [msgcat::mc "%d errors and %d warnings found."] $errors $warnings]"
 
     return {$errors > 0}

Modified: branches/new-help-system/base/src/port1.0/portlivecheck.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portlivecheck.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portlivecheck.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,7 +3,8 @@
 #
 # $Id$
 #
-# Copyright (c) 2005-2006 Paul Guyot <pguyot at kallisys.net>,
+# Copyright (c) 2007-2011 The MacPorts Project
+# Copyright (c) 2005-2007 Paul Guyot <pguyot at kallisys.net>,
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its
+# 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.
 #
@@ -46,26 +47,23 @@
 }
 
 # define options
-options livecheck.url livecheck.type livecheck.check livecheck.md5 livecheck.regex livecheck.name livecheck.distname livecheck.version
+options livecheck.url livecheck.type livecheck.md5 livecheck.regex livecheck.name livecheck.distname livecheck.version livecheck.ignore_sslcert
 
 # defaults
 default livecheck.url {$homepage}
-default livecheck.check default
 default livecheck.type default
 default livecheck.md5 ""
 default livecheck.regex ""
 default livecheck.name default
 default livecheck.distname default
 default livecheck.version {$version}
+default livecheck.ignore_sslcert yes
 
-# Deprecation
-option_deprecate livecheck.check livecheck.type
-
 proc portlivecheck::livecheck_main {args} {
     global livecheck.url livecheck.type livecheck.md5 livecheck.regex livecheck.name livecheck.distname livecheck.version
-    global fetch.user fetch.password fetch.use_epsv fetch.ignore_sslcert
+    global livecheck.ignore_sslcert
     global homepage portpath workpath
-    global master_sites name distfiles
+    global master_sites name subport distfiles
 
     set updated 0
     set updated_version "unknown"
@@ -78,18 +76,10 @@
     ui_debug "Portfile modification date is [clock format $port_moddate]"
     ui_debug "Port (livecheck) version is ${livecheck.version}"
 
-    # Copied over from portfetch in parts
-    set fetch_options {}
-    if {[string length ${fetch.user}] || [string length ${fetch.password}]} {
-        lappend fetch_options -u
-        lappend fetch_options "${fetch.user}:${fetch.password}"
+    set curl_options {}
+    if [tbool livecheck.ignore_sslcert] {
+        lappend curl_options "--ignore-ssl-cert"
     }
-    if {${fetch.use_epsv} != "yes"} {
-        lappend fetch_options "--disable-epsv"
-    }
-    if {${fetch.ignore_sslcert} != "no"} {
-        lappend fetch_options "--ignore-ssl-cert"
-    }
 
     # Check _resources/port1.0/livecheck for available types.
     set types_dir [getdefaultportresourcepath "port1.0/livecheck"]
@@ -97,9 +87,9 @@
         return -code 1 "No available types were found. Check '$types_dir'."
     }
 
-    # Convert available_types from a list of files (e.g., { freshmeat.tcl
+    # Convert available_types from a list of files (e.g., { freecode.tcl
     # gnu.tcl ... }) into a string in the format "type|type|..." (e.g.,
-    # "freshmeat|gnu|...").
+    # "freecode|gnu|...").
     set available_types [regsub -all {\.tcl} [join $available_types |] {}]
 
     if {${livecheck.type} eq "default"} {
@@ -107,6 +97,14 @@
         if {$has_master_sites} {
             foreach {master_site} ${master_sites} {
                 if {[regexp "^($available_types)(?::(\[^:\]+))?" ${master_site} _ site subdir]} {
+                    set subdirs [split $subdir /]
+                    if {[llength $subdirs] > 1} {
+                        if {[lindex $subdirs 0] == "project"} {
+                            set subdir [lindex $subdirs 1]
+                        } else {
+                            set subdir ""
+                        }
+                    }
                     if {${subdir} ne "" && ${livecheck.name} eq "default"} {
                         set livecheck.name ${subdir}
                     }
@@ -148,8 +146,8 @@
         "regexm" {
             # single and multiline regex
             ui_debug "Fetching ${livecheck.url}"
-            if {[catch {eval curl fetch $fetch_options {${livecheck.url}} $tempfile} error]} {
-                ui_error "cannot check if $name was updated ($error)"
+            if {[catch {eval curl fetch $curl_options {${livecheck.url}} $tempfile} error]} {
+                ui_error "cannot check if $subport was updated ($error)"
                 set updated -1
             } else {
                 # let's extract the version from the file.
@@ -171,12 +169,15 @@
                     set updated_version 0
                     set foundmatch 0
                     while {[gets $chan line] >= 0} {
-                        if {[regexp $the_re $line matched upver]} {
+                        set lastoff 0
+                        while {[regexp -start $lastoff -indices $the_re $line offsets]} {
+                            regexp -start $lastoff $the_re $line matched upver
                             set foundmatch 1
-                            if {$updated_version == 0 || [rpm-vercomp $upver $updated_version] > 0} {
+                            if {$updated_version == 0 || [vercmp $upver $updated_version] > 0} {
                                 set updated_version $upver
                             }
                             ui_debug "The regex matched \"$matched\", extracted \"$upver\""
+                            lassign $offsets firstoff lastoff
                         }
                     }
                     if {$foundmatch == 1} {
@@ -191,14 +192,14 @@
                 }
                 close $chan
                 if {$updated < 0} {
-                    ui_error "cannot check if $name was updated (regex didn't match)"
+                    ui_error "cannot check if $subport was updated (regex didn't match)"
                 }
             }
         }
         "md5" {
             ui_debug "Fetching ${livecheck.url}"
-            if {[catch {eval curl fetch $fetch_options {${livecheck.url}} $tempfile} error]} {
-                ui_error "cannot check if $name was updated ($error)"
+            if {[catch {eval curl fetch $curl_options {${livecheck.url}} $tempfile} error]} {
+                ui_error "cannot check if $subport was updated ($error)"
                 set updated -1
             } else {
                 # let's compute the md5 sum.
@@ -212,7 +213,7 @@
         "moddate" {
             set port_moddate [file mtime ${portpath}/Portfile]
             if {[catch {set updated [curl isnewer ${livecheck.url} $port_moddate]} error]} {
-                ui_error "cannot check if $name was updated ($error)"
+                ui_error "cannot check if $subport was updated ($error)"
                 set updated -1
             } else {
                 if {!$updated} {
@@ -231,9 +232,9 @@
 
     if {${livecheck.type} != "none"} {
         if {$updated > 0} {
-            ui_msg "$name seems to have been updated (port version: ${livecheck.version}, new version: $updated_version)"
+            ui_msg "$subport seems to have been updated (port version: ${livecheck.version}, new version: $updated_version)"
         } elseif {$updated == 0} {
-            ui_info "$name seems to be up to date"
+            ui_info "$subport seems to be up to date"
         }
     }
 }

Modified: branches/new-help-system/base/src/port1.0/portload.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portload.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portload.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
 # portsubmit.tcl
 # $Id$
 #
-# Copyright (c) 2007 MacPorts Project
+# Copyright (c) 2007, 2009, 2011 The MacPorts Project
 # Copyright (c) 2007 James D. Berry
 # All rights reserved.
 #
@@ -14,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -36,6 +36,7 @@
 
 set org.macports.load [target_new org.macports.load portload::load_main]
 target_runtype ${org.macports.load} always
+target_state ${org.macports.load} no
 target_provides ${org.macports.load} load 
 target_requires ${org.macports.load} main
 
@@ -57,7 +58,7 @@
         } elseif {![file exists $path]} {
             return -code error [format [msgcat::mc "Launchd plist %s was not found"] $path]
         } else {
-            exec $launchctl_path load -w $path
+            exec $launchctl_path load -w $path 2>@stderr
         }
     }
     

Modified: branches/new-help-system/base/src/port1.0/portmain.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portmain.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portmain.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portmain.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2004 - 2005, 2007 - 2011 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -43,14 +44,20 @@
 namespace eval portmain {
 }
 
+set_ui_prefix
+
 # define options
-options prefix name version revision epoch categories maintainers
-options long_description description homepage notes license provides conflicts replaced_by
-options worksrcdir filesdir distname portdbpath libpath distpath sources_conf os.platform os.subplatform os.version os.major os.arch os.endian platforms default_variants install.user install.group macosx_deployment_target
-options universal_variant os.universal_supported
-options supported_archs depends_skip_archcheck
-options copy_log_files
-options compiler.cpath compiler.library_path
+options prefix name version revision epoch categories maintainers \
+        long_description description homepage notes license \
+        provides conflicts replaced_by \
+        worksrcdir filesdir distname portdbpath libpath distpath sources_conf \
+        os.platform os.subplatform os.version os.major os.arch os.endian \
+        platforms default_variants install.user install.group \
+        macosx_deployment_target universal_variant os.universal_supported \
+        supported_archs depends_skip_archcheck installs_libs \
+        license_noconflict copy_log_files \
+        compiler.cpath compiler.library_path \
+        add_users altprefix
 
 # Order of option_proc and option_export matters. Filter before exporting.
 
@@ -60,13 +67,30 @@
 option_proc notes handle_option_string
 
 # Export options via PortInfo
-options_export name version revision epoch categories maintainers platforms description long_description notes homepage license provides conflicts replaced_by
+options_export name version revision epoch categories maintainers platforms description long_description notes homepage license provides conflicts replaced_by installs_libs license_noconflict
 
-default workpath {[getportworkpath_from_buildpath $portbuildpath]}
+default subport {[portmain::get_default_subport]}
+proc portmain::get_default_subport {} {
+    global name portpath
+    if {[info exists name]} {
+        return $name
+    }
+    return [file tail $portpath]
+}
+default subbuildpath {[portmain::get_subbuildpath]}
+proc portmain::get_subbuildpath {} {
+    global portpath portbuildpath subport
+    if {$subport != ""} {
+        set subdir $subport
+    } else {
+        set subdir [file tail $portpath]
+    }
+    return [file join $portbuildpath $subdir]
+}
+default workpath {[getportworkpath_from_buildpath $subbuildpath]}
 default prefix /opt/local
 default applications_dir /Applications/MacPorts
 default frameworks_dir {${prefix}/Library/Frameworks}
-default developer_dir {[portmain::get_developer_dir]}
 default destdir destroot
 default destpath {${workpath}/${destdir}}
 # destroot is provided as a clearer name for the "destpath" variable
@@ -82,6 +106,7 @@
 # empty list means all archs are supported
 default supported_archs {}
 default depends_skip_archcheck {}
+default add_users {}
 
 # Configure settings
 default install.user {${portutil::autoconf::install_user}}
@@ -120,43 +145,15 @@
 default compiler.cpath {${prefix}/include}
 default compiler.library_path {${prefix}/lib}
 
-proc portmain::get_developer_dir {} {
-    if {![catch {binaryInPath xcode-select}]} {
-        return [exec xcode-select -print-path 2> /dev/null]
-    }
-    return "/Developer"
-}
-
 # start gsoc08-privileges
 
 # Record initial euid/egid
 set euid [geteuid]
 set egid [getegid]
 
-# resolve the alternate work path in ~/.macports
-proc portmain::set_altprefix {} {
-    global altprefix env euid
-
-    # do tilde expansion manually - Tcl won't expand tildes automatically for curl, etc.
-    if {[info exists env(HOME)]} {
-        # HOME environment var is set, use it.
-        set userhome "$env(HOME)"
-    } elseif {$euid == 0 && [info exists env(SUDO_USER)] && $env(SUDO_USER) != ""} {
-        set userhome [file normalize "~$env(SUDO_USER)"]
-    } else {
-        # the environment var isn't set, expand ~user instead
-        set username [uid_to_name [getuid]]
-        if {[catch {set userhome [file normalize "~$username"]}]} {
-            set userhome ""
-        }
-    }
-
-    set altprefix [file join $userhome .macports]
-}
-
 # if unable to write to workpath, implies running without either root privileges
 # or a shared directory owned by the group so use ~/.macports
-portmain::set_altprefix
+default altprefix {[file join $user_home .macports]}
 if { $euid != 0 && (([info exists workpath] && [file exists $workpath] && ![file writable $workpath]) || ([info exists portdbpath] && ![file writable [file join $portdbpath build]])) } {
 
     # set global variable indicating to other functions to use ~/.macports as well

Modified: branches/new-help-system/base/src/port1.0/portmirror.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portmirror.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portmirror.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,6 +3,7 @@
 #
 # $Id$
 #
+# Copyright (c) 2007-2011 The MacPorts Project
 # Copyright (c) 2006 Paul Guyot <pguyot at kallisys.net>,
 # All rights reserved.
 #
@@ -15,7 +16,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its
+# 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.
 #
@@ -52,7 +53,7 @@
 # It also records the path in a database.
 
 proc portmirror::mirror_main {args} {
-    global fetch.type name mirror_filemap ports_mirror_new portdbpath
+    global fetch.type mirror_filemap ports_mirror_new portdbpath
 
     set mirror_filemap_path [file join $portdbpath distfiles_mirror.db]
     if {![info exists mirror_filemap]
@@ -69,7 +70,7 @@
     if {"${fetch.type}" == "standard"} {
         # fetch the files.
         portfetch::fetch_init $args
-        #fetch_start
+        portfetch::fetch_start $args
         portfetch::fetch_main $args
 
         # checksum the files.

Modified: branches/new-help-system/base/src/port1.0/portpatch.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portpatch.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portpatch.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portpatch.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2003 Apple Computer, Inc.
+# Copyright (c) 2004, 2006-2007, 2009-2011 The MacPorts Project
+# Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #
@@ -75,7 +76,7 @@
         return 0
     }
 
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Applying patches to %s"] [option name]]"
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Applying patches to %s"] [option subport]]"
 
     foreach patch [option patchfiles] {
         set patch_file [getdistname $patch]
@@ -96,7 +97,7 @@
     set gzcat "[findBinary gzip $portutil::autoconf::gzip_path] -dc"
     set bzcat "[findBinary bzip2 $portutil::autoconf::bzip2_path] -dc"
     foreach patch $patchlist {
-        ui_info "$UI_PREFIX [format [msgcat::mc "Applying %s"] $patch]"
+        ui_info "$UI_PREFIX [format [msgcat::mc "Applying %s"] [file tail $patch]]"
         switch -- [file extension $patch] {
             .Z -
             .gz {command_exec patch "$gzcat \"$patch\" | (" ")"}

Modified: branches/new-help-system/base/src/port1.0/portstartupitem.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portstartupitem.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portstartupitem.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,7 +3,7 @@
 #
 # $Id$
 #
-# Copyright (c) 2004-2007 MacPorts Project
+# Copyright (c) 2004-2011 The MacPorts Project
 # Copyright (c) 2006-2007 James D. Berry
 # Copyright (c) 2004,2005 Markus W. Weissman <mww at macports.org>
 # All rights reserved.
@@ -17,7 +17,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its
+# 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.
 # 
@@ -74,7 +74,7 @@
 set_ui_prefix
 
 proc portstartupitem::startupitem_create_rcng {args} {
-    global prefix destroot name os.platform
+    global prefix destroot os.platform
     global startupitem.name startupitem.requires
     global startupitem.start startupitem.stop startupitem.restart
     global startupitem.type
@@ -120,7 +120,7 @@
 }
 
 proc portstartupitem::startupitem_create_darwin_systemstarter {args} {
-    global UI_PREFIX prefix destroot destroot.keepdirs name os.platform
+    global UI_PREFIX prefix destroot destroot.keepdirs subport os.platform
     global startupitem.name startupitem.requires startupitem.init
     global startupitem.start startupitem.stop startupitem.restart startupitem.executable
     global startupitem.pidfile startupitem.logfile startupitem.logevents
@@ -181,10 +181,10 @@
         # An executable is specified, and there is no init, start, stop, or restart
     } else {
         if { ![llength ${startupitem.start} ] } {
-            set startupitem.start [list "sh ${scriptdir}/${name}.sh start"]
+            set startupitem.start [list "sh ${scriptdir}/${subport}.sh start"]
         }
         if { ![llength ${startupitem.stop} ] } {
-            set startupitem.stop [list "sh ${scriptdir}/${name}.sh stop"]
+            set startupitem.stop [list "sh ${scriptdir}/${subport}.sh stop"]
         }
     }
     if { ![llength ${startupitem.requires} ] } {
@@ -197,12 +197,16 @@
     ########################
     # Create the startup item directory
     file mkdir ${startupItemDir}
-    file attributes ${startupItemDir} -owner root -group wheel
+    if {[getuid] == 0} {
+        file attributes ${startupItemDir} -owner root -group wheel
+    }
     
     ########################
     # Generate the startup item script
     set item [open "${startupItemScript}" w 0755]
-    file attributes "${startupItemScript}" -owner root -group wheel
+    if {[getuid] == 0} {
+        file attributes "${startupItemScript}" -owner root -group wheel
+    }
     
     # Emit the header
     puts ${item} {#!/bin/sh
@@ -366,7 +370,9 @@
     ########################
     # Generate the plist
     set para [open "${startupItemPlist}" w 0644]
-    file attributes "${startupItemPlist}" -owner root -group wheel
+    if {[getuid] == 0} {
+        file attributes "${startupItemPlist}" -owner root -group wheel
+    }
     
     puts ${para} "\{"
     puts ${para} "\tDescription\t= \"${itemname}\";"
@@ -379,21 +385,22 @@
     close ${para}
     
     # Emit some information for the user
-    ui_msg "###########################################################"
-    ui_msg "# A startup item has been generated that will aid in"
-    ui_msg "# starting ${name} with SystemStarter. It is disabled"
-    ui_msg "# by default. Add the following line to /etc/hostconfig"
-    ui_msg "# or ${prefix}/etc/rc.conf to start it at startup:"
-    ui_msg "#"
-    ui_msg "# ${uppername}=-YES-"
-    ui_msg "###########################################################"
+    ui_notice "###########################################################"
+    ui_notice "# A startup item has been generated that will aid in"
+    ui_notice "# starting ${subport} with SystemStarter. It is disabled"
+    ui_notice "# by default. Add the following line to /etc/hostconfig"
+    ui_notice "# or ${prefix}/etc/rc.conf to start it at startup:"
+    ui_notice "#"
+    ui_notice "# ${uppername}=-YES-"
+    ui_notice "###########################################################"
 }
 
 proc portstartupitem::startupitem_create_darwin_launchd {args} {
-    global UI_PREFIX prefix destroot destroot.keepdirs name os.platform
+    global UI_PREFIX prefix destroot destroot.keepdirs subport macosx_deployment_target
     global startupitem.name startupitem.uniquename startupitem.plist startupitem.location
     global startupitem.init startupitem.start startupitem.stop startupitem.restart startupitem.executable
     global startupitem.pidfile startupitem.logfile startupitem.logevents startupitem.netchange
+    global startupitem.install
 
     set scriptdir ${prefix}/etc/startup
     
@@ -408,7 +415,9 @@
                         ]
     
     file mkdir ${destroot}${itemdir}
-    file attributes ${destroot}${itemdir} -owner root -group wheel
+    if {[getuid] == 0} {
+        file attributes ${destroot}${itemdir} -owner root -group wheel
+    }
         
     if { [llength ${startupitem.executable}] && 
       ![llength ${startupitem.init}] &&
@@ -429,10 +438,10 @@
         set wrapper         "${itemdir}/${wrappername}"
 
         if { ![llength ${startupitem.start}] } {
-            set startupitem.start [list "sh ${scriptdir}/${name}.sh start"]
+            set startupitem.start [list "sh ${scriptdir}/${subport}.sh start"]
         }
         if { ![llength ${startupitem.stop}] } {
-            set startupitem.stop [list "sh ${scriptdir}/${name}.sh stop"]
+            set startupitem.stop [list "sh ${scriptdir}/${subport}.sh stop"]
         }
         if { ![llength ${startupitem.restart}] } {
             set startupitem.restart [list Stop Start]
@@ -445,7 +454,9 @@
 
         # Create the wrapper script
         set item [open "${destroot}${wrapper}" w 0755]
-        file attributes "${destroot}${wrapper}" -owner root -group wheel
+        if {[getuid] == 0} {
+            file attributes "${destroot}${wrapper}" -owner root -group wheel
+        }
 
         puts ${item} "#!/bin/sh"
         puts ${item} "#"
@@ -563,7 +574,7 @@
     set plist [open "${destroot}${itemdir}/${plistname}" w 0644]
     
     puts ${plist} "<?xml version='1.0' encoding='UTF-8'?>"
-    puts ${plist} "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\""
+    puts ${plist} "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\""
     puts ${plist} "\"http://www.apple.com/DTDs/PropertyList-1.0.dtd\" >"
     puts ${plist} "<plist version='1.0'>"
     puts ${plist} "<dict>"
@@ -577,7 +588,11 @@
     
     puts ${plist} "<key>Debug</key><false/>"
     puts ${plist} "<key>Disabled</key><true/>"
-    puts ${plist} "<key>OnDemand</key><false/>"
+    if {$macosx_deployment_target != "10.4"} {
+        puts ${plist} "<key>KeepAlive</key><true/>"
+    } else {
+        puts ${plist} "<key>OnDemand</key><false/>"
+    }
     
     if { [llength ${startupitem.logfile}] } {
         puts ${plist} "<key>StandardOutPath</key><string>${startupitem.logfile}</string>"
@@ -588,8 +603,8 @@
 
     close ${plist}
 
-    # Make a symlink to the plist file
-    if {[getuid] == 0} {
+    if { [getuid] == 0 && 
+      ${startupitem.install} != "no" } {
         file mkdir "${destroot}/Library/${daemondest}"
         ln -sf "${itemdir}/${plistname}" "${destroot}/Library/${daemondest}"
     }
@@ -597,23 +612,23 @@
     # If launchd is not available, warn the user
     set haveLaunchd ${portutil::autoconf::have_launchd}
     if {![tbool haveLaunchd]} {
-        ui_msg "###########################################################"
-        ui_msg "# WARNING:"
-        ui_msg "# We're building a launchd startup item, but launchd wasn't"
-        ui_msg "# found by configure. Are you sure you didn't mess up your"
-        ui_msg "# macports.conf settings?"
-        ui_msg "###########################################################"
+        ui_notice "###########################################################"
+        ui_notice "# WARNING:"
+        ui_notice "# We're building a launchd startup item, but launchd wasn't"
+        ui_notice "# found by configure. Are you sure you didn't mess up your"
+        ui_notice "# macports.conf settings?"
+        ui_notice "###########################################################"
     }
     
     # Emit some information for the user
-    ui_msg "###########################################################"
-    ui_msg "# A startup item has been generated that will aid in"
-    ui_msg "# starting ${name} with launchd. It is disabled"
-    ui_msg "# by default. Execute the following command to start it,"
-    ui_msg "# and to cause it to launch at startup:"
-    ui_msg "#"
-    ui_msg "# sudo port load ${name}"
-    ui_msg "###########################################################"
+    ui_notice "###########################################################"
+    ui_notice "# A startup item has been generated that will aid in"
+    ui_notice "# starting ${subport} with launchd. It is disabled"
+    ui_notice "# by default. Execute the following command to start it,"
+    ui_notice "# and to cause it to launch at startup:"
+    ui_notice "#"
+    ui_notice "# sudo port load ${subport}"
+    ui_notice "###########################################################"
 }
 
 proc portstartupitem::startupitem_create {args} {
@@ -640,9 +655,9 @@
     }
 
     if { ${startupitem.type} == "none" } {
-        ui_msg "$UI_PREFIX [msgcat::mc "Skipping creation of control script"]"
+        ui_notice "$UI_PREFIX [msgcat::mc "Skipping creation of control script"]"
     } else {
-        ui_msg "$UI_PREFIX [msgcat::mc "Creating ${startupitem.type} control script"]"
+        ui_notice "$UI_PREFIX [msgcat::mc "Creating ${startupitem.type} control script"]"
 
         switch -- ${startupitem.type} {
             launchd         { startupitem_create_darwin_launchd }

Modified: branches/new-help-system/base/src/port1.0/portsubmit.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portsubmit.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portsubmit.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,8 @@
 # portsubmit.tcl
 # $Id$
 #
-# Copyright (c) 2002 - 2004 Apple Computer, Inc.
+# Copyright (c) 2007 - 2011 The MacPorts Project
+# Copyright (c) 2002 - 2004 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -13,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #
@@ -83,7 +84,7 @@
     set cmd [join $args]
 
     if {[tbool portverbose]} {
-        ui_msg "Submitting portpkg $pkgpath for $name to $submiturl"
+        ui_notice "Submitting portpkg $pkgpath for $name to $submiturl"
     }
 
     # Invoke curl to do the submit
@@ -104,16 +105,16 @@
 
     # Interpret and act on the result
     if {[info exists result(MESSAGE)] && [tbool portverbose]} {
-        ui_msg $result(MESSAGE)
+        ui_notice $result(MESSAGE)
     }
     if {[info exists result(STATUS)]} {
         if { $result(STATUS) == 0 } {
-            ui_msg "Submitted portpkg for $name"
+            ui_notice "Submitted portpkg for $name"
             if {[info exists result(DOWNLOAD_URL)]} {
-                ui_msg "    download URL => $result(DOWNLOAD_URL)"
+                ui_notice "    download URL => $result(DOWNLOAD_URL)"
             }
             if {[info exists result(HUMAN_URL)]} {
-                ui_msg "    human readable URL => $result(HUMAN_URL)"
+                ui_notice "    human readable URL => $result(HUMAN_URL)"
             }
         } else {
             return -code error [format [msgcat::mc "Status %d reported during submit of port %s"] $result(STATUS) $name]
@@ -152,13 +153,13 @@
         close $fd
     }
     if {$portsource == ""} {
-        ui_msg "$UI_PREFIX Submitting $name-$version"
+        ui_notice "$UI_PREFIX Submitting $name-$version"
         puts -nonewline "URL: "
         flush stdout
         gets stdin portsource
     }
 
-    ui_msg "$UI_PREFIX Submitting $name-$version to $portsource"
+    ui_notice "$UI_PREFIX Submitting $name-$version to $portsource"
 
     puts -nonewline "Username: "
     flush stdout
@@ -222,8 +223,8 @@
         puts $fd "revision: $result(revision)"
         close $fd
 
-        ui_msg "$name-$version submitted successfully."
-        ui_msg "New revision: $result(revision)"
+        ui_notice "$name-$version submitted successfully."
+        ui_notice "New revision: $result(revision)"
     } elseif {[info exists result(ERROR)]} {
         return -code error $result(ERROR)
     } elseif {[info exists result(CONFLICT)]} {
@@ -232,9 +233,9 @@
         set tmpdir [mktemp "/tmp/mports.XXXXXXXX"]
         file mkdir $tmpdir/new
         file mkdir $tmpdir/old
-        set worker [mport_open $portsource/files/$name/$version/$result(revision)/Portfile.tar.gz [list portdir $tmpdir/new]]
+        set worker [mport_open $portsource/files/$name/$version/$result(revision)/Portfile.tar.gz [list portdir $tmpdir/new subport $name]]
         if {$base_rev != ""} {
-            set worker2 [mport_open $portsource/files/$name/$version/$base_rev/Portfile.tar.gz [list portdir $tmpdir/old]]
+            set worker2 [mport_open $portsource/files/$name/$version/$base_rev/Portfile.tar.gz [list portdir $tmpdir/old subport $name]]
             catch {system "diff3 -m -E -- $portpath/Portfile $tmpdir/old/$name-$version/Portfile $tmpdir/new/$name-$version/Portfile > $tmpdir/Portfile"}
             file rename -force "${tmpdir}/Portfile" "${portpath}/Portfile"
             mport_close $worker2

Modified: branches/new-help-system/base/src/port1.0/porttest.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/porttest.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/porttest.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -26,16 +26,16 @@
 set_ui_prefix
 
 proc porttest::test_start {args} {
-    global UI_PREFIX name
-    ui_msg "$UI_PREFIX [format [msgcat::mc "Testing %s"] ${name}]"
+    global UI_PREFIX subport
+    ui_notice "$UI_PREFIX [format [msgcat::mc "Testing %s"] ${subport}]"
 }
 
 proc porttest::test_main {args} {
-    global name test.run
+    global subport test.run
     if {[tbool test.run]} {
         command_exec test
     } else {
-    return -code error [format [msgcat::mc "%s has no tests turned on. see 'test.run' in portfile(7)"] $name]
+    return -code error [format [msgcat::mc "%s has no tests turned on. see 'test.run' in portfile(7)"] $subport]
     }
     return 0
 }

Modified: branches/new-help-system/base/src/port1.0/porttrace.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/porttrace.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/porttrace.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -15,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its
+# 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.
 #

Modified: branches/new-help-system/base/src/port1.0/portuninstall.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portuninstall.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portuninstall.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
 # portuninstall.tcl
 # $Id$
 #
-# Copyright (c) 2010 The MacPorts Project
+# Copyright (c) 2010-2011 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -50,14 +50,14 @@
 
 proc portuninstall::uninstall_start {args} {
     global prefix
-    if { ![file writable $prefix] } {
+    if {![file writable $prefix] || ([getuid] == 0 && [geteuid] != 0)} {
         # if install location is not writable, need root privileges
         elevateToRoot "uninstall"
     }
 }
 
 proc portuninstall::uninstall_main {args} {
-    global name version revision portvariants user_options
-    registry_uninstall $name "${version}_${revision}${portvariants}" [array get user_options]
+    global subport version revision portvariants user_options
+    registry_uninstall $subport $version $revision $portvariants [array get user_options]
     return 0
 }

Modified: branches/new-help-system/base/src/port1.0/portunload.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portunload.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portunload.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,7 +2,7 @@
 # portsubmit.tcl
 # $Id$
 #
-# Copyright (c) 2007 MacPorts Project
+# Copyright (c) 2007, 2009, 2011 The MacPorts Project
 # Copyright (c) 2007 James D. Berry
 # All rights reserved.
 #
@@ -14,7 +14,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -36,6 +36,7 @@
 
 set org.macports.unload [target_new org.macports.unload portunload::unload_main]
 target_runtype ${org.macports.unload} always
+target_state ${org.macports.unload} no
 target_provides ${org.macports.unload} unload 
 target_requires ${org.macports.unload} main
 
@@ -57,7 +58,7 @@
         } elseif {![file exists $path]} {
             return -code error [format [msgcat::mc "Launchd plist %s was not found"] $path]
         } else {
-            exec $launchctl_path unload -w $path
+            exec $launchctl_path unload -w $path 2>@stderr
         }
     }
     

Modified: branches/new-help-system/base/src/port1.0/portutil.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/portutil.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/portutil.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,9 +2,10 @@
 # portutil.tcl
 # $Id$
 #
+# Copyright (c) 2002-2003 Apple Inc.
 # Copyright (c) 2004 Robert Shaw <rshaw at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
-# Copyright (c) 2006, 2007 Markus W. Weissmann <mww at macports.org>
+# Copyright (c) 2006-2007 Markus W. Weissmann <mww at macports.org>
+# Copyright (c) 2004-2012 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 #
@@ -131,11 +132,11 @@
 }
 
 ##
-# Handle option-replace
+# Handle option-strsed
 #
 # @param option name of the option
 # @param args arguments
-proc handle_option-replace {option args} {
+proc handle_option-strsed {option args} {
     global $option user_options option_procs
 
     if {![info exists user_options($option)] && [info exists $option]} {
@@ -147,6 +148,36 @@
     }
 }
 
+##
+# Handle option-replace
+#
+# @param option name of the option
+# @param args arguments
+proc handle_option-replace {option args} {
+    global $option user_options option_procs deprecated_options
+
+    # Deprecate -replace with only one argument, for backwards compatibility call -strsed
+    # XXX: Remove this in 2.2.0
+    if {[llength $args] == 1} {
+        if {![info exists deprecated_options(${option}-replace)]} {
+            set deprecated_options(${option}-replace) [list ${option}-strsed 0]
+        }
+        set refcount [lindex $deprecated_options(${option}-replace) 1]
+        lset deprecated_options(${option}-replace) 1 [expr $refcount + 1]
+        return [eval handle_option-strsed $option $args]
+    }
+
+    if {![info exists user_options($option)] && [info exists $option]} {
+        foreach {old new} $args {
+            set index [lsearch -exact [set $option] $old]
+            if {$index == -1} {
+                continue
+            }
+            set $option [lreplace [set $option] $index $index $new]
+        }
+    }
+}
+
 # options
 # Exports options in an array as externally callable procedures
 # Thus, "options name date" would create procedures named "name"
@@ -159,6 +190,7 @@
         interp alias {} $option {} handle_option $option
         interp alias {} $option-append {} handle_option-append $option
         interp alias {} $option-delete {} handle_option-delete $option
+        interp alias {} $option-strsed {} handle_option-strsed $option
         interp alias {} $option-replace {} handle_option-replace $option
     }
 }
@@ -198,13 +230,13 @@
 # @param action read/set
 # @param value ignored
 proc handle_deprecated_option {option action {value ""}} {
-    global name $option deprecated_options
+    global subport $option deprecated_options
     set newoption [lindex $deprecated_options($option) 0]
     set refcount  [lindex $deprecated_options($option) 1]
     global $newoption
 
     if {$newoption == ""} {
-        ui_warn "Port $name using deprecated option \"$option\"."
+        ui_warn "Port $subport using deprecated option \"$option\"."
         return
     }
 
@@ -323,12 +355,13 @@
 }
 
 # Given a command name, execute it with the options.
-# command_exec command [-notty] [command_prefix [command_suffix]]
+# command_exec command [-notty] [-varprefix variable_prefix] [command_prefix [command_suffix]]
 # command           name of the command
+# variable_prefix   name of the variable prefix to use (defaults to command)
 # command_prefix    additional command prefix (typically pipe command)
 # command_suffix    additional command suffix (typically redirection)
 proc command_exec {command args} {
-    global ${command}.env ${command}.env_array ${command}.nice env macosx_version
+    set varprefix "${command}"
     set notty ""
     set command_prefix ""
     set command_suffix ""
@@ -339,6 +372,11 @@
             set args [lrange $args 1 end]
         }
 
+        if {[lindex $args 0] == "-varprefix"} {
+            set varprefix [lindex $args 1]
+            set args [lrange $args 2 end]
+        }
+
         if {[llength $args] > 0} {
             set command_prefix [lindex $args 0]
             if {[llength $args] > 1} {
@@ -347,33 +385,39 @@
         }
     }
 
+    global ${varprefix}.env ${varprefix}.env_array ${varprefix}.nice env macosx_version
+
     # Set the environment.
     # If the array doesn't exist, we create it with the value
-    # coming from ${command}.env
+    # coming from ${varprefix}.env
     # Otherwise, it means the caller actually played with the environment
     # array already (e.g. configure flags).
-    if {![array exists ${command}.env_array]} {
-        parse_environment ${command}
+    if {![array exists ${varprefix}.env_array]} {
+        parse_environment ${varprefix}
     }
     if {[option macosx_deployment_target] ne ""} {
-        set ${command}.env_array(MACOSX_DEPLOYMENT_TARGET) [option macosx_deployment_target]
+        set ${varprefix}.env_array(MACOSX_DEPLOYMENT_TARGET) [option macosx_deployment_target]
     }
-    set ${command}.env_array(CC_PRINT_OPTIONS) "YES"
-    set ${command}.env_array(CC_PRINT_OPTIONS_FILE) [file join [option workpath] ".CC_PRINT_OPTIONS"]
+    set ${varprefix}.env_array(CC_PRINT_OPTIONS) "YES"
+    set ${varprefix}.env_array(CC_PRINT_OPTIONS_FILE) [file join [option workpath] ".CC_PRINT_OPTIONS"]
     if {[option compiler.cpath] ne ""} {
-        set ${command}.env_array(CPATH) [join [option compiler.cpath] :]
+        set ${varprefix}.env_array(CPATH) [join [option compiler.cpath] :]
     }
     if {[option compiler.library_path] ne ""} {
-        set ${command}.env_array(LIBRARY_PATH) [join [option compiler.library_path] :]
+        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 ${command}.env_array]"
+    ui_debug "Environment: [environment_array_to_string ${varprefix}.env_array]"
 
     # Prepare nice value change
     set nice ""
-    if {[info exists ${command}.nice] && [set ${command}.nice] != ""} {
-        set nice "-nice [set ${command}.nice]"
+    if {[info exists ${varprefix}.nice] && [set ${varprefix}.nice] != ""} {
+        set nice "-nice [set ${varprefix}.nice]"
     }
 
     # Get the command string.
@@ -384,13 +428,17 @@
     # Save the environment.
     array set saved_env [array get env]
     # Set the overriden variables from the portfile.
-    array set env [array get ${command}.env_array]
+    array set env [array get ${varprefix}.env_array]
     # Call the command.
     set fullcmdstring "$command_prefix $cmdstring $command_suffix"
+    ui_debug "Executing command line: $fullcmdstring"
     set code [catch {eval system $notty $nice \$fullcmdstring} result]
+    # Save variables in order to re-throw the same error code.
+    set errcode $::errorCode
+    set errinfo $::errorInfo
 
     # Unset the command array until next time.
-    array unset ${command}.env_array
+    array unset ${varprefix}.env_array
 
     # Restore the environment.
     array unset env *
@@ -400,7 +448,7 @@
     array set env [array get saved_env]
 
     # Return as if system had been called directly.
-    return -code $code $result
+    return -code $code -errorcode $errcode -errorInfo $errinfo $result
 }
 
 # default
@@ -740,6 +788,20 @@
     }
 }
 
+# Portfiles may define more than one port.
+# 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} {
+        lappend PortInfo(subports) $subname
+    }
+    if {[string equal -nocase $subname $subport]} {
+        set PortInfo(name) $subname
+        uplevel 1 $body
+    }
+}
+
 ########### Environment utility functions ###########
 
 # Parse the environment string of a command, storing the values into the
@@ -857,15 +919,31 @@
 # Provides "sed in place" functionality
 proc reinplace {args}  {
 
+    global env
     set extended 0
+    set suppress 0
+    set oldlocale_exists 0
+    set oldlocale "" 
+    set locale ""
     while 1 {
         set arg [lindex $args 0]
         if {[string index $arg 0] eq "-"} {
             set args [lrange $args 1 end]
             switch -- [string range $arg 1 end] {
+                locale {
+                    set oldlocale_exists [info exists env(LC_CTYPE)]
+                    if {$oldlocale_exists} {
+                        set oldlocale $env(LC_CTYPE)
+                    }
+                    set locale [lindex $args 0]
+                    set args [lrange $args 1 end]
+                }
                 E {
                     set extended 1
                 }
+                n {
+                    set suppress 1
+                }
                 - {
                     break
                 }
@@ -904,23 +982,43 @@
             }
             lappend cmdline $portutil::autoconf::sed_ext_flag
         }
+        if {$suppress} {
+            lappend cmdline -n
+        }
         set cmdline [concat $cmdline [list $pattern < $file >@ $tmpfd]]
+        if {$locale != ""} {
+            set env(LC_CTYPE) $locale
+        }
         if {[catch {eval exec $cmdline} error]} {
             global errorInfo
             ui_debug "$errorInfo"
             ui_error "reinplace: $error"
             file delete "$tmpfile"
+            if {$locale != ""} {
+                if {$oldlocale_exists} {
+                    set env(LC_CTYPE) $oldlocale
+                } else {
+                    unset env(LC_CTYPE)
+                }
+            }
             close $tmpfd
             return -code error "reinplace sed(1) failed"
         }
 
+        if {$locale != ""} {
+            if {$oldlocale_exists} {
+                set env(LC_CTYPE) $oldlocale
+            } else {
+                unset env(LC_CTYPE)
+            }
+        }
         close $tmpfd
 
+        set attributes [file attributes $file]
         # start gsoc08-privileges
         chownAsRoot $file
         # end gsoc08-privileges
 
-        set attributes [file attributes $file]
         # We need to overwrite this file
         if {[catch {file attributes $file -permissions u+w} error]} {
             global errorInfo
@@ -947,7 +1045,7 @@
 
 # delete
 # file delete -force by itself doesn't handle directories properly
-# on systems older than Tiger. Lets recurse using fs-traverse instead
+# on systems older than Tiger. Let's recurse using fs-traverse instead.
 proc delete {args} {
     ui_debug "delete: $args"
     fs-traverse -depth file $args {
@@ -1027,8 +1125,7 @@
     # do we have any files to process?
     if {[llength $args] == 0} {
         # print usage
-        ui_msg {usage: touch [-a] [-c] [-m] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...}
-        return
+        return -code error {usage: touch [-a] [-c] [-m] [-r file] [-t [[CC]YY]MMDDhhmm[.SS]] file ...}
     }
 
     foreach file $args {
@@ -1085,9 +1182,8 @@
     }
 
     if {[llength $args] == 0} {
-        ui_msg {usage: ln [-f] [-h] [-s] [-v] source_file [target_file]}
-        ui_msg {       ln [-f] [-h] [-s] [-v] file ... directory}
-        return
+        return -code error [join {{usage: ln [-f] [-h] [-s] [-v] source_file [target_file]}
+                                  {       ln [-f] [-h] [-s] [-v] file ... directory}} "\n"]
     } elseif {[llength $args] == 1} {
         set files $args
         set target ./
@@ -1119,13 +1215,13 @@
             if {![file exists $linktarget]} {
                 return -code error "ln: $linktarget: No such file or directory"
             } elseif {![file isdirectory $target]} {
-                # this error isn't striclty what BSD ln gives, but I think it's more useful
+                # this error isn't strictly what BSD ln gives, but I think it's more useful
                 return -code error "ln: $target: Not a directory"
             }
         }
 
         if {[info exists options(v)]} {
-            ui_msg "ln: $linktarget -> $file"
+            ui_notice "ln: $linktarget -> $file"
         }
         if {[info exists options(s)]} {
             symlink $file $linktarget
@@ -1208,11 +1304,14 @@
 set ports_dry_last_skipped ""
 
 proc target_run {ditem} {
-    global target_state_fd workpath portpath ports_trace PortInfo ports_dryrun ports_dry_last_skipped worksrcpath prefix
-    set portname [option name]
+    global target_state_fd workpath portpath ports_trace PortInfo ports_dryrun \
+           ports_dry_last_skipped worksrcpath prefix subport env portdbpath
+    set portname $subport
     set result 0
     set skipped 0
     set procedure [ditem_key $ditem procedure]
+    set savedhome [file join $portdbpath home]
+    set env(HOME) "${workpath}/.home"
 
     if {[ditem_key $ditem state] != "no"} {
         set target_state_fd [open_statefile]
@@ -1228,6 +1327,9 @@
 
         if {[ditem_contains $ditem init]} {
             set result [catch {[ditem_key $ditem init] $targetname} errstr]
+            # Save variables in order to re-throw the same error code.
+            set errcode $::errorCode
+            set errinfo $::errorInfo
         }
 
         if {$result == 0} {
@@ -1243,7 +1345,7 @@
             if {[info exists ports_dryrun] && $ports_dryrun == "yes"} {
                 # only one message per portname
                 if {$portname != $ports_dry_last_skipped} {
-                    ui_msg "For $portname: skipping $targetname (dry run)"
+                    ui_notice "For $portname: skipping $targetname (dry run)"
                     set ports_dry_last_skipped $portname
                 } else {
                     ui_info "    .. and skipping $targetname"
@@ -1253,13 +1355,17 @@
 
             # otherwise execute the task.
             if {$skipped == 0} {
-                set target [ditem_key $ditem provides]
+                # change current phase shown in log
+                set_phase $target
 
                 # Execute pre-run procedure
                 if {[ditem_contains $ditem prerun]} {
                     set result [catch {[ditem_key $ditem prerun] $targetname} errstr]
+                    # Save variables in order to re-throw the same error code.
+                    set errcode $::errorCode
+                    set errinfo $::errorInfo
                 }
-                set_phase  $target
+
                 #start tracelib
                 if {($result ==0
                   && [info exists ports_trace]
@@ -1291,7 +1397,6 @@
                         test        -
                         destroot    -
                         install     -
-                        archive     -
                         dmg         -
                         pkg         -
                         portpkg     -
@@ -1332,19 +1437,28 @@
                     foreach pre [ditem_key $ditem pre] {
                         ui_debug "Executing $pre"
                         set result [catch {$pre $targetname} errstr]
+                        # Save variables in order to re-throw the same error code.
+                        set errcode $::errorCode
+                        set errinfo $::errorInfo
                         if {$result != 0} { break }
                     }
                 }
 
                 if {$result == 0} {
-                ui_debug "Executing $targetname ($portname)"
-                set result [catch {$procedure $targetname} errstr]
+                    ui_debug "Executing $targetname ($portname)"
+                    set result [catch {$procedure $targetname} errstr]
+                    # Save variables in order to re-throw the same error code.
+                    set errcode $::errorCode
+                    set errinfo $::errorInfo
                 }
 
                 if {$result == 0} {
                     foreach post [ditem_key $ditem post] {
                         ui_debug "Executing $post"
                         set result [catch {$post $targetname} errstr]
+                        # Save variables in order to re-throw the same error code.
+                        set errcode $::errorCode
+                        set errinfo $::errorInfo
                         if {$result != 0} { break }
                     }
                 }
@@ -1353,6 +1467,9 @@
                     set postrun [ditem_key $ditem postrun]
                     ui_debug "Executing $postrun"
                     set result [catch {$postrun $targetname} errstr]
+                    # Save variables in order to re-throw the same error code.
+                    set errcode $::errorCode
+                    set errinfo $::errorInfo
                 }
 
                 # Check dependencies & file creations outside workpath.
@@ -1371,7 +1488,7 @@
         }
         if {[exists copy_log_files]} {
             set log_files [option copy_log_files]
-            set log_dir [getportlogpath $portpath]
+            set log_dir [getportlogpath $portpath $subport]
             file mkdir $log_dir
  
             foreach log_file $log_files {
@@ -1392,9 +1509,9 @@
             write_statefile target $targetname $target_state_fd
             }
         } else {
-            global errorInfo
-            ui_error "Target $targetname returned: $errstr"
-            ui_debug "Backtrace: $errorInfo"
+            ui_error "$targetname for port $portname returned: $errstr"
+            ui_debug "Error code: $errcode"
+            ui_debug "Backtrace: $errinfo"
             set result 1
         }
 
@@ -1407,6 +1524,8 @@
         close $target_state_fd
     }
 
+    set env(HOME) $savedhome
+
     return $result
 }
 
@@ -1449,20 +1568,20 @@
 
 
 proc eval_targets {target} {
-    global targets target_state_fd name version revision portvariants epoch ports_dryrun user_options
+    global targets target_state_fd subport version revision portvariants epoch ports_dryrun user_options
     set dlist $targets
 
     # the statefile will likely be autocleaned away after install,
     # so special-case already-completed install and activate
-    if {[registry_exists $name $version $revision $portvariants]} {
+    if {[registry_exists $subport $version $revision $portvariants]} {
         if {$target == "install"} {
-            ui_debug "Skipping $target ($name) since this port is already installed"
+            ui_debug "Skipping $target ($subport) since this port is already installed"
             return 0
         } elseif {$target == "activate"} {
-            set regref [registry_open $name $version $revision $portvariants $epoch]
+            set regref [registry_open $subport $version $revision $portvariants ""]
             if {[registry_prop_retr $regref active] != 0} {
                 # Something to close the registry entry may be called here, if it existed.
-                ui_debug "Skipping $target ($name @${version}_${revision}${portvariants}) since this port is already active"
+                ui_debug "Skipping $target ($subport @${version}_${revision}${portvariants}) since this port is already active"
                 return 0
             } else {
                 # run the activate target but ignore its (completed) dependencies
@@ -1496,7 +1615,7 @@
 
     if {[llength $dlist] > 0} {
         # somebody broke!
-        set errstring "Warning: the following items did not execute (for $name):"
+        set errstring "Warning: targets not executed for $subport:"
         foreach ditem $dlist {
             append errstring " [ditem_key $ditem name]"
         }
@@ -1512,8 +1631,8 @@
 # open_statefile
 # open file to store name of completed targets
 proc open_statefile {args} {
-    global workpath worksymlink place_worksymlink name portpath ports_ignore_older ports_dryrun
-    global usealtworkpath altprefix env applications_dir portbuildpath
+    global workpath worksymlink place_worksymlink subport portpath ports_ignore_older ports_dryrun \
+           usealtworkpath altprefix env applications_dir subbuildpath
 
     if {$usealtworkpath} {
          ui_warn_once "privileges" "MacPorts running without privileges.\
@@ -1538,9 +1657,11 @@
         }
     }
 
-    if {![file isdirectory $workpath] && ![tbool ports_dryrun]} {
-        file mkdir $workpath
-        chownAsRoot $portbuildpath
+    if {![tbool ports_dryrun]} {
+        if {![file isdirectory $workpath]} {
+            file mkdir "${workpath}/.home"
+            chownAsRoot $subbuildpath
+        }
         # Create a symlink to the workpath for port authors
         if {[tbool place_worksymlink] && ![file isdirectory $worksymlink]} {
             ui_debug "Attempting ln -sf $workpath $worksymlink"
@@ -1552,22 +1673,22 @@
     dropPrivileges
 
     # flock Portfile
-    set statefile [file join $workpath .macports.${name}.state]
+    set statefile [file join $workpath .macports.${subport}.state]
     if {[file exists $statefile]} {
         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]} {
+        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_msg "Portfile changed since last build; discarding previous state."
-                chownAsRoot $portbuildpath
+                ui_notice "Portfile changed since last build; discarding previous state."
+                chownAsRoot $subbuildpath
                 delete $workpath
                 file mkdir $workpath
             } else {
-                ui_msg "Portfile changed since last build but not discarding previous state (dry run)"
+                ui_notice "Portfile changed since last build but not discarding previous state (dry run)"
             }
         }
     } elseif {[tbool ports_dryrun]} {
@@ -1578,7 +1699,7 @@
     if {![tbool ports_dryrun]} {
         if {[catch {flock $fd -exclusive -noblock} result]} {
             if {"$result" == "EAGAIN"} {
-                ui_msg "Waiting for lock on $statefile"
+                ui_notice "Waiting for lock on $statefile"
                 flock $fd -exclusive
             } elseif {"$result" == "EOPNOTSUPP"} {
                 # Locking not supported, just return
@@ -1740,7 +1861,7 @@
     set chosen [choose_variants $dlist upvariations]
     set negated [lindex $chosen 1]
     set chosen [lindex $chosen 0]
-    set portname $PortInfo(name)
+    set portname [option subport]
 
     # Check to make sure the requested variations are available with this
     # port, if one is not, warn the user and remove the variant from the
@@ -1841,7 +1962,7 @@
 
         array set oldvariations {}
         if {[check_statefile_variants variations oldvariations $state_fd]} {
-            ui_error "Requested variants \"[canonicalize_variants [array get variations]]\" do not match original selection \"[canonicalize_variants [array get oldvariations]]\".\nPlease use the same variants again, perform 'port clean [option name]' or specify the force option (-f)."
+            ui_error "Requested variants \"[canonicalize_variants [array get variations]]\" do not match original selection \"[canonicalize_variants [array get oldvariations]]\".\nPlease use the same variants again, perform 'port clean [option subport]' or specify the force option (-f)."
             set result 1
         } elseif {!([info exists ports_dryrun] && $ports_dryrun == "yes")} {
             # Write variations out to the statefile
@@ -1999,20 +2120,18 @@
             array set vinfo $PortInfo(vinfo)
 
             foreach v $value {
-                if {[regexp {([-+])([-A-Za-z0-9_]+)} $v whole val variant]} {
+                if {[regexp {([-+])([-A-Za-z0-9_]+)} $v whole val variant] && ![info exists variations($variant)]} {
                     # Retrieve the information associated with this variant.
                     if {![info exists vinfo($variant)]} {
                         set vinfo($variant) {}
                     }
+                    array unset info
                     array set info $vinfo($variant)
+                    # Set is_default and update vinfo.
+                    set info(is_default) $val
+                    array set vinfo [list $variant [array get info]]
 
-                    if {![info exists variations($variant)]} {
-                        # Set is_default and update vinfo.
-                        array set info [list is_default val]
-                        array set vinfo [list $variant [array get info]]
-
-                        set variations($variant) $val
-                    }
+                    set variations($variant) $val
                 }
             }
             # Update PortInfo(vinfo).
@@ -2024,6 +2143,29 @@
     }
 }
 
+# create all users/groups listed in the add_users option
+# format: [username [option=value ...] ...]
+proc handle_add_users {} {
+    set cur ""
+    foreach val [option add_users] {
+        if {[string match *=* $val] && $cur != ""} {
+            set split_arg [split $val =]
+            if {[lindex $split_arg 0] == "group"} {
+                set groupname [lindex $split_arg 1]
+                addgroup $groupname
+                lappend args($cur) gid=[existsgroup $groupname]
+            } else {
+                lappend args($cur) $val
+            }
+        } else {
+            set cur $val
+        }
+    }
+    foreach username [array names args] {
+        eval adduser $username $args($username)
+    }
+}
+
 proc adduser {name args} {
     global os.platform
 
@@ -2033,14 +2175,15 @@
         return
     } elseif {[geteuid] != 0} {
         seteuid 0; setegid 0
+        set escalated 1
     }
 
     set passwd {*}
     set uid [nextuid]
     set gid [existsgroup nogroup]
     set realname ${name}
-    set home /dev/null
-    set shell /dev/null
+    set home /var/empty
+    set shell /usr/bin/false
 
     foreach arg $args {
         if {[regexp {([a-z]*)=(.*)} $arg match key val]} {
@@ -2054,10 +2197,20 @@
 
     if {${os.platform} eq "darwin"} {
         set dscl [findBinary dscl $portutil::autoconf::dscl_path]
+        exec $dscl . -create /Users/${name} UniqueID ${uid}
+
+        # These are implicitly added on Mac OSX Lion.  AuthenticationAuthority
+        # causes the user to be visible in the Users & Groups Preference Pane,
+        # and the others are just noise, so delete them.
+        # https://trac.macports.org/ticket/30168
+        exec $dscl . -delete /Users/${name} AuthenticationAuthority
+        exec $dscl . -delete /Users/${name} PasswordPolicyOptions
+        exec $dscl . -delete /Users/${name} dsAttrTypeNative:KerberosKeys
+        exec $dscl . -delete /Users/${name} dsAttrTypeNative:ShadowHashData
+
+        exec $dscl . -create /Users/${name} RealName ${realname}
         exec $dscl . -create /Users/${name} Password ${passwd}
-        exec $dscl . -create /Users/${name} UniqueID ${uid}
         exec $dscl . -create /Users/${name} PrimaryGroupID ${gid}
-        exec $dscl . -create /Users/${name} RealName ${realname}
         exec $dscl . -create /Users/${name} NFSHomeDirectory ${home}
         exec $dscl . -create /Users/${name} UserShell ${shell}
     } else {
@@ -2065,6 +2218,10 @@
         ui_warn "adduser is not implemented on ${os.platform}."
         ui_warn "The requested user '$name' was not created."
     }
+
+    if {[info exists escalated]} {
+        dropPrivileges
+    }
 }
 
 proc addgroup {name args} {
@@ -2076,6 +2233,7 @@
         return
     } elseif {[geteuid] != 0} {
         seteuid 0; setegid 0
+        set escalated 1
     }
 
     set gid [nextgid]
@@ -2106,6 +2264,10 @@
         ui_warn "addgroup is not implemented on ${os.platform}."
         ui_warn "The requested group was not created."
     }
+
+    if {[info exists escalated]} {
+        dropPrivileges
+    }
 }
 
 # proc to calculate size of a directory
@@ -2149,6 +2311,26 @@
     }
 }
 
+# return path where the 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}"]
+}
+
+# return list of archive types that we can extract
+proc supportedArchiveTypes {} {
+    global supported_archive_types
+    if {![info exists supported_archive_types]} {
+        set supported_archive_types {}
+        foreach type {tbz2 tbz tgz tar txz tlz xar xpkg zip cpgz cpio} {
+            if {[catch {archiveTypeIsSupported $type}] == 0} {
+                lappend supported_archive_types $type
+            }
+        }
+    }
+    return $supported_archive_types
+}
+
 # check if archive type is supported by current system
 # returns an error code if it is not
 proc archiveTypeIsSupported {type} {
@@ -2194,7 +2376,7 @@
                 }
             }
         }
-        xar {
+        xar|xpkg {
             set xar "xar"
             if {[catch {set xar [findBinary $xar ${portutil::autoconf::xar_path}]} errmsg] == 0} {
                 return 0
@@ -2357,12 +2539,12 @@
             # if started with sudo but have dropped the privileges
             setegid $egid
             seteuid $euid
-            ui_debug "euid changed to: [geteuid]"
+            ui_debug "euid/egid changed to: [geteuid]/[getegid]"
             chown  ${path} ${macportsuser}
             ui_debug "chowned $path to $macportsuser"
             setegid [uname_to_gid "$macportsuser"]
             seteuid [name_to_uid "$macportsuser"]
-            ui_debug "euid changed to: [geteuid]"
+            ui_debug "euid/egid changed to: [geteuid]/[getegid]"
         } else {
             # if started with sudo but have elevated back to root already
             chown  ${path} ${macportsuser}
@@ -2382,12 +2564,12 @@
             # Started as root, but not root now
             setegid $egid
             seteuid $euid
-            ui_debug "euid changed to: [geteuid]"
+            ui_debug "euid/egid changed to: [geteuid]/[getegid]"
             ui_debug "setting attributes on $file"
             eval file attributes {$file} $attributes
             setegid [uname_to_gid "$macportsuser"]
             seteuid [name_to_uid "$macportsuser"]
-            ui_debug "euid changed to: [geteuid]"
+            ui_debug "euid/egid changed to: [geteuid]/[getegid]"
         } else {
             eval file attributes {$file} $attributes
         }
@@ -2444,6 +2626,15 @@
     }
 }
 
+proc validate_macportsuser {} {
+    global macportsuser
+    if {[getuid] == 0 && $macportsuser != "root" && 
+        ([existsuser $macportsuser] == 0 || [existsgroup $macportsuser] == 0 )} {
+        ui_warn "configured user/group $macportsuser does not exist, will build as root"
+        set macportsuser "root"
+    }
+}
+
 # dependency analysis helpers
 
 ### _libtest is private; subject to change without notice
@@ -2526,14 +2717,9 @@
 
 # returns the name of the port that will actually be satisfying $depspec
 proc _get_dep_port {depspec} {
-    global registry.installtype
     set speclist [split $depspec :]
     set portname [lindex $speclist end]
-    if {[string equal ${registry.installtype} "image"]} {
-        set res [_portnameactive $portname]
-    } else {
-        set res [registry_exists_for_name $portname]
-    }
+    set res [_portnameactive $portname]
     if {$res != 0} {
         return $portname
     }
@@ -2576,22 +2762,34 @@
     }
 }
 
+# returns the flags that should be passed to the compiler to choose arch(s)
+proc get_canonical_archflags {{tool cc}} {
+    if {![variant_exists universal] || ![variant_isset universal]} {
+        return [option configure.${tool}_archflags]
+    } else {
+        if {$tool == "cc" || $tool == "objc"} {
+            set tool c
+        }
+        return [option configure.universal_${tool}flags]
+    }
+}
+
 # check that the selected archs are supported
 proc check_supported_archs {} {
-    global supported_archs build_arch universal_archs configure.build_arch configure.universal_archs name
+    global supported_archs build_arch universal_archs configure.build_arch configure.universal_archs subport
     if {$supported_archs == "noarch"} {
         return 0
     } elseif {[variant_exists universal] && [variant_isset universal]} {
         if {[llength ${configure.universal_archs}] > 1 || $universal_archs == ${configure.universal_archs}} {
             return 0
         } else {
-            ui_error "$name cannot be installed for the configured universal_archs '$universal_archs' because it only supports the arch(s) '$supported_archs'."
+            ui_error "$subport cannot be installed for the configured universal_archs '$universal_archs' because it only supports the arch(s) '$supported_archs'."
             return 1
         }
     } elseif {$build_arch == "" || ${configure.build_arch} != ""} {
         return 0
     }
-    ui_error "$name cannot be installed for the configured build_arch '$build_arch' because it only supports the arch(s) '$supported_archs'."
+    ui_error "$subport cannot be installed for the configured build_arch '$build_arch' because it only supports the arch(s) '$supported_archs'."
     return 1
 }
 
@@ -2611,50 +2809,67 @@
                 set ok 3.1
                 set rec 3.1.4
             }
-            default {
+            10.6 {
                 set min 3.2
                 set ok 3.2
-                set rec 3.2.2
+                set rec 3.2.6
             }
+            default {
+                set min 4.1
+                set ok 4.1
+                set rec 4.1
+            }
         }
         if {$xcodeversion == "none"} {
             ui_warn "Xcode does not appear to be installed; most ports will likely fail to build."
-        } elseif {[rpm-vercomp $xcodeversion $min] < 0} {
+            if {[file exists "/Applications/Install Xcode.app"]} {
+                ui_warn "You downloaded Xcode from the Mac App Store but didn't install it. Run \"Install Xcode\" in the /Applications folder."
+            }
+        } elseif {[vercmp $xcodeversion $min] < 0} {
             ui_error "The installed version of Xcode (${xcodeversion}) is too old to use on the installed OS version. Version $rec or later is recommended on Mac OS X ${macosx_version}."
             return 1
-        } elseif {[rpm-vercomp $xcodeversion $ok] < 0} {
+        } elseif {[vercmp $xcodeversion $ok] < 0} {
             ui_warn "The installed version of Xcode (${xcodeversion}) is known to cause problems. Version $rec or later is recommended on Mac OS X ${macosx_version}."
         }
+
+        # Xcode 4.3 requires the command-line utilities package to be
+        # installed. 
+        if {[vercmp $xcodeversion 4.3] >= 0 ||
+            ($xcodeversion == "none" && [file exists "/Applications/Xcode.app"])} {
+            if {![file exists "/usr/bin/make"]} {
+                ui_warn "The Command Line Tools for Xcode don't appear to be installed; most ports will likely fail to build."
+                ui_warn "See http://guide.macports.org/chunked/installing.xcode.html for more information."
+            }
+        }
+        
     }
     return 0
 }
 
 # check if we can unarchive this port
 proc _archive_available {} {
-    global name version revision portvariants ports_source_only
-    global unarchive.srcpath workpath
+    global subport version revision portvariants ports_source_only workpath \
+           registry.path os.platform os.major porturl
 
-    if {[option portarchivemode] != "yes" || [tbool ports_source_only]} {
+    if {[tbool ports_source_only]} {
         return 0
     }
 
-    # Define archive directory, file, and path
-    if {![string equal ${unarchive.srcpath} ${workpath}] && ![string equal ${unarchive.srcpath} ""]} {
-        set unarchive.fullsrcpath [file join ${unarchive.srcpath} [option archive.subdir]]
-    } else {
-        set unarchive.fullsrcpath ${unarchive.srcpath}
-    }
-
     set found 0
-    foreach unarchive.type [option portarchivetype] {
-        if {[catch {archiveTypeIsSupported ${unarchive.type}} errmsg] == 0} {
-            set archstring [join [get_canonical_archs] -]
-            set unarchive.file "${name}-${version}_${revision}${portvariants}.${archstring}.${unarchive.type}"
-            if {[file isfile [file join ${unarchive.fullsrcpath} ${unarchive.file}]]} {
-                set found 1
-                break
-            }
+    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 {!$found && [file rootname [file tail $porturl]] == [file rootname [file tail [get_portimage_path]]] && [file extension $porturl] != ""} {
+        set found 1
+    }
+
+    # TODO: maybe check if there's an archive available on the server - this
+    # is much less useful otherwise now that archive == installed image
+
     return $found
 }

Modified: branches/new-help-system/base/src/port1.0/tests/portutil.tcl
===================================================================
--- branches/new-help-system/base/src/port1.0/tests/portutil.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/port1.0/tests/portutil.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,6 +2,7 @@
 # Requires r/w access to /tmp
 # MacPorts must be installed for this to work
 
+source [file join [lindex $argv 0] macports1.0 macports_fastload.tcl]
 package require macports
 mportinit
 

Modified: branches/new-help-system/base/src/portindex/Makefile
===================================================================
--- branches/new-help-system/base/src/portindex/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/portindex/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -9,7 +9,7 @@
 
 %.cgi: %.pl
 	@ echo $@
-	@ cat $< | sed "/@@PREFIX@@/s//$(subst /,\/,$(PREFIX))/" > $@
+	@ < $< sed "/@@PREFIX@@/s//$(subst /,\/,$(PREFIX))/" > $@
 
 install: all
 	mkdir -p ${DESTDIR}$(PREFIX)

Modified: branches/new-help-system/base/src/portindex/portregister.pl
===================================================================
--- branches/new-help-system/base/src/portindex/portregister.pl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/portindex/portregister.pl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 #
-# Copyright (c) 2003-2004 Apple Computer, Inc.
+# Copyright (c) 2003-2004 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -11,7 +11,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 

Modified: branches/new-help-system/base/src/portindex/portsubmit.pl
===================================================================
--- branches/new-help-system/base/src/portindex/portsubmit.pl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/portindex/portsubmit.pl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 #
-# Copyright (c) 2003-2004 Apple Computer, Inc.
+# Copyright (c) 2003-2004 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -11,7 +11,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 

Modified: branches/new-help-system/base/src/programs/daemondo/Makefile.in
===================================================================
--- branches/new-help-system/base/src/programs/daemondo/Makefile.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/programs/daemondo/Makefile.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -8,7 +8,7 @@
 mandir=		@mandir@
 mandircat8=	${mandir}/cat8
 
-CFLAGS_QUICHEEATERS	= -W -Wall
+CFLAGS_PEDANTIC	=
 CPPFLAGS	+= -I../..
 SRCS		= main.c
 OBJS		= main.o

Modified: branches/new-help-system/base/src/programs/daemondo/main.c
===================================================================
--- branches/new-help-system/base/src/programs/daemondo/main.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/programs/daemondo/main.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -921,7 +921,9 @@
     header.msgh_id          = sig;
     
     mach_msg_return_t status = mach_msg_send(&header);
-    status = 0;
+    if (status != 0) {
+        LogMessage("mach_msg_send failed in handle_child_signal!\n");
+    }
 }
 
 
@@ -939,7 +941,9 @@
     header.msgh_id          = sig;
     
     mach_msg_return_t status = mach_msg_send(&header);
-    status = 0;
+    if (status != 0) {
+        LogMessage("mach_msg_send failed in handle_generic_signal!\n");
+    }
 }
 
 

Modified: branches/new-help-system/base/src/registry2.0/Makefile
===================================================================
--- branches/new-help-system/base/src/registry2.0/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,6 +3,7 @@
 SRCS = registry.tcl registry_autoconf.tcl registry_util.tcl receipt_flat.tcl receipt_sqlite.tcl portimage.tcl portuninstall.tcl
 OBJS = registry.o util.o \
 	entry.o entryobj.o \
+	file.o fileobj.o \
 	../cregistry/cregistry.a
 	#graph.o graphobj.o
 
@@ -20,8 +21,8 @@
 .PHONY: test
 
 test:: ${SHLIB_NAME}
-	${TCLSH} tests/entry.tcl ${SHLIB_NAME}
-	${TCLSH} tests/depends.tcl ${SHLIB_NAME}
+	${TCLSH} tests/entry.tcl ./${SHLIB_NAME}
+	${TCLSH} tests/depends.tcl ./${SHLIB_NAME}
 
 distclean:: clean
 	rm -f registry_autoconf.tcl

Modified: branches/new-help-system/base/src/registry2.0/entry.c
===================================================================
--- branches/new-help-system/base/src/registry2.0/entry.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/entry.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,6 +3,7 @@
  * $Id$
  *
  * Copyright (c) 2007 Chris Pickel <sfiera at macports.org>
+ * Copyright (c) 2012 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -35,6 +36,8 @@
 #include <tcl.h>
 #include <sqlite3.h>
 
+#include <cregistry/util.h>
+
 #include "entry.h"
 #include "entryobj.h"
 #include "registry.h"
@@ -112,7 +115,7 @@
                 variants, epoch, &error);
         if (entry != NULL) {
             Tcl_Obj* result;
-            if (entry_to_obj(interp, &result, entry, &error)) {
+            if (entry_to_obj(interp, &result, entry, NULL, &error)) {
                 Tcl_SetObjResult(interp, result);
                 return TCL_OK;
             }
@@ -192,7 +195,7 @@
                 variants, epoch, &error);
         if (entry != NULL) {
             Tcl_Obj* result;
-            if (entry_to_obj(interp, &result, entry, &error)) {
+            if (entry_to_obj(interp, &result, entry, NULL, &error)) {
                 Tcl_SetObjResult(interp, result);
                 return TCL_OK;
             }
@@ -209,7 +212,7 @@
  */
 static int entry_close(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]) {
     if (objc != 3) {
-        Tcl_WrongNumArgs(interp, 1, objv, "delete entry");
+        Tcl_WrongNumArgs(interp, 1, objv, "close entry");
         return TCL_ERROR;
     } else {
         reg_error error;
@@ -455,7 +458,7 @@
                 return TCL_OK;
             } else {
                 Tcl_Obj* result;
-                if (entry_to_obj(interp, &result, entry, &error)) {
+                if (entry_to_obj(interp, &result, entry, NULL, &error)) {
                     Tcl_SetObjResult(interp, result);
                     return TCL_OK;
                 }

Copied: branches/new-help-system/base/src/registry2.0/file.c (from rev 90355, trunk/base/src/registry2.0/file.c)
===================================================================
--- branches/new-help-system/base/src/registry2.0/file.c	                        (rev 0)
+++ branches/new-help-system/base/src/registry2.0/file.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,292 @@
+/*
+ * file.c
+ * vim:tw=80:expandtab
+ * $Id$
+ *
+ * Copyright (c) 2011 Clemens Lang <cal at macports.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sqlite3.h>
+#include <stdlib.h>
+#include <string.h>
+#include <tcl.h>
+
+#include <cregistry/file.h>
+#include <cregistry/util.h>
+
+#include "file.h"
+#include "fileobj.h"
+#include "registry.h"
+#include "util.h"
+
+/**
+ * Converts a command name into a `reg_file`.
+ *
+ * @param [in] interp  Tcl interpreter to check within
+ * @param [in] name    name of file to get
+ * @param [out] errPtr description of error if the file can't be found
+ * @return             a file, or NULL if one couldn't be found
+ * @see get_object
+ */
+static reg_file* get_file(Tcl_Interp* interp, char* name, reg_error* errPtr) {
+    return (reg_file*)get_object(interp, name, "file", file_obj_cmd, errPtr);
+}
+
+/**
+ * Removes the file from the Tcl interpreter. Doesn't actually delete it since
+ * that's the registry's job. This is written to be used as the
+ * `Tcl_CmdDeleteProc` for an file object command.
+ *
+ * @param [in] clientData address of a reg_file to remove
+ */
+void delete_file(ClientData clientData) {
+    reg_file* file = (reg_file*)clientData;
+    free(file->proc);
+    free(file->key.path);
+    file->proc = NULL;
+}
+
+/**
+ * registry::file open portid path
+ *
+ * Opens a file matching the given parameters.
+ */
+static int file_open(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]) {
+	reg_registry* reg = registry_for(interp, reg_attached);
+	if (objc != 4) {
+		Tcl_WrongNumArgs(interp, 1, objv, "open portid path");
+		return TCL_ERROR;
+	} else if (reg == NULL) {
+		return TCL_ERROR;
+	} else {
+		char* id = Tcl_GetString(objv[2]);
+		char* path = Tcl_GetString(objv[3]);
+		reg_error error;
+		reg_file* file = reg_file_open(reg, id, path, &error);
+		if (file != NULL) {
+			Tcl_Obj* result;
+			if (file_to_obj(interp, &result, file, NULL, &error)) {
+				Tcl_SetObjResult(interp, result);
+				return TCL_OK;
+			}
+		}
+		return registry_failed(interp, &error);
+	}
+	return TCL_ERROR;
+}
+
+/**
+ * registry::file close file
+ *
+ * Closes a file. It will remain in the registry.
+ */
+static int file_close(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]) {
+	if (objc != 3) {
+		Tcl_WrongNumArgs(interp, 1, objv, "close file");
+		return TCL_ERROR;
+	} else {
+		reg_error error;
+		char* proc = Tcl_GetString(objv[2]);
+		reg_file* file = get_file(interp, proc, &error);
+		if (file == NULL) {
+			return registry_failed(interp, &error);
+		} else {
+			Tcl_DeleteCommand(interp, proc);
+			return TCL_OK;
+		}
+	}
+}
+
+typedef struct {
+    char* name;
+    reg_strategy strategy;
+} strategy_type;
+
+static strategy_type strategies[] = {
+    { "-exact",  reg_strategy_exact },
+    { "-glob",   reg_strategy_glob },
+    { "-regexp", reg_strategy_regexp },
+    { "-null",   reg_strategy_null },
+    { "--",      reg_strategy_exact },
+    { NULL, 0 }
+};
+
+/*
+ * registry::file search ?key value ...?
+ *
+ * Searches the registry for files for which each key's value is equal to the
+ * given value. To find all files, call `file search` with no key-value pairs.
+ * For each key, can be given an option of -exact, -glob, -regexp or -null to
+ * specify the matching strategy; defaults to exact.
+ */
+static int file_search(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]) {
+    int i, j;
+    reg_registry* reg = registry_for(interp, reg_attached);
+    if (reg == NULL) {
+        return TCL_ERROR;
+    } else {
+        char** keys;
+        char** vals;
+        int* strats;
+        int key_count = 0;
+        reg_file** files;
+        reg_error error;
+        int file_count;
+        for (i = 2; i < objc;) {
+            int index, strat_index, val_length;
+            if (Tcl_GetIndexFromObj(interp, objv[i], file_props, "search key",
+                        0, &index) != TCL_OK) {
+                return TCL_ERROR;
+            }
+
+            /* we ate the key value */
+            i++;
+
+            /* check whether there's a strategy */
+            if (Tcl_GetString(objv[i])[0] == '-'
+                    && Tcl_GetIndexFromObjStruct(interp, objv[i], strategies,
+                        sizeof(strategy_type), "option", 0, &strat_index)
+                    != TCL_ERROR) {
+                /* this key has a strategy specified, eat the strategy parameter */
+                i++;
+
+                if (strategies[strat_index].strategy != reg_strategy_null) {
+                    /* this key must also have a value */
+
+                    if (Tcl_GetStringFromObj(objv[i], &val_length) == NULL
+                            || val_length == 0) {
+                        Tcl_WrongNumArgs(interp, 2, objv,
+                                "search ?key ?options? value ...?");
+                        return TCL_ERROR;
+                    }
+
+                    i++;
+                }
+            } else {
+                /* this key must also have a value */
+
+                if (Tcl_GetStringFromObj(objv[i], &val_length) == NULL
+                        || val_length == 0) {
+                    Tcl_WrongNumArgs(interp, 2, objv,
+                            "search ?key ?options? value ...?");
+                    return TCL_ERROR;
+                }
+
+                i++;
+            }
+
+            key_count++;
+        }
+
+        keys = malloc(key_count * sizeof(char*));
+        vals = malloc(key_count * sizeof(char*));
+        strats = malloc(key_count * sizeof(int));
+        if (!keys || !vals || !strats) {
+            return TCL_ERROR;
+        }
+        for (i = 2, j = 0; i < objc && j < key_count; j++) {
+            int strat_index;
+
+            keys[j] = Tcl_GetString(objv[i++]);
+
+            /* try to get the strategy */
+            if (Tcl_GetString(objv[i])[0] == '-'
+                    && Tcl_GetIndexFromObjStruct(interp, objv[i], strategies,
+                        sizeof(strategy_type), "option", 0, &strat_index)
+                    != TCL_ERROR) {
+                /* this key has a strategy specified */
+                i++;
+
+                strats[j] = strategies[strat_index].strategy;
+            } else {
+                /* use default strategy */
+                strats[j] = reg_strategy_exact;
+            }
+
+            if (strats[j] != reg_strategy_null) {
+                vals[j] = Tcl_GetString(objv[i++]);
+            } else {
+                vals[j] = NULL;
+            }
+        }
+        file_count = reg_file_search(reg, keys, vals, strats, key_count,
+                &files, &error);
+        free(keys);
+        free(vals);
+        free(strats);
+        if (file_count >= 0) {
+            int retval;
+            Tcl_Obj* resultObj;
+            Tcl_Obj** objs;
+            if (list_file_to_obj(interp, &objs, files, file_count, &error)){
+                resultObj = Tcl_NewListObj(file_count, objs);
+                Tcl_SetObjResult(interp, resultObj);
+                free(objs);
+                retval = TCL_OK;
+            } else {
+                retval = registry_failed(interp, &error);
+            }
+            free(files);
+            return retval;
+        }
+        return registry_failed(interp, &error);
+    }
+}
+
+typedef struct {
+    char* name;
+    int (*function)(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]);
+} file_cmd_type;
+
+static file_cmd_type file_cmds[] = {
+    /* Global commands */
+    { "open", file_open },
+    { "close", file_close },
+    { "search", file_search },
+    { NULL, NULL }
+};
+
+/*
+ * registry::file cmd ?arg ...?
+ *
+ * Commands manipulating file entries in the registry. This can be called `registry::file`
+ */
+int file_cmd(ClientData clientData UNUSED, Tcl_Interp* interp, int objc,
+        Tcl_Obj* CONST objv[]) {
+    int cmd_index;
+    if (objc < 2) {
+        Tcl_WrongNumArgs(interp, 1, objv, "cmd ?arg ...?");
+        return TCL_ERROR;
+    }
+    if (Tcl_GetIndexFromObjStruct(interp, objv[1], file_cmds,
+                sizeof(file_cmd_type), "cmd", 0, &cmd_index) == TCL_OK) {
+        file_cmd_type* cmd = &file_cmds[cmd_index];
+        return cmd->function(interp, objc, objv);
+    }
+    return TCL_ERROR;
+}

Copied: branches/new-help-system/base/src/registry2.0/file.h (from rev 90355, trunk/base/src/registry2.0/file.h)
===================================================================
--- branches/new-help-system/base/src/registry2.0/file.h	                        (rev 0)
+++ branches/new-help-system/base/src/registry2.0/file.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,44 @@
+/*
+ * file.h
+ * vim:tw=80:expandtab
+ * $Id$
+ *
+ * Copyright (c) 2011 Clemens Lang <cal at macports.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+#ifndef _FILE_H
+#define _FILE_H
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <tcl.h>
+
+void delete_file(ClientData clientData);
+
+int file_cmd(ClientData clientData UNUSED, Tcl_Interp* interp, int objc,
+        Tcl_Obj* CONST objv[]);
+
+#endif /* _FILE_H */
+

Copied: branches/new-help-system/base/src/registry2.0/fileobj.c (from rev 90355, trunk/base/src/registry2.0/fileobj.c)
===================================================================
--- branches/new-help-system/base/src/registry2.0/fileobj.c	                        (rev 0)
+++ branches/new-help-system/base/src/registry2.0/fileobj.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,142 @@
+/*
+ * fileobj.c
+ * vim:tw=80:expandtab
+ * $Id$
+ *
+ * Copyright (c) 2011 Clemens Lang <cal at macports.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <stdlib.h>
+#include <tcl.h>
+#include <sqlite3.h>
+
+#include "fileobj.h"
+#include "registry.h"
+#include "util.h"
+
+const char* file_props[] = {
+    "path",
+    "actual_path",
+    "active",
+    "mtime",
+    "md5sum",
+    "editable",
+    "binary",
+    NULL
+};
+
+/* ${file} prop ?value? */
+static int file_obj_prop(Tcl_Interp* interp, reg_file* file, int objc,
+        Tcl_Obj* CONST objv[]) {
+    int index;
+    if (objc > 3) {
+        Tcl_WrongNumArgs(interp, 2, objv, "?value?");
+        return TCL_ERROR;
+    }
+    if (objc == 2) {
+        /* ${file} prop; return the current value */
+        reg_registry* reg = registry_for(interp, reg_attached);
+        if (reg == NULL) {
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[1], file_props, "prop", 0, &index)
+                == TCL_OK) {
+            char* key = Tcl_GetString(objv[1]);
+            char* value;
+            reg_error error;
+            if (reg_file_propget(file, key, &value, &error)) {
+                Tcl_Obj* result = Tcl_NewStringObj(value, -1);
+                Tcl_SetObjResult(interp, result);
+                free(value);
+                return TCL_OK;
+            }
+            return registry_failed(interp, &error);
+        }
+        return TCL_ERROR;
+    } else {
+        /* ${file} prop name value; set a new value */
+        reg_registry* reg = registry_for(interp, reg_attached);
+        if (reg == NULL) {
+            return TCL_ERROR;
+        }
+        if (Tcl_GetIndexFromObj(interp, objv[1], file_props, "prop", 0, &index)
+                == TCL_OK) {
+            char* key = Tcl_GetString(objv[1]);
+            char* value = Tcl_GetString(objv[2]);
+            reg_error error;
+            if (reg_file_propset(file, key, value, &error)) {
+                return TCL_OK;
+            }
+            return registry_failed(interp, &error);
+        }
+        return TCL_ERROR;
+    }
+}
+
+typedef struct {
+    char* name;
+    int (*function)(Tcl_Interp* interp, reg_file* file, int objc,
+            Tcl_Obj* CONST objv[]);
+} file_obj_cmd_type;
+
+static file_obj_cmd_type file_cmds[] = {
+    /* keys */
+    { "path", file_obj_prop },
+    { "actual_path", file_obj_prop },
+    { "active", file_obj_prop },
+    { "mtime", file_obj_prop },
+    { "md5sum", file_obj_prop },
+    { "editable", file_obj_prop },
+    { "binary", file_obj_prop },
+    { NULL, NULL }
+};
+
+/* ${file} cmd ?arg ...? */
+/* This function implements the command that will be called when a file
+ * created by `registry::file` is used as a procedure. Since all data is kept
+ * in a temporary sqlite3 database that is created for the current interpreter,
+ * none of the sqlite3 functions used have any error checking. That should be a
+ * safe assumption, since nothing outside of registry:: should ever have the
+ * chance to touch it.
+ */
+int file_obj_cmd(ClientData clientData, Tcl_Interp* interp, int objc,
+        Tcl_Obj* CONST objv[]) {
+    int cmd_index;
+    if (objc < 2) {
+        Tcl_WrongNumArgs(interp, 1, objv, "cmd ?arg ...?");
+        return TCL_ERROR;
+    }
+    if (Tcl_GetIndexFromObjStruct(interp, objv[1], file_cmds,
+                sizeof(file_obj_cmd_type), "cmd", 0, &cmd_index) == TCL_OK) {
+        file_obj_cmd_type* cmd = &file_cmds[cmd_index];
+        return cmd->function(interp, (reg_file*)clientData, objc, objv);
+    }
+    return TCL_ERROR;
+}
+

Copied: branches/new-help-system/base/src/registry2.0/fileobj.h (from rev 90355, trunk/base/src/registry2.0/fileobj.h)
===================================================================
--- branches/new-help-system/base/src/registry2.0/fileobj.h	                        (rev 0)
+++ branches/new-help-system/base/src/registry2.0/fileobj.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -0,0 +1,44 @@
+/*
+ * fileobj.h
+ * vim:tw=80:expandtab
+ * $Id$
+ *
+ * Copyright (c) 2011 Clemens Lang <cal at macports.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ */
+#ifndef _FILE_OBJ_CMD_H
+#define _FILE_OBJ_CMD_H
+
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <tcl.h>
+#include <sqlite3.h>
+
+extern const char* file_props[];
+
+int file_obj_cmd(ClientData clientData, Tcl_Interp* interp, int objc,
+        Tcl_Obj* CONST objv[]);
+
+#endif /* _FILE_OBJ_CMD_H */

Modified: branches/new-help-system/base/src/registry2.0/graph.c
===================================================================
--- branches/new-help-system/base/src/registry2.0/graph.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/graph.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -43,7 +43,7 @@
 
 void DeleteGraph(graph* g) {
     sqlite3_stmt* stmt;
-    if ((sqlite3_prepare(g->db, "DETACH DATABASE registry", -1, &stmt, NULL)
+    if ((sqlite3_prepare_v2(g->db, "DETACH DATABASE registry", -1, &stmt, NULL)
                 != SQLITE_OK)
             || (sqlite3_step(stmt) != SQLITE_DONE)) {
         fprintf(stderr, "error: registry db not detached correctly (%s)\n",
@@ -80,11 +80,11 @@
             printf("initializing\n");
         }
 
-        if ((sqlite3_prepare(db, query, -1, &stmt, NULL) == SQLITE_OK)
+        if ((sqlite3_prepare_v2(db, query, -1, &stmt, NULL) == SQLITE_OK)
                 && (sqlite3_step(stmt) == SQLITE_DONE)) {
             sqlite3_finalize(stmt);
             if (!needsInit
-                    || ((sqlite3_prepare(db, "CREATE TABLE registry.ports "
+                    || ((sqlite3_prepare_v2(db, "CREATE TABLE registry.ports "
                                 "(name, portfile, url, location, epoch, "
                                 "version, revision, variants, state)", -1,
                                 &stmt, NULL)

Modified: branches/new-help-system/base/src/registry2.0/item.c
===================================================================
--- branches/new-help-system/base/src/registry2.0/item.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/item.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -44,7 +44,7 @@
     sqlite_int64 rowid = ((item_t*)clientData)->rowid;
     sqlite3* db = ((item_t*)clientData)->db;
     sqlite3_stmt* stmt;
-    sqlite3_prepare(db, "DELETE FROM items WHERE rowid=?", -1, &stmt, NULL);
+    sqlite3_prepare_v2(db, "DELETE FROM items WHERE rowid=?", -1, &stmt, NULL);
     sqlite3_bind_int(stmt, rowid, 1);
     sqlite3_step(stmt);
     sqlite3_finalize(stmt);
@@ -67,7 +67,7 @@
                 == TCL_OK) {
         sqlite3_stmt* stmt;
         /* record the proc name in case we need to return it in a search */
-        if ((sqlite3_prepare(db, "UPDATE items SET proc=? WHERE rowid=?", -1,
+        if ((sqlite3_prepare_v2(db, "UPDATE items SET proc=? WHERE rowid=?", -1,
                     &stmt, NULL) == SQLITE_OK)
                 && (sqlite3_bind_text(stmt, 1, name, -1, SQLITE_STATIC)
                     == SQLITE_OK)
@@ -194,7 +194,7 @@
             insert_size -= 7 + strlen(key);
         }
     }
-    r = sqlite3_prepare(db, query, -1, &stmt, NULL);
+    r = sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
     free(query);
     for (i=2; i<objc; i++) {
         char* val;

Modified: branches/new-help-system/base/src/registry2.0/itemobj.c
===================================================================
--- branches/new-help-system/base/src/registry2.0/itemobj.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/itemobj.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -51,7 +51,7 @@
         Tcl_WrongNumArgs(interp, 2, objv, "");
         return TCL_ERROR;
     }
-    sqlite3_prepare(item->db, "UPDATE items SET refcount = refcount+1 WHERE "
+    sqlite3_prepare_v2(item->db, "UPDATE items SET refcount = refcount+1 WHERE "
             "rowid=?", -1, &stmt, NULL);
     sqlite3_bind_int64(stmt, 1, item->rowid);
     sqlite3_step(stmt);
@@ -72,12 +72,12 @@
         Tcl_WrongNumArgs(interp, 2, objv, "");
         return TCL_ERROR;
     }
-    sqlite3_prepare(item->db, "UPDATE items SET refcount = refcount-1 "
+    sqlite3_prepare_v2(item->db, "UPDATE items SET refcount = refcount-1 "
             "WHERE rowid=?", -1, &stmt, NULL);
     sqlite3_bind_int64(stmt, 1, item->rowid);
     sqlite3_step(stmt);
     sqlite3_finalize(stmt);
-    sqlite3_prepare(item->db, "SELECT refcount FROM items WHERE rowid=?", -1,
+    sqlite3_prepare_v2(item->db, "SELECT refcount FROM items WHERE rowid=?", -1,
             &stmt, NULL);
     sqlite3_bind_int64(stmt, 1, item->rowid);
     sqlite3_step(stmt);
@@ -111,7 +111,7 @@
             const char* result;
             Tcl_Obj* resultObj;
             snprintf(query, sizeof(query), "SELECT %s FROM items WHERE rowid=?", key);
-            sqlite3_prepare(item->db, query, -1, &stmt, NULL);
+            sqlite3_prepare_v2(item->db, query, -1, &stmt, NULL);
             sqlite3_bind_int64(stmt, 1, item->rowid);
             sqlite3_step(stmt);
             /* eliminate compiler warning about signedness */
@@ -134,7 +134,7 @@
             char* key = Tcl_GetString(objv[2]);
             char* value = Tcl_GetString(objv[3]);
             snprintf(query, sizeof(query), "UPDATE items SET %s=? WHERE rowid=?", key);
-            sqlite3_prepare(item->db, query, -1, &stmt, NULL);
+            sqlite3_prepare_v2(item->db, query, -1, &stmt, NULL);
             sqlite3_bind_text(stmt, 1, value, -1, SQLITE_STATIC);
             sqlite3_bind_int64(stmt, 2, item->rowid);
             sqlite3_step(stmt);

Modified: branches/new-help-system/base/src/registry2.0/portimage.tcl
===================================================================
--- branches/new-help-system/base/src/registry2.0/portimage.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/portimage.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,6 +2,7 @@
 # portimage.tcl
 # $Id$
 #
+# Copyright (c) 2004-2005, 2007-2011 The MacPorts Project
 # Copyright (c) 2004 Will Barton <wbb4 at opendarwin.org>
 # Copyright (c) 2002 Apple Inc.
 # All rights reserved.
@@ -41,39 +42,43 @@
 
 set UI_PREFIX "--> "
 
-#
-# Port Images are basically just installations of the destroot of a port into
-# ${macports::registry.path}/software/${name}/${version}_${revision}${variants}
+# Port Images are installations of the destroot of a port into a compressed
+# tarball in ${macports::registry.path}/software/${name}.
 # They allow the user to install multiple versions of the same port, treating
 # each revision and each different combination of variants as a "version".
 #
-# From there, the user can "activate" a port image.  This creates {sym,hard}links for
-# all files in the image into the ${prefix}.  Directories are created.
+# From there, the user can "activate" a port image.  This extracts the port's
+# files from the image into the ${prefix}.  Directories are created.
 # Activation checks the registry's file_map for any files which conflict with
 # other "active" ports, and will not overwrite the links to the those files.
 # The conflicting port must be deactivated first.
 #
-# The user can also "deactivate" an active port.  This will remove all {sym,hard}links
-# from ${prefix}, and if any directories are empty, remove them as well.  It
-# will also remove all of the references of the files from the registry's
-# file_map
-#
-# For the creating and removing of links during activation and deactivation,
-# code very similar to what is used in portinstall is used.
-#
+# The user can also "deactivate" an active port.  This will remove all the
+# port's files from ${prefix}, and if any directories are empty, remove them
+# as well. It will also remove all of the references of the files from the 
+# registry's file_map.
 
+
 namespace eval portimage {
 
 variable force 0
-variable use_reg2 0
 variable noexec 0
 
+# takes a composite version spec rather than separate version,revision,variants
+proc activate_composite {name {v ""} {optionslist ""}} {
+    if {$v == ""} {
+        return [activate $name "" "" 0 $optionslist]
+    } elseif {[registry::decode_spec $v version revision variants]} {
+        return [activate $name $version $revision $variants $optionslist]
+    }
+    throw registry::invalid "Registry error: Invalid version '$v' specified for ${name}. Please specify a version as recorded in the port registry."
+}
+
 # Activate a "Port Image"
-proc activate {name v optionslist} {
-    global macports::prefix macports::registry.format macports::registry.path registry_open UI_PREFIX
+proc activate {name {version ""} {revision ""} {variants 0} {optionslist ""}} {
+    global macports::prefix macports::registry.path registry_open UI_PREFIX
     array set options $optionslist
     variable force
-    variable use_reg2
     variable noexec
 
     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
@@ -82,120 +87,67 @@
     if {[info exists options(ports_activate_no-exec)]} {
         set noexec $options(ports_activate_no-exec)
     }
-    if {[string equal ${macports::registry.format} "receipt_sqlite"]} {
-        set use_reg2 1
-        if {![info exists registry_open]} {
-            registry::open [file join ${macports::registry.path} registry registry.db]
-            set registry_open yes
-        }
+    if {![info exists registry_open]} {
+        registry::open [::file join ${macports::registry.path} registry registry.db]
+        set registry_open yes
     }
     set todeactivate [list]
 
-    if {$use_reg2} {
-        registry::read {
+    registry::read {
 
-            set requested [_check_registry $name $v]
-            # set name again since the one we were passed may not have had the correct case
-            set name [$requested name]
-            set version [$requested version]
-            set revision [$requested revision]
-            set variants [$requested variants]
-            set specifier "${version}_${revision}${variants}"
-
-            # if another version of this port is active, deactivate it first
-            set current [registry::entry installed $name]
-            foreach i $current {
-                if { ![string equal $specifier "[$i version]_[$i revision][$i variants]"] } {
-                    lappend todeactivate $i
-                }
-            }
-
-            # this shouldn't be possible
-            if { ![string equal [$requested installtype] "image"] } {
-                return -code error "Image error: ${name} @${version}_${revision}${variants} not installed as an image."
-            }
-
-            if { [string equal [$requested state] "installed"] } {
-                return -code error "Image error: ${name} @${version}_${revision}${variants} is already active."
-            }
-        }
-        foreach a $todeactivate {
-            if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
-                deactivate $name "[$a version]_[$a revision][$a variants]" [list ports_nodepcheck 1]
-            }
-        }
-    } else {
-        # registry1.0
-        set ilist [_check_registry $name $v]
+        set requested [_check_registry $name $version $revision $variants]
         # set name again since the one we were passed may not have had the correct case
-        set name [lindex $ilist 0]
-        set version [lindex $ilist 1]
-        set revision [lindex $ilist 2]
-        set variants [lindex $ilist 3]
+        set name [$requested name]
+        set version [$requested version]
+        set revision [$requested revision]
+        set variants [$requested variants]
+        set specifier "${version}_${revision}${variants}"
+        set location [$requested location]
 
         # if another version of this port is active, deactivate it first
-        set ilist [registry::installed $name]
-        if { [llength $ilist] > 1 } {
-            foreach i $ilist {
-                set iversion [lindex $i 1]
-                set irevision [lindex $i 2]
-                set ivariants [lindex $i 3]
-                set iactive [lindex $i 4]
-                if { ![string equal "${iversion}_${irevision}${ivariants}" "${version}_${revision}${variants}"] && $iactive == 1 } {
-                    lappend todeactivate "${iversion}_${irevision}${ivariants}"
-                }
+        set current [registry::entry installed $name]
+        foreach i $current {
+            if { ![string equal $specifier "[$i version]_[$i revision][$i variants]"] } {
+                lappend todeactivate $i
             }
         }
 
-        set ref [registry::open_entry $name $version $revision $variants]
-
-        if { ![string equal [registry::property_retrieve $ref installtype] "image"] } {
-            return -code error "Image error: ${name} @${version}_${revision}${variants} not installed as an image."
+        # this shouldn't be possible
+        if { ![string equal [$requested installtype] "image"] } {
+            return -code error "Image error: ${name} @${specifier} not installed as an image."
         }
-        if { [registry::property_retrieve $ref active] != 0 } {
-            return -code error "Image error: ${name} @${version}_${revision}${variants} is already active."
+        if {![::file isfile $location]} {
+            return -code error "Image error: Can't find image file $location"
         }
-
-        foreach a $todeactivate {
-            deactivate $name $a [list ports_nodepcheck 1]
+        if { [string equal [$requested state] "installed"] } {
+            return -code error "Image error: ${name} @${specifier} is already active."
         }
     }
-
-    if {$v != ""} {
-        ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s @%s"] $name $v]"
-    } else {
-        ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s"] $name]"
+    foreach a $todeactivate {
+        if {$noexec || ![registry::run_target $a deactivate [list ports_nodepcheck 1]]} {
+            deactivate $name [$a version] [$a revision] [$a variants] [list ports_nodepcheck 1]
+        }
     }
 
-    if {$use_reg2} {
-        _activate_contents $requested
-        $requested state installed
-    } else {
-        set imagedir [registry::property_retrieve $ref imagedir]
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Activating %s @%s"] $name $specifier]"
 
-        set contents [registry::property_retrieve $ref contents]
+    _activate_contents $requested
+    $requested state installed
+}
 
-        set imagefiles [_check_contents $name $contents $imagedir]
-
-        registry::open_file_map
-        _activate_contents $name $imagefiles $imagedir
-
-        registry::property_store $ref active 1
-
-        registry::write_entry $ref
-
-        foreach file $imagefiles {
-            registry::register_file $file $name
-        }
-        registry::write_file_map
-        registry::close_file_map
+# takes a composite version spec rather than separate version,revision,variants
+proc deactivate_composite {name {v ""} {optionslist ""}} {
+    if {$v == ""} {
+        return [deactivate $name "" "" 0 $optionslist]
+    } elseif {[registry::decode_spec $v version revision variants]} {
+        return [deactivate $name $version $revision $variants $optionslist]
     }
+    throw registry::invalid "Registry error: Invalid version '$v' specified for ${name}. Please specify a version as recorded in the port registry."
 }
 
-proc deactivate {name v optionslist} {
-    global UI_PREFIX macports::registry.format macports::registry.path registry_open
+proc deactivate {name {version ""} {revision ""} {variants 0} {optionslist ""}} {
+    global UI_PREFIX macports::registry.path registry_open
     array set options $optionslist
-    variable use_reg2
 
     if {[info exists options(ports_force)] && [string is true -strict $options(ports_force)] } {
         # this not using the namespace variable is correct, since activate
@@ -205,175 +157,89 @@
     } else {
         set force 0
     }
-    if {[string equal ${macports::registry.format} "receipt_sqlite"]} {
-        set use_reg2 1
-        if {![info exists registry_open]} {
-            registry::open [file join ${macports::registry.path} registry registry.db]
-            set registry_open yes
-        }
+    if {![info exists registry_open]} {
+        registry::open [::file join ${macports::registry.path} registry registry.db]
+        set registry_open yes
     }
 
-    if {$use_reg2} {
-        if { [string equal $name ""] } {
-            throw registry::image-error "Registry error: Please specify the name of the port."
-        }
-        set ilist [registry::entry installed $name]
-        if { [llength $ilist] == 1 } {
-            set requested [lindex $ilist 0]
-        } else {
-            throw registry::image-error "Image error: port ${name} is not active."
-        }
-        # set name again since the one we were passed may not have had the correct case
-        set name [$requested name]
-        set version [$requested version]
-        set revision [$requested revision]
-        set variants [$requested variants]
-        set specifier "${version}_${revision}${variants}"
+    if { [string equal $name ""] } {
+        throw registry::image-error "Registry error: Please specify the name of the port."
+    }
+    set ilist [registry::entry installed $name]
+    if { [llength $ilist] == 1 } {
+        set requested [lindex $ilist 0]
     } else {
-        set ilist [registry::active $name]
-        if { [llength $ilist] > 1 } {
-            return -code error "Registry error: Please specify the name of the port."
-        } else {
-            set ilist [lindex $ilist 0]
-        }
-        # set name again since the one we were passed may not have had the correct case
-        set name [lindex $ilist 0]
-        set version [lindex $ilist 1]
-        set revision [lindex $ilist 2]
-        set variants [lindex $ilist 3]
-        set specifier "${version}_${revision}${variants}"
+        throw registry::image-error "Image error: port ${name} is not active."
     }
+    # set name again since the one we were passed may not have had the correct case
+    set name [$requested name]
+    set specifier "[$requested version]_[$requested revision][$requested variants]"
 
-    if { $v != "" && ![string equal $specifier $v] } {
+    if {$version != "" && ($version != [$requested version] ||
+        ($revision != "" && ($revision != [$requested revision] || $variants != [$requested variants])))} {
+        set v $version
+        if {$revision != ""} {
+            append v _${revision}${variants}
+        }
         return -code error "Active version of $name is not $v but ${specifier}."
     }
 
-    if {$v != ""} {
-        ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s @%s"] $name $v]"
-    } else {
-        ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s"] $name]"
+    ui_msg "$UI_PREFIX [format [msgcat::mc "Deactivating %s @%s"] $name $specifier]"
+
+    if { ![string equal [$requested installtype] "image"] } {
+        return -code error "Image error: ${name} @${specifier} not installed as an image."
     }
+    # this shouldn't be possible
+    if { [$requested state] != "installed" } {
+        return -code error "Image error: ${name} @${specifier} is not active."
+    }
 
-    if {$use_reg2} {
-        if { ![string equal [$requested installtype] "image"] } {
-            return -code error "Image error: ${name} @${specifier} not installed as an image."
-        }
-        # this shouldn't be possible
-        if { [$requested state] != "installed" } {
-            return -code error "Image error: ${name} @${specifier} is not active."
-        }
+    if {![info exists options(ports_nodepcheck)] || ![string is true -strict $options(ports_nodepcheck)]} {
+        registry::check_dependents $requested $force "deactivate"
+    }
 
-        if {![info exists options(ports_nodepcheck)] || ![string is true -strict $options(ports_nodepcheck)]} {
-            registry::check_dependents $requested $force
-        }
+    _deactivate_contents $requested [$requested files] $force
+    $requested state imaged
+}
 
-        _deactivate_contents $requested [$requested files] $force
-        $requested state imaged
-    } else {
-        set ref [registry::open_entry $name $version $revision $variants]
+proc _check_registry {name version revision variants} {
+    global UI_PREFIX
 
-        if { ![string equal [registry::property_retrieve $ref installtype] "image"] } {
-            return -code error "Image error: ${name} @${specifier} not installed as an image."
+    set searchkeys $name
+    set composite_spec ""
+    if {$version != ""} {
+        lappend searchkeys $version
+        set composite_spec $version
+        # restriction imposed by underlying registry API (see entry.c):
+        # if a revision is specified, so must variants be
+        if {$revision != ""} {
+            lappend searchkeys $revision $variants
+            append composite_spec _${revision}${variants}
         }
-        if { [registry::property_retrieve $ref active] != 1 } {
-            return -code error "Image error: ${name} @${specifier} is not active."
-        }
-
-        registry::open_file_map
-        set imagefiles [registry::port_registered $name]
-
-        _deactivate_contents $name $imagefiles
-
-        foreach file $imagefiles {
-            registry::unregister_file $file
-        }
-        registry::write_file_map
-        registry::close_file_map
-
-        registry::property_store $ref active 0
-
-        registry::write_entry $ref
     }
-}
+    set ilist [eval registry::entry imaged $searchkeys]
 
-proc _check_registry {name v} {
-    global UI_PREFIX macports::registry.installtype
-    variable use_reg2
-
-    if {$use_reg2} {
-        if { [registry::decode_spec $v version revision variants] } {
-            set ilist [registry::entry imaged $name $version $revision $variants]
-            set valid 1
-        } else {
-            set valid [string equal $v {}]
-            set ilist [registry::entry imaged $name]
-        }
-
-        if { [llength $ilist] > 1 || (!$valid && [llength $ilist] == 1) } {
-            ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $name are currently installed:"]"
-            foreach i $ilist {
-                set iname [$i name]
-                set iversion [$i version]
-                set irevision [$i revision]
-                set ivariants [$i variants]
-                if { [$i state] == "installed" } {
-                    ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]"
-                } else {
-                    ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s"] $iname $iversion $irevision $ivariants]"
-                }
-            }
-            if { $valid } {
-                throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
+    if { [llength $ilist] > 1 } {
+        ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $name are currently installed:"]"
+        foreach i $ilist {
+            set iname [$i name]
+            set iversion [$i version]
+            set irevision [$i revision]
+            set ivariants [$i variants]
+            if { [$i state] == "installed" } {
+                ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]"
             } else {
-                throw registry::invalid "Registry error: Invalid version specified. Please specify a version as recorded in the port registry."
+                ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s"] $iname $iversion $irevision $ivariants]"
             }
-        } elseif { [llength $ilist] == 1 } {
-            return [lindex $ilist 0]
         }
-        throw registry::invalid "Registry error: No port of $name installed."
-    } else {
-        # registry1.0
-        set ilist [registry::installed $name $v]
-        if { [string equal $v ""] && [llength $ilist] > 1 } {
-            # set name again since the one we were passed may not have had the correct case
-            set name [lindex [lindex $ilist 0] 0]
-            ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $name are currently installed:"]"
-            foreach i $ilist { 
-                set iname [lindex $i 0]
-                set iversion [lindex $i 1]
-                set irevision [lindex $i 2]
-                set ivariants [lindex $i 3]
-                set iactive [lindex $i 4]
-                if { $iactive == 0 } {
-                    ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s"] $iname $iversion $irevision $ivariants]"
-                } elseif { $iactive == 1 } {
-                    ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]"
-                }
-            }
-            return -code error "Registry error: Please specify the full version as recorded in the port registry."
-        } elseif {[llength $ilist] == 1} {
-            return [lindex $ilist 0]
-        }
-        return -code error "Registry error: No port of $name installed."
+        throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
+    } elseif { [llength $ilist] == 1 } {
+        return [lindex $ilist 0]
     }
-}
-
-proc _check_contents {name contents imagedir} {
-
-    set imagefiles [list]
-    set idlen [string length $imagedir]
-
-    # generate list of activated file paths from list of paths in the image dir
-    foreach fe $contents {
-        set srcfile [lindex $fe 0]
-        if { ![string equal $srcfile ""] && [file type $srcfile] != "directory" } {
-            set file [string range $srcfile $idlen [string length $srcfile]]
-
-            lappend imagefiles $file
-        }
+    if {$composite_spec != ""} {
+        set composite_spec " @${composite_spec}"
     }
-
-    return $imagefiles
+    throw registry::invalid "Registry error: ${name}${composite_spec} is not installed."
 }
 
 ## Activates a file from an image into the filesystem. Deals with symlinks,
@@ -383,319 +249,364 @@
 ## @param [in] dstfile path to activate file to
 ## @return 1 if file needs to be explicitly deleted if we have to roll back, 0 otherwise
 proc _activate_file {srcfile dstfile} {
-    switch [file type $srcfile] {
-        link {
-            ui_debug "activating link: $dstfile"
-            file copy -force -- $srcfile $dstfile
-            return 1
+    if {[catch {set filetype [::file type $srcfile]} result]} {
+        # this can happen if the archive was built on case-sensitive and we're case-insensitive
+        # we know any existing dstfile is ours because we checked for conflicts earlier
+        if {![catch {file type $dstfile}]} {
+            ui_debug "skipping case-conflicting file: $srcfile"
+            return 0
+        } else {
+            error $result
         }
+    }
+    switch $filetype {
         directory {
             # Don't recursively copy directories
             ui_debug "activating directory: $dstfile"
             # Don't do anything if the directory already exists.
-            if { ![file isdirectory $dstfile] } {
-                file mkdir $dstfile
+            if { ![::file isdirectory $dstfile] } {
+                ::file mkdir $dstfile
                 # fix attributes on the directory.
-                eval file attributes {$dstfile} [file attributes $srcfile]
+                if {[getuid] == 0} {
+                    eval ::file attributes {$dstfile} [::file attributes $srcfile]
+                } else {
+                    # not root, so can't set owner/group
+                    eval ::file attributes {$dstfile} -permissions [::file attributes $srcfile -permissions]
+                }
                 # set mtime on installed element
-                file mtime $dstfile [file mtime $srcfile]
+                ::file mtime $dstfile [::file mtime $srcfile]
             }
             return 0
         }
         default {
             ui_debug "activating file: $dstfile"
-            # Try a hard link first and if that fails, a symlink
-            if {[catch {file link -hard $dstfile $srcfile}]} {
-                ui_debug "hardlinking $srcfile to $dstfile failed, symlinking instead"
-                file link -symbolic $dstfile $srcfile
-            }
+            ::file rename $srcfile $dstfile
             return 1
         }
     }
 }
 
+# extract an archive to a temporary location
+# returns: path to the extracted directory
+proc extract_archive_to_tmpdir {location} {
+    global macports::registry.path
+    set extractdir [mkdtemp [::file dirname $location]/mpextractXXXXXXXX]
+    set startpwd [pwd]
+
+    try {
+        if {[catch {cd $extractdir} err]} {
+            throw MACPORTS $err
+        }
+    
+        # clagged straight from unarchive... this really needs to be factored
+        # out, but it's a little tricky as the places where it's used run in
+        # different interpreter contexts with access to different packages.
+        set unarchive.cmd {}
+        set unarchive.pre_args {}
+        set unarchive.args {}
+        set unarchive.pipe_cmd ""
+        set unarchive.type [::file extension $location]
+        switch -regex ${unarchive.type} {
+            cp(io|gz) {
+                set pax "pax"
+                if {[catch {set pax [macports::findBinary $pax ${macports::autoconf::pax_path}]} errmsg] == 0} {
+                    ui_debug "Using $pax"
+                    set unarchive.cmd "$pax"
+                    if {[geteuid] == 0} {
+                        set unarchive.pre_args {-r -v -p e}
+                    } else {
+                        set unarchive.pre_args {-r -v -p p}
+                    }
+                    if {[regexp {z$} ${unarchive.type}]} {
+                        set unarchive.args {.}
+                        set gzip "gzip"
+                        if {[catch {set gzip [macports::findBinary $gzip ${macports::autoconf::gzip_path}]} errmsg] == 0} {
+                            ui_debug "Using $gzip"
+                            set unarchive.pipe_cmd "$gzip -d -c ${location} |"
+                        } else {
+                            ui_debug $errmsg
+                            throw MACPORTS "No '$gzip' was found on this system!"
+                        }
+                    } else {
+                        set unarchive.args "-f ${location} ."
+                    }
+                } else {
+                    ui_debug $errmsg
+                    throw MACPORTS "No '$pax' was found on this system!"
+                }
+            }
+            t(ar|bz|lz|xz|gz) {
+                set tar "tar"
+                if {[catch {set tar [macports::findBinary $tar ${macports::autoconf::tar_path}]} errmsg] == 0} {
+                    ui_debug "Using $tar"
+                    set unarchive.cmd "$tar"
+                    set unarchive.pre_args {-xvpf}
+                    if {[regexp {z2?$} ${unarchive.type}]} {
+                        set unarchive.args {-}
+                        if {[regexp {bz2?$} ${unarchive.type}]} {
+                            set gzip "bzip2"
+                        } elseif {[regexp {lz$} ${unarchive.type}]} {
+                            set gzip "lzma"
+                        } elseif {[regexp {xz$} ${unarchive.type}]} {
+                            set gzip "xz"
+                        } else {
+                            set gzip "gzip"
+                        }
+                        if {[info exists macports::autoconf::${gzip}_path]} {
+                            set hint [set macports::autoconf::${gzip}_path]
+                        } else {
+                            set hint ""
+                        }
+                        if {[catch {set gzip [macports::findBinary $gzip $hint]} errmsg] == 0} {
+                            ui_debug "Using $gzip"
+                            set unarchive.pipe_cmd "$gzip -d -c ${location} |"
+                        } else {
+                            ui_debug $errmsg
+                            throw MACPORTS "No '$gzip' was found on this system!"
+                        }
+                    } else {
+                        set unarchive.args "${location}"
+                    }
+                } else {
+                    ui_debug $errmsg
+                    throw MACPORTS "No '$tar' was found on this system!"
+                }
+            }
+            xar|xpkg {
+                set xar "xar"
+                if {[catch {set xar [macports::findBinary $xar ${macports::autoconf::xar_path}]} errmsg] == 0} {
+                    ui_debug "Using $xar"
+                    set unarchive.cmd "$xar"
+                    set unarchive.pre_args {-xvpf}
+                    set unarchive.args "${location}"
+                } else {
+                    ui_debug $errmsg
+                    throw MACPORTS "No '$xar' was found on this system!"
+                }
+            }
+            zip {
+                set unzip "unzip"
+                if {[catch {set unzip [macports::findBinary $unzip ${macports::autoconf::unzip_path}]} errmsg] == 0} {
+                    ui_debug "Using $unzip"
+                    set unarchive.cmd "$unzip"
+                    if {[geteuid] == 0} {
+                        set unarchive.pre_args {-oX}
+                    } else {
+                        set unarchive.pre_args {-o}
+                    }
+                    set unarchive.args "${location} -d ."
+                } else {
+                    ui_debug $errmsg
+                    throw MACPORTS "No '$unzip' was found on this system!"
+                }
+            }
+            default {
+                throw MACPORTS "Unsupported port archive type '${unarchive.type}'!"
+            }
+        }
+        
+        # and finally, reinvent command_exec
+        if {${unarchive.pipe_cmd} == ""} {
+            set cmdstring "${unarchive.cmd} ${unarchive.pre_args} ${unarchive.args}"
+        } else {
+            set cmdstring "${unarchive.pipe_cmd} ( ${unarchive.cmd} ${unarchive.pre_args} ${unarchive.args} )"
+        }
+        system $cmdstring
+    } catch {*} {
+        ::file delete -force $extractdir
+        throw
+    } finally {
+        cd $startpwd
+    }
+
+    return $extractdir
+}
+
 ## Activates the contents of a port
-proc _activate_contents {port {imagefiles {}} {imagedir {}}} {
+proc _activate_contents {port {imagefiles {}} {location {}}} {
     variable force
-    variable use_reg2
     variable noexec
     global macports::prefix
 
     set files [list]
     set baksuffix .mp_[clock seconds]
-    if {$use_reg2} {
-        set imagedir [$port location]
-        set imagefiles [$port imagefiles]
-    } else {
-        set name $port
-    }
+    set location [$port location]
+    set imagefiles [$port imagefiles]
+    set extracted_dir [extract_archive_to_tmpdir $location]
 
     set backups [list]
     # This is big and hairy and probably could be done better.
     # First, we need to check the source file, make sure it exists
-    # Then we remove the $imagedir from the path of the file in the contents
+    # Then we remove the $location from the path of the file in the contents
     #  list  and check to see if that file exists
     # Last, if the file exists, and belongs to another port, and force is set
     #  we remove the file from the file_map, take ownership of it, and
     #  clobber it
-    if {$use_reg2} {
-        array set todeactivate {}
-        try {
-            registry::write {
-                foreach file $imagefiles {
-                    set srcfile "${imagedir}${file}"
+    array set todeactivate {}
+    try {
+        registry::write {
+            foreach file $imagefiles {
+                set srcfile "${extracted_dir}${file}"
 
-                    # To be able to install links, we test if we can lstat the file to
-                    # figure out if the source file exists (file exists will return
-                    # false for symlinks on files that do not exist)
-                    if { [catch {file lstat $srcfile dummystatvar}] } {
-                        throw registry::image-error "Image error: Source file $srcfile does not appear to exist (cannot lstat it).  Unable to activate port [$port name]."
-                    }
+                # To be able to install links, we test if we can lstat the file to
+                # figure out if the source file exists (file exists will return
+                # false for symlinks on files that do not exist)
+                if { [catch {::file lstat $srcfile dummystatvar}] } {
+                    throw registry::image-error "Image error: Source file $srcfile does not appear to exist (cannot lstat it).  Unable to activate port [$port name]."
+                }
 
-                    set owner [registry::entry owner $file]
+                set owner [registry::entry owner $file]
 
-                    if {$owner != {} && $owner != $port} {
-                        # deactivate conflicting port if it is replaced_by this one
-                        set result [mportlookup [$owner name]]
-                        array unset portinfo
-                        array set portinfo [lindex $result 1]
-                        if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^[$port name]\$"] != -1} {
-                            # we'll deactivate the owner later, but before activating our files
-                            set todeactivate($owner) yes
-                            set owner "replaced"
-                        }
+                if {$owner != {} && $owner != $port} {
+                    # deactivate conflicting port if it is replaced_by this one
+                    set result [mportlookup [$owner name]]
+                    array unset portinfo
+                    array set portinfo [lindex $result 1]
+                    if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^[$port name]\$"] != -1} {
+                        # we'll deactivate the owner later, but before activating our files
+                        set todeactivate($owner) yes
+                        set owner "replaced"
                     }
+                }
 
-                    if {$owner != "replaced"} {
-                        if { [string is true -strict $force] } {
-                            # if we're forcing the activation, then we move any existing
-                            # files to a backup file, both in the filesystem and in the
-                            # registry
-                            if { [file exists $file] } {
-                                set bakfile "${file}${baksuffix}"
-                                ui_warn "File $file already exists.  Moving to: $bakfile."
-                                file rename -force -- $file $bakfile
-                                lappend backups $file
-                            }
-                            if { $owner != {} } {
-                                $owner deactivate [list $file]
-                                $owner activate [list $file] [list "${file}${baksuffix}"]
-                            }
-                        } else {
-                            # if we're not forcing the activation, then we bail out if
-                            # we find any files that already exist, or have entries in
-                            # the registry
-                            if { $owner != {} && $owner != $port } {
-                                throw registry::image-error "Image error: $file is being used by the active [$owner name] port.  Please deactivate this port first, or use 'port -f activate [$port name]' to force the activation."
-                            } elseif { $owner == {} && ![catch {file type $file}] } {
-                                throw registry::image-error "Image error: $file already exists and does not belong to a registered port.  Unable to activate port [$port name]. Use 'port -f activate [$port name]' to force the activation."
-                            }
+                if {$owner != "replaced"} {
+                    if { [string is true -strict $force] } {
+                        # if we're forcing the activation, then we move any existing
+                        # files to a backup file, both in the filesystem and in the
+                        # registry
+                        if { ![catch {::file type $file}] } {
+                            set bakfile "${file}${baksuffix}"
+                            ui_warn "File $file already exists.  Moving to: $bakfile."
+                            ::file rename -force -- $file $bakfile
+                            lappend backups $file
                         }
+                        if { $owner != {} } {
+                            $owner deactivate [list $file]
+                            $owner activate [list $file] [list "${file}${baksuffix}"]
+                        }
+                    } else {
+                        # if we're not forcing the activation, then we bail out if
+                        # we find any files that already exist, or have entries in
+                        # the registry
+                        if { $owner != {} && $owner != $port } {
+                            throw registry::image-error "Image error: $file is being used by the active [$owner name] port.  Please deactivate this port first, or use 'port -f activate [$port name]' to force the activation."
+                        } elseif { $owner == {} && ![catch {::file type $file}] } {
+                            throw registry::image-error "Image error: $file already exists and does not belong to a registered port.  Unable to activate port [$port name]. Use 'port -f activate [$port name]' to force the activation."
+                        }
                     }
-
-                    # Split out the filename's subpaths and add them to the
-                    # imagefile list.
-                    # We need directories first to make sure they will be there
-                    # before links. However, because file mkdir creates all parent
-                    # directories, we don't need to have them sorted from root to
-                    # subpaths. We do need, nevertheless, all sub paths to make sure
-                    # we'll set the directory attributes properly for all
-                    # directories.
-                    set directory [file dirname $file]
-                    while { [lsearch -exact $files $directory] == -1 } {
-                        lappend files $directory
-                        set directory [file dirname $directory]
-                    }
-
-                    # Also add the filename to the imagefile list.
-                    lappend files $file
                 }
-            }
 
-            # deactivate ports replaced_by this one
-            foreach owner [array names todeactivate] {
-                if {$noexec || ![registry::run_target $owner deactivate [list ports_nodepcheck 1]]} {
-                    deactivate [$owner name] "" [list ports_nodepcheck 1]
+                # Split out the filename's subpaths and add them to the
+                # imagefile list.
+                # We need directories first to make sure they will be there
+                # before links. However, because file mkdir creates all parent
+                # directories, we don't need to have them sorted from root to
+                # subpaths. We do need, nevertheless, all sub paths to make sure
+                # we'll set the directory attributes properly for all
+                # directories.
+                set directory [::file dirname $file]
+                while { [lsearch -exact $files $directory] == -1 } {
+                    lappend files $directory
+                    set directory [::file dirname $directory]
                 }
-            }
 
-            # Sort the list in forward order, removing duplicates.
-            # Since the list is sorted in forward order, we're sure that
-            # directories are before their elements.
-            # We don't have to do this as mentioned above, but it makes the
-            # debug output of activate make more sense.
-            set files [lsort -increasing -unique $files]
-            set rollback_filelist {}
-
-            registry::write {
-                # Activate it, and catch errors so we can roll-back
-                try {
-                    $port activate $imagefiles
-                    foreach file $files {
-                        if {[_activate_file "${imagedir}${file}" $file] == 1} {
-                            lappend rollback_filelist $file
-                        }
-                    }
-                } catch {*} {
-                    ui_debug "Activation failed, rolling back."
-                    # can't do it here since we're already inside a transaction
-                    set deactivate_this yes
-                    throw
-                }
+                # Also add the filename to the imagefile list.
+                lappend files $file
             }
-        } catch {*} {
-            # roll back activation of this port
-            if {[info exists deactivate_this]} {
-                _deactivate_contents $port $rollback_filelist yes yes
-            }
-            # if any errors occurred, move backed-up files back to their original
-            # locations, then rethrow the error. Transaction rollback will take care
-            # of this in the registry.
-            foreach file $backups {
-                file rename -force -- "${file}${baksuffix}" $file
-            }
-            # reactivate deactivated ports
-            foreach entry [array names todeactivate] {
-                if {[$entry state] == "imaged" && ($noexec || ![registry::run_target $entry activate ""])} {
-                    set pvers "[$entry version]_[$entry revision][$entry variants]"
-                    activate [$entry name] $pvers [list ports_activate_no-exec $noexec]
-                }
-            }
-            throw
         }
-    } else {
-        # registry1.0
-        set deactivated [list]
-        foreach file $imagefiles {
-            set srcfile "${imagedir}${file}"
 
-            # To be able to install links, we test if we can lstat the file to
-            # figure out if the source file exists (file exists will return
-            # false for symlinks on files that do not exist)
-            if { [catch {file lstat $srcfile dummystatvar}] } {
-                return -code error "Image error: Source file $srcfile does not appear to exist (cannot lstat it).  Unable to activate port $name."
+        # deactivate ports replaced_by this one
+        foreach owner [array names todeactivate] {
+            if {$noexec || ![registry::run_target $owner deactivate [list ports_nodepcheck 1]]} {
+                deactivate [$owner name] "" "" 0 [list ports_nodepcheck 1]
             }
-
-            set port [registry::file_registered $file]
-            
-            if {$port != 0  && $port != $name} {
-                # deactivate conflicting port if it is replaced_by this one
-                if {[catch {mportlookup $port} result]} {
-                    global errorInfo
-                    ui_debug "$errorInfo"
-                    return -code error "port lookup failed: $result"
-                }
-                array unset portinfo
-                array set portinfo [lindex $result 1]
-                if {[info exists portinfo(replaced_by)] && [lsearch -regexp $portinfo(replaced_by) "(?i)^${name}\$"] != -1} {
-                    lappend deactivated [lindex [registry::active $port] 0]
-                    deactivate $port "" ""
-                    set port 0
-                }
-            }
-    
-            if { $port != 0  && $force != 1 && $port != $name } {
-                return -code error "Image error: $file is being used by the active $port port.  Please deactivate this port first, or use 'port -f activate $name' to force the activation."
-            } elseif { [file exists $file] && $force != 1 } {
-                return -code error "Image error: $file already exists and does not belong to a registered port.  Unable to activate port $name. Use 'port -f activate $name' to force the activation."
-            } elseif { $force == 1 && [file exists $file] || $port != 0 } {
-                set bakfile "${file}${baksuffix}"
-
-                if {[file exists $file]} {
-                    ui_warn "File $file already exists.  Moving to: $bakfile."
-                    file rename -force -- $file $bakfile
-                    lappend backups $file
-                }
-
-                if { $port != 0 } {
-                    set bakport [registry::file_registered $file]
-                    registry::unregister_file $file
-                    if {[file exists $bakfile]} {
-                        registry::register_file $bakfile $bakport
-                    }
-                }
-            }
-
-            # Split out the filename's subpaths and add them to the imagefile list.
-            # We need directories first to make sure they will be there before
-            # links. However, because file mkdir creates all parent directories,
-            # we don't need to have them sorted from root to subpaths. We do need,
-            # nevertheless, all sub paths to make sure we'll set the directory
-            # attributes properly for all directories.
-            set directory [file dirname $file]
-            while { [lsearch -exact $files $directory] == -1 } { 
-                lappend files $directory
-                set directory [file dirname $directory]
-            }
-
-            # Also add the filename to the imagefile list.
-            lappend files $file
         }
-        registry::write_file_map
 
         # Sort the list in forward order, removing duplicates.
-        # Since the list is sorted in forward order, we're sure that directories
-        # are before their elements.
+        # Since the list is sorted in forward order, we're sure that
+        # directories are before their elements.
         # We don't have to do this as mentioned above, but it makes the
         # debug output of activate make more sense.
         set files [lsort -increasing -unique $files]
         set rollback_filelist {}
 
-        # Activate it, and catch errors so we can roll-back
-        if { [catch { foreach file $files {
-                        if {[_activate_file "${imagedir}${file}" $file] == 1} {
-                            lappend rollback_filelist $file
-                        }
-                    }} result]} {
-            ui_debug "Activation failed, rolling back."
-            _deactivate_contents $name $rollback_filelist yes yes
-            # return backed up files to their old locations
-            foreach f $backups {
-                set bakfile "${f}${baksuffix}"
-                set bakport [registry::file_registered $bakfile]
-                if {$bakport != 0} {
-                    registry::unregister_file $bakfile
-                    registry::register_file $f $bakport
+        registry::write {
+            # Activate it, and catch errors so we can roll-back
+            try {
+                $port activate $imagefiles
+                foreach file $files {
+                    if {[_activate_file "${extracted_dir}${file}" $file] == 1} {
+                        lappend rollback_filelist $file
+                    }
                 }
-                file rename -force -- $bakfile $file
+            } catch {*} {
+                ui_debug "Activation failed, rolling back."
+                # can't do it here since we're already inside a transaction
+                set deactivate_this yes
+                throw
             }
-            # reactivate deactivated ports
-            foreach entry $deactivated {
-                set pname [lindex $entry 0]
-                set pvers "[lindex $entry 1]_[lindex $entry 2][lindex $entry 3]"
-                activate $pname $pvers ""
+        }
+    } catch {*} {
+        # roll back activation of this port
+        if {[info exists deactivate_this]} {
+            _deactivate_contents $port $rollback_filelist yes yes
+        }
+        # if any errors occurred, move backed-up files back to their original
+        # locations, then rethrow the error. Transaction rollback will take care
+        # of this in the registry.
+        foreach file $backups {
+            ::file rename -force -- "${file}${baksuffix}" $file
+        }
+        # reactivate deactivated ports
+        foreach entry [array names todeactivate] {
+            if {[$entry state] == "imaged" && ($noexec || ![registry::run_target $entry activate ""])} {
+                activate [$entry name] [$entry version] [$entry revision] [$entry variants] [list ports_activate_no-exec $noexec]
             }
-            registry::write_file_map
-
-            return -code error $result
         }
+        # remove temp image dir
+        ::file delete -force $extracted_dir
+        throw
     }
+    ::file delete -force $extracted_dir
 }
 
+# These directories should not be removed during deactivation even if they are empty.
+# TODO: look into what other dirs should go here
+variable precious_dirs
+array set precious_dirs { /Library/LaunchDaemons 1 /Library/LaunchAgents 1 }
+
 proc _deactivate_file {dstfile} {
-    if { [file type $dstfile] == "link" } {
+    if {[catch {::file type $dstfile} filetype]} {
+        ui_debug "$dstfile does not exist"
+        return
+    }
+    if { $filetype == "link" } {
         ui_debug "deactivating link: $dstfile"
         file delete -- $dstfile
-    } elseif { [file isdirectory $dstfile] } {
+    } elseif { $filetype == "directory" } {
         # 0 item means empty.
         if { [llength [readdir $dstfile]] == 0 } {
-            ui_debug "deactivating directory: $dstfile"
-            file delete -- $dstfile
+            variable precious_dirs
+            if {![info exists precious_dirs($dstfile)]} {
+                ui_debug "deactivating directory: $dstfile"
+                ::file delete -- $dstfile
+            } else {
+                ui_debug "directory $dstfile does not belong to us"
+            }
         } else {
             ui_debug "$dstfile is not empty"
         }
     } else {
         ui_debug "deactivating file: $dstfile"
-        file delete -- $dstfile
+        ::file delete -- $dstfile
     }
 }
 
 proc _deactivate_contents {port imagefiles {force 0} {rollback 0}} {
-    variable use_reg2
     set files [list]
 
     foreach file $imagefiles {
-        if { [file exists $file] || (![catch {file type $file}] && [file type $file] == "link") } {
+        if { [::file exists $file] || (![catch {::file type $file}] && [::file type $file] == "link") } {
             # Normalize the file path to avoid removing the intermediate
             # symlinks (remove the empty directories instead)
             # Remark: paths in the registry may be not normalized.
@@ -706,14 +617,14 @@
             # belong to any port.
             # The custom realpath proc is necessary because file normalize
             # does not resolve symlinks on OS X < 10.6
-            set directory [realpath [file dirname $file]]
-            lappend files [file join $directory [file tail $file]]
+            set directory [realpath [::file dirname $file]]
+            lappend files [::file join $directory [::file tail $file]]
 
             # Split out the filename's subpaths and add them to the image list
             # as well.
             while { [lsearch -exact $files $directory] == -1 } {
                 lappend files $directory
-                set directory [file dirname $directory]
+                set directory [::file dirname $directory]
             }
         } else {
             ui_debug "$file does not exist."
@@ -726,7 +637,7 @@
     set files [lsort -decreasing -unique $files]
 
     # Remove all elements.
-    if {$use_reg2 && !$rollback} {
+    if {!$rollback} {
         registry::write {
             $port deactivate $imagefiles
             foreach file $files {

Modified: branches/new-help-system/base/src/registry2.0/portuninstall.tcl
===================================================================
--- branches/new-help-system/base/src/registry2.0/portuninstall.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/portuninstall.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -2,6 +2,7 @@
 # portuninstall.tcl
 # $Id$
 #
+# Copyright (c) 2004-2005, 2008-2011 The MacPorts Project
 # Copyright (c) 2002 - 2003 Apple Inc.
 # All rights reserved.
 #
@@ -40,10 +41,25 @@
 
 namespace eval registry_uninstall {
 
-proc uninstall {portname {v ""} optionslist} {
+# takes a composite version spec rather than separate version,revision,variants
+proc uninstall_composite {portname {v ""} {optionslist ""}} {
+    if {$v == ""} {
+        return [uninstall $portname "" "" 0 $optionslist]
+    } elseif {[registry::decode_spec $v version revision variants]} {
+        return [uninstall $portname $version $revision $variants $optionslist]
+    }
+    throw registry::invalid "Registry error: Invalid version '$v' specified for ${portname}. Please specify a version as recorded in the port registry."
+}
+
+proc uninstall {portname {version ""} {revision ""} {variants 0} {optionslist ""}} {
     global uninstall.force uninstall.nochecksum UI_PREFIX \
-           macports::registry.format macports::registry.installtype
+           macports::portimagefilepath
     array set options $optionslist
+    if {[info exists options(subport)]} {
+        # don't want this set when calling registry::run_target
+        unset options(subport)
+        set optionslist [array get options]
+    }
 
     if {![info exists uninstall.force]} {
         set uninstall.force no
@@ -56,171 +72,89 @@
     if {[info exists options(ports_uninstall_no-exec)]} {
         set options(ports_deactivate_no-exec) $options(ports_uninstall_no-exec)
     }
-    # check which registry API to use
-    set use_reg2 [string equal ${macports::registry.format} "receipt_sqlite"]
 
-    if {$use_reg2} {
-        if { [registry::decode_spec $v version revision variants] } {
-            set ilist [registry::entry imaged $portname $version $revision $variants]
-            set valid 1
-        } else {
-            set valid [string equal $v {}]
-            set ilist [registry::entry imaged $portname]
+    set searchkeys $portname
+    set composite_spec ""
+    if {$version != ""} {
+        lappend searchkeys $version
+        set composite_spec $version
+        # restriction imposed by underlying registry API (see entry.c):
+        # if a revision is specified, so must variants be
+        if {$revision != ""} {
+            lappend searchkeys $revision $variants
+            append composite_spec _${revision}${variants}
         }
-    } else {
-        set ilist [registry::installed $portname $v]
-        set valid 1
     }
+    set ilist [eval registry::entry imaged $searchkeys]
     if { [llength $ilist] > 1 } {
         # set portname again since the one we were passed may not have had the correct case
-        if {$use_reg2} {
-            set portname [[lindex $ilist 0] name]
-        } else {
-            set portname [lindex [lindex $ilist 0] 0]
-        }
+        set portname [[lindex $ilist 0] name]
         ui_msg "$UI_PREFIX [msgcat::mc "The following versions of $portname are currently installed:"]"
         foreach i [portlist_sortint $ilist] {
-            if {$use_reg2} {
-                set ispec "[$i version]_[$i revision][$i variants]"
-                if { [string equal [$i state] installed] } {
-                    ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s (active)"] [$i name] $ispec]"
-                } else {
-                    ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s"] [$i name] $ispec]"
-                }
+            set ispec "[$i version]_[$i revision][$i variants]"
+            if { [string equal [$i state] installed] } {
+                ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s (active)"] [$i name] $ispec]"
             } else {
-                set iname [lindex $i 0]
-                set iversion [lindex $i 1]
-                set irevision [lindex $i 2]
-                set ivariants [lindex $i 3]
-                set iactive [lindex $i 4]
-                if { $iactive == 1 } {
-                    ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s (active)"] $iname $iversion $irevision $ivariants]"
-                } else {
-                    ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s_%s%s"] $iname $iversion $irevision $ivariants]"
-                }
+                ui_msg "$UI_PREFIX [format [msgcat::mc "    %s @%s"] [$i name] $ispec]"
             }
         }
-        if { $valid } {
-            throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
-        } else {
-            throw registry::invalid "Registry error: Invalid version specified. Please specify a version as recorded in the port registry."
-        }
+        throw registry::invalid "Registry error: Please specify the full version as recorded in the port registry."
     } elseif { [llength $ilist] == 1 } {
-        if {$use_reg2} {
-            set port [lindex $ilist 0]
-            set version [$port version]
-            set revision [$port revision]
-            set variants [$port variants]
-        } else {
-            set version [lindex [lindex $ilist 0] 1]
-            set revision [lindex [lindex $ilist 0] 2]
-            set variants [lindex [lindex $ilist 0] 3]
-            set active [lindex [lindex $ilist 0] 4]
-        }
-        if {$v == ""} {
-            set v "${version}_${revision}${variants}"
-        }
+        set port [lindex $ilist 0]
+        set version [$port version]
+        set revision [$port revision]
+        set variants [$port variants]
+        set composite_spec "${version}_${revision}${variants}"
     } else {
-        throw registry::invalid "Registry error: $portname not registered as installed"
+        if {$composite_spec != ""} {
+            set composite_spec " @${composite_spec}"
+        }
+        throw registry::invalid "Registry error: ${portname}${composite_spec} not registered as installed"
     }
 
-    if {$use_reg2} {
-        # uninstall dependents if requested
-        if {[info exists options(ports_uninstall_follow-dependents)] && $options(ports_uninstall_follow-dependents) eq "yes"} {
-            foreach depport [$port dependents] {
-                # make sure it's still installed, since a previous dep uninstall may have removed it
-                if {[registry::entry exists $depport] && ([$depport state] == "imaged" || [$depport state] == "installed")} {
-                    if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $depport uninstall $optionslist]} {
-                        set depname [$depport name]
-                        set depver "[$depport version]_[$depport revision][$depport variants]"
-                        registry_uninstall::uninstall $depname $depver $optionslist
-                    }
-                }
-            }
-        } else {
-            # check its dependents
-            registry::check_dependents $port ${uninstall.force}
+    # uninstall dependents if requested
+    if {[info exists options(ports_uninstall_follow-dependents)] && $options(ports_uninstall_follow-dependents) eq "yes"} {
+        # don't uninstall dependents' dependencies
+        if {[info exists options(ports_uninstall_follow-dependencies)]} {
+            set orig_follow_dependencies $options(ports_uninstall_follow-dependencies)
+            unset options(ports_uninstall_follow-dependencies)
+            set optionslist [array get options]
         }
-        # if it's an image, deactivate it
-        if { [string equal [$port state] installed] } {
-            if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} {
-                ui_msg "For $portname @${v}: skipping deactivate (dry run)"
-            } else {
-                if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $port deactivate $optionslist]} {
-                    if {[$port installtype] == "image"} {
-                        portimage::deactivate $portname $v [array get options]
-                    }
+        foreach depport [$port dependents] {
+            # make sure it's still installed, since a previous dep uninstall may have removed it
+            if {[registry::entry exists $depport] && ([$depport state] == "imaged" || [$depport state] == "installed")} {
+                if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $depport uninstall $optionslist]} {
+                    registry_uninstall::uninstall [$depport name] [$depport version] [$depport revision] [$depport variants] $optionslist
                 }
             }
         }
+        if {[info exists orig_follow_dependencies]} {
+            set options(ports_uninstall_follow-dependencies) $orig_follow_dependencies
+            set optionslist [array get options]
+        }
     } else {
-        # registry1.0
-        
-        # determine if it's the only installed port with that name or not.
-        if {$v == ""} {
-            set nb_versions_installed 1
+        # check its dependents
+        registry::check_dependents $port ${uninstall.force} "uninstall"
+    }
+    # if it's active, deactivate it
+    if { [string equal [$port state] installed] } {
+        if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} {
+            ui_msg "For $portname @${composite_spec}: skipping deactivate (dry run)"
         } else {
-            set ilist [registry::installed $portname ""]
-            set nb_versions_installed [llength $ilist]
-        }
-    
-        set ref [registry::open_entry $portname $version $revision $variants]
-    
-        # Check and make sure no ports depend on this one
-        registry::open_dep_map  
-        set deplist [registry::list_dependents $portname $version $revision $variants]
-        if { [llength $deplist] > 0 } {
-            set dl [list]
-            # Check the deps first
-            foreach dep $deplist { 
-                set depport [lindex $dep 2]
-                ui_debug "$depport depends on this port"
-                if {[registry::entry_exists_for_name $depport]} {
-                    lappend dl $depport
-                }
+            if {[info exists options(ports_uninstall_no-exec)] || ![registry::run_target $port deactivate $optionslist]} {
+                portimage::deactivate $portname $version $revision $variants [array get options]
             }
-            # Now see if we need to error
-            if { [llength $dl] > 0 } {
-                if {[info exists options(ports_uninstall_follow-dependents)] && $options(ports_uninstall_follow-dependents) eq "yes"} {
-                    foreach depport $dl {
-                        # make sure it's still installed, since a previous dep uninstall may have removed it
-                        if {[registry::entry_exists_for_name $depport]} {
-                            registry_uninstall::uninstall $depport "" $optionslist
-                        }
-                    }
-                } else {
-                    # will need to change this when we get version/variant dependencies
-                    if {$nb_versions_installed == 1 || $active == 1} {
-                        ui_msg "$UI_PREFIX [format [msgcat::mc "Unable to uninstall %s %s_%s%s, the following ports depend on it:"] $portname $version $revision $variants]"
-                        foreach depport $dl {
-                            ui_msg "$UI_PREFIX [format [msgcat::mc "    %s"] $depport]"
-                        }
-                        if { [string is true -strict ${uninstall.force}] } {
-                            ui_warn "Uninstall forced.  Proceeding despite dependencies."
-                        } else {
-                            return -code error "Please uninstall the ports that depend on $portname first."
-                        }
-                    }
-                }
-            }
         }
-    
-        set installtype [registry::property_retrieve $ref installtype]
-        if { $installtype == "image" && [registry::property_retrieve $ref active] == 1} {
-            if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} {
-                ui_msg "For $portname @${version}_${revision}${variants}: skipping deactivate (dry run)"
-            } else {
-                portimage::deactivate $portname ${version}_${revision}${variants} $optionslist
-            }
-        }
     }
-    
+
+    set ref $port
+
     # note deps before we uninstall if we're going to uninstall them too
     if {[info exists options(ports_uninstall_follow-dependencies)] && [string is true -strict $options(ports_uninstall_follow-dependencies)]} {
         set deptypes {depends_fetch depends_extract depends_build depends_lib depends_run}
         set all_dependencies {}
         # look up deps from the saved portfile if possible
-        if {$use_reg2 && ![catch {set mport [mportopen_installed [$port name] [$port version] [$port revision] [$port variants] $optionslist]}]} {
+        if {![catch {set mport [mportopen_installed [$port name] [$port version] [$port revision] [$port variants] $optionslist]}]} {
             array set depportinfo [mportinfo $mport]
             mportclose_installed $mport
             foreach type $deptypes {
@@ -245,15 +179,15 @@
                 array set depportinfo [lindex $result 1]
                 set porturl $depportinfo(porturl)
                 set variations {}
-                set minusvariant [lrange [split [$port negated_variants] -] 1 end]
-                set plusvariant [lrange [split [$port variants] +] 1 end]
+                set minusvariant [lrange [split [registry::property_retrieve $ref negated_variants] -] 1 end]
+                set plusvariant [lrange [split $variants +] 1 end]
                 foreach v $plusvariant {
                     lappend variations $v "+"
                 }
                 foreach v $minusvariant {
                     lappend variations $v "-"
                 }
-                if {![catch {set mport [mportopen $porturl $optionslist [array get variations]]} result]} {
+                if {![catch {set mport [mportopen $porturl [concat $optionslist subport $portname] [array get variations]]} result]} {
                     array unset depportinfo
                     array set depportinfo [mportinfo $mport]
                     mportclose $mport
@@ -272,110 +206,27 @@
     }
 
     if {[info exists options(ports_dryrun)] && [string is true -strict $options(ports_dryrun)]} {
-        ui_msg "For $portname @${v}: skipping uninstall (dry run)"
+        ui_msg "For $portname @${composite_spec}: skipping uninstall (dry run)"
     } else {
-        ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s @%s"] $portname $v]"
-    
-        if {!$use_reg2} {
-            # Look to see if the port has registered an uninstall procedure
-            set uninstall [registry::property_retrieve $ref pkg_uninstall] 
-            if { $uninstall != 0 } {
-                if {![catch {eval [string map { \\n \n } $uninstall]} err]} {
-                    ui_info "Executing pkg_uninstall procedure"
-                    if {[catch {pkg_uninstall $portname "${version}_${revision}${variants}" } err]} {
-                        ui_error [format [msgcat::mc "Error executing pkg_uninstall procedure: %s"] $err]
-                    }
-                } else {
-                    global errorInfo
-                    ui_debug "$errorInfo"
-                    ui_error [format [msgcat::mc "Could not evaluate pkg_uninstall procedure: %s"] $err]
-                }
-            }
-        
-            # Remove the port from the dep_map if only one version was installed.
-            # This is a temporary fix for a deeper problem that is that the dependency
-            # map doesn't take the port version into account (but should).
-            # Fixing it means transitioning to a new dependency map format.
-            if {$nb_versions_installed == 1} {
-                registry::unregister_dependencies $portname
-            }
-        }
-    
-        # Now look for a contents list
-        if {$use_reg2} {
-            # imagefiles gives the actual installed files in direct mode
-            set contents [$port imagefiles]
-            set imagedir [$port location]
-        } else {
-            set contents [registry::property_retrieve $ref contents]
-            if { $contents == "" } {
-                return -code error [msgcat::mc "Uninstall failed: Port has no contents entry"]
-            }
-        }
-        set bak_suffix ".mp_[clock seconds]"
-        set files [list]
-        foreach f $contents {
-            if {$use_reg2} {
-                set fname "${imagedir}${f}"
-                #set sum1 [$port md5sum $f]
-                # there's an md5 column in registry.files in the db, but
-                # no way to get or set it seems to be implemented
-                set sum1 NONE
-            } else {
-                set fname [lindex $f 0]
-                set md5index [lsearch -regex [lrange $f 1 end] MD5]
-                if {$md5index != -1} {
-                    set sumx [lindex $f [expr $md5index + 1]]
-                } else {
-                    # XXX There is no MD5 listed, set sumx to an
-                    # empty list, causing the next conditional to
-                    # return a checksum error
-                    set sumx {}
-                }
-                set sum1 [lindex $sumx [expr [llength $sumx] - 1]]
-            }
-            if {![string match $sum1 NONE] && !([info exists uninstall.nochecksum] && [string is true -strict ${uninstall.nochecksum}]) } {
-                if {![catch {set sum2 [md5 $fname]}] && ![string match $sum1 $sum2]} {
-                    ui_warn "$UI_PREFIX  [format [msgcat::mc "Original checksum does not match for %s, saving a copy to %s"] $fname ${fname}${bak_suffix}]"
-                    catch {file copy $fname "${fname}${bak_suffix}"}
-                }
-            }
+        ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s @%s"] $portname $composite_spec]"
 
-            if { [file exists $fname] || (![catch {file type $fname}] && [file type $fname] == "link") } {
-                # Normalize the file path to avoid removing the intermediate
-                # symlinks (remove the empty directories instead)
-                # The custom realpath proc is necessary because file normalize
-                # does not resolve symlinks on OS X < 10.6
-                set directory [realpath [file dirname $fname]]
-                lappend files [file join $directory [file tail $fname]]
-    
-                # Split out the filename's subpaths and add them to the
-                # list as well.
-                while { [lsearch -exact $files $directory] == -1 } { 
-                    lappend files $directory
-                    set directory [file dirname $directory]
-                }
-            }
-        }
-    
-        # Sort the list in reverse order, removing duplicates.
-        # Since the list is sorted in reverse order, we're sure that directories
-        # are after their elements.
-        set files [lsort -decreasing -unique $files]
-    
-        # Remove all elements.
-        _uninstall_list $files
-    
-        if {$use_reg2} {
-            registry::entry delete $port
-        } else {
-            ui_info "$UI_PREFIX [format [msgcat::mc "Uninstall is removing %s from the port registry."] $portname]"
-            registry::delete_entry $ref
-        }
+        # Get the full path to the image file
+        set imagefile [registry::property_retrieve $ref location]
+        file delete $imagefile
+        # Try to delete the port's image dir; will fail if there are more image
+        # files so just ignore the failure
+        catch {file delete [::file dirname $imagefile]}
+
+        registry::entry delete $port
     }
     
     # uninstall dependencies if requested
     if {[info exists options(ports_uninstall_follow-dependencies)] && [string is true -strict $options(ports_uninstall_follow-dependencies)]} {
+        # don't uninstall dependencies' dependents
+        if {[info exists options(ports_uninstall_follow-dependents)]} {
+            unset options(ports_uninstall_follow-dependents)
+            set optionslist [array get options]
+        }
         while 1 {
             set remaining_list {}
             foreach dep $all_dependencies {
@@ -387,9 +238,8 @@
                         set ivariants [lindex $i 3]
                         if {[llength [registry::list_dependents $dep $iversion $irevision $ivariants]] == 0} {
                             set regref [registry::open_entry $dep $iversion $irevision $ivariants [lindex $i 5]]
-                            if {![registry::property_retrieve $regref requested] && (!$use_reg2 || [info exists options(ports_uninstall_no-exec)] || ![registry::run_target $regref uninstall $optionslist])} {
-                                set depver "${iversion}_${irevision}${ivariants}"
-                                registry_uninstall::uninstall $dep $depver $optionslist
+                            if {![registry::property_retrieve $regref requested] && ([info exists options(ports_uninstall_no-exec)] || ![registry::run_target $regref uninstall $optionslist])} {
+                                registry_uninstall::uninstall $dep $iversion $irevision $ivariants $optionslist
                             }
                         } else {
                             set remaining 1
@@ -410,33 +260,5 @@
     return 0
 }
 
-proc _uninstall_file {dstfile} {
-    if { ![catch {set type [file type $dstfile]}] } {
-        if { $type == "link" } {
-            ui_debug "uninstalling link: $dstfile"
-            file delete -- $dstfile
-        } elseif { [file isdirectory $dstfile] } {
-            # 0 item means empty.
-            if { [llength [readdir $dstfile]] == 0 } {
-                ui_debug "uninstalling directory: $dstfile"
-                file delete -- $dstfile
-            } else {
-                ui_debug "$dstfile is not empty"
-            }
-        } else {
-            ui_debug "uninstalling file: $dstfile"
-            file delete -- $dstfile
-        }
-    } else {
-        ui_debug "skip missing file: $dstfile"
-    }
-}
-
-proc _uninstall_list {filelist} {
-    foreach file $filelist {
-        _uninstall_file $file
-    }
-}
-
 # End of registry_uninstall namespace
 }

Modified: branches/new-help-system/base/src/registry2.0/receipt_flat.tcl
===================================================================
--- branches/new-help-system/base/src/registry2.0/receipt_flat.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/receipt_flat.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,9 +1,10 @@
 # receipt_flat.tcl
 # $Id$
 #
+# Copyright (c) 2005, 2007-2012 The MacPorts Project
 # Copyright (c) 2004 Will Barton <wbb4 at opendarwin.org>
 # Copyright (c) 2004 Paul Guyot, The MacPorts Project.
-# Copyright (c) 2002 Apple Computer, Inc.
+# Copyright (c) 2002 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -14,7 +15,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -74,7 +75,7 @@
 
     # regex match case
     if {$portversion == 0} {
-	set x [glob -nocomplain -directory [file join ${macports::registry.path} receipts] -- ${portname}-*]
+	set x [glob -nocomplain -directory [::file join ${macports::registry.path} receipts] -- ${portname}-*]
 	if {[string length $x]} {
 	    set matchfile [lindex $x 0]
 		# Remove trailing .bz2, if any.
@@ -83,7 +84,7 @@
 	    set matchfile ""
 	}
     } else {
-	set matchfile [file join ${macports::registry.path} receipts ${portname}-${portversion}]
+	set matchfile [::file join ${macports::registry.path} receipts ${portname}-${portversion}]
     }
 
     # Might as well bail out early if no file to match
@@ -91,7 +92,7 @@
 		return ""
     }
 
-    if {[file exists $matchfile] || [file exists ${matchfile}.bz2]} {
+    if {[::file exists $matchfile] || [::file exists ${matchfile}.bz2]} {
 		return $matchfile
     }
     return ""
@@ -101,7 +102,6 @@
 #
 # Open an existing entry and return its reference number.
 proc open_entry {name {version ""} {revision 0} {variants ""} {epoch ""}} {
-	global macports::registry.installtype
 	global macports::registry.path
 	variable ref_index
 	
@@ -110,11 +110,11 @@
 	    return $ref_index($name,$version,$revision,$variants)
 	}
 
-	set receipt_path [file join ${macports::registry.path} receipts ${name}]
+	set receipt_path [::file join ${macports::registry.path} receipts ${name}]
 
 	# If the receipt path ${name} doesn't exist, then the receipt probably is
 	# in the old HEAD format.
-	if { ![file isdirectory $receipt_path] } {
+	if { ![::file isdirectory $receipt_path] } {
 		set receipt_file [get_head_entry_receipt_path $name $version]
 		
 		if {![string length $receipt_file]} {
@@ -127,18 +127,17 @@
 		
 		# Extract the version from the path.
 		if { $version == "" } {
-			set theFileName [file tail $receipt_file]
+			set theFileName [::file tail $receipt_file]
 			regexp "^$name-(.*)\$" $theFileName match version
 		}
 	} else {
-		# If version wasn't specified, find out the version number.  This will
-		# depend on which installtype mode we're in, "direct" or "image"	
+		# If version wasn't specified, find out the version number.
 		if { $version == "" } {
-			# xxx: If we're in image mode, we really should have had the 
+			# xxx: We really should have had the 
 			# version given to us.  How should we handle this?
 			set x [glob -nocomplain -directory ${receipt_path} *]
 			if { [string length $x] } {
-				set v [lindex [file split [lindex $x 0]] end]
+				set v [lindex [::file split [lindex $x 0]] end]
 				regexp {([-_a-zA-Z0-9\.]+)_([0-9]*)([+-_a-zA-Z0-9]*)$} $v match version revision variants
 			} else {
 				return -code error "Registry error: ${name} not registered as installed."
@@ -149,15 +148,15 @@
 			return -code error "Registry error: ${name} @${version}_${revision}${variants} not registered as installed."
 		}
 	
-		set receipt_path [file join ${macports::registry.path} receipts ${name} ${version}_${revision}${variants}]
+		set receipt_path [::file join ${macports::registry.path} receipts ${name} ${version}_${revision}${variants}]
 	
-		set receipt_file [file join ${receipt_path} receipt]
+		set receipt_file [::file join ${receipt_path} receipt]
 	}
 
-	if { [file exists ${receipt_file}.bz2] && [file exists ${registry::autoconf::bzip2_path}] } {
+	if { [::file exists ${receipt_file}.bz2] && [::file exists ${registry::autoconf::bzip2_path}] } {
 		set receipt_file ${receipt_file}.bz2
 		set receipt_contents [exec ${registry::autoconf::bzip2_path} -d -c ${receipt_file}]
-	} elseif { [file exists ${receipt_file}] } {
+	} elseif { [::file exists ${receipt_file}] } {
 		set receipt_handle [open ${receipt_file} r]
 		set receipt_contents [read $receipt_handle]
 		close $receipt_handle
@@ -178,7 +177,7 @@
 		convert_entry_from_HEAD $name $version $revision $variants $receipt_contents $ref
 		
 		# move the old receipt
-		set convertedDirPath [file join ${macports::registry.path} receipts_converted]
+		set convertedDirPath [::file join ${macports::registry.path} receipts_converted]
 		file mkdir $convertedDirPath
 		file rename -- $receipt_file $convertedDirPath
 	} elseif {[string match "# Version: *" $receipt_contents]} {
@@ -275,15 +274,15 @@
 	foreach file $contents {
 		if {[llength $file]} {
 			set theFilePath [lindex $file 0]
-			if {[file isfile $theFilePath]} {
-				set previousPort [file_registered $theFilePath]
+			if {[::file isfile $theFilePath]} {
+				set previousPort [::file_registered $theFilePath]
 				if {$previousPort != 0} {
 					ui_warn "Conflict detected for file $theFilePath between $previousPort and $name."
 				}
 				if {[catch {register_file $theFilePath $name}]} {
 					ui_warn "An error occurred while adding $theFilePath to the file_map database."
 				}
-			} elseif {![file exists $theFilePath]} {
+			} elseif {![::file exists $theFilePath]} {
 				ui_warn "Port $name refers to $theFilePath which doesn't exist."
 			}
 			lappend theActualContents $file
@@ -311,15 +310,14 @@
 # version			the version of the port.
 # variants			the variants of the port.
 proc write_entry {ref name version {revision 0} {variants ""}} {
-	global macports::registry.installtype
 	variable receipt_$ref
 
 	set receipt_contents [array get receipt_$ref]
 
-	set receipt_path [file join ${macports::registry.path} receipts ${name} ${version}_${revision}${variants}]
-	set receipt_file [file join ${receipt_path} receipt]
+	set receipt_path [::file join ${macports::registry.path} receipts ${name} ${version}_${revision}${variants}]
+	set receipt_file [::file join ${receipt_path} receipt]
 
-	if { ![file isdirectory ${receipt_path}] } {
+	if { ![::file isdirectory ${receipt_path}] } {
 		file mkdir ${receipt_path}
 	}
 
@@ -328,15 +326,15 @@
 	puts $receipt_handle $receipt_contents
 	close $receipt_handle
 
-	if { [file exists ${receipt_file}] } {
+	if { [::file exists ${receipt_file}] } {
 		file delete -force -- "${receipt_file}"
-	} elseif { [file exists ${receipt_file}.bz2] } {
+	} elseif { [::file exists ${receipt_file}.bz2] } {
 		file delete -force -- "${receipt_file}.bz2"
 	}
 
 	file rename -force -- "${receipt_file}.tmp" "${receipt_file}"
 
-	if { [file exists ${receipt_file}] && [file exists ${registry::autoconf::bzip2_path}] && ![info exists registry.nobzip] } {
+	if { [::file exists ${receipt_file}] && [::file exists ${registry::autoconf::bzip2_path}] && ![info exists registry.nobzip] } {
 		system "${registry::autoconf::bzip2_path} -f ${receipt_file}"
 	}
 
@@ -347,12 +345,12 @@
 proc entry_exists {name version {revision 0} {variants ""}} {
 	global macports::registry.path
 
-	set receipt_path [file join ${macports::registry.path} receipts ${name} ${version}_${revision}${variants}]
-	set receipt_file [file join ${receipt_path} receipt]
+	set receipt_path [::file join ${macports::registry.path} receipts ${name} ${version}_${revision}${variants}]
+	set receipt_file [::file join ${receipt_path} receipt]
 
-	if { [file exists $receipt_file] } {
+	if { [::file exists $receipt_file] } {
 		return 1
-	} elseif { [file exists ${receipt_file}.bz2] } {
+	} elseif { [::file exists ${receipt_file}.bz2] } {
 		return 1
 	}
 
@@ -363,7 +361,7 @@
 proc entry_exists_for_name {name} {
 	global macports::registry.path
 
-	set receipt_path [file join ${macports::registry.path} receipts ${name}]
+	set receipt_path [::file join ${macports::registry.path} receipts ${name}]
 
 	if {[llength [glob -nocomplain -directory $receipt_path */receipt{,.bz2}]] > 0} {
 		return 1
@@ -419,14 +417,14 @@
 	    array unset ref_index "$name,$version,$revision,$variants"
 	}
 
-	set receipt_path [file join ${macports::registry.path} receipts ${name} ${version}_${revision}${variants}]
-	if { [file exists ${receipt_path}] } {
+	set receipt_path [::file join ${macports::registry.path} receipts ${name} ${version}_${revision}${variants}]
+	if { [::file exists ${receipt_path}] } {
 		# remove port receipt directory
 		ui_debug "deleting directory: ${receipt_path}"
 		file delete -force -- ${receipt_path}
 		# remove port receipt parent directory (if empty)
-		set receipt_dir [file join ${macports::registry.path} receipts ${name}]
-		if { [file isdirectory ${receipt_dir}] } {
+		set receipt_dir [::file join ${macports::registry.path} receipts ${name}]
+		if { [::file isdirectory ${receipt_dir}] } {
 			# 0 item means empty.
 			if { [llength [readdir ${receipt_dir}]] == 0 } {
 				ui_debug "deleting directory: ${receipt_dir}"
@@ -451,12 +449,12 @@
 proc installed {{name ""} {version ""}} {
 	global macports::registry.path
 
-	set query_path [file join ${macports::registry.path} receipts]
+	set query_path [::file join ${macports::registry.path} receipts]
 	
 	if { $name == "" } {
-		set query_path [file join ${query_path} *]
+		set query_path [::file join ${query_path} *]
 		if { $version == "" } {
-			set query_path [file join ${query_path} *]
+			set query_path [::file join ${query_path} *]
 		}
 		# [PG] Huh?
 	} else {
@@ -464,32 +462,32 @@
 	    # returned with the correct case even if it's wrong when given. To get the
 	    # correct case on a case-insensitive FS, we have to list the directory and
 	    # compare against each entry.
-	    set name_path [file join ${query_path} *]
+	    set name_path [::file join ${query_path} *]
 	    set name_entries [glob -nocomplain -types d ${name_path}]
 	    foreach entry $name_entries {
-	        set basename [file tail $entry]
+	        set basename [::file tail $entry]
 	        if {[string equal -nocase $basename $name]} {
 	            set name $basename
 	            break
 	        }
 	    }
-		set query_path [file join ${query_path} ${name}]
+		set query_path [::file join ${query_path} ${name}]
 		if { $version != "" } {
-			set query_path [file join ${query_path} ${version}]
+			set query_path [::file join ${query_path} ${version}]
 		} else {
-			set query_path [file join ${query_path} *]
+			set query_path [::file join ${query_path} *]
 		}
 	}
 
 	set x [glob -nocomplain -types d ${query_path}]
 	set rlist [list]
 	foreach p $x {
-		if {![file isfile [file join $p receipt.bz2]] && ![file isfile [file join $p receipt]]} {
+		if {![::file isfile [::file join $p receipt.bz2]] && ![::file isfile [::file join $p receipt]]} {
 			continue
 		}
 		set plist [list]
-		regexp {([-_a-zA-Z0-9\.]+)_([0-9]*)([+-_a-zA-Z0-9]*)$} [lindex [file split $p] end] match version revision variants
-		lappend plist [lindex [file split $p] end-1]
+		regexp {([-_a-zA-Z0-9\.]+)_([0-9]*)([+-_a-zA-Z0-9]*)$} [lindex [::file split $p] end] match version revision variants
+		lappend plist [lindex [::file split $p] end-1]
 		lappend plist $version
 		lappend plist $revision
 		lappend plist $variants
@@ -498,13 +496,13 @@
 
 	# append the ports in old HEAD format.
 	if { $name == "" } {
-		set query_path [file join ${macports::registry.path} receipts *]
+		set query_path [::file join ${macports::registry.path} receipts *]
 	} else {
-		set query_path [file join ${macports::registry.path} receipts ${name}-*]
+		set query_path [::file join ${macports::registry.path} receipts ${name}-*]
 	}
     set receiptglob [glob -nocomplain -types f ${query_path}]
     foreach receipt_file $receiptglob {
-		set theFileName [file tail $receipt_file]
+		set theFileName [::file tail $receipt_file]
 
     	# Remark: these regexes do not always work.
    		set theName ""
@@ -541,14 +539,14 @@
 	global macports::registry.path
 	variable file_map
 
-	set receipt_path [file join ${macports::registry.path} receipts]
-	set map_file [file join ${receipt_path} file_map]
+	set receipt_path [::file join ${macports::registry.path} receipts]
+	set map_file [::file join ${receipt_path} file_map]
 
 	# Don't reopen it (it actually would deadlock us), unless it was open r/o.
 	# and we want it r/w.
 	if { [info exists file_map] } {
 		if { $readonly == 0 } {
-			if {[filemap isreadonly file_map]} {
+			if {[::filemap isreadonly file_map]} {
 				filemap close file_map
 				filemap open file_map ${map_file}.db
 			}
@@ -558,11 +556,11 @@
 
 	set old_filemap [list]
 
-	if { ![file exists ${map_file}.db] } {
+	if { ![::file exists ${map_file}.db] } {
 		# Convert to new format
-		if { [file exists ${map_file}.bz2] && [file exists ${registry::autoconf::bzip2_path}] } {
+		if { [::file exists ${map_file}.bz2] && [::file exists ${registry::autoconf::bzip2_path}] } {
 			set old_filemap [exec ${registry::autoconf::bzip2_path} -d -c ${map_file}.bz2]
-		} elseif { [file exists $map_file] } {		
+		} elseif { [::file exists $map_file] } {		
 			set map_handle [open ${map_file} r]
 			set old_filemap [read $map_handle]
 			close $map_handle
@@ -610,8 +608,8 @@
 
 	open_file_map 1
 
-	if {[filemap exists file_map $file]} {
-		return [filemap get file_map $file]
+	if {[::filemap exists file_map $file]} {
+		return [::filemap get file_map $file]
 	} else {
 		return 0
 	}
@@ -632,7 +630,7 @@
 
 	open_file_map 1
 
-	set files [filemap list file_map $name]
+	set files [::filemap list file_map $name]
 
 	if { [llength $files] > 0 } {
 		return $files
@@ -643,7 +641,7 @@
 			# Convert the port and retry.
 			open_entry $name
 			
-			set files [filemap list file_map $name]
+			set files [::filemap list file_map $name]
 			
 			return $files
 		} else {
@@ -664,7 +662,7 @@
 
 	open_file_map
 
-	if { [file type $file] == "link" } {
+	if { [::file type $file] == "link" } {
 		ui_debug "Adding link to file_map: $file for: $port"
 	} else {
 		ui_debug "Adding file to file_map: $file for: $port"
@@ -686,7 +684,7 @@
 
 	foreach f $files {
 		set file [lindex $f 0]
-		if { [file type $file] == "link" } {
+		if { [::file type $file] == "link" } {
 			ui_debug "Adding link to file_map: $file for: $port"
 		} else {
 			ui_debug "Adding file to file_map: $file for: $port"
@@ -745,13 +743,13 @@
 	global macports::registry.path
 	variable dep_map
 
-	set receipt_path [file join ${macports::registry.path} receipts]
+	set receipt_path [::file join ${macports::registry.path} receipts]
 
-	set map_file [file join ${receipt_path} dep_map]
+	set map_file [::file join ${receipt_path} dep_map]
 
-	if { [file exists ${map_file}.bz2] && [file exists ${registry::autoconf::bzip2_path}] } {
+	if { [::file exists ${map_file}.bz2] && [::file exists ${registry::autoconf::bzip2_path}] } {
 		set dep_map [exec ${registry::autoconf::bzip2_path} -d -c ${map_file}.bz2]
-	} elseif { [file exists ${map_file}] } {
+	} elseif { [::file exists ${map_file}] } {
 		set map_handle [open ${map_file} r]
 		set dep_map [read $map_handle]
 		close $map_handle
@@ -839,9 +837,9 @@
 	global macports::registry.path
 	variable dep_map
 
-	set receipt_path [file join ${macports::registry.path} receipts]
+	set receipt_path [::file join ${macports::registry.path} receipts]
 
-	set map_file [file join ${receipt_path} dep_map]
+	set map_file [::file join ${receipt_path} dep_map]
 
 	set map_handle [open ${map_file}.tmp w 0644]
 	puts $map_handle $dep_map
@@ -852,7 +850,7 @@
 
     file rename -- ${map_file}.tmp ${map_file}
 
-	if { [file exists ${map_file}] && [file exists ${registry::autoconf::bzip2_path}] && ![info exists registry.nobzip] } {
+	if { [::file exists ${map_file}] && [::file exists ${registry::autoconf::bzip2_path}] && ![info exists registry.nobzip] } {
 		system "${registry::autoconf::bzip2_path} -f ${map_file}"
 	}
 

Modified: branches/new-help-system/base/src/registry2.0/receipt_sqlite.tcl
===================================================================
--- branches/new-help-system/base/src/registry2.0/receipt_sqlite.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/receipt_sqlite.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,7 +1,7 @@
 # receipt_sqlite.tcl
 # $Id$
 #
-# Copyright (c) 2010 The MacPorts Project
+# Copyright (c) 2010-2011 The MacPorts Project
 # Copyright (c) 2004 Will Barton <wbb4 at opendarwin.org>
 # Copyright (c) 2002 Apple Inc.
 # All rights reserved.
@@ -124,9 +124,6 @@
         active {
             set ret [string equal [$ref state] "installed"]
         }
-        imagedir {
-            set ret [$ref location]
-        }
         default {
             if {[catch {set ret [$ref $property]}]} {
                 # match behaviour of receipt_flat
@@ -152,9 +149,6 @@
                 $ref state "installed"
             }
         }
-        imagedir {
-            $ref location $value
-        }
         default {
             $ref $property $value
         }
@@ -166,28 +160,22 @@
 # If version is "", return all ports of that name.
 # Otherwise, return only ports that exactly match this version.
 # What we call version here is version_revision+variants.
+# The syntax for that can be ambiguous if there's an underscore and dash in
+# version for example, so we don't attempt to split up the composite version
+# into its components, we just compare the whole thing.
 proc installed {{name ""} {version ""}} {
-    global macports::registry.installtype
-
 	if { $name == "" && $version == "" } {
 	    set ports [registry::entry imaged]
 	} elseif { $name != "" && $version == ""} {
 	    set ports [registry::entry imaged $name]
 	} else {
-	    set cmd "registry::entry imaged $name"
-	    registry::decode_spec $version version revision variants
-	    if {[info exists version] && $version != ""} {
-                append cmd " $version"
-                if {[info exists revision] && $revision != ""} {
-                    append cmd " $revision"
-                    if {![info exists variants]} {
-                        set variants ""
-                    }
-                    append cmd " {$variants}"
-                }
-        }
-	    if {[catch {set ports [eval $cmd]}]} {
-	        set ports [list]
+	    set ports {}
+	    set possible_ports [registry::entry imaged $name]
+	    foreach p $possible_ports {
+	        if {"[$p version]_[$p revision][$p variants]" == $version
+	            || [$p version] == $version} {
+	            lappend ports $p
+	        }
 	    }
 	}
 


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

Modified: branches/new-help-system/base/src/registry2.0/registry.c
===================================================================
--- branches/new-help-system/base/src/registry2.0/registry.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/registry.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,6 +3,7 @@
  * $Id$
  *
  * Copyright (c) 2007 Chris Pickel <sfiera at macports.org>
+ * Copyright (c) 2012 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,12 +39,14 @@
 
 #include <cregistry/registry.h>
 #include <cregistry/entry.h>
+#include <cregistry/file.h>
 
-#include "registry.h"
+#include "entry.h"
+#include "entryobj.h"
+#include "file.h"
 #include "graph.h"
 #include "item.h"
-#include "entry.h"
-#include "entryobj.h"
+#include "registry.h"
 #include "util.h"
 
 int registry_failed(Tcl_Interp* interp, reg_error* errPtr) {
@@ -54,6 +57,8 @@
     return TCL_ERROR;
 }
 
+/* we don't need delete_file_list and restore_file_list unless we allow deletion
+   of files via the file interface */
 static void delete_entry_list(ClientData list, Tcl_Interp* interp UNUSED) {
     entry_list* curr = *(entry_list**)list;
     while (curr) {
@@ -80,8 +85,11 @@
 int registry_tcl_detach(Tcl_Interp* interp, reg_registry* reg,
         reg_error* errPtr) {
     reg_entry** entries;
-    int entry_count = reg_all_open_entries(reg, &entries);
+    reg_file** files;
+    int entry_count;
+    int file_count;
     int i;
+    entry_count = reg_all_open_entries(reg, &entries);
     if (entry_count == -1) {
         return 0;
     }
@@ -91,6 +99,16 @@
         }
     }
     free(entries);
+    file_count = reg_all_open_files(reg, &files);
+    if (file_count == -1) {
+        return 0;
+    }
+    for (i = 0; i < file_count; i++) {
+        if (files[i]->proc) {
+            Tcl_DeleteCommand(interp, files[i]->proc);
+        }
+    }
+    free(files);
     if (!reg_detach(reg, errPtr)) {
         return registry_failed(interp, errPtr);
     }
@@ -319,6 +337,7 @@
     /* Tcl_CreateObjCommand(interp, "registry::graph", GraphCmd, NULL, NULL); */
     /* Tcl_CreateObjCommand(interp, "registry::item", item_cmd, NULL, NULL); */
     Tcl_CreateObjCommand(interp, "registry::entry", entry_cmd, NULL, NULL);
+    Tcl_CreateObjCommand(interp, "registry::file", file_cmd, NULL, NULL);
     if (Tcl_PkgProvide(interp, "registry2", "2.0") != TCL_OK) {
         return TCL_ERROR;
     }

Modified: branches/new-help-system/base/src/registry2.0/registry.tcl
===================================================================
--- branches/new-help-system/base/src/registry2.0/registry.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/registry.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,7 +1,8 @@
 # registry.tcl
 #
+# Copyright (c) 2004-2005, 2007-2012 The MacPorts Project
 # Copyright (c) 2004 Will Barton <wbb4 at opendarwin.org>
-# Copyright (c) 2002 Apple Computer, Inc.
+# Copyright (c) 2002 Apple Inc.
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -12,7 +13,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 
@@ -45,7 +46,7 @@
 # Begin creating a new registry entry for the port version_revision+variant
 # This process assembles the directory name and creates a receipt dlist
 proc new_entry {name version {revision 0} {variants ""} {epoch 0} } {
-	global macports::registry.path macports::registry.format macports::registry.installtype macports::prefix
+	global macports::registry.path macports::registry.format macports::prefix
 
 	
 	# Make sure we don't already have an entry in the Registry for this
@@ -60,13 +61,9 @@
 		property_store $ref variants $variants
 		property_store $ref epoch $epoch
 		property_store $ref date [clock seconds]
-		property_store $ref installtype ${macports::registry.installtype}
+		property_store $ref installtype image
 		property_store $ref receipt_f ${macports::registry.format}
-		if { ${macports::registry.installtype} == "image" } {
-			set imagedir [file join ${macports::registry.path} software ${name} ${version}_${revision}${variants}]
-			property_store $ref imagedir $imagedir
-			property_store $ref active 0
-		}
+        property_store $ref active 0
 
 		return $ref
 	} else {
@@ -323,7 +320,7 @@
     # (we won't store the md5 of the target of links since it's meaningless
     # and $statvar(mode) tells us that links are links).
     if {![catch {file lstat $fname statvar}]} {
-	if {[file isfile $fname] && [file type $fname] != "link"} {
+	if {[::file isfile $fname] && [::file type $fname] != "link"} {
 	    if {[catch {md5 file $fname} md5sum] == 0} {
 		# Create a line that matches md5(1)'s output
 		# for backwards compatibility
@@ -350,7 +347,7 @@
 	set rval [list]
 	foreach file $flist {
 		if {[string index $file 0] != "/"} {
-			set file [file join $prefix $file]
+			set file [::file join $prefix $file]
 		}
 		lappend rval [fileinfo_for_file $file]
 	}
@@ -399,9 +396,9 @@
     if {$nlocked > 1} {
         return
     }
-    set lockpath [file join ${registry.path} registry .registry.lock]
+    set lockpath [::file join ${registry.path} registry .registry.lock]
     if {![info exists lockfd]} {
-        if {![file writable [file dirname $lockpath]]} {
+        if {![::file writable [::file dirname $lockpath]]} {
             # skip locking, registry can't be modified anyway
             return
         }
@@ -459,31 +456,32 @@
 
         set installtype [receipt_flat::property_retrieve $iref installtype]
         lappend proplist installtype $installtype
-        if { $installtype == "image" } {
-            set imagedir [receipt_flat::property_retrieve $iref imagedir]
-            set contents [receipt_flat::property_retrieve $iref contents]
-            set imagefiles [list]
-            set idlen [string length $imagedir]
-            foreach f $contents {
-                set fullpath [lindex $f 0]
-                # strip image dir from start
+        set location [receipt_flat::property_retrieve $iref location]
+        if {$location == "0"} {
+            set location [receipt_flat::property_retrieve $iref imagedir]
+        }
+        set contents [receipt_flat::property_retrieve $iref contents]
+        set imagefiles [list]
+        set idlen [string length $location]
+        foreach f $contents {
+            set fullpath [lindex $f 0]
+            # strip image dir from start
+            if {[string range $fullpath 0 [expr $idlen - 1]] == $location} {
                 set path [string range $fullpath $idlen [string length $fullpath]]
-                lappend imagefiles $path
-            }
-            lappend proplist imagefiles $imagefiles
-            set active [receipt_flat::property_retrieve $iref active]
-            if {$active} {
-                set state installed
-                lappend proplist files [receipt_flat::port_registered $iname]
             } else {
-                set state imaged
+                set path $fullpath
             }
-        } else {
-            set imagedir ""
+            lappend imagefiles $path
+        }
+        lappend proplist imagefiles $imagefiles
+        set active [receipt_flat::property_retrieve $iref active]
+        if {$active} {
             set state installed
             lappend proplist files [receipt_flat::port_registered $iname]
+        } else {
+            set state imaged
         }
-        lappend proplist location $imagedir
+        lappend proplist location $location
         lappend proplist state $state
         
         receipt_flat::open_dep_map

Modified: branches/new-help-system/base/src/registry2.0/registry_autoconf.tcl.in
===================================================================
--- branches/new-help-system/base/src/registry2.0/registry_autoconf.tcl.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/registry_autoconf.tcl.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -12,7 +12,7 @@
 # 2. Redistributions in binary form must reproduce the above copyright
 #    notice, this list of conditions and the following disclaimer in the
 #    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of Apple Computer, Inc. nor the names of its contributors
+# 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.
 # 

Modified: branches/new-help-system/base/src/registry2.0/registry_util.tcl
===================================================================
--- branches/new-help-system/base/src/registry2.0/registry_util.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/registry_util.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,6 +3,7 @@
 # $Id$
 #
 # Copyright (c) 2007 Chris Pickel
+# Copyright (c) 2010-2011 The MacPorts Project
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
@@ -52,7 +53,7 @@
 ## @return               true if `specifier` is a valid specifier, else false
 proc decode_spec {specifier version revision variants} {
     upvar 1 $version ver $revision rev $variants var
-    return [regexp {^([^+]+?)(_(\d+)(([-+][^-+]+)*))?$} $specifier - ver - rev var]
+    return [regexp {^([^+]+?)(_(\d+)(([-+][^-+]*[^-+[:digit:]_][^-+]*)*))?$} $specifier - ver - rev var]
 }
 
 ## Checks that the given port has no dependent ports. If it does, throws an
@@ -60,18 +61,28 @@
 ##
 ## @param [in] port  a registry::entry to check
 ## @param [in] force if true, continue even if there are dependents
-proc check_dependents {port force} {
+proc check_dependents {port force {action "uninstall/deactivate"}} {
     global UI_PREFIX
     if {[$port state] == "installed" || [llength [registry::entry imaged [$port name]]] == 1} {
-        # Check and make sure no ports depend on this one
+        # Check if any installed ports depend on this one
         set deplist [$port dependents]
+        if {$action == "deactivate"} {
+            set active_deplist {}
+            # Check if any active ports depend on this one
+            foreach p $deplist {
+                if {[$p state] == "installed"} {
+                    lappend active_deplist $p
+                }
+            }
+            set deplist $active_deplist
+        }
         if { [llength $deplist] > 0 } {
-            ui_msg "$UI_PREFIX [format [msgcat::mc "Unable to uninstall/deactivate %s @%s_%s%s, the following ports depend on it:"] [$port name] [$port version] [$port revision] [$port variants]]"
+            ui_msg "$UI_PREFIX [format [msgcat::mc "Unable to %s %s @%s_%s%s, the following ports depend on it:"] $action [$port name] [$port version] [$port revision] [$port variants]]"
             foreach depport $deplist {
                 ui_msg "$UI_PREFIX [format [msgcat::mc "	%s @%s_%s%s"] [$depport name] [$depport version] [$depport revision] [$depport variants]]"
             }
             if { [string is true -strict $force] } {
-                ui_warn "Uninstall/deactivate forced.  Proceeding despite dependencies."
+                ui_warn "[string totitle $action] forced.  Proceeding despite dependencies."
             } else {
                 throw registry::uninstall-error "Please uninstall the ports that depend on [$port name] first."
             }

Modified: branches/new-help-system/base/src/registry2.0/util.c
===================================================================
--- branches/new-help-system/base/src/registry2.0/util.c	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/util.c	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,6 +3,7 @@
  * $Id$
  *
  * Copyright (c) 2007 Chris Pickel <sfiera at macports.org>
+ * Copyright (c) 2012 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,6 +37,7 @@
 
 #include "util.h"
 #include "entryobj.h"
+#include "fileobj.h"
 
 /**
  * Generates a unique proc name starting with prefix.
@@ -45,24 +47,28 @@
  * Tcl interp context. This behavior is similar to that of the builtin
  * `interp create` command, and is intended to generate names for created
  * objects of a similar nature.
- *
- * TODO: add a int* parameter so that functions which need large numbers of
- * unique names can keep track of the lower bound between calls,thereby turning
- * N^2 to N. It'll be alchemy for the 21st century.
  */
-char* unique_name(Tcl_Interp* interp, char* prefix) {
+char* unique_name(Tcl_Interp* interp, char* prefix, int* lower_bound) {
     int result_size = strlen(prefix) + TCL_INTEGER_SPACE + 1;
     char* result = malloc(result_size);
     Tcl_CmdInfo info;
     int i;
     if (!result)
         return NULL;
-    for (i=0; ; i++) {
+    if (lower_bound == NULL) {
+        i = 0;
+    } else {
+        i = *lower_bound;
+    }
+    for (; ; i++) {
         snprintf(result, result_size, "%s%d", prefix, i);
         if (Tcl_GetCommandInfo(interp, result, &info) == 0) {
             break;
         }
     }
+    if (lower_bound != NULL) {
+        *lower_bound = i + 1;
+    }
     return result;
 }
 
@@ -175,18 +181,39 @@
         reg_error* errPtr) {
     if (set_object(interp, name, entry, "entry", entry_obj_cmd, NULL,
                 errPtr)) {
-        int size = strlen(name) + 1;
-        entry->proc = malloc(size*sizeof(char));
+        entry->proc = strdup(name);
         if (!entry->proc) {
             return 0;
         }
-        memcpy(entry->proc, name, size);
         return 1;
     }
     return 0;
 }
 
 /**
+ * Sets a given name to be a file object.
+ *
+ * @param [in] interp  Tcl interpreter to create the file within
+ * @param [in] name    name to associate the given file with
+ * @param [in] file    file to associate with the given name
+ * @param [out] errPtr description of error if it couldn't be set
+ * @return             true if success; false if failure
+ * @see set_object
+ */
+int set_file(Tcl_Interp* interp, char* name, reg_file* file,
+        reg_error* errPtr) {
+    if (set_object(interp, name, file, "file", file_obj_cmd, NULL,
+                errPtr)) {
+        file->proc = strdup(name);
+        if (!file->proc) {
+            return 0;
+        }
+        return 1;
+    }
+    return 0;
+}
+
+/**
  * Reports a sqlite3 error to Tcl.
  *
  * Queries the database for the most recent error message and sets it as the
@@ -204,47 +231,6 @@
     }
 }
 
-/**
- * Sets the result of the interpreter to all objects returned by a query.
- *
- * This function executes `query` on `db` It expects that the query will return
- * records of a single column, `rowid`. It will then use `prefix` to construct
- * unique names for these records, and call `setter` to construct their proc
- * objects. The result of `interp` will be set to a list of all such objects.
- *
- * If TCL_OK is returned, then a list is in the result. If TCL_ERROR is, then an
- * error is there.
- */
-int all_objects(Tcl_Interp* interp, sqlite3* db, char* query, char* prefix,
-        set_object_function* setter) {
-    sqlite3_stmt* stmt;
-    if (sqlite3_prepare(db, query, -1, &stmt, NULL) == SQLITE_OK) {
-        Tcl_Obj* result = Tcl_NewListObj(0, NULL);
-        Tcl_SetObjResult(interp, result);
-        while (sqlite3_step(stmt) == SQLITE_ROW) {
-            sqlite_int64 rowid = sqlite3_column_int64(stmt, 0);
-            char* name = unique_name(interp, prefix);
-            if (!name) {
-                return TCL_ERROR;
-            }
-            if (setter(interp, name, rowid) == TCL_OK) {
-                Tcl_Obj* element = Tcl_NewStringObj(name, -1);
-                Tcl_ListObjAppendElement(interp, result, element);
-                free(name);
-            } else {
-                free(name);
-                return TCL_ERROR;
-            }
-        }
-        sqlite3_finalize(stmt);
-        return TCL_OK;
-    } else {
-        sqlite3_finalize(stmt);
-        set_sqlite_result(interp, db, query);
-        return TCL_ERROR;
-    }
-}
-
 const char* string_or_null(Tcl_Obj* obj) {
     const char* string = Tcl_GetString(obj);
     if (string[0] == '\0') {
@@ -254,15 +240,16 @@
     }
 }
 
-int recast(void* userdata, cast_function* fn, free_function* del, void*** outv,
-        void** inv, int inc, reg_error* errPtr) {
+int recast(void* userdata, cast_function* fn, void* castcalldata,
+        free_function* del, void*** outv, void** inv, int inc,
+        reg_error* errPtr) {
     void** result = malloc(inc*sizeof(void*));
     int i;
     if (!result) {
         return 0;
     }
     for (i=0; i<inc; i++) {
-        if (!fn(userdata, &result[i], inv[i], errPtr)) {
+        if (!fn(userdata, &result[i], inv[i], castcalldata, errPtr)) {
             if (del != NULL) {
                 for ( ; i>=0; i--) {
                     del(userdata, result[i]);
@@ -277,9 +264,9 @@
 }
 
 int entry_to_obj(Tcl_Interp* interp, Tcl_Obj** obj, reg_entry* entry,
-        reg_error* errPtr) {
+        int* lower_bound, reg_error* errPtr) {
     if (entry->proc == NULL) {
-        char* name = unique_name(interp, "::registry::entry");
+        char* name = unique_name(interp, "::registry::entry", lower_bound);
         if (!name) {
             return 0;
         }
@@ -293,26 +280,51 @@
     return 1;
 }
 
+int file_to_obj(Tcl_Interp* interp, Tcl_Obj** obj, reg_file* file,
+        int* lower_bound, reg_error* errPtr) {
+    if (file->proc == NULL) {
+        char* name = unique_name(interp, "::registry::file", lower_bound);
+        if (!name) {
+            return 0;
+        }
+        if (!set_file(interp, name, file, errPtr)) {
+            free(name);
+            return 0;
+        }
+        free(name);
+    }
+    *obj = Tcl_NewStringObj(file->proc, -1);
+    return 1;
+}
+
 int list_entry_to_obj(Tcl_Interp* interp, Tcl_Obj*** objs,
         reg_entry** entries, int entry_count, reg_error* errPtr) {
-    return recast(interp, (cast_function*)entry_to_obj, NULL, (void***)objs,
-            (void**)entries, entry_count, errPtr);
+    int lower_bound = 0;
+    return recast(interp, (cast_function*)entry_to_obj, &lower_bound, NULL,
+            (void***)objs, (void**)entries, entry_count, errPtr);
 }
 
+int list_file_to_obj(Tcl_Interp* interp, Tcl_Obj*** objs,
+        reg_file** files, int file_count, reg_error* errPtr) {
+    int lower_bound = 0;
+    return recast(interp, (cast_function*)file_to_obj, &lower_bound, NULL,
+            (void***)objs, (void**)files, file_count, errPtr);
+}
+
 static int obj_to_string(void* userdata UNUSED, char** string, Tcl_Obj* obj,
-        reg_error* errPtr UNUSED) {
+        void* param UNUSED, reg_error* errPtr UNUSED) {
     *string = Tcl_GetString(obj);
     return 1;
 }
 
 int list_obj_to_string(char*** strings, Tcl_Obj** objv, int objc,
         reg_error* errPtr) {
-    return recast(NULL, (cast_function*)obj_to_string, NULL, (void***)strings,
+    return recast(NULL, (cast_function*)obj_to_string, NULL, NULL, (void***)strings,
             (void**)objv, objc, errPtr);
 }
 
 static int string_to_obj(void* userdata UNUSED, Tcl_Obj** obj, char* string,
-        reg_error* errPtr UNUSED) {
+        void* param UNUSED, reg_error* errPtr UNUSED) {
     *obj = Tcl_NewStringObj(string, -1);
     return 1;
 }
@@ -323,6 +335,6 @@
 
 int list_string_to_obj(Tcl_Obj*** objv, char** strings, int objc,
         reg_error* errPtr) {
-    return recast(NULL, (cast_function*)string_to_obj, (free_function*)free_obj,
+    return recast(NULL, (cast_function*)string_to_obj, NULL, (free_function*)free_obj,
             (void***)objv, (void**)strings, objc, errPtr);
 }

Modified: branches/new-help-system/base/src/registry2.0/util.h
===================================================================
--- branches/new-help-system/base/src/registry2.0/util.h	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/registry2.0/util.h	2012-03-03 14:11:19 UTC (rev 90356)
@@ -3,6 +3,7 @@
  * $Id$
  *
  * Copyright (c) 2007 Chris Pickel <sfiera at macports.org>
+ * Copyright (c) 2012 The MacPorts Project
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -37,6 +38,7 @@
 
 #include <cregistry/registry.h>
 #include <cregistry/entry.h>
+#include <cregistry/file.h>
 
 typedef struct {
     char* option;
@@ -45,7 +47,7 @@
 
 #define END_FLAGS 0
 
-char* unique_name(Tcl_Interp* interp, char* prefix);
+char* unique_name(Tcl_Interp* interp, char* prefix, int* lower_bound);
 
 int parse_flags(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[], int* start,
         option_spec options[], int* flags);
@@ -56,23 +58,25 @@
         Tcl_ObjCmdProc* proc, Tcl_CmdDeleteProc* deleteProc, reg_error* errPtr);
 int set_entry(Tcl_Interp* interp, char* name, reg_entry* entry,
         reg_error* errPtr);
+int set_file(Tcl_Interp* interp, char* name, reg_file* file,
+        reg_error* errPtr);
 
 void set_sqlite_result(Tcl_Interp* interp, sqlite3* db, const char* query);
 
-typedef int set_object_function(Tcl_Interp* interp, char* name,
-        sqlite_int64 rowid);
-int all_objects(Tcl_Interp* interp, sqlite3* db, char* query, char* prefix,
-        set_object_function* setter);
-
 const char* string_or_null(Tcl_Obj* obj);
 
-int recast(void* userdata, cast_function* fn, free_function* del, void*** outv,
-        void** inv, int inc, reg_error* errPtr);
+int recast(void* userdata, cast_function* fn, void* castcalldata,
+        free_function* del, void*** outv, void** inv, int inc,
+        reg_error* errPtr);
 
 int entry_to_obj(Tcl_Interp* interp, Tcl_Obj** obj, reg_entry* entry,
-        reg_error* errPtr);
+        int* lower_bound, reg_error* errPtr);
 int list_entry_to_obj(Tcl_Interp* interp, Tcl_Obj*** objs,
         reg_entry** entries, int entry_count, reg_error* errPtr);
+int file_to_obj(Tcl_Interp* interp, Tcl_Obj** ibj, reg_file* file,
+        int* lower_bound, reg_error* errPtr);
+int list_file_to_obj(Tcl_Interp* interp, Tcl_Obj*** objs,
+        reg_file** files, int file_count, reg_error* errPtr);
 
 void free_strings(void* userdata UNUSED, char** strings, int count);
 

Modified: branches/new-help-system/base/src/upgrade_sources_conf_default.tcl
===================================================================
--- branches/new-help-system/base/src/upgrade_sources_conf_default.tcl	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/src/upgrade_sources_conf_default.tcl	2012-03-03 14:11:19 UTC (rev 90356)
@@ -22,8 +22,15 @@
    exit 0
 }
 
+if {[file executable /usr/bin/mktemp]} {
+    set mktemp /usr/bin/mktemp
+} elseif {[file executable /bin/mktemp]} {
+    set mktemp /bin/mktemp
+} else {
+    set mktemp mktemp
+}
 
-set mktempChannel [open "|/usr/bin/mktemp -t macports_sources_upgrade.XXXXXXXXXX" r]
+set mktempChannel [open "|$mktemp -t macports_sources_upgrade.XXXXXXXXXX" r]
 set tempfile [read -nonewline $mktempChannel]
 close $mktempChannel
 
@@ -61,18 +68,15 @@
                      regexp {^URL: (.*)} $svnLine -> svnURL
                   }
                   if {[catch {close $svnChannel} err]} {
-                     if {![string match "*This client is too old to work with working copy*" $err]} {
-                        return -code error $err
-                     } else {
-                        puts $err
-                        puts "WARNING: Unable to check svn URL for '$filepath' as it has been checked out with a newer Subversion client; please manually verify $sourcesConf!"
-                     }
+                     puts $err
+                     puts "WARNING: Unable to check svn URL for '$filepath'; please manually verify $sourcesConf!"
                   }
                   if {[regexp {^https?://svn\.(macports|macosforge)\.org/repository/macports/trunk/dports} $svnURL]} {
                      set addDefault true
                   }
                } else {
-                  return -code error $err
+                  puts $err
+                  puts "WARNING: Unable to check svn URL for '$filepath'; please manually verify $sourcesConf!"
                }
             }
          }

Modified: branches/new-help-system/base/tests/Makefile
===================================================================
--- branches/new-help-system/base/tests/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,12 +1,12 @@
 include ../Mk/macports.autoconf.mk
 
-TESTS?=checksums-1 cvs-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
 
 PWD=$(shell pwd)
 
-.PHONY: test clean PortIndex
+.PHONY: all clean install test PortIndex
 
-all:
+all::
 
 /tmp/macports-tests/opt/local/etc/macports/sources.conf: sources.conf
 	@echo setting up test installation
@@ -15,6 +15,7 @@
 	mkdir -p /tmp/macports-tests/opt/local/etc/macports/
 	mkdir -p /tmp/macports-tests/opt/local/share/
 	mkdir -p /tmp/macports-tests/opt/local/var/macports/receipts/
+	mkdir -p /tmp/macports-tests/opt/local/var/macports/registry/
 	mkdir -p /tmp/macports-tests/opt/local/var/macports/build/
 	ln -s $(datadir)/macports /tmp/macports-tests/opt/local/share/
 	ln -s $(PWD)/test /tmp/macports-tests/ports/
@@ -26,7 +27,7 @@
 PortIndex:
 	$(bindir)/portindex
 
-clean:
+clean::
 	rm -rf /tmp/macports-tests/
 	rm -f PortIndex PortIndex.quick
 	for testname in $(TESTS); do \
@@ -40,27 +41,33 @@
 # Run all tests
 # Use TESTS to choose which tests to run
 # For example: make test TESTS="checkums-1 universal"
-test: clean /tmp/macports-tests/ports/PortIndex /tmp/macports-tests/opt/local/etc/macports/sources.conf
-	@for testname in $(TESTS); do\
-	    subdir=test/$$testname; \
+test:: clean /tmp/macports-tests/ports/PortIndex /tmp/macports-tests/opt/local/etc/macports/sources.conf
+	@num=0; \
+	success=0; \
+	for testname in $(TESTS); do\
+		subdir=test/$$testname; \
 		echo ===\> test ${DIRPRFX}$$subdir; \
-		if [ -e ${DIRPRFX}$$subdir/Makefile ]; then \
+		if [ -e $$subdir/Makefile ]; then \
 			( cd $$subdir && \
-				$(MAKE) DIRPRFX=${DIRPRFX}$$subdir/ PORTSRC=$(PWD)/test-macports.conf test) || exit 1; \
+				$(MAKE) DIRPRFX=${DIRPRFX}$$subdir/ PORTSRC=$(PWD)/test-macports.conf test) && \
+			success=$$(( success + 1 )); \
 		else \
 			( cd $$subdir && \
 				PORTSRC=$(PWD)/test-macports.conf $(bindir)/port clean > /dev/null && \
 				PORTSRC=$(PWD)/test-macports.conf $(bindir)/port test > output 2>&1 \
 					|| ([ -e error_expected ] || (cat output; exit 1)) && \
 			sed -e "s|${PWD}|PWD|g" < output > output.sed && \
-			diff output.sed master 2>&1 | tee difference && \
+			diff -u master output.sed 2>&1 | tee difference && \
 			if [ -s difference ]; then \
 				exit 1; \
 			else \
 				rm -f difference output.sed; \
-			fi) \
-		fi || exit 1; \
-	done
+			fi) && \
+			success=$$(( success + 1 )); \
+		fi; \
+		num=$$(( num + 1 )); \
+	done; \
+	echo ===\> $$success of $$num tests passed.
 	@rm -rf /tmp/macports-tests/
 	@rm -f PortIndex PortIndex.quick
 
@@ -70,6 +77,6 @@
 test-%:
 	$(MAKE) TESTS="$(@:test-%=%)" test
 
-install:
+install::
 
-distclean: clean
+distclean:: clean

Modified: branches/new-help-system/base/tests/test/case-insensitive-deactivate/Makefile
===================================================================
--- branches/new-help-system/base/tests/test/case-insensitive-deactivate/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/case-insensitive-deactivate/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,7 +1,7 @@
 include ../../../Mk/macports.autoconf.mk
 
 # see test-macports.conf for the value of prefix
-TESTFILE=/tmp/macports-tests/opt/local/var/macports/case
+TESTFILE=/tmp/macports-tests/opt/local/var/test/case
 TESTPORT1=casesensitive
 TESTPORT2=CaseSensitivE
 

Modified: branches/new-help-system/base/tests/test/case-insensitive-deactivate/Portfile.in
===================================================================
--- branches/new-help-system/base/tests/test/case-insensitive-deactivate/Portfile.in	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/case-insensitive-deactivate/Portfile.in	2012-03-03 14:11:19 UTC (rev 90356)
@@ -12,11 +12,10 @@
 
 long_description ${description}
 
-fetch		{}
-checksum	{}
-extract		{}
-configure	{}
+distfiles
+use_configure no
 build		{}
 destroot	{
-	system "touch ${destroot}${prefix}/var/macports/case"
+	xinstall -d ${destroot}${prefix}/var/test
+	system "touch ${destroot}${prefix}/var/test/case"
 }

Modified: branches/new-help-system/base/tests/test/case-insensitive-deactivate/README
===================================================================
--- branches/new-help-system/base/tests/test/case-insensitive-deactivate/README	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/case-insensitive-deactivate/README	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,2 +1,2 @@
 See ticket #11759,
-http://trac.macosforge.org/projects/macports/ticket/11759
+https://trac.macports.org/ticket/11759

Modified: branches/new-help-system/base/tests/test/checksums-1/master
===================================================================
--- branches/new-help-system/base/tests/test/checksums-1/master	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/checksums-1/master	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,4 +1,3 @@
---->  Computing dependencies for checksum
 --->  Fetching checksum
 --->  Verifying checksum(s) for checksum
 --->  Extracting checksum

Modified: branches/new-help-system/base/tests/test/dependencies-a/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/dependencies-a/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/dependencies-a/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,10 +11,8 @@
 
 long_description ${description}
 
-fetch		{}
-checksum	{}
-extract		{}
-configure	{}
+distfiles
+use_configure no
 build		{}
 destroot	{
 	system "touch ${destroot}${prefix}/lib/${name}"

Modified: branches/new-help-system/base/tests/test/dependencies-b/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/dependencies-b/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/dependencies-b/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,10 +11,8 @@
 
 long_description ${description}
 
-fetch		{}
-checksum	{}
-extract		{}
-configure	{}
+distfiles
+use_configure no
 build		{}
 destroot	{
 	system "touch ${destroot}${prefix}/lib/${name}"

Modified: branches/new-help-system/base/tests/test/dependencies-c/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/dependencies-c/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/dependencies-c/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,10 +11,8 @@
 
 long_description ${description}
 
-fetch		{}
-checksum	{}
-extract		{}
-configure	{}
+distfiles
+use_configure no
 build		{}
 destroot	{
 	system "touch ${destroot}${prefix}/lib/${name}"

Modified: branches/new-help-system/base/tests/test/dependencies-c/master
===================================================================
--- branches/new-help-system/base/tests/test/dependencies-c/master	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/dependencies-c/master	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,4 +1,6 @@
 --->  Computing dependencies for dependencies-c
+--->  Dependencies to be installed: dependencies-a dependencies-b
+--->  Fetching archive for dependencies-b
 --->  Fetching dependencies-b
 --->  Verifying checksum(s) for dependencies-b
 --->  Extracting dependencies-b
@@ -8,6 +10,7 @@
 --->  Installing dependencies-b @1_0
 --->  Activating dependencies-b @1_0
 --->  Cleaning dependencies-b
+--->  Fetching archive for dependencies-a
 --->  Fetching dependencies-a
 --->  Verifying checksum(s) for dependencies-a
 --->  Extracting dependencies-a

Modified: branches/new-help-system/base/tests/test/dependencies-d/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/dependencies-d/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/dependencies-d/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,10 +11,8 @@
 
 long_description ${description}
 
-fetch		{}
-checksum	{}
-extract		{}
-configure	{}
+distfiles
+use_configure no
 build		{}
 destroot	{
 	system "touch ${destroot}${prefix}/lib/${name}"

Modified: branches/new-help-system/base/tests/test/dependencies-e/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/dependencies-e/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/dependencies-e/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,10 +11,8 @@
 
 long_description ${description}
 
-fetch		{}
-checksum	{}
-extract		{}
-configure	{}
+distfiles
+use_configure no
 build		{}
 destroot	{
 	system "touch ${destroot}${prefix}/lib/${name}"

Modified: branches/new-help-system/base/tests/test/dependencies-e/master
===================================================================
--- branches/new-help-system/base/tests/test/dependencies-e/master	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/dependencies-e/master	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,3 +1,4 @@
 --->  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>

Modified: branches/new-help-system/base/tests/test/envvariables/Makefile
===================================================================
--- branches/new-help-system/base/tests/test/envvariables/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/envvariables/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -9,8 +9,8 @@
 test:
 	@PORTSRC=$(PORTSRC) $(bindir)/port clean > /dev/null
 	@sh -c "export ENVA=A ; export ENVB=B; \
-		export PORTSRC=$(PORTSRC); $(bindir)/port -t test" > output 2>&1 || (cat output; exit 1)
-	@diff output master 2>&1 | tee difference
+		export PORTSRC=$(PORTSRC); $(bindir)/port test" > output 2>&1 || (cat output; exit 1)
+	@diff -u master output 2>&1 | tee difference
 	@if [ -s difference ]; then \
 		exit 1; \
 	else \

Modified: branches/new-help-system/base/tests/test/envvariables/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/envvariables/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/envvariables/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,10 +11,8 @@
 
 long_description ${description}
 
-fetch		{}
-checksum	{}
-extract		{}
-configure	{}
+distfiles
+use_configure no
 build		{}
 destroot	{
 	system "touch ${destroot}${prefix}/lib/${name}"

Modified: branches/new-help-system/base/tests/test/envvariables/master
===================================================================
--- branches/new-help-system/base/tests/test/envvariables/master	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/envvariables/master	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,4 +1,3 @@
---->  Computing dependencies for envvariables
 --->  Fetching envvariables
 --->  Verifying checksum(s) for envvariables
 --->  Extracting envvariables

Modified: branches/new-help-system/base/tests/test/site-tags/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/site-tags/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/site-tags/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,10 +11,10 @@
 
 long_description ${description}
 
-master_sites	http://www.douglas.stebila.ca/code/vim/app/:app_aqua \
-				http://www.douglas.stebila.ca/code/vim/doc/:doc_aqua
+master_sites	http://www.douglas.stebila.ca/files/code/vim/app/:app_aqua \
+				http://www.douglas.stebila.ca/files/code/vim/doc/:doc_aqua
 distfiles		app-bm.tar.gz:app_aqua \
-				doc.tar.gz:doc_aqua 
+				doc.tar.gz:doc_aqua
 
 checksums		app-bm.tar.gz \
 					md5 418b9e615a34ae5aad918f5c5a694a44 \
@@ -26,7 +26,7 @@
 					rmd160 3cbae7e39e8c78eca03a0db709cf520003896a12
 
 extract		{}
-configure	{}
+use_configure no
 build		{}
 destroot	{
 	system "touch ${destroot}${prefix}/lib/${name}"
@@ -34,4 +34,4 @@
 
 test {
 	# test is actually running the fetch target
-}
\ No newline at end of file
+}

Modified: branches/new-help-system/base/tests/test/site-tags/master
===================================================================
--- branches/new-help-system/base/tests/test/site-tags/master	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/site-tags/master	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,7 +1,6 @@
---->  Computing dependencies for site-tags
 --->  Fetching site-tags
---->  Attempting to fetch app-bm.tar.gz from http://www.douglas.stebila.ca/code/vim/app/
---->  Attempting to fetch doc.tar.gz from http://www.douglas.stebila.ca/code/vim/doc/
+--->  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
 --->  Extracting site-tags
 --->  Configuring site-tags

Modified: branches/new-help-system/base/tests/test/trace/Makefile
===================================================================
--- branches/new-help-system/base/tests/test/trace/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/trace/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -29,9 +29,9 @@
 	@rm -rf rmdir-trace
 	@rm -f /tmp/hello-trace
 	@sed -e "s|${PWD}|PWD|g" < output > output.sed
-	@diff output.sed master 2>&1 | tee difference
+	@diff -u master output.sed 2>&1 | tee difference
 	@if [ -s difference ]; then \
 		exit 1; \
 	else \
 		rm -f difference output.sed; \
-	fi
\ No newline at end of file
+	fi

Modified: branches/new-help-system/base/tests/test/trace/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/trace/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/trace/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,10 +11,8 @@
 
 long_description ${description}
 
-fetch		{}
-checksum	{}
-extract		{}
-configure	{}
+distfiles
+use_configure no
 build		{}
 destroot	{
 	system "touch ${destroot}${prefix}/lib/${name}"

Modified: branches/new-help-system/base/tests/test/trace/master
===================================================================
--- branches/new-help-system/base/tests/test/trace/master	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/trace/master	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,4 +1,3 @@
---->  Computing dependencies for trace
 --->  Fetching trace
 --->  Verifying checksum(s) for trace
 --->  Extracting trace

Modified: branches/new-help-system/base/tests/test/universal/Makefile
===================================================================
--- branches/new-help-system/base/tests/test/universal/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/universal/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -9,7 +9,7 @@
 test:
 	@PORTSRC=$(PORTSRC) $(bindir)/port clean > /dev/null
 	@sh -c "export PORTSRC=$(PORTSRC); $(bindir)/port info --variants" > output 2>&1 || (cat output; exit 1)
-	@diff output master 2>&1 | tee difference
+	@diff -u master output 2>&1 | tee difference
 	@if [ -s difference ]; then \
 		exit 1; \
 	else \

Modified: branches/new-help-system/base/tests/test/universal/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/universal/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/universal/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,9 +11,7 @@
 
 long_description ${description}
 
-fetch		{}
-checksum	{}
-extract		{}
+distfiles
 configure	{}
 build		{}
 destroot	{

Modified: branches/new-help-system/base/tests/test/universal-2/Makefile
===================================================================
--- branches/new-help-system/base/tests/test/universal-2/Makefile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/universal-2/Makefile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -9,7 +9,7 @@
 test:
 	@PORTSRC=$(PORTSRC) $(bindir)/port clean > /dev/null
 	@sh -c "export PORTSRC=$(PORTSRC); $(bindir)/port info --variants" > output 2>&1 || (cat output; exit 1)
-	@diff output master 2>&1 | tee difference
+	@diff -u master output 2>&1 | tee difference
 	@if [ -s difference ]; then \
 		exit 1; \
 	else \

Modified: branches/new-help-system/base/tests/test/universal-2/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/universal-2/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/universal-2/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,9 +11,7 @@
 
 long_description ${description}
 
-fetch		{}
-checksum	{}
-extract		{}
+distfiles
 configure	{}
 build		{}
 destroot	{

Modified: branches/new-help-system/base/tests/test/variants/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/variants/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/variants/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -11,10 +11,8 @@
 
 long_description ${description}
 
-fetch 		{}
-checksum	{}
-extract		{}
-configure	{}
+distfiles
+use_configure no
 build		{}
 destroot	{
 	system "touch ${destroot}${prefix}/lib/${name}"
@@ -24,19 +22,17 @@
 	# test is actually installing this.
 }
 
-use_configure	no
-
 # We override universal variant.
 variant universal {
 	puts "Universal Variant"
 }
 
-# We define the utopia platform twice
-platform utopia {
-	puts "Utopia platform -- 1"
+# We define the utopia variant twice
+variant utopia {
+	puts "Utopia variant -- 1"
 }
-platform utopia {
-	puts "Utopia platform -- 2"
+variant utopia {
+	puts "Utopia variant -- 2"
 }
 
 default_variants	+utopia

Modified: branches/new-help-system/base/tests/test/variants/master
===================================================================
--- branches/new-help-system/base/tests/test/variants/master	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/variants/master	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,6 +1,5 @@
-Utopia platform -- 1
-Utopia platform -- 1
---->  Computing dependencies for variants
+Utopia variant -- 2
+Utopia variant -- 2
 --->  Fetching variants
 --->  Verifying checksum(s) for variants
 --->  Extracting variants

Modified: branches/new-help-system/base/tests/test/xcodeversion/Portfile
===================================================================
--- branches/new-help-system/base/tests/test/xcodeversion/Portfile	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/xcodeversion/Portfile	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,26 +1,31 @@
 # $Id$
 
 PortSystem 1.0
-name		xcodeversion
-version		1
-categories	test
-maintainers	pguyot at kallisys.net
-description	Test port for \$xcodeversion
-homepage	http://www.macports.org/
-platforms	darwin
+name        xcodeversion
+version     1
+categories  test
+maintainers pguyot at kallisys.net
+description Test port for \$xcodeversion
+homepage    http://www.macports.org/
+platforms   darwin
 
 long_description ${description}
 
-fetch		{}
-checksum	{}
-extract		{}
-configure	{}
-build		{}
-destroot	{
-	system "touch ${destroot}${prefix}/lib/${name}"
+distfiles
+use_configure no
+build       {}
+destroot    {
+    system "touch ${destroot}${prefix}/lib/${name}"
 }
 
 test {
-	ui_msg "xcodeversion = $xcodeversion"
-	ui_msg "xcodebuildcmd = $xcodebuildcmd"
+    # rpm-vercomp is now deprecated, change it here too when removed
+    # from all ports and base (but keep this test here, meanwhile...)
+    # rpm-vercomp removed from ports r89810, from base r89911
+    if {$xcodeversion != "" && [vercmp $xcodeversion 2.1] >= 0} {
+        ui_msg "xcodeversion >= 2.1"
+    } else {
+        ui_msg "xcodeversion = $xcodeversion"
+    }
+    ui_msg "xcodebuildcmd = $xcodebuildcmd"
 }

Modified: branches/new-help-system/base/tests/test/xcodeversion/master
===================================================================
--- branches/new-help-system/base/tests/test/xcodeversion/master	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test/xcodeversion/master	2012-03-03 14:11:19 UTC (rev 90356)
@@ -1,9 +1,8 @@
---->  Computing dependencies for xcodeversion
 --->  Fetching xcodeversion
 --->  Verifying checksum(s) for xcodeversion
 --->  Extracting xcodeversion
 --->  Configuring xcodeversion
 --->  Building xcodeversion
 --->  Testing xcodeversion
-xcodeversion = 2.1
-xcodebuildcmd = xcodebuild
+xcodeversion >= 2.1
+xcodebuildcmd = /usr/bin/xcodebuild

Modified: branches/new-help-system/base/tests/test-macports.conf
===================================================================
--- branches/new-help-system/base/tests/test-macports.conf	2012-03-03 12:15:14 UTC (rev 90355)
+++ branches/new-help-system/base/tests/test-macports.conf	2012-03-03 14:11:19 UTC (rev 90356)
@@ -8,24 +8,14 @@
 portdbpath		/tmp/macports-tests/opt/local/var/macports
 
 # Type of storage to use for the port registry information, "flat" or "sqlite"
-# NOTE: sqlite not yet supported.
-portdbformat		flat
+portdbformat		sqlite
 
-# Type of installation to do for ports, "direct" or "image".  See macports.conf(5) and online documentation.
-portinstalltype		image
-
 # Where to find the sources list.
 sources_conf		/tmp/macports-tests/opt/local/etc/macports/sources.conf
 
 # Where to find global variants definition file (optional)
 #variants_conf		/opt/local/etc/macports/variants.conf
 
-# Create and use binary archive packages for installation/reinstallation ease
-portarchivemode		no
-
-# Where to store/retrieve ports binary archive files
-portarchivepath		/tmp/macports-tests/opt/local/var/macports/packages
-
 # Type of binary archive packages to create when using archive mode
 #
 # Note: Multiple types ARE allowed and must be a colon or comma
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20120303/55d283fc/attachment-0001.html>


More information about the macports-changes mailing list