From 1b4db00efac269d81cc4e461ac5f6e2aa4a60969 Mon Sep 17 00:00:00 2001 From: Joshua Root Date: Thu, 2 Nov 2023 01:12:49 +1100 Subject: [PATCH] Allow "any" in registry os_{platform,major} Now setting these values on installation the same way as the platform string in the archive filename. Also don't consider a port outdated due to platform mismatch if it has an "any" value for these. Closes: https://trac.macports.org/ticket/68256 --- src/macports1.0/macports.tcl | 4 ++-- src/port/port.tcl | 12 ++++++------ src/port1.0/portinstall.tcl | 5 +++-- src/port1.0/portutil.tcl | 24 +++++++++++++++--------- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/macports1.0/macports.tcl b/src/macports1.0/macports.tcl index 8c20905e82..3706262a06 100644 --- a/src/macports1.0/macports.tcl +++ b/src/macports1.0/macports.tcl @@ -4322,9 +4322,9 @@ proc macports::_upgrade {portname dspec variationslist optionslist {depscachenam } elseif {[info exists options(ports_upgrade_enforce-variants)] && $options(ports_upgrade_enforce-variants) && [info exists portinfo(canonical_active_variants)] && $portinfo(canonical_active_variants) ne $oldvariant} { ui_debug "variant override ... upgrading!" - } elseif {$os_platform_installed ne "" && $os_major_installed ne "" && $os_platform_installed != 0 + } elseif {$os_platform_installed ni [list any "" 0] && $os_major_installed ne "" && ([_mportkey $mport os.platform] ne $os_platform_installed - || [_mportkey $mport os.major] != $os_major_installed)} { + || ($os_major_installed ne "any" && [_mportkey $mport os.major] != $os_major_installed))} { ui_debug "platform mismatch ... upgrading!" set build_override 1 } elseif {$cxx_stdlib_overridden == 0 && ($cxx_stdlib_installed eq "libstdc++" || $cxx_stdlib_installed eq "libc++") diff --git a/src/port/port.tcl b/src/port/port.tcl index 368fc04438..c808977f45 100755 --- a/src/port/port.tcl +++ b/src/port/port.tcl @@ -790,9 +790,9 @@ proc get_outdated_ports {} { } else { set wrong_stdlib libc++ } - if {($os_platform_installed ne "" && $os_platform_installed != 0 - && $os_major_installed ne "" && $os_major_installed != 0 - && ($os_platform_installed != ${macports::os_platform} || $os_major_installed != ${macports::os_major})) + if {($os_platform_installed ni [list any "" 0] && $os_major_installed ni [list "" 0] + && ($os_platform_installed != ${macports::os_platform} + || ($os_major_installed ne "any" && $os_major_installed != ${macports::os_major}))) || ($cxx_stdlib_overridden == 0 && $cxx_stdlib_installed eq $wrong_stdlib)} { set comp_result -1 } @@ -3475,9 +3475,9 @@ proc action_outdated { action portlist opts } { set regref [registry::open_entry $portname $installed_version $installed_revision [lindex $i 3] $installed_epoch] set os_platform_installed [registry::property_retrieve $regref os_platform] set os_major_installed [registry::property_retrieve $regref os_major] - if {$os_platform_installed ne "" && $os_platform_installed != 0 - && $os_major_installed ne "" && $os_major_installed != 0 - && ($os_platform_installed != ${macports::os_platform} || $os_major_installed != ${macports::os_major})} { + if {$os_platform_installed ni [list any "" 0] && $os_major_installed ni [list "" 0] + && ($os_platform_installed != ${macports::os_platform} + || ($os_major_installed ne "any" && $os_major_installed != ${macports::os_major}))} { set comp_result -1 set reason { (platform $os_platform_installed $os_major_installed != ${macports::os_platform} ${macports::os_major})} } else { diff --git a/src/port1.0/portinstall.tcl b/src/port1.0/portinstall.tcl index b572da3eb8..a18240f33c 100644 --- a/src/port1.0/portinstall.tcl +++ b/src/port1.0/portinstall.tcl @@ -383,8 +383,9 @@ proc portinstall::install_main {args} { } else { lappend regref requested 0 } - lappend regref os_platform ${os.platform} - lappend regref os_major ${os.major} + lassign [_get_compatible_platform] os_platform os_major + lappend regref os_platform $os_platform + lappend regref os_major $os_major lappend regref archs [get_canonical_archs] if {${portinstall::actual_cxx_stdlib} ne ""} { lappend regref cxx_stdlib ${portinstall::actual_cxx_stdlib} diff --git a/src/port1.0/portutil.tcl b/src/port1.0/portutil.tcl index 855296658f..1a3f8c083f 100644 --- a/src/port1.0/portutil.tcl +++ b/src/port1.0/portutil.tcl @@ -895,19 +895,25 @@ proc _handle_platforms {option action args} { } } -# Platform specifier for binary archive name -# "any" in platforms means the built archive will work on any OS +# Platform and major version this port will be compatible with in built form +# "any" in platforms means the built port will work on any OS # "darwin any" means it will work on any darwin version -proc _get_archive_platform {} { - global platforms os.platform os.subplatform os.major - foreach p $platforms { +# Returns a list: {platform major} +proc _get_compatible_platform {} { + global os.platform + foreach p [option platforms] { if {$p eq "any"} { - return any_any - } elseif {[lindex $p 0] in [list ${os.platform} ${os.subplatform}] && [lindex $p 1] eq "any"} { - return ${os.platform}_any + return [list any any] + } elseif {[lindex $p 0] in [list ${os.platform} [option os.subplatform]] && [lindex $p 1] eq "any"} { + return [list ${os.platform} any] } } - return ${os.platform}_${os.major} + return [list ${os.platform} [option os.major]] +} + +# Platform specifier string for binary archive name +proc _get_archive_platform {} { + return [join [_get_compatible_platform] _] } # Portfiles may define more than one port.