New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Changeset 81754


Ignore:
Timestamp:
08/04/11 10:48:47 (4 years ago)
Author:
cal@…
Message:

rev-upgrade: Handle macros in loadcommands, handle some broken ports (GitX installing precompiled binaries...)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc11-rev-upgrade/base/src/macports1.0/macports.tcl

    r81686 r81754  
    38083808        set i 1 
    38093809        foreach b $binaries { 
    3810             ui_debug "Scanning binary $i of [llength $binaries]: [$b path]" 
     3810            ui_debug "$i/[llength $binaries]: [$b path]" 
    38113811            incr i 
    38123812 
     
    38163816 
    38173817            if {$returncode != $machista::SUCCESS} { 
    3818                 ui_info "Error parsing file [$b path]: [machista::strerror $returncode]" 
     3818                if {$returncode == $machista::EMAGIC} { 
     3819                    # not a Mach-O file 
     3820                    ui_debug "Error parsing file [$b path]: [machista::strerror $returncode]" 
     3821                } else { 
     3822                    ui_warn "Error parsing file [$b path]: [machista::strerror $returncode]" 
     3823                } 
    38193824                continue; 
    38203825            } 
     
    38253830 
    38263831                while {$loadcommand != "NULL"} { 
    3827                     set libresultlist [machista::parse_file $handle [$loadcommand cget -mlt_install_name]] 
     3832                    if {0 != [catch {set filepath [revupgrade_handle_special_paths [$b path] [$loadcommand cget -mlt_install_name]]}]} { 
     3833                        set loadcommand [$loadcommand cget -next] 
     3834                        continue; 
     3835                    } 
     3836 
     3837                    set libresultlist [machista::parse_file $handle $filepath] 
    38283838                    set libreturncode [lindex $libresultlist 0] 
    38293839                    set libresult     [lindex $libresultlist 1] 
     
    38313841                    # if {[string first "/usr/" [$loadcommand cget -mlt_install_name]] == 0} { 
    38323842                    #     # TODO: Filter whitelist 
    3833                     #     ui_warn "File links against /usr/*: `[$b path]' links against `[$loadcommand cget -mlt_install_name]'" 
     3843                    #     ui_warn "File links against /usr/*: [$b path] links against [$loadcommand cget -mlt_install_name]" 
    38343844                    # } 
    38353845 
    38363846                    if {$libreturncode != $machista::SUCCESS} { 
    3837                         ui_info "Could not open `[$loadcommand cget -mlt_install_name]': [machista::strerror $libreturncode]" 
     3847                        ui_warn "Could not open $filepath: [machista::strerror $libreturncode]" 
    38383848                        if {$libreturncode == $machista::EFILE} { 
     3849                            ui_debug "Marking [$b path] as broken" 
    38393850                            lappend broken_files [$b path] 
    38403851                        } 
     
    38523863 
    38533864                        if {[$loadcommand cget -mlt_version] != [$libarchitecture cget -mat_version] && [$loadcommand cget -mlt_comp_version] != [$libarchitecture cget -mat_comp_version]} { 
    3854                             ui_info "Incompatible library version of file `[$loadcommand cget -mlt_install_name]': Expected [$loadcommand cget -mlt_comp_version], but got [$libarchitecture cget -mat_comp_version]" 
    3855                             lappend broken_files [$architecture cget -mat_install_name] 
     3865                            ui_warn "Incompatible library version of file [$loadcommand cget -mlt_install_name]: Expected [$loadcommand cget -mlt_comp_version], but got [$libarchitecture cget -mat_comp_version]" 
     3866                            ui_debug "Marking [$b path] as broken" 
     3867                            lappend broken_files [$b path] 
    38563868                        } 
    38573869 
     
    38613873 
    38623874                    if {$libarch_found == false} { 
    3863                         ui_info "Missing architecture [$architecture cget -mat_arch] in file `[$loadcommand cget -mlt_install_name]'" 
    3864                         lappend broken_files [$architecture cget -mat_install_name] 
     3875                        ui_debug "Missing architecture [$architecture cget -mat_arch] in file $filepath" 
     3876                        if {[path_is_in_prefix $filepath]} { 
     3877                            ui_debug "Marking [$b path] as broken" 
     3878                            lappend broken_files [$b path] 
     3879                        } else { 
     3880                            ui_warn "Missing architecture [$architecture cget -mat_arch] in file outside prefix referenced from [$b path]" 
     3881                            ui_warn "   How did you get that compiled anyway?" 
     3882                        } 
    38653883                    } 
    38663884                    set loadcommand [$loadcommand cget -next] 
     
    38823900            set port [registry::entry owner $file] 
    38833901            if {$port == ""} { 
    3884                 ui_error "Broken file `$file' doesn't belong to any port." 
     3902                ui_error "Broken file $file doesn't belong to any port." 
    38853903            } 
    38863904            lappend broken_ports $port 
     
    39884006} 
    39894007 
     4008# Return whether a path is in the macports prefix 
     4009# Usage: path_is_in_prefix path_to_test 
     4010# Returns true if the path is in the prefix, false otherwise 
     4011proc path_is_in_prefix {path} { 
     4012    return [string first $macports::prefix $path] == 0 || [string first $macports::applications_dir $path] == 0 
     4013} 
     4014 
     4015# Function to replace macros in loadcommand paths with their proper values (which are usually determined at load time) 
     4016# Usage: revupgrade_handle_special_paths name_of_file path_from_loadcommand 
     4017# Returns the corrected path on success or an error in case of failure. 
     4018# Note that we can't reliably replace @executable_path, because it's only clear when executing a file where it was executed from. 
     4019# Replacing @rpath does not work yet, but it might be possible to get it working using the rpath attribute in the file containing the 
     4020# loadcommand 
     4021proc revupgrade_handle_special_paths {fname path} { 
     4022    set corrected_path $path 
     4023 
     4024    set loaderpath_idx [string first "@loader_path" $corrected_path] 
     4025    if {$loaderpath_idx != -1} { 
     4026        set corrected_path [string replace $corrected_path $loaderpath_idx $loaderpath_idx+11 [file dirname $fname]] 
     4027    } 
     4028 
     4029    set executablepath_idx [string first "@executable_path" $corrected_path] 
     4030    if {$executablepath_idx != -1} { 
     4031        ui_warn "Ignoring loadcommand containing @exectuable_path in $fname" 
     4032        error "@exectuable_path in loadcommand" 
     4033    } 
     4034 
     4035    set rpath_idx [string first "@rpath" $corrected_path] 
     4036    if {$rpath_idx != -1} { 
     4037        ui_warn "Ignoring loadcommand containing @rpath in $fname" 
     4038        error "@rpath in loadcommand" 
     4039    } 
     4040 
     4041    return $corrected_path 
     4042} 
     4043 
     4044# Recursively build the dependency graph between broken ports 
     4045# Usage: revupgrade_buildgraph start_port name_of_stack name_of_adjacency_list name_of_reverse_adjacency_list name_of_visited_map 
    39904046proc revupgrade_buildgraph {port stackname adjlistname revadjlistname visitedname} { 
    39914047    upvar $stackname stack 
Note: See TracChangeset for help on using the changeset viewer.