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

[tor-commits] [Git][tpo/applications/tor-browser-build][main] Bug 41931: Refactor our patch to hfsplus-tools.



Title: GitLab

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

Commits:

  • 293435a3
    by Pier Angelo Vendrame at 2026-11-19T13:39:09+01:00
    Bug 41931: Refactor our patch to hfsplus-tools.
    
    With the toolchain update, our patch to hfsplus-tools did not build
    anymore because of a type mismatch.
    
    So, we took this opportunity to improve it, and use the volume creation
    time rather than the volume name to generate the UUID.
    That way, different releases will have a different UUID, which seems
    more correct for its purpose.
    
    The creation time was already there, but it used the current time.
    It worked because we use faketime for the DMG creation, but faketime
    is the last resort, having a CLI argument or an environment variable is
    a better solution, therefore we update our patch also to introduce one.
    
    Sadly, it is not enough to remove the dependency on faketime because
    other tools have the same behavior.
    

4 changed files:

Changes:

  • projects/browser/ddmg.sh
    ... ... @@ -20,7 +20,7 @@ directories=$(find "$src_dir" -type d | wc -l)
    20 20
     # Give some room to breathe
    
    21 21
     size=$(echo $(($fileblocks + $directories)) | awk '{print int($1 * 1.1)}')
    
    22 22
     dd if=/dev/zero of="$hfsfile" bs=4096 count=$size
    
    23
    -newfs_hfs -v "[% c('var/display_name') %]" "$hfsfile"
    
    23
    +newfs_hfs -v "[% c('var/display_name') %]" -t [% c('timestamp') %] "$hfsfile"
    
    24 24
     
    
    25 25
     pushd [% src %]
    
    26 26
     
    

  • projects/hfsplus-tools/newfs_hfs.diff
    ... ... @@ -23,16 +23,64 @@ diff '--color=auto' -Naur diskdev_cmds-540.1.linux3_orig/newfs_hfs.tproj/makehfs
    23 23
      #include <sys/vmmeter.h>
    
    24 24
      #endif
    
    25 25
      
    
    26
    -@@ -571,8 +571,10 @@
    
    27
    - 	/* Adjust free blocks to reflect everything we have allocated. */
    
    26
    +@@ -572,7 +572,18 @@ InitVH(hfsparams_t *defaults, UInt64 sec
    
    28 27
      	hp->freeBlocks -= blocksUsed;
    
    29 28
      
    
    30
    --	/* Generate and write UUID for the HFS+ disk */
    
    29
    + 	/* Generate and write UUID for the HFS+ disk */
    
    31 30
     -	GenerateVolumeUUID(&newVolumeUUID);
    
    32
    -+	/* Use a deterministic UUID for reproducibility */
    
    33
    -+	memset(&newVolumeUUID, 0, sizeof(newVolumeUUID));
    
    34
    -+	strncpy(&newVolumeUUID, defaults->volumeName, sizeof(newVolumeUUID));
    
    35
    -+
    
    31
    ++	/*
    
    32
    ++	 * createDate is a 32-bit integer, so spread its value around with
    
    33
    ++	 * https://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64
    
    34
    ++	 */
    
    35
    ++	{
    
    36
    ++		uint64_t z = defaults->createDate + 0x9e3779b97f4a7c15;
    
    37
    ++		z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
    
    38
    ++		z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
    
    39
    ++		z = z ^ (z >> 31);
    
    40
    ++		newVolumeUUID.value[0] = (uint32_t)(z >> 32);
    
    41
    ++		newVolumeUUID.value[1] = (uint32_t)z;
    
    42
    ++	}
    
    36 43
      	finderInfoUUIDPtr = (VolumeUUID *)(&hp->finderInfo[24]);
    
    37 44
      	finderInfoUUIDPtr->v.high = OSSwapHostToBigInt32(newVolumeUUID.v.high); 
    
    38 45
      	finderInfoUUIDPtr->v.low = OSSwapHostToBigInt32(newVolumeUUID.v.low); 
    
    46
    +diff '--color=auto' -rupN diskdev_cmds-540.1.linux3.orig/newfs_hfs.tproj/newfs_hfs.c diskdev_cmds-540.1.linux3/newfs_hfs.tproj/newfs_hfs.c
    
    47
    +--- diskdev_cmds-540.1.linux3_orig/newfs_hfs.tproj/newfs_hfs.c	2026-11-18 09:58:18.436848140 +0100
    
    48
    ++++ diskdev_cmds-540.1.linux3/newfs_hfs.tproj/newfs_hfs.c	2026-11-18 10:21:37.246871550 +0100
    
    49
    +@@ -191,7 +191,7 @@ main(argc, argv)
    
    50
    + 		progname = *argv;
    
    51
    + 
    
    52
    + 
    
    53
    +-	while ((ch = getopt(argc, argv, "G:J:D:M:N:PU:hsb:c:i:n:v:")) != EOF)
    
    54
    ++	while ((ch = getopt(argc, argv, "G:J:D:M:N:PU:hsb:c:i:n:v:t:")) != EOF)
    
    55
    + 		switch (ch) {
    
    56
    + 		case 'G':
    
    57
    + 			gGroupID = a_gid(optarg);
    
    58
    +@@ -286,6 +286,10 @@ main(argc, argv)
    
    59
    + #endif
    
    60
    + 			break;
    
    61
    + 
    
    62
    ++		case 't':
    
    63
    ++			createtime = (time_t)strtoull(optarg, NULL, 10);
    
    64
    ++			break;
    
    65
    ++
    
    66
    + 		case '?':
    
    67
    + 		default:
    
    68
    + 			usage();
    
    69
    +@@ -763,7 +767,8 @@ hfs_newfs(char *device)
    
    70
    + #endif
    
    71
    + 
    
    72
    + 	dip.sectorOffset = 0;
    
    73
    +-	time(&createtime);
    
    74
    ++	if (!createtime)
    
    75
    ++		time(&createtime);
    
    76
    + 	
    
    77
    + 	/* Check to see if the disk is too big */
    
    78
    + 	u_int64_t secsize = (u_int64_t) dip.sectorSize;
    
    79
    +@@ -1270,6 +1275,7 @@ void usage()
    
    80
    + 	fprintf(stderr, "\t\tc=size (catalog b-tree)\n");
    
    81
    + 	fprintf(stderr, "\t\ta=size (attributes b-tree)\n");
    
    82
    + 	fprintf(stderr, "\t-v volume name (in ascii or UTF-8)\n");
    
    83
    ++	fprintf(stderr, "\t-t creation time (UNIX timestamp)\n");
    
    84
    + 
    
    85
    + 	fprintf(stderr, "  examples:\n");
    
    86
    + 	fprintf(stderr, "\t%s -v Untitled /dev/rdisk0s7 \n", progname);

  • tools/signing/ddmg.sh
    ... ... @@ -28,6 +28,7 @@ hfsfile="$dmg_tmpdir/tbb-uncompressed.dmg"
    28 28
     
    
    29 29
     export LD_PRELOAD=$faketime_path
    
    30 30
     export FAKETIME="$browser_release_date"
    
    31
    +release_timestamp=$(date -u -d "$browser_release_date" +%s)
    
    31 32
     
    
    32 33
     echo "Starting: " $(basename $dest_file)
    
    33 34
     
    
    ... ... @@ -37,7 +38,7 @@ directories=$(find "$src_dir" -type d | wc -l)
    37 38
     # Give some room to breathe
    
    38 39
     size=$(echo $(($fileblocks + $directories)) | awk '{print int($1 * 1.1)}')
    
    39 40
     dd if=/dev/zero of="$hfsfile" bs=4096 count=$size
    
    40
    -newfs_hfs -v "$volume_label" "$hfsfile"
    
    41
    +newfs_hfs -v "$volume_label" -t "$release_timestamp" "$hfsfile"
    
    41 42
     
    
    42 43
     cd $src_dir
    
    43 44
     
    

  • tools/signing/functions
    ... ... @@ -92,7 +92,7 @@ function setup_dmg_tools {
    92 92
           "You can build it with:" \
    
    93 93
           "  ./rbm/rbm build --target no_containers libdmg-hfsplus" \
    
    94 94
           "See var/deps in projects/libdmg-hfsplus/config for the list of build dependencies"
    
    95
    -  local hfstools_file="$script_dir/../../out/hfsplus-tools/hfsplus-tools-540.1.linux3-2acaa4.tar.zst"
    
    95
    +  local hfstools_file="$script_dir/../../out/hfsplus-tools/hfsplus-tools-540.1.linux3-722a62.tar.zst"
    
    96 96
       test -f "$hfstools_file" || \
    
    97 97
         exit_error "$hfstools_file is missing." \
    
    98 98
           "You can build it with:" \
    

  • _______________________________________________
    tor-commits mailing list -- tor-commits@xxxxxxxxxxxxxxxxxxxx
    To unsubscribe send an email to tor-commits-leave@xxxxxxxxxxxxxxxxxxxx