<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch release-2.10
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/90d374e0e1fe56ad672684c1283971e18cdcd6c8">https://github.com/macports/macports-base/commit/90d374e0e1fe56ad672684c1283971e18cdcd6c8</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 90d374e0e1fe56ad672684c1283971e18cdcd6c8
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Thu Sep 26 17:15:14 2024 +1000
<span style='display:block; white-space:pre;color:#404040;'> extract_archive_metadata: handle multiple types
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Now takes a list of metadata types to extract, and returns a dict.
</span><span style='display:block; white-space:pre;color:#404040;'> Avoids potentially extracting from the archive multiple times.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> (cherry picked from commit f89637fd02e3151f15e1762a7962f7ba1f0474ba)
</span>---
src/port1.0/portclean.tcl | 2 +-
src/port1.0/portinstall.tcl | 11 ++----
src/port1.0/portutil.tcl | 93 +++++++++++++++++++++++++--------------------
3 files changed, 56 insertions(+), 50 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portclean.tcl b/src/port1.0/portclean.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 22c790c95..c5da30425 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portclean.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portclean.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -242,7 +242,7 @@ proc portclean::clean_archive {args} {
</span> # thus can't be checked and aren't useful anyway.
set archivetype [string range [file extension $path] 1 end]
if {[file isfile $path] && ($archivetype eq "TMP"
<span style='display:block; white-space:pre;background:#ffe0e0;'>- || [extract_archive_metadata $path $archivetype portname] eq $subport)} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ || [dict get [extract_archive_metadata $path $archivetype portname] portname] eq $subport)} {
</span> ui_debug "Removing archive: $path"
if {[catch {delete $path} result]} {
ui_debug "$::errorInfo"
<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 18a5a2de7..34c95c43b 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;'>@@ -351,10 +351,6 @@ proc portinstall::create_archive {location archive.type} {
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-proc portinstall::extract_contents {location type} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return [extract_archive_metadata $location $type contents]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span> proc portinstall::install_main {args} {
global subport version portpath depends_run revision user_options \
portvariants requested_variants depends_lib PortInfo epoch \
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -380,10 +376,9 @@ proc portinstall::install_main {args} {
</span> delete [file join [option workpath] .macports.${subport}.state]
set location [file join $install_dir [file tail $archive_path]]
set current_archive_type [string range [file extension $location] 1 end]
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set contents [extract_contents $location $current_archive_type]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lassign $contents installPlist file_is_binary
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set cxxinfo [extract_archive_metadata $location $current_archive_type cxx_info]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lassign $cxxinfo actual_cxx_stdlib cxx_stdlib_overridden
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set archive_metadata [extract_archive_metadata $location $current_archive_type {contents cxx_info}]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lassign [dict get $archive_metadata contents] installPlist file_is_binary
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lassign [dict get $archive_metadata cxx_info] actual_cxx_stdlib cxx_stdlib_overridden
</span> } else {
if {$portimage_mode eq "directory"} {
# Special value to avoid writing archive out to disk, since
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/port1.0/portutil.tcl b/src/port1.0/portutil.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 04b672fd9..1bd67d8ce 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/port1.0/portutil.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/port1.0/portutil.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2784,8 +2784,8 @@ proc archiveTypeIsSupported {type} {
</span> return -code error [format [msgcat::mc "Unsupported port archive type '%s': %s"] $type $errmsg]
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-# return the specified piece of metadata from the +CONTENTS file in the given archive
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-proc extract_archive_metadata {archive_location archive_type metadata_type} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# return the specified pieces of metadata from the +CONTENTS file in the given archive
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc extract_archive_metadata {archive_location archive_type metadata_types} {
</span> set qflag ${portutil::autoconf::tar_q}
set raw_contents ""
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -2855,52 +2855,63 @@ proc extract_archive_metadata {archive_location archive_type metadata_type} {
</span> close $fd
file delete -force $tempdir
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$metadata_type eq "contents"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set contents [list]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set binary_info [list]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set ignore 0
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set sep [file separator]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach line [split $raw_contents \n] {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$ignore} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ret [dict create]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach metadata_type $metadata_types {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ switch -- $metadata_type {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ contents {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set contents [list]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set binary_info [list]
</span> set ignore 0
<span style='display:block; white-space:pre;background:#ffe0e0;'>- continue
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[string index $line 0] ne "@"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend contents "${sep}${line}"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } elseif {$line eq "@ignore"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set ignore 1
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } elseif {[string range $line 0 15] eq "@comment binary:"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- lappend binary_info [lindex $contents end] [string range $line 16 end]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return [list $contents $binary_info]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } elseif {$metadata_type eq "portname"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach line [split $raw_contents \n] {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[lindex $line 0] eq "@portname"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return [lindex $line 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set sep [file separator]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach line [split $raw_contents \n] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$ignore} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ignore 0
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ continue
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[string index $line 0] ne "@"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend contents "${sep}${line}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } elseif {$line eq "@ignore"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ignore 1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } elseif {[string range $line 0 15] eq "@comment binary:"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ lappend binary_info [lindex $contents end] [string range $line 16 end]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set ret contents [list $contents $binary_info]
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- }
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return ""
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } elseif {$metadata_type eq "cxx_info"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set val_cxx_stdlib ""
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set val_cxx_stdlib_overridden ""
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- foreach line [split $raw_contents \n] {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {[lindex $line 0] eq "@cxx_stdlib"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set val_cxx_stdlib [lindex $line 1]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$val_cxx_stdlib_overridden ne ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ portname {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portname {}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach line [split $raw_contents \n] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[lindex $line 0] eq "@portname"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portname [lindex $line 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
<span style='display:block; white-space:pre;background:#ffe0e0;'>- } elseif {[lindex $line 0] eq "@cxx_stdlib_overridden"} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- set val_cxx_stdlib_overridden [lindex $line 1]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if {$val_cxx_stdlib ne ""} {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set ret portname $portname
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ cxx_info {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set val_cxx_stdlib ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set val_cxx_stdlib_overridden ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach line [split $raw_contents \n] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[lindex $line 0] eq "@cxx_stdlib"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set val_cxx_stdlib [lindex $line 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$val_cxx_stdlib_overridden ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } elseif {[lindex $line 0] eq "@cxx_stdlib_overridden"} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set val_cxx_stdlib_overridden [lindex $line 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$val_cxx_stdlib ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ break
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ dict set ret cxx_info [list $val_cxx_stdlib $val_cxx_stdlib_overridden]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ default {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -code error "unknown metadata_type: $metadata_type"
</span> }
}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- return [list $val_cxx_stdlib $val_cxx_stdlib_overridden]
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- } else {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- return -code error "unknown metadata_type: $metadata_type"
</span> }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $ret
</span> }
#
</pre><pre style='margin:0'>
</pre>