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"}
44 # Example: LOGFILE='../log.$PACKAGE_NAME'
45 # Yes, you can use variable name! Note _single_ quotes!
65 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
66 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
71 CVS_SERVER="cvs.pld-linux.org"
72 DISTFILES_SERVER="://distfiles.pld-linux.org"
76 FAIL_IF_NO_SOURCES="yes"
78 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
79 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
81 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
82 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
85 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
93 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
96 # Example grep cvs /etc/poldek.conf:
97 # source = cvs /home/users/yoshi/rpm/RPMS/
98 if [ "$UPDATE_POLDEK_INDEXES" = "yes" ]; then
99 POLDEK_SOURCE_VALIDITY="`grep ${POLDEK_SOURCE} /etc/poldek.conf|grep -v ^#`"
100 if [ "${POLDEK_SOURCE_VALIDITY}" = "" ]; then
101 echo "Using improper source '${POLDEK_SOURCE}' in /etc/poldek.conf"
102 echo "Fix it and try to contiune"
107 if [ -f ~/etc/builderrc ]; then
111 if [ -n "$HOME_ETC" ]; then
112 USER_CFG=$HOME_ETC/.builderrc
114 USER_CFG=~/.builderrc
117 [ -f $USER_CFG ] && . $USER_CFG
119 #---------------------------------------------
124 if [ -n "$DEBUG" ]; then set -xv; fi
126 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
128 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
129 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
130 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
131 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
132 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
133 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
134 [{-Tp|--tag-prefix} <prefix>]
135 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
136 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
139 - update md5 comments in spec, implies -nd -ncs
140 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
141 -D, --debug - enable script debugging mode,
142 -V, --version - output builder version
143 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
145 --build - get all files from CVS repo or HTTP/FTP and build
146 package from <package>.spec,
148 - get all files from CVS repo or HTTP/FTP and build
149 binary only package from <package>.spec,
151 --build-source - get all files from CVS repo or HTTP/FTP and only
152 pack them into src.rpm,
154 - execute the %prep phase of <package>.spec,
155 -B, --branch - add branch
156 -c, --clean - clean all temporarily created files (in BUILD,
157 SOURCES, SPECS and \$RPM_BUILD_ROOT),
158 -d <cvsroot>, --cvsroot <cvsroot>
160 --define <macro> <value>
161 - define a macro <macro> with value <value>,
162 --nodeps - rpm won't check any dependences
163 -g, --get - get <package>.spec and all related files from
164 CVS repo or HTTP/FTP,
165 -h, --help - this message,
166 --http - use http instead of ftp,
167 -l <logfile>, --logtofile <logfile>
169 -m, --mr-proper - only remove all files related to spec file and
171 -nc, --no-cvs - don't download sources from CVS, if source URL is
174 - don't check specs in CVS
176 - don't download from distfiles
177 -nm, --no-mirrors - don't download from mirror, if source URL is given,
178 -nu, --no-urls - don't try to download from FTP/HTTP location,
179 -ns, --no-srcs - don't download Sources
181 - don't download Source0
183 - additional options for rpm
184 -q, --quiet - be quiet,
186 - build package using resources from specified CVS
188 -r <cvstag>, --cvstag <cvstag>
189 - build package using resources from specified CVS
191 -R, --fetch-build-requires
192 - fetch what is BuildRequired,
193 -RB, --remove-build-requires
194 - remove all you fetched with -R or --fetch-build-requires
195 remember, this option requires confirmation,
196 -FRB, --force-remove-build-requires
197 - remove all you fetched with -R or --fetch-build-requires
198 remember, this option works without confirmation,
199 -T <cvstag> , --tag <cvstag>
200 - add cvs tag <cvstag> for files,
201 -Tvs, --tag-version-stable
202 - add cvs tags STABLE and NAME-VERSION-RELESE for files,
203 -Tvn, --tag-version-nest
204 - add cvs tags NEST and NAME-VERSION-RELESE for files,
206 - add cvs tag STABLE for files,
208 - add cvs tag NEST for files,
210 - add cvs tag NAME-VERSION-RELESE for files,
211 -Tp, --tag-prefix <prefix>
212 - add <prefix> to NAME-VERSION-RELEASE tags,
213 -v, --verbose - be verbose,
215 - check version, and try to upgrade package
216 -un, --try-upgrade-with-float-version
217 - as above, but allow float version
219 - refetch sources, don't use distfiles, and update md5
221 -Upi, --update-poldek-indexes
222 - refresh or make poldek package index files.
223 --with/--without <feature>
224 - conditional build package depending on
225 %_with_<feature>/%_without_<feature> macro
227 You may now use --with feat1 feat2 feat3 --without feat4
228 feat5 --with feat6 constructions.
236 rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1
239 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1
245 if [ -z "$rpm_dump_cache" ] ; then
246 echo "internal error: cache_rpm_dump not called!" 1>&2
248 echo "$rpm_dump_cache"
253 if [ -n "$DEBUG" ]; then
262 if [ "$NOSRCS" != "yes" ]; then
263 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
265 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
266 FAIL_IF_NO_SOURCES="no"
269 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
270 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
271 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
272 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -1`"
273 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -1`"
275 if [ -n "$BE_VERBOSE" ]; then
276 echo "- Sources : `nourl $SOURCES`"
277 if [ -n "$PATCHES" ]; then
278 echo "- Patches : `nourl $PATCHES`"
280 echo "- Patches : *no patches needed*"
282 if [ -n "$ICONS" ]; then
283 echo "- Icon : `nourl $ICONS`"
285 echo "- Icon : *no package icon*"
287 echo "- Name : $PACKAGE_NAME"
288 echo "- Version : $PACKAGE_VERSION"
289 echo "- Release : $PACKAGE_RELEASE"
295 if [ -n "$DEBUG" ]; then
303 "err_no_spec_in_cmdl" )
304 remove_build_requires
305 echo "ERROR: spec file name not specified.";
307 "err_no_spec_in_repo" )
308 remove_build_requires
309 echo "Error: spec file not stored in CVS repo.";
311 "err_no_source_in_repo" )
312 remove_build_requires
313 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
316 remove_build_requires
317 echo "Error: package build failed. (${2:-no more info})";
324 if [ -n "$DEBUG" ]; then
329 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
330 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
337 if [ -n "$DEBUG" ]; then
342 if [ "$NOCVSSPEC" != "yes" ]; then
347 if [ -n "$CVSROOT" ]; then
348 OPTIONS="-d $CVSROOT $OPTIONS"
350 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
351 echo "warning: No cvs access defined - using local .spec file"
356 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
357 OPTIONS="$OPTIONS -A"
359 if [ -n "$CVSDATE" ]; then
360 OPTIONS="$OPTIONS -D $CVSDATE"
362 if [ -n "$CVSTAG" ]; then
363 OPTIONS="$OPTIONS -r $CVSTAG"
369 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
370 retries_counter=$(( $retries_counter + 1 ))
371 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
373 [ -n "$output" ] && echo "$output"
374 if [ "$result" -ne "0" ]; then
375 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
376 echo "Trying again [$SPECFILE]... ($retries_counter)"
380 Exit_error err_no_spec_in_repo;
384 if [ ! -f "$SPECFILE" ]; then
385 Exit_error err_no_spec_in_repo;
388 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
389 chmod $CHMOD_MODE $SPECFILE
392 grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
399 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
400 cvs update mirrors >&2
404 while read origin mirror name rest; do
405 ol=`echo -n "$origin"|wc -c`
406 prefix="`echo -n "$url" | head -c $ol`"
407 if [ "$prefix" = "$origin" ] ; then
408 suffix="`echo "$url"|cut -b $ol-`"
409 echo -n "$mirror$suffix"
420 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
421 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
428 [ -z "$no" ] && return
430 spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::)
431 if [ -z "$spec_rev" ]; then
432 spec_rev="$(head -1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
434 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
435 md5=$(grep -s -v '^#' additional-md5sums | \
436 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
437 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
438 grep -E '^[0-9a-f]{32}$')
439 if [ X"$md5" = X"" ] ; then
440 grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://' | xargs
442 if [ $(echo "$md5" | wc -l) != 1 ] ; then
443 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
445 echo "$md5" | tail -1
451 echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
458 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
465 if [ -n "$DEBUG" ]; then
470 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
474 if [ -n "$CVSROOT" ]; then
475 OPTIONS="-d $CVSROOT $OPTIONS"
477 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
478 echo "warning: No cvs access defined for SOURCES"
482 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
483 OPTIONS="$OPTIONS -A"
485 if [ -n "$CVSDATE" ]; then
486 OPTIONS="$OPTIONS -D $CVSDATE"
488 if [ -n "$CVSTAG" ]; then
489 OPTIONS="$OPTIONS -r $CVSTAG"
492 for i in $GET_FILES; do
493 if [ -n "$UPDATE5" ]; then
494 if [ -n "$ADD5" ]; then
495 [ `nourl $i` = "$i" ] && continue
496 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
498 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
502 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
503 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
504 echo "Warning: no URL given for $i"
507 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
508 if good_md5 "$i"; then
509 echo "$(nourl "$i") having proper md5sum already exists"
513 url=$(distfiles_url "$i")
514 if [ `echo $url | grep -E '^(\.|/)'` ]; then
515 ${GETLOCAL} $url $target
518 if [ -z "$NOMIRRORS" ]; then
519 url="`find_mirror "$url"`"
521 ${GETURI} -O "$target" "$url" || \
522 if [ `echo $url | grep -E 'ftp://'` ]; then
523 ${GETURI2} -O "$target" "$url"
525 if ! test -s "$target"; then
530 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
531 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
534 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
535 retries_counter=$(( $retries_counter + 1 ))
536 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
538 [ -n "$output" ] && echo "$output"
539 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
540 echo "Trying again [`nourl $i`]... ($retries_counter)"
549 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
550 if [ -z "$NOMIRRORS" ]; then
551 im="`find_mirror "$i"`"
556 if [ `echo $im | grep -E 'ftp://'` ]; then ${GETURI2} "$im" ; fi
562 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
563 Exit_error err_no_source_in_repo $i;
564 elif [ -n "$UPDATE5" ] && \
565 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
566 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
567 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
569 echo "Updating source-$srcno md5."
570 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
572 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
573 print "# Source'$srcno'-md5:\t'$md5'\n"
574 if /^Source'$srcno'\s*:\s+/;
579 if good_md5 "$i"; then
581 elif [ "$FROM_DISTFILES" = 1 ]; then
582 # wrong md5 from distfiles: remove the file and try again
584 echo "MD5 sum mismatch. Trying full fetch."
587 ${GETURI} -O "$target" "$url" || \
588 if [ `echo $url | grep -E 'ftp://'` ]; then
589 ${GETURI2} -O "$target" "$url"
591 test -s "$target" || rm -f "$target"
594 if good_md5 "$i"; then
597 echo "MD5 sum mismatch. Use -U to refetch sources,"
598 echo "or -5 to update md5 sums, if you're sure files are correct."
599 Exit_error err_no_source_in_repo $i
603 if [ "$CHMOD" = "yes" ]; then
604 CHMOD_FILES="`nourl $GET_FILES`"
605 if [ -n "$CHMOD_FILES" ]; then
606 chmod $CHMOD_MODE $CHMOD_FILES
617 if [ -n "$DEBUG" ]; then
622 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
623 echo "Version: $PACKAGE_VERSION"
624 echo "Release: $PACKAGE_RELEASE"
625 # Check whether first character of PACKAGE_NAME is legal for tag name
626 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
629 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"`
630 # Remove #kernel.version_release from TAGVER because tagging sources
631 # could occur with different kernel-headers than kernel-headers used at build time.
632 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
633 if [ "$TAG_VERSION" = "yes" ]; then
634 echo "CVS tag: $TAGVER"
636 if [ -n "$TAG" ]; then
641 if [ -n "$CVSROOT" ]; then
642 OPTIONS="-d $CVSROOT $OPTIONS"
646 for i in $TAG_FILES; do
647 # don't tag non cvs files (ie. stored on distfiles)
648 [ "`nourl $i`" != "$i" ] && continue
649 if [ -f "`nourl $i`" ]; then
650 if [ "$TAG_VERSION" = "yes" ]; then
651 cvs $OPTIONS $TAGVER `nourl $i`
653 if [ -n "$TAG" ]; then
654 cvs $OPTIONS $TAG `nourl $i`
657 Exit_error err_no_source_in_repo $i
662 if [ "$TAG_VERSION" = "yes" ]; then
663 cvs $OPTIONS $TAGVER $SPECFILE
665 if [ -n "$TAG" ]; then
666 cvs $OPTIONS $TAG $SPECFILE
676 echo "CVS branch tag: $TAG"
681 if [ -n "$DEBUG" ]; then
686 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
689 if [ -n "$CVSROOT" ]; then
690 OPTIONS="-d $CVSROOT $OPTIONS"
693 for i in $TAG_FILES; do
694 if [ -f `nourl $i` ]; then
695 cvs $OPTIONS $TAG `nourl $i`
697 Exit_error err_no_source_in_repo $i
701 cvs $OPTIONS $TAG $SPECFILE
711 if [ -n "$DEBUG" ]; then
718 if [ -n "$TRY_UPGRADE" ]; then
720 if [ -n "$FLOAT_VERSION" ]; then
721 TNOTIFY=`./pldnotify.awk $SPECFILE -n`
723 TNOTIFY=`./pldnotify.awk $SPECFILE`
726 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
728 if [ -n "$TNEWVER" ]; then
730 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
732 echo "New version found, updating spec file to version " $TNEWVER
734 cp -f $SPECFILE $SPECFILE.bak
738 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
739 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE"
743 get_files "$SOURCES $PATCHES";
745 unset TOLDVER TNEWVER TNOTIFY
755 BUILD_SWITCH="-ba" ;;
757 BUILD_SWITCH="-bb" ;;
759 BUILD_SWITCH="-bs --nodeps" ;;
761 BUILD_SWITCH="-bp --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"
830 echo -ne "Package installation failed:\t$package_name\n"
832 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
833 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
834 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
835 # jakby nie bylo tego kawalka kodu.
837 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
838 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
846 # Istnieje taki spec? ${package}.spec
847 if [ -f "${POLDEK_INDEX_DIR}/../SPECS/${package}.spec" ]; then
848 parent_spec_name=${package}.spec
849 elif [ -f "${POLDEK_INDEX_DIR}/../SPECS/`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
850 parent_spec_name="`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec"
852 for provides_line in `grep ^Provides:.*$package ${POLDEK_INDEX_DIR}/../SPECS/ -R`
858 if [ "${parent_spec_name}" != "" ]; then
860 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
861 sub_builder_opts="${sub_builder_opts} -R"
863 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
864 sub_builder_opts="${sub_builder_opts} -RB"
865 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
866 sub_builder_opts="${sub_builder_opts} -FRB"
868 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
869 sub_builder_opts="${sub_builder_opts} -Upi"
871 cd "${POLDEK_INDEX_DIR}/../SPECS"
872 ./builder ${sub_builder_opts} ${parent_spec_name}
876 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
880 remove_build_requires()
882 if [ "$INSTALLED_PACKAGES" != "" ]; then
883 case "$REMOVE_BUILD_REQUIRES" in
885 poldek --noask -e $INSTALLED_PACKAGES
888 poldek --ask -e $INSTALLED_PACKAGES
891 echo You may want to manually remove following BuildRequires fetched:
892 echo $INSTALLED_PACKAGES
893 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
901 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
902 echo -ne "We are going to build $SPECFILE with the following conditional flags:\n"
903 if [ "$BCOND" != "" ]; then
906 echo -ne "No --with || --without conditions passed to $0!"
908 echo -ne "\n\nfrom available:\n\n"
909 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
913 fetch_build_requires()
915 if [ "$FETCH_BUILD_REQUIRES" = "yes" ]; then
916 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
917 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
918 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
919 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
920 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
921 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,perl\(,perl-,g -e s,::,-,g -e s,\(.*\),,g -e s,%{,,g -e s,},,g|grep -v OpenGL-devel|sed -e s,sh-utils,coreutils,g -e s,fileutils,coreutils,g -e s,kgcc_package,gcc,g -e s,\),,g`
923 package_item="`echo $package_item|sed -e s,rpmbuild,rpm-build,g |sed -e s,__perl,perl,g |sed -e s,gasp,binutils-gasp,g |sed -e s,apxs,apache,g|sed -e s,apache\(EAPI\)-devel,apache-devel,g`"
925 package=`basename "$package_item"|sed -e "s/}$//g"`
926 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
929 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
930 if [ "`echo $COND_TST|grep '^BuildRequires:'`" != "" ]; then
931 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
936 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
939 if [ "`echo $COND_TST|grep 'without_'`" != "" ]; then
940 COND_NAME=`echo $COND_NAME|sed -e s,^.*_without_,,g`
941 if [ "`echo $COND_TST|grep !`" != "" ]; then
946 if [ "`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`" != "" ]; then
952 elif [ "`echo $COND_TST|grep 'with_'`" != "" ]; then
953 COND_NAME=`echo $COND_NAME|sed -e s,^.*_with_,,g`
954 if [ "`echo $COND_TST|grep !`" != "" ]; then
959 if [ "`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`" != "" ]; then
965 RESULT="${COND_STATE}-${COND_ARGV}"
967 "with-wout" | "wout-with" )
970 "wout-wout" | "with-with" )
974 echo "Action '$RESULT' was not defined for package '$package_item'"
981 if [ "$GO" = "yes" ]; then
982 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
983 echo "Testing if $package has subrequirements..."
984 poldek -t -i $package --dumpn=".$package-req.txt"
985 if [ -f ".$package-req.txt" ]; then
986 for package_name in `cat ".$package-req.txt"|grep -v ^#`
988 if [ "$package_name" = "$package" ]; then
989 echo -ne "Installing BuildRequired package:\t$package_name\n"
990 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
991 poldek -i $package_name
993 echo -ne "Installing (sub)Required package:\t$package_name\n"
994 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
995 poldek -i $package_name
999 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1000 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1003 echo "Attempting to run spawn sub - builder..."
1004 run_sub_builder $package_name
1008 rm -f ".$package-req.txt"
1010 echo "Attempting to run spawn sub - builder..."
1011 run_sub_builder $package
1014 echo "Package $package is already installed. BuildRequirement satisfied."
1018 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1019 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1020 echo "Nie uda³o siê zainstalowaæ nastêpuj±cych pakietów i ich zale¿no¶ci:"
1021 for pkg in "$NOT_INSTALLED_PACKAGES"
1025 remove_build_requires
1031 #---------------------------------------------
1034 if [ "$#" = 0 ]; then
1039 while test $# -gt 0 ; do
1056 DEBUG="yes"; shift ;;
1058 COMMAND="version"; shift ;;
1060 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1061 -b | -ba | --build )
1062 COMMAND="build"; shift ;;
1063 -bb | --build-binary )
1064 COMMAND="build-binary"; shift ;;
1065 -bs | --build-source )
1066 COMMAND="build-source"; shift ;;
1067 -bp | --build-prep )
1068 COMMAND="build-prep"; shift ;;
1070 COMMAND="branch"; shift; TAG="${1}"; shift;;
1072 CLEAN="--clean --rmspec --rmsource"; shift ;;
1074 shift; CVSROOT="${1}"; shift ;;
1076 COMMAND="get"; shift ;;
1078 COMMAND="usage"; shift ;;
1080 PROTOCOL="http"; shift ;;
1082 shift; LOGFILE="${1}"; shift ;;
1084 shift; DEF_NICE_LEVEL=${1}; shift ;;
1086 COMMAND="mr-proper"; shift ;;
1088 NOCVS="yes"; shift ;;
1089 -ncs | --no-cvs-specs )
1090 NOCVSSPEC="yes"; shift ;;
1091 -nd | --no-distfiles )
1092 NODIST="yes"; shift ;;
1093 -nm | --no-mirrors )
1094 NOMIRRORS="yes"; shift ;;
1096 NOURLS="yes"; shift ;;
1098 NOSRCS="yes"; shift ;;
1099 -ns0 | --no-source0 )
1100 NOSOURCE0="yes"; shift ;;
1102 shift; RPMOPTS="${1}"; shift ;;
1103 --with | --without )
1104 case $GROUP_BCONDS in
1108 while [ "`echo ${1}|grep ^-`" = "" ] && [ "`echo ${1}|grep spec`" = "" ]
1110 BCOND="$BCOND $COND $1"
1114 BCOND="$BCOND $1 $2" ; shift 2 ;;
1118 QUIET="--quiet"; shift ;;
1120 CVSDATE="${2}"; shift 2 ;;
1122 shift; CVSTAG="${1}"; shift ;;
1123 -R | --fetch-build-requires)
1124 FETCH_BUILD_REQUIRES="yes"
1125 #UPDATE_POLDEK_INDEXES="yes"
1126 NOT_INSTALLED_PACKAGES=
1128 -RB | --remove-build-requires)
1129 REMOVE_BUILD_REQUIRES="nice"
1131 -FRB | --force-remove-build-requires)
1132 REMOVE_BUILD_REQUIRES="force"
1134 -Tvs | --tag-version-stable )
1139 -Tvn | --tag-version-nest )
1144 -Ts | --tag-stable )
1154 -Tv | --tag-version )
1159 -Tp | --tag-prefix )
1175 -Upi | --update-poldek-indexes )
1176 UPDATE_POLDEK_INDEXES="yes"
1178 -u | --try-upgrade )
1179 TRY_UPGRADE="1"; shift ;;
1180 -un | --try-upgrade-with-float-version )
1181 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1183 BE_VERBOSE="1"; shift ;;
1189 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1193 RPMOPTS="${RPMOPTS} --nodeps"
1196 SPECFILE="`basename ${1} .spec`.spec";
1197 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1202 if [ -n "$DEBUG" ]; then
1208 "build" | "build-binary" | "build-source" | "build-prep" )
1210 if [ -n "$SPECFILE" ]; then
1214 fetch_build_requires;
1217 if [ -n "$FAIL_IF_CHANGED_BUT_NOT_BUMPED" ]; then
1218 TAGVER=$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
1219 CURTAGREL=$(cvs status $SPECFILE | grep "Working revision:" | awk '{ print $3 }')
1220 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1222 if [ -n "$TAGREL" -a "$TAGREL" != "$CURTAGREL" ]; then
1223 Exit_error err_build_fail "not bumped ver-rel - was already used in rev $TAGREL"
1227 if [ -n "$ICONS" ]; then
1231 if [ -n "$NOSOURCE0" ] ; then
1232 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1234 get_files "$SOURCES $PATCHES";
1236 if [ "$UPDATE_POLDEK_INDEXES" = "yes" ]; then
1237 poldek --sn ${POLDEK_SOURCE} --mkidx="${POLDEK_INDEX_DIR}/packages.dir.gz"
1238 poldek --sn ${POLDEK_SOURCE} --up
1240 remove_build_requires;
1242 Exit_error err_no_spec_in_cmdl;
1247 if [ -n "$SPECFILE" ]; then
1250 if [ -n "$ICONS" ]; then
1254 get_files $SOURCES $PATCHES;
1255 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1257 Exit_error err_no_spec_in_cmdl;
1262 if [ -n "$SPECFILE" ]; then
1265 if [ -n "$ICONS" ]; then
1269 if [ -n "$NOSOURCE0" ] ; then
1270 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1272 get_files $SOURCES $PATCHES
1274 Exit_error err_no_spec_in_cmdl;
1279 if [ -n "$SPECFILE" ]; then
1282 if [ -n "$ICONS" ]; then
1286 # don't fetch sources from remote locations
1288 for file in $SOURCES; do
1289 [ "`nourl $file`" != "$file" ] && continue
1290 new_SOURCES="$new_SOURCES $file"
1292 SOURCES="$new_SOURCES"
1293 get_files $SOURCES $PATCHES;
1294 tag_files "$SOURCES $PATCHES $ICONS";
1296 Exit_error err_no_spec_in_cmdl;
1300 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE