3 # Copyright 2008, Elirion, Inc. All rights reserved.
4 # This software is licensed under the same terms as Freeside itself.
6 # This script builds SRPMs if the Freeside CVS contents have changed.
7 # It must have reference copies of the Freeside versions it builds.
8 # Each SRPM's "release" is set to the date & time the script is run.
9 # The version number is forced to the CVS version. The version and release
10 # hard-coded in the last .spec file committed to CVS are NOT used.
12 source $HOME/freeside-cvs
13 RELEASE=`date +%Y%m%d%H%M%S`
20 while getopts "fhqv:" flag
30 echo "Changing versions from $VERSIONS to $OPTARG"
38 echo "build-from-cvs: build SRPMs if the Freeside CVS contents have changed"
40 echo " -f: force building SRPMs even if CVS is unchanged"
41 echo " -h: print this usage information"
42 echo " -q: run quietly"
43 echo " -v <versions>: change versions (currently: $VERSIONS)"
47 for VERSION in $VERSIONS; do
49 /bin/rm -rf ref-${VERSION}
50 cp -pr freeside-${VERSION} ref-${VERSION}
51 cd freeside-${VERSION}
54 diff -qr --exclude=CVS freeside-${VERSION} ref-${VERSION}
56 if [ $FORCE_FLAG = 1 -o $RETVAL -gt 0 ]; then
57 # Build the tarball with the modified .spec file in it, hard-coding the release into the .spec file
58 cd freeside-${VERSION}
59 for SPECFILE in install/rpm/freeside.spec rpm/freeside.spec; do
60 if [ -f $SPECFILE ]; then
62 perl -p -i -e "s/\d+[^\}]+/${VERSION}/ if /%define\s+version\s+(\d+[^\}]+)\}/;" ${SPECFILE}
63 perl -pi -e "s/\$1/${RELEASE}/ if /%define\s+release\s+(\d+)/;" $SPECFILE
64 tar zcvf $HOME/redhat/SOURCES/freeside-${VERSION}.tar.gz --exclude CVS ../freeside-${VERSION}
65 mv -f ../`basename $SPECFILE` `dirname $SPECFILE`
69 rpmbuild -ts $HOME/redhat/SOURCES/freeside-${VERSION}.tar.gz
70 # Could do a koji-build here
71 # Or move the SRPM to a staging directory for the build machine to check
72 # Should make the Bundles and check the dependencies for changes
74 /bin/rm -rf ref-${VERSION}