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" -a -n "$SPECFILE" ]; 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_FILES="`nourl $GET_FILES`"
259 if [ -n "$CHMOD_FILES" ]; then
260 chmod 444 $CHMOD_FILES
271 if [ -n "$DEBUG" ]; then
276 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
277 echo $PACKAGE_VERSION
278 echo $PACKAGE_RELEASE
279 TAG=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g"`
283 if [ -n "$CVSROOT" ]; then
284 OPTIONS="-d $CVSROOT $OPTIONS"
288 for i in $TAG_FILES; do
289 if [ -f `nourl $i` ]; then
290 cvs $OPTIONS $TAG `nourl $i`
291 cvs $OPTIONS STABLE `nourl $i`
293 Exit_error err_no_source_in_repo
298 cvs $OPTIONS $TAG $SPECFILE
299 cvs $OPTIONS STABLE $SPECFILE
307 if [ -n "$DEBUG" ]; then
315 BUILD_SWITCH="-ba" ;;
317 BUILD_SWITCH="-bb" ;;
319 BUILD_SWITCH="-bs --nodeps" ;;
321 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $SPECFILE
323 if [ "$?" -ne "0" ]; then
324 Exit_error err_build_fail;
331 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
333 #---------------------------------------------
336 if [ "$#" = 0 ]; then
341 while test $# -gt 0 ; do
344 DEBUG="yes"; shift ;;
346 COMMAND="version"; shift ;;
348 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
350 COMMAND="build"; shift ;;
351 -bb | --build-binary )
352 COMMAND="build-binary"; shift ;;
353 -bs | --build-source )
354 COMMAND="build-source"; shift ;;
356 CLEAN="--clean --rmspec --rmsource"; shift ;;
358 shift; CVSROOT="${1}"; shift ;;
360 COMMAND="get"; shift ;;
362 COMMAND="usage"; shift ;;
364 shift; LOGFILE="${1}"; shift ;;
366 shift; DEF_NICE_LEVEL=${1}; shift ;;
368 COMMAND="mr-proper"; shift ;;
370 NOCVS="yes"; shift ;;
372 NOURLS="yes"; shift ;;
374 NOSRCS="yes"; shift ;;
376 shift; RPMOPTS="${1}"; shift ;;
378 QUIET="--quiet"; shift ;;
380 shift; CVSTAG="${1}"; shift ;;
382 COMMAND="tag"; shift;;
384 BE_VERBOSE="1"; shift ;;
386 SPECFILE="${1}"; shift ;;
390 if [ -n "$DEBUG" ]; then
396 "build" | "build-binary" | "build-source" )
398 if [ -n "$SPECFILE" ]; then
401 if [ -n "$ICONS" ]; then
405 get_files "$SOURCES $PATCHES";
408 Exit_error err_no_spec_in_cmdl;
413 if [ -n "$SPECFILE" ]; then
416 if [ -n "$ICONS" ]; then
420 get_files $SOURCES $PATCHES
422 Exit_error err_no_spec_in_cmdl;
427 if [ -n "$SPECFILE" ]; then
430 if [ -n "$ICONS" ]; then
434 get_files $SOURCES $PATCHES;
435 tag_files "$SOURCES $PATCHES $ICONS";
437 Exit_error err_no_spec_in_cmdl;
441 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE
452 # Revision 1.75 2001/04/19 23:14:25 misiek
453 # redirect errors from query to /dev/null
455 # Revision 1.74 2001/04/02 15:39:29 misiek
456 # fix problems with get_files when no files passed
458 # Revision 1.73 2001/03/30 14:06:10 wiget
459 # massive typo by kloczek
461 # Revision 1.72 2001/03/26 22:16:22 kloczek
462 # - fixed grabbing name, version and release in parse_spec(),
463 # - added -T option (tag) (temporary it tags also additional STABLE tag - must
464 # be added -Ts for separate tagging as STABLE).
466 # Revision 1.71 2001/03/05 14:12:27 misiek
469 # Revision 1.70 2001/03/03 19:55:42 misiek
470 # workaround for problems with rpm when icons isn't cvs up'ed