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:-""}
39 if [ -f ~/etc/builderrc ]; then
41 elif [ -f ~/.builderrc ]; then
45 #---------------------------------------------
50 if [ -n "$DEBUG" ]; then set -xv; fi
52 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
53 [--build] [-bb] [--build-binary] [-bs] [--build-source]
54 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
55 [-l <logfile>] [-m] [--mr-proper] [--logtofile <logfile>] [-q] [--quiet]
56 [-r <cvstag>] [--cvstag <cvstag>] [-u] [--no-urls] [-v] [--verbose]
59 -D, --debug - enable script debugging mode,
60 -V, --version - output builder version
61 -a, --as_anon - get files via pserver as cvs@anoncvs.pld.org.pl,
63 --build - get all files from CVS repo or HTTP/FTP and build
64 package from <package>.spec,
66 --build-binary - get all files from CVS repo or HTTP/FTP and build
67 binary only package from <package>.spec,
69 --build-source - get all files from CVS repo or HTTP/FTP and only
70 pack them into src.rpm,
71 -c, --clean - clean all temporarily created files (in BUILD,
72 SOURCES, SPECS and \$RPM_BUILD_ROOT),
73 SOURCES, SPECS and \$RPM_BUILD_ROOT),
74 -d, --cvsroot - setup \$CVSROOT,
75 -g, --get - get <package>.spec and all related files from
77 -h, --help - this message,
78 -l, --logtofile - log all to file,
79 -m, --mr-proper - only remove all files related to spec file and
81 -nc, --no-cvs - don't download from CVS, if source URL is given,
82 -nu, --no-urls - don't try to download from FTP/HTTP location,
83 -q, --quiet - be quiet,
84 -r, --cvstag - build package using resources from specified CVS
86 -v, --verbose - be verbose,
93 if [ -n "$DEBUG" ]; then
98 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i "^Icon\:" > $SPECFILE.__
100 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCEURL[0-9]+/ {print $3}'`"
101 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCHURL[0-9]+/ {print $3}'`"
102 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
103 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
104 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
105 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
109 if [ -n "$BE_VERBOSE" ]; then
110 echo "- Sources : `nourl $SOURCES`"
111 if [ -n "$PATCHES" ]; then
112 echo "- Patches : `nourl $PATCHES`"
114 echo "- Patches : *no patches needed*"
116 if [ -n "$ICONS" ]; then
117 echo "- Icon : `nourl $ICONS`"
119 echo "- Icon : *no package icon*"
121 echo "- Name : $PACKAGE_NAME"
122 echo "- Version : $PACKAGE_VERSION"
123 echo "- Release : $PACKAGE_RELEASE"
129 if [ -n "$DEBUG" ]; then
137 "err_no_spec_in_cmdl" )
138 echo "ERROR: spec file name not specified.";
140 "err_no_spec_in_repo" )
141 echo "Error: spec file not stored in CVS repo.";
143 "err_no_source_in_repo" )
144 echo "Error: some source, patch or icon files not stored in CVS repo.";
147 echo "Error: package build failed.";
154 if [ -n "$DEBUG" ]; then
159 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
160 SPECS_DIR="`rpm --eval "%{_specdir}"`"
167 if [ -n "$DEBUG" ]; then
176 if [ -n "$CVSROOT" ]; then
177 OPTIONS="-d $CVSROOT $OPTIONS"
179 if [ -n "$CVSTAG" ]; then
180 OPTIONS="$OPTIONS -r $CVSTAG"
182 OPTIONS="$OPTIONS -A"
185 cvs $OPTIONS $SPECFILE
186 if [ "$?" -ne "0" ]; then
187 Exit_error err_no_spec_in_repo;
189 if [ ! -f "$SPECFILE" ]; then
190 Exit_error err_no_spec_in_repo;
193 if [ "$CHMOD" = "yes" ]; then
201 if [ -n "$DEBUG" ]; then
206 if [ -n "$SOURCES$PATCHES$ICONS" ]; then
210 if [ -n "$CVSROOT" ]; then
211 OPTIONS="-d $CVSROOT $OPTIONS"
213 if [ -n "$CVSTAG" ]; then
214 OPTIONS="$OPTIONS -r $CVSTAG"
216 OPTIONS="$OPTIONS -A"
218 for i in $SOURCES $PATCHES $ICONS; do
219 if ! [ -r `nourl $i` ]
222 echo $i | grep -vE '(http|ftp|https|cvs)://' |\
223 grep -qE '\.(gz|bz2)$'
225 echo "Warning: no URL given for $i"
228 if [ -z "$NOCVS" ]||\
229 [ `echo $i | grep -vE '(ftp|http|https|cvs)://'` ]
231 cvs $OPTIONS `nourl $i`
234 if [ -z "$NOURLS" ]&&[ ! -f "`nourl $i`" ]&&\
235 [ `echo $i | grep -E 'ftp://|http://|https://'` ]
240 if [ ! -f "`nourl $i`" ]; then
241 Exit_error err_no_source_in_repo;
246 if [ "$CHMOD" = "yes" ]; then
247 chmod 444 `nourl $SOURCES $PATCHES $ICONS`
255 if [ -n "$DEBUG" ]; then
263 BUILD_SWITCH="-ba" ;;
265 BUILD_SWITCH="-bb" ;;
267 BUILD_SWITCH="-bs --nodeps" ;;
269 nice -n ${DEF_NICE_LEVEL} rpm $BUILD_SWITCH -v $QUIET $CLEAN $SPECFILE
271 if [ "$?" -ne "0" ]; then
272 Exit_error err_build_fail;
279 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\)://.*/##g'
281 #---------------------------------------------
284 if [ "$#" = 0 ]; then
289 while test $# -gt 0 ; do
292 DEBUG="yes"; shift ;;
294 COMMAND="version"; shift ;;
296 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
298 COMMAND="build"; shift ;;
299 -bb | --build-binary )
300 COMMAND="build-binary"; shift ;;
301 -bs | --build-source )
302 COMMAND="build-source"; shift ;;
304 CLEAN="--clean --rmspec --rmsource"; shift ;;
306 shift; CVSROOT="${1}"; shift ;;
308 COMMAND="get"; shift ;;
310 COMMAND="usage"; shift ;;
312 shift; LOGFILE="${1}"; shift ;;
314 shift; DEF_NICE_LEVEL=${1}; shift ;;
316 COMMAND="mr-proper"; shift ;;
318 NOCVS="yes"; shift ;;
320 NOURLS="yes"; shift ;;
322 QUIET="--quiet"; shift ;;
324 shift; CVSTAG="${1}"; shift ;;
326 BE_VERBOSE="1"; shift ;;
328 SPECFILE="${1}"; shift ;;
332 if [ -n "$DEBUG" ]; then
338 "build" | "build-binary" | "build-source" )
340 if [ -n "$SPECFILE" ]; then
346 Exit_error err_no_spec_in_cmdl;
351 if [ -n "$SPECFILE" ]; then
356 Exit_error err_no_spec_in_cmdl;
360 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE