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.9 (C) 1999-2001 Tomasz K³oczko".
16 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
28 CVSROOT=${CVSROOT:-""}
42 FAIL_IF_NO_SOURCES="yes"
44 GETURI="wget -c -nd -t0"
46 if [ -f ~/etc/builderrc ]; then
48 elif [ -f ~/.builderrc ]; then
52 #---------------------------------------------
57 if [ -n "$DEBUG" ]; then set -xv; fi
59 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
60 [--build] [-bb] [--build-binary] [-bs] [--build-source]
61 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
62 [-l <logfile>] [-m] [--mr-proper] [--logtofile <logfile>] [-q] [--quiet]
63 [-r <cvstag>] [--cvstag <cvstag>] [-u] [--no-urls] [-v] [--verbose]
64 [--opts <rpm opts>] <package>.spec
66 -D, --debug - enable script debugging mode,
67 -V, --version - output builder version
68 -a, --as_anon - get files via pserver as cvs@anoncvs.pld.org.pl,
70 --build - get all files from CVS repo or HTTP/FTP and build
71 package from <package>.spec,
73 --build-binary - get all files from CVS repo or HTTP/FTP and build
74 binary only package from <package>.spec,
76 --build-source - get all files from CVS repo or HTTP/FTP and only
77 pack them into src.rpm,
78 -c, --clean - clean all temporarily created files (in BUILD,
79 SOURCES, SPECS and \$RPM_BUILD_ROOT),
80 SOURCES, SPECS and \$RPM_BUILD_ROOT),
81 -d, --cvsroot - setup \$CVSROOT,
82 -g, --get - get <package>.spec and all related files from
84 -h, --help - this message,
85 -l, --logtofile - log all to file,
86 -m, --mr-proper - only remove all files related to spec file and
88 -nc, --no-cvs - don't download from CVS, if source URL is given,
89 -nu, --no-urls - don't try to download from FTP/HTTP location,
90 -ns, --no-srcs - don't downland Sources
91 --opts - additional options for rpm
92 -q, --quiet - be quiet,
93 -r, --cvstag - build package using resources from specified CVS
95 -T, --tag - add cvs tags for files,
96 -v, --verbose - be verbose,
103 if [ -n "$DEBUG" ]; then
110 if [ "$NOSRCS" != "yes" ]; then
111 SOURCES="`rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | awk '/SOURCEURL[0-9]+/ {print $3}'`"
113 if (rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | grep -qEi ":.*nosource.*1"); then
114 FAIL_IF_NO_SOURCES="no"
118 PATCHES="`rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | awk '/PATCHURL[0-9]+/ {print $3}'`"
119 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
120 PACKAGE_NAME="`rpm -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
121 PACKAGE_VERSION="`rpm -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
122 PACKAGE_RELEASE="`rpm -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
124 if [ -n "$BE_VERBOSE" ]; then
125 echo "- Sources : `nourl $SOURCES`"
126 if [ -n "$PATCHES" ]; then
127 echo "- Patches : `nourl $PATCHES`"
129 echo "- Patches : *no patches needed*"
131 if [ -n "$ICONS" ]; then
132 echo "- Icon : `nourl $ICONS`"
134 echo "- Icon : *no package icon*"
136 echo "- Name : $PACKAGE_NAME"
137 echo "- Version : $PACKAGE_VERSION"
138 echo "- Release : $PACKAGE_RELEASE"
144 if [ -n "$DEBUG" ]; then
152 "err_no_spec_in_cmdl" )
153 echo "ERROR: spec file name not specified.";
155 "err_no_spec_in_repo" )
156 echo "Error: spec file not stored in CVS repo.";
158 "err_no_source_in_repo" )
159 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
162 echo "Error: package build failed.";
169 if [ -n "$DEBUG" ]; then
174 SOURCE_DIR="`rpm --eval '%{_sourcedir}'`"
175 SPECS_DIR="`rpm --eval '%{_specdir}'`"
182 if [ -n "$DEBUG" ]; then
191 if [ -n "$CVSROOT" ]; then
192 OPTIONS="-d $CVSROOT $OPTIONS"
194 if [ -n "$CVSTAG" ]; then
195 OPTIONS="$OPTIONS -r $CVSTAG"
197 OPTIONS="$OPTIONS -A"
200 cvs $OPTIONS $SPECFILE
201 if [ "$?" -ne "0" ]; then
202 Exit_error err_no_spec_in_repo;
204 if [ ! -f "$SPECFILE" ]; then
205 Exit_error err_no_spec_in_repo;
208 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
218 if [ -n "$DEBUG" ]; then
223 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
227 if [ -n "$CVSROOT" ]; then
228 OPTIONS="-d $CVSROOT $OPTIONS"
230 if [ -n "$CVSTAG" ]; then
231 OPTIONS="$OPTIONS -r $CVSTAG"
233 OPTIONS="$OPTIONS -A"
235 for i in $GET_FILES; do
236 if [ ! -f `nourl $i` ] || [ $ALLWAYS_CVSUP = "yes" ]
239 echo $i | grep -vE '(http|ftp|https|cvs)://' |\
240 grep -qE '\.(gz|bz2)$'
242 echo "Warning: no URL given for $i"
245 if [ -z "$NOCVS" ]||\
246 [ `echo $i | grep -vE '(ftp|http|https)://'` ]
248 cvs $OPTIONS `nourl $i`
251 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
252 [ `echo $i | grep -E 'ftp://|http://|https://'` ]
257 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
258 Exit_error err_no_source_in_repo $i;
263 if [ "$CHMOD" = "yes" ]; then
264 CHMOD_FILES="`nourl $GET_FILES`"
265 if [ -n "$CHMOD_FILES" ]; then
266 chmod 444 $CHMOD_FILES
277 if [ -n "$DEBUG" ]; then
282 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
283 echo $PACKAGE_VERSION
284 echo $PACKAGE_RELEASE
285 TAG=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g"`
289 if [ -n "$CVSROOT" ]; then
290 OPTIONS="-d $CVSROOT $OPTIONS"
294 for i in $TAG_FILES; do
295 if [ -f `nourl $i` ]; then
296 cvs $OPTIONS $TAG `nourl $i`
297 cvs $OPTIONS STABLE `nourl $i`
299 Exit_error err_no_source_in_repo $i
304 cvs $OPTIONS $TAG $SPECFILE
305 cvs $OPTIONS STABLE $SPECFILE
313 if [ -n "$DEBUG" ]; then
321 BUILD_SWITCH="-ba" ;;
323 BUILD_SWITCH="-bb" ;;
325 BUILD_SWITCH="-bs --nodeps" ;;
327 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $SPECFILE
329 if [ "$?" -ne "0" ]; then
330 Exit_error err_build_fail;
337 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
339 #---------------------------------------------
342 if [ "$#" = 0 ]; then
347 while test $# -gt 0 ; do
350 DEBUG="yes"; shift ;;
352 COMMAND="version"; shift ;;
354 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
356 COMMAND="build"; shift ;;
357 -bb | --build-binary )
358 COMMAND="build-binary"; shift ;;
359 -bs | --build-source )
360 COMMAND="build-source"; shift ;;
362 CLEAN="--clean --rmspec --rmsource"; shift ;;
364 shift; CVSROOT="${1}"; shift ;;
366 COMMAND="get"; shift ;;
368 COMMAND="usage"; shift ;;
370 shift; LOGFILE="${1}"; shift ;;
372 shift; DEF_NICE_LEVEL=${1}; shift ;;
374 COMMAND="mr-proper"; shift ;;
376 NOCVS="yes"; shift ;;
378 NOURLS="yes"; shift ;;
380 NOSRCS="yes"; shift ;;
382 shift; RPMOPTS="${1}"; shift ;;
384 QUIET="--quiet"; shift ;;
386 shift; CVSTAG="${1}"; shift ;;
388 COMMAND="tag"; shift;;
390 BE_VERBOSE="1"; shift ;;
392 SPECFILE="${1}"; shift ;;
396 if [ -n "$DEBUG" ]; then
402 "build" | "build-binary" | "build-source" )
404 if [ -n "$SPECFILE" ]; then
407 if [ -n "$ICONS" ]; then
411 get_files "$SOURCES $PATCHES";
414 Exit_error err_no_spec_in_cmdl;
419 if [ -n "$SPECFILE" ]; then
422 if [ -n "$ICONS" ]; then
426 get_files $SOURCES $PATCHES
428 Exit_error err_no_spec_in_cmdl;
433 if [ -n "$SPECFILE" ]; then
436 if [ -n "$ICONS" ]; then
440 get_files $SOURCES $PATCHES;
441 tag_files "$SOURCES $PATCHES $ICONS";
443 Exit_error err_no_spec_in_cmdl;
447 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE
458 # Revision 1.78 2001/05/13 19:04:44 misiek
461 # Revision 1.77 2001/05/13 10:51:30 misiek
462 # don't fail if no sources found (hack to allow build nosrc packages)
464 # Revision 1.76 2001/04/19 23:24:06 misiek
467 # Revision 1.75 2001/04/19 23:14:25 misiek
468 # redirect errors from query to /dev/null
470 # Revision 1.74 2001/04/02 15:39:29 misiek
471 # fix problems with get_files when no files passed
473 # Revision 1.73 2001/03/30 14:06:10 wiget
474 # massive typo by kloczek
476 # Revision 1.72 2001/03/26 22:16:22 kloczek
477 # - fixed grabbing name, version and release in parse_spec(),
478 # - added -T option (tag) (temporary it tags also additional STABLE tag - must
479 # be added -Ts for separate tagging as STABLE).
481 # Revision 1.71 2001/03/05 14:12:27 misiek
484 # Revision 1.70 2001/03/03 19:55:42 misiek
485 # workaround for problems with rpm when icons isn't cvs up'ed