[79636] branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl
cal at macports.org
cal at macports.org
Tue Jun 21 15:33:34 PDT 2011
Revision: 79636
http://trac.macports.org/changeset/79636
Author: cal at macports.org
Date: 2011-06-21 15:33:34 -0700 (Tue, 21 Jun 2011)
Log Message:
-----------
rev-upgrade: Quickly hacked code to call otool -L on the files marked binary and parse it's output using regexes.
Tested to find and report missing libs.
TODO: Test compatibility version, maybe get to work with .a files.
Modified Paths:
--------------
branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl
Modified: branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl
===================================================================
--- branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl 2011-06-21 22:11:45 UTC (rev 79635)
+++ branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl 2011-06-21 22:33:34 UTC (rev 79636)
@@ -3518,12 +3518,19 @@
proc macports::revupgrade {args} {
set files [registry::file search active 1 binary -null]
if {[llength $files] > 0} {
- ui_msg "---> Updating database of binaries"
- set i 1
- foreach f $files {
- ui_debug "Updating binary flag for file $i of [llength $files]: [$f path]"
- incr i
- $f binary [fileIsBinary [$f path]]
+ registry::write {
+ try {
+ ui_msg "---> Updating database of binaries"
+ set i 1
+ foreach f $files {
+ ui_debug "Updating binary flag for file $i of [llength $files]: [$f path]"
+ incr i
+ $f binary [fileIsBinary [$f path]]
+ }
+ } catch {*} {
+ ui_msg "Updating database of binaries failed"
+ throw
+ }
}
}
set binaries [registry::file search active 1 binary 1]
@@ -3535,11 +3542,68 @@
# TODO: Call something, that will use
# http://www.opensource.apple.com/source/cctools/cctools-800/otool/main.c
# as if it was called with otool -L, thus using
- # http://www.opensource.apple.com/source/cctools/cctools-698/libstuff/ofile.c
+ # http://www.opensource.apple.com/source/cctools/cctools-800/libstuff/ofile.c
# and print_libraries from
# http://www.opensource.apple.com/source/cctools/cctools-800/otool/ofile_print.c,
# but don't actually print the libs, but write them into a list and check them for existance and compatibility.
# Maybe implement a cache for libs that have already been checked (because a lot of software links against similar libs)
+
+ if {[catch {set otool_output [exec /usr/bin/otool -arch all -L [$b path]]} msg]} {
+ ui_warn "Error running otool on file [$b path]: $msg"
+ continue;
+ }
+ set otool_lines [split $otool_output "\n"]
+ set arch "unknown"
+ foreach otool_line $otool_lines {
+ if {1 == [regexp -nocase {^Archive} $otool_line]} {
+ ui_info "Ignoring archive file [$b path]"
+ break;
+ }
+ if {1 == [regexp -nocase {\(architecture ([^\s]+)\)} $otool_line match arch]} {
+ switch $arch {
+ x86_64 {}
+ i386 {}
+ ppc {}
+ ppc64 {}
+ default {
+ ui_warn "Unknown architecture $arch"
+ }
+ }
+ continue;
+ }
+ if {$arch == "unknown"} {
+ ui_warn "Unspecified architecture in file [$b path]"
+ break;
+ }
+ if {1 == [regexp -nocase {^\t([^\s]+) \(compatibility version ([^,]+), current version ([^)]+)\)} $otool_line match file comp_version curr_version]} {
+ if {$file == [$b path]} {
+ # This is a self-referencing entry
+ continue;
+ }
+ ui_debug "Linked against: $file, architecture $arch, version $curr_version, compatibility version $comp_version"
+ set lib_found false
+ if {[catch {set lib_otool_output [exec /usr/bin/otool -arch $arch -L $file]}] == 0} {
+ set lib_otool_lines [split $lib_otool_output "\n"]
+ foreach lib_otool_line $lib_otool_lines {
+ if {1 == [regexp -nocase {^\t([^\s]+) \(compatibility version ([^,]+), current version ([^)]+)\)} $lib_otool_line match lib_file lib_comp_version lib_curr_version]} {
+ if {$file == $lib_file} {
+ set lib_found true
+ if {$curr_version != $lib_curr_version} {
+ if {$comp_version != $lib_comp_version} {
+ ui_warn "Incompatibly library version: Expected $comp_version, but got $lib_comp_version!"
+ }
+ }
+ }
+ }
+ }
+ }
+ if {$lib_found == false} {
+ ui_warn "Missing dependency $file!"
+ }
+ continue;
+ }
+ ui_warn "unparseable line in otool output: $otool_line"
+ }
}
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110621/890687cb/attachment-0001.html>
More information about the macports-changes
mailing list