Ticket #13015: 0001-Bug-13015-use-git-tags-to-set-tor-browser-version.patch

File 0001-Bug-13015-use-git-tags-to-set-tor-browser-version.patch, 13.9 KB (added by boklm, 4 years ago)
  • gitian/check-match.sh

    From ab22d5939b457ffffa50534c0e936c18ad914f39 Mon Sep 17 00:00:00 2001
    From: Nicolas Vigier <boklm@torproject.org>
    Date: Mon, 27 Oct 2014 18:00:01 +0100
    Subject: [PATCH] Bug #13015: use git tags to set tor-browser version
    
    This commit adds a get-tb-version script which uses the git tags to
    output the Tor Browser version and its build directory. The output
    should be used with 'eval' in shell scripts to define the variables.
    It takes as argument the type of version (release, alpha or beta).
    
    If the current commit is tagged with tag tbb-4.2-build15, get-tb-version
    will output this:
    
        TORBROWSER_VERSION=4.2
        TORBROWSER_BUILDDIR=4.2-build15
        TORBROWSER_SYMLINK_VERSION=1
    
    If the current commit is not tagged, get-tb-version will use the version
    from the last tagged commit in history. The build directory will include
    the commit hash rather than a build number. The output will be something
    like this:
    
        TORBROWSER_VERSION=4.0
        TORBROWSER_BUILDDIR=4.0-1a98e3efb368
        TORBROWSER_SYMLINK_VERSION=0
    
    The TORBROWSER_BUILDDIR variable is used as the build directory.
    
    The TORBROWSER_SYMLINK_VERSION variable indicate whether we should
    create a symlink TORBROWSER_VERSION -> TORBROWSER_BUILDDIR.
    
    The various files which source the versions files and use
    TORBROWSER_VERSION have been updated to eval the output of
    get-tb-version too, and use TORBROWSER_BUILDDIR as build directory.
    ---
     gitian/check-match.sh      | 25 +++++++++++-----------
     gitian/get-tb-version      | 53 ++++++++++++++++++++++++++++++++++++++++++++++
     gitian/hash-bundles.sh     |  3 ++-
     gitian/mkbundle-linux.sh   | 18 +++++++++++-----
     gitian/mkbundle-mac.sh     | 12 +++++++++--
     gitian/mkbundle-windows.sh | 16 ++++++++++----
     gitian/upload-signature.sh | 17 ++++++++-------
     gitian/versions            |  2 +-
     gitian/versions.alpha      |  2 +-
     gitian/versions.beta       |  2 +-
     gitian/versions.nightly    |  3 +++
     11 files changed, 118 insertions(+), 35 deletions(-)
     create mode 100755 gitian/get-tb-version
    
    diff --git a/gitian/check-match.sh b/gitian/check-match.sh
    index 062251230c1f..71a57f2c7f47 100755
    a b if ! [ -e $VERSIONS_FILE ]; then 
    2424fi
    2525
    2626. $VERSIONS_FILE
     27eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
    2728
    2829VALID=""
    2930VALID_incrementals=""
    do 
    3334  cd $WRAPPER_DIR
    3435
    3536  # XXX: Is there a better way to store these and rename them?
    36   mkdir -p $TORBROWSER_VERSION/$u
    37   cd $TORBROWSER_VERSION/$u
     37  mkdir -p $TORBROWSER_BUILDDIR/$u
     38  cd $TORBROWSER_BUILDDIR/$u
    3839
    39   wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_VERSION/sha256sums.txt || continue
    40   wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_VERSION/sha256sums.txt.asc || continue
     40  wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_BUILDDIR/sha256sums.txt || continue
     41  wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_BUILDDIR/sha256sums.txt.asc || continue
    4142
    4243  keyring="../../gpg/$u.gpg"
    4344
    done 
    5354cd ../..
    5455
    5556# XXX: We should refactor this code into a shared function
    56 if [ -f $TORBROWSER_VERSION/sha256sums.incrementals.txt ]
     57if [ -f $TORBROWSER_BUILDDIR/sha256sums.incrementals.txt ]
    5758then
    5859  for u in $USERS
    5960  do
    6061    cd $WRAPPER_DIR
    6162
    6263    # XXX: Is there a better way to store these and rename them?
    63     mkdir -p $TORBROWSER_VERSION/$u
    64     cd $TORBROWSER_VERSION/$u
     64    mkdir -p $TORBROWSER_BUILDDIR/$u
     65    cd $TORBROWSER_BUILDDIR/$u
    6566
    66     wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_VERSION/sha256sums.incrementals.txt || continue
    67     wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_VERSION/sha256sums.incrementals.txt.asc || continue
     67    wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_BUILDDIR/sha256sums.incrementals.txt || continue
     68    wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_BUILDDIR/sha256sums.incrementals.txt.asc || continue
    6869
    6970    keyring="../../gpg/$u.gpg"
    7071
    cd ../.. 
    8384exit_val=0
    8485if [ -z "$VALID" ];
    8586then
    86   echo "No bundle hashes or sigs published for $TORBROWSER_VERSION."
     87  echo "No bundle hashes or sigs published for $TORBROWSER_BUILDDIR."
    8788  echo
    8889  exit_val=1
    8990else
    9091  echo "Matching bundles exist from the following users: $VALID"
    9192fi
    9293
    93 if [ -f $TORBROWSER_VERSION/sha256sums.incrementals.txt ]
     94if [ -f $TORBROWSER_BUILDDIR/sha256sums.incrementals.txt ]
    9495then
    9596  if [ -z "$VALID_incrementals" ]
    9697  then
    97     echo "No incremental mars hashes or sigs published for $TORBROWSER_VERSION."
     98    echo "No incremental mars hashes or sigs published for $TORBROWSER_BUILDDIR."
    9899    exit_val=1
    99100  else
    100101    echo "Matching incremental mars exist from the following users: $VALID_incrementals"
  • new file gitian/get-tb-version

    diff --git a/gitian/get-tb-version b/gitian/get-tb-version
    new file mode 100755
    index 000000000000..9a4a102ccdf9
    - +  
     1#!/usr/bin/perl -w
     2use strict;
     3
     4sub run_cmd {
     5    my @cmd = @_;
     6    my $pid = open(my $fh, '-|');
     7    if (!$pid) {
     8        exec(@cmd);
     9    }
     10    my @res = <$fh>;
     11    waitpid($pid, 0);
     12    die "Error running " . join(' ', @cmd) if $?;
     13    chomp @res;
     14    return @res;
     15}
     16
     17my %types = (
     18    release => qr/tbb-([^ab]+)-build(.+)$/,
     19    beta => qr/tbb-(.+b.+)-build(.+)$/,
     20    alpha => qr/tbb-(.+a.+)-build(.+)$/,
     21);
     22my $type = $ARGV[0] ? $ARGV[0] : 'release';
     23exit 0 if $type eq 'nightly';
     24die "Unknown type $type" unless $types{$type};
     25my %tags;
     26foreach my $tag (run_cmd('git', 'tag')) {
     27    if ($tag =~ m/$types{$type}/) {
     28        my ($commit) = run_cmd('git', 'show', '-s', '--format=%H',
     29                               "$tag^{commit}");
     30        $tags{$commit} = [ $1, $2 ];
     31    }
     32}
     33
     34my ($current_commit) = run_cmd('git', 'show', '-s', '--format=%H');
     35if ($tags{$current_commit}) {
     36    print "TORBROWSER_VERSION=$tags{$current_commit}->[0]\n";
     37    print 'TORBROWSER_BUILDDIR=', $tags{$current_commit}->[0], '-build',
     38          $tags{$current_commit}->[1], "\n";
     39    print "TORBROWSER_SYMLINK_VERSION=1\n";
     40    exit 0;
     41}
     42
     43foreach my $commit (run_cmd('git', 'log', '-s', '--format=%H', '-200')) {
     44    next unless $tags{$commit};
     45    print "TORBROWSER_VERSION=$tags{$commit}->[0]\n";
     46    print "TORBROWSER_BUILDDIR=$tags{$commit}->[0]-",
     47          substr($commit, 0, 12), "\n";
     48    print "TORBROWSER_SYMLINK_VERSION=0\n";
     49    exit 0;
     50}
     51
     52print STDERR "Could not find TORBROWSER version from tags\n";
     53exit 1;
  • gitian/hash-bundles.sh

    diff --git a/gitian/hash-bundles.sh b/gitian/hash-bundles.sh
    index 26841587ecf1..37efdb1855b6 100755
    a b if ! [ -e $VERSIONS_FILE ]; then 
    1414fi
    1515
    1616. $VERSIONS_FILE
     17eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
    1718
    1819export LC_ALL=C
    1920
    20 cd $TORBROWSER_VERSION
     21cd $TORBROWSER_BUILDDIR
    2122rm -f sha256sums.txt sha256sums.incrementals.txt
    2223sha256sum `ls -1 | grep -v '\.incremental\.mar$' | sort` > sha256sums.txt
    2324if ls -1 | grep -q '\.incremental\.mar$'
  • gitian/mkbundle-linux.sh

    diff --git a/gitian/mkbundle-linux.sh b/gitian/mkbundle-linux.sh
    index 8321ffe98f89..c2fb06bd21bb 100755
    a b if ! [ -e $VERSIONS_FILE ]; then 
    1616fi
    1717
    1818. $VERSIONS_FILE
     19eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
    1920
    2021WRAPPER_DIR=$PWD
    2122GITIAN_DIR=$PWD/../../gitian-builder
    export PATH=$PATH:$PWD/libexec 
    4445
    4546echo "$TORBROWSER_VERSION" > $GITIAN_DIR/inputs/bare-version
    4647cp -a $WRAPPER_DIR/$VERSIONS_FILE $GITIAN_DIR/inputs/versions
     48./get-tb-version $TORBROWSER_VERSION_TYPE >> $GITIAN_DIR/inputs/versions
    4749
    4850cp -r $WRAPPER_DIR/build-helpers/* $GITIAN_DIR/inputs/
    4951cp $WRAPPER_DIR/patches/* $GITIAN_DIR/inputs/
    then 
    251253    exit 1
    252254  fi
    253255
    254   mkdir -p $WRAPPER_DIR/$TORBROWSER_VERSION/
    255   cp -a build/out/tor-browser-linux*xz* $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
    256   cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
    257   #cp -a inputs/mar-tools-linux*.zip $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
    258   cp -a inputs/*debug.zip $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
     256  mkdir -p $WRAPPER_DIR/$TORBROWSER_BUILDDIR/
     257  cp -a build/out/tor-browser-linux*xz* $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
     258  cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
     259  #cp -a inputs/mar-tools-linux*.zip $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
     260  cp -a inputs/*debug.zip $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
    259261  touch inputs/bundle-linux.gbuilt
    260262else
    261263  echo
    else 
    263265  echo
    264266fi
    265267
     268cd $WRAPPER_DIR
     269if [ "$TORBROWSER_SYMLINK_VERSION" == '1' ]
     270then
     271    ln -sf $TORBROWSER_BUILDDIR $TORBROWSER_VERSION
     272fi
     273
    266274echo
    267275echo "****** Linux Bundle complete ******"
    268276echo
  • gitian/mkbundle-mac.sh

    diff --git a/gitian/mkbundle-mac.sh b/gitian/mkbundle-mac.sh
    index 9c5d99bf13a9..80b8c5eb10e2 100755
    a b if ! [ -e $VERSIONS_FILE ]; then 
    1616fi
    1717
    1818. $VERSIONS_FILE
     19eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
    1920
    2021WRAPPER_DIR=$PWD
    2122GITIAN_DIR=$PWD/../../gitian-builder
    export PATH=$PATH:$PWD/libexec 
    4445
    4546echo "$TORBROWSER_VERSION" > $GITIAN_DIR/inputs/bare-version
    4647cp -a $WRAPPER_DIR/$VERSIONS_FILE $GITIAN_DIR/inputs/versions
     48./get-tb-version $TORBROWSER_VERSION_TYPE >> $GITIAN_DIR/inputs/versions
    4749
    4850cp -r $WRAPPER_DIR/build-helpers/* $GITIAN_DIR/inputs/
    4951cp $WRAPPER_DIR/patches/* $GITIAN_DIR/inputs/
    then 
    218220    exit 1
    219221  fi
    220222
    221   mkdir -p $WRAPPER_DIR/$TORBROWSER_VERSION/
    222   cp -a build/out/* $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
     223  mkdir -p $WRAPPER_DIR/$TORBROWSER_BUILDDIR/
     224  cp -a build/out/* $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
    223225  touch inputs/bundle-mac.gbuilt
    224226else
    225227  echo
    else 
    227229  echo
    228230fi
    229231
     232cd $WRAPPER_DIR
     233if [ "$TORBROWSER_SYMLINK_VERSION" == '1' ]
     234then
     235    ln -sf $TORBROWSER_BUILDDIR $TORBROWSER_VERSION
     236fi
     237
    230238echo
    231239echo "****** Mac Bundle complete ******"
    232240echo
  • gitian/mkbundle-windows.sh

    diff --git a/gitian/mkbundle-windows.sh b/gitian/mkbundle-windows.sh
    index 673344a50727..a9368e3e276e 100755
    a b if ! [ -e $VERSIONS_FILE ]; then 
    1616fi
    1717
    1818. $VERSIONS_FILE
     19eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
    1920
    2021WRAPPER_DIR=$PWD
    2122GITIAN_DIR=$PWD/../../gitian-builder
    export PATH=$PATH:$PWD/libexec 
    4445
    4546echo "$TORBROWSER_VERSION" > $GITIAN_DIR/inputs/bare-version
    4647cp -a $WRAPPER_DIR/$VERSIONS_FILE $GITIAN_DIR/inputs/versions
     48./get-tb-version $TORBROWSER_VERSION_TYPE >> $GITIAN_DIR/inputs/versions
    4749
    4850cp -r $WRAPPER_DIR/build-helpers/* $GITIAN_DIR/inputs/
    4951cp $WRAPPER_DIR/patches/* $GITIAN_DIR/inputs/
    then 
    221223    exit 1
    222224  fi
    223225
    224   mkdir -p $WRAPPER_DIR/$TORBROWSER_VERSION/
    225   cp -a build/out/*.exe $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
    226   cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
    227   cp -a inputs/tor-win32-gbuilt.zip $WRAPPER_DIR/$TORBROWSER_VERSION/tor-win32-${TOR_TAG_ORIG}.zip || exit 1
     226  mkdir -p $WRAPPER_DIR/$TORBROWSER_BUILDDIR/
     227  cp -a build/out/*.exe $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
     228  cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
     229  cp -a inputs/tor-win32-gbuilt.zip $WRAPPER_DIR/$TORBROWSER_BUILDDIR/tor-win32-${TOR_TAG_ORIG}.zip || exit 1
    228230  touch inputs/bundle-windows.gbuilt
    229231else
    230232  echo
    else 
    232234  echo
    233235fi
    234236
     237cd $WRAPPER_DIR
     238if [ "$TORBROWSER_SYMLINK_VERSION" == '1' ]
     239then
     240    ln -sf $TORBROWSER_BUILDDIR $TORBROWSER_VERSION
     241fi
     242
    235243echo
    236244echo "****** Windows Bundle complete ******"
    237245echo
  • gitian/upload-signature.sh

    diff --git a/gitian/upload-signature.sh b/gitian/upload-signature.sh
    index 58059aa1b272..c403cd59e49e 100755
    a b if ! [ -e $VERSIONS_FILE ]; then 
    2121fi
    2222
    2323. $VERSIONS_FILE
     24eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
    2425
    25 if [ ! -f $TORBROWSER_VERSION/sha256sums.txt.asc ];
     26if [ ! -f $TORBROWSER_BUILDDIR/sha256sums.txt.asc ];
    2627then
    27   pushd $TORBROWSER_VERSION && gpg -abs sha256sums.txt
     28  pushd $TORBROWSER_BUILDDIR && gpg -abs sha256sums.txt
    2829  popd
    2930fi
    3031
    31 if [ -f $TORBROWSER_VERSION/sha256sums.incrementals.txt ] \
    32     && [ ! -f $TORBROWSER_VERSION/sha256sums.incrementals.txt.asc ]
     32if [ -f $TORBROWSER_BUILDDIR/sha256sums.incrementals.txt ] \
     33    && [ ! -f $TORBROWSER_BUILDDIR/sha256sums.incrementals.txt.asc ]
    3334then
    34   pushd $TORBROWSER_VERSION && gpg -abs sha256sums.incrementals.txt
     35  pushd $TORBROWSER_BUILDDIR && gpg -abs sha256sums.incrementals.txt
    3536  popd
    3637fi
    3738
    3839
    39 ssh $HOST "mkdir -p $BASE_DIR/$TORBROWSER_VERSION"
    40 scp $TORBROWSER_VERSION/sha256sums*.txt* $HOST:$BASE_DIR/$TORBROWSER_VERSION/
    41 ssh $HOST "chmod 755 $BASE_DIR/$TORBROWSER_VERSION && chmod 644 $BASE_DIR/$TORBROWSER_VERSION/*"
     40ssh $HOST "mkdir -p $BASE_DIR/$TORBROWSER_BUILDDIR"
     41scp $TORBROWSER_BUILDDIR/sha256sums*.txt* $HOST:$BASE_DIR/$TORBROWSER_BUILDDIR/
     42ssh $HOST "chmod 755 $BASE_DIR/$TORBROWSER_BUILDDIR && chmod 644 $BASE_DIR/$TORBROWSER_BUILDDIR/*"
  • gitian/versions

    diff --git a/gitian/versions b/gitian/versions
    index b6ec79febbd5..36f315d5d81d 100755
    a b  
    1 TORBROWSER_VERSION=4.0.1
     1TORBROWSER_VERSION_TYPE=release
    22BUNDLE_LOCALES="ar de es-ES fa fr it ko nl pl pt-PT ru tr vi zh-CN"
    33BUILD_PT_BUNDLES=1
    44
  • gitian/versions.alpha

    diff --git a/gitian/versions.alpha b/gitian/versions.alpha
    index e17b071eaa3f..8ca8d4c62788 100755
    a b  
    1 TORBROWSER_VERSION=4.0-alpha-3
     1TORBROWSER_VERSION_TYPE=alpha
    22BUNDLE_LOCALES="ar de es-ES fa fr it ko nl pl pt-PT ru tr vi zh-CN"
    33BUILD_PT_BUNDLES=1
    44
  • gitian/versions.beta

    diff --git a/gitian/versions.beta b/gitian/versions.beta
    index 29ba9e924441..3678b378761e 100755
    a b  
    1 TORBROWSER_VERSION=3.6.1
     1TORBROWSER_VERSION_TYPE=beta
    22BUNDLE_LOCALES="ar de es-ES fa fr it ko nl pl pt-PT ru tr vi zh-CN"
    33BUILD_PT_BUNDLES=1
    44
  • gitian/versions.nightly

    diff --git a/gitian/versions.nightly b/gitian/versions.nightly
    index 4ff8d99308f1..968ef1b7b601 100755
    a b  
     1TORBROWSER_VERSION_TYPE=nightly
    12TORBROWSER_VERSION=tbb-nightly
     3TORBROWSER_BUILDDIR=tbb-nightly
     4TORBROWSER_SYMLINK_VERSION=0
    25BUNDLE_LOCALES="ar ru zh-CN"
    36BUILD_PT_BUNDLES=1
    47