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 if [ -s CVS/Root ]; then
29 CVSROOT=$(cat CVS/Root)
31 CVSROOT=${CVSROOT:-""}
47 FAIL_IF_NO_SOURCES="yes"
49 GETURI="wget -c -nd -t0"
51 if [ -f ~/etc/builderrc ]; then
53 elif [ -f ~/.builderrc ]; then
57 #---------------------------------------------
62 if [ -n "$DEBUG" ]; then set -xv; fi
64 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
65 [--build] [-bb] [--build-binary] [-bs] [--build-source]
66 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
67 [-l <logfile>] [-m] [--mr-proper] [--logtofile <logfile>] [-q] [--quiet]
68 [-r <cvstag>] [--cvstag <cvstag>] [-u] [--no-urls] [-v] [--verbose]
69 [--opts <rpm opts>] [--with/--without pkg] <package>.spec
71 -D, --debug - enable script debugging mode,
72 -V, --version - output builder version
73 -a, --as_anon - get files via pserver as cvs@anoncvs.pld.org.pl,
75 --build - get all files from CVS repo or HTTP/FTP and build
76 package from <package>.spec,
78 --build-binary - get all files from CVS repo or HTTP/FTP and build
79 binary only package from <package>.spec,
81 --build-source - get all files from CVS repo or HTTP/FTP and only
82 pack them into src.rpm,
83 -c, --clean - clean all temporarily created files (in BUILD,
84 SOURCES, SPECS and \$RPM_BUILD_ROOT),
85 SOURCES, SPECS and \$RPM_BUILD_ROOT),
86 -d, --cvsroot - setup \$CVSROOT,
87 -g, --get - get <package>.spec and all related files from
89 -h, --help - this message,
90 -l, --logtofile - log all to file,
91 -m, --mr-proper - only remove all files related to spec file and
93 -nc, --no-cvs - don't download from CVS, if source URL is given,
94 -nu, --no-urls - don't try to download from FTP/HTTP location,
95 -ns, --no-srcs - don't downland Sources
96 --opts - additional options for rpm
97 -q, --quiet - be quiet,
98 -r, --cvstag - build package using resources from specified CVS
100 -T, --tag - add cvs tags for files,
101 -v, --verbose - be verbose,
108 if [ -n "$DEBUG" ]; then
115 if [ "$NOSRCS" != "yes" ]; then
116 SOURCES="`rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | awk '/SOURCEURL[0-9]+/ {print $3}'`"
118 if (rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | grep -qEi ":.*nosource.*1"); then
119 FAIL_IF_NO_SOURCES="no"
123 PATCHES="`rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | awk '/PATCHURL[0-9]+/ {print $3}'`"
124 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
125 PACKAGE_NAME="`rpm -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
126 PACKAGE_VERSION="`rpm -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
127 PACKAGE_RELEASE="`rpm -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
129 if [ -n "$BE_VERBOSE" ]; then
130 echo "- Sources : `nourl $SOURCES`"
131 if [ -n "$PATCHES" ]; then
132 echo "- Patches : `nourl $PATCHES`"
134 echo "- Patches : *no patches needed*"
136 if [ -n "$ICONS" ]; then
137 echo "- Icon : `nourl $ICONS`"
139 echo "- Icon : *no package icon*"
141 echo "- Name : $PACKAGE_NAME"
142 echo "- Version : $PACKAGE_VERSION"
143 echo "- Release : $PACKAGE_RELEASE"
149 if [ -n "$DEBUG" ]; then
157 "err_no_spec_in_cmdl" )
158 echo "ERROR: spec file name not specified.";
160 "err_no_spec_in_repo" )
161 echo "Error: spec file not stored in CVS repo.";
163 "err_no_source_in_repo" )
164 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
167 echo "Error: package build failed.";
174 if [ -n "$DEBUG" ]; then
179 SOURCE_DIR="`rpm --eval '%{_sourcedir}'`"
180 SPECS_DIR="`rpm --eval '%{_specdir}'`"
187 if [ -n "$DEBUG" ]; then
196 if [ -n "$CVSROOT" ]; then
197 OPTIONS="-d $CVSROOT $OPTIONS"
199 if [ -n "$CVSTAG" ]; then
200 OPTIONS="$OPTIONS -r $CVSTAG"
202 OPTIONS="$OPTIONS -A"
205 cvs $OPTIONS $SPECFILE
206 if [ "$?" -ne "0" ]; then
207 Exit_error err_no_spec_in_repo;
209 if [ ! -f "$SPECFILE" ]; then
210 Exit_error err_no_spec_in_repo;
213 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
223 if [ -n "$DEBUG" ]; then
228 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
232 if [ -n "$CVSROOT" ]; then
233 OPTIONS="-d $CVSROOT $OPTIONS"
235 if [ -n "$CVSTAG" ]; then
236 OPTIONS="$OPTIONS -r $CVSTAG"
238 OPTIONS="$OPTIONS -A"
240 for i in $GET_FILES; do
241 if [ ! -f `nourl $i` ] || [ $ALLWAYS_CVSUP = "yes" ]
244 echo $i | grep -vE '(http|ftp|https|cvs)://' |\
245 grep -qE '\.(gz|bz2)$'
247 echo "Warning: no URL given for $i"
250 if [ -z "$NOCVS" ]||\
251 [ `echo $i | grep -vE '(ftp|http|https)://'` ]
253 cvs $OPTIONS `nourl $i`
256 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
257 [ `echo $i | grep -E 'ftp://|http://|https://'` ]
262 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
263 Exit_error err_no_source_in_repo $i;
268 if [ "$CHMOD" = "yes" ]; then
269 CHMOD_FILES="`nourl $GET_FILES`"
270 if [ -n "$CHMOD_FILES" ]; then
271 chmod 444 $CHMOD_FILES
282 if [ -n "$DEBUG" ]; then
287 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
288 echo $PACKAGE_VERSION
289 echo $PACKAGE_RELEASE
290 TAG=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g"`
294 if [ -n "$CVSROOT" ]; then
295 OPTIONS="-d $CVSROOT $OPTIONS"
299 for i in $TAG_FILES; do
300 if [ -f `nourl $i` ]; then
301 cvs $OPTIONS $TAG `nourl $i`
302 cvs $OPTIONS STABLE `nourl $i`
304 Exit_error err_no_source_in_repo $i
309 cvs $OPTIONS $TAG $SPECFILE
310 cvs $OPTIONS STABLE $SPECFILE
318 if [ -n "$DEBUG" ]; then
326 BUILD_SWITCH="-ba" ;;
328 BUILD_SWITCH="-bb" ;;
330 BUILD_SWITCH="-bs --nodeps" ;;
332 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE
334 if [ "$?" -ne "0" ]; then
335 Exit_error err_build_fail;
342 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
344 #---------------------------------------------
347 if [ "$#" = 0 ]; then
352 while test $# -gt 0 ; do
355 DEBUG="yes"; shift ;;
357 COMMAND="version"; shift ;;
359 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
361 COMMAND="build"; shift ;;
362 -bb | --build-binary )
363 COMMAND="build-binary"; shift ;;
364 -bs | --build-source )
365 COMMAND="build-source"; shift ;;
367 CLEAN="--clean --rmspec --rmsource"; shift ;;
369 shift; CVSROOT="${1}"; shift ;;
371 COMMAND="get"; shift ;;
373 COMMAND="usage"; shift ;;
375 shift; LOGFILE="${1}"; shift ;;
377 shift; DEF_NICE_LEVEL=${1}; shift ;;
379 COMMAND="mr-proper"; shift ;;
381 NOCVS="yes"; shift ;;
383 NOURLS="yes"; shift ;;
385 NOSRCS="yes"; shift ;;
387 shift; RPMOPTS="${1}"; shift ;;
389 BCOND="$1 $2" ; shift 2 ;;
391 QUIET="--quiet"; shift ;;
393 shift; CVSTAG="${1}"; shift ;;
395 COMMAND="tag"; shift;;
397 BE_VERBOSE="1"; shift ;;
399 SPECFILE="${1}"; shift ;;
403 if [ -n "$DEBUG" ]; then
409 "build" | "build-binary" | "build-source" )
411 if [ -n "$SPECFILE" ]; then
414 if [ -n "$ICONS" ]; then
418 get_files "$SOURCES $PATCHES";
421 Exit_error err_no_spec_in_cmdl;
426 if [ -n "$SPECFILE" ]; then
429 if [ -n "$ICONS" ]; then
433 get_files $SOURCES $PATCHES
435 Exit_error err_no_spec_in_cmdl;
440 if [ -n "$SPECFILE" ]; then
443 if [ -n "$ICONS" ]; then
447 get_files $SOURCES $PATCHES;
448 tag_files "$SOURCES $PATCHES $ICONS";
450 Exit_error err_no_spec_in_cmdl;
454 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE
465 # Revision 1.80 2001/06/22 18:52:39 misiek
466 # - added support for --with/--without options
468 # Revision 1.79 2001/05/28 14:44:16 baggins
469 # - if file is not in repo TELL which fucking file it is!
471 # Revision 1.78 2001/05/13 19:04:44 misiek
474 # Revision 1.77 2001/05/13 10:51:30 misiek
475 # don't fail if no sources found (hack to allow build nosrc packages)
477 # Revision 1.76 2001/04/19 23:24:06 misiek
480 # Revision 1.75 2001/04/19 23:14:25 misiek
481 # redirect errors from query to /dev/null
483 # Revision 1.74 2001/04/02 15:39:29 misiek
484 # fix problems with get_files when no files passed
486 # Revision 1.73 2001/03/30 14:06:10 wiget
487 # massive typo by kloczek
489 # Revision 1.72 2001/03/26 22:16:22 kloczek
490 # - fixed grabbing name, version and release in parse_spec(),
491 # - added -T option (tag) (temporary it tags also additional STABLE tag - must
492 # be added -Ts for separate tagging as STABLE).
494 # Revision 1.71 2001/03/05 14:12:27 misiek
497 # Revision 1.70 2001/03/03 19:55:42 misiek
498 # workaround for problems with rpm when icons isn't cvs up'ed