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

File 0001-Bug-13015-use-git-tags-to-set-tor-browser-version_v2.patch, 13.9 KB (added by boklm, 4 years ago)

new version of the patch

  • gitian/check-match.sh

    From 28e1585aff3e8dd8d15ef7a7add7f95508e9a50b 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 indicates 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 45f4f9b802b8..4a773b819a3b 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
     48echo "TORBROWSER_VERSION=$TORBROWSER_VERSION" >> $GITIAN_DIR/inputs/versions
    4749
    4850cp -r $WRAPPER_DIR/build-helpers/* $GITIAN_DIR/inputs/
    4951cp $WRAPPER_DIR/patches/* $GITIAN_DIR/inputs/
    then 
    252254    exit 1
    253255  fi
    254256
    255   mkdir -p $WRAPPER_DIR/$TORBROWSER_VERSION/
    256   cp -a build/out/tor-browser-linux*xz* $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
    257   cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
    258   #cp -a inputs/mar-tools-linux*.zip $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
    259   cp -a inputs/*debug.zip $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
     257  mkdir -p $WRAPPER_DIR/$TORBROWSER_BUILDDIR/
     258  cp -a build/out/tor-browser-linux*xz* $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
     259  cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
     260  #cp -a inputs/mar-tools-linux*.zip $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
     261  cp -a inputs/*debug.zip $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
    260262  touch inputs/bundle-linux.gbuilt
    261263else
    262264  echo
    else 
    264266  echo
    265267fi
    266268
     269cd $WRAPPER_DIR
     270if [ "$TORBROWSER_SYMLINK_VERSION" == '1' ]
     271then
     272    ln -sf $TORBROWSER_BUILDDIR $TORBROWSER_VERSION
     273fi
     274
    267275echo
    268276echo "****** Linux Bundle complete ******"
    269277echo
  • gitian/mkbundle-mac.sh

    diff --git a/gitian/mkbundle-mac.sh b/gitian/mkbundle-mac.sh
    index 8a3aba6bd34b..ed54dc63cc2b 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
     48echo "TORBROWSER_VERSION=$TORBROWSER_VERSION" >> $GITIAN_DIR/inputs/versions
    4749
    4850cp -r $WRAPPER_DIR/build-helpers/* $GITIAN_DIR/inputs/
    4951cp $WRAPPER_DIR/patches/* $GITIAN_DIR/inputs/
    then 
    219221    exit 1
    220222  fi
    221223
    222   mkdir -p $WRAPPER_DIR/$TORBROWSER_VERSION/
    223   cp -a build/out/* $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
     224  mkdir -p $WRAPPER_DIR/$TORBROWSER_BUILDDIR/
     225  cp -a build/out/* $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
    224226  touch inputs/bundle-mac.gbuilt
    225227else
    226228  echo
    else 
    228230  echo
    229231fi
    230232
     233cd $WRAPPER_DIR
     234if [ "$TORBROWSER_SYMLINK_VERSION" == '1' ]
     235then
     236    ln -sf $TORBROWSER_BUILDDIR $TORBROWSER_VERSION
     237fi
     238
    231239echo
    232240echo "****** Mac Bundle complete ******"
    233241echo
  • gitian/mkbundle-windows.sh

    diff --git a/gitian/mkbundle-windows.sh b/gitian/mkbundle-windows.sh
    index e9508844caf9..945511b0f7ee 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
     48echo "TORBROWSER_VERSION=$TORBROWSER_VERSION" >> $GITIAN_DIR/inputs/versions
    4749
    4850cp -r $WRAPPER_DIR/build-helpers/* $GITIAN_DIR/inputs/
    4951cp $WRAPPER_DIR/patches/* $GITIAN_DIR/inputs/
    then 
    222224    exit 1
    223225  fi
    224226
    225   mkdir -p $WRAPPER_DIR/$TORBROWSER_VERSION/
    226   cp -a build/out/*.exe $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
    227   cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1
    228   cp -a inputs/tor-win32-gbuilt.zip $WRAPPER_DIR/$TORBROWSER_VERSION/tor-win32-${TOR_TAG_ORIG:4}.zip || exit 1
     227  mkdir -p $WRAPPER_DIR/$TORBROWSER_BUILDDIR/
     228  cp -a build/out/*.exe $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
     229  cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1
     230  cp -a inputs/tor-win32-gbuilt.zip $WRAPPER_DIR/$TORBROWSER_BUILDDIR/tor-win32-${TOR_TAG_ORIG:4}.zip || exit 1
    229231  touch inputs/bundle-windows.gbuilt
    230232else
    231233  echo
    else 
    233235  echo
    234236fi
    235237
     238cd $WRAPPER_DIR
     239if [ "$TORBROWSER_SYMLINK_VERSION" == '1' ]
     240then
     241    ln -sf $TORBROWSER_BUILDDIR $TORBROWSER_VERSION
     242fi
     243
    236244echo
    237245echo "****** Windows Bundle complete ******"
    238246echo
  • 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 b84f92ee4486..5306d6be13fd 100755
    a b  
    1 TORBROWSER_VERSION=4.5-alpha-1
     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 e6ea2a1ad99b..d8121870641c 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