[64640] trunk/base/src

jmr at macports.org jmr at macports.org
Fri Mar 12 08:47:29 PST 2010


Revision: 64640
          http://trac.macports.org/changeset/64640
Author:   jmr at macports.org
Date:     2010-03-12 08:47:29 -0800 (Fri, 12 Mar 2010)
Log Message:
-----------
fix flat registry's pkg_uninstall functionality (#19176)

Modified Paths:
--------------
    trunk/base/src/port1.0/portinstall.tcl
    trunk/base/src/registry2.0/portuninstall.tcl

Modified: trunk/base/src/port1.0/portinstall.tcl
===================================================================
--- trunk/base/src/port1.0/portinstall.tcl	2010-03-12 15:46:13 UTC (rev 64639)
+++ trunk/base/src/port1.0/portinstall.tcl	2010-03-12 16:47:29 UTC (rev 64640)
@@ -140,7 +140,7 @@
 
 proc portinstall::install_main {args} {
     global name version portpath categories description long_description \
-    homepage depends_run installPlist package-install uninstall workdir \
+    homepage depends_run installPlist package-install workdir \
     worksrcdir UI_PREFIX destroot revision maintainers user_options \
     portvariants negated_variants targets depends_lib PortInfo epoch license \
     registry.installtype registry.path registry.format \
@@ -275,7 +275,7 @@
             registry_prop_store $regref package-install ${package-install}
         }
         if {[info proc pkg_uninstall] == "pkg_uninstall"} {
-            registry_prop_store $regref uninstall [proc_disasm pkg_uninstall]
+            registry_prop_store $regref pkg_uninstall [proc_disasm pkg_uninstall]
         }
 
         registry_write $regref
@@ -284,9 +284,22 @@
     return 0
 }
 
+# apparent usage of pkg_uninstall variable in the (flat) registry
+# the Portfile needs to define a procedure
+# proc pkg_uninstall {portname portver} {
+#     body of proc
+# }
+# which gets stored above in the receipt's pkg_uninstall property
+# this is then called by the portuninstall procedure
+# note that the portuninstall procedure is not called within
+# the context of the portfile so many usual port variables do not exist
+# e.g. destroot/workpath/filespath
+ 
+# this procedure encodes the pkg_uninstall body so that it can be stored in the
+# the receipt file
 proc portinstall::proc_disasm {pname} {
     set p "proc "
-    append p $pname " \{"
+    append p $pname " {"
     set space ""
     foreach arg [info args $pname] {
         if {[info default $pname $arg value]} {
@@ -296,6 +309,6 @@
         }
         set space " "
     }
-    append p "\} \{" [info body $pname] "\}"
+    append p "} {" [string map { \n \\n } [info body $pname] ] " }"
     return $p
 }

Modified: trunk/base/src/registry2.0/portuninstall.tcl
===================================================================
--- trunk/base/src/registry2.0/portuninstall.tcl	2010-03-12 15:46:13 UTC (rev 64639)
+++ trunk/base/src/registry2.0/portuninstall.tcl	2010-03-12 16:47:29 UTC (rev 64640)
@@ -212,15 +212,15 @@
 
     ui_msg "$UI_PREFIX [format [msgcat::mc "Uninstalling %s @%s"] $portname $v]"
 
-    if {$use_reg2} {
-        # pkg_uninstall isn't used anywhere as far as I can tell and I intend to add
-        # some proper pre-/post- hooks to uninstall/deactivate.
-    } else {
+    if {!$use_reg2} {
         # Look to see if the port has registered an uninstall procedure
         set uninstall [registry::property_retrieve $ref pkg_uninstall] 
         if { $uninstall != 0 } {
-            if {![catch {eval $uninstall} err]} {
-                pkg_uninstall $portname $v
+            if {![catch {eval [string map { \\n \n } $uninstall]} err]} {
+                ui_info "Executing pkg_uninstall procedure"
+                if {[catch {pkg_uninstall $portname "${version}_${revision}${variants}" } err]} {
+                    ui_error [format [msgcat::mc "Error executing pkg_uninstall procedure: %s"] $err]
+                }
             } else {
                 global errorInfo
                 ui_debug "$errorInfo"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20100312/d81d5a94/attachment.html>


More information about the macports-changes mailing list