[77511] trunk/base

jmr at macports.org jmr at macports.org
Fri Apr 1 18:47:04 PDT 2011


Revision: 77511
          http://trac.macports.org/changeset/77511
Author:   jmr at macports.org
Date:     2011-04-01 18:47:03 -0700 (Fri, 01 Apr 2011)
Log Message:
-----------
manual merge/rewrite of images-and-archives branch, integrated with archivefetch and registry2.0

Modified Paths:
--------------
    trunk/base/Makefile.in
    trunk/base/doc/macports.conf.5
    trunk/base/doc/macports.conf.in
    trunk/base/doc/port.1
    trunk/base/doc/porthier.7
    trunk/base/src/macports1.0/macports.tcl
    trunk/base/src/macports1.0/macports_autoconf.tcl.in
    trunk/base/src/package1.0/Makefile
    trunk/base/src/package1.0/package.tcl
    trunk/base/src/package1.0/portarchivefetch.tcl
    trunk/base/src/package1.0/portdpkg.tcl
    trunk/base/src/package1.0/portpkg.tcl
    trunk/base/src/package1.0/portrpm.tcl
    trunk/base/src/package1.0/portunarchive.tcl
    trunk/base/src/port/port-help.tcl
    trunk/base/src/port/port.tcl
    trunk/base/src/port1.0/portactivate.tcl
    trunk/base/src/port1.0/portclean.tcl
    trunk/base/src/port1.0/portdeactivate.tcl
    trunk/base/src/port1.0/portinstall.tcl
    trunk/base/src/port1.0/portutil.tcl
    trunk/base/src/registry2.0/portimage.tcl
    trunk/base/src/registry2.0/portuninstall.tcl
    trunk/base/src/registry2.0/receipt_flat.tcl
    trunk/base/src/registry2.0/receipt_sqlite.tcl
    trunk/base/src/registry2.0/registry.tcl
    trunk/base/tests/test-macports.conf

Added Paths:
-----------
    trunk/base/src/images_to_archives.tcl

Removed Paths:
-------------
    trunk/base/src/package1.0/portarchive.tcl

Modified: trunk/base/Makefile.in
===================================================================
--- trunk/base/Makefile.in	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/Makefile.in	2011-04-02 01:47:03 UTC (rev 77511)
@@ -38,9 +38,11 @@
 # Only run these scripts when not building in a destroot
 ifeq ($(DESTDIR),)
 # Add [default] tag to the central MacPorts repository, if it isn't already
-	$(TCLSH) src/upgrade_sources_conf_default.tcl ${prefix}
+	$(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}"
+# Convert image directories (and direct mode installs) to image archives
+	$(TCLSH) src/images_to_archives.tcl "${macports_tcl_dir}"
 endif
 	@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 ""

Modified: trunk/base/doc/macports.conf.5
===================================================================
--- trunk/base/doc/macports.conf.5	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/doc/macports.conf.5	2011-04-02 01:47:03 UTC (rev 77511)
@@ -67,17 +67,6 @@
 .br
 .Ic Default:
 sqlite
-.It Va portinstalltype
-Sets the mode in which ports are installed by MacPorts. Supported values are 'direct' or 'image'.
-The 'direct' mode is often used on systems that do not support 'image' due to limitations in their
-installed version of Tcl. In 'direct' mode ports are installed directly into '${prefix}' and only
-one flavor of a port can be installed at any given time. In 'image' mode multiple flavors of a port
-(i.e., different versions and/or any possible combination of its variants) can be installed concurrently
-into '${portdbpath}/software/${portname}' and only one can be "activated" onto '${prefix}' via soft or
-hard links from the former to the latter.
-.br
-.Ic Default:
-image
 .It Va applications_dir
 Directory containing Applications installed from ports.
 .br
@@ -102,26 +91,16 @@
 .br
 .Ic Default:
 ${prefix}/etc/macports/variants.conf
-.It Va portarchivemode
-Key governing the creation of binary archives of installed ports for installation/reinstallation ease.
-.br
-.Ic Default:
-yes
-.It Va portarchivepath
-Location to store ports' binary archive files when archive mode is active.
-.br
-.Ic Default:
-${portdbpath}/packages
 .It Va portarchivetype
