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:
- projects/browser/ddmg.sh - tools/signing/ddmg.sh
Changes:
===================================== projects/browser/ddmg.sh ===================================== @@ -14,9 +14,13 @@ hfsfile="$dmg_tmpdir/tbb-uncompressed.dmg" export LD_PRELOAD=[% c("var/faketime_path") %] export FAKETIME="[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]"
-# Use a similar strategy to Mozilla (they have 1.02, we have 1.1) -size=$(du -ms [% src %] | awk '{ print int( $1 * 1.1 ) }') -dd if=/dev/zero of="$hfsfile" bs=1M count=$size +src_dir=[% src %] +# 1 for ceiling and 1 for the inode +fileblocks=$(find "$src_dir" -type f -printf '%s\n' | awk '{s += int($1 / 4096) + 2} END {print s}') +directories=$(find "$src_dir" -type d | wc -l) +# Give some room to breathe +size=$(echo $(($fileblocks + $directories)) | awk '{print int($1 * 1.1)}') +dd if=/dev/zero of="$hfsfile" bs=4096 count=$size newfs_hfs -v "[% c("var/Project_Name") %]" "$hfsfile"
pushd [% src %]
===================================== tools/signing/ddmg.sh ===================================== @@ -30,9 +30,12 @@ export FAKETIME="2000-01-01 01:01:01"
echo "Starting: " $(basename $dest_file)
-# Use a similar strategy to Mozilla (they have 1.02, we have 1.1) -size=$(du -ms "$src_dir" | awk '{ print int( $1 * 1.1 ) }') -dd if=/dev/zero of="$hfsfile" bs=1M count=$size +# 1 for ceiling and 1 for the inode +fileblocks=$(find "$src_dir" -type f -printf '%s\n' | awk '{s += int($1 / 4096) + 2} END {print s}') +directories=$(find "$src_dir" -type d | wc -l) +# Give some room to breathe +size=$(echo $(($fileblocks + $directories)) | awk '{print int($1 * 1.1)}') +dd if=/dev/zero of="$hfsfile" bs=4096 count=$size newfs_hfs -v "$volume_label" "$hfsfile"
cd $src_dir
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/commit/25...
tor-commits@lists.torproject.org