7 # 2 - no spec file name in cmdl parameters
8 # 3 - spec file not stored in repo
9 # 4 - some source, apatch or icon files not stored in repo
10 # 5 - build package no succed
13 Build package utility from PLD CVS repository
14 V 0.8 (C) 1999 Tomasz K³oczko".
16 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
28 CVSROOT=${CVSROOT:-""}
42 GETURI="wget -c -nd -t0"
44 if [ -f ~/etc/builderrc ]; then
46 elif [ -f ~/.builderrc ]; then
50 #---------------------------------------------
55 if [ -n "$DEBUG" ]; then set -xv; fi
57 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
58 [--build] [-bb] [--build-binary] [-bs] [--build-source]
59 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
60 [-l <logfile>] [-m] [--mr-proper] [--logtofile <logfile>] [-q] [--quiet]
61 [-r <cvstag>] [--cvstag <cvstag>] [-u] [--no-urls] [-v] [--verbose]
62 [--opts <rpm opts>] <package>.spec
64 -D, --debug - enable script debugging mode,
65 -V, --version - output builder version
66 -a, --as_anon - get files via pserver as cvs@anoncvs.pld.org.pl,
68 --build - get all files from CVS repo or HTTP/FTP and build
69 package from <package>.spec,
71 --build-binary - get all files from CVS repo or HTTP/FTP and build
72 binary only package from <package>.spec,
74 --build-source - get all files from CVS repo or HTTP/FTP and only
75 pack them into src.rpm,
76 -c, --clean - clean all temporarily created files (in BUILD,
77 SOURCES, SPECS and \$RPM_BUILD_ROOT),
78 SOURCES, SPECS and \$RPM_BUILD_ROOT),
79 -d, --cvsroot - setup \$CVSROOT,
80 -g, --get - get <package>.spec and all related files from
82 -h, --help - this message,
83 -l, --logtofile - log all to file,
84 -m, --mr-proper - only remove all files related to spec file and
86 -nc, --no-cvs - don't download from CVS, if source URL is given,
87 -nu, --no-urls - don't try to download from FTP/HTTP location,
88 --opts - additional options for rpm
89 -q, --quiet - be quiet,
90 -r, --cvstag - build package using resources from specified CVS
92 -v, --verbose - be verbose,
99 if [ -n "$DEBUG" ]; then
104 SOURCES="`rpm -bp --nobuild --define "__spec_prep_pre %{dump}" $SPECFILE 2>&1 | awk '/ SOURCEURL[0-9]+/ {print $3}'`"
105 PATCHES="`rpm -bp --nobuild --define "__spec_prep_pre %{dump}" $SPECFILE 2>&1 | awk '/ PATCHURL[0-9]+/ {print $3}'`"
106 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
107 PACKAGE_NAME="`rpm -bp --nobuild --define "__spec_prep_pre %{dump}" $SPECFILE 2>&1 | awk '/ name/ {print $3}'`"
108 PACKAGE_VERSION="`rpm -bp --nobuild --define "__spec_prep_pre %{dump}" $SPECFILE 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
109 PACKAGE_RELEASE="`rpm -bp --nobuild --define "__spec_prep_pre %{dump}" $SPECFILE 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
111 if [ -n "$BE_VERBOSE" ]; then
112 echo "- Sources : `nourl $SOURCES`"
113 if [ -n "$PATCHES" ]; then
114 echo "- Patches : `nourl $PATCHES`"
116 echo "- Patches : *no patches needed*"
118 if [ -n "$ICONS" ]; then
119 echo "- Icon : `nourl $ICONS`"
121 echo "- Icon : *no package icon*"
123 echo "- Name : $PACKAGE_NAME"
124 echo "- Version : $PACKAGE_VERSION"
125 echo "- Release : $PACKAGE_RELEASE"
131 if [ -n "$DEBUG" ]; then
139 "err_no_spec_in_cmdl" )
140 echo "ERROR: spec file name not specified.";
142 "err_no_spec_in_repo" )
143 echo "Error: spec file not stored in CVS repo.";
145 "err_no_source_in_repo" )
146 echo "Error: some source, patch or icon files not stored in CVS repo.";
149 echo "Error: package build failed.";
156 if [ -n "$DEBUG" ]; then
161 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
162 SPECS_DIR="`rpm --eval "%{_specdir}"`"
169 if [ -n "$DEBUG" ]; then
178 if [ -n "$CVSROOT" ]; then
179 OPTIONS="-d $CVSROOT $OPTIONS"
181 if [ -n "$CVSTAG" ]; then
182 OPTIONS="$OPTIONS -r $CVSTAG"
184 OPTIONS="$OPTIONS -A"
187 cvs $OPTIONS $SPECFILE
188 if [ "$?" -ne "0" ]; then
189 Exit_error err_no_spec_in_repo;
191 if [ ! -f "$SPECFILE" ]; then
192 Exit_error err_no_spec_in_repo;
195 if [ "$CHMOD" = "yes" ]; then
203 if [ -n "$DEBUG" ]; then
208 if [ -n "$SOURCES$PATCHES$ICONS" ]; then
212 if [ -n "$CVSROOT" ]; then
213 OPTIONS="-d $CVSROOT $OPTIONS"
215 if [ -n "$CVSTAG" ]; then
216 OPTIONS="$OPTIONS -r $CVSTAG"
218 OPTIONS="$OPTIONS -A"
220 for i in $SOURCES $PATCHES $ICONS; do
221 if [ ! -f `nourl $i` ] || [ $ALLWAYS_CVSUP = "yes" ]
224 echo $i | grep -vE '(http|ftp|https|cvs)://' |\
225 grep -qE '\.(gz|bz2)$'
227 echo "Warning: no URL given for $i"
230 if [ -z "$NOCVS" ]||\
231 [ `echo $i | grep -vE '(ftp|http|https)://'` ]
233 cvs $OPTIONS `nourl $i`
236 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
237 [ `echo $i | grep -E 'ftp://|http://|https://'` ]
242 if [ ! -f "`nourl $i`" ]; then
243 Exit_error err_no_source_in_repo;
248 if [ "$CHMOD" = "yes" ]; then
249 chmod 444 `nourl $SOURCES $PATCHES $ICONS`
257 if [ -n "$DEBUG" ]; then
265 BUILD_SWITCH="-ba" ;;
267 BUILD_SWITCH="-bb" ;;
269 BUILD_SWITCH="-bs --nodeps" ;;
271 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $SPECFILE
273 if [ "$?" -ne "0" ]; then
274 Exit_error err_build_fail;
281 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
283 #---------------------------------------------
286 if [ "$#" = 0 ]; then
291 while test $# -gt 0 ; do
294 DEBUG="yes"; shift ;;
296 COMMAND="version"; shift ;;
298 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
300 COMMAND="build"; shift ;;
301 -bb | --build-binary )
302 COMMAND="build-binary"; shift ;;
303 -bs | --build-source )
304 COMMAND="build-source"; shift ;;
306 CLEAN="--clean --rmspec --rmsource"; shift ;;
308 shift; CVSROOT="${1}"; shift ;;
310 COMMAND="get"; shift ;;
312 COMMAND="usage"; shift ;;
314 shift; LOGFILE="${1}"; shift ;;
316 shift; DEF_NICE_LEVEL=${1}; shift ;;
318 COMMAND="mr-proper"; shift ;;
320 NOCVS="yes"; shift ;;
322 NOURLS="yes"; shift ;;
324 shift; RPMOPTS="${1}"; shift ;;
326 QUIET="--quiet"; shift ;;
328 shift; CVSTAG="${1}"; shift ;;
330 BE_VERBOSE="1"; shift ;;
332 SPECFILE="${1}"; shift ;;
336 if [ -n "$DEBUG" ]; then
342 "build" | "build-binary" | "build-source" )
344 if [ -n "$SPECFILE" ]; then
350 Exit_error err_no_spec_in_cmdl;
355 if [ -n "$SPECFILE" ]; then
360 Exit_error err_no_spec_in_cmdl;
364 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE