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 -v, --verbose - be verbose,
100 if [ -n "$DEBUG" ]; then
107 if [ "$NOSRCS" != "yes" ]; then
108 SOURCES="`rpm -bp --nobuild --define "prep %dump" $SPECFILE 2>&1 | awk '/SOURCEURL[0-9]+/ {print $3}'`"
111 PATCHES="`rpm -bp --nobuild --define "prep %dump" $SPECFILE 2>&1 | awk '/PATCHURL[0-9]+/ {print $3}'`"
112 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
113 PACKAGE_NAME="`rpm -bp --nobuild $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
114 PACKAGE_VERSION="`rpm -bp --nobuild $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
115 PACKAGE_RELEASE="`rpm -bp --nobuild $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
117 if [ -n "$BE_VERBOSE" ]; then
118 echo "- Sources : `nourl $SOURCES`"
119 if [ -n "$PATCHES" ]; then
120 echo "- Patches : `nourl $PATCHES`"
122 echo "- Patches : *no patches needed*"
124 if [ -n "$ICONS" ]; then
125 echo "- Icon : `nourl $ICONS`"
127 echo "- Icon : *no package icon*"
129 echo "- Name : $PACKAGE_NAME"
130 echo "- Version : $PACKAGE_VERSION"
131 echo "- Release : $PACKAGE_RELEASE"
137 if [ -n "$DEBUG" ]; then
145 "err_no_spec_in_cmdl" )
146 echo "ERROR: spec file name not specified.";
148 "err_no_spec_in_repo" )
149 echo "Error: spec file not stored in CVS repo.";
151 "err_no_source_in_repo" )
152 echo "Error: some source, patch or icon files not stored in CVS repo.";
155 echo "Error: package build failed.";
162 if [ -n "$DEBUG" ]; then
167 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
168 SPECS_DIR="`rpm --eval "%{_specdir}"`"
175 if [ -n "$DEBUG" ]; then
184 if [ -n "$CVSROOT" ]; then
185 OPTIONS="-d $CVSROOT $OPTIONS"
187 if [ -n "$CVSTAG" ]; then
188 OPTIONS="$OPTIONS -r $CVSTAG"
190 OPTIONS="$OPTIONS -A"
193 cvs $OPTIONS $SPECFILE
194 if [ "$?" -ne "0" ]; then
195 Exit_error err_no_spec_in_repo;
197 if [ ! -f "$SPECFILE" ]; then
198 Exit_error err_no_spec_in_repo;
201 if [ "$CHMOD" = "yes" ]; then
211 if [ -n "$DEBUG" ]; then
216 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
220 if [ -n "$CVSROOT" ]; then
221 OPTIONS="-d $CVSROOT $OPTIONS"
223 if [ -n "$CVSTAG" ]; then
224 OPTIONS="$OPTIONS -r $CVSTAG"
226 OPTIONS="$OPTIONS -A"
228 for i in $GET_FILES; do
229 if [ ! -f `nourl $i` ] || [ $ALLWAYS_CVSUP = "yes" ]
232 echo $i | grep -vE '(http|ftp|https|cvs)://' |\
233 grep -qE '\.(gz|bz2)$'
235 echo "Warning: no URL given for $i"
238 if [ -z "$NOCVS" ]||\
239 [ `echo $i | grep -vE '(ftp|http|https)://'` ]
241 cvs $OPTIONS `nourl $i`
244 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
245 [ `echo $i | grep -E 'ftp://|http://|https://'` ]
250 if [ ! -f "`nourl $i`" ]; then
251 Exit_error err_no_source_in_repo;
256 if [ "$CHMOD" = "yes" ]; then
257 chmod 444 `nourl $GET_FILES`
265 if [ -n "$DEBUG" ]; then
273 BUILD_SWITCH="-ba" ;;
275 BUILD_SWITCH="-bb" ;;
277 BUILD_SWITCH="-bs --nodeps" ;;
279 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $SPECFILE
281 if [ "$?" -ne "0" ]; then
282 Exit_error err_build_fail;
289 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
291 #---------------------------------------------
294 if [ "$#" = 0 ]; then
299 while test $# -gt 0 ; do
302 DEBUG="yes"; shift ;;
304 COMMAND="version"; shift ;;
306 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
308 COMMAND="build"; shift ;;
309 -bb | --build-binary )
310 COMMAND="build-binary"; shift ;;
311 -bs | --build-source )
312 COMMAND="build-source"; shift ;;
314 CLEAN="--clean --rmspec --rmsource"; shift ;;
316 shift; CVSROOT="${1}"; shift ;;
318 COMMAND="get"; shift ;;
320 COMMAND="usage"; shift ;;
322 shift; LOGFILE="${1}"; shift ;;
324 shift; DEF_NICE_LEVEL=${1}; shift ;;
326 COMMAND="mr-proper"; shift ;;
328 NOCVS="yes"; shift ;;
330 NOURLS="yes"; shift ;;
332 NOSRCS="yes"; shift ;;
334 shift; RPMOPTS="${1}"; shift ;;
336 QUIET="--quiet"; shift ;;
338 shift; CVSTAG="${1}"; shift ;;
340 BE_VERBOSE="1"; shift ;;
342 SPECFILE="${1}"; shift ;;
346 if [ -n "$DEBUG" ]; then
352 "build" | "build-binary" | "build-source" )
354 if [ -n "$SPECFILE" ]; then
357 if [ -n "$ICONS" ]; then
361 get_files "$SOURCES $PATCHES";
364 Exit_error err_no_spec_in_cmdl;
369 if [ -n "$SPECFILE" ]; then
372 if [ -n "$ICONS" ]; then
376 get_files "$SOURCES $PATCHES"
378 Exit_error err_no_spec_in_cmdl;
382 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE
393 # Revision 1.70 2001/03/03 19:55:42 misiek
394 # workaround for problems with rpm when icons isn't cvs up'ed