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"
26 CVSROOT=${CVSROOT:-""}
40 if [ -f ~/etc/builderrc ]; then
42 elif [ -f ~/.builderrc ]; then
46 #---------------------------------------------
51 if [ -n "$DEBUG" ]; then set -xv; fi
53 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
54 [--build] [-bb] [--build-binary] [-bs] [--build-source]
55 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
56 [-l <logfile>] [-m] [--mr-proper] [--logtofile <logfile>] [-q] [--quiet]
57 [-r <cvstag>] [--cvstag <cvstag>] [-u] [--no-urls] [-v] [--verbose]
58 [--opts <rpm opts>] <package>.spec
60 -D, --debug - enable script debugging mode,
61 -V, --version - output builder version
62 -a, --as_anon - get files via pserver as cvs@anoncvs.pld.org.pl,
64 --build - get all files from CVS repo or HTTP/FTP and build
65 package from <package>.spec,
67 --build-binary - get all files from CVS repo or HTTP/FTP and build
68 binary only package from <package>.spec,
70 --build-source - get all files from CVS repo or HTTP/FTP and only
71 pack them into src.rpm,
72 -c, --clean - clean all temporarily created files (in BUILD,
73 SOURCES, SPECS and \$RPM_BUILD_ROOT),
74 SOURCES, SPECS and \$RPM_BUILD_ROOT),
75 -d, --cvsroot - setup \$CVSROOT,
76 -g, --get - get <package>.spec and all related files from
78 -h, --help - this message,
79 -l, --logtofile - log all to file,
80 -m, --mr-proper - only remove all files related to spec file and
82 -nc, --no-cvs - don't download from CVS, if source URL is given,
83 -nu, --no-urls - don't try to download from FTP/HTTP location,
84 --opts - additional options for rpm
85 -q, --quiet - be quiet,
86 -r, --cvstag - build package using resources from specified CVS
88 -v, --verbose - be verbose,
95 if [ -n "$DEBUG" ]; then
100 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i "^Icon\:" > $SPECFILE.__
102 SOURCES="`rpm -bp --test --ignorearch $SPECFILE.__ 2>&1 | awk '/ SOURCEURL[0-9]+/ {print $3}'`"
103 PATCHES="`rpm -bp --test --ignorearch $SPECFILE.__ 2>&1 | awk '/ PATCHURL[0-9]+/ {print $3}'`"
104 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
105 PACKAGE_NAME="`rpm -bp --test --ignorearch $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
106 PACKAGE_VERSION="`rpm -bp --test --ignorearch $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
107 PACKAGE_RELEASE="`rpm -bp --test --ignorearch $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
111 if [ -n "$BE_VERBOSE" ]; then
112 echo "- Sources : `nourl $SOURCES`"
113 if [ -n "$PATCHES" ]; then
114 echo "- Patches : `nourl $PATCHES`"
116 echo "- Patches : *no patches needed*"
118 if [ -n "$ICONS" ]; then
119 echo "- Icon : `nourl $ICONS`"
121 echo "- Icon : *no package icon*"
123 echo "- Name : $PACKAGE_NAME"
124 echo "- Version : $PACKAGE_VERSION"
125 echo "- Release : $PACKAGE_RELEASE"
131 if [ -n "$DEBUG" ]; then
139 "err_no_spec_in_cmdl" )
140 echo "ERROR: spec file name not specified.";
142 "err_no_spec_in_repo" )
143 echo "Error: spec file not stored in CVS repo.";
145 "err_no_source_in_repo" )
146 echo "Error: some source, patch or icon files not stored in CVS repo.";
149 echo "Error: package build failed.";
156 if [ -n "$DEBUG" ]; then
161 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
162 SPECS_DIR="`rpm --eval "%{_specdir}"`"
169 if [ -n "$DEBUG" ]; then
178 if [ -n "$CVSROOT" ]; then
179 OPTIONS="-d $CVSROOT $OPTIONS"
181 if [ -n "$CVSTAG" ]; then
182 OPTIONS="$OPTIONS -r $CVSTAG"
184 OPTIONS="$OPTIONS -A"
187 cvs $OPTIONS $SPECFILE
188 if [ "$?" -ne "0" ]; then
189 Exit_error err_no_spec_in_repo;
191 if [ ! -f "$SPECFILE" ]; then
192 Exit_error err_no_spec_in_repo;
195 if [ "$CHMOD" = "yes" ]; then
203 if [ -n "$DEBUG" ]; then
208 if [ -n "$SOURCES$PATCHES$ICONS" ]; then
212 if [ -n "$CVSROOT" ]; then
213 OPTIONS="-d $CVSROOT $OPTIONS"
215 if [ -n "$CVSTAG" ]; then
216 OPTIONS="$OPTIONS -r $CVSTAG"
218 OPTIONS="$OPTIONS -A"
220 for i in $SOURCES $PATCHES $ICONS; do
221 if ! [ -r `nourl $i` ]
224 echo $i | grep -vE '(http|ftp|https|cvs)://' |\
225 grep -qE '\.(gz|bz2)$'
227 echo "Warning: no URL given for $i"
230 if [ -z "$NOCVS" ]||\
231 [ `echo $i | grep -vE '(ftp|http|https|cvs)://'` ]
233 cvs $OPTIONS `nourl $i`
236 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
237 [ `echo $i | grep -E 'ftp://|http://|https://'` ]
242 if [ ! -f "`nourl $i`" ]; then
243 Exit_error err_no_source_in_repo;
248 if [ "$CHMOD" = "yes" ]; then
249 chmod 444 `nourl $SOURCES $PATCHES $ICONS`
257 if [ -n "$DEBUG" ]; then
265 BUILD_SWITCH="-ba" ;;
267 BUILD_SWITCH="-bb" ;;
269 BUILD_SWITCH="-bs --nodeps" ;;
271 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $SPECFILE
273 if [ "$?" -ne "0" ]; then
274 Exit_error err_build_fail;
281 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
283 #---------------------------------------------
286 if [ "$#" = 0 ]; then
291 while test $# -gt 0 ; do
294 DEBUG="yes"; shift ;;
296 COMMAND="version"; shift ;;
298 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
300 COMMAND="build"; shift ;;
301 -bb | --build-binary )
302 COMMAND="build-binary"; shift ;;
303 -bs | --build-source )
304 COMMAND="build-source"; shift ;;
306 CLEAN="--clean --rmspec --rmsource"; shift ;;
308 shift; CVSROOT="${1}"; shift ;;
310 COMMAND="get"; shift ;;
312 COMMAND="usage"; shift ;;
314 shift; LOGFILE="${1}"; shift ;;
316 shift; DEF_NICE_LEVEL=${1}; shift ;;
318 COMMAND="mr-proper"; shift ;;
320 NOCVS="yes"; shift ;;
322 NOURLS="yes"; shift ;;
324 shift; RPMOPTS="${1}"; shift ;;
326 QUIET="--quiet"; shift ;;
328 shift; CVSTAG="${1}"; shift ;;
330 BE_VERBOSE="1"; shift ;;
332 SPECFILE="${1}"; shift ;;
336 if [ -n "$DEBUG" ]; then
342 "build" | "build-binary" | "build-source" )
344 if [ -n "$SPECFILE" ]; then
350 Exit_error err_no_spec_in_cmdl;
355 if [ -n "$SPECFILE" ]; then
360 Exit_error err_no_spec_in_cmdl;
364 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE