morgan pushed to branch main at The Tor Project / Applications / tor-browser-build

Commits:

4 changed files:

Changes:

  • projects/release/create_update_responses_tar
    1 1
     #!/bin/bash
    
    2 2
     [% c("var/set_default_env") -%]
    
    3 3
     [% SET channel = c('var/channel') -%]
    
    4
    +rm -Rf [% shell_quote(c("basedir")) %]/tools/update-responses/htdocs/[% channel %]
    
    4 5
     [% shell_quote(c("basedir")) %]/tools/update-responses/update_responses [% channel %]
    
    5 6
     mkdir -p [% shell_quote(path(dest_dir)) %]/update-responses
    
    6 7
     mv [% shell_quote(c("basedir")) %]/tools/update-responses/htdocs/[% channel %] [% channel %]
    
    7
    -chmod 775 [% channel %]
    
    8
    -chmod 664 [% channel %]/.htaccess [% channel %]/*
    
    8
    +find [% channel %] -type d -exec chmod 775 {} \;
    
    9
    +find [% channel %] -type f -exec chmod 664 {} \;
    
    9 10
     tar cf [% shell_quote(path(dest_dir)) %]/update-responses/update-responses-[% channel %]-[%  c("version") %].tar [% channel %]

  • tools/signing/functions
    ... ... @@ -23,7 +23,7 @@ function check_update_responses_repository_dir {
    23 23
       if test -z "$update_responses_repository_dir" || ! test -d "$update_responses_repository_dir"
    
    24 24
       then
    
    25 25
         cat << 'EOF' > /dev/stderr
    
    26
    -$aus1_repository_dir is not defined, or the directory does not exist
    
    26
    +$update_responses_repository_dir is not defined, or the directory does not exist
    
    27 27
     You should clone git@gitlab.torproject.org:tpo/applications/tor-browser-update-responses.git
    
    28 28
     and set $update_responses_repository_dir in set-config.update-responses
    
    29 29
     EOF
    

  • tools/signing/upload-update_responses-to-staticiforme
    ... ... @@ -39,8 +39,32 @@ do
    39 39
       mv "$file" "$tbb_version_type/$fname"
    
    40 40
     done
    
    41 41
     
    
    42
    +# Keep directory from previous release if they are not in the new release.
    
    43
    +# This happens when a release does not include some platforms.
    
    44
    +for file in $(ls -1 "$old_ur/$tbb_version_type")
    
    45
    +do
    
    46
    +  test -d "$old_ur/$tbb_version_type/$file" || continue
    
    47
    +  test -d "$tbb_version_type/$file" && continue
    
    48
    +  mv -f "$old_ur/$tbb_version_type/$file" "$tbb_version_type/$file"
    
    49
    +done
    
    50
    +
    
    51
    +# Commit each sub-directory separately
    
    52
    +for file in $(ls -1 "$tbb_version_type")
    
    53
    +do
    
    54
    +  test -d "$tbb_version_type/$file" || continue
    
    55
    +  git add "$tbb_version_type/$file"
    
    56
    +  git add "$tbb_version_type/download-$file.json"
    
    57
    +  git diff --quiet  --cached --exit-code || \
    
    58
    +    git commit -m "$tbb_version_type: new version, $tbb_version ($file)"
    
    59
    +done
    
    60
    +
    
    61
    +git add "$tbb_version_type"/download-android-*.json
    
    62
    +git diff --quiet  --cached --exit-code || \
    
    63
    +  git commit -m "$tbb_version_type: new version, $tbb_version (android)"
    
    64
    +
    
    42 65
     git add "$tbb_version_type"
    
    43
    -git commit -m "$tbb_version_type: new version, $tbb_version"
    
    66
    +git diff --quiet  --cached --exit-code || \
    
    67
    +  git commit -m "$tbb_version_type: new version, $tbb_version"
    
    44 68
     git push
    
    45 69
     
    
    46 70
     # we just need to push mullvadbrowser's update responses to git, not deploy to staticiforme
    

  • tools/update-responses/update_responses
    ... ... @@ -29,7 +29,6 @@ setlocale(LC_ALL, "C");
    29 29
     
    
    30 30
     my $htdocsdir = "$FindBin::Bin/htdocs";
    
    31 31
     my $config = LoadFile("$FindBin::Bin/config.yml");
    
    32
    -my %htdocsfiles;
    
    33 32
     my $releases_dir = $config->{releases_dir};
    
    34 33
     $releases_dir = "$FindBin::Bin/$releases_dir" unless $releases_dir =~ m/^\//;
    
    35 34
     my @check_errors;
    
    ... ... @@ -51,12 +50,6 @@ sub get_tmpdir {
    51 50
                                     : ());
    
    52 51
     }
    
    53 52
     
    
    54
    -sub build_targets_by_os {
    
    55
    -    exit_error "Unknown build target for OS $_[0]" unless $config->{build_targets}{$_[0]};
    
    56
    -    my $r = $config->{build_targets}{$_[0]};
    
    57
    -    return ref $r eq 'ARRAY' ? @$r : ($r);
    
    58
    -}
    
    59
    -
    
    60 53
     sub get_nbprocs {
    
    61 54
         return $ENV{NUM_PROCS} if defined $ENV{NUM_PROCS};
    
    62 55
         if (-f '/proc/cpuinfo') {
    
    ... ... @@ -80,19 +73,11 @@ sub setup_martools {
    80 73
     }
    
    81 74
     
    
    82 75
     sub write_htdocs {
    
    83
    -    my ($channel, $file, $content) = @_;
    
    76
    +    my ($channel, $dir, $file, $content) = @_;
    
    84 77
         mkdir $htdocsdir unless -d $htdocsdir;
    
    85 78
         mkdir "$htdocsdir/$channel" unless -d "$htdocsdir/$channel";
    
    86
    -    write_file("$htdocsdir/$channel/$file", $content);
    
    87
    -    $htdocsfiles{$channel}->{$file} = 1;
    
    88
    -}
    
    89
    -
    
    90
    -sub clean_htdocs {
    
    91
    -    my ($channel) = @_;
    
    92
    -    opendir(my $d, "$htdocsdir/$channel");
    
    93
    -    my @files = grep { ! $htdocsfiles{$channel}->{$_} } readdir $d;
    
    94
    -    closedir $d;
    
    95
    -    unlink map { "$htdocsdir/$channel/$_" } @files;
    
    79
    +    mkdir "$htdocsdir/$channel/$dir" unless -d "$htdocsdir/$channel/$dir";
    
    80
    +    write_file("$htdocsdir/$channel/$dir/$file", $content);
    
    96 81
     }
    
    97 82
     
    
    98 83
     sub get_sha512_hex_of_file {
    
    ... ... @@ -418,24 +403,31 @@ sub write_responses {
    418 403
         my $versions_str = join('+', @$versions);
    
    419 404
         foreach my $os (keys %oses) {
    
    420 405
             my $resp = get_response($config, $versions, $os);
    
    421
    -        write_htdocs($channel, "$versions_str-$os.xml", $resp);
    
    406
    +        write_htdocs($channel, $os, "$versions_str-$os.xml", $resp);
    
    422 407
             foreach my $from_version (keys %from_versions) {
    
    423 408
                 $resp = get_response($config, $versions, $os, $from_version);
    
    424
    -            write_htdocs($channel, "$from_version-$versions_str-$os.xml", $resp);
    
    409
    +            write_htdocs($channel, $os, "$from_version-$versions_str-$os.xml", $resp);
    
    425 410
             }
    
    411
    +        write_htdocs($channel, $os, 'no-update.xml',
    
    412
    +            '<?xml version="1.0" encoding="UTF-8"?>'
    
    413
    +            . "\n<updates></updates>\n");
    
    426 414
         }
    
    427
    -    write_htdocs($channel, 'no-update.xml',
    
    428
    -        '<?xml version="1.0" encoding="UTF-8"?>'
    
    429
    -        . "\n<updates></updates>\n");
    
    430 415
     }
    
    431 416
     
    
    432 417
     sub write_htaccess {
    
    433 418
         my ($config, $channel) = @_;
    
    434
    -    my $flags = "[last]";
    
    435
    -    my $htaccess = "RewriteEngine On\n";
    
    436
    -    $htaccess .= $config->{htaccess_rewrite_rules}{$channel} // '';
    
    419
    +
    
    420
    +    my $htaccess_main = "RewriteEngine On\n";
    
    421
    +    $htaccess_main .= $config->{htaccess_rewrite_rules}{$channel} // '';
    
    437 422
         my $versions = as_array($config->{channels}{$channel});
    
    438 423
         my $versions_str = join('+', @$versions);
    
    424
    +    foreach my $os (sort keys %{$config->{build_targets}}) {
    
    425
    +        foreach my $bt (@{ as_array($config->{build_targets}{$os}) }) {
    
    426
    +            $htaccess_main .= "RewriteRule ^$bt/(.*) $os/\$1 [last]\n";
    
    427
    +        }
    
    428
    +    }
    
    429
    +    write_htdocs($channel, '.', '.htaccess', $htaccess_main);
    
    430
    +
    
    439 431
         my (%oses, %from_versions);
    
    440 432
         foreach my $version (@$versions) {
    
    441 433
             my $files = $config->{versions}{$version}{files};
    
    ... ... @@ -445,20 +437,20 @@ sub write_htaccess {
    445 437
                     $from_versions{$from_version} = 1;
    
    446 438
                 }
    
    447 439
             }
    
    448
    -        $htaccess .= "RewriteRule ^[^\/]+/$version/ no-update.xml $flags\n";
    
    449 440
         }
    
    450
    -    foreach my $os (sort keys %oses) {
    
    451
    -        foreach my $bt (build_targets_by_os($os)) {
    
    441
    +    foreach my $version (@$versions) {
    
    442
    +        my $files = $config->{versions}{$version}{files};
    
    443
    +        foreach my $os (sort keys %oses) {
    
    444
    +            my $htaccess_os = "RewriteEngine On\n";
    
    445
    +            $htaccess_os .= "RewriteRule ^$version/ no-update.xml [last]\n";
    
    452 446
                 foreach my $from_version (sort keys %from_versions) {
    
    453
    -                $htaccess .= "RewriteRule ^$bt/$from_version/ALL "
    
    454
    -                          .  "$from_version-$versions_str-$os.xml $flags\n";
    
    447
    +                $htaccess_os .= "RewriteRule ^$from_version/ "
    
    448
    +                             .  "$from_version-$versions_str-$os.xml [last]\n";
    
    455 449
                 }
    
    456
    -            $htaccess .= "RewriteRule ^$bt/[^\/]+/ALL "
    
    457
    -                      .  "$versions_str-$os.xml $flags\n";
    
    458
    -            $htaccess .= "RewriteRule ^$bt/ $versions_str-$os.xml $flags\n";
    
    450
    +            $htaccess_os .= "RewriteRule ^[^\/]+/ $versions_str-$os.xml [last]\n";
    
    451
    +            write_htdocs($channel, $os, '.htaccess', $htaccess_os);
    
    459 452
             }
    
    460 453
         }
    
    461
    -    write_htdocs($channel, '.htaccess', $htaccess);
    
    462 454
     }
    
    463 455
     
    
    464 456
     sub write_downloads_json {
    
    ... ... @@ -472,11 +464,11 @@ sub write_downloads_json {
    472 464
             tag => "$tag",
    
    473 465
             downloads => get_version_downloads($config, $version),
    
    474 466
         };
    
    475
    -    write_htdocs($channel, 'downloads.json',
    
    467
    +    write_htdocs($channel, '.', 'downloads.json',
    
    476 468
             JSON->new->utf8->canonical->encode($data));
    
    477 469
         my $pp_downloads = get_perplatform_downloads($config, $version, $tag);
    
    478 470
         foreach my $os (keys %{$pp_downloads}) {
    
    479
    -        write_htdocs($channel, "download-$os.json",
    
    471
    +        write_htdocs($channel, '.', "download-$os.json",
    
    480 472
                 JSON->new->utf8->canonical->encode($pp_downloads->{$os}));
    
    481 473
         }
    
    482 474
     }
    
    ... ... @@ -636,11 +628,9 @@ my %actions = (
    636 628
             exit_error "Wrong arguments" unless @ARGV == 1;
    
    637 629
             my $channel = $ARGV[0];
    
    638 630
             exit_error "Unknown channel $channel" unless $config->{channels}{$channel};
    
    639
    -        $htdocsfiles{$channel} = { '.' => 1, '..' => 1 };
    
    640 631
             write_responses($config, $channel);
    
    641 632
             write_htaccess($config, $channel);
    
    642 633
             write_downloads_json($config, $channel);
    
    643
    -        clean_htdocs($channel);
    
    644 634
         },
    
    645 635
         gen_incrementals => sub {
    
    646 636
             my ($config) = @_;