6 # 2 - no spec file name in cmdl parameters
7 # 3 - spec file not stored in repo
8 # 4 - some source, apatch or icon files not stored in repo
9 # 5 - build package no succed
12 Build package utility from PLD CVS repository
13 V 0.8 (C) 1999 Tomasz K³oczko".
15 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
27 CVSROOT=${CVSROOT:-""}
41 GETURI="wget -c -nd -t0"
43 if [ -f ~/etc/builderrc ]; then
45 elif [ -f ~/.builderrc ]; then
49 #---------------------------------------------
54 if [ -n "$DEBUG" ]; then set -xv; fi
56 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
57 [--build] [-bb] [--build-binary] [-bs] [--build-source]
58 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
59 [-l <logfile>] [-m] [--mr-proper] [--logtofile <logfile>] [-q] [--quiet]
60 [-r <cvstag>] [--cvstag <cvstag>] [-u] [--no-urls] [-v] [--verbose]
61 [--opts <rpm opts>] <package>.spec
63 -D, --debug - enable script debugging mode,
64 -V, --version - output builder version
65 -a, --as_anon - get files via pserver as cvs@anoncvs.pld.org.pl,
67 --build - get all files from CVS repo or HTTP/FTP and build
68 package from <package>.spec,
70 --build-binary - get all files from CVS repo or HTTP/FTP and build
71 binary only package from <package>.spec,
73 --build-source - get all files from CVS repo or HTTP/FTP and only
74 pack them into src.rpm,
75 -c, --clean - clean all temporarily created files (in BUILD,
76 SOURCES, SPECS and \$RPM_BUILD_ROOT),
77 SOURCES, SPECS and \$RPM_BUILD_ROOT),
78 -d, --cvsroot - setup \$CVSROOT,
79 -g, --get - get <package>.spec and all related files from
81 -h, --help - this message,
82 -l, --logtofile - log all to file,
83 -m, --mr-proper - only remove all files related to spec file and
85 -nc, --no-cvs - don't download from CVS, if source URL is given,
86 -nu, --no-urls - don't try to download from FTP/HTTP location,
87 --opts - additional options for rpm
88 -q, --quiet - be quiet,
89 -r, --cvstag - build package using resources from specified CVS
91 -v, --verbose - be verbose,
98 if [ -n "$DEBUG" ]; then
103 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i "^Icon\:" > $SPECFILE.__
105 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCEURL[0-9]+/ {print $3}'`"
106 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCHURL[0-9]+/ {print $3}'`"
107 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
108 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
109 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
110 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
114 if [ -n "$BE_VERBOSE" ]; then
115 echo "- Sources : `nourl $SOURCES`"
116 if [ -n "$PATCHES" ]; then
117 echo "- Patches : `nourl $PATCHES`"
119 echo "- Patches : *no patches needed*"
121 if [ -n "$ICONS" ]; then
122 echo "- Icon : `nourl $ICONS`"
124 echo "- Icon : *no package icon*"
126 echo "- Name : $PACKAGE_NAME"
127 echo "- Version : $PACKAGE_VERSION"
128 echo "- Release : $PACKAGE_RELEASE"
134 if [ -n "$DEBUG" ]; then
142 "err_no_spec_in_cmdl" )
143 echo "ERROR: spec file name not specified.";
145 "err_no_spec_in_repo" )
146 echo "Error: spec file not stored in CVS repo.";
148 "err_no_source_in_repo" )
149 echo "Error: some source, patch or icon files not stored in CVS repo.";
152 echo "Error: package build failed.";
159 if [ -n "$DEBUG" ]; then
164 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
165 SPECS_DIR="`rpm --eval "%{_specdir}"`"
172 if [ -n "$DEBUG" ]; then
181 if [ -n "$CVSROOT" ]; then
182 OPTIONS="-d $CVSROOT $OPTIONS"
184 if [ -n "$CVSTAG" ]; then
185 OPTIONS="$OPTIONS -r $CVSTAG"
187 OPTIONS="$OPTIONS -A"
190 cvs $OPTIONS $SPECFILE
191 if [ "$?" -ne "0" ]; then
192 Exit_error err_no_spec_in_repo;
194 if [ ! -f "$SPECFILE" ]; then
195 Exit_error err_no_spec_in_repo;
198 if [ "$CHMOD" = "yes" ]; then
206 if [ -n "$DEBUG" ]; then
211 if [ -n "$SOURCES$PATCHES$ICONS" ]; then
215 if [ -n "$CVSROOT" ]; then
216 OPTIONS="-d $CVSROOT $OPTIONS"
218 if [ -n "$CVSTAG" ]; then
219 OPTIONS="$OPTIONS -r $CVSTAG"
221 OPTIONS="$OPTIONS -A"
223 for i in $SOURCES $PATCHES $ICONS; do
224 if [ ! -f `nourl $i` ] || [ $ALLWAYS_CVSUP = "yes" ]
227 echo $i | grep -vE '(http|ftp|https|cvs)://' |\
228 grep -qE '\.(gz|bz2)$'
230 echo "Warning: no URL given for $i"
233 if [ -z "$NOCVS" ]||\
234 [ `echo $i | grep -vE '(ftp|http|https)://'` ]
236 cvs $OPTIONS `nourl $i`
239 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
240 [ `echo $i | grep -E 'ftp://|http://|https://'` ]
245 if [ ! -f "`nourl $i`" ]; then
246 Exit_error err_no_source_in_repo;
251 if [ "$CHMOD" = "yes" ]; then
252 chmod 444 `nourl $SOURCES $PATCHES $ICONS`
260 if [ -n "$DEBUG" ]; then
268 BUILD_SWITCH="-ba" ;;
270 BUILD_SWITCH="-bb" ;;
272 BUILD_SWITCH="-bs --nodeps" ;;
274 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $SPECFILE
276 if [ "$?" -ne "0" ]; then
277 Exit_error err_build_fail;
284 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
286 #---------------------------------------------
289 if [ "$#" = 0 ]; then
294 while test $# -gt 0 ; do
297 DEBUG="yes"; shift ;;
299 COMMAND="version"; shift ;;
301 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
303 COMMAND="build"; shift ;;
304 -bb | --build-binary )
305 COMMAND="build-binary"; shift ;;
306 -bs | --build-source )
307 COMMAND="build-source"; shift ;;
309 CLEAN="--clean --rmspec --rmsource"; shift ;;
311 shift; CVSROOT="${1}"; shift ;;
313 COMMAND="get"; shift ;;
315 COMMAND="usage"; shift ;;
317 shift; LOGFILE="${1}"; shift ;;
319 shift; DEF_NICE_LEVEL=${1}; shift ;;
321 COMMAND="mr-proper"; shift ;;
323 NOCVS="yes"; shift ;;
325 NOURLS="yes"; shift ;;
327 shift; RPMOPTS="${1}"; shift ;;
329 QUIET="--quiet"; shift ;;
331 shift; CVSTAG="${1}"; shift ;;
333 BE_VERBOSE="1"; shift ;;
335 SPECFILE="${1}"; shift ;;
339 if [ -n "$DEBUG" ]; then
345 "build" | "build-binary" | "build-source" )
347 if [ -n "$SPECFILE" ]; then
353 Exit_error err_no_spec_in_cmdl;
358 if [ -n "$SPECFILE" ]; then
363 Exit_error err_no_spec_in_cmdl;
367 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE