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
13 # 8 - Failed installing buildrequirements and subrequirements
14 # 9 - Requested tag already exist
15 # 10 - Refused to build fractional release
16 # 100 - Unknown error (should not happen)
19 # - builder -u fetches current version first
20 # - tries to get new version from distfiles without new md5
21 # - after fetching new version doesn't update md5
22 # - doesn't get sources for specs with %include /usr/lib/rpm/macros.python
23 # when there's no rpm-pythonprov (rpm's fault, but it's ugly anyway)
24 # - as above with %include /usr/lib/rpm/macros.perl and no rpm-perlprov
25 # - when Icon: field is present, -5 and -a5 doesn't work
28 Build package utility from PLD CVS repository
29 V 0.13 (C) 1999-2005 Free Penguins".
30 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
49 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
52 # It can be used i.e. in log file naming.
53 # See LOGFILE example.
54 DATE=`date +%Y-%m-%d_%H-%M-%S`
56 # Example: LOGFILE='../log.$PACKAGE_NAME'
57 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
58 # Yes, you can use variable name! Note _single_ quotes!
80 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
81 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
86 CVS_SERVER="cvs.pld-linux.org"
87 DISTFILES_SERVER="://distfiles.pld-linux.org"
88 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
92 FAIL_IF_NO_SOURCES="yes"
94 if [ -x /usr/bin/rpm-getdeps ]; then
95 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
97 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
100 # Here we load saved user environment used to
101 # predefine options set above, or passed to builder
103 # This one reads global system environment settings:
104 if [ -f ~/etc/builderrc ]; then
107 # And this one cascades settings using user personal
109 # Example of ~/.builderrc:
111 #UPDATE_POLDEK_INDEXES="yes"
112 #FETCH_BUILD_REQUIRES="yes"
113 #REMOVE_BUILD_REQUIRES="force"
115 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
118 if [ -n "$HOME_ETC" ]; then
119 USER_CFG="$HOME_ETC/.builderrc"
121 USER_CFG=~/.builderrc
124 [ -f "$USER_CFG" ] && . "$USER_CFG"
126 if [ -n "$USE_PROZILLA" ]; then
127 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
130 elif [ -n "$USE_AXEL" ]; then
131 GETURI="axel -a $AXEL_OPTS"
135 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
136 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
138 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
139 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
145 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
153 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
154 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
158 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
159 if [ -n "$LOGFILE" ]; then
160 LOG=`eval echo $LOGFILE`
161 if [ -n "$LASTLOG_FILE" ]; then
162 echo "LASTLOG=$LOG" > $LASTLOG_FILE
164 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
167 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
168 return `cat ${RES_FILE}`
173 #---------------------------------------------
178 if [ -n "$DEBUG" ]; then set -xv; fi
180 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
182 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
183 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
184 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
185 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
186 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
187 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
188 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
189 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
190 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
192 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
193 --adapter[ize] - run adapter.awk on SPECFILE
194 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
195 -n5, --no-md5 - ignore md5 comments in spec
196 -D, --debug - enable builder script debugging mode,
197 -debug - produce rpm debug package (same as --opts -debug)
198 -V, --version - output builder version
199 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
200 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
202 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
203 only package from <package>.spec,
204 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
206 -bp, --build-prep - execute the %prep phase of <package>.spec,
207 -B, --branch - add branch
208 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
209 SPECS and \$RPM_BUILD_ROOT),
210 -d <cvsroot>, --cvsroot <cvsroot>
212 --define <macro> <value>
213 - define a macro <macro> with value <value>,
214 --nodeps - rpm won't check any dependences
215 -g, --get - get <package>.spec and all related files from CVS repo
217 -h, --help - this message,
218 --http - use http instead of ftp,
219 -l <logfile>, --logtofile <logfile>
221 -m, --mr-proper - only remove all files related to spec file and all work
223 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
225 - don't check specs in CVS
226 -nd, --no-distfiles - don't download from distfiles
227 -nm, --no-mirrors - don't download from mirror, if source URL is given,
228 -nu, --no-urls - don't try to download from FTP/HTTP location,
229 -ns, --no-srcs - don't download Sources
230 -ns0, --no-source0 - don't download Source0
231 -nn, --no-net - don't download anything from the net
232 --opts <rpm opts> - additional options for rpm
233 -q, --quiet - be quiet,
234 --date yyyy-mm-dd - build package using resources from specified CVS date,
235 -r <cvstag>, --cvstag <cvstag>
236 - build package using resources from specified CVS tag,
237 -R, --fetch-build-requires
238 - fetch what is BuildRequired,
239 -RB, --remove-build-requires
240 - remove all you fetched with -R or --fetch-build-requires
241 remember, this option requires confirmation,
242 -FRB, --force-remove-build-requires
243 - remove all you fetched with -R or --fetch-build-requires
244 remember, this option works without confirmation,
245 -sf, --source-files - list sources - bare filenames (intended for offline
246 operations; does not work when Icon field is present
247 but icon file is absent),
248 -sp, --source-paths - list sources - filenames with full local paths (intended for
249 offline operations; does not work when Icon field is present
250 but icon file is absent),
251 -T <cvstag> , --tag <cvstag>
252 - add cvs tag <cvstag> for files,
253 -Tvs, --tag-version-stable
254 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
255 -Tvn, --tag-version-nest
256 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
258 - add cvs tag STABLE for files,
260 - add cvs tag NEST for files,
262 - add cvs tag NAME-VERSION-RELEASE for files,
263 -Tp, --tag-prefix <prefix>
264 - add <prefix> to NAME-VERSION-RELEASE tags,
265 -tt, --test-tag <prefix>
266 - fail if tag is already present,
267 -ir, --integer-release-only
268 - allow only integer and snapshot releases
269 -v, --verbose - be verbose,
270 -u, --try-upgrade - check version, and try to upgrade package
271 -un, --try-upgrade-with-float-version
272 - as above, but allow float version
273 -U, --update - refetch sources, don't use distfiles, and update md5 comments
274 -Upi, --update-poldek-indexes
275 - refresh or make poldek package index files.
276 --with/--without <feature>
277 - conditional build package depending on %_with_<feature>/
278 %_without_<feature> macro switch. You may now use
279 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
280 constructions. Set GROUP_BCONDS to yes to make use of it.
281 --target <platform>, --target=<platform>
282 - build for platform <platform>.
286 # set TARGET from BuildArch: from SPECFILE
288 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
289 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
294 TARGET_SWITCH="--target $TARGET" ;;
296 TARGET_SWITCH="--target=$TARGET" ;;
303 if [ -n "$DEBUG" ]; then
311 rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
314 # FIXME: no $TARGET_SWITCH here needed?
315 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1
321 if [ -z "$rpm_dump_cache" ] ; then
322 echo "internal error: cache_rpm_dump not called!" 1>&2
324 echo "$rpm_dump_cache"
329 if [ -n "$DEBUG" ]; then
338 if [ "$NOSRCS" != "yes" ]; then
339 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
341 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
342 FAIL_IF_NO_SOURCES="no"
345 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
346 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
347 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
348 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
349 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
351 # These variables may be unset after first cache_rpm_dump call
352 # (because of not-yet-retrieved icon file)
354 # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
355 # Exit_error err_no_package_data;
358 if [ -n "$BE_VERBOSE" ]; then
359 echo "- Sources : `nourl $SOURCES`"
360 if [ -n "$PATCHES" ]; then
361 echo "- Patches : `nourl $PATCHES`"
363 echo "- Patches : *no patches needed*"
365 if [ -n "$ICONS" ]; then
366 echo "- Icon : `nourl $ICONS`"
368 echo "- Icon : *no package icon*"
370 echo "- Name : $PACKAGE_NAME"
371 echo "- Version : $PACKAGE_VERSION"
372 echo "- Release : $PACKAGE_RELEASE"
378 if [ -n "$DEBUG" ]; then
386 "err_no_spec_in_cmdl" )
387 remove_build_requires
388 echo "ERROR: spec file name not specified.";
390 "err_no_spec_in_repo" )
391 remove_build_requires
392 echo "Error: spec file not stored in CVS repo.";
394 "err_no_source_in_repo" )
395 remove_build_requires
396 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
399 remove_build_requires
400 echo "Error: package build failed. (${2:-no more info})";
402 "err_no_package_data" )
403 remove_build_requires
404 echo "Error: couldn't get out package name/version/release from spec file."
407 remove_build_requires
408 echo "Tag ${2} already exists (spec release: ${3}).";
411 remove_build_requires
412 echo "Release ${2} not integer and not a snapshot.";
416 echo "Unknown error."
422 if [ -n "$DEBUG" ]; then
427 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
428 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
435 if [ -n "$DEBUG" ]; then
441 if [ \! -f "$SPECFILE" ]; then
442 SPECFILE="`basename $SPECFILE .spec`.spec";
444 if [ "$NOCVSSPEC" != "yes" ]; then
447 if [ -n "$CVSROOT" ]; then
448 OPTIONS="-d $CVSROOT $OPTIONS"
450 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
451 echo "warning: No cvs access defined - using local .spec file"
456 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
457 OPTIONS="$OPTIONS -A"
459 if [ -n "$CVSDATE" ]; then
460 OPTIONS="$OPTIONS -D $CVSDATE"
462 if [ -n "$CVSTAG" ]; then
463 OPTIONS="$OPTIONS -r $CVSTAG"
469 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
471 retries_counter=$(( $retries_counter + 1 ))
472 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
474 [ -n "$output" ] && echo "$output"
475 if [ "$result" -ne "0" ]; then
476 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
477 echo "Trying again [$SPECFILE]... ($retries_counter)"
481 Exit_error err_no_spec_in_repo;
485 if [ ! -f "$SPECFILE" ]; then
486 Exit_error err_no_spec_in_repo;
489 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
490 chmod $CHMOD_MODE $SPECFILE
493 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
502 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
503 cvs update mirrors >&2
507 while read origin mirror name rest
509 ol=`echo -n "$origin"|wc -c`
510 prefix="`echo -n "$url" | head -c $ol`"
511 if [ "$prefix" = "$origin" ] ; then
512 suffix="`echo "$url"|cut -b $ol-`"
513 echo -n "$mirror$suffix"
524 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
525 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
531 [ X"$NO5" = X"yes" ] && return
533 [ -z "$no" ] && return
535 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
536 if [ -z "$spec_rev" ]; then
537 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
539 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
540 md5=$(grep -s -v '^#' additional-md5sums | \
541 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
542 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
543 grep -E '^[0-9a-f]{32}$')
544 if [ X"$md5" = X"" ] ; then
545 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
546 if [ ! -z "$source_md5" ] ; then
549 # we have empty SourceX-md5, but it is still possible
550 # that we have NoSourceX-md5 AND NoSource: X
551 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
552 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
557 if [ $(echo "$md5" | wc -l) != 1 ] ; then
558 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
560 echo "$md5" | tail -n 1
566 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
569 distfiles_attic_url ()
571 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
578 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
583 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
584 [ -n "$size" -a "$size" -gt 0 ]
589 if [ "$CVSIGNORE_DF" != "yes" ]; then
592 cvsignore=${SOURCE_DIR}/.cvsignore
593 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
594 echo "$1" >> $cvsignore
602 if [ -n "$DEBUG" ]; then
607 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
611 if [ -n "$CVSROOT" ]; then
612 OPTIONS="-d $CVSROOT $OPTIONS"
614 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
615 echo "warning: No cvs access defined for SOURCES"
619 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
620 OPTIONS="$OPTIONS -A"
622 if [ -n "$CVSDATE" ]; then
623 OPTIONS="$OPTIONS -D $CVSDATE"
625 if [ -n "$CVSTAG" ]; then
626 OPTIONS="$OPTIONS -r $CVSTAG"
631 if [ -n "$UPDATE5" ]; then
632 if [ -n "$ADD5" ]; then
633 [ `nourl $i` = "$i" ] && continue
634 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
636 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
640 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
641 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
642 echo "Warning: no URL given for $i"
645 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
646 if good_md5 "$i" && good_size "$i"; then
647 echo "$(nourl "$i") having proper md5sum already exists"
651 url=$(distfiles_url "$i")
652 url_attic=$(distfiles_attic_url "$i")
654 if [ `echo $url | grep -E '^(\.|/)'` ]; then
655 ${GETLOCAL} $url $target
657 if [ -z "$NOMIRRORS" ]; then
658 url="`find_mirror "$url"`"
660 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
661 if [ `echo $url | grep -E 'ftp://'` ]; then
662 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
665 if ! test -s "$target"; then
667 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
668 ${GETLOCAL} $url_attic $target
670 if [ -z "$NOMIRRORS" ]; then
671 url_attic="`find_mirror "$url_attic"`"
673 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
674 if [ `echo $url_attic | grep -E 'ftp://'` ]; then
675 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
679 if test -s "$target"; then
685 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
686 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
689 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
691 retries_counter=$(( $retries_counter + 1 ))
692 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
694 [ -n "$output" ] && echo "$output"
695 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
696 echo "Trying again [`nourl $i`]... ($retries_counter)"
705 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
706 if [ -z "$NOMIRRORS" ]; then
707 im="`find_mirror "$i"`"
712 if [ `echo $im | grep -E 'ftp://'` ]; then
719 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
720 Exit_error err_no_source_in_repo $i;
721 elif [ -n "$UPDATE5" ] && \
722 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
723 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
724 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
726 echo "Updating source-$srcno md5."
727 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
729 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
730 print "# Source'$srcno'-md5:\t'$md5'\n"
731 if /^Source'$srcno'\s*:\s+/;
736 if good_md5 "$i" && good_size "$i"; then
738 elif [ "$FROM_DISTFILES" = 1 ]; then
739 # wrong md5 from distfiles: remove the file and try again
741 echo "MD5 sum mismatch. Trying full fetch."
744 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
745 if [ `echo $url | grep -E 'ftp://'` ]; then
746 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
748 if ! test -s "$target"; then
750 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
751 if [ `echo $url_attic | grep -E 'ftp://'` ]; then
752 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
755 test -s "$target" || rm -f "$target"
758 if good_md5 "$i" && good_size "$i" ; then
761 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
762 echo "or -5 to update md5 sums, if you're sure files are correct."
763 Exit_error err_no_source_in_repo $i
767 if [ "$CHMOD" = "yes" ]; then
768 CHMOD_FILES="`nourl $GET_FILES`"
769 if [ -n "$CHMOD_FILES" ]; then
770 chmod $CHMOD_MODE $CHMOD_FILES
779 if [ -n "$DEBUG" ]; then
784 # Check whether first character of PACKAGE_NAME is legal for tag name
785 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
788 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"`
789 # Remove #kernel.version_release from TAGVER because tagging sources
790 # could occur with different kernel-headers than kernel-headers used at build time.
791 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
799 if [ -n "$DEBUG" ]; then
804 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
805 echo "Version: $PACKAGE_VERSION"
806 echo "Release: $PACKAGE_RELEASE"
810 if [ "$TAG_VERSION" = "yes" ]; then
811 echo "CVS tag: $TAGVER"
813 if [ -n "$TAG" ]; then
818 if [ -n "$CVSROOT" ]; then
819 OPTIONS="-d $CVSROOT $OPTIONS"
825 # don't tag files stored on distfiles
826 [ -n "`src_md5 $i`" ] && continue
827 if [ -f "`nourl $i`" ]; then
828 if [ "$TAG_VERSION" = "yes" ]; then
829 cvs $OPTIONS $TAGVER `nourl $i`
831 if [ -n "$TAG" ]; then
832 cvs $OPTIONS $TAG `nourl $i`
835 Exit_error err_no_source_in_repo $i
840 if [ "$TAG_VERSION" = "yes" ]; then
841 cvs $OPTIONS $TAGVER $SPECFILE
843 if [ -n "$TAG" ]; then
844 cvs $OPTIONS $TAG $SPECFILE
854 echo "CVS branch tag: $TAG"
859 if [ -n "$DEBUG" ]; then
864 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
867 if [ -n "$CVSROOT" ]; then
868 OPTIONS="-d $CVSROOT $OPTIONS"
873 if [ -f `nourl $i` ]; then
874 cvs $OPTIONS $TAG `nourl $i`
876 Exit_error err_no_source_in_repo $i
880 cvs $OPTIONS $TAG $SPECFILE
890 if [ -n "$DEBUG" ]; then
897 if [ -n "$TRY_UPGRADE" ]; then
898 if [ -n "$FLOAT_VERSION" ]; then
899 TNOTIFY=`./pldnotify.awk $SPECFILE -n`
901 TNOTIFY=`./pldnotify.awk $SPECFILE`
904 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
906 if [ -n "$TNEWVER" ]; then
907 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
908 echo "New version found, updating spec file to version " $TNEWVER
909 cp -f $SPECFILE $SPECFILE.bak
911 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
912 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE"
914 if [ -n "$ICONS" ]; then
918 get_files "$SOURCES $PATCHES";
919 unset TOLDVER TNEWVER TNOTIFY
926 BUILD_SWITCH="-ba" ;;
928 BUILD_SWITCH="-bb" ;;
930 BUILD_SWITCH="-bs --nodeps" ;;
932 BUILD_SWITCH="-bp --nodeps" ;;
934 if [ -n "$LOGFILE" ]; then
935 LOG=`eval echo $LOGFILE`
936 if [ -d "$LOG" ]; then
937 echo "Log file $LOG is a directory."
938 echo "Parse error in the spec?"
939 Exit_error err_build_fail;
941 if [ -n "$LASTLOG_FILE" ]; then
942 echo "LASTLOG=$LOG" > $LASTLOG_FILE
944 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
945 (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
946 RETVAL=`cat $RES_FILE`
948 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
949 if [ "$RETVAL" -eq "0" ]; then
956 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
959 if [ "$RETVAL" -ne "0" ]; then
960 if [ -n "$TRY_UPGRADE" ]; then
961 echo "\n!!! Package with new version cannot be build automagically\n"
962 mv -f $SPECFILE.bak $SPECFILE
964 Exit_error err_build_fail;
971 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
974 install_required_packages()
982 AVAIL_BCONDS_WITHOUT=""
984 if `grep -q ^%bcond ${SPECFILE}`; then
986 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
992 # expand bconds from ~/.bcondrc
993 # The file structure is like gentoo's package.use:
996 # samba -mysql -pgsql
997 # w32codec-installer license_agreement
1000 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
1001 # This takes package name, first defined in spec.
1002 # so consider that when defining flags for package.
1003 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
1004 AVAIL=`$RPMBUILD --bcond $SPECFILE`
1006 BCONDRC=$HOME/.bcondrc
1007 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
1009 while read pkg flags; do
1011 [[ "$pkg" == \#* ]] && continue
1013 # any package or current package?
1014 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ]; then
1015 for flag in $flags; do
1018 # use only flags which are in this package.
1019 if [[ $AVAIL = *${opt}* ]]; then
1020 if [[ $flag = -* ]]; then
1021 BCOND="$BCOND --without $opt"
1023 BCOND="$BCOND --with $opt"
1031 case "${BCOND_VERSION}" in
1036 echo "Warning: This spec has old style bconds. Fix it || die."
1037 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1039 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1040 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1041 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1043 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1047 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1049 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1050 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1051 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1053 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1058 cond_type="" # with || without
1059 for opt in `$RPMBUILD --bcond $SPECFILE`
1069 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1070 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1071 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1073 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1077 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1078 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1079 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1081 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1085 case "$cond_type" in
1088 AVAIL_BCOND_WITH="$opt"
1089 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1090 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1092 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1097 AVAIL_BCOND_WITHOUT="$opt"
1098 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1099 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1101 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1115 echo -ne "Package installation failed:\t$package_name\n"
1117 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1118 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1119 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1120 # jakby nie bylo tego kawalka kodu.
1122 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1123 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1130 # Istnieje taki spec? ${package}.spec
1131 if [ -f "${SPECS_DIR}${package}.spec" ]; then
1132 parent_spec_name=${package}.spec
1133 elif [ -f "${SPECS_DIR}`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1134 parent_spec_name="`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1136 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1142 if [ "${parent_spec_name}" != "" ]; then
1144 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1145 sub_builder_opts="${sub_builder_opts} -R"
1147 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1148 sub_builder_opts="${sub_builder_opts} -RB"
1149 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1150 sub_builder_opts="${sub_builder_opts} -FRB"
1152 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1153 sub_builder_opts="${sub_builder_opts} -Upi"
1156 ./builder ${sub_builder_opts} ${parent_spec_name}
1158 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1161 remove_build_requires()
1163 if [ "$INSTALLED_PACKAGES" != "" ]; then
1164 case "$REMOVE_BUILD_REQUIRES" in
1166 run_poldek --noask -ve $INSTALLED_PACKAGES
1169 run_poldek --ask -ve $INSTALLED_PACKAGES
1172 echo You may want to manually remove following BuildRequires fetched:
1173 echo $INSTALLED_PACKAGES
1174 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1182 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1183 if [ "$BCOND" != "" ]; then
1184 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1187 echo -ne "\nNo conditional flags passed"
1189 echo -ne "\n\nfrom available:\n"
1190 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1194 # checks a given list of packages/files/provides agains current rpmdb.
1195 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1196 # input can be either STDIN or parameters
1201 if [ "$#" -gt 0 ]; then
1207 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1210 echo "$DEPS" | awk '/^no package provides/ { print "@" $NF }'
1212 # other deps (files)
1213 echo "$DEPS" | awk -F: '/^error:.*No such file/{o=$2; gsub("^ file ", "", o); print "@" o}'
1216 # checks if given package/files/provides exists in rpmdb.
1217 # inout can be either stdin or parameters
1218 # returns packages wchi hare present in the rpmdb
1223 if [ "$#" -gt 0 ]; then
1229 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1232 fetch_build_requires()
1234 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1235 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1236 CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1237 DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1239 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1240 $SU_SUDO /usr/bin/poldek --update || $SU_SUDO /usr/bin/poldek --upa
1242 if [ -n "$CONF" ]; then
1243 echo "Trying to uninstall conflicting packages ($CONF):"
1244 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1246 if [ -n "$DEPS" ]; then
1247 echo "Trying to install dependencies ($DEPS):"
1248 $SU_SUDO /usr/bin/poldek --caplookup -uGv $DEPS
1253 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1254 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1255 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1256 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1257 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1258 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,textutils,coreutils,g -e s,kgcc_package,gcc,g -e s,\),,g`
1260 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 -e s,binutils-binutils,binutils,g -e s,apxs,apache,g|sed -e s,apache\(EAPI\)-devel,apache-devel,g -e s,kernel-headers\(netfilter\),kernel-headers,g -e s,awk,mawk,g -e s,mmawk,mawk,g -e s,motif,openmotif,g -e s,openopenmotif,openmotif,g`"
1262 package=`basename "$package_item"|sed -e "s/}$//g"`
1263 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1266 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1267 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1268 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
1273 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1276 if `echo $COND_TST|grep -q 'without_'`; then
1277 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1278 if `echo $COND_TST|grep -q !`; then
1283 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1284 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1285 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1291 elif `echo $COND_TST|grep -q 'with_'`; then
1292 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1293 if `echo $COND_TST|grep -q !`; then
1298 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1299 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1300 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1306 RESULT="${COND_STATE}-${COND_ARGV}"
1308 "with-wout" | "wout-with" )
1311 "wout-wout" | "with-with" )
1315 echo "Action '$RESULT' was not defined for package '$package_item'"
1321 if [ "$GO" = "yes" ]; then
1322 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1323 echo "Testing if $package has subrequirements..."
1324 run_poldek -t -i $package --dumpn=".$package-req.txt"
1325 if [ -f ".$package-req.txt" ]; then
1326 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1328 if [ "$package_name" = "$package" ]; then
1329 echo -ne "Installing BuildRequired package:\t$package_name\n"
1330 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1331 install_required_packages $package;
1333 echo -ne "Installing (sub)Required package:\t$package_name\n"
1334 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1335 install_required_packages $package_name;
1339 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1340 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1343 echo "Attempting to run spawn sub - builder..."
1344 run_sub_builder $package_name
1345 if [ $? -eq 0 ]; then
1346 install_required_packages $package_name;
1349 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1350 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1353 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1360 rm -f ".$package-req.txt"
1362 echo "Attempting to run spawn sub - builder..."
1363 run_sub_builder $package
1364 if [ $? -eq 0 ]; then
1365 install_required_packages $package;
1368 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1369 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1372 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1378 echo "Package $package is already installed. BuildRequirement satisfied."
1382 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1383 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1384 echo "Unable to install following packages and their dependencies:"
1385 for pkg in "$NOT_INSTALLED_PACKAGES"
1389 remove_build_requires
1397 # vim like diff colourization, glen@pld-linux.org
1399 s,
\e,
\e[44m^[
\e[49m,g;
1400 s,
\a,
\e[44m^G
\e[49m,g;
1401 s,^\(Index:\|diff\|---\|+++\) .*$,
\e[32m&,;
1405 s,
\r,
\e[44m^M
\e[49m,g;
1407 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1
\e[41m\2
\e[49m,g;
1416 tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/adapter-XXXXXX) || exit
1417 awk -f adapter.awk $SPECFILE > $tmpdir/$SPECFILE || exit
1419 if [ "`diff --brief $SPECFILE $tmpdir/$SPECFILE`" ] ; then
1420 diff -u $SPECFILE $tmpdir/$SPECFILE > $tmpdir/$SPECFILE.diff
1422 diffcol $tmpdir/$SPECFILE.diff | less -r
1424 echo -n "Accept? [yn] "
1428 mv -f $tmpdir/$SPECFILE $SPECFILE
1429 echo "Ok, adapterized."
1439 cat $tmpdir/$SPECFILE.diff
1442 echo "The SPEC is perfect ;)"
1448 #---------------------------------------------
1451 if [ "$#" = 0 ]; then
1465 --adapter | --adapterize )
1466 COMMAND="adapterize";
1483 DEBUG="yes"; shift ;;
1485 COMMAND="version"; shift ;;
1487 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1488 -b | -ba | --build )
1489 COMMAND="build"; shift ;;
1490 -bb | --build-binary )
1491 COMMAND="build-binary"; shift ;;
1492 -bs | --build-source )
1493 COMMAND="build-source"; shift ;;
1494 -bp | --build-prep )
1495 COMMAND="build-prep"; shift ;;
1497 COMMAND="branch"; shift; TAG="${1}"; shift;;
1499 CLEAN="--clean --rmspec --rmsource"; shift ;;
1501 shift; CVSROOT="${1}"; shift ;;
1503 COMMAND="get"; shift ;;
1505 COMMAND="usage"; shift ;;
1507 PROTOCOL="http"; shift ;;
1509 shift; LOGFILE="${1}"; shift ;;
1511 shift; DEF_NICE_LEVEL=${1}; shift ;;
1513 COMMAND="mr-proper"; shift ;;
1515 NOCVS="yes"; shift ;;
1516 -ncs | --no-cvs-specs )
1517 NOCVSSPEC="yes"; shift ;;
1518 -nd | --no-distfiles )
1519 NODIST="yes"; shift ;;
1520 -nm | --no-mirrors )
1521 NOMIRRORS="yes"; shift ;;
1523 NOURLS="yes"; shift ;;
1525 NOSRCS="yes"; shift ;;
1526 -ns0 | --no-source0 )
1527 NOSOURCE0="yes"; shift ;;
1537 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1538 --with | --without )
1539 case $GROUP_BCONDS in
1543 while ! `echo ${1}|grep -qE '(^-|spec)'`
1545 BCOND="$BCOND $COND $1"
1549 BCOND="$BCOND $1 $2" ; shift 2 ;;
1553 shift; TARGET="${1}"; shift ;;
1555 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1557 QUIET="--quiet"; shift ;;
1559 CVSDATE="${2}"; shift 2 ;;
1561 shift; CVSTAG="${1}"; shift ;;
1562 -R | --fetch-build-requires)
1563 FETCH_BUILD_REQUIRES="yes"
1564 NOT_INSTALLED_PACKAGES=
1566 -RB | --remove-build-requires)
1567 REMOVE_BUILD_REQUIRES="nice"
1569 -FRB | --force-remove-build-requires)
1570 REMOVE_BUILD_REQUIRES="force"
1572 -sf | --sources-files)
1573 COMMAND="list-sources-files"
1575 -sp | --sources-paths)
1576 COMMAND="list-sources-local-paths"
1578 -Tvs | --tag-version-stable )
1583 -Tvn | --tag-version-nest )
1588 -Ts | --tag-stable )
1598 -Tv | --tag-version )
1603 -Tp | --tag-prefix )
1615 -ir | --integer-release-only )
1616 INTEGER_RELEASE="yes"
1625 -Upi | --update-poldek-indexes )
1626 UPDATE_POLDEK_INDEXES="yes"
1628 -u | --try-upgrade )
1629 TRY_UPGRADE="1"; shift ;;
1630 -un | --try-upgrade-with-float-version )
1631 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1633 BE_VERBOSE="1"; shift ;;
1639 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1643 RPMOPTS="${RPMOPTS} --nodeps"
1646 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1649 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1654 if [ -n "$DEBUG" ]; then
1659 if [ -n "$TARGET" ]; then
1662 TARGET_SWITCH="--target $TARGET" ;;
1664 TARGET_SWITCH="--target=$TARGET" ;;
1669 "build" | "build-binary" | "build-source" | "build-prep" )
1671 if [ -n "$SPECFILE" ]; then
1675 fetch_build_requires;
1677 if [ "$INTEGER_RELEASE" = "yes" ]; then
1678 echo "Checking release $PACKAGE_RELEASE..."
1679 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1680 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1684 if [ -n "$TEST_TAG" ]; then
1685 TAGVER=`make_tagver`
1686 echo "Searching for tag $TAGVER..."
1687 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1688 if [ -n "$TAGREL" ]; then
1689 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1693 if [ -n "$ICONS" ]; then
1697 if [ -n "$NOSOURCE0" ] ; then
1698 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1700 get_files "$SOURCES $PATCHES";
1702 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1703 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1705 remove_build_requires;
1707 Exit_error err_no_spec_in_cmdl;
1712 if [ -n "$SPECFILE" ]; then
1715 if [ -n "$ICONS" ]; then
1719 get_files $SOURCES $PATCHES;
1720 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1722 Exit_error err_no_spec_in_cmdl;
1727 if [ -n "$SPECFILE" ]; then
1730 if [ -n "$ICONS" ]; then
1731 OLD_UPDATE5=$UPDATE5
1732 UPDATE5= get_files $ICONS
1733 UPDATE5=$OLD_UPDATE5
1736 if [ -n "$NOSOURCE0" ] ; then
1737 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1739 get_files $SOURCES $PATCHES
1741 Exit_error err_no_spec_in_cmdl;
1748 if [ -n "$SPECFILE" ]; then
1751 if [ -n "$ICONS" ]; then
1755 # don't fetch sources from remote locations
1757 for file in $SOURCES
1759 [ -n "`src_md5 $file`" ] && continue
1760 new_SOURCES="$new_SOURCES $file"
1762 SOURCES="$new_SOURCES"
1763 get_files $SOURCES $PATCHES;
1764 tag_files "$SOURCES $PATCHES $ICONS";
1766 Exit_error err_no_spec_in_cmdl;
1770 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1772 "list-sources-files" )
1775 DONT_PRINT_REVISION="yes"
1778 SAPS="$SOURCES $PATCHES"
1779 for SAP in $SAPS ; do
1780 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1783 "list-sources-local-paths" )
1786 DONT_PRINT_REVISION="yes"
1789 SAPS="$SOURCES $PATCHES"
1790 for SAP in $SAPS ; do
1791 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1802 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1803 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1807 # vi:syntax=sh:ts=3:sw=4