Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port_binary_distributable: more verbose description of failures #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions jobs/distributable_lib.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ proc remove_version {license} {

proc check_licenses {portName variantInfo} {
array set portSeen {}
set failures {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use [list] so the variable is a pure list.

set top_info [infoForPort $portName $variantInfo]
if {$top_info eq {}} {
return 1
Expand All @@ -219,26 +220,34 @@ proc check_licenses {portName variantInfo} {
set sub_names {}
foreach full_lic $sublist {
# chop off any trailing version number
set lic [remove_version [string tolower $full_lic]]
set lic [remove_version $full_lic]
# add name to the list for later
lappend sub_names $lic
if {[info exists ::license_good($lic)]} {
if {[info exists ::license_good([string tolower $lic])]} {
set any_good 1
}
}
lappend top_license_names $sub_names
if {!$any_good} {
return [list 1 "\"$portName\" is not distributable because its license \"$lic\" is not known to be distributable"]
lappend failures "\"$portName\" is not distributable because its license \"$lic\" is not known to be distributable"
}
}

# start with deps of top-level port
set portPaths [dict create [lindex $top_info 0] [list]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really need a dict rather than just an array? And what's the purpose of adding an entry for the whole list of dependencies?

set portList [lindex $top_info 0]
foreach aPort $portList {
dict set portPaths $aPort [list]
}

while {[llength $portList] > 0} {
set aPort [lindex $portList 0]
set portList [lreplace $portList 0 0]
if {[info exists portSeen($aPort)] && $portSeen($aPort) eq 1} {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eq is for string comparisons and strings should always be quoted in expressions. However there's really no need to check the value at all.

continue
}
# mark as seen and remove from the list
set portSeen($aPort) 1
set portList [lreplace $portList 0 0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this makes the comment above incorrect.

if {[info exists noconflict_ports($aPort)]} {
continue
}
Expand All @@ -252,6 +261,7 @@ proc check_licenses {portName variantInfo} {
if {!$installs_libs} {
continue
}
set parentPath [list {*}[dict get $portPaths $aPort] $aPort]
foreach sublist $aPortLicense {
set any_good 0
set any_compatible 0
Expand Down Expand Up @@ -289,10 +299,9 @@ proc check_licenses {portName variantInfo} {
}

if {!$any_good} {
return [list 1 "\"$portName\" is not distributable because its dependency \"$aPort\" has license \"$lic\" which is not known to be distributable"]
}
if {!$any_compatible} {
return [list 1 "\"$portName\" is not distributable because its license \"$top_lic\" conflicts with license \"$full_lic\" of dependency \"$aPort\""]
lappend failures "\"$portName\" is not distributable because its dependency \"$aPort\" has license \"$full_lic\" which is not known to be distributable: [join $parentPath " -> "]"
} elseif {!$any_compatible} {
lappend failures "\"$portName\" is not distributable because its license \"$top_lic\" conflicts with license \"$full_lic\": [join $parentPath " -> "]"
}
}

Expand All @@ -305,11 +314,16 @@ proc check_licenses {portName variantInfo} {
foreach possiblyNewPort [lindex $aPortInfo 0] {
if {![info exists portSeen($possiblyNewPort)] && ![info exists aPort_noconflict_ports($possiblyNewPort)]} {
lappend portList $possiblyNewPort
dict set portPaths $possiblyNewPort $parentPath
}
}
}

return [list 0 "\"$portName\" is distributable"]
if {[llength $failures] ne 0} {
return [list 1 $failures]
} else {
return [list 0 [list "\"$portName\" is distributable"]]
}
}

# given a variant string, return an array of variations
Expand Down
4 changes: 3 additions & 1 deletion jobs/port_binary_distributable.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ if {$dbdir ne ""} {
write_license_db $dbdir
}
if {$verbose} {
puts [lindex $results 1]
foreach result [lindex $results 1] {
puts $result
}
}
exit [lindex $results 0]