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
115 if [ -n "$HOME_ETC" ]; then
116 USER_CFG=$HOME_ETC/.builderrc
118 USER_CFG=~/.builderrc
121 [ -f $USER_CFG ] && . $USER_CFG
123 #---------------------------------------------
128 if [ -n "$DEBUG" ]; then set -xv; fi
130 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
132 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
133 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
134 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
135 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
136 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
137 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
138 [{-Tp|--tag-prefix} <prefix>]
139 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
140 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
143 - update md5 comments in spec, implies -nd -ncs
144 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
145 -D, --debug - enable script debugging mode,
146 -V, --version - output builder version
147 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
149 --build - get all files from CVS repo or HTTP/FTP and build
150 package from <package>.spec,
152 - get all files from CVS repo or HTTP/FTP and build
153 binary only package from <package>.spec,
155 --build-source - get all files from CVS repo or HTTP/FTP and only
156 pack them into src.rpm,
157 -B, --branch - add branch
158 -c, --clean - clean all temporarily created files (in BUILD,
159 SOURCES, SPECS and \$RPM_BUILD_ROOT),
160 -d <cvsroot>, --cvsroot <cvsroot>
162 --define <macro> <value>
163 - define a macro <macro> with value <value>,
164 --nodeps - rpm won't check any dependences
165 -g, --get - get <package>.spec and all related files from
166 CVS repo or HTTP/FTP,
167 -h, --help - this message,
168 --http - use http instead of ftp,
169 -l <logfile>, --logtofile <logfile>
171 -m, --mr-proper - only remove all files related to spec file and
173 -nc, --no-cvs - don't download sources from CVS, if source URL is
176 - don't check specs in CVS
178 - don't download from distfiles
179 -nm, --no-mirrors - don't download from mirror, if source URL is given,
180 -nu, --no-urls - don't try to download from FTP/HTTP location,
181 -ns, --no-srcs - don't download Sources
183 - don't download Source0
185 - additional options for rpm
186 -q, --quiet - be quiet,
188 - build package using resources from specified CVS
190 -r <cvstag>, --cvstag <cvstag>
191 - build package using resources from specified CVS
193 -R, --fetch-build-requires
194 - fetch what is BuildRequired,
195 -RB, --remove-build-requires
196 - remove all you fetched with -R or --fetch-build-requires
197 remember, this option requires confirmation,
198 -FRB, --force-remove-build-requires
199 - remove all you fetched with -R or --fetch-build-requires
200 remember, this option works without confirmation,
201 -T <cvstag> , --tag <cvstag>
202 - add cvs tag <cvstag> for files,
203 -Tvs, --tag-version-stable
204 - add cvs tags STABLE and NAME-VERSION-RELESE for files,
205 -Tvn, --tag-version-nest
206 - add cvs tags NEST and NAME-VERSION-RELESE for files,
208 - add cvs tag STABLE for files,
210 - add cvs tag NEST for files,
212 - add cvs tag NAME-VERSION-RELESE for files,
213 -Tp, --tag-prefix <prefix>
214 - add <prefix> to NAME-VERSION-RELEASE tags,
215 -v, --verbose - be verbose,
217 - check version, and try to upgrade package
218 -un, --try-upgrade-with-float-version
219 - as above, but allow float version
221 - refetch sources, don't use distfiles, and update md5
223 -Upi, --update-poldek-indexes
224 - refresh or make poldek package index files.
225 --with/--without <feature>
226 - conditional build package depending on
227 %_with_<feature>/%_without_<feature> macro
229 You may now use --with feat1 feat2 feat3 --without feat4
230 feat5 --with feat6 constructions.
238 rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1
241 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1
247 if [ -z "$rpm_dump_cache" ] ; then
248 echo "internal error: cache_rpm_dump not called!" 1>&2
250 echo "$rpm_dump_cache"
255 if [ -n "$DEBUG" ]; then
264 if [ "$NOSRCS" != "yes" ]; then
265 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
267 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
268 FAIL_IF_NO_SOURCES="no"
271 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
272 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
273 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
274 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
275 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
277 if [ -n "$BE_VERBOSE" ]; then
278 echo "- Sources : `nourl $SOURCES`"
279 if [ -n "$PATCHES" ]; then
280 echo "- Patches : `nourl $PATCHES`"
282 echo "- Patches : *no patches needed*"
284 if [ -n "$ICONS" ]; then
285 echo "- Icon : `nourl $ICONS`"
287 echo "- Icon : *no package icon*"
289 echo "- Name : $PACKAGE_NAME"
290 echo "- Version : $PACKAGE_VERSION"
291 echo "- Release : $PACKAGE_RELEASE"
297 if [ -n "$DEBUG" ]; then
305 "err_no_spec_in_cmdl" )
306 remove_build_requires
307 echo "ERROR: spec file name not specified.";
309 "err_no_spec_in_repo" )
310 remove_build_requires
311 echo "Error: spec file not stored in CVS repo.";
313 "err_no_source_in_repo" )
314 remove_build_requires
315 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
318 remove_build_requires
319 echo "Error: package build failed. (${2:-no more info})";
326 if [ -n "$DEBUG" ]; then
331 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
332 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
339 if [ -n "$DEBUG" ]; then
344 if [ "$NOCVSSPEC" != "yes" ]; then
349 if [ -n "$CVSROOT" ]; then
350 OPTIONS="-d $CVSROOT $OPTIONS"
352 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
353 echo "warning: No cvs access defined - using local .spec file"
358 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
359 OPTIONS="$OPTIONS -A"
361 if [ -n "$CVSDATE" ]; then
362 OPTIONS="$OPTIONS -D $CVSDATE"
364 if [ -n "$CVSTAG" ]; then
365 OPTIONS="$OPTIONS -r $CVSTAG"
371 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
372 retries_counter=$(( $retries_counter + 1 ))
373 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
375 [ -n "$output" ] && echo "$output"
376 if [ "$result" -ne "0" ]; then
377 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
378 echo "Trying again [$SPECFILE]... ($retries_counter)"
382 Exit_error err_no_spec_in_repo;
386 if [ ! -f "$SPECFILE" ]; then
387 Exit_error err_no_spec_in_repo;
390 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
391 chmod $CHMOD_MODE $SPECFILE
394 grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
401 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
402 cvs update mirrors >&2
406 while read origin mirror name rest; do
407 ol=`echo -n "$origin"|wc -c`
408 prefix="`echo -n "$url" | head -c $ol`"
409 if [ "$prefix" = "$origin" ] ; then
410 suffix="`echo "$url"|cut -b $ol-`"
411 echo -n "$mirror$suffix"
422 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
423 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
430 [ -z "$no" ] && return
432 spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::)
433 if [ -z "$spec_rev" ]; then
434 spec_rev="$(head -1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
436 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
437 md5=$(grep -s -v '^#' additional-md5sums | \
438 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
439 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
440 grep -E '^[0-9a-f]{32}$')
441 if [ X"$md5" = X"" ] ; then
442 grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://' | xargs
444 if [ $(echo "$md5" | wc -l) != 1 ] ; then
445 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
447 echo "$md5" | tail -1
453 echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
460 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
467 if [ -n "$DEBUG" ]; then
472 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
476 if [ -n "$CVSROOT" ]; then
477 OPTIONS="-d $CVSROOT $OPTIONS"
479 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
480 echo "warning: No cvs access defined for SOURCES"
484 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
485 OPTIONS="$OPTIONS -A"
487 if [ -n "$CVSDATE" ]; then
488 OPTIONS="$OPTIONS -D $CVSDATE"
490 if [ -n "$CVSTAG" ]; then
491 OPTIONS="$OPTIONS -r $CVSTAG"
494 for i in $GET_FILES; do
495 if [ -n "$UPDATE5" ]; then
496 if [ -n "$ADD5" ]; then
497 [ `nourl $i` = "$i" ] && continue
498 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
500 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
504 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
505 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
506 echo "Warning: no URL given for $i"
509 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
510 if good_md5 "$i"; then
511 echo "$(nourl "$i") having proper md5sum already exists"
515 url=$(distfiles_url "$i")
516 if [ `echo $url | grep -E '^(\.|/)'` ]; then
517 ${GETLOCAL} $url $target
520 if [ -z "$NOMIRRORS" ]; then
521 url="`find_mirror "$url"`"
523 ${GETURI} -O "$target" "$url" || \
524 if [ `echo $url | grep -E 'ftp://'` ]; then
525 ${GETURI2} -O "$target" "$url"
527 if ! test -s "$target"; then
532 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
533 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
536 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
537 retries_counter=$(( $retries_counter + 1 ))
538 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
540 [ -n "$output" ] && echo "$output"
541 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
542 echo "Trying again [`nourl $i`]... ($retries_counter)"
551 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
552 if [ -z "$NOMIRRORS" ]; then
553 im="`find_mirror "$i"`"
558 if [ `echo $im | grep -E 'ftp://'` ]; then ${GETURI2} "$im" ; fi
564 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
565 Exit_error err_no_source_in_repo $i;
566 elif [ -n "$UPDATE5" ] && \
567 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
568 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
569 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
571 echo "Updating source-$srcno md5."
572 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
574 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
575 print "# Source'$srcno'-md5:\t'$md5'\n"
576 if /^Source'$srcno'\s*:\s+/;
581 if good_md5 "$i"; then
583 elif [ "$FROM_DISTFILES" = 1 ]; then
584 # wrong md5 from distfiles: remove the file and try again
586 echo "MD5 sum mismatch. Trying full fetch."
589 ${GETURI} -O "$target" "$url" || \
590 if [ `echo $url | grep -E 'ftp://'` ]; then
591 ${GETURI2} -O "$target" "$url"
593 test -s "$target" || rm -f "$target"
596 if good_md5 "$i"; then
599 echo "MD5 sum mismatch. Use -U to refetch sources,"
600 echo "or -5 to update md5 sums, if you're sure files are correct."
601 Exit_error err_no_source_in_repo $i
605 if [ "$CHMOD" = "yes" ]; then
606 CHMOD_FILES="`nourl $GET_FILES`"
607 if [ -n "$CHMOD_FILES" ]; then
608 chmod $CHMOD_MODE $CHMOD_FILES
619 if [ -n "$DEBUG" ]; then
624 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
625 echo "Version: $PACKAGE_VERSION"
626 echo "Release: $PACKAGE_RELEASE"
627 # Check whether first character of PACKAGE_NAME is legal for tag name
628 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
631 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"`
632 # Remove #kernel.version_release from TAGVER because tagging sources
633 # could occur with different kernel-headers than kernel-headers used at build time.
634 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
635 if [ "$TAG_VERSION" = "yes" ]; then
636 echo "CVS tag: $TAGVER"
638 if [ -n "$TAG" ]; then
643 if [ -n "$CVSROOT" ]; then
644 OPTIONS="-d $CVSROOT $OPTIONS"
648 for i in $TAG_FILES; do
649 # don't tag non cvs files (ie. stored on distfiles)
650 [ "`nourl $i`" != "$i" ] && continue
651 if [ -f "`nourl $i`" ]; then
652 if [ "$TAG_VERSION" = "yes" ]; then
653 cvs $OPTIONS $TAGVER `nourl $i`
655 if [ -n "$TAG" ]; then
656 cvs $OPTIONS $TAG `nourl $i`
659 Exit_error err_no_source_in_repo $i
664 if [ "$TAG_VERSION" = "yes" ]; then
665 cvs $OPTIONS $TAGVER $SPECFILE
667 if [ -n "$TAG" ]; then
668 cvs $OPTIONS $TAG $SPECFILE
678 echo "CVS branch tag: $TAG"
683 if [ -n "$DEBUG" ]; then
688 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
691 if [ -n "$CVSROOT" ]; then
692 OPTIONS="-d $CVSROOT $OPTIONS"
695 for i in $TAG_FILES; do
696 if [ -f `nourl $i` ]; then
697 cvs $OPTIONS $TAG `nourl $i`
699 Exit_error err_no_source_in_repo $i
703 cvs $OPTIONS $TAG $SPECFILE
713 if [ -n "$DEBUG" ]; then
720 if [ -n "$TRY_UPGRADE" ]; then
722 if [ -n "$FLOAT_VERSION" ]; then
723 TNOTIFY=`./pldnotify.awk $SPECFILE -n`
725 TNOTIFY=`./pldnotify.awk $SPECFILE`
728 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
730 if [ -n "$TNEWVER" ]; then
732 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
734 echo "New version found, updating spec file to version " $TNEWVER
736 cp -f $SPECFILE $SPECFILE.bak
740 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
741 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE"
745 get_files "$SOURCES $PATCHES";
747 unset TOLDVER TNEWVER TNOTIFY
757 BUILD_SWITCH="-ba" ;;
759 BUILD_SWITCH="-bb" ;;
761 BUILD_SWITCH="-bs --nodeps" ;;
763 if [ -n "$LOGFILE" ]; then
764 LOG=`eval echo $LOGFILE`
765 if [ -n "$LASTLOG_FILE" ]; then
766 echo "LASTLOG=$LOG" > $LASTLOG_FILE
768 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
769 (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
770 RETVAL=`cat $RES_FILE`
772 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
773 if [ "$RETVAL" -eq "0" ]; then
780 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE
784 if [ "$RETVAL" -ne "0" ]; then
786 if [ -n "$TRY_UPGRADE" ]; then
787 echo "\n!!! Package with new version cannot be build automagically\n"
788 mv -f $SPECFILE.bak $SPECFILE
791 Exit_error err_build_fail;
799 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
804 AVAIL_BCONDS_WITHOUT=""
806 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
808 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
809 if [ "`echo $BCOND|grep -- "--without $AVAIL_BCOND_WITHOUT"`" != "" ];then
810 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
812 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
816 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
818 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
819 if [ "`echo $BCOND|grep -- "--with $AVAIL_BCOND_WITH"`" != "" ];then
820 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
822 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
827 remove_build_requires()
829 if [ "$INSTALLED_PACKAGES" != "" ]; then
830 case "$REMOVE_BUILD_REQUIRES" in
832 poldek --noask -e $INSTALLED_PACKAGES
835 poldek --ask -e $INSTALLED_PACKAGES
838 echo You may want to manually remove following BuildRequires fetched:
839 echo $INSTALLED_PACKAGES
840 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
848 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
849 echo -ne "We are going to build $SPECFILE with the following conditional flags:\n"
850 if [ "$BCOND" != "" ]; then
853 echo -ne "No --with || --without conditions passed to $0!"
855 echo -ne "\n\nfrom available:\n\n"
856 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
860 fetch_build_requires()
862 if [ "$FETCH_BUILD_REQUIRES" = "yes" ]; then
863 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
864 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
865 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
866 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
867 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
868 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`
870 package_item=`echo $package_item|sed -e s,rpmbuild,rpm-build,g`
872 package=`basename "$package_item"|sed -e "s/}$//g"`
873 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
876 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
877 if [ "`echo $COND_TST|grep '^BuildRequires:'`" != "" ]; then
878 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
883 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
886 if [ "`echo $COND_TST|grep 'without_'`" != "" ]; then
887 COND_NAME=`echo $COND_NAME|sed -e s,^.*_without_,,g`
888 if [ "`echo $COND_TST|grep !`" != "" ]; then
893 if [ "`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`" != "" ]; then
899 elif [ "`echo $COND_TST|grep 'with_'`" != "" ]; then
900 COND_NAME=`echo $COND_NAME|sed -e s,^.*_with_,,g`
901 if [ "`echo $COND_TST|grep !`" != "" ]; then
906 if [ "`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`" != "" ]; then
912 RESULT="${COND_STATE}-${COND_ARGV}"
914 "with-wout" | "wout-with" )
917 "wout-wout" | "with-with" )
921 echo "Action '$RESULT' was not defined for package '$package_item'"
927 if [ "$GO" = "yes" ]; then
928 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
929 echo "Testing if $package has subrequirements..."
930 poldek -t -i $package --dumpn=".$package-req.txt"
931 for package_name in `cat ".$package-req.txt"|grep -v ^#`
933 if [ "$package_name" = "$package" ]; then
934 echo -ne "Installing BuildRequired package:\t$package_name\n"
935 poldek -i $package_name
937 echo -ne "Installing (sub)Required package:\t$package_name\n"
938 poldek -i $package_name
942 echo -ne "Package installation failed:\t$package_name\n"
944 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
947 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
950 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
951 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
955 rm ".$package-req.txt"
957 echo "Package $package is already installed. BuildRequirement satisfied."
961 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
962 echo "Nie uda³o siê zainstalowaæ nastêpuj±cych pakietów i ich zale¿no¶ci:"
963 for pkg in "$NOT_INSTALLED_PACKAGES"
967 remove_build_requires
973 #---------------------------------------------
976 if [ "$#" = 0 ]; then
981 while test $# -gt 0 ; do
998 DEBUG="yes"; shift ;;
1000 COMMAND="version"; shift ;;
1002 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1003 -b | -ba | --build )
1004 COMMAND="build"; shift ;;
1005 -bb | --build-binary )
1006 COMMAND="build-binary"; shift ;;
1007 -bs | --build-source )
1008 COMMAND="build-source"; shift ;;
1010 COMMAND="branch"; shift; TAG="${1}"; shift;;
1012 CLEAN="--clean --rmspec --rmsource"; shift ;;
1014 shift; CVSROOT="${1}"; shift ;;
1016 COMMAND="get"; shift ;;
1018 COMMAND="usage"; shift ;;
1020 PROTOCOL="http"; shift ;;
1022 shift; LOGFILE="${1}"; shift ;;
1024 shift; DEF_NICE_LEVEL=${1}; shift ;;
1026 COMMAND="mr-proper"; shift ;;
1028 NOCVS="yes"; shift ;;
1029 -ncs | --no-cvs-specs )
1030 NOCVSSPEC="yes"; shift ;;
1031 -nd | --no-distfiles )
1032 NODIST="yes"; shift ;;
1033 -nm | --no-mirrors )
1034 NOMIRRORS="yes"; shift ;;
1036 NOURLS="yes"; shift ;;
1038 NOSRCS="yes"; shift ;;
1039 -ns0 | --no-source0 )
1040 NOSOURCE0="yes"; shift ;;
1042 shift; RPMOPTS="${1}"; shift ;;
1043 --with | --without )
1044 case $GROUP_BCONDS in
1048 while [ "`echo ${1}|grep ^-`" = "" ] && [ "`echo ${1}|grep spec`" = "" ]
1050 BCOND="$BCOND $COND $1"
1054 BCOND="$BCOND $1 $2" ; shift 2 ;;
1058 QUIET="--quiet"; shift ;;
1060 CVSDATE="${2}"; shift 2 ;;
1062 shift; CVSTAG="${1}"; shift ;;
1063 -R | --fetch-build-requires)
1064 FETCH_BUILD_REQUIRES="yes"
1065 #UPDATE_POLDEK_INDEXES="yes"
1066 NOT_INSTALLED_PACKAGES=
1068 -RB | --remove-build-requires)
1069 REMOVE_BUILD_REQUIRES="nice"
1071 -FRB | --force-remove-build-requires)
1072 REMOVE_BUILD_REQUIRES="force"
1074 -Tvs | --tag-version-stable )
1079 -Tvn | --tag-version-nest )
1084 -Ts | --tag-stable )
1094 -Tv | --tag-version )
1099 -Tp | --tag-prefix )
1115 -Upi | --update-poldek-indexes )
1116 UPDATE_POLDEK_INDEXES="yes"
1118 -u | --try-upgrade )
1119 TRY_UPGRADE="1"; shift ;;
1120 -un | --try-upgrade-with-float-version )
1121 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1123 BE_VERBOSE="1"; shift ;;
1129 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1133 RPMOPTS="${RPMOPTS} --nodeps"
1136 SPECFILE="`basename ${1} .spec`.spec"; shift ;;
1140 if [ -n "$DEBUG" ]; then
1146 "build" | "build-binary" | "build-source" )
1148 if [ -n "$SPECFILE" ]; then
1152 fetch_build_requires;
1155 if [ -n "$FAIL_IF_CHANGED_BUT_NOT_BUMPED" ]; then
1156 TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
1157 CURTAGREL=$(cvs status $SPECFILE | grep "Working revision:" | awk '{ print $3 }')
1158 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1160 if [ -n "$TAGREL" -a "$TAGREL" != "$CURTAGREL" ]; then
1161 Exit_error err_build_fail "not bumped ver-rel - was already used in rev $TAGREL"
1165 if [ -n "$ICONS" ]; then
1169 if [ -n "$NOSOURCE0" ] ; then
1170 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1172 get_files "$SOURCES $PATCHES";
1174 if [ "$UPDATE_POLDEK_INDEXES" = "yes" ]; then
1175 poldek --sn ${POLDEK_SOURCE} --mkidx="${POLDEK_INDEX_DIR}/packages.dir.gz"
1176 poldek --sn ${POLDEK_SOURCE} --up
1178 remove_build_requires;
1180 Exit_error err_no_spec_in_cmdl;
1185 if [ -n "$SPECFILE" ]; then
1188 if [ -n "$ICONS" ]; then
1192 get_files $SOURCES $PATCHES;
1193 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1195 Exit_error err_no_spec_in_cmdl;
1200 if [ -n "$SPECFILE" ]; then
1203 if [ -n "$ICONS" ]; then
1207 if [ -n "$NOSOURCE0" ] ; then
1208 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1210 get_files $SOURCES $PATCHES
1212 Exit_error err_no_spec_in_cmdl;
1217 if [ -n "$SPECFILE" ]; then
1220 if [ -n "$ICONS" ]; then
1224 # don't fetch sources from remote locations
1226 for file in $SOURCES; do
1227 [ "`nourl $file`" != "$file" ] && continue
1228 new_SOURCES="$new_SOURCES $file"
1230 SOURCES="$new_SOURCES"
1231 get_files $SOURCES $PATCHES;
1232 tag_files "$SOURCES $PATCHES $ICONS";
1234 Exit_error err_no_spec_in_cmdl;
1238 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE