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.5 (C) 1999 Tomasz K³oczko".
15 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
20 CVSROOT=${CVSROOT:-""}
30 #---------------------------------------------
36 Usage: builder [-V] [--version] [-a] [--as_anon] [-b] [--build]
37 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
38 [-l <logfile>] [--logtofile <logfile>] [-q] [--quiet]
39 [-v] [--verbose] <package>.spec
41 -V, --version - output builder version
42 -a, --as_anon - get files via pserver as cvs@cvs.pld.org.pl,
43 -b, --build - get all files from CVS repo and build
44 package from <package>.spec,
45 -d, --cvsroot - setup \$CVSROOT,
46 -g, --get - get <package>.spec and all relayted files from
48 -h, --help - this message,
49 -l, --logtofile - log all to file,
50 -q, --quiet - be quiet,
51 -v, --verbose - be verbose,
58 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i Icon > $SPECFILE.__
60 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCE[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
61 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCH[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
62 ICON="`awk '/^Icon:/ {print $2}' ${SPECFILE} |sed -e 's#.*/##g'`"
63 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
64 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
65 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
69 if [ -n "$BE_VERBOSE" ]; then
70 echo "- Sources : $SOURCES"
71 echo "- Patches : $PATCHES"
72 if [ -n "$ICON" ]; then
75 echo "- Icon : *no package icon*"
77 echo "- Name : $PACKAGE_NAME"
78 echo "- Version : $PACKAGE_VERSION"
79 echo "- Release : $PACKAGE_RELEASE"
88 "err_no_spec_in_cmdl" )
89 echo "ERROR: spec file name not specified.";
91 "err_no_spec_in_repo" )
92 echo "Error: spec file not stored in CVS repo.";
94 "err_no_source_in_repo" )
95 echo "Error: some source, apatch or icon files not stored in CVS repo.";
98 echo "Error: package build failed.";
105 DUMB_SPEC_FILE=`mktemp -q /tmp/bilder.XXXXXX`
116 echo SOURCE_DIR=%{_sourcedir}
117 echo SPECS_DIR=%{_specdir}" > $DUMB_SPEC_FILE
119 SOURCE_DIR=`rpm -bp $DUMB_SPEC_FILE 2>&1 | grep "^SOURCE_DIR" | sed "s/SOURCE_DIR\=//"`
120 SPECS_DIR=`rpm -bp $DUMB_SPEC_FILE 2>&1 | grep "^SPECS_DIR" |sed "s/SPECS_DIR\=//"`
122 rm -f $DUMB_SPEC_FILE
131 if [ -n "$CVSROOT" ]; then
132 cvs -d "$CVSROOT" up $SPECFILE
137 if [ "$?" -ne "0" ]; then
138 Exit_error err_no_spec_in_repo;
145 if [ -n "$CVSROOT" ]; then
146 cvs -d "$CVSROOT" up $SOURCES $PATCHES $ICON
148 cvs up $SOURCES $PATCHES $ICON
151 if [ "$?" -ne "0" ]; then
152 Exit_error err_no_source_in_repo;
159 rpm -ba -v $QUIET $SPECFILE
161 if [ "$?" -ne "0" ]; then
162 Exit_error err_build_fail;
167 #---------------------------------------------
170 if [ "$#" == 0 ]; then
175 while test $# -gt 0 ; do
178 COMMAND="version"; shift ;;
180 CVSROOT=":pserver:cvs@cvs.pld.org.pl:/cvsroot"; shift ;;
182 COMMAND="build"; shift ;;
184 shift; CVSROOT="${1}"; shift ;;
186 COMMAND="get"; shift ;;
188 COMMAND="usage"; shift ;;
190 shift; LOGFILE="${1}"; shift ;;
192 QUIET="--quiet"; shift ;;
194 BE_VERBOSE="1"; shift ;;
196 SPECFILE="${1}"; shift ;;
203 if [ -n "$SPECFILE" ]; then
209 Exit_error err_no_spec_in_cmdl;
214 if [ -n "$SPECFILE" ]; then
219 Exit_error err_no_spec_in_cmdl;