-Colon or comma separated, space free list of supported formats of archives to create or read from when
-\&'${archivemode}' is set to 'yes'. 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 any existing archive,
-with the first found match being used.
+Format of archives in which to store port images. This controls both the type
+of archive created locally after building from source, and the type to request
+from remote servers. Changing this will not affect the usability of already
+installed archives; they can be of any supported type.
 .br
 Supported types are: tgz, tar, tbz, tbz2, tlz, txz, xar, zip, cpgz, cpio
 .br
 .Ic Default:
-tgz
+tbz2
 .It Va configureccache
 Use ccache (C/C++ compiler cache). Requires that ccache has been installed.
 .br

Modified: trunk/base/doc/macports.conf.in
===================================================================
--- trunk/base/doc/macports.conf.in	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/doc/macports.conf.in	2011-04-02 01:47:03 UTC (rev 77511)
@@ -14,9 +14,6 @@
 # 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
@@ -36,22 +33,10 @@
 # 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
-
-# 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

Modified: trunk/base/doc/port.1
===================================================================
--- trunk/base/doc/port.1	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/doc/port.1	2011-04-02 01:47:03 UTC (rev 77511)
@@ -249,9 +249,9 @@
 .It Fl o
 honor state files older than Portfile
 .It Fl s
-source-only mode (build and install from source, ignore all binary archives, do not create/recreate binary archives) (only applies when archive mode is enabled)
+source-only mode (build and install from source, do not attempt to fetch binary archives)
 .It Fl b
-binary-only mode (build and install from binary archives, ignore source, abort if no archive present; do not create/recreate binary archives from source) (only applies when archive mode is enabled)
+binary-only mode (build and install from binary archives, ignore source, abort if no archive available)
 .It Fl c
 autoclean mode (execute clean after install)
 .It Fl k
@@ -471,27 +471,15 @@
 This is the default when no flag is given.
 To remove the distribution files (tarballs, etc), specify
 .Fl -dist .
-To remove the archive(s) for the current version of a port, pass
-.Fl -archive .
-To remove the work files, distribution files and archives, pass
+To remove the work files, distribution files and logs, pass
 .Fl -all .
 To remove log files for certain port, pass
 .Fl -logs .
 For example:
 .Pp
 .Dl "port clean --dist vim"
-.Dl "port clean --archive vim"
 .Dl "port clean --logs vim"
 .Pp
-To remove only certain version(s) of a port's archives (
-.Ar version
-is any valid UNIX glob pattern), you can use:
-.Pp
-.Dl "port clean --archive vim 6.2.114"
-.Pp
-or:
-.Pp
-.Dl "port clean --archive vim '6.*'"
 .Ss log
 Parses and shows log files for
 .Ar portname .
@@ -605,12 +593,6 @@
 .Ss ed
 An alias for
 .Ic edit .
-.Ss unarchive
-Unpack the port from a pre-built binary archive. When archive mode is enabled, this command is called automatically, prior to
-.Ar fetch ,
-to check for an existing binary archive to unpack. If found, it is unpacked and all stages up to
-.Ar install
-are then skipped.
 .Ss fetch
 Fetches the distribution files required to build
 .Ar portname .
@@ -644,14 +626,6 @@
 .Ar portname .
 To nitpick about whitespace and patchfile names, use
 .Fl -nitpick .
-.Ss archive
-Archive the port for a later
-.Ar unarchive .
-When archive mode is enabled, binary archives will be created automatically whenever an
-.Ar install
-is performed, or when the
-.Ar archive
-target is called explicitly.
 .Ss distcheck
 Check if the distfiles haven't changed and can be fetched.
 .Ss distfiles

Modified: trunk/base/doc/porthier.7
===================================================================
--- trunk/base/doc/porthier.7	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/doc/porthier.7	2011-04-02 01:47:03 UTC (rev 77511)
@@ -98,13 +98,11 @@
 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
 .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

