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!
69 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
70 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
75 CVS_SERVER="cvs.pld-linux.org"
76 DISTFILES_SERVER="://distfiles.pld-linux.org"
80 FAIL_IF_NO_SOURCES="yes"
82 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
83 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
85 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
86 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
89 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
97 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
100 # Example grep cvs /etc/poldek.conf:
101 # source = cvs /home/users/yoshi/rpm/RPMS/
102 if [ "$UPDATE_POLDEK_INDEXES" == "yes" ]; then
103 POLDEK_SOURCE_VALIDITY="`grep ${POLDEK_SOURCE} /etc/poldek.conf|grep -v ^#`"
104 if [ "${POLDEK_SOURCE_VALIDITY}" == "" ]; then
105 echo "Using improper source '${POLDEK_SOURCE}' in /etc/poldek.conf"
106 echo "Fix it and try to contiune"
111 if [ -f ~/etc/builderrc ]; then
113 elif [ -f ~/.builderrc ]; then
117 #---------------------------------------------
122 if [ -n "$DEBUG" ]; then set -xv; fi
124 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
126 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
127 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
128 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
129 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
130 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
131 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
132 [{-Tp|--tag-prefix} <prefix>]
133 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
134 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
137 - update md5 comments in spec, implies -nd -ncs
138 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
139 -D, --debug - enable script debugging mode,
140 -V, --version - output builder version
141 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
143 --build - get all files from CVS repo or HTTP/FTP and build
144 package from <package>.spec,
146 - get all files from CVS repo or HTTP/FTP and build
147 binary only package from <package>.spec,
149 --build-source - get all files from CVS repo or HTTP/FTP and only
150 pack them into src.rpm,
151 -B, --branch - add branch
152 -c, --clean - clean all temporarily created files (in BUILD,
153 SOURCES, SPECS and \$RPM_BUILD_ROOT),
154 -d <cvsroot>, --cvsroot <cvsroot>
156 --define <macro> <value>
157 - define a macro <macro> with value <value>,
158 --nodeps - rpm won't check any dependences
159 -g, --get - get <package>.spec and all related files from
160 CVS repo or HTTP/FTP,
161 -h, --help - this message,
162 --http - use http instead of ftp,
163 -l <logfile>, --logtofile <logfile>
165 -m, --mr-proper - only remove all files related to spec file and
167 -nc, --no-cvs - don't download sources from CVS, if source URL is
170 - don't check specs in CVS
172 - don't download from distfiles
173 -nm, --no-mirrors - don't download from mirror, if source URL is given,
174 -nu, --no-urls - don't try to download from FTP/HTTP location,
175 -ns, --no-srcs - don't download Sources
177 - don't download Source0
179 - additional options for rpm
180 -q, --quiet - be quiet,
182 - build package using resources from specified CVS
184 -r <cvstag>, --cvstag <cvstag>
185 - build package using resources from specified CVS
187 -R, --fetch-build-requires
188 - fetch what is BuildRequired,
189 -RB, --remove-build-requires
190 - remove all you fetched with -R or --fetch-build-requires
191 remember, this option requires confirmation,
192 -FRB, --force-remove-build-requires
193 - remove all you fetched with -R or --fetch-build-requires
194 remember, this option works without confirmation,
195 -T <cvstag> , --tag <cvstag>
196 - add cvs tag <cvstag> for files,
197 -Tvs, --tag-version-stable
198 - add cvs tags STABLE and NAME-VERSION-RELESE for files,
199 -Tvn, --tag-version-nest
200 - add cvs tags NEST and NAME-VERSION-RELESE for files,
202 - add cvs tag STABLE for files,
204 - add cvs tag NEST for files,
206 - add cvs tag NAME-VERSION-RELESE for files,
207 -Tp, --tag-prefix <prefix>
208 - add <prefix> to NAME-VERSION-RELEASE tags,
209 -v, --verbose - be verbose,
211 - check version, and try to upgrade package
212 -un, --try-upgrade-with-float-version
213 - as above, but allow float version
215 - refetch sources, don't use distfiles, and update md5
217 -Upi, --update-poldek-indexes
218 - refresh or make poldek package index files.
219 --with/--without <feature>
220 - conditional build package depending on
221 %_with_<feature>/%_without_<feature> macro
223 You may now use --with feat1 feat2 feat3 --without feat4
224 feat5 --with feat6 constructions.
232 rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1
235 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1
241 if [ -z "$rpm_dump_cache" ] ; then
242 echo "internal error: cache_rpm_dump not called!" 1>&2
244 echo "$rpm_dump_cache"
249 if [ -n "$DEBUG" ]; then
258 if [ "$NOSRCS" != "yes" ]; then
259 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
261 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
262 FAIL_IF_NO_SOURCES="no"
265 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
266 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
267 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
268 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
269 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
271 if [ -n "$BE_VERBOSE" ]; then
272 echo "- Sources : `nourl $SOURCES`"
273 if [ -n "$PATCHES" ]; then
274 echo "- Patches : `nourl $PATCHES`"
276 echo "- Patches : *no patches needed*"
278 if [ -n "$ICONS" ]; then
279 echo "- Icon : `nourl $ICONS`"
281 echo "- Icon : *no package icon*"
283 echo "- Name : $PACKAGE_NAME"
284 echo "- Version : $PACKAGE_VERSION"
285 echo "- Release : $PACKAGE_RELEASE"
291 if [ -n "$DEBUG" ]; then
299 "err_no_spec_in_cmdl" )
300 echo "ERROR: spec file name not specified.";
302 "err_no_spec_in_repo" )
303 echo "Error: spec file not stored in CVS repo.";
305 "err_no_source_in_repo" )
306 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
309 echo "Error: package build failed. (${2:-no more info})";
316 if [ -n "$DEBUG" ]; then
321 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
322 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
329 if [ -n "$DEBUG" ]; then
334 if [ "$NOCVSSPEC" != "yes" ]; then
339 if [ -n "$CVSROOT" ]; then
340 OPTIONS="-d $CVSROOT $OPTIONS"
342 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
343 echo "warning: No cvs access defined - using local .spec file"
348 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
349 OPTIONS="$OPTIONS -A"
351 if [ -n "$CVSDATE" ]; then
352 OPTIONS="$OPTIONS -D $CVSDATE"
354 if [ -n "$CVSTAG" ]; then
355 OPTIONS="$OPTIONS -r $CVSTAG"
361 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
362 retries_counter=$(( $retries_counter + 1 ))
363 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
365 [ -n "$output" ] && echo "$output"
366 if [ "$result" -ne "0" ]; then
367 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
368 echo "Trying again [$SPECFILE]... ($retries_counter)"
372 Exit_error err_no_spec_in_repo;
376 if [ ! -f "$SPECFILE" ]; then
377 Exit_error err_no_spec_in_repo;
380 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
381 chmod $CHMOD_MODE $SPECFILE
384 grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
391 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
392 cvs update mirrors >&2
396 while read origin mirror name rest; do
397 ol=`echo -n "$origin"|wc -c`
398 prefix="`echo -n "$url" | head -c $ol`"
399 if [ "$prefix" = "$origin" ] ; then
400 suffix="`echo "$url"|cut -b $ol-`"
401 echo -n "$mirror$suffix"
412 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
413 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
420 [ -z "$no" ] && return
422 spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::)
423 if [ -z "$spec_rev" ]; then
424 spec_rev="$(head -1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
426 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
427 md5=$(grep -s -v '^#' additional-md5sums | \
428 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
429 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
430 grep -E '^[0-9a-f]{32}$')
431 if [ X"$md5" = X"" ] ; then
432 grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://' | xargs
434 if [ $(echo "$md5" | wc -l) != 1 ] ; then
435 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
437 echo "$md5" | tail -1
443 echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
450 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
457 if [ -n "$DEBUG" ]; then
462 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
466 if [ -n "$CVSROOT" ]; then
467 OPTIONS="-d $CVSROOT $OPTIONS"
469 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
470 echo "warning: No cvs access defined for SOURCES"
474 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
475 OPTIONS="$OPTIONS -A"
477 if [ -n "$CVSDATE" ]; then
478 OPTIONS="$OPTIONS -D $CVSDATE"
480 if [ -n "$CVSTAG" ]; then
481 OPTIONS="$OPTIONS -r $CVSTAG"
484 for i in $GET_FILES; do
485 if [ -n "$UPDATE5" ]; then
486 if [ -n "$ADD5" ]; then
487 [ `nourl $i` = "$i" ] && continue
488 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
490 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
494 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
495 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
496 echo "Warning: no URL given for $i"
499 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
500 if good_md5 "$i"; then
501 echo "$(nourl "$i") having proper md5sum already exists"
505 url=$(distfiles_url "$i")
506 if [ `echo $url | grep -E '^(\.|/)'` ]; then
507 ${GETLOCAL} $url $target
510 if [ -z "$NOMIRRORS" ]; then
511 url="`find_mirror "$url"`"
513 ${GETURI} -O "$target" "$url" || \
514 if [ `echo $url | grep -E 'ftp://'` ]; then
515 ${GETURI2} -O "$target" "$url"
517 if ! test -s "$target"; then
522 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
523 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
526 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
527 retries_counter=$(( $retries_counter + 1 ))
528 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
530 [ -n "$output" ] && echo "$output"
531 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
532 echo "Trying again [`nourl $i`]... ($retries_counter)"
541 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
542 if [ -z "$NOMIRRORS" ]; then
543 im="`find_mirror "$i"`"
548 if [ `echo $im | grep -E 'ftp://'` ]; then ${GETURI2} "$im" ; fi
554 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
555 Exit_error err_no_source_in_repo $i;
556 elif [ -n "$UPDATE5" ] && \
557 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
558 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
559 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
561 echo "Updating source-$srcno md5."
562 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
564 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
565 print "# Source'$srcno'-md5:\t'$md5'\n"
566 if /^Source'$srcno'\s*:\s+/;
571 if good_md5 "$i"; then
573 elif [ "$FROM_DISTFILES" = 1 ]; then
574 # wrong md5 from distfiles: remove the file and try again
576 echo "MD5 sum mismatch. Trying full fetch."
579 ${GETURI} -O "$target" "$url" || \
580 if [ `echo $url | grep -E 'ftp://'` ]; then
581 ${GETURI2} -O "$target" "$url"
583 test -s "$target" || rm -f "$target"
586 if good_md5 "$i"; then
589 echo "MD5 sum mismatch. Use -U to refetch sources,"
590 echo "or -5 to update md5 sums, if you're sure files are correct."
591 Exit_error err_no_source_in_repo $i
595 if [ "$CHMOD" = "yes" ]; then
596 CHMOD_FILES="`nourl $GET_FILES`"
597 if [ -n "$CHMOD_FILES" ]; then
598 chmod $CHMOD_MODE $CHMOD_FILES
609 if [ -n "$DEBUG" ]; then
614 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
615 echo "Version: $PACKAGE_VERSION"
616 echo "Release: $PACKAGE_RELEASE"
617 # Check whether first character of PACKAGE_NAME is legal for tag name
618 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
621 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"`
622 # Remove #kernel.version_release from TAGVER because tagging sources
623 # could occur with different kernel-headers than kernel-headers used at build time.
624 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
625 if [ "$TAG_VERSION" = "yes" ]; then
626 echo "CVS tag: $TAGVER"
628 if [ -n "$TAG" ]; then
633 if [ -n "$CVSROOT" ]; then
634 OPTIONS="-d $CVSROOT $OPTIONS"
638 for i in $TAG_FILES; do
639 # don't tag non cvs files (ie. stored on distfiles)
640 [ "`nourl $i`" != "$i" ] && continue
641 if [ -f "`nourl $i`" ]; then
642 if [ "$TAG_VERSION" = "yes" ]; then
643 cvs $OPTIONS $TAGVER `nourl $i`
645 if [ -n "$TAG" ]; then
646 cvs $OPTIONS $TAG `nourl $i`
649 Exit_error err_no_source_in_repo $i
654 if [ "$TAG_VERSION" = "yes" ]; then
655 cvs $OPTIONS $TAGVER $SPECFILE
657 if [ -n "$TAG" ]; then
658 cvs $OPTIONS $TAG $SPECFILE
668 echo "CVS branch tag: $TAG"
673 if [ -n "$DEBUG" ]; then
678 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
681 if [ -n "$CVSROOT" ]; then
682 OPTIONS="-d $CVSROOT $OPTIONS"
685 for i in $TAG_FILES; do
686 if [ -f `nourl $i` ]; then
687 cvs $OPTIONS $TAG `nourl $i`
689 Exit_error err_no_source_in_repo $i
693 cvs $OPTIONS $TAG $SPECFILE
703 if [ -n "$DEBUG" ]; then
710 if [ -n "$TRY_UPGRADE" ]; then
712 if [ -n "$FLOAT_VERSION" ]; then
713 TNOTIFY=`./pldnotify.awk $SPECFILE -n`
715 TNOTIFY=`./pldnotify.awk $SPECFILE`
718 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
720 if [ -n "$TNEWVER" ]; then
722 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
724 echo "New version found, updating spec file to version " $TNEWVER
726 cp -f $SPECFILE $SPECFILE.bak
730 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
731 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE"
735 get_files "$SOURCES $PATCHES";
737 unset TOLDVER TNEWVER TNOTIFY
747 BUILD_SWITCH="-ba" ;;
749 BUILD_SWITCH="-bb" ;;
751 BUILD_SWITCH="-bs --nodeps" ;;
753 if [ -n "$LOGFILE" ]; then
754 LOG=`eval echo $LOGFILE`
755 if [ -n "$LASTLOG_FILE" ]; then
756 echo "LASTLOG=$LOG" > $LASTLOG_FILE
758 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
759 (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
760 RETVAL=`cat $RES_FILE`
762 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
763 if [ "$RETVAL" -eq "0" ]; then
770 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE
774 if [ "$RETVAL" -ne "0" ]; then
776 if [ -n "$TRY_UPGRADE" ]; then
777 echo "\n!!! Package with new version cannot be build automagically\n"
778 mv -f $SPECFILE.bak $SPECFILE
781 Exit_error err_build_fail;
789 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
794 AVAIL_BCONDS_WITHOUT=""
796 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
798 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
799 if [ "`echo $BCOND|grep -- "--without $AVAIL_BCOND_WITHOUT"`" != "" ];then
800 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
802 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
806 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
808 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
809 if [ "`echo $BCOND|grep -- "--with $AVAIL_BCOND_WITH"`" != "" ];then
810 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
812 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
819 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
820 echo -ne "We are going to build $SPECFILE with the following conditional flags:\n"
821 if [ "$BCOND" != "" ]; then
824 echo -ne "No --with || --without conditions passed to $0!"
826 echo -ne "\n\nfrom available:\n\n"
827 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
831 fetch_build_requires()
833 if [ "$FETCH_BUILD_REQUIRES" == "yes" ]; then
834 for package_item in `cat $SPECFILE|grep -B100000 ^%changelog|grep -v ^#|grep BuildRequires|grep -v ^-|sed -e "s/^.*BuildRequires://g"|awk '{print $1}'|sed -e s,\(.*\),,g -e s,%{,,g`
836 package_item=`echo $package_item|sed -e s,rpmbuild,rpm-build,g`
838 package=`basename "$package_item"|sed -e "s/}$//g"`
839 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
842 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
843 if [ "`echo $COND_TST|grep '^BuildRequires:'`" != "" ]; then
844 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
849 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
852 if [ "`echo $COND_TST|grep 'without_'`" != "" ]; then
853 COND_NAME=`echo $COND_NAME|sed -e s,^.*_without_,,g`
854 if [ "`echo $COND_TST|grep !`" != "" ]; then
859 if [ "`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`" != "" ]; then
865 elif [ "`echo $COND_TST|grep 'with_'`" != "" ]; then
866 COND_NAME=`echo $COND_NAME|sed -e s,^.*_with_,,g`
867 if [ "`echo $COND_TST|grep !`" != "" ]; then
872 if [ "`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`" != "" ]; then
878 RESULT="${COND_STATE}-${COND_ARGV}"
880 "with-wout" | "wout-with" )
883 "wout-wout" | "with-with" )
887 echo "Action '$RESULT' was not defined for package '$package_item'"
893 if [ "$GO" == "yes" ]; then
894 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
895 echo "Package $package is not installed. Attempting to install..."
899 echo "Unable to install $package package! Still trying to fetch rest..."
900 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package"
903 INSTALLED_PACKAGES="$package $INSTALLED_PACKAGES"
907 echo "Package $package is already installed. BuildRequirement satisfied."
911 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
912 echo "Nie uda³o siê zainstalowaæ nastêpuj±cych pakietów i ich zale¿no¶ci:"
913 for pkg in "$NOT_INSTALLED_PACKAGES"
922 #---------------------------------------------
925 if [ "$#" = 0 ]; then
930 while test $# -gt 0 ; do
947 DEBUG="yes"; shift ;;
949 COMMAND="version"; shift ;;
951 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
953 COMMAND="build"; shift ;;
954 -bb | --build-binary )
955 COMMAND="build-binary"; shift ;;
956 -bs | --build-source )
957 COMMAND="build-source"; shift ;;
959 COMMAND="branch"; shift; TAG="${1}"; shift;;
961 CLEAN="--clean --rmspec --rmsource"; shift ;;
963 shift; CVSROOT="${1}"; shift ;;
965 COMMAND="get"; shift ;;
967 COMMAND="usage"; shift ;;
969 PROTOCOL="http"; shift ;;
971 shift; LOGFILE="${1}"; shift ;;
973 shift; DEF_NICE_LEVEL=${1}; shift ;;
975 COMMAND="mr-proper"; shift ;;
977 NOCVS="yes"; shift ;;
978 -ncs | --no-cvs-specs )
979 NOCVSSPEC="yes"; shift ;;
980 -nd | --no-distfiles )
981 NODIST="yes"; shift ;;
983 NOMIRRORS="yes"; shift ;;
985 NOURLS="yes"; shift ;;
987 NOSRCS="yes"; shift ;;
988 -ns0 | --no-source0 )
989 NOSOURCE0="yes"; shift ;;
991 shift; RPMOPTS="${1}"; shift ;;
993 case $GROUP_BCONDS in
997 while [ "`echo ${1}|grep ^-`" == "" ] && [ "`echo ${1}|grep spec`" == "" ]
999 BCOND="$BCOND $COND $1"
1003 BCOND="$BCOND $1 $2" ; shift 2 ;;
1007 QUIET="--quiet"; shift ;;
1009 CVSDATE="${2}"; shift 2 ;;
1011 shift; CVSTAG="${1}"; shift ;;
1012 -R | --fetch-build-requires)
1013 FETCH_BUILD_REQUIRES="yes"
1014 #UPDATE_POLDEK_INDEXES="yes"
1015 NOT_INSTALLED_PACKAGES=
1017 -RB | --remove-build-requires)
1018 REMOVE_BUILD_REQUIRES="nice"
1020 -FRB | --force-remove-build-requires)
1021 REMOVE_BUILD_REQUIRES="force"
1023 -Tvs | --tag-version-stable )
1028 -Tvn | --tag-version-nest )
1033 -Ts | --tag-stable )
1043 -Tv | --tag-version )
1048 -Tp | --tag-prefix )
1064 -Upi | --update-poldek-indexes )
1065 UPDATE_POLDEK_INDEXES="yes"
1067 -u | --try-upgrade )
1068 TRY_UPGRADE="1"; shift ;;
1069 -un | --try-upgrade-with-float-version )
1070 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1072 BE_VERBOSE="1"; shift ;;
1078 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1082 RPMOPTS="${RPMOPTS} --nodeps"
1085 SPECFILE="`basename ${1} .spec`.spec"; shift ;;
1089 if [ -n "$DEBUG" ]; then
1095 "build" | "build-binary" | "build-source" )
1097 if [ -n "$SPECFILE" ]; then
1101 fetch_build_requires;
1104 if [ -n "$FAIL_IF_CHANGED_BUT_NOT_BUMPED" ]; then
1105 TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
1106 CURTAGREL=$(cvs status $SPECFILE | grep "Working revision:" | awk '{ print $3 }')
1107 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1109 if [ -n "$TAGREL" -a "$TAGREL" != "$CURTAGREL" ]; then
1110 Exit_error err_build_fail "not bumped ver-rel - was already used in rev $TAGREL"
1114 if [ -n "$ICONS" ]; then
1118 if [ -n "$NOSOURCE0" ] ; then
1119 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1121 get_files "$SOURCES $PATCHES";
1123 if [ $? -eq 0 ] && [ "$UPDATE_POLDEK_INDEXES" == "yes" ]; then
1124 poldek --sn ${POLDEK_SOURCE} --mkidx="${POLDEK_INDEX_DIR}/packages.dir.gz"
1125 poldek --sn ${POLDEK_SOURCE} --up
1127 case "$REMOVE_BUILD_REQUIRES" in
1129 poldek --noask -e $INSTALLED_PACKAGES
1132 poldek --ask -e $INSTALLED_PACKAGES
1135 echo You may want to manually remove following BuildRequires fetched:
1136 echo $INSTALLED_PACKAGES
1140 Exit_error err_no_spec_in_cmdl;
1145 if [ -n "$SPECFILE" ]; then
1148 if [ -n "$ICONS" ]; then
1152 get_files $SOURCES $PATCHES;
1153 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1155 Exit_error err_no_spec_in_cmdl;
1160 if [ -n "$SPECFILE" ]; then
1163 if [ -n "$ICONS" ]; then
1167 if [ -n "$NOSOURCE0" ] ; then
1168 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1170 get_files $SOURCES $PATCHES
1172 Exit_error err_no_spec_in_cmdl;
1177 if [ -n "$SPECFILE" ]; then
1180 if [ -n "$ICONS" ]; then
1184 # don't fetch sources from remote locations
1186 for file in $SOURCES; do
1187 [ "`nourl $file`" != "$file" ] && continue
1188 new_SOURCES="$new_SOURCES $file"
1190 SOURCES="$new_SOURCES"
1191 get_files $SOURCES $PATCHES;
1192 tag_files "$SOURCES $PATCHES $ICONS";
1194 Exit_error err_no_spec_in_cmdl;
1198 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE