[r13118]: trunk / rosegarden / scripts / make-release-tarball Maximize Restore History

Download this file

make-release-tarball    138 lines (104 with data), 4.3 kB

#!/bin/bash
#
# make-release-tarball
#
# Copyright (c) 2009  D. Michael McIntyre <rosegarden.trumpeter@gmail.com>
# Released under the GPL
#
# REQUIRES: 
#
#
# PURPOSE:
#
#
#

myname=$(basename $0)
target=$1

usage() {
    cat << EOF
Usage: $myname [TARGET]

Must run from a valid rosegarden/ directory.  Examines the current directory to
determine where it resides in the Subversion repository (typically
branches/stable_YY_MM for release candidates) and pulls a clean copy from there.
Bootstraps the fresh checkout and performs some preparatory cleanups, then
leaves rosegarden-[VERSION]-[TARGET].tar.bz2 ready for release.

VERSION - extracted from source

TARGET  - assumes that configure.ac already has the correct version in the
          AC_INIT call and the codename has been set on the CODENAME= line; use
          the target "RELEASE" for a final release or a release candidate (as
          opposed to an alpha, beta, pre, etc.)

Example: $myname alpha-2
EOF
    exit 1
}

puke() {
    echo $1
    exit 2
}

[ -z "$target" ] && usage

[ -d "src" ] || puke "$myname must be run from a top level directory!"
[ -f "configure.ac" ] || puke "No configure.ac!  Is this a top level directory?"
[ -d ".svn" ] || puke "No .svn directory.  Is this a development tree?"

VERSION=$(grep AC_INIT configure.ac|cut -d \, -f 2|sed 's/ //g')

URL=
for v in $(grep http .svn/entries); do
    # The only way I can find to determine what branch we're sitting in is to
    # look at the first return of "grep http" in .svn/entries, discarding all
    # subsequent returns.  This might not actually work in other situations, but
    # the pattern is appropriate for all the trees I happen to have available.
    if [ -z "$URL" ]; then
        URL=$v; 
    fi
done

# insert $TARGET for alpha, beta, pre, etc. releases, otherwise use $VERSION
# straight up
NEW_VERSION=$VERSION
[ "$target" != "RELEASE" ] && NEW_VERSION="$VERSION-$target"

outDir="rosegarden-$NEW_VERSION"
[ -d "$outDir" ] && puke "$outDir already exists!  Aborting!"

echo "Checking out a clean copy of $URL (this will take some time)..."
svn co $URL $outDir > /dev/null || puke "Unable to check out $URL!"

cd $outDir || puke "Unable to change to $outDir!"

echo "Rewriting version from $VERSION to $NEW_VERSION in configure.ac..."
# NOTE: . is a regex wildcard, but it does match a simple . so I've elected not
# to bother with some hackery to escape it to \. here
sed "s/$VERSION/$NEW_VERSION/" configure.ac > foo42 && mv foo42 configure.ac

# only set this if this is a final release
if [ "$target" == "RELEASE" ]; then
    sed "s/UNSTABLE/STABLE/" Makefile.in > foo42 && mv foo42 Makefile.in
fi

echo "Purging unwanted files..."
# templates/ and test/ are of no value to people doing an end use build
rm -rf templates test

# attic/ will be disappearing before the real release, but if it still exists,
# remove it
[ -d "attic" ] && rm -rf attic

# remove all the .svn directories and their contents 
find . -name \.svn|xargs rm -rf

echo "Bootstrapping..."
sh ./bootstrap.sh || "Bootstrapping failed!"

cat > CONTRIBUTING << EOF
This source tree is a release version that has been stripped of version-control
information in order to reduce its size.  If you wish to submit a patch to fix a
bug or add a new feature, PLEASE do not begin working from this directory!

It is very difficult to use patches built against a release source tree, and we
have had to reject some otherwise excellent patches due to their being built
against a release tree so old and so far removed from the current development
line that it was almost impossible to do anything with them.

Please don't let this happen to you.  To learn about the recommended way to
contribute patches, please see:

http://rosegardenmusic.com/wiki/dev:contributing
EOF

rm -f README.DEVELOPERS


cd ..

outFile="$outDir.tar.bz2"
echo "Assembling $outFile..."
tar cjf $outFile $outDir || puke "Making tarball failed!"

echo "Cleaning up..."
rm -rf $outDir

# deal with tagging later, but it will be nice to automate this
# read -p "Do you want to tag this release?"
# "copied from trunk/rosegarden to tags/rosegarden-1.7.1-rc1"

# hack around my personal umask, to ensure files are world readable if I forget
chmod 644 $outFile

exit 0