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 if [ -f ~/etc/builderrc ]; then
43 elif [ -f ~/.builderrc ]; then
47 #---------------------------------------------
52 if [ -n "$DEBUG" ]; then set -xv; fi
54 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
55 [--build] [-bb] [--build-binary] [-bs] [--build-source]
56 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
57 [-l <logfile>] [-m] [--mr-proper] [--logtofile <logfile>] [-q] [--quiet]
58 [-r <cvstag>] [--cvstag <cvstag>] [-u] [--no-urls] [-v] [--verbose]
59 [--opts <rpm opts>] <package>.spec
61 -D, --debug - enable script debugging mode,
62 -V, --version - output builder version
63 -a, --as_anon - get files via pserver as cvs@anoncvs.pld.org.pl,
65 --build - get all files from CVS repo or HTTP/FTP and build
66 package from <package>.spec,
68 --build-binary - get all files from CVS repo or HTTP/FTP and build
69 binary only package from <package>.spec,
71 --build-source - get all files from CVS repo or HTTP/FTP and only
72 pack them into src.rpm,
73 -c, --clean - clean all temporarily created files (in BUILD,
74 SOURCES, SPECS and \$RPM_BUILD_ROOT),
75 SOURCES, SPECS and \$RPM_BUILD_ROOT),
76 -d, --cvsroot - setup \$CVSROOT,
77 -g, --get - get <package>.spec and all related files from
79 -h, --help - this message,
80 -l, --logtofile - log all to file,
81 -m, --mr-proper - only remove all files related to spec file and
83 -nc, --no-cvs - don't download from CVS, if source URL is given,
84 -nu, --no-urls - don't try to download from FTP/HTTP location,
85 --opts - additional options for rpm
86 -q, --quiet - be quiet,
87 -r, --cvstag - build package using resources from specified CVS
89 -v, --verbose - be verbose,
96 if [ -n "$DEBUG" ]; then
101 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i "^Icon\:" > $SPECFILE.__
103 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCEURL[0-9]+/ {print $3}'`"
104 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCHURL[0-9]+/ {print $3}'`"
105 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
106 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
107 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
108 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
112 if [ -n "$BE_VERBOSE" ]; then
113 echo "- Sources : `nourl $SOURCES`"
114 if [ -n "$PATCHES" ]; then
115 echo "- Patches : `nourl $PATCHES`"
117 echo "- Patches : *no patches needed*"
119 if [ -n "$ICONS" ]; then
120 echo "- Icon : `nourl $ICONS`"
122 echo "- Icon : *no package icon*"
124 echo "- Name : $PACKAGE_NAME"
125 echo "- Version : $PACKAGE_VERSION"
126 echo "- Release : $PACKAGE_RELEASE"
132 if [ -n "$DEBUG" ]; then
140 "err_no_spec_in_cmdl" )
141 echo "ERROR: spec file name not specified.";
143 "err_no_spec_in_repo" )
144 echo "Error: spec file not stored in CVS repo.";
146 "err_no_source_in_repo" )
147 echo "Error: some source, patch or icon files not stored in CVS repo.";
150 echo "Error: package build failed.";
157 if [ -n "$DEBUG" ]; then
162 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
163 SPECS_DIR="`rpm --eval "%{_specdir}"`"
170 if [ -n "$DEBUG" ]; then
179 if [ -n "$CVSROOT" ]; then
180 OPTIONS="-d $CVSROOT $OPTIONS"
182 if [ -n "$CVSTAG" ]; then
183 OPTIONS="$OPTIONS -r $CVSTAG"
185 OPTIONS="$OPTIONS -A"
188 cvs $OPTIONS $SPECFILE
189 if [ "$?" -ne "0" ]; then
190 Exit_error err_no_spec_in_repo;
192 if [ ! -f "$SPECFILE" ]; then
193 Exit_error err_no_spec_in_repo;
196 if [ "$CHMOD" = "yes" ]; then
204 if [ -n "$DEBUG" ]; then
209 if [ -n "$SOURCES$PATCHES$ICONS" ]; then
213 if [ -n "$CVSROOT" ]; then
214 OPTIONS="-d $CVSROOT $OPTIONS"
216 if [ -n "$CVSTAG" ]; then
217 OPTIONS="$OPTIONS -r $CVSTAG"
219 OPTIONS="$OPTIONS -A"
221 for i in $SOURCES $PATCHES $ICONS; do
222 if [ ! -f `nourl $i` ] || [ $ALLWAYS_CVSUP = "yes" ]
225 echo $i | grep -vE '(http|ftp|https|cvs)://' |\
226 grep -qE '\.(gz|bz2)$'
228 echo "Warning: no URL given for $i"
231 if [ -z "$NOCVS" ]||\
232 [ `echo $i | grep -vE '(ftp|http|https)://'` ]
234 cvs $OPTIONS `nourl $i`
237 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
238 [ `echo $i | grep -E 'ftp://|http://|https://'` ]
243 if [ ! -f "`nourl $i`" ]; then
244 Exit_error err_no_source_in_repo;
249 if [ "$CHMOD" = "yes" ]; then
250 chmod 444 `nourl $SOURCES $PATCHES $ICONS`
258 if [ -n "$DEBUG" ]; then
266 BUILD_SWITCH="-ba" ;;
268 BUILD_SWITCH="-bb" ;;
270 BUILD_SWITCH="-bs --nodeps" ;;
272 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $SPECFILE
274 if [ "$?" -ne "0" ]; then
275 Exit_error err_build_fail;
282 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
284 #---------------------------------------------
287 if [ "$#" = 0 ]; then
292 while test $# -gt 0 ; do
295 DEBUG="yes"; shift ;;
297 COMMAND="version"; shift ;;
299 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
301 COMMAND="build"; shift ;;
302 -bb | --build-binary )
303 COMMAND="build-binary"; shift ;;
304 -bs | --build-source )
305 COMMAND="build-source"; shift ;;
307 CLEAN="--clean --rmspec --rmsource"; shift ;;
309 shift; CVSROOT="${1}"; shift ;;
311 COMMAND="get"; shift ;;
313 COMMAND="usage"; shift ;;
315 shift; LOGFILE="${1}"; shift ;;
317 shift; DEF_NICE_LEVEL=${1}; shift ;;
319 COMMAND="mr-proper"; shift ;;
321 NOCVS="yes"; shift ;;
323 NOURLS="yes"; shift ;;
325 shift; RPMOPTS="${1}"; shift ;;
327 QUIET="--quiet"; shift ;;
329 shift; CVSTAG="${1}"; shift ;;
331 BE_VERBOSE="1"; shift ;;
333 SPECFILE="${1}"; shift ;;
337 if [ -n "$DEBUG" ]; then
343 "build" | "build-binary" | "build-source" )
345 if [ -n "$SPECFILE" ]; then
351 Exit_error err_no_spec_in_cmdl;
356 if [ -n "$SPECFILE" ]; then
361 Exit_error err_no_spec_in_cmdl;
365 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE