[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [Git][tpo/applications/tor-browser-build][main] Bug 40847: Do not rely on du to compute the HFS size



Title: GitLab

Pier Angelo Vendrame pushed to branch main at The Tor Project / Applications / tor-browser-build

Commits:

  • 2579da7c
    by Pier Angelo Vendrame at 2023-06-07T18:30:37+02:00
    Bug 40847: Do not rely on du to compute the HFS size
    
    HFS has the disadvantage that we cannot grow the filesystem while
    adding files.
    We have to estimate an initial size, instead, and we relied on du for
    this. However, du depends on the underlying filesystem, and this could
    lead to reproducibility issues (because the HFS headers tell different
    sizes).
    
    So, with this change, we compute a rough number of needed blocks by
    taking the actual size of the files.
    
    Overshooting is not a problem, because DMG is compressed with bzip2, so
    unused space will be trimmed, eventually.
    

2 changed files:

Changes:

  • projects/browser/ddmg.sh
    ... ... @@ -14,9 +14,13 @@ hfsfile="\$dmg_tmpdir/tbb-uncompressed.dmg"
    14 14
     export LD_PRELOAD=[% c("var/faketime_path") %]
    
    15 15
     export FAKETIME="[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]"
    
    16 16
     
    
    17
    -# Use a similar strategy to Mozilla (they have 1.02, we have 1.1)
    
    18
    -size=\$(du -ms [% src %] | awk '{ print int( \$1 * 1.1 ) }')
    
    19
    -dd if=/dev/zero of="\$hfsfile" bs=1M count=\$size
    
    17
    +src_dir=[% src %]
    
    18
    +# 1 for ceiling and 1 for the inode
    
    19
    +fileblocks=\$(find "\$src_dir" -type f -printf '%s\n' | awk '{s += int(\$1 / 4096) + 2} END {print s}')
    
    20
    +directories=\$(find "\$src_dir" -type d | wc -l)
    
    21
    +# Give some room to breathe
    
    22
    +size=\$(echo \$((\$fileblocks + \$directories)) | awk '{print int(\$1 * 1.1)}')
    
    23
    +dd if=/dev/zero of="\$hfsfile" bs=4096 count=\$size
    
    20 24
     newfs_hfs -v "[% c("var/Project_Name") %]" "\$hfsfile"
    
    21 25
     
    
    22 26
     pushd [% src %]
    

  • tools/signing/ddmg.sh
    ... ... @@ -30,9 +30,12 @@ export FAKETIME="2000-01-01 01:01:01"
    30 30
     
    
    31 31
     echo "Starting: " $(basename $dest_file)
    
    32 32
     
    
    33
    -# Use a similar strategy to Mozilla (they have 1.02, we have 1.1)
    
    34
    -size=$(du -ms "$src_dir" | awk '{ print int( $1 * 1.1 ) }')
    
    35
    -dd if=/dev/zero of="$hfsfile" bs=1M count=$size
    
    33
    +# 1 for ceiling and 1 for the inode
    
    34
    +fileblocks=$(find "$src_dir" -type f -printf '%s\n' | awk '{s += int($1 / 4096) + 2} END {print s}')
    
    35
    +directories=$(find "$src_dir" -type d | wc -l)
    
    36
    +# Give some room to breathe
    
    37
    +size=$(echo $(($fileblocks + $directories)) | awk '{print int($1 * 1.1)}')
    
    38
    +dd if=/dev/zero of="$hfsfile" bs=4096 count=$size
    
    36 39
     newfs_hfs -v "$volume_label" "$hfsfile"
    
    37 40
     
    
    38 41
     cd $src_dir
    

  • _______________________________________________
    tor-commits mailing list
    tor-commits@xxxxxxxxxxxxxxxxxxxx
    https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits