Skip to content

Commit df1d5d6

Browse files
committed
port_binary_distributable: more verbose description of failures
I've changed this to describe all reasons why a port isn't distributable, and properly capitalise license names. An example: $ ./port_binary_distributable.tcl -v mplayer +glx +faac "mplayer" is not distributable because its dependency "faac" has license "Restrictive" which is not known to be distributable: faac "mplayer" is not distributable because its license "GPL" conflicts with license "OpenSSL": mesa -> xorg-libxcb -> python38 -> openssl "mplayer" is not distributable because its license "GPL" conflicts with license "SSLeay": mesa -> xorg-libxcb -> python38 -> openssl Fixes: https://trac.macports.org/ticket/60995
1 parent d92ac81 commit df1d5d6

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

jobs/distributable_lib.tcl

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ proc remove_version {license} {
203203

204204
proc check_licenses {portName variantInfo} {
205205
array set portSeen {}
206+
set failures {}
206207
set top_info [infoForPort $portName $variantInfo]
207208
if {$top_info eq {}} {
208209
return 1
@@ -219,26 +220,34 @@ proc check_licenses {portName variantInfo} {
219220
set sub_names {}
220221
foreach full_lic $sublist {
221222
# chop off any trailing version number
222-
set lic [remove_version [string tolower $full_lic]]
223+
set lic [remove_version $full_lic]
223224
# add name to the list for later
224225
lappend sub_names $lic
225-
if {[info exists ::license_good($lic)]} {
226+
if {[info exists ::license_good([string tolower $lic])]} {
226227
set any_good 1
227228
}
228229
}
229230
lappend top_license_names $sub_names
230231
if {!$any_good} {
231-
return [list 1 "\"$portName\" is not distributable because its license \"$lic\" is not known to be distributable"]
232+
lappend failures "\"$portName\" is not distributable because its license \"$lic\" is not known to be distributable"
232233
}
233234
}
234235

235236
# start with deps of top-level port
237+
set portPaths [dict create [lindex $top_info 0] [list]]
236238
set portList [lindex $top_info 0]
239+
foreach aPort $portList {
240+
dict set portPaths $aPort [list]
241+
}
242+
237243
while {[llength $portList] > 0} {
238244
set aPort [lindex $portList 0]
245+
set portList [lreplace $portList 0 0]
246+
if {[info exists portSeen($aPort)] && $portSeen($aPort) eq 1} {
247+
continue
248+
}
239249
# mark as seen and remove from the list
240250
set portSeen($aPort) 1
241-
set portList [lreplace $portList 0 0]
242251
if {[info exists noconflict_ports($aPort)]} {
243252
continue
244253
}
@@ -252,6 +261,7 @@ proc check_licenses {portName variantInfo} {
252261
if {!$installs_libs} {
253262
continue
254263
}
264+
set parentPath [list {*}[dict get $portPaths $aPort] $aPort]
255265
foreach sublist $aPortLicense {
256266
set any_good 0
257267
set any_compatible 0
@@ -289,10 +299,9 @@ proc check_licenses {portName variantInfo} {
289299
}
290300

291301
if {!$any_good} {
292-
return [list 1 "\"$portName\" is not distributable because its dependency \"$aPort\" has license \"$lic\" which is not known to be distributable"]
293-
}
294-
if {!$any_compatible} {
295-
return [list 1 "\"$portName\" is not distributable because its license \"$top_lic\" conflicts with license \"$full_lic\" of dependency \"$aPort\""]
302+
lappend failures "\"$portName\" is not distributable because its dependency \"$aPort\" has license \"$full_lic\" which is not known to be distributable: [join $parentPath " -> "]"
303+
} elseif {!$any_compatible} {
304+
lappend failures "\"$portName\" is not distributable because its license \"$top_lic\" conflicts with license \"$full_lic\": [join $parentPath " -> "]"
296305
}
297306
}
298307

@@ -305,11 +314,16 @@ proc check_licenses {portName variantInfo} {
305314
foreach possiblyNewPort [lindex $aPortInfo 0] {
306315
if {![info exists portSeen($possiblyNewPort)] && ![info exists aPort_noconflict_ports($possiblyNewPort)]} {
307316
lappend portList $possiblyNewPort
317+
dict set portPaths $possiblyNewPort $parentPath
308318
}
309319
}
310320
}
311321

312-
return [list 0 "\"$portName\" is distributable"]
322+
if {[llength $failures] ne 0} {
323+
return [list 1 $failures]
324+
} else {
325+
return [list 0 [list "\"$portName\" is distributable"]]
326+
}
313327
}
314328

315329
# given a variant string, return an array of variations

jobs/port_binary_distributable.tcl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ if {$dbdir ne ""} {
9393
write_license_db $dbdir
9494
}
9595
if {$verbose} {
96-
puts [lindex $results 1]
96+
foreach result [lindex $results 1] {
97+
puts $result
98+
}
9799
}
98100
exit [lindex $results 0]

0 commit comments

Comments
 (0)