[64638] trunk/base/src

jmr at macports.org jmr at macports.org
Fri Mar 12 06:28:01 PST 2010


Revision: 64638
          http://trac.macports.org/changeset/64638
Author:   jmr at macports.org
Date:     2010-03-12 06:28:00 -0800 (Fri, 12 Mar 2010)
Log Message:
-----------
make deactivate and uninstall into real targets, have action_{activate,deactivate,uninstall} run targets using the portfile stored in the registry

Modified Paths:
--------------
    trunk/base/src/macports1.0/macports.tcl
    trunk/base/src/port/port.tcl
    trunk/base/src/port1.0/Makefile
    trunk/base/src/port1.0/port.tcl
    trunk/base/src/port1.0/portactivate.tcl

Added Paths:
-----------
    trunk/base/src/port1.0/portdeactivate.tcl
    trunk/base/src/port1.0/portuninstall.tcl

Modified: trunk/base/src/macports1.0/macports.tcl
===================================================================
--- trunk/base/src/macports1.0/macports.tcl	2010-03-12 01:00:52 UTC (rev 64637)
+++ trunk/base/src/macports1.0/macports.tcl	2010-03-12 14:28:00 UTC (rev 64638)
@@ -988,6 +988,8 @@
     $workername alias registry_exists registry::entry_exists
     $workername alias registry_exists_for_name registry::entry_exists_for_name
     $workername alias registry_activate portimage::activate
+    $workername alias registry_deactivate portimage::deactivate
+    $workername alias registry_uninstall portuninstall::uninstall
     $workername alias registry_register_deps registry::register_dependencies
     $workername alias registry_fileinfo_for_index registry::fileinfo_for_index
     $workername alias registry_bulk_register_files registry::register_bulk_files
@@ -1283,6 +1285,50 @@
     return $mport
 }
 
+# mportopen_installed
+# opens a portfile stored in the registry
+proc mportopen_installed {name version revision variants options} {
+    global macports::registry.format macports::registry.path
+    if {${registry.format} != "receipt_sqlite"} {
+        return -code error "mportopen_installed requires sqlite registry"
+    }
+    set regref [lindex [registry::entry imaged $name $version $revision $variants] 0]
+    set portfile_dir [file join ${registry.path} registry portfiles $name "${version}_${revision}${variants}"]
+    file mkdir $portfile_dir
+    set fd [open ${portfile_dir}/Portfile w]
+    puts $fd [$regref portfile]
+    close $fd
+    
+    set variations {}
+    set minusvariant [lrange [split [$regref negated_variants] -] 1 end]
+    set plusvariant [lrange [split [$regref variants] +] 1 end]
+    foreach v $plusvariant {
+        lappend variations $v "+"
+    }
+    foreach v $minusvariant {
+        lappend variations $v "-"
+    }
+    set variations [mport_filtervariants $variations no]
+    
+    return [mportopen "file://${portfile_dir}/" $options $variations]
+}
+
+# mportclose_installed
+# close mport opened with mportopen_installed and clean up associated files
+proc mportclose_installed {mport} {
+    global macports::registry.path
+    foreach key {name version revision portvariants} {
+        set $key [_mportkey $mport $key]
+    }
+    mportclose $mport
+    set portfiles_dir [file join ${registry.path} registry portfiles $name]
+    set portfile [file join $portfiles_dir "${version}_${revision}${portvariants}" Portfile]
+    file delete -force $portfile [file dirname $portfile]
+    if {[llength [glob -nocomplain -directory $portfiles_dir *]] == 0} {
+        file delete -force $portfiles_dir
+    }
+}
+
 # Traverse a directory with ports, calling a function on the path of ports
 # (at the second depth).
 # I.e. the structure of dir shall be:

Modified: trunk/base/src/port/port.tcl
===================================================================
--- trunk/base/src/port/port.tcl	2010-03-12 01:00:52 UTC (rev 64637)
+++ trunk/base/src/port/port.tcl	2010-03-12 14:28:00 UTC (rev 64638)
@@ -1977,13 +1977,33 @@
 
 
 proc action_activate { action portlist opts } {
+    global macports::registry.format
     set status 0
     if {[require_portlist portlist]} {
         return 1
     }
     foreachport $portlist {
+        set composite_version [composite_version $portversion [array get variations]]
+        if {${macports::registry.format} == "receipt_sqlite" && ![catch {set ilist [registry::installed $portname $composite_version]}] && [llength $ilist] == 1} {
+            set i [lindex $ilist 0]
+            set iversion [lindex $i 1]
+            set irevision [lindex $i 2]
+            set ivariants [lindex $i 3]
+            if {![catch {set mport [mportopen_installed $portname $iversion $irevision $ivariants [array get options]]}]} {
+                if {[catch {set result [mportexec $mport activate]} result]} {
+                    global errorInfo
+                    mportclose_installed $mport
+                    ui_debug "$errorInfo"
+                    break_softcontinue "Unable to execute port: $result" 1 status
+                }
+                mportclose_installed $mport
+                continue
+            } else {
+                ui_warn "Could not open Portfile from registry for $portname $composite_version"
+            }
+        }
         if {![macports::global_option_isset ports_dryrun]} {
-            if { [catch {portimage::activate $portname [composite_version $portversion [array get variations]] [array get options]} result] } {
+            if { [catch {portimage::activate $portname $composite_version [array get options]} result] } {
                 global errorInfo
                 ui_debug "$errorInfo"
                 break_softcontinue "port activate failed: $result" 1 status
@@ -1998,13 +2018,37 @@
 
 
 proc action_deactivate { action portlist opts } {
+    global macports::registry.format
     set status 0
     if {[require_portlist portlist]} {
         return 1
     }
     foreachport $portlist {
+        set composite_version [composite_version $portversion [array get variations]]
+        if {${macports::registry.format} == "receipt_sqlite" && ![catch {set ilist [registry::active $portname]}]} {
+            set i [lindex $ilist 0]
+            set iversion [lindex $i 1]
+            set irevision [lindex $i 2]
+            set ivariants [lindex $i 3]
+            if {$composite_version == "" || $composite_version == "${iversion}_${irevision}${ivariants}"} {
+                if {![catch {set mport [mportopen_installed $portname $iversion $irevision $ivariants [array get options]]}]} {
+                    if {[catch {set result [mportexec $mport deactivate]} result]} {
+                        global errorInfo
+                        mportclose_installed $mport
+                        ui_debug "$errorInfo"
+                        break_softcontinue "Unable to execute port: $result" 1 status
+                    }
+                    mportclose_installed $mport
+                    continue
+                } else {
+                    global errorInfo
+                    ui_debug "$errorInfo"
+                    ui_warn "Could not open Portfile from registry for $portname $composite_version"
+                }
+            }
+        }
         if {![macports::global_option_isset ports_dryrun]} {
-            if { [catch {portimage::deactivate $portname [composite_version $portversion [array get variations]] [array get options]} result] } {
+            if { [catch {portimage::deactivate $portname $composite_version [array get options]} result] } {
                 global errorInfo
                 ui_debug "$errorInfo"
                 break_softcontinue "port deactivate failed: $result" 1 status
@@ -2231,6 +2275,7 @@
 
 
 proc action_uninstall { action portlist opts } {
+    global macports::registry.format
     set status 0
     if {[macports::global_option_isset port_uninstall_old]} {
         # if -u then uninstall all inactive ports
@@ -2248,7 +2293,27 @@
             ui_info "$portname is already uninstalled"
             continue
         }
-        if { [catch {portuninstall::uninstall $portname [composite_version $portversion [array get variations]] [array get options]} result] } {
+        set composite_version [composite_version $portversion [array get variations]]
+        if {${macports::registry.format} == "receipt_sqlite" && ![catch {set ilist [registry::installed $portname $composite_version]}] && [llength $ilist] == 1} {
+            set i [lindex $ilist 0]
+            set iversion [lindex $i 1]
+            set irevision [lindex $i 2]
+            set ivariants [lindex $i 3]
+            if {![catch {set mport [mportopen_installed $portname $iversion $irevision $ivariants [array get options]]}]} {
+                if {[catch {set result [mportexec $mport uninstall]} result]} {
+                    global errorInfo
+                    mportclose_installed $mport
+                    ui_debug "$errorInfo"
+                    break_softcontinue "Unable to execute port: $result" 1 status
+                }
+                mportclose_installed $mport
+                continue
+            } else {
+                ui_warn "Could not open Portfile from registry for $portname $composite_version"
+            }
+        }
+
+        if { [catch {portuninstall::uninstall $portname $composite_version [array get options]} result] } {
             global errorInfo
             ui_debug "$errorInfo"
             break_softcontinue "port uninstall failed: $result" 1 status

Modified: trunk/base/src/port1.0/Makefile
===================================================================
--- trunk/base/src/port1.0/Makefile	2010-03-12 01:00:52 UTC (rev 64637)
+++ trunk/base/src/port1.0/Makefile	2010-03-12 14:28:00 UTC (rev 64638)
@@ -2,11 +2,11 @@
 
 SRCS=	port.tcl portchecksum.tcl portconfigure.tcl portextract.tcl	    \
 	portfetch.tcl portmain.tcl portbuild.tcl portpatch.tcl portutil.tcl \
-	portinstall.tcl portdepends.tcl portdestroot.tcl portlint.tcl \
-	portclean.tcl porttest.tcl portactivate.tcl portsubmit.tcl \
-	port_autoconf.tcl portstartupitem.tcl porttrace.tcl portlivecheck.tcl \
-	portdistcheck.tcl portmirror.tcl portload.tcl portunload.tcl \
-	portdistfiles.tcl
+	portinstall.tcl portuninstall.tcl portdepends.tcl portdestroot.tcl \
+	portlint.tcl portclean.tcl porttest.tcl portactivate.tcl \
+	portdeactivate.tcl portsubmit.tcl port_autoconf.tcl portstartupitem.tcl \
+	porttrace.tcl portlivecheck.tcl portdistcheck.tcl portmirror.tcl \
+	portload.tcl portunload.tcl portdistfiles.tcl
 
 include ../../Mk/macports.subdir.mk
 include ../../Mk/macports.autoconf.mk

Modified: trunk/base/src/port1.0/port.tcl
===================================================================
--- trunk/base/src/port1.0/port.tcl	2010-03-12 01:00:52 UTC (rev 64637)
+++ trunk/base/src/port1.0/port.tcl	2010-03-12 14:28:00 UTC (rev 64638)
@@ -43,7 +43,9 @@
 package require portbuild 1.0
 package require portdestroot 1.0
 package require portinstall 1.0
+package require portuninstall 1.0
 package require portactivate 1.0
+package require portdeactivate 1.0
 package require portclean 1.0
 package require porttest 1.0
 package require portlint 1.0

Modified: trunk/base/src/port1.0/portactivate.tcl
===================================================================
--- trunk/base/src/port1.0/portactivate.tcl	2010-03-12 01:00:52 UTC (rev 64637)
+++ trunk/base/src/port1.0/portactivate.tcl	2010-03-12 14:28:00 UTC (rev 64638)
@@ -1,4 +1,4 @@
-# et:ts=4
+# -*- 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
 # portactivate.tcl
 # $Id$
 #
@@ -49,11 +49,12 @@
 namespace eval portactivate {
 }
 
-set_ui_prefix
+options activate.asroot
+default activate.asroot yes
 
 proc portactivate::activate_main {args} {
     global env name version revision portvariants user_options portnotes
-    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 portnotes] && $portnotes ne {}} {

Copied: trunk/base/src/port1.0/portdeactivate.tcl (from rev 64607, trunk/base/src/port1.0/portactivate.tcl)
===================================================================
--- trunk/base/src/port1.0/portdeactivate.tcl	                        (rev 0)
+++ trunk/base/src/port1.0/portdeactivate.tcl	2010-03-12 14:28:00 UTC (rev 64638)
@@ -0,0 +1,54 @@
+# -*- 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
+# portdeactivate.tcl
+# $Id$
+#
+# Copyright (c) 2010 The MacPorts Project
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of The MacPorts Project nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+# the 'deactivate' target is provided by this package
+
+package provide portdeactivate 1.0
+package require portutil 1.0
+
+set org.macports.deactivate [target_new org.macports.deactivate portdeactivate::deactivate_main]
+target_runtype ${org.macports.deactivate} always
+target_state ${org.macports.deactivate} no
+target_provides ${org.macports.deactivate} deactivate
+target_requires ${org.macports.deactivate} main
+
+namespace eval portdeactivate {
+}
+
+options deactivate.asroot
+default deactivate.asroot yes
+
+proc portdeactivate::deactivate_main {args} {
+    global name version revision portvariants user_options
+    registry_deactivate $name "${version}_${revision}${portvariants}" [array get user_options]
+    return 0
+}

Copied: trunk/base/src/port1.0/portuninstall.tcl (from rev 64607, trunk/base/src/port1.0/portactivate.tcl)
===================================================================
--- trunk/base/src/port1.0/portuninstall.tcl	                        (rev 0)
+++ trunk/base/src/port1.0/portuninstall.tcl	2010-03-12 14:28:00 UTC (rev 64638)
@@ -0,0 +1,54 @@
+# -*- 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
+# portuninstall.tcl
+# $Id$
+#
+# Copyright (c) 2010 The MacPorts Project
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+# 3. Neither the name of The MacPorts Project nor the names of its contributors
+#    may be used to endorse or promote products derived from this software
+#    without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+
+# the 'uninstall' target is provided by this package
+
+package provide portuninstall 1.0
+package require portutil 1.0
+
+set org.macports.uninstall [target_new org.macports.uninstall portuninstall::uninstall_main]
+target_runtype ${org.macports.uninstall} always
+target_state ${org.macports.uninstall} no
+target_provides ${org.macports.uninstall} uninstall
+target_requires ${org.macports.uninstall} main
+
+namespace eval portuninstall {
+}
+
+options uninstall.asroot
+default uninstall.asroot yes
+
+proc portuninstall::uninstall_main {args} {
+    global name version revision portvariants user_options
+    registry_uninstall $name "${version}_${revision}${portvariants}" [array get user_options]
+    return 0
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100312/def5a90b/attachment-0001.html>


More information about the macports-changes mailing list