Changeset 54378


Ignore:
Timestamp:
Jul 25, 2009, 9:31:51 PM (10 years ago)
Author:
jmr@…
Message:

Add 'replaced_by' portfile option to allow renaming or replacing ports. Also add a --no-replace option to upgrade to stop it from doing the replacements. Closes #20157.

Location:
trunk/base/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/macports1.0/macports.tcl

    r54376 r54378  
    24252425    set oldvariantlist [mport_filtervariants $oldvariantlist no]
    24262426
     2427    # at this point we need to check if a different port will be replacing this one
     2428    if {[info exists portinfo(replaced_by)] && ![info exists options(ports_upgrade_no-replace)]} {
     2429        ui_debug "$portname is replaced by $portinfo(replaced_by)"
     2430        if {[catch {mportlookup $portinfo(replaced_by)} result]} {
     2431            global errorInfo
     2432            ui_debug "$errorInfo"
     2433            ui_error "port lookup failed: $result"
     2434            return 1
     2435        }
     2436        if {$result == ""} {
     2437            ui_error "No port $portinfo(replaced_by) found."
     2438            return 1
     2439        }
     2440        array unset portinfo
     2441        array set portinfo [lindex $result 1]
     2442        set newname $portinfo(name)
     2443        set version_in_tree "$portinfo(version)"
     2444
     2445        set porturl $portinfo(porturl)
     2446        if {![info exists porturl]} {
     2447            set porturl file://./
     2448        }
     2449        set depscache(port:${newname}) 1
     2450    } else {
     2451        set newname $portname
     2452    }
     2453
    24272454    # check if the variants are present in $version_in_tree
    24282455    if {[info exists portinfo(variants)]} {
     
    24342461    foreach {variation value} $oldvariantlist {
    24352462        if {[lsearch $avariants $variation] != -1} {
    2436             ui_debug "variant $variation is present in $portname $version_in_tree"
     2463            ui_debug "variant $variation is present in $newname $version_in_tree"
    24372464            if { ![info exists variations($variation)]} {
    24382465                set variations($variation) $value
     
    24612488    array unset portinfo
    24622489    array set portinfo [mportinfo $workername]
    2463     set portwasopened 1
    24642490    set version_in_tree "$portinfo(version)"
    24652491    set revision_in_tree "$portinfo(revision)"
     
    24842510                && [rpm-vercomp $revision_installed $revision_in_tree] >= 0 ))
    24852511        && ![info exists options(ports_upgrade_force)] } {
    2486         if { $epoch_installed < $epoch_in_tree } {
     2512        if {$portname != $newname} {
     2513            ui_debug "ignoring versions, installing replacement port"
     2514        } elseif { $epoch_installed < $epoch_in_tree } {
    24872515            set epoch_override 1
    24882516            ui_debug "epoch override ... upgrading!"
     
    25322560    # avoid building again unnecessarily
    25332561    if {[info exists options(ports_upgrade_force)] || $epoch_override == 1
    2534         || ![registry::entry_exists $portname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]} {
     2562        || ![registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]} {
    25352563        if {[catch {set result [mportexec $workername $upgrade_action]} result] || $result != 0} {
    25362564            global errorInfo
     
    25632591    } else {
    25642592        # are we installing an existing version due to force or epoch override?
    2565         if {[registry::entry_exists $portname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]
     2593        if {[registry::entry_exists $newname $version_in_tree $revision_in_tree $portinfo(canonical_active_variants)]
    25662594            && ([info exists options(ports_upgrade_force)] || $epoch_override == 1)} {
    2567              ui_debug "Uninstalling $portname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants)"
     2595             ui_debug "Uninstalling $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants)"
    25682596            # we have to force the uninstall in case of dependents
    25692597            set force_cur [info exists options(ports_force)]
    25702598            set options(ports_force) yes
    25712599            if {$is_dryrun eq "yes"} {
    2572                 ui_msg "Skipping uninstall $portname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)"
    2573             } elseif {[catch {portuninstall::uninstall $portname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) [array get options]} result]} {
     2600                ui_msg "Skipping uninstall $newname @${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) (dry run)"
     2601            } elseif {[catch {portuninstall::uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) [array get options]} result]} {
    25742602                global errorInfo
    25752603                ui_debug "$errorInfo"
    2576                 ui_error "Uninstall $portname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) failed: $result"
     2604                ui_error "Uninstall $newname ${version_in_tree}_${revision_in_tree}$portinfo(canonical_active_variants) failed: $result"
    25772605                catch {mportclose $workername}
    25782606                return 1
     
    25822610            }
    25832611            if {$anyactive && $version_in_tree == $version_active && $revision_in_tree == $revision_active
    2584                 && $portinfo(canonical_active_variants) == $variant_active} {
     2612                && $portinfo(canonical_active_variants) == $variant_active && $portname == $newname} {
    25852613                set anyactive no
    25862614            }
     
    26062634
    26072635    if {$is_dryrun eq "yes"} {
    2608         ui_msg "Skipping activate $portname @${version_in_tree}_${revision_in_tree} (dry run)"
     2636        ui_msg "Skipping activate $newname @${version_in_tree}_${revision_in_tree} (dry run)"
    26092637    } elseif {[catch {set result [mportexec $workername install]} result]} {
    26102638        global errorInfo
    26112639        ui_debug "$errorInfo"
    2612         ui_error "Couldn't activate $portname ${version_in_tree}_${revision_in_tree}: $result"
     2640        ui_error "Couldn't activate $newname ${version_in_tree}_${revision_in_tree}: $result"
    26132641        catch {mportclose $workername}
    26142642        return 1
     
    26202648            set revision [lindex $i 2]
    26212649            set variant [lindex $i 3]
    2622             if {$version == $version_in_tree && $revision == $revision_in_tree && $variant == $portinfo(canonical_active_variants)} {
     2650            if {$version == $version_in_tree && $revision == $revision_in_tree && $variant == $portinfo(canonical_active_variants) && $portname == $newname} {
    26232651                continue
    26242652            }
     
    26292657                global errorInfo
    26302658                ui_debug "$errorInfo"
    2631                 ui_error "Uninstall $portname @${version}_${revision}${variant} failed: $result"
    2632                 catch {mportclose $workername}
    2633                 return 1
     2659                # replaced_by can mean that we try to uninstall all versions of the old port, so handle errors due to dependents
     2660                if {$result != "Please uninstall the ports that depend on $portname first." && ![ui_isset ports_processall]} {
     2661                    ui_error "Uninstall $portname @${version}_${revision}${variant} failed: $result"
     2662                    catch {mportclose $workername}
     2663                    return 1
     2664                }
    26342665            }
    26352666        }
     
    26422673
    26432674        registry::open_dep_map
    2644         set deplist [registry::list_dependents $portname]
     2675        set deplist [registry::list_dependents $newname]
     2676        if {$portname != $newname} {
     2677            set deplist [concat $deplist [registry::list_dependents $portname]]
     2678        }
    26452679
    26462680        if { [llength deplist] > 0 } {
  • trunk/base/src/port/port-help.tcl

    r54376 r54378  
    287287--enforce-variants  If the installed variants do not match those requested,
    288288                    upgrade even if the port is not outdated.
     289--no-replace        Do not replace one port with another according to the
     290                    replaced_by field
    289291}
    290292
  • trunk/base/src/port/port.tcl

    r54376 r54378  
    14931493            license     License
    14941494            conflicts   "Conflicts with"
     1495            replaced_by "Replaced by"
    14951496        }
    14961497
     
    14981499        array set pretty_wrap {
    14991500            heading 0
     1501            replaced_by 22
    15001502            variants 22
    15011503            depends_fetch 22
     
    15611563        set fields_tried {}
    15621564        if {![llength $opts_todo]} {
    1563             set opts_todo {ports_info_heading ports_info_variants
     1565            set opts_todo {ports_info_heading
     1566                ports_info_replaced_by
     1567                ports_info_variants
    15641568                ports_info_skip_line
    15651569                ports_info_long_description ports_info_homepage
     
    31033107                 line long_description
    31043108                 maintainer maintainers name platform platforms portdir pretty
    3105                  revision variant variants version}
     3109                 replaced_by revision variant variants version}
    31063110    search      {case-sensitive category categories depends_fetch
    31073111                 depends_extract depends_build depends_lib depends_run
     
    31163120    lint        {nitpick}
    31173121    select      {list set show}
    3118     upgrade     {force enforce-variants}
     3122    upgrade     {force enforce-variants no-replace}
    31193123}
    31203124
  • trunk/base/src/port/portindex.tcl

    r53740 r54378  
    6969        }
    7070
    71         set keepkeys {categories depends_fetch depends_extract depends_build depends_lib depends_run description epoch homepage long_description maintainers name platforms revision variants version portdir portarchive}
     71        set keepkeys {categories depends_fetch depends_extract depends_build depends_lib depends_run description epoch homepage long_description maintainers name platforms revision variants version portdir portarchive replaced_by}
    7272        foreach availkey [array names portinfo] {
    7373            if {[lsearch -exact ${keepkeys} $availkey] == -1} {
  • trunk/base/src/port1.0/portmain.tcl

    r54368 r54378  
    4646# define options
    4747options prefix macportsuser name version revision epoch categories maintainers
    48 options long_description description homepage license provides conflicts
     48options long_description description homepage license provides conflicts replaced_by
    4949options worksrcdir filesdir distname portdbpath libpath distpath sources_conf os.platform os.version os.major os.arch os.endian platforms default_variants install.user install.group macosx_deployment_target
    5050options universal_variant os.universal_supported
     
    5252
    5353# Export options via PortInfo
    54 options_export name version revision epoch categories maintainers platforms description long_description homepage license provides conflicts
     54options_export name version revision epoch categories maintainers platforms description long_description homepage license provides conflicts replaced_by
    5555
    5656# Assign option procedure to default_variants
Note: See TracChangeset for help on using the changeset viewer.