Added: trunk/base/src/images_to_archives.tcl
===================================================================
--- trunk/base/src/images_to_archives.tcl	                        (rev 0)
+++ trunk/base/src/images_to_archives.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -0,0 +1,140 @@
+#!/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
+
+mportinit
+
+# 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
+}
+
+foreach installed $ilist {
+    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}]
+        if {[llength $archs] == 1} {
+            set oldarchivedir [file join $oldarchivedir $archs $iname]
+        } else {
+            set oldarchivedir [file join $oldarchivedir universal $iname]
+        }
+        set found 0
+        foreach type {tbz2 tbz tgz tar txz tlz xar xpkg zip cpgz cpio} {
+            set oldarchivefullpath "[file join $oldarchivedir $oldarchiverootname].${type}"
+            if {[file isfile $oldarchivefullpath]} {
+                set found 1
+                set archivetype $type
+                break
+            }
+        }
+
+        # compute new name and location of archive
+        set archivename "${iname}-${iversion}_${irevision}${ivariants}.${macports::os_platform}_${macports::os_major}.[join $archs -].${archivetype}"
+        if {$installtype == "image"} {
+            set targetdir [file dirname $location]
+        } else {
+            set targetdir [file join ${macports::registry.path} software ${iname}]
+        }
+        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 *"
+        } 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]
+            set contents [registry::property_retrieve $iref contents]
+            foreach entry $contents {
+                puts $fd [lindex $entry 0]
+                if {${macports::registry.format} == "receipt_flat"} {
+                    registry::register_file [lindex $entry 0] $iname
+                }
+            }
+            system "$tarcmd -cjf $newlocation -T ${targetdir}/tarlist"
+            close $fd
+            file delete -force ${targetdir}/tarlist
+            
+            # change receipt to image
+            if {${macports::registry.format} == "receipt_sqlite"} {
+                $iref installtype image
+                $iref state imaged
+                $iref activate [$iref imagefiles]
+                $iref state installed
+            } else {
+                registry::property_store $iref installtype image
+                registry::property_store $iref active 1
+            }
+        }
+
+        if {${macports::registry.format} == "flat" && $installtype == "image"} {
+            # flat receipts also need file paths in contents trimmed to exclude image dir
+            set loclen [string length $location]
+            set locend [expr $loclen - 1]
+            set oldcontents [registry::property_retrieve $iref contents]
+            set newcontents {}
+            foreach fe $contents {
+                set oldfilepath [lindex $fe 0]
+                if {[string range $oldfilepath 0 $locend] == $location} {
+                    set newfilepath [string range $oldfilepath $loclen end]
+                    set newentry [list $newfilepath]
+                    foreach other [lrange $fe 1 end] {
+                        lappend newentry $other
+                    }
+                    lappend newcontents $newentry
+                } else {
+                    lappend newcontents $fe
+                }
+            }
+            registry::property_store $iref contents $newcontents
+        }
+        # set the new location in the registry and delete the old dir
+        registry::property_store $iref location $newlocation
+        if {${macports::registry.format} == "flat"} {
+            registry::write_entry $iref
+        }
+        if {$location != "" && [file isdirectory $location]} {
+            file delete -force $location
+        }
+    }
+}
+
+exit 0


Property changes on: trunk/base/src/images_to_archives.tcl
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/macports1.0/macports.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -41,7 +41,7 @@
     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 ccache_dir ccache_size configuredistcc configurepipe buildnicevalue buildmakejobs \
@@ -51,7 +51,7 @@
     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 \
         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 ccache_dir ccache_size configuredistcc configurepipe buildnicevalue buildmakejobs \
@@ -450,7 +450,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
@@ -653,13 +652,6 @@
         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
-    }
-
     # Autoclean mode, whether to automatically call clean after "install"
     if {![info exists portautoclean]} {
         set macports::portautoclean "yes"
@@ -704,36 +696,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]} {
@@ -1003,7 +973,7 @@
 }
 
 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
@@ -1074,6 +1044,7 @@
     $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
@@ -1115,10 +1086,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.
@@ -1158,7 +1125,7 @@
 }
 
 proc macports::fetch_port {url} {
-    global macports::portdbpath tcl_platform
+    global macports::portdbpath
     set fetchdir [file join $portdbpath portdirs]
     set fetchfile [file tail $url]
     file mkdir $fetchdir
@@ -1471,7 +1438,7 @@
     return [$workername eval registry_exists_for_name \${name}]
 }
 
-# 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} {
@@ -1489,7 +1456,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
@@ -1501,7 +1468,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)
@@ -1509,11 +1476,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
@@ -1597,8 +1560,6 @@
 # mportexec
 # Execute the specified target of the given mport.
 proc mportexec {mport target} {
-    global macports::registry.installtype
-
     set workername [ditem_key $mport workername]
 
     # check variants
@@ -1660,13 +1621,8 @@
         }
 
         # 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 != {}} {
@@ -1726,11 +1682,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)]} {
@@ -1804,11 +1756,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]
@@ -2708,7 +2656,6 @@
         test -
         destroot -
         install -
-        archive -
         activate -
         dmg -
         mdmg -
@@ -2733,7 +2680,6 @@
         test        -
         srpm        -
         destroot    { return "depends_fetch depends_extract depends_build depends_lib depends_run" }
