6 # 2 - no spec file name in cmdl parameters
7 # 3 - spec file not stored in repo
8 # 4 - some source, apatch or icon files not stored in repo
9 # 5 - build package no succed
12 Build package utility from PLD CVS repository
13 V 0.6 (C) 1999 Tomasz K³oczko".
15 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
23 CVSROOT=${CVSROOT:-""}
33 #---------------------------------------------
39 Usage: builder [-V] [--version] [-a] [--as_anon] [-b] [--build]
40 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
41 [-l <logfile>] [--logtofile <logfile>] [-q] [--quiet]
42 [-r <cvstag>] [--cvstag <cvstag>] [-v] [--verbose]
45 -V, --version - output builder version
46 -a, --as_anon - get files via pserver as cvs@cvs.pld.org.pl,
47 -b, --build - get all files from CVS repo and build
48 package from <package>.spec,
49 -c, --clean - clean all temporary maked files (in BUILD,
50 SOURCES, SPECS and $RPM_BUILD_ROOT),
51 -d, --cvsroot - setup \$CVSROOT,
52 -g, --get - get <package>.spec and all relayted files from
54 -h, --help - this message,
55 -l, --logtofile - log all to file,
56 -q, --quiet - be quiet,
57 -r, --cvstag - build package using resources from specified CVS
59 -v, --verbose - be verbose,
66 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i Icon > $SPECFILE.__
68 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCE[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
69 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCH[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
70 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE} |sed -e 's#.*/##g'`"
71 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
72 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
73 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
77 if [ -n "$BE_VERBOSE" ]; then
78 echo "- Sources : $SOURCES"
79 echo "- Patches : $PATCHES"
80 if [ -n "$ICONS" ]; then
81 echo "- Icon : $ICONS"
83 echo "- Icon : *no package icon*"
85 echo "- Name : $PACKAGE_NAME"
86 echo "- Version : $PACKAGE_VERSION"
87 echo "- Release : $PACKAGE_RELEASE"
96 "err_no_spec_in_cmdl" )
97 echo "ERROR: spec file name not specified.";
99 "err_no_spec_in_repo" )
100 echo "Error: spec file not stored in CVS repo.";
102 "err_no_source_in_repo" )
103 echo "Error: some source, apatch or icon files not stored in CVS repo.";
106 echo "Error: package build failed.";
113 DUMB_SPEC_FILE=`mktemp -q /tmp/bilder.XXXXXX`
124 echo SOURCE_DIR=%{_sourcedir}
125 echo SPECS_DIR=%{_specdir}" > $DUMB_SPEC_FILE
127 SOURCE_DIR=`rpm -bp $DUMB_SPEC_FILE 2>&1 | grep "^SOURCE_DIR" | sed "s/SOURCE_DIR\=//"`
128 SPECS_DIR=`rpm -bp $DUMB_SPEC_FILE 2>&1 | grep "^SPECS_DIR" |sed "s/SPECS_DIR\=//"`
130 rm -f $DUMB_SPEC_FILE
141 if [ -n "$CVSROOT" ]; then
142 OPTIONS="-d $CVSROOT"
144 if [ -n "$CVSTAG" ]; then
145 OPTIONS="$OPTIONS -r $CVSTAG"
147 OPTIONS="$OPTIONS -P"
150 cvs $OPTIONS $SPECFILE
151 if [ "$?" -ne "0" ]; then
152 Exit_error err_no_spec_in_repo;
162 if [ -n "$SOURCES$PATCHES$ICONS" ]; then
166 if [ -n "$CVSROOT" ]; then
167 OPTIONS="-d $CVSROOT"
169 if [ -n "$CVSTAG" ]; then
170 OPTIONS="$OPTIONS -r $CVSTAG"
172 OPTIONS="$OPTIONS -P"
175 cvs $OPTIONS $SOURCES $PATCHES $ICONS
176 if [ "$?" -ne "0" ]; then
177 Exit_error err_no_source_in_repo;
180 chmod 444 $SOURCES $PATCHES $ICONS
188 rpm -ba -v $QUIET $CLEAN $SPECFILE
190 if [ "$?" -ne "0" ]; then
191 Exit_error err_build_fail;
196 #---------------------------------------------
199 if [ "$#" == 0 ]; then
204 while test $# -gt 0 ; do
207 COMMAND="version"; shift ;;
209 CVSROOT=":pserver:cvs@cvs.pld.org.pl:/cvsroot"; shift ;;
211 COMMAND="build"; shift ;;
213 CLEAN="--clean --rmspec --rmsource"; shift ;;
215 shift; CVSROOT="${1}"; shift ;;
217 COMMAND="get"; shift ;;
219 COMMAND="usage"; shift ;;
221 shift; LOGFILE="${1}"; shift ;;
223 QUIET="--quiet"; shift ;;
225 shift; CVSTAG="${1}"; shift ;;
227 BE_VERBOSE="1"; shift ;;
229 SPECFILE="${1}"; shift ;;
236 if [ -n "$SPECFILE" ]; then
242 Exit_error err_no_spec_in_cmdl;
247 if [ -n "$SPECFILE" ]; then
252 Exit_error err_no_spec_in_cmdl;