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:-""}
43 FAIL_IF_NO_SOURCES="yes"
45 GETURI="wget -c -nd -t0"
47 if [ -f ~/etc/builderrc ]; then
49 elif [ -f ~/.builderrc ]; then
53 #---------------------------------------------
58 if [ -n "$DEBUG" ]; then set -xv; fi
60 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
61 [--build] [-bb] [--build-binary] [-bs] [--build-source]
62 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
63 [-l <logfile>] [-m] [--mr-proper] [--logtofile <logfile>] [-q] [--quiet]
64 [-r <cvstag>] [--cvstag <cvstag>] [-u] [--no-urls] [-v] [--verbose]
65 [--opts <rpm opts>] [--with/--without pkg] <package>.spec
67 -D, --debug - enable script debugging mode,
68 -V, --version - output builder version
69 -a, --as_anon - get files via pserver as cvs@anoncvs.pld.org.pl,
71 --build - get all files from CVS repo or HTTP/FTP and build
72 package from <package>.spec,
74 --build-binary - get all files from CVS repo or HTTP/FTP and build
75 binary only package from <package>.spec,
77 --build-source - get all files from CVS repo or HTTP/FTP and only
78 pack them into src.rpm,
79 -c, --clean - clean all temporarily created files (in BUILD,
80 SOURCES, SPECS and \$RPM_BUILD_ROOT),
81 SOURCES, SPECS and \$RPM_BUILD_ROOT),
82 -d, --cvsroot - setup \$CVSROOT,
83 -g, --get - get <package>.spec and all related files from
85 -h, --help - this message,
86 -l, --logtofile - log all to file,
87 -m, --mr-proper - only remove all files related to spec file and
89 -nc, --no-cvs - don't download from CVS, if source URL is given,
90 -nu, --no-urls - don't try to download from FTP/HTTP location,
91 -ns, --no-srcs - don't downland Sources
92 --opts - additional options for rpm
93 -q, --quiet - be quiet,
94 -r, --cvstag - build package using resources from specified CVS
96 -T, --tag - add cvs tags for files,
97 -v, --verbose - be verbose,
104 if [ -n "$DEBUG" ]; then
111 if [ "$NOSRCS" != "yes" ]; then
112 SOURCES="`rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | awk '/SOURCEURL[0-9]+/ {print $3}'`"
114 if (rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | grep -qEi ":.*nosource.*1"); then
115 FAIL_IF_NO_SOURCES="no"
119 PATCHES="`rpm -bp --nobuild --define 'prep %dump' $SPECFILE 2>&1 | awk '/PATCHURL[0-9]+/ {print $3}'`"
120 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
121 PACKAGE_NAME="`rpm -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
122 PACKAGE_VERSION="`rpm -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
123 PACKAGE_RELEASE="`rpm -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
125 if [ -n "$BE_VERBOSE" ]; then
126 echo "- Sources : `nourl $SOURCES`"
127 if [ -n "$PATCHES" ]; then
128 echo "- Patches : `nourl $PATCHES`"
130 echo "- Patches : *no patches needed*"
132 if [ -n "$ICONS" ]; then
133 echo "- Icon : `nourl $ICONS`"
135 echo "- Icon : *no package icon*"
137 echo "- Name : $PACKAGE_NAME"
138 echo "- Version : $PACKAGE_VERSION"
139 echo "- Release : $PACKAGE_RELEASE"
145 if [ -n "$DEBUG" ]; then
153 "err_no_spec_in_cmdl" )
154 echo "ERROR: spec file name not specified.";
156 "err_no_spec_in_repo" )
157 echo "Error: spec file not stored in CVS repo.";
159 "err_no_source_in_repo" )
160 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
163 echo "Error: package build failed.";
170 if [ -n "$DEBUG" ]; then
175 SOURCE_DIR="`rpm --eval '%{_sourcedir}'`"
176 SPECS_DIR="`rpm --eval '%{_specdir}'`"
183 if [ -n "$DEBUG" ]; then
192 if [ -n "$CVSROOT" ]; then
193 OPTIONS="-d $CVSROOT $OPTIONS"
195 if [ -n "$CVSTAG" ]; then
196 OPTIONS="$OPTIONS -r $CVSTAG"
198 OPTIONS="$OPTIONS -A"
201 cvs $OPTIONS $SPECFILE
202 if [ "$?" -ne "0" ]; then
203 Exit_error err_no_spec_in_repo;
205 if [ ! -f "$SPECFILE" ]; then
206 Exit_error err_no_spec_in_repo;
209 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
219 if [ -n "$DEBUG" ]; then
224 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
228 if [ -n "$CVSROOT" ]; then
229 OPTIONS="-d $CVSROOT $OPTIONS"
231 if [ -n "$CVSTAG" ]; then
232 OPTIONS="$OPTIONS -r $CVSTAG"
234 OPTIONS="$OPTIONS -A"
236 for i in $GET_FILES; do
237 if [ ! -f `nourl $i` ] || [ $ALLWAYS_CVSUP = "yes" ]
240 echo $i | grep -vE '(http|ftp|https|cvs)://' |\
241 grep -qE '\.(gz|bz2)$'
243 echo "Warning: no URL given for $i"
246 if [ -z "$NOCVS" ]||\
247 [ `echo $i | grep -vE '(ftp|http|https)://'` ]
249 cvs $OPTIONS `nourl $i`
252 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
253 [ `echo $i | grep -E 'ftp://|http://|https://'` ]
258 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
259 Exit_error err_no_source_in_repo $i;
264 if [ "$CHMOD" = "yes" ]; then
265 CHMOD_FILES="`nourl $GET_FILES`"
266 if [ -n "$CHMOD_FILES" ]; then
267 chmod 444 $CHMOD_FILES
278 if [ -n "$DEBUG" ]; then
283 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
284 echo $PACKAGE_VERSION
285 echo $PACKAGE_RELEASE
286 TAG=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g"`
290 if [ -n "$CVSROOT" ]; then
291 OPTIONS="-d $CVSROOT $OPTIONS"
295 for i in $TAG_FILES; do
296 if [ -f `nourl $i` ]; then
297 cvs $OPTIONS $TAG `nourl $i`
298 cvs $OPTIONS STABLE `nourl $i`
300 Exit_error err_no_source_in_repo $i
305 cvs $OPTIONS $TAG $SPECFILE
306 cvs $OPTIONS STABLE $SPECFILE
314 if [ -n "$DEBUG" ]; then
322 BUILD_SWITCH="-ba" ;;
324 BUILD_SWITCH="-bb" ;;
326 BUILD_SWITCH="-bs --nodeps" ;;
328 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE
330 if [ "$?" -ne "0" ]; then
331 Exit_error err_build_fail;
338 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
340 #---------------------------------------------
343 if [ "$#" = 0 ]; then
348 while test $# -gt 0 ; do
351 DEBUG="yes"; shift ;;
353 COMMAND="version"; shift ;;
355 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
357 COMMAND="build"; shift ;;
358 -bb | --build-binary )
359 COMMAND="build-binary"; shift ;;
360 -bs | --build-source )
361 COMMAND="build-source"; shift ;;
363 CLEAN="--clean --rmspec --rmsource"; shift ;;
365 shift; CVSROOT="${1}"; shift ;;
367 COMMAND="get"; shift ;;
369 COMMAND="usage"; shift ;;
371 shift; LOGFILE="${1}"; shift ;;
373 shift; DEF_NICE_LEVEL=${1}; shift ;;
375 COMMAND="mr-proper"; shift ;;
377 NOCVS="yes"; shift ;;
379 NOURLS="yes"; shift ;;
381 NOSRCS="yes"; shift ;;
383 shift; RPMOPTS="${1}"; shift ;;
385 BCOND="$1 $2" ; shift 2 ;;
387 QUIET="--quiet"; shift ;;
389 shift; CVSTAG="${1}"; shift ;;
391 COMMAND="tag"; shift;;
393 BE_VERBOSE="1"; shift ;;
395 SPECFILE="${1}"; shift ;;
399 if [ -n "$DEBUG" ]; then
405 "build" | "build-binary" | "build-source" )
407 if [ -n "$SPECFILE" ]; then
410 if [ -n "$ICONS" ]; then
414 get_files "$SOURCES $PATCHES";
417 Exit_error err_no_spec_in_cmdl;
422 if [ -n "$SPECFILE" ]; then
425 if [ -n "$ICONS" ]; then
429 get_files $SOURCES $PATCHES
431 Exit_error err_no_spec_in_cmdl;
436 if [ -n "$SPECFILE" ]; then
439 if [ -n "$ICONS" ]; then
443 get_files $SOURCES $PATCHES;
444 tag_files "$SOURCES $PATCHES $ICONS";
446 Exit_error err_no_spec_in_cmdl;
450 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE
461 # Revision 1.79 2001/05/28 14:44:16 baggins
462 # - if file is not in repo TELL which fucking file it is!
464 # Revision 1.78 2001/05/13 19:04:44 misiek
467 # Revision 1.77 2001/05/13 10:51:30 misiek
468 # don't fail if no sources found (hack to allow build nosrc packages)
470 # Revision 1.76 2001/04/19 23:24:06 misiek
473 # Revision 1.75 2001/04/19 23:14:25 misiek
474 # redirect errors from query to /dev/null
476 # Revision 1.74 2001/04/02 15:39:29 misiek
477 # fix problems with get_files when no files passed
479 # Revision 1.73 2001/03/30 14:06:10 wiget
480 # massive typo by kloczek
482 # Revision 1.72 2001/03/26 22:16:22 kloczek
483 # - fixed grabbing name, version and release in parse_spec(),
484 # - added -T option (tag) (temporary it tags also additional STABLE tag - must
485 # be added -Ts for separate tagging as STABLE).
487 # Revision 1.71 2001/03/05 14:12:27 misiek
490 # Revision 1.70 2001/03/03 19:55:42 misiek
491 # workaround for problems with rpm when icons isn't cvs up'ed