Skip to content
Snippets Groups Projects
Verified Commit 2579da7c authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame :jack_o_lantern:
Browse files

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.
parent 723c63a0
Branches
Tags
1 merge request!709Bug 40847: Do not rely on du to compute the HFS size
......@@ -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 %]
......
......
......@@ -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
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment