[88029] branches/gsoc11-rev-upgrade/base/src
cal at macports.org
cal at macports.org
Fri Dec 16 12:11:23 PST 2011
Revision: 88029
http://trac.macports.org/changeset/88029
Author: cal at macports.org
Date: 2011-12-16 12:11:21 -0800 (Fri, 16 Dec 2011)
Log Message:
-----------
rev-upgrade: Implement checking of the id loadcommand
The check will warn if the id is a relative path, does not exist or points
to a different file than the one it was encountered in.
Run rev-upgrade with --id-loadcmd-check to enable the check. It is not
enabled by default, because the enduser hardly benefits from this test and
it generates quite a few harmless warnings.
Modified Paths:
--------------
branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl
branches/gsoc11-rev-upgrade/base/src/port/port.tcl
Modified: branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl
===================================================================
--- branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl 2011-12-16 20:00:03 UTC (rev 88028)
+++ branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl 2011-12-16 20:11:21 UTC (rev 88029)
@@ -3832,18 +3832,19 @@
}
}
-proc macports::revupgrade {args} {
+proc macports::revupgrade {opts} {
set run_loop 1
array set broken_port_counts {}
while {$run_loop == 1} {
- set run_loop [revupgrade_scanandrebuild broken_port_counts]
+ set run_loop [revupgrade_scanandrebuild broken_port_counts $opts]
}
return 0;
}
# returns 1 if ports were rebuilt and revupgrade_scanandrebuild should be called again
-proc revupgrade_scanandrebuild {broken_port_counts_name} {
+proc revupgrade_scanandrebuild {broken_port_counts_name opts} {
upvar $broken_port_counts_name broken_port_counts
+ array set options $opts
set files [registry::file search active 1 binary -null]
if {[llength $files] > 0} {
@@ -3910,6 +3911,56 @@
set architecture [$result cget -mt_archs]
while {$architecture != "NULL"} {
+ if {[info exists options(ports_rev-upgrade_id-loadcmd-check)] && $options(ports_rev-upgrade_id-loadcmd-check) == "yes"} {
+ if {[$architecture cget -mat_install_name] != "NULL" && [$architecture cget -mat_install_name] != ""} {
+ # check if this lib's install name actually refers to this file itself
+ # if this is not the case software linking against this library might have erroneous load commands
+ if {0 == [catch {set idloadcmdpath [revupgrade_handle_special_paths [$b path] [$architecture cget -mat_install_name]]}]} {
+ if {[string index $idloadcmdpath 0] != "/"} {
+ set port [registry::entry owner [$b path]]
+ if {$port != ""} {
+ set portname [$port name]
+ } else {
+ set portname "<unknown-port>"
+ }
+ if {![macports::ui_isset ports_debug]} {
+ ui_msg ""
+ }
+ ui_warn "ID load command in [$b path], arch [machista::get_arch_name [$architecture cget -mat_arch]] (belonging to port $portname) contains relative path"
+ } elseif {![file exists $idloadcmdpath]} {
+ set port [registry::entry owner [$b path]]
+ if {$port != ""} {
+ set portname [$port name]
+ } else {
+ set portname "<unknown-port>"
+ }
+ if {![macports::ui_isset ports_debug]} {
+ ui_msg ""
+ }
+ ui_warn "ID load command in [$b path], arch [machista::get_arch_name [$architecture cget -mat_arch]] refers to non-existant file $idloadcmdpath"
+ ui_warn "This is probably a bug in the $portname port and might cause problems in libraries linking against this file"
+ } else {
+
+ set hash_this [sha256 file [$b path]]
+ set hash_idloadcmd [sha256 file $idloadcmdpath]
+
+ if {$hash_this != $hash_idloadcmd} {
+ set port [registry::entry owner [$b path]]
+ if {$port != ""} {
+ set portname [$port name]
+ } else {
+ set portname "<unknown-port>"
+ }
+ if {![macports::ui_isset ports_debug]} {
+ ui_msg ""
+ }
+ ui_warn "ID load command in [$b path], arch [machista::get_arch_name [$architecture cget -mat_arch]] refers to file $idloadcmdpath, which is a different file"
+ ui_warn "This is probably a bug in the $portname port and might cause problems in libraries linking against this file"
+ }
+ }
+ }
+ }
+ }
set loadcommand [$architecture cget -mat_loadcmds]
while {$loadcommand != "NULL"} {
@@ -3922,11 +3973,6 @@
set libreturncode [lindex $libresultlist 0]
set libresult [lindex $libresultlist 1]
- # if {[string first "/usr/" [$loadcommand cget -mlt_install_name]] == 0} {
- # # TODO: Filter whitelist
- # ui_warn "File links against /usr/*: [$b path] links against [$loadcommand cget -mlt_install_name]"
- # }
-
if {$libreturncode != $machista::SUCCESS} {
if {![info exists files_warned_about($filepath)]} {
if {![macports::ui_isset ports_debug]} {
Modified: branches/gsoc11-rev-upgrade/base/src/port/port.tcl
===================================================================
--- branches/gsoc11-rev-upgrade/base/src/port/port.tcl 2011-12-16 20:00:03 UTC (rev 88028)
+++ branches/gsoc11-rev-upgrade/base/src/port/port.tcl 2011-12-16 20:11:21 UTC (rev 88029)
@@ -2593,7 +2593,7 @@
}
proc action_revupgrade { action portlist opts } {
- set status [macports::revupgrade]
+ set status [macports::revupgrade $opts]
if {$status != 0} {
print_tickets_url
}
@@ -4156,6 +4156,7 @@
select {list set show}
log {{phase 1} {level 1}}
upgrade {force enforce-variants no-replace no-rev-upgrade}
+ rev-upgrade {id-loadcmd-check}
}
##
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20111216/b3816eb8/attachment-0001.html>
More information about the macports-changes
mailing list