-        archive     -
         dmg         -
         pkg         -
         mdmg        -
@@ -2921,8 +2867,6 @@
 
 # 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
 
@@ -3252,13 +3196,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"
             }
@@ -3268,82 +3207,60 @@
         }
     }
 
-    # 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.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 $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.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)
+        }
+        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} {
@@ -3584,3 +3501,15 @@
     }
     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"
+    }
+}

Modified: trunk/base/src/macports1.0/macports_autoconf.tcl.in
===================================================================
--- trunk/base/src/macports1.0/macports_autoconf.tcl.in	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/macports1.0/macports_autoconf.tcl.in	2011-04-02 01:47:03 UTC (rev 77511)
@@ -32,6 +32,7 @@
 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@"
@@ -39,7 +40,10 @@
     variable macports_user_dir "~/.macports"
     variable macportsuser "@RUNUSR@"
     variable open_path "@OPEN@"
+    variable pax_path "@PAX@"
     variable rsync_path "@RSYNC@"
     variable tar_command "@TAR_CMD@"
     variable tar_path "@TAR@"
+    variable unzip_path "@UNZIP@"
+    variable xar_path "@XAR@"
 }

Modified: trunk/base/src/package1.0/Makefile
===================================================================
--- trunk/base/src/package1.0/Makefile	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/package1.0/Makefile	2011-04-02 01:47:03 UTC (rev 77511)
@@ -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: trunk/base/src/package1.0/package.tcl
===================================================================
--- trunk/base/src/package1.0/package.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/package1.0/package.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -42,4 +42,3 @@
 package require portportpkg 1.0
 package require portarchivefetch 1.0
 package require portunarchive 1.0
-package require portarchive 1.0

Deleted: trunk/base/src/package1.0/portarchive.tcl
===================================================================
--- trunk/base/src/package1.0/portarchive.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/package1.0/portarchive.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -1,526 +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 ""
-                    } 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}"
-        }
-    }
-    set res [mport_lookup $name]
-    if {[llength $res] < 2} {
-        ui_error "Port $name not found"
-    } else {
-        array set portinfo [lindex $res 1]
-        foreach key "depends_lib depends_run" {
-             if {[info exists portinfo($key)]} {
-                 foreach depspec $portinfo($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}"
-                     }
-                 }
-             }
-        }
-    }
-    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: trunk/base/src/package1.0/portarchivefetch.tcl
===================================================================
--- trunk/base/src/package1.0/portarchivefetch.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/package1.0/portarchivefetch.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -62,55 +62,32 @@
 default archive_sites macports_archives
 default archive_sites.listfile {"archive_sites.tcl"}
 default archive_sites.listpath {"port1.0/fetch"}
-default archive.subdir {[portarchivefetch::get_archive_subdir]}
 
 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]]
-    }
-}
-
 # 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 \
+           name 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
-        }
-    }
-    if {$found} {
-        ui_debug "Found [string toupper ${archive.type}] archive: ${archive.path}"
+    # throws an error if unsupported
+    archiveTypeIsSupported $portarchivetype
+
+    if {[file isfile ${archive.path}]} {
+        ui_debug "Found 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"
+    } else {
+        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}
+        }
     }
 }
 
@@ -133,7 +110,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 +126,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"
@@ -245,12 +222,20 @@
                     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]"
     } else {
@@ -260,9 +245,7 @@
 
 # Initialize archivefetch target and call checkfiles.
 proc portarchivefetch::archivefetch_init {args} {
-    if {[option portarchivemode] != "yes"} {
-        return -code error "Archive mode is not enabled!"
-    }
+    return 0
 }
 
 proc portarchivefetch::archivefetch_start {args} {
@@ -282,8 +265,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: trunk/base/src/package1.0/portdpkg.tcl
===================================================================
--- trunk/base/src/package1.0/portdpkg.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/package1.0/portdpkg.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -37,7 +37,7 @@
 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 {
 }

Modified: trunk/base/src/package1.0/portpkg.tcl
===================================================================
--- trunk/base/src/package1.0/portpkg.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/package1.0/portpkg.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -36,11 +36,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 {
 }

Modified: trunk/base/src/package1.0/portrpm.tcl
===================================================================
--- trunk/base/src/package1.0/portrpm.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/package1.0/portrpm.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -36,7 +36,7 @@
 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 {
 }

Modified: trunk/base/src/package1.0/portunarchive.tcl
===================================================================
--- trunk/base/src/package1.0/portunarchive.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/package1.0/portunarchive.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -53,31 +53,19 @@
 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 \
+           ports_force ports_source_only ports_binary_only \
+           name 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]} {
@@ -93,21 +81,15 @@
         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} {
@@ -116,27 +98,25 @@
             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!"
             } 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 ($name) 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 name version revision portvariants \
+           unarchive.type unarchive.skip
 
+    if {${unarchive.skip}} {
+        return 0
+    }
+
     if {[getuid] == 0 && [geteuid] != 0} {
         # run as root if possible so file ownership can be preserved
         elevateToRoot "unarchive"
@@ -148,11 +128,9 @@
 }
 
 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 {}
@@ -227,7 +205,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"
@@ -264,9 +242,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
 
@@ -287,8 +268,12 @@
 }
 
 proc portunarchive::unarchive_finish {args} {
-    global UI_PREFIX target_state_fd unarchive.file name workpath destpath
+    global UI_PREFIX target_state_fd unarchive.file name 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]

Modified: trunk/base/src/port/port-help.tcl
===================================================================
--- trunk/base/src/port/port-help.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/port/port-help.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -13,10 +13,6 @@
 --no-exec   Do not execute any stored pre- or post-activate procedures
 }
 
-set porthelp(archive) {
-Archive the given ports
-}
-
 set porthelp(archivefetch) {
 Fetch archive for the given ports
 }
@@ -42,7 +38,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)
@@ -319,7 +314,7 @@
 }
 
 set porthelp(unarchive) {
-Unarchive the given ports
+Unarchive the destroot of the given ports from installed images
 }
 
 set porthelp(uninstall) {

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/port/port.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -715,9 +715,6 @@
 
 
 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] } {
@@ -741,7 +738,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]
 
@@ -2112,13 +2109,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
@@ -2932,9 +2925,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
@@ -2976,7 +2967,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]
@@ -3827,7 +3818,6 @@
     unload      [list action_target         [ACTION_ARGS_PORTS]] \
     distfiles   [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]] \
@@ -3899,7 +3889,7 @@
     deactivate  {no-exec}
     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}

Modified: trunk/base/src/port1.0/portactivate.tcl
===================================================================
--- trunk/base/src/port1.0/portactivate.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/port1.0/portactivate.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -40,11 +40,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,20 +50,17 @@
 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 name 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 $name "${version}_${revision}${portvariants}" [array get user_options]
 
     # Display notes at the end of the activation phase.
     if {[info exists PortInfo(notes)] && $PortInfo(notes) ne {}} {

Modified: trunk/base/src/port1.0/portclean.tcl
===================================================================
--- trunk/base/src/port1.0/portclean.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/port1.0/portclean.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -57,7 +57,7 @@
 
 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} {
@@ -69,15 +69,9 @@
         ui_info "$UI_PREFIX [format [msgcat::mc "Removing distfiles for %s"] [option name]]"
         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"))} {
+        !([info exists ports_clean_logs] && $ports_clean_logs == "yes")} {
          ui_info "$UI_PREFIX [format [msgcat::mc "Removing work directory for %s"] [option name]]"
          clean_work
     }
@@ -255,54 +249,3 @@
     }           	
     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: trunk/base/src/port1.0/portdeactivate.tcl
===================================================================
--- trunk/base/src/port1.0/portdeactivate.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/port1.0/portdeactivate.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -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 name version revision portvariants user_options
+    registry_deactivate $name "${version}_${revision}${portvariants}" [array get user_options]
     return 0
 }

Modified: trunk/base/src/port1.0/portinstall.tcl
===================================================================
--- trunk/base/src/port1.0/portinstall.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/port1.0/portinstall.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -38,11 +38,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 {
@@ -76,84 +72,442 @@
     }
 }
 
-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 name version revision portvariants \
+           epoch os.platform PortInfo installPlist \
+           archive.env archive.cmd archive.pre_args archive.args \
+           archive.post_args archive.dir
+    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
+
+    set archive.fulldestpath [file dirname $location]
+    # 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}]} {
+        return -code error "no destroot found at: ${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}"
+        }
+    }
+    set res [mport_lookup $name]
+    if {[llength $res] < 2} {
+        ui_error "Port $name not found"
+    } else {
+        array set portinfo [lindex $res 1]
+        foreach key "depends_lib depends_run" {
+             if {[info exists portinfo($key)]} {
+                 foreach depspec $portinfo($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}"
+                     }
+                 }
+             }
+        }
+    }
+    # also save the contents for our own use later
+    set installPlist {}
+    fs-traverse -depth fullpath $destpath {
+        if {[file isdirectory $fullpath]} {
+            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
+
+    # 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
+
+        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
+    }
+
+    # 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} {
+    switch -- $type {
+        tbz -
+        tbz2 {
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOjqf $location +CONTENTS]
+        }
+        tgz {
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOzqf $location +CONTENTS]
+        }
+        tar {
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOqf $location +CONTENTS]
+        }
+        txz {
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOqf $location --use-compress-program [findBinary xz ""] +CONTENTS]
+        }
+        tlz {
+            set raw_contents [exec [findBinary tar ${portutil::autoconf::tar_path}] -xOqf $location --use-compress-program [findBinary lzma ""] +CONTENTS]
+        }
+        xar {
+            system "cd ${workpath} && [findBinary xar ${portutil::autoconf::xar_path}] -xf $location +CONTENTS"
+            set twostep 1
+        }
+        xpkg {
+            system "cd ${workpath} && [findBinary xar ${portutil::autoconf::xar_path}] -xf $location --compression=bzip2 +CONTENTS"
+            set twostep 1
+        }
+        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
+    foreach line [split $raw_contents \n] {
+        if {$ignore} {
+            set ignore 0
+            continue
+        }
+        if {[string index $line 0] != "@"} {
+            lappend contents $line
+        } elseif {$line == "@ignore"} {
+            set ignore 1
+        }
+    }
+    return $contents
+}
+
 proc portinstall::install_main {args} {
     global name version portpath categories description long_description \
-    homepage depends_run installPlist package-install workdir workpath \
+    homepage depends_run 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
+    registry.format os.platform os.major portarchivetype installPlist
 
     set oldpwd [pwd]
     if {$oldpwd == ""} {
         set oldpwd $portpath
     }
-    _cd $workpath
 
+    # 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]
+    }
+
     if {[string equal ${registry.format} "receipt_sqlite"]} {
         # registry2.0
 
@@ -188,20 +542,10 @@
                 $regref depends $dep_portname
             }
 
-            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
+            $regref installtype image
+            $regref state imaged
+            $regref location $location
 
-            # 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
@@ -219,12 +563,7 @@
             registry_prop_store $regref negated_variants $negated_variants
         }
 
-        set imagedir ""
-        if { [registry_prop_retr $regref installtype] == "image" } {
-            set imagedir [registry_prop_retr $regref imagedir]
-        }
-        # Install the files
-        directory_dig ${destroot} ${destroot} ${imagedir}
+        registry_prop_store $regref location $location
 
         registry_prop_store $regref requested $user_options(ports_requested)
         registry_prop_store $regref categories $categories
@@ -257,10 +596,7 @@
             registry_register_deps $depends_lib $name
         }
         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
-            }
+            registry_prop_store $regref contents [_fake_fileinfo_for_index $installPlist]
         }
         if {[info exists package-install]} {
             registry_prop_store $regref package-install ${package-install}

Modified: trunk/base/src/port1.0/portutil.tcl
===================================================================
--- trunk/base/src/port1.0/portutil.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/port1.0/portutil.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -1296,7 +1296,6 @@
                         test        -
                         destroot    -
                         install     -
-                        archive     -
                         dmg         -
                         pkg         -
                         portpkg     -
@@ -2154,6 +2153,26 @@
     }
 }
 
+# return path where the image/archive for this port will be stored
+proc get_portimage_path {} {
+    global registry.path name version revision portvariants os.platform os.major portarchivetype
+    return [file join ${registry.path} software ${name} "${name}-${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} {
@@ -2199,7 +2218,7 @@
                 }
             }
         }
-        xar {
+        xar|xpkg {
             set xar "xar"
             if {[catch {set xar [findBinary $xar ${portutil::autoconf::xar_path}]} errmsg] == 0} {
                 return 0
@@ -2531,14 +2550,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
     }
@@ -2636,30 +2650,25 @@
 
 # check if we can unarchive this port
 proc _archive_available {} {
-    global name version revision portvariants ports_source_only
-    global unarchive.srcpath workpath
+    global name version revision portvariants ports_source_only workpath \
+           registry.path os.platform os.major
 
-    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 ${name} "${name}-${version}_${revision}${portvariants}.${os.platform}_${os.major}.[join [get_canonical_archs] -].${unarchive.type}"]
+        if {[file isfile $fullarchivepath]} {
+            set found 1
+            break
         }
     }
+    
+    # TODO: also check if porturl points to an archive
+    # maybe check if there's an archive available on the server too - this
+    # is kind of useless otherwise now that archive == installed image
+
     return $found
 }

