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"
21 CVSROOT=${CVSROOT:-""}
31 #---------------------------------------------
37 Usage: builder [-V] [--version] [-a] [--as_anon] [-b] [--build]
38 [-d <cvsroot>] [--cvsroot <cvsroot>] [-g] [--get] [-h] [--help]
39 [-l <logfile>] [--logtofile <logfile>] [-q] [--quiet]
40 [-v] [--verbose] <package>.spec
42 -V, --version - output builder version
43 -a, --as_anon - get files via pserver as cvs@cvs.pld.org.pl,
44 -b, --build - get all files from CVS repo and build
45 package from <package>.spec,
46 -c, --clean - clean all temporary maked files (in BUILD,
47 SOURCES, SPECS and $RPM_BUILD_ROOT),
48 -d, --cvsroot - setup \$CVSROOT,
49 -g, --get - get <package>.spec and all relayted files from
51 -h, --help - this message,
52 -l, --logtofile - log all to file,
53 -q, --quiet - be quiet,
54 -v, --verbose - be verbose,
61 sed -e "s#%prep#%dump#I" $SPECFILE | grep -v -i Icon > $SPECFILE.__
63 SOURCES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ SOURCE[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
64 PATCHES="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PATCH[0-9]+/ {print $3}'|sed -e 's#.*/##g'`"
65 ICON="`awk '/^Icon:/ {print $2}' ${SPECFILE} |sed -e 's#.*/##g'`"
66 PACKAGE_NAME="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ name/ {print $3}'`"
67 PACKAGE_VERSION="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_VERSION/ {print $3}'`"
68 PACKAGE_RELEASE="`rpm -bp --test $SPECFILE.__ 2>&1 | awk '/ PACKAGE_RELEASE/ {print $3}'`"
72 if [ -n "$BE_VERBOSE" ]; then
73 echo "- Sources : $SOURCES"
74 echo "- Patches : $PATCHES"
75 if [ -n "$ICON" ]; then
78 echo "- Icon : *no package icon*"
80 echo "- Name : $PACKAGE_NAME"
81 echo "- Version : $PACKAGE_VERSION"
82 echo "- Release : $PACKAGE_RELEASE"
91 "err_no_spec_in_cmdl" )
92 echo "ERROR: spec file name not specified.";
94 "err_no_spec_in_repo" )
95 echo "Error: spec file not stored in CVS repo.";
97 "err_no_source_in_repo" )
98 echo "Error: some source, apatch or icon files not stored in CVS repo.";
101 echo "Error: package build failed.";
108 DUMB_SPEC_FILE=`mktemp -q /tmp/bilder.XXXXXX`
119 echo SOURCE_DIR=%{_sourcedir}
120 echo SPECS_DIR=%{_specdir}" > $DUMB_SPEC_FILE
122 SOURCE_DIR=`rpm -bp $DUMB_SPEC_FILE 2>&1 | grep "^SOURCE_DIR" | sed "s/SOURCE_DIR\=//"`
123 SPECS_DIR=`rpm -bp $DUMB_SPEC_FILE 2>&1 | grep "^SPECS_DIR" |sed "s/SPECS_DIR\=//"`
125 rm -f $DUMB_SPEC_FILE
134 if [ -n "$CVSROOT" ]; then
135 cvs -d "$CVSROOT" up $SPECFILE
140 if [ "$?" -ne "0" ]; then
141 Exit_error err_no_spec_in_repo;
150 if [ -n "$CVSROOT" ]; then
151 cvs -d "$CVSROOT" up $SOURCES $PATCHES $ICON
153 cvs up $SOURCES $PATCHES $ICON
156 if [ "$?" -ne "0" ]; then
157 Exit_error err_no_source_in_repo;
160 chmod 444 $SOURCES $PATCHES $ICON
166 rpm -ba -v $QUIET $CLEAN $SPECFILE
168 if [ "$?" -ne "0" ]; then
169 Exit_error err_build_fail;
174 #---------------------------------------------
177 if [ "$#" == 0 ]; then
182 while test $# -gt 0 ; do
185 COMMAND="version"; shift ;;
187 CVSROOT=":pserver:cvs@cvs.pld.org.pl:/cvsroot"; shift ;;
189 COMMAND="build"; shift ;;
191 CLEAN="--clean --rmspec --rmsource"; shift ;;
193 shift; CVSROOT="${1}"; shift ;;
195 COMMAND="get"; shift ;;
197 COMMAND="usage"; shift ;;
199 shift; LOGFILE="${1}"; shift ;;
201 QUIET="--quiet"; shift ;;
203 BE_VERBOSE="1"; shift ;;
205 SPECFILE="${1}"; shift ;;
212 if [ -n "$SPECFILE" ]; then
218 Exit_error err_no_spec_in_cmdl;
223 if [ -n "$SPECFILE" ]; then
228 Exit_error err_no_spec_in_cmdl;