commit 28e1585aff3e8dd8d15ef7a7add7f95508e9a50b Author: Nicolas Vigier boklm@torproject.org Date: Mon Oct 27 18:00:01 2014 +0100
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(-)
diff --git a/gitian/check-match.sh b/gitian/check-match.sh index 0622512..71a57f2 100755 --- a/gitian/check-match.sh +++ b/gitian/check-match.sh @@ -24,6 +24,7 @@ if ! [ -e $VERSIONS_FILE ]; then fi
. $VERSIONS_FILE +eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
VALID="" VALID_incrementals="" @@ -33,11 +34,11 @@ do cd $WRAPPER_DIR
# XXX: Is there a better way to store these and rename them? - mkdir -p $TORBROWSER_VERSION/$u - cd $TORBROWSER_VERSION/$u + mkdir -p $TORBROWSER_BUILDDIR/$u + cd $TORBROWSER_BUILDDIR/$u
- wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_VERSION/sha256sums.txt || continue - wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_VERSION/sha256sums.txt.asc || continue + wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_BUILDDIR/sha256sums.txt || continue + wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_BUILDDIR/sha256sums.txt.asc || continue
keyring="../../gpg/$u.gpg"
@@ -53,18 +54,18 @@ done cd ../..
# XXX: We should refactor this code into a shared function -if [ -f $TORBROWSER_VERSION/sha256sums.incrementals.txt ] +if [ -f $TORBROWSER_BUILDDIR/sha256sums.incrementals.txt ] then for u in $USERS do cd $WRAPPER_DIR
# XXX: Is there a better way to store these and rename them? - mkdir -p $TORBROWSER_VERSION/$u - cd $TORBROWSER_VERSION/$u + mkdir -p $TORBROWSER_BUILDDIR/$u + cd $TORBROWSER_BUILDDIR/$u
- wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_VERSION/sha256sums.incrementals.txt || continue - wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_VERSION/sha256sums.incrementals.txt.asc || continue + wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_BUILDDIR/sha256sums.incrementals.txt || continue + wget -U "" -N https://$HOST/~$u/builds/$TORBROWSER_BUILDDIR/sha256sums.incrementals.txt.as... || continue
keyring="../../gpg/$u.gpg"
@@ -83,18 +84,18 @@ cd ../.. exit_val=0 if [ -z "$VALID" ]; then - echo "No bundle hashes or sigs published for $TORBROWSER_VERSION." + echo "No bundle hashes or sigs published for $TORBROWSER_BUILDDIR." echo exit_val=1 else echo "Matching bundles exist from the following users: $VALID" fi
-if [ -f $TORBROWSER_VERSION/sha256sums.incrementals.txt ] +if [ -f $TORBROWSER_BUILDDIR/sha256sums.incrementals.txt ] then if [ -z "$VALID_incrementals" ] then - echo "No incremental mars hashes or sigs published for $TORBROWSER_VERSION." + echo "No incremental mars hashes or sigs published for $TORBROWSER_BUILDDIR." exit_val=1 else echo "Matching incremental mars exist from the following users: $VALID_incrementals" diff --git a/gitian/get-tb-version b/gitian/get-tb-version new file mode 100755 index 0000000..9a4a102 --- /dev/null +++ b/gitian/get-tb-version @@ -0,0 +1,53 @@ +#!/usr/bin/perl -w +use strict; + +sub run_cmd { + my @cmd = @_; + my $pid = open(my $fh, '-|'); + if (!$pid) { + exec(@cmd); + } + my @res = <$fh>; + waitpid($pid, 0); + die "Error running " . join(' ', @cmd) if $?; + chomp @res; + return @res; +} + +my %types = ( + release => qr/tbb-([^ab]+)-build(.+)$/, + beta => qr/tbb-(.+b.+)-build(.+)$/, + alpha => qr/tbb-(.+a.+)-build(.+)$/, +); +my $type = $ARGV[0] ? $ARGV[0] : 'release'; +exit 0 if $type eq 'nightly'; +die "Unknown type $type" unless $types{$type}; +my %tags; +foreach my $tag (run_cmd('git', 'tag')) { + if ($tag =~ m/$types{$type}/) { + my ($commit) = run_cmd('git', 'show', '-s', '--format=%H', + "$tag^{commit}"); + $tags{$commit} = [ $1, $2 ]; + } +} + +my ($current_commit) = run_cmd('git', 'show', '-s', '--format=%H'); +if ($tags{$current_commit}) { + print "TORBROWSER_VERSION=$tags{$current_commit}->[0]\n"; + print 'TORBROWSER_BUILDDIR=', $tags{$current_commit}->[0], '-build', + $tags{$current_commit}->[1], "\n"; + print "TORBROWSER_SYMLINK_VERSION=1\n"; + exit 0; +} + +foreach my $commit (run_cmd('git', 'log', '-s', '--format=%H', '-200')) { + next unless $tags{$commit}; + print "TORBROWSER_VERSION=$tags{$commit}->[0]\n"; + print "TORBROWSER_BUILDDIR=$tags{$commit}->[0]-", + substr($commit, 0, 12), "\n"; + print "TORBROWSER_SYMLINK_VERSION=0\n"; + exit 0; +} + +print STDERR "Could not find TORBROWSER version from tags\n"; +exit 1; diff --git a/gitian/hash-bundles.sh b/gitian/hash-bundles.sh index 2684158..37efdb1 100755 --- a/gitian/hash-bundles.sh +++ b/gitian/hash-bundles.sh @@ -14,10 +14,11 @@ if ! [ -e $VERSIONS_FILE ]; then fi
. $VERSIONS_FILE +eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
export LC_ALL=C
-cd $TORBROWSER_VERSION +cd $TORBROWSER_BUILDDIR rm -f sha256sums.txt sha256sums.incrementals.txt sha256sum `ls -1 | grep -v '.incremental.mar$' | sort` > sha256sums.txt if ls -1 | grep -q '.incremental.mar$' diff --git a/gitian/mkbundle-linux.sh b/gitian/mkbundle-linux.sh index 45f4f9b..4a773b8 100755 --- a/gitian/mkbundle-linux.sh +++ b/gitian/mkbundle-linux.sh @@ -16,6 +16,7 @@ if ! [ -e $VERSIONS_FILE ]; then fi
. $VERSIONS_FILE +eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
WRAPPER_DIR=$PWD GITIAN_DIR=$PWD/../../gitian-builder @@ -44,6 +45,7 @@ export PATH=$PATH:$PWD/libexec
echo "$TORBROWSER_VERSION" > $GITIAN_DIR/inputs/bare-version cp -a $WRAPPER_DIR/$VERSIONS_FILE $GITIAN_DIR/inputs/versions +echo "TORBROWSER_VERSION=$TORBROWSER_VERSION" >> $GITIAN_DIR/inputs/versions
cp -r $WRAPPER_DIR/build-helpers/* $GITIAN_DIR/inputs/ cp $WRAPPER_DIR/patches/* $GITIAN_DIR/inputs/ @@ -252,11 +254,11 @@ then exit 1 fi
- mkdir -p $WRAPPER_DIR/$TORBROWSER_VERSION/ - cp -a build/out/tor-browser-linux*xz* $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1 - cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1 - #cp -a inputs/mar-tools-linux*.zip $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1 - cp -a inputs/*debug.zip $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1 + mkdir -p $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ + cp -a build/out/tor-browser-linux*xz* $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1 + cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1 + #cp -a inputs/mar-tools-linux*.zip $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1 + cp -a inputs/*debug.zip $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1 touch inputs/bundle-linux.gbuilt else echo @@ -264,6 +266,12 @@ else echo fi
+cd $WRAPPER_DIR +if [ "$TORBROWSER_SYMLINK_VERSION" == '1' ] +then + ln -sf $TORBROWSER_BUILDDIR $TORBROWSER_VERSION +fi + echo echo "****** Linux Bundle complete ******" echo diff --git a/gitian/mkbundle-mac.sh b/gitian/mkbundle-mac.sh index 8a3aba6..ed54dc6 100755 --- a/gitian/mkbundle-mac.sh +++ b/gitian/mkbundle-mac.sh @@ -16,6 +16,7 @@ if ! [ -e $VERSIONS_FILE ]; then fi
. $VERSIONS_FILE +eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
WRAPPER_DIR=$PWD GITIAN_DIR=$PWD/../../gitian-builder @@ -44,6 +45,7 @@ export PATH=$PATH:$PWD/libexec
echo "$TORBROWSER_VERSION" > $GITIAN_DIR/inputs/bare-version cp -a $WRAPPER_DIR/$VERSIONS_FILE $GITIAN_DIR/inputs/versions +echo "TORBROWSER_VERSION=$TORBROWSER_VERSION" >> $GITIAN_DIR/inputs/versions
cp -r $WRAPPER_DIR/build-helpers/* $GITIAN_DIR/inputs/ cp $WRAPPER_DIR/patches/* $GITIAN_DIR/inputs/ @@ -219,8 +221,8 @@ then exit 1 fi
- mkdir -p $WRAPPER_DIR/$TORBROWSER_VERSION/ - cp -a build/out/* $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1 + mkdir -p $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ + cp -a build/out/* $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1 touch inputs/bundle-mac.gbuilt else echo @@ -228,6 +230,12 @@ else echo fi
+cd $WRAPPER_DIR +if [ "$TORBROWSER_SYMLINK_VERSION" == '1' ] +then + ln -sf $TORBROWSER_BUILDDIR $TORBROWSER_VERSION +fi + echo echo "****** Mac Bundle complete ******" echo diff --git a/gitian/mkbundle-windows.sh b/gitian/mkbundle-windows.sh index e950884..945511b 100755 --- a/gitian/mkbundle-windows.sh +++ b/gitian/mkbundle-windows.sh @@ -16,6 +16,7 @@ if ! [ -e $VERSIONS_FILE ]; then fi
. $VERSIONS_FILE +eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
WRAPPER_DIR=$PWD GITIAN_DIR=$PWD/../../gitian-builder @@ -44,6 +45,7 @@ export PATH=$PATH:$PWD/libexec
echo "$TORBROWSER_VERSION" > $GITIAN_DIR/inputs/bare-version cp -a $WRAPPER_DIR/$VERSIONS_FILE $GITIAN_DIR/inputs/versions +echo "TORBROWSER_VERSION=$TORBROWSER_VERSION" >> $GITIAN_DIR/inputs/versions
cp -r $WRAPPER_DIR/build-helpers/* $GITIAN_DIR/inputs/ cp $WRAPPER_DIR/patches/* $GITIAN_DIR/inputs/ @@ -222,10 +224,10 @@ then exit 1 fi
- mkdir -p $WRAPPER_DIR/$TORBROWSER_VERSION/ - cp -a build/out/*.exe $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1 - cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_VERSION/ || exit 1 - cp -a inputs/tor-win32-gbuilt.zip $WRAPPER_DIR/$TORBROWSER_VERSION/tor-win32-${TOR_TAG_ORIG:4}.zip || exit 1 + mkdir -p $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ + cp -a build/out/*.exe $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1 + cp -a build/out/*.mar $WRAPPER_DIR/$TORBROWSER_BUILDDIR/ || exit 1 + cp -a inputs/tor-win32-gbuilt.zip $WRAPPER_DIR/$TORBROWSER_BUILDDIR/tor-win32-${TOR_TAG_ORIG:4}.zip || exit 1 touch inputs/bundle-windows.gbuilt else echo @@ -233,6 +235,12 @@ else echo fi
+cd $WRAPPER_DIR +if [ "$TORBROWSER_SYMLINK_VERSION" == '1' ] +then + ln -sf $TORBROWSER_BUILDDIR $TORBROWSER_VERSION +fi + echo echo "****** Windows Bundle complete ******" echo diff --git a/gitian/upload-signature.sh b/gitian/upload-signature.sh index 58059aa..c403cd5 100755 --- a/gitian/upload-signature.sh +++ b/gitian/upload-signature.sh @@ -21,21 +21,22 @@ if ! [ -e $VERSIONS_FILE ]; then fi
. $VERSIONS_FILE +eval $(./get-tb-version $TORBROWSER_VERSION_TYPE)
-if [ ! -f $TORBROWSER_VERSION/sha256sums.txt.asc ]; +if [ ! -f $TORBROWSER_BUILDDIR/sha256sums.txt.asc ]; then - pushd $TORBROWSER_VERSION && gpg -abs sha256sums.txt + pushd $TORBROWSER_BUILDDIR && gpg -abs sha256sums.txt popd fi
-if [ -f $TORBROWSER_VERSION/sha256sums.incrementals.txt ] \ - && [ ! -f $TORBROWSER_VERSION/sha256sums.incrementals.txt.asc ] +if [ -f $TORBROWSER_BUILDDIR/sha256sums.incrementals.txt ] \ + && [ ! -f $TORBROWSER_BUILDDIR/sha256sums.incrementals.txt.asc ] then - pushd $TORBROWSER_VERSION && gpg -abs sha256sums.incrementals.txt + pushd $TORBROWSER_BUILDDIR && gpg -abs sha256sums.incrementals.txt popd fi
-ssh $HOST "mkdir -p $BASE_DIR/$TORBROWSER_VERSION" -scp $TORBROWSER_VERSION/sha256sums*.txt* $HOST:$BASE_DIR/$TORBROWSER_VERSION/ -ssh $HOST "chmod 755 $BASE_DIR/$TORBROWSER_VERSION && chmod 644 $BASE_DIR/$TORBROWSER_VERSION/*" +ssh $HOST "mkdir -p $BASE_DIR/$TORBROWSER_BUILDDIR" +scp $TORBROWSER_BUILDDIR/sha256sums*.txt* $HOST:$BASE_DIR/$TORBROWSER_BUILDDIR/ +ssh $HOST "chmod 755 $BASE_DIR/$TORBROWSER_BUILDDIR && chmod 644 $BASE_DIR/$TORBROWSER_BUILDDIR/*" diff --git a/gitian/versions b/gitian/versions index b6ec79f..36f315d 100755 --- a/gitian/versions +++ b/gitian/versions @@ -1,4 +1,4 @@ -TORBROWSER_VERSION=4.0.1 +TORBROWSER_VERSION_TYPE=release BUNDLE_LOCALES="ar de es-ES fa fr it ko nl pl pt-PT ru tr vi zh-CN" BUILD_PT_BUNDLES=1
diff --git a/gitian/versions.alpha b/gitian/versions.alpha index b84f92e..5306d6b 100755 --- a/gitian/versions.alpha +++ b/gitian/versions.alpha @@ -1,4 +1,4 @@ -TORBROWSER_VERSION=4.5-alpha-1 +TORBROWSER_VERSION_TYPE=alpha BUNDLE_LOCALES="ar de es-ES fa fr it ko nl pl pt-PT ru tr vi zh-CN" BUILD_PT_BUNDLES=1
diff --git a/gitian/versions.beta b/gitian/versions.beta index 29ba9e9..3678b37 100755 --- a/gitian/versions.beta +++ b/gitian/versions.beta @@ -1,4 +1,4 @@ -TORBROWSER_VERSION=3.6.1 +TORBROWSER_VERSION_TYPE=beta BUNDLE_LOCALES="ar de es-ES fa fr it ko nl pl pt-PT ru tr vi zh-CN" BUILD_PT_BUNDLES=1
diff --git a/gitian/versions.nightly b/gitian/versions.nightly index e6ea2a1..d812187 100755 --- a/gitian/versions.nightly +++ b/gitian/versions.nightly @@ -1,4 +1,7 @@ +TORBROWSER_VERSION_TYPE=nightly TORBROWSER_VERSION=tbb-nightly +TORBROWSER_BUILDDIR=tbb-nightly +TORBROWSER_SYMLINK_VERSION=0 BUNDLE_LOCALES="ar ru zh-CN" BUILD_PT_BUNDLES=1