Modified: trunk/base/src/registry2.0/portimage.tcl
===================================================================
--- trunk/base/src/registry2.0/portimage.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/registry2.0/portimage.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -41,27 +41,23 @@
 
 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
@@ -101,6 +97,7 @@
             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 current [registry::entry installed $name]
@@ -114,7 +111,9 @@
             if { ![string equal [$requested installtype] "image"] } {
                 return -code error "Image error: ${name} @${version}_${revision}${variants} not installed as an image."
             }
-
+            if {![file isfile $location]} {
+                return -code error "Image error: Can't find image file $location"
+            }
             if { [string equal [$requested state] "installed"] } {
                 return -code error "Image error: ${name} @${version}_${revision}${variants} is already active."
             }
@@ -152,6 +151,10 @@
         if { ![string equal [registry::property_retrieve $ref installtype] "image"] } {
             return -code error "Image error: ${name} @${version}_${revision}${variants} not installed as an image."
         }
+        set location [registry::property_retrieve $ref location]
+        if {![file isfile $location]} {
+            return -code error "Image error: Can't find image file $location"
+        }
         if { [registry::property_retrieve $ref active] != 0 } {
             return -code error "Image error: ${name} @${version}_${revision}${variants} is already active."
         }
@@ -171,14 +174,15 @@
         _activate_contents $requested
         $requested state installed
     } else {
-        set imagedir [registry::property_retrieve $ref imagedir]
-
         set contents [registry::property_retrieve $ref contents]
 
-        set imagefiles [_check_contents $name $contents $imagedir]
+        set imagefiles {}
+        foreach content_element $contents {
+            lappend imagefiles [lindex $content_element 0]
+        }
 
         registry::open_file_map
-        _activate_contents $name $imagefiles $imagedir
+        _activate_contents $name $imagefiles $location
 
         registry::property_store $ref active 1
 
@@ -297,7 +301,7 @@
 }
 
 proc _check_registry {name v} {
-    global UI_PREFIX macports::registry.installtype
+    global UI_PREFIX
     variable use_reg2
 
     if {$use_reg2} {
@@ -358,24 +362,6 @@
     }
 }
 
-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
-        }
-    }
-
-    return $imagefiles
-}
-
 ## Activates a file from an image into the filesystem. Deals with symlinks,
 ## directories and files.
 ##
@@ -384,11 +370,6 @@
 ## @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
-        }
         directory {
             # Don't recursively copy directories
             ui_debug "activating directory: $dstfile"
@@ -404,18 +385,149 @@
         }
         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} {
+    set extractdir [mkdtemp [file join [macports::gettmpdir] mpextractXXXXXXXX]]
+
+    try {
+        set startpwd [pwd]
+        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 tail $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
@@ -424,16 +536,17 @@
     set files [list]
     set baksuffix .mp_[clock seconds]
     if {$use_reg2} {
-        set imagedir [$port location]
+        set location [$port location]
         set imagefiles [$port imagefiles]
     } else {
         set name $port
     }
+    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
@@ -443,7 +556,7 @@
         try {
             registry::write {
                 foreach file $imagefiles {
-                    set srcfile "${imagedir}${file}"
+                    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
@@ -532,7 +645,7 @@
                 try {
                     $port activate $imagefiles
                     foreach file $files {
-                        if {[_activate_file "${imagedir}${file}" $file] == 1} {
+                        if {[_activate_file "${extracted_dir}${file}" $file] == 1} {
                             lappend rollback_filelist $file
                         }
                     }
@@ -561,18 +674,21 @@
                     activate [$entry name] $pvers [list ports_activate_no-exec $noexec]
                 }
             }
+            # remove temp image dir
+            file delete -force $extracted_dir
             throw
         }
     } else {
         # registry1.0
         set deactivated [list]
         foreach file $imagefiles {
-            set srcfile "${imagedir}${file}"
+            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}] } {
+                file delete -force $extracted_dir
                 return -code error "Image error: Source file $srcfile does not appear to exist (cannot lstat it).  Unable to activate port $name."
             }
 
@@ -583,6 +699,7 @@
                 if {[catch {mportlookup $port} result]} {
                     global errorInfo
                     ui_debug "$errorInfo"
+                    file delete -force $extracted_dir
                     return -code error "port lookup failed: $result"
                 }
                 array unset portinfo
@@ -595,8 +712,10 @@
             }
     
             if { $port != 0  && $force != 1 && $port != $name } {
+                file delete -force $extracted_dir
                 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 } {
+                file delete -force $extracted_dir
                 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}"
@@ -643,7 +762,7 @@
 
         # Activate it, and catch errors so we can roll-back
         if { [catch { foreach file $files {
-                        if {[_activate_file "${imagedir}${file}" $file] == 1} {
+                        if {[_activate_file "${extracted_dir}${file}" $file] == 1} {
                             lappend rollback_filelist $file
                         }
                     }} result]} {
@@ -667,9 +786,11 @@
             }
             registry::write_file_map
 
+            file delete -force $extracted_dir
             return -code error $result
         }
     }
+    file delete -force $extracted_dir
 }
 
 proc _deactivate_file {dstfile} {

Modified: trunk/base/src/registry2.0/portuninstall.tcl
===================================================================
--- trunk/base/src/registry2.0/portuninstall.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/registry2.0/portuninstall.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -42,7 +42,7 @@
 
 proc uninstall {portname {v ""} optionslist} {
     global uninstall.force uninstall.nochecksum UI_PREFIX \
-           macports::registry.format macports::registry.installtype
+           macports::registry.format macports::portimagefilepath
     array set options $optionslist
 
     if {![info exists uninstall.force]} {
@@ -141,15 +141,13 @@
             # check its dependents
             registry::check_dependents $port ${uninstall.force}
         }
-        # if it's an image, deactivate it
+        # 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 @${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]
-                    }
+                    portimage::deactivate $portname $v [array get options]
                 }
             }
         }
@@ -205,8 +203,7 @@
             }
         }
     
-        set installtype [registry::property_retrieve $ref installtype]
-        if { $installtype == "image" && [registry::property_retrieve $ref active] == 1} {
+        if { [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 {
@@ -214,7 +211,11 @@
             }
         }
     }
-    
+
+    if {$use_reg2} {
+        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}
@@ -245,9 +246,6 @@
                 array set depportinfo [lindex $result 1]
                 set porturl $depportinfo(porturl)
                 set variations {}
-                if {$use_reg2} {
-                    set ref $port
-                }
                 set minusvariant [lrange [split [registry::property_retrieve $ref negated_variants] -] 1 end]
                 set plusvariant [lrange [split $variants +] 1 end]
                 foreach v $plusvariant {
@@ -304,71 +302,13 @@
             }
         }
     
-        # 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}"}
-                }
-            }
+        # 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]}
 
-            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 {
@@ -413,33 +353,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: trunk/base/src/registry2.0/receipt_flat.tcl
===================================================================
--- trunk/base/src/registry2.0/receipt_flat.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/registry2.0/receipt_flat.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -101,7 +101,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
 	
@@ -131,10 +130,9 @@
 			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] } {
@@ -311,7 +309,6 @@
 # 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]

Modified: trunk/base/src/registry2.0/receipt_sqlite.tcl
===================================================================
--- trunk/base/src/registry2.0/receipt_sqlite.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/registry2.0/receipt_sqlite.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -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
         }
@@ -167,8 +161,6 @@
 # Otherwise, return only ports that exactly match this version.
 # What we call version here is version_revision+variants.
 proc installed {{name ""} {version ""}} {
-    global macports::registry.installtype
-
 	if { $name == "" && $version == "" } {
 	    set ports [registry::entry imaged]
 	} elseif { $name != "" && $version == ""} {

Modified: trunk/base/src/registry2.0/registry.tcl
===================================================================
--- trunk/base/src/registry2.0/registry.tcl	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/src/registry2.0/registry.tcl	2011-04-02 01:47:03 UTC (rev 77511)
@@ -45,7 +45,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 +60,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 {
@@ -459,31 +455,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: trunk/base/tests/test-macports.conf
===================================================================
--- trunk/base/tests/test-macports.conf	2011-04-02 00:26:11 UTC (rev 77510)
+++ trunk/base/tests/test-macports.conf	2011-04-02 01:47:03 UTC (rev 77511)
@@ -10,21 +10,12 @@
 # Type of storage to use for the port registry information, "flat" or "sqlite"
 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/20110401/85e10e30/attachment-0001.html>


More information about the macports-changes mailing list