<pre style='margin:0'>
Joshua Root (jmroot) pushed a commit to branch master
in repository macports-infrastructure.
</pre>
<p><a href="https://github.com/macports/macports-infrastructure/commit/4842c5c9ee9788c74a4316e263ff6a67fce11779">https://github.com/macports/macports-infrastructure/commit/4842c5c9ee9788c74a4316e263ff6a67fce11779</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 4842c5c9ee9788c74a4316e263ff6a67fce11779
</span>Author: Joshua Root <jmr@macports.org>
AuthorDate: Sun Nov 10 02:09:04 2019 +1100
<span style='display:block; white-space:pre;color:#404040;'> port_binary_distributable: allow caching data
</span>---
jobs/distributable_lib.tcl | 86 +++++++++++++++++++++++++++++++++++++-
jobs/port_binary_distributable.tcl | 25 +++++++++--
2 files changed, 106 insertions(+), 5 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/jobs/distributable_lib.tcl b/jobs/distributable_lib.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index a902373..260f92d 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/jobs/distributable_lib.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/jobs/distributable_lib.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,3 +1,5 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> # Library code for checking if ports are binary distributable.
# Used by the port_binary_distributable tool.
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -81,15 +83,81 @@ array set license_conflicts \
</span> zpl-1 [list agpl cecill gpl] \
]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# license database format:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# each line consists of "portname mtime {array}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# where array is one or more {variant_string {dependencies license installs_libs [license_noconflict]}}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# load database if it exists
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc init_license_db {dbpath} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[file isfile ${dbpath}/license_db]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set fd [open ${dbpath}/license_db r]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while {[gets $fd entry] >= 0} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ::license_db([lindex $entry 0]) [lrange $entry 1 end]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ close $fd
</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;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# write out database
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc write_license_db {dbpath} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {![file isdirectory dbpath]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ file mkdir $dbpath
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set fd [open ${dbpath}/license_db w]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach portname [array names ::license_db] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts $fd [list $portname {*}$::license_db($portname)]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ close $fd
</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;'>+# purge old ports from database
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc cleanup_license_db {dbpath} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[file isfile ${dbpath}/license_db]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set fd [open ${dbpath}/license_db r]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set content [read $fd]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ close $fd
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set fd [open ${dbpath}/license_db w]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach entry [split $content \n] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portSearchResult [mportlookup [lindex $entry 0]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {$portSearchResult ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set portInfo [lindex $portSearchResult 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portfile_path [macports::getportdir $portInfo(porturl)]/Portfile
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[file mtime $portfile_path] == [lindex $entry 1]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts $fd $entry
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array unset portInfo
</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;'>+ close $fd
</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;'>+
</span> # return deps and license for given port
proc infoForPort {portName variantInfo} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- set dependencyList {}
</span> set portSearchResult [mportlookup $portName]
if {[llength $portSearchResult] < 1} {
puts stderr "Warning: port \"$portName\" not found"
return {}
}
array set portInfo [lindex $portSearchResult 1]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ set portfile_path [macports::getportdir $portInfo(porturl)]/Portfile
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set variant_string [normalize_variants $variantInfo]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # check if the port's info is already in the db
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists ::license_db($portName)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set info_list $::license_db($portName)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[file mtime $portfile_path] == [lindex $info_list 0]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # keyed by normalized variant string
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set info_array [lindex $info_list 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[info exists info_array($variant_string)]} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $info_array($variant_string)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ } else {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ unset ::license_db($portName)
</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;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set dependencyList {}
</span> set mport [mportopen $portInfo(porturl) [list subport $portInfo(name)] $variantInfo]
array unset portInfo
array set portInfo [mportinfo $mport]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -114,6 +182,11 @@ proc infoForPort {portName variantInfo} {
</span> if {[info exists portInfo(license_noconflict)]} {
lappend ret $portInfo(license_noconflict)
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # update the db
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set info_array($variant_string) $ret
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ::license_db($portName) [list [file mtime $portfile_path] [array get info_array]]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> return $ret
}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -239,6 +312,7 @@ proc check_licenses {portName variantInfo} {
</span> return [list 0 "\"$portName\" is distributable"]
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# given a variant string, return an array of variations
</span> set split_variants_re {([-+])([[:alpha:]_]+[\w\.]*)}
proc split_variants {variants} {
set result {}
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -248,3 +322,13 @@ proc split_variants {variants} {
</span> }
return $result
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# given an array of variations, return a variant string in normalized form
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+proc normalize_variants {variations} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ array set varray $variations
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set variant_string ""
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ foreach vname [lsort -ascii [array names varray]] {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ append variant_string $varray($vname)${vname}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return $variant_string
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/jobs/port_binary_distributable.tcl b/jobs/port_binary_distributable.tcl
</span><span style='display:block; white-space:pre;color:#808080;'>index 90cde11..6bcd799 100755
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/jobs/port_binary_distributable.tcl
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/jobs/port_binary_distributable.tcl
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -16,10 +16,11 @@ set MY_VERSION 0.1
</span> source [file join [file dirname [info script]] distributable_lib.tcl]
proc printUsage {} {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- puts "Usage: $::argv0 \[-hvV\] port-name \[variants...\]"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts " -h This help"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts " -v verbose output"
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- puts " -V show version and MacPorts version being used"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts "Usage: $::argv0 \[-d dir\] \[-hvV\] port-name \[variants...\]"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts " -d dir Use directory 'dir' for persistent data storage"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts " -h This help"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts " -v verbose output"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts " -V show version and MacPorts version being used"
</span> puts ""
puts "port-name is the name of a port to check"
puts "variants is the list of variants to enable/disable: +one -two..."
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -27,9 +28,18 @@ proc printUsage {} {
</span>
set verbose 0
set showVersion 0
<span style='display:block; white-space:pre;background:#e0ffe0;'>+set dbdir ""
</span>
while {[string index [lindex $::argv 0] 0] eq "-"} {
switch [string range [lindex $::argv 0] 1 end] {
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ d {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if {[llength $::argv] < 2} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ printUsage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ exit 2
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set dbdir [lindex $::argv 1]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ set ::argv [lrange $::argv 1 end]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span> h {
printUsage
exit 0
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -66,6 +76,10 @@ if {[llength $::argv] == 0} {
</span> set portName [lindex $::argv 0]
set ::argv [lrange $::argv 1 end]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+if {$dbdir ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ init_license_db $dbdir
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> array set variantInfo {}
foreach variantSetting $::argv {
set variant [split_variants $variantSetting]
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -75,6 +89,9 @@ foreach variantSetting $::argv {
</span> }
set results [check_licenses $portName [array get variantInfo]]
<span style='display:block; white-space:pre;background:#e0ffe0;'>+if {$dbdir ne ""} {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ write_license_db $dbdir
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span> if {$verbose} {
puts [lindex $results 1]
}
</pre><pre style='margin:0'>
</pre>