4 if [ ! -d $TMPDIR ]; then mkdir $TMPDIR; fi
7 echo "$0 daily | release [ signed | <key-id> ]"
9 echo " You must specify either release or daily in order for this script"
10 echo "to make tarballs. If this is a daily release, the tarballs will"
11 echo "be named <component>-git.tar.gz and will overwrite existing tarballs."
12 echo "If this is a release build, then the tarball will be named"
13 echo "<component>-<version>.tar.gz and must be a new file. In addition,"
14 echo "the script will add a new set of symbolic tags to the git repo"
15 echo "that correspond to the <component>-<version> of each tarball."
17 echo " If the TARGETS environment variable is not NULL, then it is taken"
18 echo "as the list of components in the management tree that should be"
19 echo "included in this release. If it's NULL, then do all the components."
21 echo " If the script detects that the tag on any component already exists,"
22 echo "it will abort the release and prompt you to update the version on"
23 echo "the already tagged component. This enforces the proper behavior of"
24 echo "treating any released tarball as set in stone so that in the future"
25 echo "you will always be able to get to any given release tarball by"
26 echo "checking out the git tag and know with certainty that it is the same"
27 echo "code as released before even if you no longer have the same tarball"
30 echo " As part of this process, the script will parse the <target>.spec.in"
31 echo "file and output a <target>.spec file. Since this script isn't smart"
32 echo "enough to deal with other random changes that should have their own"
33 echo "checkin the script will refuse to run if the current repo state is not"
36 echo " NOTE: the script has no clue if you are tagging on the right branch,"
37 echo "it will however show you the git branch output so you can confirm it"
38 echo "is on the right branch before proceeding with the release."
40 echo " In addition to just tagging the git repo, whenever creating a release"
41 echo "there is an optional argument of either signed or a hex gpg key-id."
42 echo "If you do not pass an argument to release, then the tag will be a"
43 echo "simple git annotated tag. If you pass signed as the argument, the"
44 echo "git tag operation will use your default signing key to sign the tag."
45 echo "Or you can pass an actual gpg key id in hex format and git will sign"
46 echo "the tag with that key."
50 if [ -z "$1" ]; then usage; exit 1; fi
52 if [ "$1" != "daily" -a "$1" != "release" ]; then usage; exit 1; fi
54 if [ -z "$TARGETS" ]; then
55 TARGETS="libibcommon libibumad libibmad opensm infiniband-diags"
59 git diff-index --quiet HEAD -- $package > /dev/null 2>&1
61 echo "Git tree is dirty. Please commit or undo any changes before proceeding."
65 # make sure we are on the right branch
67 echo -n "Is the active branch the right one to tag this release on [y/N]? "
69 if [ "$answer" = y -o "$answer" = Y ]; then
72 echo "Please check out the right branch and run make.dist again"
76 for target in $TARGETS; do
77 VERSION=`grep "AC_INIT.*$target" $target/configure.in | cut -f 2 -d ',' | sed -e 's/ //g'`
78 if [ "$1" = "release" ]; then
79 # Check versions to make sure that we can proceed
80 if [ -f $TMPDIR/$target-$VERSION.tar.gz ]; then
81 echo "Target $target-$VERSION.tar.gz already exists, please update the version on"
82 echo "component $target"
85 if [ ! -z "`git tag -l $target-$VERSION`" ]; then
86 echo "A git tag already exists for $target-$VERSION. Please change the version"
87 echo "of $target so a tag replacement won't occur."
90 # On a real release, this resets the daily release starting point, on the
91 # assumption that any new daily builds will have a version number that is
92 # incrementally higher than the last officially released tarball.
94 echo $RELEASE > $TMPDIR/$target.release
96 if [ ! -z "$2" ]; then
97 if [ $2 = "signed" ]; then
98 git tag -s -m "Auto tag by make.dist on release tarball creation" $target-$VERSION
100 git tag -u "$2" -m "Auto tag by make.dist on release tarball creation" $target-$VERSION
102 elif [ $1 = "release" ]; then
103 git tag -a -m "Auto tag by make.dist on release tarball creation" $target-$VERSION
105 elif [ "$1" = "daily" ]; then
107 git_rev=`./gen_ver.sh $target | sed -e 's/^'$VERSION'_//'`
108 if [ "$git_rev" = "$VERSION" ] ; then
109 VERSION=${VERSION}_${DATE}
111 VERSION=${VERSION}_${DATE}_${git_rev}
113 if [ -f $TMPDIR/$target.gitrev ]; then
114 old_rev=`cat $TMPDIR/$target.gitrev`
116 echo $git_rev > $TMPDIR/$target.gitrev
117 if [ "$old_rev" = "$git_rev" ] ; then
118 echo "No daily build is needed for '$target' ($git_rev)"
121 if [ -f $TMPDIR/$target.release ]; then
122 RELEASE=`cat $TMPDIR/$target.release`
123 RELEASE=`expr $RELEASE + 1`
127 echo $RELEASE > $TMPDIR/$target.release
129 cat $target/configure.in \
130 | sed -e '/AC_INIT/s/'$target', .*,/'$target', '$VERSION',/' \
132 diff $target/configure.in configure.in.new > /dev/null \
133 || cat configure.in.new > $target/configure.in
136 TARBALL=$target-$VERSION.tar.gz
138 echo "Creating $TMPDIR/$TARBALL"
139 ( export RELEASE=$RELEASE && export TARBALL=$TARBALL &&
140 cd $target && ./autogen.sh && ./configure &&
141 make dist && mv $target-$VERSION.tar.gz $TMPDIR/$TARBALL ) ||
143 git checkout $target/configure.in