summaryrefslogtreecommitdiff
path: root/rpm/build/native/build-from-cvs
blob: aa1319b962a1a28d9d3245aef6e79d98e57f6951 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/sh
#
# Copyright 2008, Elirion, Inc.  All rights reserved.
# This software is licensed under the same terms as Freeside itself.
#
# This script builds SRPMs if the Freeside CVS contents have changed.
# It must have reference copies of the Freeside versions it builds.
# Each SRPM's "release" is set to the date & time the script is run.
# The version number is forced to the CVS version.  The version and release
# hard-coded in the last .spec file committed to CVS are NOT used.
#
source $HOME/freeside-cvs
RELEASE=`date +%Y%m%d%H%M%S`
QUIET_FLAG=
#FORCE_FLAG=0
FORCE_FLAG=1
#VERSIONS='1.7 1.9'
VERSIONS='1.7'

while getopts "fhqv:" flag
do
        case $flag in
		f)
			echo "Force mode"
			FORCE_FLAG=1;;
		q)
			echo "Quiet mode"
			QUIET_FLAG=-q;;
		v)
			echo "Changing versions from $VERSIONS to $OPTARG"
			VERSIONS=$OPTARG;;
		*)
			usage;;
        esac
done

usage() {
	echo "build-from-cvs: build SRPMs if the Freeside CVS contents have changed"
	echo "where:"
	echo " -f: force building SRPMs even if CVS is unchanged"
	echo " -h: print this usage information"
	echo " -q: run quietly"
	echo " -v <versions>: change versions (currently: $VERSIONS)"
	exit 0
}

for VERSION in $VERSIONS; do
	echo ${VERSION}
	/bin/rm -rf ref-${VERSION}
	cp -pr freeside-${VERSION} ref-${VERSION}
	cd freeside-${VERSION}
	cvs update -d -P
	cd ..
	diff -qr --exclude=CVS freeside-${VERSION} ref-${VERSION}
	RETVAL=$?
	if [ $FORCE_FLAG = 1 -o $RETVAL -gt 0 ]; then
		# Build the tarball with the modified .spec file in it, hard-coding the release into the .spec file
		cd freeside-${VERSION}
		for SPECFILE in install/rpm/freeside.spec rpm/freeside.spec; do
		if [ -f $SPECFILE ]; then
			cp -pf $SPECFILE ..
			perl -p -i -e "s/\d+[^\}]+/${VERSION}/ if /%define\s+version\s+(\d+[^\}]+)\}/;" ${SPECFILE}
			perl -pi -e "s/\$1/${RELEASE}/ if /%define\s+release\s+(\d+)/;" $SPECFILE
			tar zcvf $HOME/redhat/SOURCES/freeside-${VERSION}.tar.gz --exclude CVS ../freeside-${VERSION}
			mv -f ../`basename $SPECFILE` `dirname $SPECFILE`
		fi
		done
		cd ..
		rpmbuild -ts $HOME/redhat/SOURCES/freeside-${VERSION}.tar.gz
		# Could do a koji-build here
		# Or move the SRPM to a staging directory for the build machine to check
		# Should make the Bundles and check the dependencies for changes
	fi
	/bin/rm -rf ref-${VERSION}
done