<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/99fafc70894f7d6aae1264a271a3c8761f2e7d4a">https://github.com/macports/macports-base/commit/99fafc70894f7d6aae1264a271a3c8761f2e7d4a</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 99fafc70894f7d6aae1264a271a3c8761f2e7d4a
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Mon Feb 12 02:21:14 2024 +1100
<span style='display:block; white-space:pre;color:#404040;'> Use dict in portimage::install and portinstall
</span>---
src/port1.0/portinstall.tcl | 52 +++++++++++++++++++++----------------------
src/registry2.0/portimage.tcl | 43 ++++++++++++++++++-----------------
2 files changed, 48 insertions(+), 47 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portinstall.tcl b/src/port1.0/portinstall.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index d0e2a3927..62d083d24 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portinstall.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portinstall.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -275,6 +275,7 @@ proc portinstall::create_archive {location archive.type} {
</span>
set have_fileIsBinary [expr {[option os.platform] eq "darwin"}]
set binary_files [list]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portinstall::file_is_binary [dict create]
</span> # also save the contents for our own use later
set installPlist [list]
set destpathLen [string length $destpath]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -299,7 +300,7 @@ proc portinstall::create_archive {location archive.type} {
</span> lappend binary_files $fullpath
}
puts $fd "@comment binary:$is_binary"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set portinstall::file_is_binary($abspath) $is_binary
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set portinstall::file_is_binary $abspath $is_binary
</span> }
}
} else {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -361,7 +362,7 @@ proc portinstall::install_main {args} {
</span> set current_archive_type [string range [file extension $location] 1 end]
set contents [extract_contents $location $current_archive_type]
set installPlist [lindex $contents 0]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set portinstall::file_is_binary [lindex $contents 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portinstall::file_is_binary [lindex $contents 1]
</span> set cxxinfo [extract_archive_metadata $location $current_archive_type cxx_info]
set portinstall::actual_cxx_stdlib [lindex $cxxinfo 0]
set portinstall::cxx_stdlib_overridden [lindex $cxxinfo 1]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -385,60 +386,59 @@ proc portinstall::install_main {args} {
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref name $subport
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref version $version
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref revision $revision
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref variants $portvariants
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref epoch $epoch
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set regref [dict create]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref name $subport
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref version $version
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref revision $revision
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref variants $portvariants
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref epoch $epoch
</span> if {[info exists user_options(ports_requested)]} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref requested $user_options(ports_requested)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref requested $user_options(ports_requested)
</span> } else {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref requested 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref requested 0
</span> }
lassign [_get_compatible_platform] os_platform os_major
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref os_platform $os_platform
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref os_major $os_major
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref archs [get_canonical_archs]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref os_platform $os_platform
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref os_major $os_major
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref archs [get_canonical_archs]
</span> if {${portinstall::actual_cxx_stdlib} ne ""} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref cxx_stdlib ${portinstall::actual_cxx_stdlib}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref cxx_stdlib_overridden ${portinstall::cxx_stdlib_overridden}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref cxx_stdlib ${portinstall::actual_cxx_stdlib}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref cxx_stdlib_overridden ${portinstall::cxx_stdlib_overridden}
</span> } else {
# no info in the archive
global configure.cxx_stdlib cxx_stdlib
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref cxx_stdlib_overridden [expr {${configure.cxx_stdlib} ne $cxx_stdlib}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref cxx_stdlib_overridden [expr {${configure.cxx_stdlib} ne $cxx_stdlib}]
</span> }
# Trick to have a portable GMT-POSIX epoch-based time.
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref date [expr {[clock scan now -gmt true] - [clock scan "1970-1-1 00:00:00" -gmt true]}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref date [expr {[clock scan now -gmt true] - [clock scan "1970-1-1 00:00:00" -gmt true]}]
</span> if {[info exists requested_variants]} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref requested_variants $requested_variants
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref requested_variants $requested_variants
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref depends $dep_portnames
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref depends $dep_portnames
</span>
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref location $location
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref location $location
</span>
if {[info exists installPlist]} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref files $installPlist
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref binary [array get portinstall::file_is_binary]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref files $installPlist
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref binary $portinstall::file_is_binary
</span> }
# portfile info
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref portfile_path [file join $portpath Portfile]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref portfile_path [file join $portpath Portfile]
</span>
# portgroup info
if {[info exists PortInfo(portgroups)]} {
set regref_pgs [list]
foreach pg $PortInfo(portgroups) {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set pgname [lindex $pg 0]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set pgversion [lindex $pg 1]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set groupFile [lindex $pg 2]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lassign $pg pgname pgversion groupFile
</span> if {[file isfile $groupFile]} {
lappend regref_pgs $pgname $pgversion $groupFile
} else {
ui_debug "install_main: no portgroup ${pgname}-${pgversion}.tcl found"
}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend regref portgroups $regref_pgs
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set regref portgroups $regref_pgs
</span> }
registry_install $regref
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/registry2.0/portimage.tcl b/src/registry2.0/portimage.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 472340138..7a1cbbed5 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/registry2.0/portimage.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/registry2.0/portimage.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -850,26 +850,26 @@ proc _deactivate_contents {port imagefiles {force 0} {rollback 0}} {
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-# Create a new registry entry using the given metadata array
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# Create a new registry entry using the given metadata dictionary
</span> proc install {metadata} {
global macports::registry.path
<span style='display:block; white-space:pre;background:#ffe0e0;'>- array set m $metadata
</span> registry::write {
# store portfile
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set portfile_sha256 [sha256 file $m(portfile_path)]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set portfile_size [file size $m(portfile_path)]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set portfile_reg_dir [file join ${registry.path} registry portfiles $m(name)-$m(version)_$m(revision) ${portfile_sha256}-${portfile_size}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portfile_path [dict get $metadata portfile_path]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portfile_sha256 [sha256 file $portfile_path]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portfile_size [file size $portfile_path]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portfile_reg_dir [file join ${registry.path} registry portfiles [dict get $metadata name]-[dict get $metadata version]_[dict get $metadata revision] ${portfile_sha256}-${portfile_size}]
</span> set portfile_reg_path ${portfile_reg_dir}/Portfile
file mkdir $portfile_reg_dir
if {![file isfile $portfile_reg_path] || [file size $portfile_reg_path] != $portfile_size
|| [sha256 file $portfile_reg_path] ne $portfile_sha256} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- file copy -force $m(portfile_path) $portfile_reg_dir
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ file copy -force $portfile_path $portfile_reg_dir
</span> file attributes $portfile_reg_path -permissions 0644
}
# store portgroups
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists m(portgroups)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach {pgname pgversion groupFile} $m(portgroups) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $metadata portgroups]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach {pgname pgversion groupFile} [dict get $metadata portgroups] {
</span> set pgsha256 [sha256 file $groupFile]
set pgsize [file size $groupFile]
set pg_reg_dir [file join ${registry.path} registry portgroups ${pgsha256}-${pgsize}]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -881,10 +881,10 @@ proc install {metadata} {
</span> }
file attributes $pg_reg_path -permissions 0644
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- unset m(portgroups)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict unset metadata portgroups
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set regref [registry::entry create $m(name) $m(version) $m(revision) $m(variants) $m(epoch)]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set regref [registry::entry create [dict get $metadata name] [dict get $metadata version] [dict get $metadata revision] [dict get $metadata variants] [dict get $metadata epoch]]
</span> $regref installtype image
$regref state imaged
$regref portfile ${portfile_sha256}-${portfile_size}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -893,28 +893,29 @@ proc install {metadata} {
</span> $regref addgroup {*}$p
}
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach dep_portname $m(depends) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach dep_portname [dict get $metadata depends] {
</span> $regref depends $dep_portname
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists m(files)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $metadata files]} {
</span> # register files
<span style='display:block; white-space:pre;background:#ffe0e0;'>- $regref map $m(files)
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- unset m(files)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $regref map [dict get $metadata files]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict unset metadata files
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[info exists m(binary)]} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach {f isbinary} $m(binary) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[dict exists $metadata binary]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict for {f isbinary} [dict get $metadata binary] {
</span> set fileref [registry::file open [$regref id] $f]
$fileref binary $isbinary
registry::file close $fileref
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- unset m(binary)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict unset metadata binary
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach key {name version revision variants epoch depends portfile_path} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict unset metadata $key
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- unset m(name) m(version) m(revision) m(variants) m(epoch) m(depends) \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- m(portfile_path)
</span>
# remaining metadata maps directly to reg entry fields
<span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach key [array names m] {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- $regref $key $m($key)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict for {key val} $metadata {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $regref $key $val
</span> }
}
}
</pre><pre style='margin:0'>
</pre>