Changeset 1579 for trunk/base


Ignore:
Timestamp:
Jan 6, 2003, 11:10:02 AM (17 years ago)
Author:
landonf (Landon Fuller)
Message:

Write out accurate size file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/base/src/port1.0/portpackage.tcl

    r1560 r1579  
    166166        write_info_plist ${pkgpath}/Contents/Info.plist $portname $portversion $prefix
    167167        write_description_plist ${pkgpath}/Contents/Resources/Description.plist $portname $portversion $description
    168         system "cp ${portresourcepath}/package/background.tiff ${pkgpath}/Contents/Resources/background.tiff"
     168        file copy -force -- ${portresourcepath}/package/background.tiff ${pkgpath}/Contents/Resources/background.tiff
    169169        system "mkbom ${destpath} ${pkgpath}/Contents/Archive.bom"
    170170        system "cd ${pkgpath}/Contents/Resources/ && ln -fs ../Archive.bom ${portname}.bom"
     
    172172        system "cd ${pkgpath}/Contents/Resources/ && ln -fs ../Archive.pax.gz ${portname}.pax.gz"
    173173
    174         write_sizes_file ${pkgpath}/Contents/Resources/${portname}.sizes ${pkgpath} ${destpath}
     174        write_sizes_file ${pkgpath}/Contents/Resources/${portname}.sizes ${portname} ${pkgpath} ${destpath}
    175175
    176176    return 0
     177}
     178
     179proc dirSize {dir} {
     180    set size    0;
     181    foreach file [readdir $dir] {
     182        if {$file == "." || $file == ".."} {
     183            continue
     184        }
     185        if {[file isdirectory [file join $dir $file]]} {
     186            incr size [dirSize [file join $dir $file]]
     187        } else {
     188            incr size [file size [file join $dir $file]];
     189        }
     190    }
     191    return $size;
    177192}
    178193
     
    280295}
    281296
    282 proc write_sizes_file {sizesfile pkgpath destpath} {
    283 set numFiles 0
    284 set compressedSize 0
    285 set installedSize 0
    286 #       set numFiles `lsbom -s "${pkgpath}/Contents/Archive.bom" | wc -l`
    287 #       set compresedSize `du -k -s "$pkgpath" | awk '{print $1}'`
    288 #       incr compressedSize 3
    289 #       set infoSize `ls -s "${pkgpath}/Contents/Resources/${portname}.info" | awk '{print $1}'`
    290 #       set bomSize `ls -s "${pkgpath}/Contents/Archive.bom" | awk '{print $1}'`
    291 #       set installedSize `du -k -s "$destpath" | awk '{print $1}'`
    292 #       incr installedSize $infoSize
    293 #       incr installedSize $bomSize
    294 #       incr installedSize 3
    295        
    296         set fd [open ${sizesfile} w+]
    297         puts $fd "NumFiles $numFiles
     297proc write_sizes_file {sizesfile portname pkgpath destpath} {
     298   
     299    if {[catch {set numFiles [exec lsbom -s ${pkgpath}/Contents/Archive.bom | wc -l]} result]} {
     300        return -code error "Reading package bom failed: $result"
     301    }
     302    if {[catch {set compressedSize [expr [dirSize ${pkgpath}] / 1024]} result]} {
     303        return -code error "Error determining compressed size: $result"
     304    }
     305    if {[catch {set installedSize [expr [dirSize ${destpath}] / 1024]} result]} {
     306        return -code error "Error determining installed size: $result"
     307    }
     308    if {[catch {set infoSize [file size ${pkgpath}/Contents/Resources/${portname}.info]} result]} {
     309        return -code error "Error determining info file size: $result"
     310    }
     311    if {[catch {set bomSize [file size ${pkgpath}/Contents/Archive.bom]} result]} {
     312        return -code error "Error determining bom file size: $result"
     313    }
     314    incr installedSize $infoSize
     315    incr installedSize $bomSize
     316       
     317    set fd [open ${sizesfile} w+]
     318    puts $fd "NumFiles $numFiles
    298319InstalledSize $installedSize
    299320CompressedSize $compressedSize"
    300         close $fd
    301 }
     321    close $fd
     322}
Note: See TracChangeset for help on using the changeset viewer.