7 # 2 - no spec file name in cmdl parameters
8 # 3 - spec file not stored in repo
9 # 4 - some source, patch or icon files not stored in repo
10 # 5 - package build failed
11 # 6 - spec file with errors
12 # 7 - wrong source in /etc/poldek.conf
15 # - builder -u fetches current version first
16 # - tries to get new version from distfiles without new md5
17 # - after fetching new version doesn't update md5
18 # - doesn't get sources for specs with %include /usr/lib/rpm/macros.python
19 # when there's no rpm-pythonprov (rpm's fault, but it's ugly anyway)
20 # - as above with %include /usr/lib/rpm/macros.perl and no rpm-perlprov
21 # - when Icon: field is present, -5 and -a5 doesn't work
24 Build package utility from PLD CVS repository
25 V 0.11 (C) 1999-2003 Free Penguins".
26 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
42 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
43 if [ -s CVS/Root ]; then
44 CVSROOT=$(cat CVS/Root)
46 CVSROOT=${CVSROOT:-""}
48 # Example: LOGFILE='../log.$PACKAGE_NAME'
49 # Yes, you can use variable name! Note _single_ quotes!
68 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
69 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
74 CVS_SERVER="cvs.pld-linux.org"
75 DISTFILES_SERVER="://distfiles.pld-linux.org"
79 FAIL_IF_NO_SOURCES="yes"
81 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
82 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
84 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
85 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
88 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
96 #POLDEK_INDEX_DIR="/home/users/yoshi/rpm/RPMS/"
97 POLDEK_INDEX_DIR="~/rpm/RPMS/"
100 # Example grep cvs /etc/poldek.conf:
101 # source = cvs /home/users/yoshi/rpm/RPMS/
102 POLDEK_SOURCE_VALIDITY="`grep ${POLDEK_SOURCE} /etc/poldek.conf|grep -v ^#`"
103 if [ "${POLDEK_SOURCE_VALIDITY}" == "" ]; then
104 echo "Using improper source '${POLDEK_SOURCE}' in /etc/poldek.conf"
105 echo "Fix it and try to contiune"
109 if [ -f ~/etc/builderrc ]; then
111 elif [ -f ~/.builderrc ]; then
115 #---------------------------------------------
120 if [ -n "$DEBUG" ]; then set -xv; fi
122 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
124 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
125 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
126 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
127 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
128 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
129 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
130 [{-Tp|--tag-prefix} <prefix>]
131 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
132 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
135 - update md5 comments in spec, implies -nd -ncs
136 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
137 -D, --debug - enable script debugging mode,
138 -V, --version - output builder version
139 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
141 --build - get all files from CVS repo or HTTP/FTP and build
142 package from <package>.spec,
144 - get all files from CVS repo or HTTP/FTP and build
145 binary only package from <package>.spec,
147 --build-source - get all files from CVS repo or HTTP/FTP and only
148 pack them into src.rpm,
149 -B, --branch - add branch
150 -c, --clean - clean all temporarily created files (in BUILD,
151 SOURCES, SPECS and \$RPM_BUILD_ROOT),
152 -d <cvsroot>, --cvsroot <cvsroot>
154 --define <macro> <value>
155 - define a macro <macro> with value <value>,
156 --nodeps - rpm won't check any dependences
157 -g, --get - get <package>.spec and all related files from
158 CVS repo or HTTP/FTP,
159 -h, --help - this message,
160 --http - use http instead of ftp,
161 -l <logfile>, --logtofile <logfile>
163 -m, --mr-proper - only remove all files related to spec file and
165 -nc, --no-cvs - don't download sources from CVS, if source URL is
168 - don't check specs in CVS
170 - don't download from distfiles
171 -nm, --no-mirrors - don't download from mirror, if source URL is given,
172 -nu, --no-urls - don't try to download from FTP/HTTP location,
173 -ns, --no-srcs - don't download Sources
175 - don't download Source0
177 - additional options for rpm
178 -q, --quiet - be quiet,
180 - build package using resources from specified CVS
182 -r <cvstag>, --cvstag <cvstag>
183 - build package using resources from specified CVS
185 -R, --fetch-build-requires
186 - fetch what is BuildRequired,
187 -T <cvstag> , --tag <cvstag>
188 - add cvs tag <cvstag> for files,
189 -Tvs, --tag-version-stable
190 - add cvs tags STABLE and NAME-VERSION-RELESE for files,
191 -Tvn, --tag-version-nest
192 - add cvs tags NEST and NAME-VERSION-RELESE for files,
194 - add cvs tag STABLE for files,
196 - add cvs tag NEST for files,
198 - add cvs tag NAME-VERSION-RELESE for files,
199 -Tp, --tag-prefix <prefix>
200 - add <prefix> to NAME-VERSION-RELEASE tags,
201 -v, --verbose - be verbose,
203 - check version, and try to upgrade package
204 -un, --try-upgrade-with-float-version
205 - as above, but allow float version
207 - refetch sources, don't use distfiles, and update md5
209 -Upi, --update-poldek-indexes
210 - refresh or make poldek package index files.
211 --with/--without <feature>
212 - conditional build package depending on
213 %_with_<feature>/%_without_<feature> macro
215 You may now use --with feat1 feat2 feat3 --without feat4
216 feat5 --with feat6 constructions.
224 rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1
227 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1
233 if [ -z "$rpm_dump_cache" ] ; then
234 echo "internal error: cache_rpm_dump not called!" 1>&2
236 echo "$rpm_dump_cache"
241 if [ -n "$DEBUG" ]; then
250 if [ "$NOSRCS" != "yes" ]; then
251 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
253 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
254 FAIL_IF_NO_SOURCES="no"
257 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
258 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
259 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
260 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
261 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
263 if [ -n "$BE_VERBOSE" ]; then
264 echo "- Sources : `nourl $SOURCES`"
265 if [ -n "$PATCHES" ]; then
266 echo "- Patches : `nourl $PATCHES`"
268 echo "- Patches : *no patches needed*"
270 if [ -n "$ICONS" ]; then
271 echo "- Icon : `nourl $ICONS`"
273 echo "- Icon : *no package icon*"
275 echo "- Name : $PACKAGE_NAME"
276 echo "- Version : $PACKAGE_VERSION"
277 echo "- Release : $PACKAGE_RELEASE"
283 if [ -n "$DEBUG" ]; then
291 "err_no_spec_in_cmdl" )
292 echo "ERROR: spec file name not specified.";
294 "err_no_spec_in_repo" )
295 echo "Error: spec file not stored in CVS repo.";
297 "err_no_source_in_repo" )
298 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
301 echo "Error: package build failed. (${2:-no more info})";
308 if [ -n "$DEBUG" ]; then
313 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
314 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
321 if [ -n "$DEBUG" ]; then
326 if [ "$NOCVSSPEC" != "yes" ]; then
331 if [ -n "$CVSROOT" ]; then
332 OPTIONS="-d $CVSROOT $OPTIONS"
334 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
335 echo "warning: No cvs access defined - using local .spec file"
340 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
341 OPTIONS="$OPTIONS -A"
343 if [ -n "$CVSDATE" ]; then
344 OPTIONS="$OPTIONS -D $CVSDATE"
346 if [ -n "$CVSTAG" ]; then
347 OPTIONS="$OPTIONS -r $CVSTAG"
353 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
354 retries_counter=$(( $retries_counter + 1 ))
355 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
357 [ -n "$output" ] && echo "$output"
358 if [ "$result" -ne "0" ]; then
359 if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out|Unknown host)") && [ "$retries_counter" -le "$CVS_RETRIES" ]; then
360 echo "Trying again [$SPECFILE]... ($retries_counter)"
364 Exit_error err_no_spec_in_repo;
368 if [ ! -f "$SPECFILE" ]; then
369 Exit_error err_no_spec_in_repo;
372 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
373 chmod $CHMOD_MODE $SPECFILE
376 grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
383 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
384 cvs update mirrors >&2
388 while read origin mirror name rest; do
389 ol=`echo -n "$origin"|wc -c`
390 prefix="`echo -n "$url" | head -c $ol`"
391 if [ "$prefix" = "$origin" ] ; then
392 suffix="`echo "$url"|cut -b $ol-`"
393 echo -n "$mirror$suffix"
404 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
405 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
412 [ -z "$no" ] && return
414 spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::)
415 if [ -z "$spec_rev" ]; then
416 spec_rev="$(head -1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
418 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
419 md5=$(grep -s -v '^#' additional-md5sums | \
420 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
421 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
422 grep -E '^[0-9a-f]{32}$')
423 if [ X"$md5" = X"" ] ; then
424 grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://' | xargs
426 if [ $(echo "$md5" | wc -l) != 1 ] ; then
427 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
429 echo "$md5" | tail -1
435 echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
442 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
449 if [ -n "$DEBUG" ]; then
454 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
458 if [ -n "$CVSROOT" ]; then
459 OPTIONS="-d $CVSROOT $OPTIONS"
461 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
462 echo "warning: No cvs access defined for SOURCES"
466 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
467 OPTIONS="$OPTIONS -A"
469 if [ -n "$CVSDATE" ]; then
470 OPTIONS="$OPTIONS -D $CVSDATE"
472 if [ -n "$CVSTAG" ]; then
473 OPTIONS="$OPTIONS -r $CVSTAG"
476 for i in $GET_FILES; do
477 if [ -n "$UPDATE5" ]; then
478 if [ -n "$ADD5" ]; then
479 [ `nourl $i` = "$i" ] && continue
480 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
482 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
486 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
487 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
488 echo "Warning: no URL given for $i"
491 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
492 if good_md5 "$i"; then
493 echo "$(nourl "$i") having proper md5sum already exists"
497 url=$(distfiles_url "$i")
498 if [ `echo $url | grep -E '^(\.|/)'` ]; then
499 ${GETLOCAL} $url $target
502 if [ -z "$NOMIRRORS" ]; then
503 url="`find_mirror "$url"`"
505 ${GETURI} -O "$target" "$url" || \
506 if [ `echo $url | grep -E 'ftp://'` ]; then
507 ${GETURI2} -O "$target" "$url"
509 if ! test -s "$target"; then
514 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
515 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
518 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
519 retries_counter=$(( $retries_counter + 1 ))
520 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
522 [ -n "$output" ] && echo "$output"
523 if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out|Unknown host)") && [ "$result" -ne "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; then
524 echo "Trying again [`nourl $i`]... ($retries_counter)"
533 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
534 if [ -z "$NOMIRRORS" ]; then
535 im="`find_mirror "$i"`"
540 if [ `echo $im | grep -E 'ftp://'` ]; then ${GETURI2} "$im" ; fi
546 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
547 Exit_error err_no_source_in_repo $i;
548 elif [ -n "$UPDATE5" ] && \
549 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
550 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
551 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
553 echo "Updating source-$srcno md5."
554 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
556 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
557 print "# Source'$srcno'-md5:\t'$md5'\n"
558 if /^Source'$srcno'\s*:\s+/;
563 if good_md5 "$i"; then
565 elif [ "$FROM_DISTFILES" = 1 ]; then
566 # wrong md5 from distfiles: remove the file and try again
568 echo "MD5 sum mismatch. Trying full fetch."
571 ${GETURI} -O "$target" "$url" || \
572 if [ `echo $url | grep -E 'ftp://'` ]; then
573 ${GETURI2} -O "$target" "$url"
575 test -s "$target" || rm -f "$target"
578 if good_md5 "$i"; then
581 echo "MD5 sum mismatch. Use -U to refetch sources,"
582 echo "or -5 to update md5 sums, if you're sure files are correct."
583 Exit_error err_no_source_in_repo $i
587 if [ "$CHMOD" = "yes" ]; then
588 CHMOD_FILES="`nourl $GET_FILES`"
589 if [ -n "$CHMOD_FILES" ]; then
590 chmod $CHMOD_MODE $CHMOD_FILES
601 if [ -n "$DEBUG" ]; then
606 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
607 echo "Version: $PACKAGE_VERSION"
608 echo "Release: $PACKAGE_RELEASE"
609 # Check whether first character of PACKAGE_NAME is legal for tag name
610 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
613 TAGVER=$TAG_PREFIX$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
614 # Remove #kernel.version_release from TAGVER because tagging sources
615 # could occur with different kernel-headers than kernel-headers used at build time.
616 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
617 if [ "$TAG_VERSION" = "yes" ]; then
618 echo "CVS tag: $TAGVER"
620 if [ -n "$TAG" ]; then
625 if [ -n "$CVSROOT" ]; then
626 OPTIONS="-d $CVSROOT $OPTIONS"
630 for i in $TAG_FILES; do
631 # don't tag non cvs files (ie. stored on distfiles)
632 [ "`nourl $i`" != "$i" ] && continue
633 if [ -f "`nourl $i`" ]; then
634 if [ "$TAG_VERSION" = "yes" ]; then
635 cvs $OPTIONS $TAGVER `nourl $i`
637 if [ -n "$TAG" ]; then
638 cvs $OPTIONS $TAG `nourl $i`
641 Exit_error err_no_source_in_repo $i
646 if [ "$TAG_VERSION" = "yes" ]; then
647 cvs $OPTIONS $TAGVER $SPECFILE
649 if [ -n "$TAG" ]; then
650 cvs $OPTIONS $TAG $SPECFILE
660 echo "CVS branch tag: $TAG"
665 if [ -n "$DEBUG" ]; then
670 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
673 if [ -n "$CVSROOT" ]; then
674 OPTIONS="-d $CVSROOT $OPTIONS"
677 for i in $TAG_FILES; do
678 if [ -f `nourl $i` ]; then
679 cvs $OPTIONS $TAG `nourl $i`
681 Exit_error err_no_source_in_repo $i
685 cvs $OPTIONS $TAG $SPECFILE
695 if [ -n "$DEBUG" ]; then
702 if [ -n "$TRY_UPGRADE" ]; then
704 if [ -n "$FLOAT_VERSION" ]; then
705 TNOTIFY=`./pldnotify.awk $SPECFILE -n`
707 TNOTIFY=`./pldnotify.awk $SPECFILE`
710 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
712 if [ -n "$TNEWVER" ]; then
714 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
716 echo "New version found, updating spec file to version " $TNEWVER
718 cp -f $SPECFILE $SPECFILE.bak
722 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
723 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE"
727 get_files "$SOURCES $PATCHES";
729 unset TOLDVER TNEWVER TNOTIFY
739 BUILD_SWITCH="-ba" ;;
741 BUILD_SWITCH="-bb" ;;
743 BUILD_SWITCH="-bs --nodeps" ;;
745 if [ -n "$LOGFILE" ]; then
746 LOG=`eval echo $LOGFILE`
747 if [ -n "$LASTLOG_FILE" ]; then
748 echo "LASTLOG=$LOG" > $LASTLOG_FILE
750 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
751 (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
752 RETVAL=`cat $RES_FILE`
754 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
755 if [ "$RETVAL" -eq "0" ]; then
762 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE
766 if [ "$RETVAL" -ne "0" ]; then
768 if [ -n "$TRY_UPGRADE" ]; then
769 echo "\n!!! Package with new version cannot be build automagically\n"
770 mv -f $SPECFILE.bak $SPECFILE
773 Exit_error err_build_fail;
781 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
786 AVAIL_BCONDS_WITHOUT=""
788 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
790 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
791 if [ "`echo $BCOND|grep -- "--without $AVAIL_BCOND_WITHOUT"`" != "" ];then
792 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
794 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
798 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
800 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
801 if [ "`echo $BCOND|grep -- "--with $AVAIL_BCOND_WITH"`" != "" ];then
802 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
804 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
811 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
812 echo -ne "We are going to build $SPECFILE with the following confitional flags:\n"
813 if [ "$BCOND" != "" ]; then
816 echo -ne "No --with || --without conditions passed to $0!"
818 echo -ne "\n\nfrom available:\n\n"
819 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
823 fetch_build_requires()
825 if [ "$FETCH_BUILD_REQUIRES" == "yes" ]; then
826 for package_item in `cat $SPECFILE|grep -B100000 ^%changelog|grep -v ^#|grep BuildRequires|grep -v ^-|sed -e "s/^.*BuildRequires://g"|awk '{print $1}'`
829 package=`basename "$package_item"|sed -e "s/}$//g"`
830 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
833 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
834 if [ "`echo $COND_TST|grep '^BuildRequires:'`" != "" ]; then
835 if [ "$COND_ARCH_TST" != "" ] && [ "`echo $COND_ARCH_TST|sed -e "s/i.86/ix86/g"`" != "`echo $mach|sed -e "s/i.86/ix86/g"`" ]; then
840 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
843 if [ "`echo $COND_TST|grep 'without_'`" != "" ]; then
844 COND_NAME=`echo $COND_NAME|sed -e s,^.*_without_,,g`
845 if [ "`echo $COND_TST|grep !`" != "" ]; then
850 if [ "`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`" != "" ]; then
856 elif [ "`echo $COND_TST|grep 'with_'`" != "" ]; then
857 COND_NAME=`echo $COND_NAME|sed -e s,^.*_with_,,g`
858 if [ "`echo $COND_TST|grep !`" != "" ]; then
863 if [ "`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`" != "" ]; then
869 RESULT="${COND_STATE}-${COND_ARGV}"
871 with-wout|wout-with )
874 wout-wout|with-with )
878 echo "Action '$RESULT' was not defined for package '$package_item'"
884 if [ "$GO" == "yes" ]; then
885 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
886 echo "Package $package is not installed. Attempting to install..."
887 poldek ${POLDEK_SOURCE} -i $package
890 echo "Unable to install $package package! Still trying to fetch rest..."
891 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package"
897 echo "Package $package is already installed. BuildRequirement satisfied."
901 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
902 echo "Nie uda³o siê zainstalowaæ nastêpuj±cych pakietów i ich zale¿no¶ci:"
903 for pkg in "$NOT_INSTALLED_PACKAGES"
912 #---------------------------------------------
915 if [ "$#" = 0 ]; then
920 while test $# -gt 0 ; do
937 DEBUG="yes"; shift ;;
939 COMMAND="version"; shift ;;
941 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
943 COMMAND="build"; shift ;;
944 -bb | --build-binary )
945 COMMAND="build-binary"; shift ;;
946 -bs | --build-source )
947 COMMAND="build-source"; shift ;;
949 COMMAND="branch"; shift; TAG="${1}"; shift;;
951 CLEAN="--clean --rmspec --rmsource"; shift ;;
953 shift; CVSROOT="${1}"; shift ;;
955 COMMAND="get"; shift ;;
957 COMMAND="usage"; shift ;;
959 PROTOCOL="http"; shift ;;
961 shift; LOGFILE="${1}"; shift ;;
963 shift; DEF_NICE_LEVEL=${1}; shift ;;
965 COMMAND="mr-proper"; shift ;;
967 NOCVS="yes"; shift ;;
968 -ncs | --no-cvs-specs )
969 NOCVSSPEC="yes"; shift ;;
970 -nd | --no-distfiles )
971 NODIST="yes"; shift ;;
973 NOMIRRORS="yes"; shift ;;
975 NOURLS="yes"; shift ;;
977 NOSRCS="yes"; shift ;;
978 -ns0 | --no-source0 )
979 NOSOURCE0="yes"; shift ;;
981 shift; RPMOPTS="${1}"; shift ;;
985 while [ "`echo ${1}|grep ^-`" == "" ] && [ "`echo ${1}|grep spec`" == "" ]
987 BCOND="$BCOND $COND $1"
991 QUIET="--quiet"; shift ;;
993 CVSDATE="${2}"; shift 2 ;;
995 shift; CVSTAG="${1}"; shift ;;
996 -R | --fetch-build-requires)
997 FETCH_BUILD_REQUIRES="yes"
998 NOT_INSTALLED_PACKAGES=
1000 -Tvs | --tag-version-stable )
1005 -Tvn | --tag-version-nest )
1010 -Ts | --tag-stable )
1020 -Tv | --tag-version )
1025 -Tp | --tag-prefix )
1041 -Upi | --update-poldek-indexes )
1042 UPDATE_POLDEK_INDEXES="yes"
1044 -u | --try-upgrade )
1045 TRY_UPGRADE="1"; shift ;;
1046 -un | --try-upgrade-with-float-version )
1047 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1049 BE_VERBOSE="1"; shift ;;
1055 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1059 RPMOPTS="${RPMOPTS} --nodeps"
1062 SPECFILE="`basename ${1} .spec`.spec"; shift ;;
1066 if [ -n "$DEBUG" ]; then
1072 "build" | "build-binary" | "build-source" )
1074 if [ -n "$SPECFILE" ]; then
1078 fetch_build_requires;
1081 if [ -n "$FAIL_IF_CHANGED_BUT_NOT_BUMPED" ]; then
1082 TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
1083 CURTAGREL=$(cvs status $SPECFILE | grep "Working revision:" | awk '{ print $3 }')
1084 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1086 if [ -n "$TAGREL" -a "$TAGREL" != "$CURTAGREL" ]; then
1087 Exit_error err_build_fail "not bumped ver-rel - was already used in rev $TAGREL"
1091 if [ -n "$ICONS" ]; then
1095 if [ -n "$NOSOURCE0" ] ; then
1096 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1098 get_files "$SOURCES $PATCHES";
1100 if [ $_ -eq 0 ] && [ "$UPDATE_POLDEK_INDEXES" == "yes" ]; then
1101 poldek --sn ${POLDEK_SOURCE} --mkidx="${POLDEK_INDEX_DIR}/packages.dir.gz"
1102 poldek --sn ${POLDEK_SOURCE} --up
1105 Exit_error err_no_spec_in_cmdl;
1110 if [ -n "$SPECFILE" ]; then
1113 if [ -n "$ICONS" ]; then
1117 get_files $SOURCES $PATCHES;
1118 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1120 Exit_error err_no_spec_in_cmdl;
1125 if [ -n "$SPECFILE" ]; then
1128 if [ -n "$ICONS" ]; then
1132 if [ -n "$NOSOURCE0" ] ; then
1133 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1135 get_files $SOURCES $PATCHES
1137 Exit_error err_no_spec_in_cmdl;
1142 if [ -n "$SPECFILE" ]; then
1145 if [ -n "$ICONS" ]; then
1149 # don't fetch sources from remote locations
1151 for file in $SOURCES; do
1152 [ "`nourl $file`" != "$file" ] && continue
1153 new_SOURCES="$new_SOURCES $file"
1155 SOURCES="$new_SOURCES"
1156 get_files $SOURCES $PATCHES;
1157 tag_files "$SOURCES $PATCHES $ICONS";
1159 Exit_error err_no_spec_in_cmdl;
1163 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE