]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/ofed/management/make.dist
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / ofed / management / make.dist
1 #!/bin/bash
2
3 TMPDIR=`pwd`/dist
4 if [ ! -d $TMPDIR ]; then mkdir $TMPDIR; fi
5
6 usage() {
7 echo "$0 daily | release [ signed | <key-id> ]"
8 echo
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."
16 echo
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."
20 echo
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"
28 echo "around."
29 echo
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"
34 echo "clean."
35 echo
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."
39 echo
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."
47 echo
48 }
49
50 if [ -z "$1" ]; then usage; exit 1; fi
51
52 if [ "$1" != "daily" -a "$1" != "release" ]; then usage; exit 1; fi
53
54 if [ -z "$TARGETS" ]; then
55         TARGETS="libibcommon libibumad libibmad opensm infiniband-diags"
56 fi
57
58 # Is the repo clean?
59 git diff-index --quiet HEAD -- $package > /dev/null 2>&1
60 if [ $? -ne 0 ]; then
61         echo "Git tree is dirty.  Please commit or undo any changes before proceeding."
62         exit 4
63 fi
64
65 # make sure we are on the right branch
66 git branch
67 echo -n "Is the active branch the right one to tag this release on [y/N]? "
68 read answer
69 if [ "$answer" = y -o "$answer" = Y ]; then
70         echo "Proceeding..."
71 else
72         echo "Please check out the right branch and run make.dist again"
73         exit 0
74 fi
75
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"
83                         exit 2
84                 fi
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."
88                         exit 3
89                 fi
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.
93                 RELEASE=1
94                 echo $RELEASE > $TMPDIR/$target.release
95
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
99                         else
100                                 git tag -u "$2" -m "Auto tag by make.dist on release tarball creation" $target-$VERSION
101                         fi
102                 elif [ $1 = "release" ]; then
103                         git tag -a -m "Auto tag by make.dist on release tarball creation" $target-$VERSION
104                 fi
105         elif [ "$1" = "daily" ]; then
106                 DATE=`date +%Y%m%d`
107                 git_rev=`./gen_ver.sh $target | sed -e 's/^'$VERSION'_//'`
108                 if [ "$git_rev" = "$VERSION" ] ; then
109                         VERSION=${VERSION}_${DATE}
110                 else
111                         VERSION=${VERSION}_${DATE}_${git_rev}
112                 fi
113                 if [ -f $TMPDIR/$target.gitrev ]; then
114                         old_rev=`cat $TMPDIR/$target.gitrev`
115                 fi
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)"
119                         continue
120                 fi
121                 if [ -f $TMPDIR/$target.release ]; then
122                         RELEASE=`cat $TMPDIR/$target.release`
123                         RELEASE=`expr $RELEASE + 1`
124                 else
125                         RELEASE=1
126                 fi
127                 echo $RELEASE > $TMPDIR/$target.release
128                 RELEASE=0.${RELEASE}
129                 cat $target/configure.in \
130                   | sed -e '/AC_INIT/s/'$target', .*,/'$target', '$VERSION',/' \
131                   > configure.in.new
132                 diff $target/configure.in configure.in.new > /dev/null \
133                   || cat configure.in.new > $target/configure.in
134         fi
135
136         TARBALL=$target-$VERSION.tar.gz
137
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 ) ||
142         exit $?
143         git checkout $target/configure.in
144 done