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.12 (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>.
287 if [ -n "$DEBUG" ]; then
294 rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
297 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1
303 if [ -z "$rpm_dump_cache" ] ; then
304 echo "internal error: cache_rpm_dump not called!" 1>&2
306 echo "$rpm_dump_cache"
311 if [ -n "$DEBUG" ]; then
320 if [ "$NOSRCS" != "yes" ]; then
321 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
323 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
324 FAIL_IF_NO_SOURCES="no"
327 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
328 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
329 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
330 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
331 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
333 # These variables may be unset after first cache_rpm_dump call
334 # (because of not-yet-retrieved icon file)
336 # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
337 # Exit_error err_no_package_data;
340 if [ -n "$BE_VERBOSE" ]; then
341 echo "- Sources : `nourl $SOURCES`"
342 if [ -n "$PATCHES" ]; then
343 echo "- Patches : `nourl $PATCHES`"
345 echo "- Patches : *no patches needed*"
347 if [ -n "$ICONS" ]; then
348 echo "- Icon : `nourl $ICONS`"
350 echo "- Icon : *no package icon*"
352 echo "- Name : $PACKAGE_NAME"
353 echo "- Version : $PACKAGE_VERSION"
354 echo "- Release : $PACKAGE_RELEASE"
360 if [ -n "$DEBUG" ]; then
368 "err_no_spec_in_cmdl" )
369 remove_build_requires
370 echo "ERROR: spec file name not specified.";
372 "err_no_spec_in_repo" )
373 remove_build_requires
374 echo "Error: spec file not stored in CVS repo.";
376 "err_no_source_in_repo" )
377 remove_build_requires
378 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
381 remove_build_requires
382 echo "Error: package build failed. (${2:-no more info})";
384 "err_no_package_data" )
385 remove_build_requires
386 echo "Error: couldn't get out package name/version/release from spec file."
389 remove_build_requires
390 echo "Tag ${2} already exists (spec release: ${3}).";
393 remove_build_requires
394 echo "Release ${2} not integer and not a snapshot.";
398 echo "Unknown error."
404 if [ -n "$DEBUG" ]; then
409 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
410 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
417 if [ -n "$DEBUG" ]; then
423 if [ \! -f "$SPECFILE" ]; then
424 SPECFILE="`basename $SPECFILE .spec`.spec";
426 if [ "$NOCVSSPEC" != "yes" ]; then
429 if [ -n "$CVSROOT" ]; then
430 OPTIONS="-d $CVSROOT $OPTIONS"
432 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
433 echo "warning: No cvs access defined - using local .spec file"
438 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
439 OPTIONS="$OPTIONS -A"
441 if [ -n "$CVSDATE" ]; then
442 OPTIONS="$OPTIONS -D $CVSDATE"
444 if [ -n "$CVSTAG" ]; then
445 OPTIONS="$OPTIONS -r $CVSTAG"
451 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
453 retries_counter=$(( $retries_counter + 1 ))
454 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
456 [ -n "$output" ] && echo "$output"
457 if [ "$result" -ne "0" ]; then
458 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
459 echo "Trying again [$SPECFILE]... ($retries_counter)"
463 Exit_error err_no_spec_in_repo;
467 if [ ! -f "$SPECFILE" ]; then
468 Exit_error err_no_spec_in_repo;
471 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
472 chmod $CHMOD_MODE $SPECFILE
475 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
482 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
483 cvs update mirrors >&2
487 while read origin mirror name rest
489 ol=`echo -n "$origin"|wc -c`
490 prefix="`echo -n "$url" | head -c $ol`"
491 if [ "$prefix" = "$origin" ] ; then
492 suffix="`echo "$url"|cut -b $ol-`"
493 echo -n "$mirror$suffix"
504 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
505 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
511 [ X"$NO5" = X"yes" ] && return
513 [ -z "$no" ] && return
515 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
516 if [ -z "$spec_rev" ]; then
517 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
519 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
520 md5=$(grep -s -v '^#' additional-md5sums | \
521 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
522 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
523 grep -E '^[0-9a-f]{32}$')
524 if [ X"$md5" = X"" ] ; then
525 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
526 if [ ! -z "$source_md5" ] ; then
529 # we have empty SourceX-md5, but it is still possible
530 # that we have NoSourceX-md5 AND NoSource: X
531 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
532 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
537 if [ $(echo "$md5" | wc -l) != 1 ] ; then
538 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
540 echo "$md5" | tail -n 1
546 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
549 distfiles_attic_url ()
551 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
558 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
563 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
564 [ -n "$size" -a "$size" -gt 0 ]
569 if [ "$CVSIGNORE_DF" != "yes" ]; then
572 cvsignore=${SOURCE_DIR}/.cvsignore
573 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
574 echo "$1" >> $cvsignore
582 if [ -n "$DEBUG" ]; then
587 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
591 if [ -n "$CVSROOT" ]; then
592 OPTIONS="-d $CVSROOT $OPTIONS"
594 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
595 echo "warning: No cvs access defined for SOURCES"
599 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
600 OPTIONS="$OPTIONS -A"
602 if [ -n "$CVSDATE" ]; then
603 OPTIONS="$OPTIONS -D $CVSDATE"
605 if [ -n "$CVSTAG" ]; then
606 OPTIONS="$OPTIONS -r $CVSTAG"
611 if [ -n "$UPDATE5" ]; then
612 if [ -n "$ADD5" ]; then
613 [ `nourl $i` = "$i" ] && continue
614 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
616 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
620 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
621 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
622 echo "Warning: no URL given for $i"
625 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
626 if good_md5 "$i" && good_size "$i"; then
627 echo "$(nourl "$i") having proper md5sum already exists"
631 url=$(distfiles_url "$i")
632 url_attic=$(distfiles_attic_url "$i")
634 if [ `echo $url | grep -E '^(\.|/)'` ]; then
635 ${GETLOCAL} $url $target
637 if [ -z "$NOMIRRORS" ]; then
638 url="`find_mirror "$url"`"
640 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
641 if [ `echo $url | grep -E 'ftp://'` ]; then
642 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
645 if ! test -s "$target"; then
647 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
648 ${GETLOCAL} $url_attic $target
650 if [ -z "$NOMIRRORS" ]; then
651 url_attic="`find_mirror "$url_attic"`"
653 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
654 if [ `echo $url_attic | grep -E 'ftp://'` ]; then
655 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
659 if test -s "$target"; then
665 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
666 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
669 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
671 retries_counter=$(( $retries_counter + 1 ))
672 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
674 [ -n "$output" ] && echo "$output"
675 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
676 echo "Trying again [`nourl $i`]... ($retries_counter)"
685 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
686 if [ -z "$NOMIRRORS" ]; then
687 im="`find_mirror "$i"`"
692 if [ `echo $im | grep -E 'ftp://'` ]; then
699 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
700 Exit_error err_no_source_in_repo $i;
701 elif [ -n "$UPDATE5" ] && \
702 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
703 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
704 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
706 echo "Updating source-$srcno md5."
707 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
709 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
710 print "# Source'$srcno'-md5:\t'$md5'\n"
711 if /^Source'$srcno'\s*:\s+/;
716 if good_md5 "$i" && good_size "$i"; then
718 elif [ "$FROM_DISTFILES" = 1 ]; then
719 # wrong md5 from distfiles: remove the file and try again
721 echo "MD5 sum mismatch. Trying full fetch."
724 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
725 if [ `echo $url | grep -E 'ftp://'` ]; then
726 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
728 if ! test -s "$target"; then
730 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
731 if [ `echo $url_attic | grep -E 'ftp://'` ]; then
732 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
735 test -s "$target" || rm -f "$target"
738 if good_md5 "$i" && good_size "$i" ; then
741 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
742 echo "or -5 to update md5 sums, if you're sure files are correct."
743 Exit_error err_no_source_in_repo $i
747 if [ "$CHMOD" = "yes" ]; then
748 CHMOD_FILES="`nourl $GET_FILES`"
749 if [ -n "$CHMOD_FILES" ]; then
750 chmod $CHMOD_MODE $CHMOD_FILES
759 if [ -n "$DEBUG" ]; then
764 # Check whether first character of PACKAGE_NAME is legal for tag name
765 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
768 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"`
769 # Remove #kernel.version_release from TAGVER because tagging sources
770 # could occur with different kernel-headers than kernel-headers used at build time.
771 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
779 if [ -n "$DEBUG" ]; then
784 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
785 echo "Version: $PACKAGE_VERSION"
786 echo "Release: $PACKAGE_RELEASE"
790 if [ "$TAG_VERSION" = "yes" ]; then
791 echo "CVS tag: $TAGVER"
793 if [ -n "$TAG" ]; then
798 if [ -n "$CVSROOT" ]; then
799 OPTIONS="-d $CVSROOT $OPTIONS"
805 # don't tag files stored on distfiles
806 [ -n "`src_md5 $i`" ] && continue
807 if [ -f "`nourl $i`" ]; then
808 if [ "$TAG_VERSION" = "yes" ]; then
809 cvs $OPTIONS $TAGVER `nourl $i`
811 if [ -n "$TAG" ]; then
812 cvs $OPTIONS $TAG `nourl $i`
815 Exit_error err_no_source_in_repo $i
820 if [ "$TAG_VERSION" = "yes" ]; then
821 cvs $OPTIONS $TAGVER $SPECFILE
823 if [ -n "$TAG" ]; then
824 cvs $OPTIONS $TAG $SPECFILE
834 echo "CVS branch tag: $TAG"
839 if [ -n "$DEBUG" ]; then
844 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
847 if [ -n "$CVSROOT" ]; then
848 OPTIONS="-d $CVSROOT $OPTIONS"
853 if [ -f `nourl $i` ]; then
854 cvs $OPTIONS $TAG `nourl $i`
856 Exit_error err_no_source_in_repo $i
860 cvs $OPTIONS $TAG $SPECFILE
870 if [ -n "$DEBUG" ]; then
877 if [ -n "$TRY_UPGRADE" ]; then
878 if [ -n "$FLOAT_VERSION" ]; then
879 TNOTIFY=`./pldnotify.awk $SPECFILE -n`
881 TNOTIFY=`./pldnotify.awk $SPECFILE`
884 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
886 if [ -n "$TNEWVER" ]; then
887 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
888 echo "New version found, updating spec file to version " $TNEWVER
889 cp -f $SPECFILE $SPECFILE.bak
891 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
892 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE"
894 if [ -n "$ICONS" ]; then
898 get_files "$SOURCES $PATCHES";
899 unset TOLDVER TNEWVER TNOTIFY
906 BUILD_SWITCH="-ba" ;;
908 BUILD_SWITCH="-bb" ;;
910 BUILD_SWITCH="-bs --nodeps" ;;
912 BUILD_SWITCH="-bp --nodeps" ;;
914 if [ -n "$LOGFILE" ]; then
915 LOG=`eval echo $LOGFILE`
916 if [ -d "$LOG" ]; then
917 echo "Log file $LOG is a directory."
918 echo "Parse error in the spec?"
919 Exit_error err_build_fail;
921 if [ -n "$LASTLOG_FILE" ]; then
922 echo "LASTLOG=$LOG" > $LASTLOG_FILE
924 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
925 (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
926 RETVAL=`cat $RES_FILE`
928 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
929 if [ "$RETVAL" -eq "0" ]; then
936 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
939 if [ "$RETVAL" -ne "0" ]; then
940 if [ -n "$TRY_UPGRADE" ]; then
941 echo "\n!!! Package with new version cannot be build automagically\n"
942 mv -f $SPECFILE.bak $SPECFILE
944 Exit_error err_build_fail;
951 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
954 install_required_packages()
962 AVAIL_BCONDS_WITHOUT=""
964 if `grep -q ^%bcond ${SPECFILE}`; then
966 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
972 # expand bconds from ~/.bcondrc
973 # The file structure is like gentoo's package.use:
976 # samba -mysql -pgsql
977 # w32codec-installer license_agreement
980 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
981 # This takes package name, first defined in spec.
982 # so consider that when defining flags for package.
983 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
984 AVAIL=`$RPMBUILD --bcond $SPECFILE`
986 BCONDRC=$HOME/.bcondrc
987 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
989 while read pkg flags; do
991 [[ "$pkg" == \#* ]] && continue
993 # any package or current package?
994 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ]; then
995 for flag in $flags; do
998 # use only flags which are in this package.
999 if [[ $AVAIL = *${opt}* ]]; then
1000 if [[ $flag = -* ]]; then
1001 BCOND="$BCOND --without $opt"
1003 BCOND="$BCOND --with $opt"
1011 case "${BCOND_VERSION}" in
1016 echo "Warning: This spec has old style bconds. Fix it || die."
1017 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1019 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1020 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1021 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1023 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1027 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1029 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1030 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1031 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1033 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1038 cond_type="" # with || without
1039 for opt in `$RPMBUILD --bcond $SPECFILE`
1049 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1050 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1051 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1053 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1057 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1058 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1059 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1061 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1065 case "$cond_type" in
1068 AVAIL_BCOND_WITH="$opt"
1069 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1070 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1072 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1077 AVAIL_BCOND_WITHOUT="$opt"
1078 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1079 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1081 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1095 echo -ne "Package installation failed:\t$package_name\n"
1097 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1098 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1099 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1100 # jakby nie bylo tego kawalka kodu.
1102 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1103 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1110 # Istnieje taki spec? ${package}.spec
1111 if [ -f "${SPECS_DIR}${package}.spec" ]; then
1112 parent_spec_name=${package}.spec
1113 elif [ -f "${SPECS_DIR}`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1114 parent_spec_name="`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1116 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1122 if [ "${parent_spec_name}" != "" ]; then
1124 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1125 sub_builder_opts="${sub_builder_opts} -R"
1127 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1128 sub_builder_opts="${sub_builder_opts} -RB"
1129 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1130 sub_builder_opts="${sub_builder_opts} -FRB"
1132 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1133 sub_builder_opts="${sub_builder_opts} -Upi"
1136 ./builder ${sub_builder_opts} ${parent_spec_name}
1138 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1141 remove_build_requires()
1143 if [ "$INSTALLED_PACKAGES" != "" ]; then
1144 case "$REMOVE_BUILD_REQUIRES" in
1146 run_poldek --noask -ve $INSTALLED_PACKAGES
1149 run_poldek --ask -ve $INSTALLED_PACKAGES
1152 echo You may want to manually remove following BuildRequires fetched:
1153 echo $INSTALLED_PACKAGES
1154 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1162 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1163 if [ "$BCOND" != "" ]; then
1164 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1167 echo -ne "\nNo conditional flags passed"
1169 echo -ne "\n\nfrom available:\n"
1170 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1174 # checks a given list of packages/files/provides agains current rpmdb.
1175 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1176 # input can be either STDIN or parameters
1181 if [ "$#" -gt 0 ]; then
1187 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1190 echo "$DEPS" | awk '/^no package provides/ { print "@" $NF }'
1192 # other deps (files)
1193 echo "$DEPS" | awk -F: '/^error:.*No such file/{o=$2; gsub("^ file ", "", o); print "@" o}'
1196 # checks if given package/files/provides exists in rpmdb.
1197 # inout can be either stdin or parameters
1198 # returns packages wchi hare present in the rpmdb
1203 if [ "$#" -gt 0 ]; then
1209 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1212 fetch_build_requires()
1214 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1215 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1216 CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1217 DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1219 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1220 $SU_SUDO /usr/bin/poldek --update || $SU_SUDO /usr/bin/poldek --upa
1222 if [ -n "$CONF" ]; then
1223 echo "Trying to uninstall conflicting packages ($CONF):"
1224 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1226 if [ -n "$DEPS" ]; then
1227 echo "Trying to install dependencies ($DEPS):"
1228 $SU_SUDO /usr/bin/poldek --caplookup -uGv $DEPS
1233 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1234 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1235 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1236 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1237 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1238 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`
1240 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`"
1242 package=`basename "$package_item"|sed -e "s/}$//g"`
1243 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1246 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1247 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1248 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
1253 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1256 if `echo $COND_TST|grep -q 'without_'`; then
1257 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1258 if `echo $COND_TST|grep -q !`; then
1263 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1264 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1265 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1271 elif `echo $COND_TST|grep -q 'with_'`; then
1272 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1273 if `echo $COND_TST|grep -q !`; then
1278 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1279 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1280 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1286 RESULT="${COND_STATE}-${COND_ARGV}"
1288 "with-wout" | "wout-with" )
1291 "wout-wout" | "with-with" )
1295 echo "Action '$RESULT' was not defined for package '$package_item'"
1301 if [ "$GO" = "yes" ]; then
1302 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1303 echo "Testing if $package has subrequirements..."
1304 run_poldek -t -i $package --dumpn=".$package-req.txt"
1305 if [ -f ".$package-req.txt" ]; then
1306 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1308 if [ "$package_name" = "$package" ]; then
1309 echo -ne "Installing BuildRequired package:\t$package_name\n"
1310 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1311 install_required_packages $package;
1313 echo -ne "Installing (sub)Required package:\t$package_name\n"
1314 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1315 install_required_packages $package_name;
1319 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1320 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1323 echo "Attempting to run spawn sub - builder..."
1324 run_sub_builder $package_name
1325 if [ $? -eq 0 ]; then
1326 install_required_packages $package_name;
1329 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1330 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1333 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1340 rm -f ".$package-req.txt"
1342 echo "Attempting to run spawn sub - builder..."
1343 run_sub_builder $package
1344 if [ $? -eq 0 ]; then
1345 install_required_packages $package;
1348 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1349 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1352 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1358 echo "Package $package is already installed. BuildRequirement satisfied."
1362 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1363 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1364 echo "Unable to install following packages and their dependencies:"
1365 for pkg in "$NOT_INSTALLED_PACKAGES"
1369 remove_build_requires
1377 # vim like diff colourization, glen@pld-linux.org
1379 s,
\e,
\e[44m^[
\e[49m,g;
1380 s,
\a,
\e[44m^G
\e[49m,g;
1381 s,^\(Index:\|diff\|---\|+++\) .*$,
\e[32m&,;
1385 s,
\r,
\e[44m^M
\e[49m,g;
1387 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1
\e[41m\2
\e[49m,g;
1396 tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/adapter-XXXXXX) || exit
1397 awk -f adapter.awk $SPECFILE > $tmpdir/$SPECFILE
1399 if [ "`diff --brief $SPECFILE $tmpdir/$SPECFILE`" ] ; then
1400 diff -u $SPECFILE $tmpdir/$SPECFILE > $tmpdir/$SPECFILE.diff
1401 diffcol $tmpdir/$SPECFILE.diff | less -r
1404 echo -n "Accept? [yn] "
1408 mv -f $tmpdir/$SPECFILE $SPECFILE
1409 echo "Ok, adapterized."
1420 echo "The SPEC is perfect ;)"
1426 #---------------------------------------------
1429 if [ "$#" = 0 ]; then
1443 --adapter | --adapterize )
1444 COMMAND="adapterize";
1461 DEBUG="yes"; shift ;;
1463 COMMAND="version"; shift ;;
1465 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1466 -b | -ba | --build )
1467 COMMAND="build"; shift ;;
1468 -bb | --build-binary )
1469 COMMAND="build-binary"; shift ;;
1470 -bs | --build-source )
1471 COMMAND="build-source"; shift ;;
1472 -bp | --build-prep )
1473 COMMAND="build-prep"; shift ;;
1475 COMMAND="branch"; shift; TAG="${1}"; shift;;
1477 CLEAN="--clean --rmspec --rmsource"; shift ;;
1479 shift; CVSROOT="${1}"; shift ;;
1481 COMMAND="get"; shift ;;
1483 COMMAND="usage"; shift ;;
1485 PROTOCOL="http"; shift ;;
1487 shift; LOGFILE="${1}"; shift ;;
1489 shift; DEF_NICE_LEVEL=${1}; shift ;;
1491 COMMAND="mr-proper"; shift ;;
1493 NOCVS="yes"; shift ;;
1494 -ncs | --no-cvs-specs )
1495 NOCVSSPEC="yes"; shift ;;
1496 -nd | --no-distfiles )
1497 NODIST="yes"; shift ;;
1498 -nm | --no-mirrors )
1499 NOMIRRORS="yes"; shift ;;
1501 NOURLS="yes"; shift ;;
1503 NOSRCS="yes"; shift ;;
1504 -ns0 | --no-source0 )
1505 NOSOURCE0="yes"; shift ;;
1515 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1516 --with | --without )
1517 case $GROUP_BCONDS in
1521 while ! `echo ${1}|grep -qE '(^-|spec)'`
1523 BCOND="$BCOND $COND $1"
1527 BCOND="$BCOND $1 $2" ; shift 2 ;;
1531 shift; TARGET="${1}"; shift ;;
1533 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1535 QUIET="--quiet"; shift ;;
1537 CVSDATE="${2}"; shift 2 ;;
1539 shift; CVSTAG="${1}"; shift ;;
1540 -R | --fetch-build-requires)
1541 FETCH_BUILD_REQUIRES="yes"
1542 NOT_INSTALLED_PACKAGES=
1544 -RB | --remove-build-requires)
1545 REMOVE_BUILD_REQUIRES="nice"
1547 -FRB | --force-remove-build-requires)
1548 REMOVE_BUILD_REQUIRES="force"
1550 -sf | --sources-files)
1551 COMMAND="list-sources-files"
1553 -sp | --sources-paths)
1554 COMMAND="list-sources-local-paths"
1556 -Tvs | --tag-version-stable )
1561 -Tvn | --tag-version-nest )
1566 -Ts | --tag-stable )
1576 -Tv | --tag-version )
1581 -Tp | --tag-prefix )
1593 -ir | --integer-release-only )
1594 INTEGER_RELEASE="yes"
1603 -Upi | --update-poldek-indexes )
1604 UPDATE_POLDEK_INDEXES="yes"
1606 -u | --try-upgrade )
1607 TRY_UPGRADE="1"; shift ;;
1608 -un | --try-upgrade-with-float-version )
1609 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1611 BE_VERBOSE="1"; shift ;;
1617 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1621 RPMOPTS="${RPMOPTS} --nodeps"
1624 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1627 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1632 if [ -n "$DEBUG" ]; then
1637 if [ -n "$TARGET" ]; then
1640 TARGET_SWITCH="--target $TARGET" ;;
1642 TARGET_SWITCH="--target=$TARGET" ;;
1647 "build" | "build-binary" | "build-source" | "build-prep" )
1649 if [ -n "$SPECFILE" ]; then
1653 fetch_build_requires;
1655 if [ "$INTEGER_RELEASE" = "yes" ]; then
1656 echo "Checking release $PACKAGE_RELEASE..."
1657 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1658 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1662 if [ -n "$TEST_TAG" ]; then
1663 TAGVER=`make_tagver`
1664 echo "Searching for tag $TAGVER..."
1665 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1666 if [ -n "$TAGREL" ]; then
1667 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1671 if [ -n "$ICONS" ]; then
1675 if [ -n "$NOSOURCE0" ] ; then
1676 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1678 get_files "$SOURCES $PATCHES";
1680 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1681 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1683 remove_build_requires;
1685 Exit_error err_no_spec_in_cmdl;
1690 if [ -n "$SPECFILE" ]; then
1693 if [ -n "$ICONS" ]; then
1697 get_files $SOURCES $PATCHES;
1698 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1700 Exit_error err_no_spec_in_cmdl;
1705 if [ -n "$SPECFILE" ]; then
1708 if [ -n "$ICONS" ]; then
1709 OLD_UPDATE5=$UPDATE5
1710 UPDATE5= get_files $ICONS
1711 UPDATE5=$OLD_UPDATE5
1714 if [ -n "$NOSOURCE0" ] ; then
1715 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1717 get_files $SOURCES $PATCHES
1719 Exit_error err_no_spec_in_cmdl;
1726 if [ -n "$SPECFILE" ]; then
1729 if [ -n "$ICONS" ]; then
1733 # don't fetch sources from remote locations
1735 for file in $SOURCES
1737 [ -n "`src_md5 $file`" ] && continue
1738 new_SOURCES="$new_SOURCES $file"
1740 SOURCES="$new_SOURCES"
1741 get_files $SOURCES $PATCHES;
1742 tag_files "$SOURCES $PATCHES $ICONS";
1744 Exit_error err_no_spec_in_cmdl;
1748 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1750 "list-sources-files" )
1753 DONT_PRINT_REVISION="yes"
1756 SAPS="$SOURCES $PATCHES"
1757 for SAP in $SAPS ; do
1758 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1761 "list-sources-local-paths" )
1764 DONT_PRINT_REVISION="yes"
1767 SAPS="$SOURCES $PATCHES"
1768 for SAP in $SAPS ; do
1769 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1780 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1781 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1785 # vi:syntax=sh:ts=3:sw=4