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.6 (C) 1999 Tomasz K³oczko".
15 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
24 CVSROOT=${CVSROOT:-""}
34 #---------------------------------------------
39 if [ -n "$DEBUG" ]; then set -xv; fi
41 Usage: builder [-D] [--debug] [-V] [--version] [-a] [--as_anon] [-b]
42 [--build] [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h]
43 [--help] [-l <logfile>] [--logtofile <logfile>] [-q] [--quiet] [-r
44 <cvstag>] [--cvstag <cvstag>] [-v] [--verbose] <package>.spec
46 -D, --debug - enable scrip debuging mode,
47 -V, --version - output builder version
48 -a, --as_anon - get files via pserver as cvs@cvs.pld.org.pl,
49 -b, --build - get all files from CVS repo and build
50 package from <package>.spec,
51 -c, --clean - clean all temporary maked files (in BUILD,
52 SOURCES, SPECS and $RPM_BUILD_ROOT),
53 -d, --cvsroot - setup \$CVSROOT,
54 -g, --get - get <package>.spec and all relayted files from
56 -h, --help - this message,
57 -l, --logtofile - log all to file,
58 -q, --quiet - be quiet,
59 -r, --cvstag - build package using resources from specified CVS
61 -v, --verbose - be verbose,
68 if [ -n "$DEBUG" ]; then set -xv; fi
70 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i "^Icon\:" > $SPECFILE.__
72 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCE[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
73 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCH[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
74 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE} |sed -e 's#.*/##g'`"
75 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
76 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
77 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
81 if [ -n "$BE_VERBOSE" ]; then
82 echo "- Sources : $SOURCES"
83 echo "- Patches : $PATCHES"
84 if [ -n "$ICONS" ]; then
85 echo "- Icon : $ICONS"
87 echo "- Icon : *no package icon*"
89 echo "- Name : $PACKAGE_NAME"
90 echo "- Version : $PACKAGE_VERSION"
91 echo "- Release : $PACKAGE_RELEASE"
97 if [ -n "$DEBUG" ]; then set -xv; fi
102 "err_no_spec_in_cmdl" )
103 echo "ERROR: spec file name not specified.";
105 "err_no_spec_in_repo" )
106 echo "Error: spec file not stored in CVS repo.";
108 "err_no_source_in_repo" )
109 echo "Error: some source, apatch or icon files not stored in CVS repo.";
112 echo "Error: package build failed.";
119 if [ -n "$DEBUG" ]; then set -xv; fi
121 DUMB_SPEC_FILE=`mktemp -q /tmp/bilder.XXXXXX`
132 echo SOURCE_DIR=%{_sourcedir}
133 echo SPECS_DIR=%{_specdir}" > $DUMB_SPEC_FILE
135 SOURCE_DIR=`rpm -bp $DUMB_SPEC_FILE 2>&1 | grep "^SOURCE_DIR" | sed "s/SOURCE_DIR\=//"`
136 SPECS_DIR=`rpm -bp $DUMB_SPEC_FILE 2>&1 | grep "^SPECS_DIR" |sed "s/SPECS_DIR\=//"`
138 rm -f $DUMB_SPEC_FILE
145 if [ -n "$DEBUG" ]; then set -xv; fi
151 if [ -n "$CVSROOT" ]; then
152 OPTIONS="-d $CVSROOT $OPTIONS"
154 if [ -n "$CVSTAG" ]; then
155 OPTIONS="$OPTIONS -r $CVSTAG"
157 OPTIONS="$OPTIONS -A"
160 cvs $OPTIONS $SPECFILE
161 if [ "$?" -ne "0" ]; then
162 Exit_error err_no_spec_in_repo;
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 chmod 444 $SOURCES $PATCHES $ICONS
198 if [ -n "$DEBUG" ]; then set -xv; fi
201 rpm -ba -v $QUIET $CLEAN $SPECFILE
203 if [ "$?" -ne "0" ]; then
204 Exit_error err_build_fail;
209 #---------------------------------------------
212 if [ "$#" == 0 ]; then
217 while test $# -gt 0 ; do
220 DEBUG="yes"; shift ;;
222 COMMAND="version"; shift ;;
224 CVSROOT=":pserver:cvs@cvs.pld.org.pl:/cvsroot"; shift ;;
226 COMMAND="build"; shift ;;
228 CLEAN="--clean --rmspec --rmsource"; shift ;;
230 shift; CVSROOT="${1}"; shift ;;
232 COMMAND="get"; shift ;;
234 COMMAND="usage"; shift ;;
236 shift; LOGFILE="${1}"; shift ;;
238 QUIET="--quiet"; shift ;;
240 shift; CVSTAG="${1}"; shift ;;
242 BE_VERBOSE="1"; shift ;;
244 SPECFILE="${1}"; shift ;;
248 if [ -n "$DEBUG" ]; then set -xv; fi
253 if [ -n "$SPECFILE" ]; then
259 Exit_error err_no_spec_in_cmdl;
264 if [ -n "$SPECFILE" ]; then
269 Exit_error err_no_spec_in_cmdl;