Fix usage message to match expected arguments
[deb_libnfs.git] / packaging / RPM / makerpms.sh
CommitLineData
9f89cfcd
RS
1#!/bin/sh
2#
3# makerpms.sh - build RPM packages from the git sources
4#
5# Copyright (C) John H Terpstra 1998-2002
6# Copyright (C) Gerald (Jerry) Carter 2003
7# Copyright (C) Jim McDonough 2007
8# Copyright (C) Andrew Tridgell 2007
9# Copyright (C) Michael Adam 2008-2009
10#
11# This program is free software; you can redistribute it and/or modify it
12# under the terms of the GNU General Public License as published by the Free
13# Software Foundation; either version 3 of the License, or (at your option)
14# any later version.
15#
16# This program is distributed in the hope that it will be useful, but WITHOUT
17# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19# more details.
20#
21# You should have received a copy of the GNU General Public License along with
22# this program; if not, see <http://www.gnu.org/licenses/>.
23#
24
25#
26# The following allows environment variables to override the target directories
27# the alternative is to have a file in your home directory calles .rpmmacros
28# containing the following:
29# %_topdir /home/mylogin/redhat
30#
31# Note: Under this directory rpm expects to find the same directories that are under the
32# /usr/src/redhat directory
33#
34
35EXTRA_OPTIONS="$1"
36
37DIRNAME=$(dirname $0)
38TOPDIR=${DIRNAME}/../..
39
40SPECDIR=`rpm --eval %_specdir`
41SRCDIR=`rpm --eval %_sourcedir`
42
43SPECFILE="libnfs.spec"
44SPECFILE_IN="libnfs.spec.in"
45RPMBUILD="rpmbuild"
46
47# We use tags and determine the version, as follows:
48# libnfs-0.9.1 (First release of 0.9).
49# libnfs-0.9.23 (23rd minor release of the 112 version)
50#
51# If we're not directly on a tag, this is a devel release; we append
52# .0.<patchnum>.<checksum>.devel to the release.
53TAG=`git describe`
54case "$TAG" in
55 libnfs-*)
56 TAG=${TAG##libnfs-}
57 case "$TAG" in
58 *-*-g*) # 0.9-168-ge6cf0e8
59 # Not exactly on tag: devel version.
60 VERSION=`echo "$TAG" | sed 's/\([^-]\+\)-\([0-9]\+\)-\(g[0-9a-f]\+\)/\1.0.\2.\3.devel/'`
61 ;;
62 *)
63 # An actual release version
64 VERSION=$TAG
65 ;;
66 esac
67 ;;
68 *)
69 echo Invalid tag "$TAG" >&2
70 exit 1
71 ;;
72esac
73
74sed -e s/@VERSION@/$VERSION/g \
75 < ${DIRNAME}/${SPECFILE_IN} \
76 > ${DIRNAME}/${SPECFILE}
77
78VERSION=$(grep ^Version ${DIRNAME}/${SPECFILE} | sed -e 's/^Version:\ \+//')
79
80if echo | gzip -c --rsyncable - > /dev/null 2>&1 ; then
81 GZIP="gzip -9 --rsyncable"
82else
83 GZIP="gzip -9"
84fi
85
86pushd ${TOPDIR}
87echo -n "Creating libnfs-${VERSION}.tar.gz ... "
88git archive --prefix=libnfs-${VERSION}/ HEAD | ${GZIP} > ${SRCDIR}/libnfs-${VERSION}.tar.gz
89RC=$?
90popd
91echo "Done."
92if [ $RC -ne 0 ]; then
93 echo "Build failed!"
94 exit 1
95fi
96
97# At this point the SPECDIR and SRCDIR vaiables must have a value!
98
99##
100## copy additional source files
101##
102cp -p ${DIRNAME}/${SPECFILE} ${SPECDIR}
103
104##
105## Build
106##
107echo "$(basename $0): Getting Ready to build release package"
108${RPMBUILD} -ba --clean --rmsource ${EXTRA_OPTIONS} ${SPECDIR}/${SPECFILE} || exit 1
109
110echo "$(basename $0): Done."
111
112exit 0