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"
23 CVSROOT=${CVSROOT:-""}
33 #---------------------------------------------
39 Usage: builder [-V] [--version] [-a] [--as_anon] [-b] [--build]
40 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
41 [-l <logfile>] [--logtofile <logfile>] [-q] [--quiet]
42 [-v] [--verbose] <package>.spec
44 -V, --version - output builder version
45 -a, --as_anon - get files via pserver as cvs@cvs.pld.org.pl,
46 -b, --build - get all files from CVS repo and build
47 package from <package>.spec,
48 -c, --clean - clean all temporary maked files (in BUILD,
49 SOURCES, SPECS and $RPM_BUILD_ROOT),
50 -d, --cvsroot - setup \$CVSROOT,
51 -g, --get - get <package>.spec and all relayted files from
53 -h, --help - this message,
54 -l, --logtofile - log all to file,
55 -q, --quiet - be quiet,
56 -v, --verbose - be verbose,
63 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i Icon > $SPECFILE.__
65 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCE[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
66 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCH[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
67 ICON="`awk '/^Icon:/ {print $2}' ${SPECFILE} |sed -e 's#.*/##g'`"
68 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
69 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
70 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
74 if [ -n "$BE_VERBOSE" ]; then
75 echo "- Sources : $SOURCES"
76 echo "- Patches : $PATCHES"
77 if [ -n "$ICON" ]; then
80 echo "- Icon : *no package icon*"
82 echo "- Name : $PACKAGE_NAME"
83 echo "- Version : $PACKAGE_VERSION"
84 echo "- Release : $PACKAGE_RELEASE"
93 "err_no_spec_in_cmdl" )
94 echo "ERROR: spec file name not specified.";
96 "err_no_spec_in_repo" )
97 echo "Error: spec file not stored in CVS repo.";
99 "err_no_source_in_repo" )
100 echo "Error: some source, apatch or icon files not stored in CVS repo.";
103 echo "Error: package build failed.";
110 DUMB_SPEC_FILE=`mktemp -q /tmp/bilder.XXXXXX`
121 echo SOURCE_DIR=%{_sourcedir}
122 echo SPECS_DIR=%{_specdir}" > $DUMB_SPEC_FILE
124 SOURCE_DIR=`rpm -bp $DUMB_SPEC_FILE 2>&1 | grep "^SOURCE_DIR" | sed "s/SOURCE_DIR\=//"`
125 SPECS_DIR=`rpm -bp $DUMB_SPEC_FILE 2>&1 | grep "^SPECS_DIR" |sed "s/SPECS_DIR\=//"`
127 rm -f $DUMB_SPEC_FILE
136 if [ -n "$CVSROOT" ]; then
137 cvs -d "$CVSROOT" up $SPECFILE
142 if [ "$?" -ne "0" ]; then
143 Exit_error err_no_spec_in_repo;
152 if [ -n "$CVSROOT" ]; then
153 cvs -d "$CVSROOT" up $SOURCES $PATCHES $ICON
155 cvs up $SOURCES $PATCHES $ICON
158 if [ "$?" -ne "0" ]; then
159 Exit_error err_no_source_in_repo;
162 chmod 444 $SOURCES $PATCHES $ICON
168 rpm -ba -v $QUIET $CLEAN $SPECFILE
170 if [ "$?" -ne "0" ]; then
171 Exit_error err_build_fail;
176 #---------------------------------------------
179 if [ "$#" == 0 ]; then
184 while test $# -gt 0 ; do
187 COMMAND="version"; shift ;;
189 CVSROOT=":pserver:cvs@cvs.pld.org.pl:/cvsroot"; shift ;;
191 COMMAND="build"; shift ;;
193 CLEAN="--clean --rmspec --rmsource"; shift ;;
195 shift; CVSROOT="${1}"; shift ;;
197 COMMAND="get"; shift ;;
199 COMMAND="usage"; shift ;;
201 shift; LOGFILE="${1}"; shift ;;
203 QUIET="--quiet"; shift ;;
205 BE_VERBOSE="1"; shift ;;
207 SPECFILE="${1}"; shift ;;
214 if [ -n "$SPECFILE" ]; then
220 Exit_error err_no_spec_in_cmdl;
225 if [ -n "$SPECFILE" ]; then
230 Exit_error err_no_spec_in_cmdl;