Richard Pospesel pushed to branch main at The Tor Project / Applications / tor-browser-build
Commits: 0ae26788 by Pier Angelo Vendrame at 2023-01-16T19:30:36+00:00 Bug 28124: Switch to Mozilla's libdmg-hfsplus
To show the DMG icon it seems we need to create the DMG from a HFS filesystem, rather than an ISO one. So, to then do so, with this commit I am switching to Mozilla's fork of libdmg-hfsplus, I am updating its build script and using it to build also the hfsplus tool.
Also, add the hfsplus project, which is needed to create the HFS filesystem in the first place.
- - - - - e75f3348 by Pier Angelo Vendrame at 2023-01-16T19:30:36+00:00 Bug 28124: Switch from ISO to HFS and show the disk icon
Use the new tools from the previous commit to build the DMG from a HFS filesystem, and configure it to show the custom volume icon.
- - - - - 71e464f1 by Pier Angelo Vendrame at 2023-01-16T19:30:36+00:00 Bug 28124: Update the macOS volume icon
- - - - -
13 changed files:
- projects/browser/Bundle-Data/mac-applications.dmg/.VolumeIcon.icns - − projects/browser/Bundle-Data/mac-applications.dmg/Applications - projects/browser/build - projects/browser/config - projects/browser/ddmg.sh - + projects/hfsplus-tools/build - + projects/hfsplus-tools/config - + projects/hfsplus-tools/only-newfs_include.diff - projects/libdmg-hfsplus/build - projects/libdmg-hfsplus/config - − projects/libdmg-hfsplus/libdmg.patch - tools/signing/ddmg.sh - tools/signing/gatekeeper-bundling.sh
Changes:
===================================== projects/browser/Bundle-Data/mac-applications.dmg/.VolumeIcon.icns ===================================== Binary files a/projects/browser/Bundle-Data/mac-applications.dmg/.VolumeIcon.icns and b/projects/browser/Bundle-Data/mac-applications.dmg/.VolumeIcon.icns differ
===================================== projects/browser/Bundle-Data/mac-applications.dmg/Applications deleted ===================================== @@ -1 +0,0 @@ -/Applications \ No newline at end of file
===================================== projects/browser/build ===================================== @@ -33,8 +33,9 @@ touch "$GENERATEDPREFSPATH" TORBINPATH=Contents/MacOS/Tor TORCONFIGPATH=Contents/Resources/TorBrowser/Tor
+ tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/hfsplus-tools') %] tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/libdmg') %] - export PATH=/var/tmp/dist/libdmg-hfsplus:$PATH + export PATH=/var/tmp/dist/hfsplus-tools:/var/tmp/dist/libdmg-hfsplus:$PATH [% ELSE %] TBDIR=$TB_STAGE_DIR/Browser TBDIRS=("$TBDIR")
===================================== projects/browser/config ===================================== @@ -33,7 +33,6 @@ targets: macos: var: arch_deps: - - genisoimage - faketime - python3-dev - python3-pip @@ -106,6 +105,9 @@ input_files: sha256sum: 078026ae894fe516ce9e61a1084d1b6dc883cd72c51027de342132141ca7f00d - filename: 'gtk3-settings.ini' enable: '[% c("var/linux") %]' + - project: hfsplus-tools + name: hfsplus-tools + enable: '[% c("var/macos") %]' - project: libdmg-hfsplus name: libdmg enable: '[% c("var/macos") %]'
===================================== projects/browser/ddmg.sh ===================================== @@ -5,17 +5,26 @@ find [% src %] ! -executable -exec chmod 0644 {} ; find [% src %] -exec [% c("touch") %] {} ;
dmg_tmpdir=$(mktemp -d) -[% SET filelist = '"$dmg_tmpdir/filelist.txt"' %] -pushd [% src %] -find . -type f | sed -e 's/^.///' | sort | xargs -i echo "{}={}" > [% filelist %] -find . -type l | sed -e 's/^.///' | sort | xargs -i echo "{}={}" >> [% filelist %] +hfsfile="$dmg_tmpdir/tbb-uncompressed.dmg"
+# hfsplus sets all the times to time(NULL) export LD_PRELOAD=[% c("var/faketime_path") %] export FAKETIME="[% USE date; GET date.format(c('timestamp'), format = '%Y-%m-%d %H:%M:%S') %]"
-genisoimage -D -V "Tor Browser" -no-pad -R -apple -o "$dmg_tmpdir/tbb-uncompressed.dmg" -path-list [% filelist %] -graft-points -gid 20 -dir-mode 0755 -new-dir-mode 0755 +# 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 +newfs_hfs -v "[% c("var/Project_Name") %]" "$hfsfile"
-dmg dmg "$dmg_tmpdir/tbb-uncompressed.dmg" [% c('dmg_out', { error_if_undef => 1 }) %] +pushd [% src %] + +hfsplus "$hfsfile" addall . +# hfsplus does not play well with dangling links +hfsplus "$hfsfile" symlink /Applications /Applications +# Show the volume icon +hfsplus "$hfsfile" attr / C + +dmg dmg "$hfsfile" [% c('dmg_out', { error_if_undef => 1 }) %] popd
rm -Rf "$dmg_tmpdir"
===================================== projects/hfsplus-tools/build ===================================== @@ -0,0 +1,22 @@ +#!/bin/bash +[% c("var/set_default_env") -%] +distdir=/var/tmp/dist/[% project %] +mkdir /var/tmp/dist +tar -C /var/tmp/dist -xf $rootdir/[% c('input_files_by_name/clang') %] +export PATH="/var/tmp/dist/clang/bin:$PATH" + +tar -xf diskdev_cmds-[% c("version") %].tar.gz +cd diskdev_cmds-[% c("version") %] + +patch -p1 < $rootdir/only-newfs_include.diff + +make -j[% c("num_procs") %] + +mkdir -p "$distdir" +cp newfs_hfs.tproj/newfs_hfs "$distdir/" + +cd /var/tmp/dist +[% c('tar', { + tar_src => [ project ], + tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'), + }) %]
===================================== projects/hfsplus-tools/config ===================================== @@ -0,0 +1,21 @@ +# vim: filetype=yaml sw=2 +version: 540.1.linux3 +filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz' +container: + use_container: 1 +var: + deps: + - build-essential + - libssl-dev + - uuid-dev +input_files: + # See hfsplus-tools in taskcluster/ci/fetch/toolchains.yml + - URL: https://src.fedoraproject.org/repo/pkgs/hfsplus-tools/diskdev_cmds-540.1.lin... c("version") %].tar.gz + sha256: b01b203a97f9a3bf36a027c13ddfc59292730552e62722d690d33bd5c24f5497 + - project: container-image + # The project uses a flag that is not supported by GCC + - name: clang + project: clang + # Build only newfs (we do not care of fsck), and remove a header that does not + # exist on Linux (at that path) and is not required on Linux either. + - filename: only-newfs_include.diff
===================================== projects/hfsplus-tools/only-newfs_include.diff ===================================== @@ -0,0 +1,25 @@ +diff '--color=auto' -Naur diskdev_cmds-540.1.linux3_orig/Makefile diskdev_cmds-540.1.linux3/Makefile +--- diskdev_cmds-540.1.linux3_orig/Makefile 2023-01-13 10:01:32.474525600 +0100 ++++ diskdev_cmds-540.1.linux3/Makefile 2023-01-13 10:01:50.346876760 +0100 +@@ -3,7 +3,7 @@ + CC := clang + CFLAGS := -g3 -Wall -fblocks -I$(PWD)/BlocksRunTime -I$(PWD)/include -DDEBUG_BUILD=0 -D_FILE_OFFSET_BITS=64 -D LINUX=1 -D BSD=1 -D VERSION="$(VERSION)" + LDFLAGS := -Wl,--build-id -L$(PWD)/BlocksRunTime +-SUBDIRS := BlocksRunTime newfs_hfs.tproj fsck_hfs.tproj ++SUBDIRS := newfs_hfs.tproj + + all clean: + for d in $(SUBDIRS); do $(MAKE) -C $$d -f Makefile.lnx $@; done +diff '--color=auto' -Naur diskdev_cmds-540.1.linux3_orig/newfs_hfs.tproj/makehfs.c diskdev_cmds-540.1.linux3/newfs_hfs.tproj/makehfs.c +--- diskdev_cmds-540.1.linux3_orig/newfs_hfs.tproj/makehfs.c 2023-01-13 10:01:32.474525600 +0100 ++++ diskdev_cmds-540.1.linux3/newfs_hfs.tproj/makehfs.c 2023-01-13 10:02:07.899221800 +0100 +@@ -38,8 +38,8 @@ + #endif + #include <sys/errno.h> + #include <sys/stat.h> +-#include <sys/sysctl.h> + #if !LINUX ++#include <sys/sysctl.h> + #include <sys/vmmeter.h> + #endif +
===================================== projects/libdmg-hfsplus/build ===================================== @@ -1,16 +1,22 @@ #!/bin/bash [% c("var/set_default_env") -%] -distdir=$(pwd)/dist -mkdir -p $distdir/[% project %] -tar xf [% project %]-[% c('version') %].tar.gz -cd [% project %]-[% c('version') %] -patch -p1 < ../libdmg.patch -cmake -DCMAKE_INSTALL_PREFIX:PATH=$distdir/[% project %] CMakeLists.txt -cd dmg -make -j[% c("num_procs") %] -make install -cd $distdir +distdir=/var/tmp/dist/[% project %] +mkdir -p /var/tmp/dist +tar -C /var/tmp/dist -xf [% c('input_files_by_name/cmake') %] +tar -C /var/tmp/dist -xf [% c('input_files_by_name/ninja') %] +export PATH="/var/tmp/dist/ninja:/var/tmp/dist/cmake/bin:$PATH" + +mkdir /var/tmp/build +tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz +cd /var/tmp/build/[% project %]-[% c('version') %] +cmake . -GNinja -DCMAKE_BUILD_TYPE=Release +ninja -j[% c("num_procs") %] -v + +mkdir $distdir +# We take only dmg and hfsplus like Mozilla does +cp dmg/dmg hfs/hfsplus $distdir/ +cd /var/tmp/dist [% c('tar', { tar_src => [ project ], tar_args => '-czf ' _ dest_dir _ '/' _ c('filename'), - }) %] + }) %]
===================================== projects/libdmg-hfsplus/config ===================================== @@ -1,16 +1,18 @@ # vim: filetype=yaml sw=2 version: '[% c("abbrev") %]' -git_url: https://github.com/vasi/libdmg-hfsplus -git_hash: dfd5e5cc3dc1191e37d3c3a6118975afdd1d7014 +git_url: https://github.com/mozilla/libdmg-hfsplus +git_hash: 2ee327795680101d36f9700bd0fb618362237718 filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz' container: use_container: 1 var: deps: - build-essential - - cmake - zlib1g-dev - libbz2-dev input_files: - project: container-image - - filename: libdmg.patch + - name: cmake + project: cmake + - name: ninja + project: ninja
===================================== projects/libdmg-hfsplus/libdmg.patch deleted ===================================== @@ -1,39 +0,0 @@ -From d1a5eca891f32103ccda80ee75e158dfc7ece70d Mon Sep 17 00:00:00 2001 -From: Mike Perry mikeperry-git@torproject.org -Date: Thu, 6 Mar 2014 19:47:05 -0800 -Subject: [PATCH] Memset a UDIF header to ensure archive reproducibility. - -Some of the struct padding and fields contained unitialized memory, which -caused two successive invocations to produce archives that differed in some -bytes. ---- - dmg/dmglib.c | 6 ++++-- - 1 file changed, 4 insertions(+), 2 deletions(-) - -diff --git a/dmg/dmglib.c b/dmg/dmglib.c -index f481b1f..b74e50b 100644 ---- a/dmg/dmglib.c -+++ b/dmg/dmglib.c -@@ -108,7 +108,8 @@ int buildDmg(AbstractFile* abstractIn, AbstractFile* abstractOut) { - ChecksumToken dataForkToken; - - UDIFResourceFile koly; -- -+ memset(&koly, 0, sizeof(koly)); -+ - off_t plistOffset; - uint32_t plistSize; - uint32_t dataForkChecksum; -@@ -284,7 +285,8 @@ int convertToDMG(AbstractFile* abstractIn, AbstractFile* abstractOut) { - uint64_t numSectors; - - UDIFResourceFile koly; -- -+ memset(&koly, 0, sizeof(koly)); -+ - char partitionName[512]; - - off_t fileLength; --- -1.8.1.2 -
===================================== tools/signing/ddmg.sh ===================================== @@ -21,20 +21,33 @@ find $src_dir ! -executable -exec chmod 0644 {} ; 2> /dev/null find $src_dir -exec touch -m -t 200001010101 {} ; 2> /dev/null set -e
+VOLUME_LABEL="${VOLUME_LABEL:-Tor Browser}" + dmg_tmpdir=$(mktemp -d) -filelist="$dmg_tmpdir/filelist.txt" -cd $src_dir -find . -type f | sed -e 's/^.///' | sort | xargs -i echo "{}={}" > $filelist -find . -type l | sed -e 's/^.///' | sort | xargs -i echo "{}={}" >> $filelist +hfsfile="$dmg_tmpdir/tbb-uncompressed.dmg"
export LD_PRELOAD=$faketime_path export FAKETIME="2000-01-01 01:01:01"
echo "Starting: " $(basename $dest_file)
-genisoimage -D -V "Tor Browser" -no-pad -R -apple -o "$dmg_tmpdir/tbb-uncompressed.dmg" -path-list $filelist -graft-points -gid 20 -dir-mode 0755 -new-dir-mode 0755 +# 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 +newfs_hfs -v "$VOLUME_LABEL" "$hfsfile" + +cd $src_dir + +# hfsplus does not play well with dangling links, so remove /Applications, and +# add it back again with the special command to do so. +rm -f Applications + +hfsplus "$hfsfile" addall . +hfsplus "$hfsfile" symlink /Applications /Applications +# Show the volume icon +hfsplus "$hfsfile" attr / C
-dmg dmg "$dmg_tmpdir/tbb-uncompressed.dmg" "$dest_file" +dmg dmg "$hfsfile" "$dest_file"
echo "Finished: " $(basename $dest_file)
===================================== tools/signing/gatekeeper-bundling.sh ===================================== @@ -35,18 +35,22 @@ set -e script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) source "$script_dir/functions"
-which genisoimage > /dev/null || \ - exit_error 'genisoimage is missing. You should install the genisoimage package.' test -f $faketime_path || \ exit_error "$faketime_path is missing" test -d $macos_stapled_dir || \ exit_error "The stapled macos zip files should be placed in directory $macos_stapled_dir" -libdmg_file="$script_dir/../../out/libdmg-hfsplus/libdmg-hfsplus-dfd5e5cc3dc1-c9296e.tar.gz" +libdmg_file="$script_dir/../../out/libdmg-hfsplus/libdmg-hfsplus-2ee327795680-aa3810.tar.gz" test -f "$libdmg_file" || \ exit_error "$libdmg_file is missing." \ "You can build it with:" \ " ./rbm/rbm build --target no_containers libdmg-hfsplus" \ "See var/deps in projects/libdmg-hfsplus/config for the list of build dependencies" +# hfsplus-tools needs to be compiled with Clang, so its build id might change +hfstools_file="$script_dir/../../out/hfsplus-tools/hfsplus-tools-540.1.linux3-*.tar.gz" +test -f "$hfstools_file" || \ + exit_error "$hfstools_file is missing." \ + "You can build it with:" \ + " ./rbm/rbm build hfsplus-tools --target alpha --target torbrowser-macos-x86_64"
test -d "$macos_signed_dir" || mkdir "$macos_signed_dir" tmpdir="$macos_stapled_dir/tmp" @@ -55,7 +59,8 @@ mkdir "$tmpdir" cp -rT "$script_dir/../../projects/browser/Bundle-Data/mac-applications.dmg" "$tmpdir/dmg"
tar -C "$tmpdir" -xf "$libdmg_file" -export PATH="$PATH:$tmpdir/libdmg-hfsplus" +tar -C "$tmpdir" -xf "$hfstools_file" +export PATH="$PATH:$tmpdir/libdmg-hfsplus:$tmpdir/hfsplus-tools"
for lang in $bundle_locales do
View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/compare/f...