Changeset 80618
- Timestamp:
- 07/15/11 16:02:25 (4 years ago)
- Location:
- branches/gsoc11-post-destroot/base/src
- Files:
-
- 2 added
- 3 edited
-
pextlib1.0/Makefile (modified) (1 diff)
-
pextlib1.0/Pextlib.c (modified) (2 diffs)
-
pextlib1.0/macho.c (added)
-
pextlib1.0/macho.h (added)
-
port1.0/portcheckdestroot.tcl (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/gsoc11-post-destroot/base/src/pextlib1.0/Makefile
r72727 r80618 4 4 sha1cmd.o curl.o rmd160cmd.o sha256cmd.o readline.o uid.o \ 5 5 tracelib.o tty.o readdir.o pipe.o flock.o \ 6 system.o mktemp.o realpath.o 6 system.o mktemp.o realpath.o macho.o 7 7 SHLIB_NAME= Pextlib${SHLIB_SUFFIX} 8 8 INSTALLDIR= ${DESTDIR}${datadir}/macports/Tcl/pextlib1.0 -
branches/gsoc11-post-destroot/base/src/pextlib1.0/Pextlib.c
r74010 r80618 79 79 #include "mktemp.h" 80 80 #include "realpath.h" 81 #include "macho.h" 81 82 82 83 #if HAVE_CRT_EXTERNS_H … … 514 515 Tcl_CreateObjCommand(interp, "name_to_gid", name_to_gidCmd, NULL, NULL); 515 516 Tcl_CreateObjCommand(interp, "gid_to_name", gid_to_nameCmd, NULL, NULL); 517 Tcl_CreateObjCommand(interp, "list_dlibs", list_dlibs, NULL, NULL); 518 Tcl_CreateObjCommand(interp, "list_archs", list_archs, NULL, NULL); 516 519 517 520 Tcl_CreateObjCommand(interp, "tracelib", TracelibCmd, NULL, NULL); -
branches/gsoc11-post-destroot/base/src/port1.0/portcheckdestroot.tcl
r80264 r80618 4 4 package provide portcheckdestroot 1.0 5 5 package require portutil 1.0 6 package require Pextlib 1.0 6 7 7 8 … … 151 152 global UI_PREFIX 152 153 153 set mtree [findBinary mtree ${portutil::autoconf::mtree_path}] 154 155 # test for violations of mtree 156 if { ${destroot.violate_mtree} != "yes" } { 157 ui_notice "$UI_PREFIX Executing mtree check" 158 ui_debug "checking for mtree violations" 159 set mtree_violation "no" 160 161 set prefixPaths [list bin etc include lib libexec sbin share src var www Applications Developer Library] 162 163 set pathsToCheck [list /] 164 while {[llength $pathsToCheck] > 0} { 165 set pathToCheck [lshift pathsToCheck] 166 foreach file [glob -nocomplain -directory $destroot$pathToCheck .* *] { 167 if {[file tail $file] eq "." || [file tail $file] eq ".."} { 168 continue 154 set mtree [findBinary mtree ${portutil::autoconf::mtree_path}] 155 156 # test for violations of mtree 157 if { ${destroot.violate_mtree} != "yes" } { 158 ui_notice "$UI_PREFIX Executing mtree check" 159 ui_debug "checking for mtree violations" 160 set mtree_violation "no" 161 162 set prefixPaths [list bin etc include lib libexec sbin share src var www Applications Developer Library] 163 164 set pathsToCheck [list /] 165 while {[llength $pathsToCheck] > 0} { 166 set pathToCheck [lshift pathsToCheck] 167 foreach file [glob -nocomplain -directory $destroot$pathToCheck .* *] { 168 if {[file tail $file] eq "." || [file tail $file] eq ".."} { 169 continue 170 } 171 if {[string equal -length [string length $destroot] $destroot $file]} { 172 # just double-checking that $destroot is a prefix, as is appropriate 173 set dfile [file join / [string range $file [string length $destroot] end]] 174 } else { 175 throw MACPORTS "Unexpected filepath `${file}' while checking for mtree violations" 176 } 177 if {$dfile eq $prefix} { 178 # we've found our prefix 179 foreach pfile [glob -nocomplain -tails -directory $file .* *] { 180 if {$pfile eq "." || $pfile eq ".."} { 181 continue 182 } 183 if {[lsearch -exact $prefixPaths $pfile] == -1} { 184 ui_warn "violation by [file join $dfile $pfile]" 185 set mtree_violation "yes" 186 } 187 } 188 } elseif {[string equal -length [expr [string length $dfile] + 1] $dfile/ $prefix]} { 189 # we've found a subpath of our prefix 190 lpush pathsToCheck $dfile 191 } else { 192 set dir_allowed no 193 # these files are (at least potentially) outside of the prefix 194 foreach dir "$applications_dir $frameworks_dir /Library/LaunchAgents /Library/LaunchDaemons /Library/StartupItems" { 195 if {[string equal -length [expr [string length $dfile] + 1] $dfile/ $dir]} { 196 # it's a prefix of one of the allowed paths 197 set dir_allowed yes 198 break 199 } 200 } 201 if {$dir_allowed} { 202 lpush pathsToCheck $dfile 203 } else { 204 # not a prefix of an allowed path, so it's either the path itself or a violation 205 switch -- $dfile \ 206 $applications_dir - \ 207 $frameworks_dir - \ 208 /Library/LaunchAgents - \ 209 /Library/LaunchDaemons - \ 210 /Library/StartupItems { ui_debug "port installs files in $dfile" } \ 211 default { 212 ui_warn "violation by $dfile" 213 set mtree_violation "yes" 214 } 215 } 216 } 169 217 } 170 if {[string equal -length [string length $destroot] $destroot $file]} { 171 # just double-checking that $destroot is a prefix, as is appropriate 172 set dfile [file join / [string range $file [string length $destroot] end]] 218 } 219 220 # abort here only so all violations can be observed 221 if { ${mtree_violation} != "no" } { 222 ui_warn "[format [msgcat::mc "%s violates the layout of the ports-filesystems!"] [option subport]]" 223 ui_warn "Please fix or indicate this misbehavior (if it is intended), it will be an error in future releases!" 224 # error "mtree violation!" 225 } 226 } else { 227 ui_warn "[format [msgcat::mc "%s installs files outside the common directory structure."] [option subport]]" 228 } 229 } 230 231 # Check for dynamic links that aren't in the dependency list 232 proc portcheckdestroot::checkdestroot_libs {} { 233 global destroot prefix UI_PREFIX subport 234 ui_notice "$UI_PREFIX Checking for wrong dynamic links" 235 236 #Folders that don't need to be alerted if not on dependencies. 237 #TODO: Compile whitelist folders 238 set dep_whitelist {/usr/lib/ /System/Library/ /lib/} 239 240 #Get dependencies files list. 241 set dep_files {} 242 foreach dep [get_dependencies] { 243 lappend dep_files [file tail [registry_port_registered $dep]] 244 } 245 set self_files [bin_list $destroot$prefix] 246 set dep_files [concat $dep_files $self_files] 247 248 249 #Get package files 250 foreach file [files_list $destroot] { 251 if { [binary? "$file"] } { 252 foreach file_lib [list_dlibs $file] { 253 if { [lsearch $dep_files $file_lib] != -1 } { 254 ui_debug "$file_lib binary dependency is met" 173 255 } else { 174 throw MACPORTS "Unexpected filepath `${file}' while checking for mtree violations" 175 } 176 if {$dfile eq $prefix} { 177 # we've found our prefix 178 foreach pfile [glob -nocomplain -tails -directory $file .* *] { 179 if {$pfile eq "." || $pfile eq ".."} { 180 continue 181 } 182 if {[lsearch -exact $prefixPaths $pfile] == -1} { 183 ui_warn "violation by [file join $dfile $pfile]" 184 set mtree_violation "yes" 185 } 186 } 187 } elseif {[string equal -length [expr [string length $dfile] + 1] $dfile/ $prefix]} { 188 # we've found a subpath of our prefix 189 lpush pathsToCheck $dfile 190 } else { 191 set dir_allowed no 192 # these files are (at least potentially) outside of the prefix 193 foreach dir "$applications_dir $frameworks_dir /Library/LaunchAgents /Library/LaunchDaemons /Library/StartupItems" { 194 if {[string equal -length [expr [string length $dfile] + 1] $dfile/ $dir]} { 195 # it's a prefix of one of the allowed paths 196 set dir_allowed yes 256 #match file folder agains whitelist 257 set found 0 258 foreach dep $dep_whitelist { 259 if { [regexp "^$dep" [regsub $prefix $file_lib ""]] } { 260 set found 1 197 261 break 198 262 } 199 263 } 200 if { $dir_allowed} {201 lpush pathsToCheck $dfile264 if { $found } { 265 ui_debug "$file_lib binary dependency folder is on whitelist" 202 266 } else { 203 # not a prefix of an allowed path, so it's either the path itself or a violation 204 switch -- $dfile \ 205 $applications_dir - \ 206 $frameworks_dir - \ 207 /Library/LaunchAgents - \ 208 /Library/LaunchDaemons - \ 209 /Library/StartupItems { ui_debug "port installs files in $dfile" } \ 210 default { 211 ui_warn "violation by $dfile" 212 set mtree_violation "yes" 213 } 214 } 215 } 216 } 217 } 218 219 # abort here only so all violations can be observed 220 if { ${mtree_violation} != "no" } { 221 ui_warn "[format [msgcat::mc "%s violates the layout of the ports-filesystems!"] [option subport]]" 222 ui_warn "Please fix or indicate this misbehavior (if it is intended), it will be an error in future releases!" 223 # error "mtree violation!" 224 } 225 } else { 226 ui_warn "[format [msgcat::mc "%s installs files outside the common directory structure."] [option subport]]" 227 } 228 } 229 230 # Check for dynamic links that aren't in the dependency list 231 proc portcheckdestroot::checkdestroot_libs {} { 232 global destroot prefix UI_PREFIX subport 233 ui_notice "$UI_PREFIX Checking for wrong dynamic links" 234 235 #Folders that don't need to be alerted if not on dependencies. 236 #TODO: Compile whitelist folders 237 set dep_whitelist {/usr/lib/ /System/Library/ /lib/} 238 239 #Get dependencies files list. 240 set dep_files {} 241 foreach dep [get_dependencies] { 242 lappend dep_files [registry_port_registered $dep] 243 } 244 set self_files [bin_list $destroot$prefix] 245 set dep_files [concat $dep_files $self_files] 246 247 #Get package files 248 foreach file [files_list $destroot] { 249 if { [binary? "$file"] } { 250 #Check it dinamic links with otool 251 set otool_output [get_otool_libs $file] 252 if { $otool_output == "ignore" } { 253 ui_debug "Ignoring $file otool output" 254 } else { 255 foreach line [get_otool_libs $file] { 256 #match they with dependency files 257 if { [regexp {\(.*} $line] } { 258 set lib [string trim [regsub {\(.*} $line ""]] 259 #match against itself 260 if { [regexp [escape_chars $lib] $file] } { 261 ui_debug "skipping, should be the file itself" 262 } else { 263 #match against dependencies or self files 264 if { [regexp [escape_chars $lib] [join $dep_files]] } { 265 ui_debug "$lib binary dependency is met" 266 } else { 267 #match file folder agains whitelist 268 set found 0 269 foreach dep $dep_whitelist { 270 if { [regexp "^$dep" [regsub $prefix $lib ""]] } { 271 set found 1 272 break 273 } 274 } 275 if { $found } { 276 ui_debug "$lib binary dependency folder is on whitelist" 277 } else { 278 return -code error "$lib binary dependencies are NOT met" 279 } 280 } 281 } 267 return -code error "$file_lib binary dependencies are NOT met" 282 268 } 283 269 } … … 292 278 foreach file [files_list $destroot] { 293 279 if { [binary? "$file"] } { 294 set lipo_arches [get_lipo_arches $file] 295 # Chekcs if every arch is present on the lipo output 296 if { $lipo_arches == "ignore" } { 297 ui_debug "Ignoring arch check for $file" 298 } else { 299 foreach arch $archs { 300 if { [regexp $arch $lipo_arches] == 0 } { 301 return -code error "$file supports the arch $arch, and should not" 302 } 280 set file_archs [list_archs $file] 281 foreach arch $archs { 282 if { [lsearch $file_archs $arch] == -1 } { 283 return -code error "$file supports the arch $arch, and should not" 303 284 } 304 285 }
Note: See TracChangeset
for help on using the changeset viewer.

