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"
25 CVSROOT=${CVSROOT:-""}
36 if [ -f ~/etc/builderrc ]; then
38 elif [ -f ~/.builderrc ]; then
42 #---------------------------------------------
47 if [ -n "$DEBUG" ]; then set -xv; fi
49 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
50 [--build] [-bb] [--build-binary] [-bs] [--build-source]
51 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
52 [-l <logfile>] [-m] [--mr-proper] [--logtofile <logfile>] [-q] [--quiet]
53 [-r <cvstag>] [--cvstag <cvstag>] [-u] [--no-urls] [-v] [--verbose]
56 -D, --debug - enable script debugging mode,
57 -V, --version - output builder version
58 -a, --as_anon - get files via pserver as cvs@anoncvs.pld.org.pl,
60 --build - get all files from CVS repo or HTTP/FTP and build
61 package from <package>.spec,
63 --build-binary - get all files from CVS repo or HTTP/FTP and build
64 binary only package from <package>.spec,
66 --build-source - get all files from CVS repo or HTTP/FTP and only
67 pack them into src.rpm,
68 -c, --clean - clean all temporarily created files (in BUILD,
69 SOURCES, SPECS and \$RPM_BUILD_ROOT),
70 SOURCES, SPECS and \$RPM_BUILD_ROOT),
71 -d, --cvsroot - setup \$CVSROOT,
72 -g, --get - get <package>.spec and all related files from
74 -h, --help - this message,
75 -l, --logtofile - log all to file,
76 -m, --mr-proper - only remove all files relayted to spec file and
78 -q, --quiet - be quiet,
79 -r, --cvstag - build package using resources from specified CVS
81 -u, --no-urls - try to get sources only from CVS repo,
82 -v, --verbose - be verbose,
89 if [ -n "$DEBUG" ]; then set -xv; fi
91 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i "^Icon\:" > $SPECFILE.__
93 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCEURL[0-9]+/ {print $3}'`"
94 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCHURL[0-9]+/ {print $3}'`"
95 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
96 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
97 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
98 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
102 if [ -n "$BE_VERBOSE" ]; then
103 echo "- Sources : `nourl $SOURCES`"
104 if [ -n "$PATCHES" ]; then
105 echo "- Patches : `nourl $PATCHES`"
107 echo "- Patches : *no patches needed*"
109 if [ -n "$ICONS" ]; then
110 echo "- Icon : `nourl $ICONS`"
112 echo "- Icon : *no package icon*"
114 echo "- Name : $PACKAGE_NAME"
115 echo "- Version : $PACKAGE_VERSION"
116 echo "- Release : $PACKAGE_RELEASE"
122 if [ -n "$DEBUG" ]; then set -xv; fi
127 "err_no_spec_in_cmdl" )
128 echo "ERROR: spec file name not specified.";
130 "err_no_spec_in_repo" )
131 echo "Error: spec file not stored in CVS repo.";
133 "err_no_source_in_repo" )
134 echo "Error: some source, patch or icon files not stored in CVS repo.";
137 echo "Error: package build failed.";
144 if [ -n "$DEBUG" ]; then set -xv; fi
146 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
147 SPECS_DIR="`rpm --eval "%{_specdir}"`"
154 if [ -n "$DEBUG" ]; then set -xv; fi
160 if [ -n "$CVSROOT" ]; then
161 OPTIONS="-d $CVSROOT $OPTIONS"
163 if [ -n "$CVSTAG" ]; then
164 OPTIONS="$OPTIONS -r $CVSTAG"
166 OPTIONS="$OPTIONS -A"
169 cvs $OPTIONS $SPECFILE
170 if [ "$?" -ne "0" ]; then
171 Exit_error err_no_spec_in_repo;
173 if [ ! -f "$SPECFILE" ]; then
174 Exit_error err_no_spec_in_repo;
177 if [ "$CHMOD" = "yes" ]; then
185 if [ -n "$DEBUG" ]; then set -xv; fi
187 if [ -n "$SOURCES$PATCHES$ICONS" ]; then
191 if [ -n "$CVSROOT" ]; then
192 OPTIONS="-d $CVSROOT $OPTIONS"
194 if [ -n "$CVSTAG" ]; then
195 OPTIONS="$OPTIONS -r $CVSTAG"
197 OPTIONS="$OPTIONS -A"
200 cvs $OPTIONS `nourl $SOURCES $PATCHES $ICONS`
202 if [ -z "$NOURLS" ]; then
203 for i in $SOURCES $PATCHES $ICONS; do
204 if [ ! -f "`nourl $i`" ]&&\
205 [ `echo $i | grep 'ftp://\|http://'` ]; then
211 for i in $SOURCES $PATCHES $ICONS; do
212 if [ ! -f "`nourl $i`" ]; then
213 Exit_error err_no_source_in_repo;
217 if [ "$CHMOD" = "yes" ]; then
218 chmod 444 `nourl $SOURCES $PATCHES $ICONS`
226 if [ -n "$DEBUG" ]; then set -xv; fi
231 BUILD_SWITCH="-ba" ;;
233 BUILD_SWITCH="-bb" ;;
235 BUILD_SWITCH="-bs" ;;
237 rpm $BUILD_SWITCH -v $QUIET $CLEAN $SPECFILE
239 if [ "$?" -ne "0" ]; then
240 Exit_error err_build_fail;
247 echo "$@" | sed 's#\<\(ftp\|http\)://.*/##g'
249 #---------------------------------------------
252 if [ "$#" = 0 ]; then
257 while test $# -gt 0 ; do
260 DEBUG="yes"; shift ;;
262 COMMAND="version"; shift ;;
264 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
266 COMMAND="build"; shift ;;
267 -bb | --build-binary )
268 COMMAND="build-binary"; shift ;;
269 -bs | --build-source )
270 COMMAND="build-source"; shift ;;
272 CLEAN="--clean --rmspec --rmsource"; shift ;;
274 shift; CVSROOT="${1}"; shift ;;
276 COMMAND="get"; shift ;;
278 COMMAND="usage"; shift ;;
280 shift; LOGFILE="${1}"; shift ;;
282 COMMAND="mr-proper"; shift ;;
284 QUIET="--quiet"; shift ;;
286 shift; CVSTAG="${1}"; shift ;;
288 BE_VERBOSE="1"; shift ;;
290 NOURLS="yes"; shift ;;
292 SPECFILE="${1}"; shift ;;
296 if [ -n "$DEBUG" ]; then set -xv; fi
299 "build" | "build-binary" | "build-source" )
301 if [ -n "$SPECFILE" ]; then
307 Exit_error err_no_spec_in_cmdl;
312 if [ -n "$SPECFILE" ]; then
317 Exit_error err_no_spec_in_cmdl;
321 rpm --clean --rmsource --rmspec --force --nodeps $SPECFILE