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 ICONS="`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 "$ICONS" ]; then
78 echo "- Icon : $ICONS"
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;
151 if [ "$CVSROOT $PATCHES $ICONS" -ne " " ]; then
154 if [ -n "$CVSROOT" ]; then
155 cvs -d "$CVSROOT" up $SOURCES $PATCHES $ICONS
157 cvs up $SOURCES $PATCHES $ICONS
160 if [ "$?" -ne "0" ]; then
161 Exit_error err_no_source_in_repo;
164 chmod 444 $SOURCES $PATCHES $ICONS
171 rpm -ba -v $QUIET $CLEAN $SPECFILE
173 if [ "$?" -ne "0" ]; then
174 Exit_error err_build_fail;
179 #---------------------------------------------
182 if [ "$#" == 0 ]; then
187 while test $# -gt 0 ; do
190 COMMAND="version"; shift ;;
192 CVSROOT=":pserver:cvs@cvs.pld.org.pl:/cvsroot"; shift ;;
194 COMMAND="build"; shift ;;
196 CLEAN="--clean --rmspec --rmsource"; shift ;;
198 shift; CVSROOT="${1}"; shift ;;
200 COMMAND="get"; shift ;;
202 COMMAND="usage"; shift ;;
204 shift; LOGFILE="${1}"; shift ;;
206 QUIET="--quiet"; shift ;;
208 BE_VERBOSE="1"; shift ;;
210 SPECFILE="${1}"; shift ;;
217 if [ -n "$SPECFILE" ]; then
223 Exit_error err_no_spec_in_cmdl;
228 if [ -n "$SPECFILE" ]; then
233 Exit_error err_no_spec_in_cmdl;