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="`$RPM --eval %_rpmdir`/"
99 # Example grep cvs /etc/poldek.conf:
100 # source = cvs /home/users/yoshi/rpm/RPMS/
101 if [ "$UPDATE_POLDEK_INDEXES" == "yes" ]; then
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"
110 if [ -f ~/etc/builderrc ]; then
112 elif [ -f ~/.builderrc ]; then
116 #---------------------------------------------
121 if [ -n "$DEBUG" ]; then set -xv; fi
123 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
125 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
126 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
127 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
128 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
129 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
130 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
131 [{-Tp|--tag-prefix} <prefix>]
132 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
133 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
136 - update md5 comments in spec, implies -nd -ncs
137 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
138 -D, --debug - enable script debugging mode,
139 -V, --version - output builder version
140 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
142 --build - get all files from CVS repo or HTTP/FTP and build
143 package from <package>.spec,
145 - get all files from CVS repo or HTTP/FTP and build
146 binary only package from <package>.spec,
148 --build-source - get all files from CVS repo or HTTP/FTP and only
149 pack them into src.rpm,
150 -B, --branch - add branch
151 -c, --clean - clean all temporarily created files (in BUILD,
152 SOURCES, SPECS and \$RPM_BUILD_ROOT),
153 -d <cvsroot>, --cvsroot <cvsroot>
155 --define <macro> <value>
156 - define a macro <macro> with value <value>,
157 --nodeps - rpm won't check any dependences
158 -g, --get - get <package>.spec and all related files from
159 CVS repo or HTTP/FTP,
160 -h, --help - this message,
161 --http - use http instead of ftp,
162 -l <logfile>, --logtofile <logfile>
164 -m, --mr-proper - only remove all files related to spec file and
166 -nc, --no-cvs - don't download sources from CVS, if source URL is
169 - don't check specs in CVS
171 - don't download from distfiles
172 -nm, --no-mirrors - don't download from mirror, if source URL is given,
173 -nu, --no-urls - don't try to download from FTP/HTTP location,
174 -ns, --no-srcs - don't download Sources
176 - don't download Source0
178 - additional options for rpm
179 -q, --quiet - be quiet,
181 - build package using resources from specified CVS
183 -r <cvstag>, --cvstag <cvstag>
184 - build package using resources from specified CVS
186 -R, --fetch-build-requires
187 - fetch what is BuildRequired,
188 -T <cvstag> , --tag <cvstag>
189 - add cvs tag <cvstag> for files,
190 -Tvs, --tag-version-stable
191 - add cvs tags STABLE and NAME-VERSION-RELESE for files,
192 -Tvn, --tag-version-nest
193 - add cvs tags NEST and NAME-VERSION-RELESE for files,
195 - add cvs tag STABLE for files,
197 - add cvs tag NEST for files,
199 - add cvs tag NAME-VERSION-RELESE for files,
200 -Tp, --tag-prefix <prefix>
201 - add <prefix> to NAME-VERSION-RELEASE tags,
202 -v, --verbose - be verbose,
204 - check version, and try to upgrade package
205 -un, --try-upgrade-with-float-version
206 - as above, but allow float version
208 - refetch sources, don't use distfiles, and update md5
210 -Upi, --update-poldek-indexes
211 - refresh or make poldek package index files.
212 --with/--without <feature>
213 - conditional build package depending on
214 %_with_<feature>/%_without_<feature> macro
216 You may now use --with feat1 feat2 feat3 --without feat4
217 feat5 --with feat6 constructions.
225 rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1
228 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1
234 if [ -z "$rpm_dump_cache" ] ; then
235 echo "internal error: cache_rpm_dump not called!" 1>&2
237 echo "$rpm_dump_cache"
242 if [ -n "$DEBUG" ]; then
251 if [ "$NOSRCS" != "yes" ]; then
252 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
254 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
255 FAIL_IF_NO_SOURCES="no"
258 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
259 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
260 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
261 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
262 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
264 if [ -n "$BE_VERBOSE" ]; then
265 echo "- Sources : `nourl $SOURCES`"
266 if [ -n "$PATCHES" ]; then
267 echo "- Patches : `nourl $PATCHES`"
269 echo "- Patches : *no patches needed*"
271 if [ -n "$ICONS" ]; then
272 echo "- Icon : `nourl $ICONS`"
274 echo "- Icon : *no package icon*"
276 echo "- Name : $PACKAGE_NAME"
277 echo "- Version : $PACKAGE_VERSION"
278 echo "- Release : $PACKAGE_RELEASE"
284 if [ -n "$DEBUG" ]; then
292 "err_no_spec_in_cmdl" )
293 echo "ERROR: spec file name not specified.";
295 "err_no_spec_in_repo" )
296 echo "Error: spec file not stored in CVS repo.";
298 "err_no_source_in_repo" )
299 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
302 echo "Error: package build failed. (${2:-no more info})";
309 if [ -n "$DEBUG" ]; then
314 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
315 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
322 if [ -n "$DEBUG" ]; then
327 if [ "$NOCVSSPEC" != "yes" ]; then
332 if [ -n "$CVSROOT" ]; then
333 OPTIONS="-d $CVSROOT $OPTIONS"
335 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
336 echo "warning: No cvs access defined - using local .spec file"
341 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
342 OPTIONS="$OPTIONS -A"
344 if [ -n "$CVSDATE" ]; then
345 OPTIONS="$OPTIONS -D $CVSDATE"
347 if [ -n "$CVSTAG" ]; then
348 OPTIONS="$OPTIONS -r $CVSTAG"
354 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
355 retries_counter=$(( $retries_counter + 1 ))
356 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
358 [ -n "$output" ] && echo "$output"
359 if [ "$result" -ne "0" ]; then
360 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
361 echo "Trying again [$SPECFILE]... ($retries_counter)"
365 Exit_error err_no_spec_in_repo;
369 if [ ! -f "$SPECFILE" ]; then
370 Exit_error err_no_spec_in_repo;
373 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
374 chmod $CHMOD_MODE $SPECFILE
377 grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
384 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
385 cvs update mirrors >&2
389 while read origin mirror name rest; do
390 ol=`echo -n "$origin"|wc -c`
391 prefix="`echo -n "$url" | head -c $ol`"
392 if [ "$prefix" = "$origin" ] ; then
393 suffix="`echo "$url"|cut -b $ol-`"
394 echo -n "$mirror$suffix"
405 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
406 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
413 [ -z "$no" ] && return
415 spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::)
416 if [ -z "$spec_rev" ]; then
417 spec_rev="$(head -1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
419 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
420 md5=$(grep -s -v '^#' additional-md5sums | \
421 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
422 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
423 grep -E '^[0-9a-f]{32}$')
424 if [ X"$md5" = X"" ] ; then
425 grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://' | xargs
427 if [ $(echo "$md5" | wc -l) != 1 ] ; then
428 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
430 echo "$md5" | tail -1
436 echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
443 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
450 if [ -n "$DEBUG" ]; then
455 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
459 if [ -n "$CVSROOT" ]; then
460 OPTIONS="-d $CVSROOT $OPTIONS"
462 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
463 echo "warning: No cvs access defined for SOURCES"
467 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
468 OPTIONS="$OPTIONS -A"
470 if [ -n "$CVSDATE" ]; then
471 OPTIONS="$OPTIONS -D $CVSDATE"
473 if [ -n "$CVSTAG" ]; then
474 OPTIONS="$OPTIONS -r $CVSTAG"
477 for i in $GET_FILES; do
478 if [ -n "$UPDATE5" ]; then
479 if [ -n "$ADD5" ]; then
480 [ `nourl $i` = "$i" ] && continue
481 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
483 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
487 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
488 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
489 echo "Warning: no URL given for $i"
492 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
493 if good_md5 "$i"; then
494 echo "$(nourl "$i") having proper md5sum already exists"
498 url=$(distfiles_url "$i")
499 if [ `echo $url | grep -E '^(\.|/)'` ]; then
500 ${GETLOCAL} $url $target
503 if [ -z "$NOMIRRORS" ]; then
504 url="`find_mirror "$url"`"
506 ${GETURI} -O "$target" "$url" || \
507 if [ `echo $url | grep -E 'ftp://'` ]; then
508 ${GETURI2} -O "$target" "$url"
510 if ! test -s "$target"; then
515 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
516 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
519 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
520 retries_counter=$(( $retries_counter + 1 ))
521 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
523 [ -n "$output" ] && echo "$output"
524 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
525 echo "Trying again [`nourl $i`]... ($retries_counter)"
534 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
535 if [ -z "$NOMIRRORS" ]; then
536 im="`find_mirror "$i"`"
541 if [ `echo $im | grep -E 'ftp://'` ]; then ${GETURI2} "$im" ; fi
547 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
548 Exit_error err_no_source_in_repo $i;
549 elif [ -n "$UPDATE5" ] && \
550 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
551 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
552 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
554 echo "Updating source-$srcno md5."
555 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
557 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
558 print "# Source'$srcno'-md5:\t'$md5'\n"
559 if /^Source'$srcno'\s*:\s+/;
564 if good_md5 "$i"; then
566 elif [ "$FROM_DISTFILES" = 1 ]; then
567 # wrong md5 from distfiles: remove the file and try again
569 echo "MD5 sum mismatch. Trying full fetch."
572 ${GETURI} -O "$target" "$url" || \
573 if [ `echo $url | grep -E 'ftp://'` ]; then
574 ${GETURI2} -O "$target" "$url"
576 test -s "$target" || rm -f "$target"
579 if good_md5 "$i"; then
582 echo "MD5 sum mismatch. Use -U to refetch sources,"
583 echo "or -5 to update md5 sums, if you're sure files are correct."
584 Exit_error err_no_source_in_repo $i
588 if [ "$CHMOD" = "yes" ]; then
589 CHMOD_FILES="`nourl $GET_FILES`"
590 if [ -n "$CHMOD_FILES" ]; then
591 chmod $CHMOD_MODE $CHMOD_FILES
602 if [ -n "$DEBUG" ]; then
607 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
608 echo "Version: $PACKAGE_VERSION"
609 echo "Release: $PACKAGE_RELEASE"
610 # Check whether first character of PACKAGE_NAME is legal for tag name
611 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
614 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"`
615 # Remove #kernel.version_release from TAGVER because tagging sources
616 # could occur with different kernel-headers than kernel-headers used at build time.
617 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
618 if [ "$TAG_VERSION" = "yes" ]; then
619 echo "CVS tag: $TAGVER"
621 if [ -n "$TAG" ]; then
626 if [ -n "$CVSROOT" ]; then
627 OPTIONS="-d $CVSROOT $OPTIONS"
631 for i in $TAG_FILES; do
632 # don't tag non cvs files (ie. stored on distfiles)
633 [ "`nourl $i`" != "$i" ] && continue
634 if [ -f "`nourl $i`" ]; then
635 if [ "$TAG_VERSION" = "yes" ]; then
636 cvs $OPTIONS $TAGVER `nourl $i`
638 if [ -n "$TAG" ]; then
639 cvs $OPTIONS $TAG `nourl $i`
642 Exit_error err_no_source_in_repo $i
647 if [ "$TAG_VERSION" = "yes" ]; then
648 cvs $OPTIONS $TAGVER $SPECFILE
650 if [ -n "$TAG" ]; then
651 cvs $OPTIONS $TAG $SPECFILE
661 echo "CVS branch tag: $TAG"
666 if [ -n "$DEBUG" ]; then
671 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
674 if [ -n "$CVSROOT" ]; then
675 OPTIONS="-d $CVSROOT $OPTIONS"
678 for i in $TAG_FILES; do
679 if [ -f `nourl $i` ]; then
680 cvs $OPTIONS $TAG `nourl $i`
682 Exit_error err_no_source_in_repo $i
686 cvs $OPTIONS $TAG $SPECFILE
696 if [ -n "$DEBUG" ]; then
703 if [ -n "$TRY_UPGRADE" ]; then
705 if [ -n "$FLOAT_VERSION" ]; then
706 TNOTIFY=`./pldnotify.awk $SPECFILE -n`
708 TNOTIFY=`./pldnotify.awk $SPECFILE`
711 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
713 if [ -n "$TNEWVER" ]; then
715 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
717 echo "New version found, updating spec file to version " $TNEWVER
719 cp -f $SPECFILE $SPECFILE.bak
723 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
724 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE"
728 get_files "$SOURCES $PATCHES";
730 unset TOLDVER TNEWVER TNOTIFY
740 BUILD_SWITCH="-ba" ;;
742 BUILD_SWITCH="-bb" ;;
744 BUILD_SWITCH="-bs --nodeps" ;;
746 if [ -n "$LOGFILE" ]; then
747 LOG=`eval echo $LOGFILE`
748 if [ -n "$LASTLOG_FILE" ]; then
749 echo "LASTLOG=$LOG" > $LASTLOG_FILE
751 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
752 (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
753 RETVAL=`cat $RES_FILE`
755 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
756 if [ "$RETVAL" -eq "0" ]; then
763 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE
767 if [ "$RETVAL" -ne "0" ]; then
769 if [ -n "$TRY_UPGRADE" ]; then
770 echo "\n!!! Package with new version cannot be build automagically\n"
771 mv -f $SPECFILE.bak $SPECFILE
774 Exit_error err_build_fail;
782 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
787 AVAIL_BCONDS_WITHOUT=""
789 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
791 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
792 if [ "`echo $BCOND|grep -- "--without $AVAIL_BCOND_WITHOUT"`" != "" ];then
793 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
795 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
799 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
801 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
802 if [ "`echo $BCOND|grep -- "--with $AVAIL_BCOND_WITH"`" != "" ];then
803 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
805 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
812 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
813 echo -ne "We are going to build $SPECFILE with the following confitional flags:\n"
814 if [ "$BCOND" != "" ]; then
817 echo -ne "No --with || --without conditions passed to $0!"
819 echo -ne "\n\nfrom available:\n\n"
820 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
824 fetch_build_requires()
826 if [ "$FETCH_BUILD_REQUIRES" == "yes" ]; then
827 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`
829 package_item=`echo $package_item|sed -e s,rpmbuild,rpm-build,g`
831 package=`basename "$package_item"|sed -e "s/}$//g"`
832 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
835 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
836 if [ "`echo $COND_TST|grep '^BuildRequires:'`" != "" ]; then
837 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
842 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
845 if [ "`echo $COND_TST|grep 'without_'`" != "" ]; then
846 COND_NAME=`echo $COND_NAME|sed -e s,^.*_without_,,g`
847 if [ "`echo $COND_TST|grep !`" != "" ]; then
852 if [ "`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`" != "" ]; then
858 elif [ "`echo $COND_TST|grep 'with_'`" != "" ]; then
859 COND_NAME=`echo $COND_NAME|sed -e s,^.*_with_,,g`
860 if [ "`echo $COND_TST|grep !`" != "" ]; then
865 if [ "`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`" != "" ]; then
871 RESULT="${COND_STATE}-${COND_ARGV}"
873 "with-wout" | "wout-with" )
876 "wout-wout" | "with-with" )
880 echo "Action '$RESULT' was not defined for package '$package_item'"
886 if [ "$GO" == "yes" ]; then
887 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
888 echo "Package $package is not installed. Attempting to install..."
892 echo "Unable to install $package package! Still trying to fetch rest..."
893 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package"
896 INSTALLED_PACKAGES="$package $INSTALLED_PACKAGES"
900 echo "Package $package is already installed. BuildRequirement satisfied."
904 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
905 echo "Nie uda³o siê zainstalowaæ nastêpuj±cych pakietów i ich zale¿no¶ci:"
906 for pkg in "$NOT_INSTALLED_PACKAGES"
915 #---------------------------------------------
918 if [ "$#" = 0 ]; then
923 while test $# -gt 0 ; do
940 DEBUG="yes"; shift ;;
942 COMMAND="version"; shift ;;
944 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
946 COMMAND="build"; shift ;;
947 -bb | --build-binary )
948 COMMAND="build-binary"; shift ;;
949 -bs | --build-source )
950 COMMAND="build-source"; shift ;;
952 COMMAND="branch"; shift; TAG="${1}"; shift;;
954 CLEAN="--clean --rmspec --rmsource"; shift ;;
956 shift; CVSROOT="${1}"; shift ;;
958 COMMAND="get"; shift ;;
960 COMMAND="usage"; shift ;;
962 PROTOCOL="http"; shift ;;
964 shift; LOGFILE="${1}"; shift ;;
966 shift; DEF_NICE_LEVEL=${1}; shift ;;
968 COMMAND="mr-proper"; shift ;;
970 NOCVS="yes"; shift ;;
971 -ncs | --no-cvs-specs )
972 NOCVSSPEC="yes"; shift ;;
973 -nd | --no-distfiles )
974 NODIST="yes"; shift ;;
976 NOMIRRORS="yes"; shift ;;
978 NOURLS="yes"; shift ;;
980 NOSRCS="yes"; shift ;;
981 -ns0 | --no-source0 )
982 NOSOURCE0="yes"; shift ;;
984 shift; RPMOPTS="${1}"; shift ;;
988 while [ "`echo ${1}|grep ^-`" == "" ] && [ "`echo ${1}|grep spec`" == "" ]
990 BCOND="$BCOND $COND $1"
994 QUIET="--quiet"; shift ;;
996 CVSDATE="${2}"; shift 2 ;;
998 shift; CVSTAG="${1}"; shift ;;
999 -R | --fetch-build-requires)
1000 FETCH_BUILD_REQUIRES="yes"
1001 #UPDATE_POLDEK_INDEXES="yes"
1002 NOT_INSTALLED_PACKAGES=
1004 -Tvs | --tag-version-stable )
1009 -Tvn | --tag-version-nest )
1014 -Ts | --tag-stable )
1024 -Tv | --tag-version )
1029 -Tp | --tag-prefix )
1045 -Upi | --update-poldek-indexes )
1046 UPDATE_POLDEK_INDEXES="yes"
1048 -u | --try-upgrade )
1049 TRY_UPGRADE="1"; shift ;;
1050 -un | --try-upgrade-with-float-version )
1051 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1053 BE_VERBOSE="1"; shift ;;
1059 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1063 RPMOPTS="${RPMOPTS} --nodeps"
1066 SPECFILE="`basename ${1} .spec`.spec"; shift ;;
1070 if [ -n "$DEBUG" ]; then
1076 "build" | "build-binary" | "build-source" )
1078 if [ -n "$SPECFILE" ]; then
1082 fetch_build_requires;
1085 if [ -n "$FAIL_IF_CHANGED_BUT_NOT_BUMPED" ]; then
1086 TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
1087 CURTAGREL=$(cvs status $SPECFILE | grep "Working revision:" | awk '{ print $3 }')
1088 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1090 if [ -n "$TAGREL" -a "$TAGREL" != "$CURTAGREL" ]; then
1091 Exit_error err_build_fail "not bumped ver-rel - was already used in rev $TAGREL"
1095 if [ -n "$ICONS" ]; then
1099 if [ -n "$NOSOURCE0" ] ; then
1100 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1102 get_files "$SOURCES $PATCHES";
1104 if [ $? -eq 0 ] && [ "$UPDATE_POLDEK_INDEXES" == "yes" ]; then
1105 poldek --sn ${POLDEK_SOURCE} --mkidx="${POLDEK_INDEX_DIR}/packages.dir.gz"
1106 poldek --sn ${POLDEK_SOURCE} --up
1109 Exit_error err_no_spec_in_cmdl;
1114 if [ -n "$SPECFILE" ]; then
1117 if [ -n "$ICONS" ]; then
1121 get_files $SOURCES $PATCHES;
1122 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1124 Exit_error err_no_spec_in_cmdl;
1129 if [ -n "$SPECFILE" ]; then
1132 if [ -n "$ICONS" ]; then
1136 if [ -n "$NOSOURCE0" ] ; then
1137 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1139 get_files $SOURCES $PATCHES
1141 Exit_error err_no_spec_in_cmdl;
1146 if [ -n "$SPECFILE" ]; then
1149 if [ -n "$ICONS" ]; then
1153 # don't fetch sources from remote locations
1155 for file in $SOURCES; do
1156 [ "`nourl $file`" != "$file" ] && continue
1157 new_SOURCES="$new_SOURCES $file"
1159 SOURCES="$new_SOURCES"
1160 get_files $SOURCES $PATCHES;
1161 tag_files "$SOURCES $PATCHES $ICONS";
1163 Exit_error err_no_spec_in_cmdl;
1167 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE