1#!/bin/sh
2
3# This script makes a release from a git repository. The input is
4# the number for a snapshot and the path to a temporary directory.
5# for example:
6#
7#    sh scripts/MAKE_RELEASE.sh 11.0 ~/tmp
8#
9# The above assumes that there is a tag "v11_0" at the point
10# to be released. (The tag has the "v", but the argument to this
11# script does not have the "v"). This script extracts based on the
12# tag, uses the temporary directory to stage intermediate results,
13# and finally creates a file called verilog-11.0.tar.gz that
14# contains the release ready to go.
15#
16# The complete steps to make a release x.y generally are:
17#
18#   Edit version_base.h to suit.
19#
20#   Edit verilog.spec to suit.
21#
22#   git tag -a v11_0
23#                 (Make the tag in the local git repository.)
24#
25#   sh scripts/MAKE_RELEASE.sh 11.0 ~/tmp
26#                 (Make the snapshot bundle verilog-11.0.tar.gz)
27#
28#   git push --tags
29#                 (Publish the tag to the repository.)
30#
31id=$1
32destdir=$2
33
34# The git tag to use.
35tag="v"`echo $id | tr '.' '_'`
36
37# The prefix is the directory that contains the extracted files
38# of the bundle. This is also the name of the bundle file itself.
39prefix="verilog-$id"
40
41if [ ! -d $destdir ]; then
42    echo "ERROR: Directory $destdir does not exist."
43    exit 1
44fi
45
46if [ -e $destdir/$prefix ]; then
47    echo "ERROR: $destdir/$prefix already exists."
48    exit 1
49fi
50
51echo "Exporting $tag to $destdir/$prefix..."
52git archive --prefix="$prefix/" $tag | ( cd "$destdir" && tar xf - )
53
54versionh="$destdir/$prefix/version_tag.h"
55echo "Create $versionh ..."
56echo "#ifndef VERSION_TAG" > $versionh
57echo "#define VERSION_TAG \"$tag\"" >> $versionh
58echo "#endif" >> $versionh
59
60echo "Running autoconf.sh..."
61( cd $destdir/$prefix && sh autoconf.sh )
62
63echo "Making bundle $prefix.tar.gz..."
64tar czf $prefix.tar.gz --exclude=autom4te.cache -C "$destdir" $prefix
65
66echo "Removing temporary $destdir/$prefix..."
67rm -rf "$destdir/$prefix"
68
69echo done
70