Ticket #19176: patch-unsintall-new.diff

File patch-unsintall-new.diff, 3.0 KB (added by david.osguthorpe@…, 15 years ago)
  • src/registry1.0/portuninstall.tcl

     
    140140        # Look to see if the port has registered an uninstall procedure
    141141        set uninstall [registry::property_retrieve $ref pkg_uninstall]
    142142        if { $uninstall != 0 } {
    143                 if {![catch {eval $uninstall} err]} {
    144                         pkg_uninstall $portname ${version}_${revision}${variants}
     143                if {![catch {eval [string map { \\n \n } $uninstall]} err]} {
     144                        ui_info "Executing pkg_uninstall procedure"
     145                        if {[catch {pkg_uninstall $portname ${version}_${revision}${variants} } err]} {
     146                                ui_error [format [msgcat::mc "Error executing pkg_uninstall procedure: %s"] $err]
     147                        }
    145148                } else {
    146149                        global errorInfo
    147150                        ui_debug "$errorInfo"
  • src/port1.0/portinstall.tcl

     
    128128}
    129129
    130130proc install_main {args} {
    131         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
     131        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
    132132
    133133        # Begin the registry entry
    134134        set regref [registry_new $portname $portversion $portrevision $portvariants $epoch]
     
    168168                registry_prop_store $regref package-install ${package-install}
    169169    }
    170170    if {[info proc pkg_uninstall] == "pkg_uninstall"} {
    171                 registry_prop_store $regref uninstall [proc_disasm pkg_uninstall]
     171                registry_prop_store $regref pkg_uninstall [proc_disasm pkg_uninstall]
    172172    }
    173173       
    174174        registry_write $regref
     
    176176    return 0
    177177}
    178178
     179#
     180# apparent usage of pkg_uninstall variable in the registry
     181# the Portfile needs to define a procedure
     182# proc pkg_uninstall {portname portver} {
     183#     body of proc
     184# }
     185# which gets stored above into the registry pkg_uninstall variable
     186# this is then called by the portuninstall procedure
     187# note that in general the portuninstall procedure is not called within
     188# the context of its port so many usual port variables do not exist
     189# e.g. destroot/workpath/filespath
     190 
     191# this procedure encodes the pkg_uninstall body so that it can be stored in the
     192# the receipt file
    179193proc proc_disasm {pname} {
    180194    set p "proc "
    181     append p $pname " \{"
     195    append p $pname " {"
    182196    set space ""
    183197    foreach arg [info args $pname] {
    184198        if {[info default $pname $arg value]} {
     
    188202        }
    189203        set space " "
    190204    }
    191     append p "\} \{" [info body $pname] "\}"
     205    append p "} {" [string map { \n \\n } [info body $pname] ] " }"
    192206    return $p
    193207}