Skip to content
Snippets Groups Projects
Unverified Commit 28e1585a authored by boklm's avatar boklm
Browse files

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-1a98e3ef
    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.
parent 31349ad1
No related branches found
No related tags found
No related merge requests found
......@@ -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.asc || 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"
......
#!/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;
......@@ -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$'
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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/*"
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
......
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
......
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
......
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment