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"
24 CVSROOT=${CVSROOT:-""}
35 if [ -f ~/.builderrc ]; then
39 #---------------------------------------------
44 if [ -n "$DEBUG" ]; then set -xv; fi
46 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b] [-ba]
47 [--build] [-bb] [--build-binary] [-bs] [--build-source] [-d <cvsroot>]
48 [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help] [-l <logfile>]
49 [--logtofile <logfile>] [-q] [--quiet] [-r <cvstag>]
50 [--cvstag <cvstag>] [-v] [--verbose] <package>.spec
52 -D, --debug - enable script debugging mode,
53 -V, --version - output builder version
54 -a, --as_anon - get files via pserver as cvs@cvs.pld.org.pl,
56 --build - get all files from CVS repo and build
57 package from <package>.spec,
59 --build-binary - get all files from CVS repo and build
60 binary only package from <package>.spec,
62 --build-source - get all files from CVS repo and only pack them into
64 -c, --clean - clean all temporarily created files (in BUILD,
65 SOURCES, SPECS and \$RPM_BUILD_ROOT),
66 SOURCES, SPECS and \$RPM_BUILD_ROOT),
67 -d, --cvsroot - setup \$CVSROOT,
68 -g, --get - get <package>.spec and all related files from
70 -h, --help - this message,
71 -l, --logtofile - log all to file,
72 -q, --quiet - be quiet,
73 -r, --cvstag - build package using resources from specified CVS
75 -v, --verbose - be verbose,
82 if [ -n "$DEBUG" ]; then set -xv; fi
84 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i "^Icon\:" > $SPECFILE.__
86 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCE[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
87 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCH[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
88 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE} |sed -e 's#.*/##g'`"
89 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
90 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
91 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
95 if [ -n "$BE_VERBOSE" ]; then
96 echo "- Sources : $SOURCES"
97 echo "- Patches : $PATCHES"
98 if [ -n "$ICONS" ]; then
99 echo "- Icon : $ICONS"
101 echo "- Icon : *no package icon*"
103 echo "- Name : $PACKAGE_NAME"
104 echo "- Version : $PACKAGE_VERSION"
105 echo "- Release : $PACKAGE_RELEASE"
111 if [ -n "$DEBUG" ]; then set -xv; fi
116 "err_no_spec_in_cmdl" )
117 echo "ERROR: spec file name not specified.";
119 "err_no_spec_in_repo" )
120 echo "Error: spec file not stored in CVS repo.";
122 "err_no_source_in_repo" )
123 echo "Error: some source, apatch or icon files not stored in CVS repo.";
126 echo "Error: package build failed.";
133 if [ -n "$DEBUG" ]; then set -xv; fi
135 SOURCE_DIR="`rpm --eval "%{_sourcedir}"`"
136 SPECS_DIR="`rpm --eval "%{_specdir}"`"
143 if [ -n "$DEBUG" ]; then set -xv; fi
149 if [ -n "$CVSROOT" ]; then
150 OPTIONS="-d $CVSROOT $OPTIONS"
152 if [ -n "$CVSTAG" ]; then
153 OPTIONS="$OPTIONS -r $CVSTAG"
155 OPTIONS="$OPTIONS -A"
158 cvs $OPTIONS $SPECFILE
159 if [ "$?" -ne "0" ]; then
160 Exit_error err_no_spec_in_repo;
163 if [ "$CHMODE" = "yes" ]; then
171 if [ -n "$DEBUG" ]; then set -xv; fi
173 if [ -n "$SOURCES$PATCHES$ICONS" ]; then
177 if [ -n "$CVSROOT" ]; then
178 OPTIONS="-d $CVSROOT $OPTIONS"
180 if [ -n "$CVSTAG" ]; then
181 OPTIONS="$OPTIONS -r $CVSTAG"
183 OPTIONS="$OPTIONS -A"
186 cvs $OPTIONS $SOURCES $PATCHES $ICONS
187 if [ "$?" -ne "0" ]; then
188 Exit_error err_no_source_in_repo;
191 if [ "$CHMOD" = "yes" ]; then
192 chmod 444 $SOURCES $PATCHES $ICONS
200 if [ -n "$DEBUG" ]; then set -xv; fi
205 BUILD_SWITCH="-ba" ;;
207 BUILD_SWITCH="-bb" ;;
209 BUILD_SWITCH="-bs" ;;
211 rpm $BUILD_SWITCH -v $QUIET $CLEAN $SPECFILE
213 if [ "$?" -ne "0" ]; then
214 Exit_error err_build_fail;
220 #---------------------------------------------
223 if [ "$#" = 0 ]; then
228 while test $# -gt 0 ; do
231 DEBUG="yes"; shift ;;
233 COMMAND="version"; shift ;;
235 CVSROOT=":pserver:cvs@cvs.pld.org.pl:/cvsroot"; shift ;;
237 COMMAND="build"; shift ;;
238 -bb | --build-binary )
239 COMMAND="build-binary"; shift ;;
240 -bs | --build-source )
241 COMMAND="build-source"; shift ;;
243 CLEAN="--clean --rmspec --rmsource"; shift ;;
245 shift; CVSROOT="${1}"; shift ;;
247 COMMAND="get"; shift ;;
249 COMMAND="usage"; shift ;;
251 shift; LOGFILE="${1}"; shift ;;
253 QUIET="--quiet"; shift ;;
255 shift; CVSTAG="${1}"; shift ;;
257 BE_VERBOSE="1"; shift ;;
259 SPECFILE="${1}"; shift ;;
263 if [ -n "$DEBUG" ]; then set -xv; fi
266 "build" | "build-binary" | "build-source" )
268 if [ -n "$SPECFILE" ]; then
274 Exit_error err_no_spec_in_cmdl;
279 if [ -n "$SPECFILE" ]; then
284 Exit_error err_no_spec_in_cmdl;