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.7 (C) 1999 Tomasz K³oczko".
15 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
25 CVSROOT=${CVSROOT:-""}
36 if [ -f ~/.builderrc ]; then
40 #---------------------------------------------
45 if [ -n "$DEBUG" ]; then set -xv; fi
47 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
48 [--build] [-bb] [--build-binary] [-bs] [--build-source] [-d <cvsroot>]
49 [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help] [-l <logfile>]
50 [--logtofile <logfile>] [-q] [--quiet] [-r <cvstag>]
51 [--cvstag <cvstag>] [-v] [--verbose] <package>.spec
53 -D, --debug - enable script debugging mode,
54 -V, --version - output builder version
55 -a, --as_anon - get files via pserver as cvs@anoncvs.pld.org.pl,
57 --build - get all files from CVS repo or HTTP/FTP and build
58 package from <package>.spec,
60 --build-binary - get all files from CVS repo or HTTP/FTP and build
61 binary only package from <package>.spec,
63 --build-source - get all files from CVS repo or HTTP/FTP and only
64 pack them into src.rpm,
65 -c, --clean - clean all temporarily created files (in BUILD,
66 SOURCES, SPECS and \$RPM_BUILD_ROOT),
67 SOURCES, SPECS and \$RPM_BUILD_ROOT),
68 -d, --cvsroot - setup \$CVSROOT,
69 -g, --get - get <package>.spec and all related files from
71 -h, --help - this message,
72 -l, --logtofile - log all to file,
73 -q, --quiet - be quiet,
74 -r, --cvstag - build package using resources from specified CVS
76 -u, --no_urls - try to get sources only from CVS repo,
77 -v, --verbose - be verbose,
84 if [ -n "$DEBUG" ]; then set -xv; fi
86 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i "^Icon\:" > $SPECFILE.__
88 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCEURL[0-9]+/ {print $3}'`"
89 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCHURL[0-9]+/ {print $3}'`"
90 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
91 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
92 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
93 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
97 if [ -n "$BE_VERBOSE" ]; then
98 echo "- Sources : `nourl $SOURCES`"
99 if [ -n "$PATCHES" ]; then
100 echo "- Patches : `nourl $PATCHES`"
102 echo "- Patches : *no patches needed*"
104 if [ -n "$ICONS" ]; then
105 echo "- Icon : `nourl $ICONS`"
107 echo "- Icon : *no package icon*"
109 echo "- Name : $PACKAGE_NAME"
110 echo "- Version : $PACKAGE_VERSION"
111 echo "- Release : $PACKAGE_RELEASE"
117 if [ -n "$DEBUG" ]; then set -xv; fi
122 "err_no_spec_in_cmdl" )
123 echo "ERROR: spec file name not specified.";
125 "err_no_spec_in_repo" )
126 echo "Error: spec file not stored in CVS repo.";
128 "err_no_source_in_repo" )
129 echo "Error: some source, patch or icon files not stored in CVS repo.";
132 echo "Error: package build failed.";
139 if [ -n "$DEBUG" ]; then set -xv; fi
141 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
142 SPECS_DIR="`rpm --eval "%{_specdir}"`"
149 if [ -n "$DEBUG" ]; then set -xv; fi
155 if [ -n "$CVSROOT" ]; then
156 OPTIONS="-d $CVSROOT $OPTIONS"
158 if [ -n "$CVSTAG" ]; then
159 OPTIONS="$OPTIONS -r $CVSTAG"
161 OPTIONS="$OPTIONS -A"
164 cvs $OPTIONS $SPECFILE
165 if [ "$?" -ne "0" ]; then
166 Exit_error err_no_spec_in_repo;
168 if [ ! -f "$SPECFILE" ]; then
169 Exit_error err_no_spec_in_repo;
172 if [ "$CHMODE" = "yes" ]; then
180 if [ -n "$DEBUG" ]; then set -xv; fi
182 if [ -n "$SOURCES$PATCHES$ICONS" ]; then
186 if [ -n "$CVSROOT" ]; then
187 OPTIONS="-d $CVSROOT $OPTIONS"
189 if [ -n "$CVSTAG" ]; then
190 OPTIONS="$OPTIONS -r $CVSTAG"
192 OPTIONS="$OPTIONS -A"
195 cvs $OPTIONS `nourl $SOURCES $PATCHES $ICONS`
197 if [ -z "$NOURLS" ]; then
198 for i in $SOURCES $PATCHES $ICONS; do
199 if [ ! -f "`nourl $i`" ]&&\
200 [ `echo $i | grep 'ftp://\|http://'` ]; then
206 for i in $SOURCES $PATCHES $ICONS; do
207 if [ ! -f "`nourl $i`" ]; then
208 Exit_error err_no_source_in_repo;
212 if [ "$CHMOD" = "yes" ]; then
213 chmod 444 `nourl $SOURCES $PATCHES $ICONS`
221 if [ -n "$DEBUG" ]; then set -xv; fi
226 BUILD_SWITCH="-ba" ;;
228 BUILD_SWITCH="-bb" ;;
230 BUILD_SWITCH="-bs" ;;
232 rpm $BUILD_SWITCH -v $QUIET $CLEAN $SPECFILE
234 if [ "$?" -ne "0" ]; then
235 Exit_error err_build_fail;
242 echo "$@" | sed 's#\<\(ftp\|http\)://.*/##g'
244 #---------------------------------------------
247 if [ "$#" = 0 ]; then
252 while test $# -gt 0 ; do
255 DEBUG="yes"; shift ;;
257 COMMAND="version"; shift ;;
259 CVSROOT=":pserver:cvs@anoncvs.pld.org.pl:/cvsroot"; shift ;;
261 COMMAND="build"; shift ;;
262 -bb | --build-binary )
263 COMMAND="build-binary"; shift ;;
264 -bs | --build-source )
265 COMMAND="build-source"; shift ;;
267 CLEAN="--clean --rmspec --rmsource"; shift ;;
269 shift; CVSROOT="${1}"; shift ;;
271 COMMAND="get"; shift ;;
273 COMMAND="usage"; shift ;;
275 shift; LOGFILE="${1}"; shift ;;
277 QUIET="--quiet"; shift ;;
279 shift; CVSTAG="${1}"; shift ;;
281 BE_VERBOSE="1"; shift ;;
283 NOURLS="yes"; shift ;;
285 SPECFILE="${1}"; shift ;;
289 if [ -n "$DEBUG" ]; then set -xv; fi
292 "build" | "build-binary" | "build-source" )
294 if [ -n "$SPECFILE" ]; then
300 Exit_error err_no_spec_in_cmdl;
305 if [ -n "$SPECFILE" ]; then
310 Exit_error err_no_spec_in_cmdl;