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.8 (C) 1999 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 --opts - additional options for rpm
89 -q, --quiet - be quiet,
90 -r, --cvstag - build package using resources from specified CVS
92 -v, --verbose - be verbose,
99 if [ -n "$DEBUG" ]; then
104 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i "^Icon\:" > $SPECFILE.__
106 SOURCES="`rpm -bp --nobuild $SPECFILE.__ 2>&1 | awk '/ SOURCEURL[0-9]+/ {print $3}'`"
107 PATCHES="`rpm -bp --nobuild $SPECFILE.__ 2>&1 | awk '/ PATCHURL[0-9]+/ {print $3}'`"
108 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
109 PACKAGE_NAME="`rpm -bp --nobuild $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
110 PACKAGE_VERSION="`rpm -bp --nobuild $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
111 PACKAGE_RELEASE="`rpm -bp --nobuild $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
115 if [ -n "$BE_VERBOSE" ]; then
116 echo "- Sources : `nourl $SOURCES`"
117 if [ -n "$PATCHES" ]; then
118 echo "- Patches : `nourl $PATCHES`"
120 echo "- Patches : *no patches needed*"
122 if [ -n "$ICONS" ]; then
123 echo "- Icon : `nourl $ICONS`"
125 echo "- Icon : *no package icon*"
127 echo "- Name : $PACKAGE_NAME"
128 echo "- Version : $PACKAGE_VERSION"
129 echo "- Release : $PACKAGE_RELEASE"
135 if [ -n "$DEBUG" ]; then
143 "err_no_spec_in_cmdl" )
144 echo "ERROR: spec file name not specified.";
146 "err_no_spec_in_repo" )
147 echo "Error: spec file not stored in CVS repo.";
149 "err_no_source_in_repo" )
150 echo "Error: some source, patch or icon files not stored in CVS repo.";
153 echo "Error: package build failed.";
160 if [ -n "$DEBUG" ]; then
165 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
166 SPECS_DIR="`rpm --eval "%{_specdir}"`"
173 if [ -n "$DEBUG" ]; then
182 if [ -n "$CVSROOT" ]; then
183 OPTIONS="-d $CVSROOT $OPTIONS"
185 if [ -n "$CVSTAG" ]; then
186 OPTIONS="$OPTIONS -r $CVSTAG"
188 OPTIONS="$OPTIONS -A"
191 cvs $OPTIONS $SPECFILE
192 if [ "$?" -ne "0" ]; then
193 Exit_error err_no_spec_in_repo;
195 if [ ! -f "$SPECFILE" ]; then
196 Exit_error err_no_spec_in_repo;
199 if [ "$CHMOD" = "yes" ]; then
207 if [ -n "$DEBUG" ]; then
212 if [ -n "$SOURCES$PATCHES$ICONS" ]; then
216 if [ -n "$CVSROOT" ]; then
217 OPTIONS="-d $CVSROOT $OPTIONS"
219 if [ -n "$CVSTAG" ]; then
220 OPTIONS="$OPTIONS -r $CVSTAG"
222 OPTIONS="$OPTIONS -A"
224 for i in $SOURCES $PATCHES $ICONS; do
225 if [ ! -f `nourl $i` ] || [ $ALLWAYS_CVSUP = "yes" ]
228 echo $i | grep -vE '(http|ftp|https|cvs)://' |\
229 grep -qE '\.(gz|bz2)$'
231 echo "Warning: no URL given for $i"
234 if [ -z "$NOCVS" ]||\
235 [ `echo $i | grep -vE '(ftp|http|https)://'` ]
237 cvs $OPTIONS `nourl $i`
240 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
241 [ `echo $i | grep -E 'ftp://|http://|https://'` ]
246 if [ ! -f "`nourl $i`" ]; then
247 Exit_error err_no_source_in_repo;
252 if [ "$CHMOD" = "yes" ]; then
253 chmod 444 `nourl $SOURCES $PATCHES $ICONS`
261 if [ -n "$DEBUG" ]; then
269 BUILD_SWITCH="-ba" ;;
271 BUILD_SWITCH="-bb" ;;
273 BUILD_SWITCH="-bs --nodeps" ;;
275 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $SPECFILE
277 if [ "$?" -ne "0" ]; then
278 Exit_error err_build_fail;
285 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
287 #---------------------------------------------
290 if [ "$#" = 0 ]; then
295 while test $# -gt 0 ; do
298 DEBUG="yes"; shift ;;
300 COMMAND="version"; shift ;;
302 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
304 COMMAND="build"; shift ;;
305 -bb | --build-binary )
306 COMMAND="build-binary"; shift ;;
307 -bs | --build-source )
308 COMMAND="build-source"; shift ;;
310 CLEAN="--clean --rmspec --rmsource"; shift ;;
312 shift; CVSROOT="${1}"; shift ;;
314 COMMAND="get"; shift ;;
316 COMMAND="usage"; shift ;;
318 shift; LOGFILE="${1}"; shift ;;
320 shift; DEF_NICE_LEVEL=${1}; shift ;;
322 COMMAND="mr-proper"; shift ;;
324 NOCVS="yes"; shift ;;
326 NOURLS="yes"; shift ;;
328 shift; RPMOPTS="${1}"; shift ;;
330 QUIET="--quiet"; shift ;;
332 shift; CVSTAG="${1}"; shift ;;
334 BE_VERBOSE="1"; shift ;;
336 SPECFILE="${1}"; shift ;;
340 if [ -n "$DEBUG" ]; then
346 "build" | "build-binary" | "build-source" )
348 if [ -n "$SPECFILE" ]; then
354 Exit_error err_no_spec_in_cmdl;
359 if [ -n "$SPECFILE" ]; then
364 Exit_error err_no_spec_in_cmdl;
368 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE