Changeset 79576
- Timestamp:
- 06/18/11 19:07:13 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/gsoc11-post-destroot/base/src/port1.0/portcheckdestroot.tcl
r79307 r79576 14 14 15 15 #options 16 options destroot.violate_mtree destroot.asroot 16 options destroot.violate_mtree destroot.asroot depends_lib 17 17 18 18 #defaults 19 19 default destroot.violate_mtree no 20 default destroot.depends_lib {} 20 21 21 22 set_ui_prefix 22 23 23 24 24 # Starting procedure from checkdestroot phase. Check for permissions. … … 37 37 # List all links on a directory recursively. This function is for internal use. 38 38 proc portcheckdestroot::links_list {dir} { 39 return [types_list $dir "l"] 40 } 41 42 # List all links on a directory recursively. This function is for internal use. 43 proc portcheckdestroot::files_list {dir} { 44 return [types_list $dir "f"] 45 } 46 47 # List all files of a type on a directory recursively. This function is for internal use. 48 proc portcheckdestroot::types_list {dir type} { 39 49 set ret {} 40 foreach item [glob -nocomplain -type {d l}-directory $dir *] {50 foreach item [glob -nocomplain -type "d $type" -directory $dir *] { 41 51 if {[file isdirectory $item]} { 42 set ret [concat $ret [ links_list $item]]52 set ret [concat $ret [types_list $item $type]] 43 53 } else { 44 #is link54 #is from the correct type 45 55 lappend ret $item 46 56 } 47 57 } 48 58 return $ret 59 } 60 61 # Get files from a list. For internal use only 62 proc portcheckdestroot::get_files { list } { 63 set files {} 64 foreach element $list { 65 if { [regexp {^/?[A-Za-z0-9\.-]+(/[A-Za-z0-9\.-]+)*$} $element] } { 66 if { [file exists $element] } { 67 lappend files $element 68 } 69 } 70 } 71 return $files 72 } 73 74 # List dependencies from the current package 75 proc portcheckdestroot::get_dependencies {} { 76 global destroot destroot.depends_lib subport depends_lib 77 set deps {} 78 if {[info exists depends_lib]} { 79 foreach dep [set depends_lib] { 80 set dep_portname [_get_dep_port $dep] 81 if {$dep_portname != ""} { 82 set dep_portname [_get_dep_port $dep] 83 lappend deps $dep_portname 84 } 85 } 86 } 87 return $deps 49 88 } 50 89 … … 159 198 } 160 199 200 # Check for dynamic links that aren't in the dependency list 201 proc portcheckdestroot::checkdestroot_libs {} { 202 global destroot destroot.depends_lib subport depends_lib UI_PREFIX 203 ui_notice "$UI_PREFIX Checking for wrong dynamic links" 204 205 #Files that don't need to be alerted if not on dependencies. 206 #TODO: Compile these files (and move for configuration folder?) 207 set dep_whitelist {/usr/lib/libSystem.B.dylib} 208 209 #Get dependencies files list. 210 set dep_files {} 211 foreach dep [get_dependencies] { 212 lappend dep_files [get_files [exec port contents $dep]] 213 } 214 set dep_files [concat $dep_files $dep_whitelist] 215 216 #Get package files 217 foreach file [files_list $destroot] { 218 if { [file executable "$file"] } { 219 #Check it dinamic links with otool 220 foreach line [split [exec -keepnewline otool -L $file] "\n"] { 221 #match they with dependency files 222 if { [regexp {\(.*} $line] } { 223 set lib [string trim [regsub {\(.*} $line ""]] 224 if { [regexp $lib $file] } { 225 ui_debug "skipping, should be the file itself" 226 } else { 227 if { [regexp $lib [join $dep_files]] } { 228 ui_debug "$lib binary dependency is met" 229 } else { 230 return -code error "$lib binary dependencies are NOT met" 231 } 232 } 233 } 234 } 235 } 236 } 237 } 238 239 #For the given archs, check if the files from destroot are compatible 240 proc portcheckdestroot::checkdestroot_arches { archs } { 241 global destroot 242 foreach file [files_list $destroot] { 243 if { [file executable "$file"] } { 244 set lipo_arches [checkdestroot_get_lipo_arches $file] 245 # Chekcs if every arch is present on the lipo output 246 foreach arch $archs { 247 if { [regexp $arch $lipo_arches] == 0 } { 248 return -code error "$file supports the arch $arch, and should not" 249 } 250 } 251 } 252 } 253 } 254 255 # Recover the arches from a file, from it's lipo output. For internal use only. 256 proc portcheckdestroot::checkdestroot_get_lipo_arches { file } { 257 set lipo_output [exec lipo -info $file] 258 return [regsub "Architectures in the.*are:" $lipo_output ""] 259 } 260 261 # Check for arch constraints 262 proc portcheckdestroot::checkdestroot_arch {} { 263 global UI_PREFIX 264 ui_notice "$UI_PREFIX Checking for archs" 265 set archs [get_canonical_archs] 266 if { "archs" != "noarch" } { 267 checkdestroot_arches $archs 268 } 269 } 270 161 271 proc portcheckdestroot::checkdestroot_main {args} { 162 272 global UI_PREFIX … … 165 275 checkdestroot_symlink 166 276 checkdestroot_mtree 277 checkdestroot_libs 278 checkdestroot_arch 167 279 return 0 168 280 }
Note: See TracChangeset
for help on using the changeset viewer.

