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 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 -ns, --no-srcs - don't downland Sources
89 --opts - additional options for rpm
90 -q, --quiet - be quiet,
91 -r, --cvstag - build package using resources from specified CVS
93 -T, --tag - add cvs tags for files,
94 -v, --verbose - be verbose,
101 if [ -n "$DEBUG" ]; then
108 if [ "$NOSRCS" != "yes" ]; then
109 SOURCES="`rpm -bp --nobuild --define "prep %dump" $SPECFILE 2>&1 | awk '/SOURCEURL[0-9]+/ {print $3}'`"
112 PATCHES="`rpm -bp --nobuild --define "prep %dump" $SPECFILE 2>&1 | awk '/PATCHURL[0-9]+/ {print $3}'`"
113 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
114 PACKAGE_NAME="`rpm -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
115 PACKAGE_VERSION="`rpm -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
116 PACKAGE_RELEASE="`rpm -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
118 if [ -n "$BE_VERBOSE" ]; then
119 echo "- Sources : `nourl $SOURCES`"
120 if [ -n "$PATCHES" ]; then
121 echo "- Patches : `nourl $PATCHES`"
123 echo "- Patches : *no patches needed*"
125 if [ -n "$ICONS" ]; then
126 echo "- Icon : `nourl $ICONS`"
128 echo "- Icon : *no package icon*"
130 echo "- Name : $PACKAGE_NAME"
131 echo "- Version : $PACKAGE_VERSION"
132 echo "- Release : $PACKAGE_RELEASE"
138 if [ -n "$DEBUG" ]; then
146 "err_no_spec_in_cmdl" )
147 echo "ERROR: spec file name not specified.";
149 "err_no_spec_in_repo" )
150 echo "Error: spec file not stored in CVS repo.";
152 "err_no_source_in_repo" )
153 echo "Error: some source, patch or icon files not stored in CVS repo.";
156 echo "Error: package build failed.";
163 if [ -n "$DEBUG" ]; then
168 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
169 SPECS_DIR="`rpm --eval "%{_specdir}"`"
176 if [ -n "$DEBUG" ]; then
185 if [ -n "$CVSROOT" ]; then
186 OPTIONS="-d $CVSROOT $OPTIONS"
188 if [ -n "$CVSTAG" ]; then
189 OPTIONS="$OPTIONS -r $CVSTAG"
191 OPTIONS="$OPTIONS -A"
194 cvs $OPTIONS $SPECFILE
195 if [ "$?" -ne "0" ]; then
196 Exit_error err_no_spec_in_repo;
198 if [ ! -f "$SPECFILE" ]; then
199 Exit_error err_no_spec_in_repo;
202 if [ "$CHMOD" = "yes" ]; then
212 if [ -n "$DEBUG" ]; then
217 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
221 if [ -n "$CVSROOT" ]; then
222 OPTIONS="-d $CVSROOT $OPTIONS"
224 if [ -n "$CVSTAG" ]; then
225 OPTIONS="$OPTIONS -r $CVSTAG"
227 OPTIONS="$OPTIONS -A"
229 for i in $GET_FILES; do
230 if [ ! -f `nourl $i` ] || [ $ALLWAYS_CVSUP = "yes" ]
233 echo $i | grep -vE '(http|ftp|https|cvs)://' |\
234 grep -qE '\.(gz|bz2)$'
236 echo "Warning: no URL given for $i"
239 if [ -z "$NOCVS" ]||\
240 [ `echo $i | grep -vE '(ftp|http|https)://'` ]
242 cvs $OPTIONS `nourl $i`
245 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
246 [ `echo $i | grep -E 'ftp://|http://|https://'` ]
251 if [ ! -f "`nourl $i`" ]; then
252 Exit_error err_no_source_in_repo;
257 if [ "$CHMOD" = "yes" ]; then
258 chmod 444 `nourl $GET_FILES`
268 if [ -n "$DEBUG" ]; then
273 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
274 echo $PACKAGE_VERSION
275 echo $PACKAGE_RELEASE
276 TAG=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g"`
280 if [ -n "$CVSROOT" ]; then
281 OPTIONS="-d $CVSROOT $OPTIONS"
285 for i in $TAG_FILES; do
286 if [ -f `nourl $i` ]; then
287 cvs $OPTIONS $TAG `nourl $i`
288 cvs $OPTIONS STABLE `nourl $i`
290 Exit_error err_no_source_in_repo
295 cvs $OPTIONS $TAG $SPECFILE
296 cvs $OPTIONS STABLE $SPECFILE
304 if [ -n "$DEBUG" ]; then
312 BUILD_SWITCH="-ba" ;;
314 BUILD_SWITCH="-bb" ;;
316 BUILD_SWITCH="-bs --nodeps" ;;
318 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $SPECFILE
320 if [ "$?" -ne "0" ]; then
321 Exit_error err_build_fail;
328 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
330 #---------------------------------------------
333 if [ "$#" = 0 ]; then
338 while test $# -gt 0 ; do
341 DEBUG="yes"; shift ;;
343 COMMAND="version"; shift ;;
345 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
347 COMMAND="build"; shift ;;
348 -bb | --build-binary )
349 COMMAND="build-binary"; shift ;;
350 -bs | --build-source )
351 COMMAND="build-source"; shift ;;
353 CLEAN="--clean --rmspec --rmsource"; shift ;;
355 shift; CVSROOT="${1}"; shift ;;
357 COMMAND="get"; shift ;;
359 COMMAND="usage"; shift ;;
361 shift; LOGFILE="${1}"; shift ;;
363 shift; DEF_NICE_LEVEL=${1}; shift ;;
365 COMMAND="mr-proper"; shift ;;
367 NOCVS="yes"; shift ;;
369 NOURLS="yes"; shift ;;
371 NOSRCS="yes"; shift ;;
373 shift; RPMOPTS="${1}"; shift ;;
375 QUIET="--quiet"; shift ;;
377 shift; CVSTAG="${1}"; shift ;;
379 COMMAND="tag"; shift;;
381 BE_VERBOSE="1"; shift ;;
383 SPECFILE="${1}"; shift ;;
387 if [ -n "$DEBUG" ]; then
393 "build" | "build-binary" | "build-source" )
395 if [ -n "$SPECFILE" ]; then
398 if [ -n "$ICONS" ]; then
402 get_files "$SOURCES $PATCHES";
405 Exit_error err_no_spec_in_cmdl;
410 if [ -n "$SPECFILE" ]; then
413 if [ -n "$ICONS" ]; then
417 get_files $SOURCES $PATCHES
419 Exit_error err_no_spec_in_cmdl;
424 if [ -n "$SPECFILE" ]; then
427 if [ -n "$ICONS" ]; then
431 get_files $SOURCES $PATCHES;
432 tag_files "$SOURCES $PATCHES $ICONS";
434 Exit_error err_no_spec_in_cmdl;
438 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE
449 # Revision 1.74 2001/04/02 15:39:29 misiek
450 # fix problems with get_files when no files passed
452 # Revision 1.73 2001/03/30 14:06:10 wiget
453 # massive typo by kloczek
455 # Revision 1.72 2001/03/26 22:16:22 kloczek
456 # - fixed grabbing name, version and release in parse_spec(),
457 # - added -T option (tag) (temporary it tags also additional STABLE tag - must
458 # be added -Ts for separate tagging as STABLE).
460 # Revision 1.71 2001/03/05 14:12:27 misiek
463 # Revision 1.70 2001/03/03 19:55:42 misiek
464 # workaround for problems with rpm when icons isn't cvs up'ed