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:-""}
37 if [ -f ~/etc/builderrc ]; then
39 elif [ -f ~/.builderrc ]; then
43 #---------------------------------------------
48 if [ -n "$DEBUG" ]; then set -xv; fi
50 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
51 [--build] [-bb] [--build-binary] [-bs] [--build-source]
52 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
53 [-l <logfile>] [-m] [--mr-proper] [--logtofile <logfile>] [-q] [--quiet]
54 [-r <cvstag>] [--cvstag <cvstag>] [-u] [--no-urls] [-v] [--verbose]
57 -D, --debug - enable script debugging mode,
58 -V, --version - output builder version
59 -a, --as_anon - get files via pserver as cvs@anoncvs.pld.org.pl,
61 --build - get all files from CVS repo or HTTP/FTP and build
62 package from <package>.spec,
64 --build-binary - get all files from CVS repo or HTTP/FTP and build
65 binary only package from <package>.spec,
67 --build-source - get all files from CVS repo or HTTP/FTP and only
68 pack them into src.rpm,
69 -c, --clean - clean all temporarily created files (in BUILD,
70 SOURCES, SPECS and \$RPM_BUILD_ROOT),
71 SOURCES, SPECS and \$RPM_BUILD_ROOT),
72 -d, --cvsroot - setup \$CVSROOT,
73 -g, --get - get <package>.spec and all related files from
75 -h, --help - this message,
76 -l, --logtofile - log all to file,
77 -m, --mr-proper - only remove all files relayted to spec file and
79 -nc, --no-cvs - don't download from CVS, if source URL is given,
80 -nu, --no-urls - don't try to download from FTP/HTTP location,
81 -q, --quiet - be quiet,
82 -r, --cvstag - build package using resources from specified CVS
84 -v, --verbose - be verbose,
91 if [ -n "$DEBUG" ]; then
96 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i "^Icon\:" > $SPECFILE.__
98 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCEURL[0-9]+/ {print $3}'`"
99 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCHURL[0-9]+/ {print $3}'`"
100 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
101 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
102 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
103 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
107 if [ -n "$BE_VERBOSE" ]; then
108 echo "- Sources : `nourl $SOURCES`"
109 if [ -n "$PATCHES" ]; then
110 echo "- Patches : `nourl $PATCHES`"
112 echo "- Patches : *no patches needed*"
114 if [ -n "$ICONS" ]; then
115 echo "- Icon : `nourl $ICONS`"
117 echo "- Icon : *no package icon*"
119 echo "- Name : $PACKAGE_NAME"
120 echo "- Version : $PACKAGE_VERSION"
121 echo "- Release : $PACKAGE_RELEASE"
127 if [ -n "$DEBUG" ]; then
135 "err_no_spec_in_cmdl" )
136 echo "ERROR: spec file name not specified.";
138 "err_no_spec_in_repo" )
139 echo "Error: spec file not stored in CVS repo.";
141 "err_no_source_in_repo" )
142 echo "Error: some source, patch or icon files not stored in CVS repo.";
145 echo "Error: package build failed.";
152 if [ -n "$DEBUG" ]; then
157 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
158 SPECS_DIR="`rpm --eval "%{_specdir}"`"
165 if [ -n "$DEBUG" ]; then
174 if [ -n "$CVSROOT" ]; then
175 OPTIONS="-d $CVSROOT $OPTIONS"
177 if [ -n "$CVSTAG" ]; then
178 OPTIONS="$OPTIONS -r $CVSTAG"
180 OPTIONS="$OPTIONS -A"
183 cvs $OPTIONS $SPECFILE
184 if [ "$?" -ne "0" ]; then
185 Exit_error err_no_spec_in_repo;
187 if [ ! -f "$SPECFILE" ]; then
188 Exit_error err_no_spec_in_repo;
191 if [ "$CHMOD" = "yes" ]; then
199 if [ -n "$DEBUG" ]; then
204 if [ -n "$SOURCES$PATCHES$ICONS" ]; then
208 if [ -n "$CVSROOT" ]; then
209 OPTIONS="-d $CVSROOT $OPTIONS"
211 if [ -n "$CVSTAG" ]; then
212 OPTIONS="$OPTIONS -r $CVSTAG"
214 OPTIONS="$OPTIONS -A"
216 for i in $SOURCES $PATCHES $ICONS; do
218 echo $i | egrep -v '(http|ftp)://' |\
219 egrep -q '\.(gz|bz2)$'
221 echo "Warning: no URL given for $i"
224 if [ -z "$NOCVS" ]||\
225 [ `echo $i | egrep -v 'ftp://|http://'` ]
227 cvs $OPTIONS `nourl $i`
230 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
231 [ `echo $i | egrep 'ftp://|http://'` ]
236 if [ ! -f "`nourl $i`" ]; then
237 Exit_error err_no_source_in_repo;
241 if [ "$CHMOD" = "yes" ]; then
242 chmod 444 `nourl $SOURCES $PATCHES $ICONS`
250 if [ -n "$DEBUG" ]; then
258 BUILD_SWITCH="-ba" ;;
260 BUILD_SWITCH="-bb" ;;
262 BUILD_SWITCH="-bs" ;;
264 rpm $BUILD_SWITCH -v $QUIET $CLEAN $SPECFILE
266 if [ "$?" -ne "0" ]; then
267 Exit_error err_build_fail;
274 echo "$@" | sed 's#\<\(ftp\|http\)://.*/##g'
276 #---------------------------------------------
279 if [ "$#" = 0 ]; then
284 while test $# -gt 0 ; do
287 DEBUG="yes"; shift ;;
289 COMMAND="version"; shift ;;
291 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
293 COMMAND="build"; shift ;;
294 -bb | --build-binary )
295 COMMAND="build-binary"; shift ;;
296 -bs | --build-source )
297 COMMAND="build-source"; shift ;;
299 CLEAN="--clean --rmspec --rmsource"; shift ;;
301 shift; CVSROOT="${1}"; shift ;;
303 COMMAND="get"; shift ;;
305 COMMAND="usage"; shift ;;
307 shift; LOGFILE="${1}"; shift ;;
309 COMMAND="mr-proper"; shift ;;
311 NOCVS="yes"; shift ;;
313 NOURLS="yes"; shift ;;
315 QUIET="--quiet"; shift ;;
317 shift; CVSTAG="${1}"; shift ;;
319 BE_VERBOSE="1"; shift ;;
321 SPECFILE="${1}"; shift ;;
325 if [ -n "$DEBUG" ]; then
331 "build" | "build-binary" | "build-source" )
333 if [ -n "$SPECFILE" ]; then
339 Exit_error err_no_spec_in_cmdl;
344 if [ -n "$SPECFILE" ]; then
349 Exit_error err_no_spec_in_cmdl;
353 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE