

--- src/port1.0/portinstall.tcl.orig	2008-04-28 21:29:37.000000000 -0600
+++ src/port1.0/portinstall.tcl	2009-04-04 20:15:24.000000000 -0600
@@ -128,7 +128,7 @@
 }
 
 proc install_main {args} {
-	global portname portversion portpath categories description long_description homepage depends_run installPlist package-install uninstall workdir worksrcdir pregrefix UI_PREFIX destroot portrevision maintainers ports_force portvariants targets depends_lib PortInfo epoch
+	global portname portversion portpath categories description long_description homepage depends_run installPlist package-install workdir worksrcdir pregrefix UI_PREFIX destroot portrevision maintainers ports_force portvariants targets depends_lib PortInfo epoch
 
 	# Begin the registry entry
    	set regref [registry_new $portname $portversion $portrevision $portvariants $epoch]
@@ -168,7 +168,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 
@@ -176,9 +176,23 @@
     return 0
 }
 
+#
+# apparent usage of pkg_uninstall variable in the registry
+# the Portfile needs to define a procedure
+# proc pkg_uninstall {portname portver} {
+#     body of proc
+# }
+# which gets stored above into the registry pkg_uninstall variable
+# this is then called by the portuninstall procedure
+# note that in general the portuninstall procedure is not called within
+# the context of its port 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 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]} {
@@ -188,6 +202,6 @@
 	}
 	set space " "
     }
-    append p "\} \{" [info body $pname] "\}"
+    append p "} {" [string map { \n \\n } [info body $pname] ] " }"
     return $p
 }


--- src/registry1.0/portuninstall.tcl.orig	2008-06-04 02:32:15.000000000 -0600
+++ src/registry1.0/portuninstall.tcl	2009-04-04 20:14:58.000000000 -0600
@@ -140,7 +140,8 @@
 	# 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]} {
+		if {![catch {eval [string map { \\n \n } $uninstall]} err]} {
+			ui_info "Executing pkg_uninstall procedure"
 			pkg_uninstall $portname ${version}_${revision}${variants}
 		} else {
 			global errorInfo

