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 (well that's okay, how you compare versions if you have no old spec?)
20 # - when Icon: field is present, -5 and -a5 doesn't work
21 # - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
24 Build package utility from PLD CVS repository
25 V 0.13 (C) 1999-2005 Free Penguins".
26 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
45 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
48 # It can be used i.e. in log file naming.
49 # See LOGFILE example.
50 DATE=`date +%Y-%m-%d_%H-%M-%S`
52 # Example: LOGFILE='../log.$PACKAGE_NAME'
53 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
54 # Yes, you can use variable name! Note _single_ quotes!
76 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
77 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
82 CVS_SERVER="cvs.pld-linux.org"
83 DISTFILES_SERVER="://distfiles.pld-linux.org"
84 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
88 FAIL_IF_NO_SOURCES="yes"
90 if [ -x /usr/bin/rpm-getdeps ]; then
91 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
93 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
96 # Here we load saved user environment used to
97 # predefine options set above, or passed to builder
99 # This one reads global system environment settings:
100 if [ -f ~/etc/builderrc ]; then
103 # And this one cascades settings using user personal
105 # Example of ~/.builderrc:
107 #UPDATE_POLDEK_INDEXES="yes"
108 #FETCH_BUILD_REQUIRES="yes"
109 #REMOVE_BUILD_REQUIRES="force"
111 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
114 if [ -n "$HOME_ETC" ]; then
115 USER_CFG="$HOME_ETC/.builderrc"
117 USER_CFG=~/.builderrc
120 [ -f "$USER_CFG" ] && . "$USER_CFG"
122 wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
124 if [ -n "$USE_PROZILLA" ]; then
125 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
128 elif [ -n "$USE_AXEL" ]; then
129 GETURI="axel -a $AXEL_OPTS"
133 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
134 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
136 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
137 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
143 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
151 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
152 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
156 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
157 if [ -n "$LOGFILE" ]; then
158 LOG=`eval echo $LOGFILE`
159 if [ -n "$LASTLOG_FILE" ]; then
160 echo "LASTLOG=$LOG" > $LASTLOG_FILE
162 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
165 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
166 return `cat ${RES_FILE}`
171 #---------------------------------------------
176 if [ -n "$DEBUG" ]; then set -xv; fi
178 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
180 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
181 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
182 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
183 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
184 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
185 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
186 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
187 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
188 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
190 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
191 --adapter[ize] - run adapter.awk on SPECFILE
192 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
193 -n5, --no-md5 - ignore md5 comments in spec
194 -D, --debug - enable builder script debugging mode,
195 -debug - produce rpm debug package (same as --opts -debug)
196 -V, --version - output builder version
197 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
198 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
200 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
201 only package from <package>.spec,
202 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
204 -bp, --build-prep - execute the %prep phase of <package>.spec,
205 -B, --branch - add branch
206 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
207 SPECS and \$RPM_BUILD_ROOT),
208 -d <cvsroot>, --cvsroot <cvsroot>
210 --define <macro> <value>
211 - define a macro <macro> with value <value>,
212 --nodeps - rpm won't check any dependences
213 -g, --get - get <package>.spec and all related files from CVS repo
215 -h, --help - this message,
216 --http - use http instead of ftp,
217 -l <logfile>, --logtofile <logfile>
219 -m, --mr-proper - only remove all files related to spec file and all work
221 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
223 - don't check specs in CVS
224 -nd, --no-distfiles - don't download from distfiles
225 -nm, --no-mirrors - don't download from mirror, if source URL is given,
226 -nu, --no-urls - don't try to download from FTP/HTTP location,
227 -ns, --no-srcs - don't download Sources
228 -ns0, --no-source0 - don't download Source0
229 -nn, --no-net - don't download anything from the net
230 --opts <rpm opts> - additional options for rpm
231 -q, --quiet - be quiet,
232 --date yyyy-mm-dd - build package using resources from specified CVS date,
233 -r <cvstag>, --cvstag <cvstag>
234 - build package using resources from specified CVS tag,
235 -R, --fetch-build-requires
236 - fetch what is BuildRequired,
237 -RB, --remove-build-requires
238 - remove all you fetched with -R or --fetch-build-requires
239 remember, this option requires confirmation,
240 -FRB, --force-remove-build-requires
241 - remove all you fetched with -R or --fetch-build-requires
242 remember, this option works without confirmation,
243 -sf, --source-files - list sources - bare filenames (intended for offline
244 operations; does not work when Icon field is present
245 but icon file is absent),
246 -sp, --source-paths - list sources - filenames with full local paths (intended for
247 offline operations; does not work when Icon field is present
248 but icon file is absent),
249 -T <cvstag> , --tag <cvstag>
250 - add cvs tag <cvstag> for files,
251 -Tvs, --tag-version-stable
252 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
253 -Tvn, --tag-version-nest
254 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
256 - add cvs tag STABLE for files,
258 - add cvs tag NEST for files,
260 - add cvs tag NAME-VERSION-RELEASE for files,
261 -Tp, --tag-prefix <prefix>
262 - add <prefix> to NAME-VERSION-RELEASE tags,
263 -tt, --test-tag <prefix>
264 - fail if tag is already present,
265 -ir, --integer-release-only
266 - allow only integer and snapshot releases
267 -v, --verbose - be verbose,
268 -u, --try-upgrade - check version, and try to upgrade package
269 -un, --try-upgrade-with-float-version
270 - as above, but allow float version
271 -U, --update - refetch sources, don't use distfiles, and update md5 comments
272 -Upi, --update-poldek-indexes
273 - refresh or make poldek package index files.
274 -np, --nopatch <patchnumber>
275 - don't apply patches
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 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
320 if [ -z "$rpm_dump_cache" ] ; then
321 echo "internal error: cache_rpm_dump not called!" 1>&2
323 echo "$rpm_dump_cache"
328 if [ -n "$DEBUG" ]; then
337 if [ "$NOSRCS" != "yes" ]; then
338 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
340 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
341 FAIL_IF_NO_SOURCES="no"
344 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
345 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
346 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
347 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
348 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
350 # These variables may be unset after first cache_rpm_dump call
351 # (because of not-yet-retrieved icon file)
353 # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
354 # Exit_error err_no_package_data;
357 if [ -n "$BE_VERBOSE" ]; then
358 echo "- Sources : `nourl $SOURCES`"
359 if [ -n "$PATCHES" ]; then
360 echo "- Patches : `nourl $PATCHES`"
362 echo "- Patches : *no patches needed*"
364 if [ -n "$ICONS" ]; then
365 echo "- Icon : `nourl $ICONS`"
367 echo "- Icon : *no package icon*"
369 echo "- Name : $PACKAGE_NAME"
370 echo "- Version : $PACKAGE_VERSION"
371 echo "- Release : $PACKAGE_RELEASE"
377 if [ -n "$DEBUG" ]; then
385 "err_no_spec_in_cmdl" )
386 remove_build_requires
387 echo "ERROR: spec file name not specified.";
389 "err_no_spec_in_repo" )
390 remove_build_requires
391 echo "Error: spec file not stored in CVS repo.";
393 "err_no_source_in_repo" )
394 remove_build_requires
395 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
398 remove_build_requires
399 echo "Error: package build failed. (${2:-no more info})";
401 "err_no_package_data" )
402 remove_build_requires
403 echo "Error: couldn't get out package name/version/release from spec file."
406 remove_build_requires
407 echo "Tag ${2} already exists (spec release: ${3}).";
410 remove_build_requires
411 echo "Release ${2} not integer and not a snapshot.";
413 "err_branch_exists" )
414 remove_build_requires
415 echo "Tree branch already exists (${2}).";
419 echo "Unknown error."
425 if [ -n "$DEBUG" ]; then
430 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
431 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
438 if [ -n "$DEBUG" ]; then
444 if [ \! -f "$SPECFILE" ]; then
445 SPECFILE="`basename $SPECFILE .spec`.spec";
447 if [ "$NOCVSSPEC" != "yes" ]; then
450 if [ -n "$CVSROOT" ]; then
451 OPTIONS="-d $CVSROOT $OPTIONS"
453 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
454 echo "warning: No cvs access defined - using local .spec file"
459 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
460 OPTIONS="$OPTIONS -A"
462 if [ -n "$CVSDATE" ]; then
463 OPTIONS="$OPTIONS -D $CVSDATE"
465 if [ -n "$CVSTAG" ]; then
466 OPTIONS="$OPTIONS -r $CVSTAG"
472 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
474 retries_counter=$(( $retries_counter + 1 ))
475 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
477 [ -n "$output" ] && echo "$output"
478 if [ "$result" -ne "0" ]; then
479 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
480 echo "Trying again [$SPECFILE]... ($retries_counter)"
484 Exit_error err_no_spec_in_repo;
488 if [ ! -f "$SPECFILE" ]; then
489 Exit_error err_no_spec_in_repo;
492 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
493 chmod $CHMOD_MODE $SPECFILE
496 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
505 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
506 cvs update mirrors >&2
510 while read origin mirror name rest
512 ol=`echo -n "$origin"|wc -c`
513 prefix="`echo -n "$url" | head -c $ol`"
514 if [ "$prefix" = "$origin" ] ; then
515 suffix="`echo "$url"|cut -b $ol-`"
516 echo -n "$mirror$suffix"
527 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
528 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
534 [ X"$NO5" = X"yes" ] && return
536 [ -z "$no" ] && return
538 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
539 if [ -z "$spec_rev" ]; then
540 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
542 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
543 md5=$(grep -s -v '^#' additional-md5sums | \
544 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
545 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
546 grep -E '^[0-9a-f]{32}$')
547 if [ X"$md5" = X"" ] ; then
548 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
549 if [ ! -z "$source_md5" ] ; then
552 # we have empty SourceX-md5, but it is still possible
553 # that we have NoSourceX-md5 AND NoSource: X
554 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
555 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
560 if [ $(echo "$md5" | wc -l) != 1 ] ; then
561 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
563 echo "$md5" | tail -n 1
569 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
572 distfiles_attic_url ()
574 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
581 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
586 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
587 [ -n "$size" -a "$size" -gt 0 ]
592 if [ "$CVSIGNORE_DF" != "yes" ]; then
595 cvsignore=${SOURCE_DIR}/.cvsignore
596 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
597 echo "$1" >> $cvsignore
605 if [ -n "$DEBUG" ]; then
610 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
614 if [ -n "$CVSROOT" ]; then
615 OPTIONS="-d $CVSROOT $OPTIONS"
617 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
618 echo "warning: No cvs access defined for SOURCES"
622 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
623 OPTIONS="$OPTIONS -A"
625 if [ -n "$CVSDATE" ]; then
626 OPTIONS="$OPTIONS -D $CVSDATE"
628 if [ -n "$CVSTAG" ]; then
629 OPTIONS="$OPTIONS -r $CVSTAG"
634 if [ -n "$UPDATE5" ]; then
635 if [ -n "$ADD5" ]; then
636 [ `nourl $i` = "$i" ] && continue
637 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
639 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
643 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
644 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
645 echo "Warning: no URL given for $i"
648 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
649 if good_md5 "$i" && good_size "$i"; then
650 echo "$(nourl "$i") having proper md5sum already exists"
654 url=$(distfiles_url "$i")
655 url_attic=$(distfiles_attic_url "$i")
657 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
658 ${GETLOCAL} $url $target
660 if [ -z "$NOMIRRORS" ]; then
661 url="`find_mirror "$url"`"
663 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
664 if [ "`echo $url | grep -E 'ftp://'`" ]; then
665 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
668 if ! test -s "$target"; then
670 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
671 ${GETLOCAL} $url_attic $target
673 if [ -z "$NOMIRRORS" ]; then
674 url_attic="`find_mirror "$url_attic"`"
676 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
677 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
678 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
682 if test -s "$target"; then
688 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
689 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
692 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
694 retries_counter=$(( $retries_counter + 1 ))
695 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
697 [ -n "$output" ] && echo "$output"
698 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
699 echo "Trying again [`nourl $i`]... ($retries_counter)"
708 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
709 if [ -z "$NOMIRRORS" ]; then
710 im="`find_mirror "$i"`"
715 if [ "`echo $im | grep -E 'ftp://'`" ]; then
722 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
723 Exit_error err_no_source_in_repo $i;
724 elif [ -n "$UPDATE5" ] && \
725 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
726 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
727 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
729 echo "Updating source-$srcno md5."
730 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
732 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
733 print "# Source'$srcno'-md5:\t'$md5'\n"
734 if /^Source'$srcno'\s*:\s+/;
739 if good_md5 "$i" && good_size "$i"; then
741 elif [ "$FROM_DISTFILES" = 1 ]; then
742 # wrong md5 from distfiles: remove the file and try again
744 echo "MD5 sum mismatch. Trying full fetch."
747 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
748 if [ "`echo $url | grep -E 'ftp://'`" ]; then
749 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
751 if ! test -s "$target"; then
753 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
754 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
755 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
758 test -s "$target" || rm -f "$target"
761 if good_md5 "$i" && good_size "$i" ; then
764 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
765 echo "or -5 to update md5 sums, if you're sure files are correct."
766 Exit_error err_no_source_in_repo $i
770 if [ "$CHMOD" = "yes" ]; then
771 CHMOD_FILES="`nourl $GET_FILES`"
772 if [ -n "$CHMOD_FILES" ]; then
773 chmod $CHMOD_MODE $CHMOD_FILES
782 if [ -n "$DEBUG" ]; then
787 # Check whether first character of PACKAGE_NAME is legal for tag name
788 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
791 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"`
792 # Remove #kernel.version_release from TAGVER because tagging sources
793 # could occur with different kernel-headers than kernel-headers used at build time.
794 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
802 if [ -n "$DEBUG" ]; then
807 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
808 echo "Version: $PACKAGE_VERSION"
809 echo "Release: $PACKAGE_RELEASE"
813 if [ "$TAG_VERSION" = "yes" ]; then
814 echo "CVS tag: $TAGVER"
816 if [ -n "$TAG" ]; then
821 if [ -n "$CVSROOT" ]; then
822 OPTIONS="-d $CVSROOT $OPTIONS"
828 # don't tag files stored on distfiles
829 [ -n "`src_md5 $i`" ] && continue
830 if [ -f "`nourl $i`" ]; then
831 if [ "$TAG_VERSION" = "yes" ]; then
832 cvs $OPTIONS $TAGVER `nourl $i`
834 if [ -n "$TAG" ]; then
835 cvs $OPTIONS $TAG `nourl $i`
838 Exit_error err_no_source_in_repo $i
843 if [ "$TAG_VERSION" = "yes" ]; then
844 cvs $OPTIONS $TAGVER $SPECFILE
846 if [ -n "$TAG" ]; then
847 cvs $OPTIONS $TAG $SPECFILE
857 echo "CVS branch tag: $TAG"
862 if [ -n "$DEBUG" ]; then
867 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
870 if [ -n "$CVSROOT" ]; then
871 OPTIONS="-d $CVSROOT $OPTIONS"
876 if [ -f `nourl $i` ]; then
877 cvs $OPTIONS $TAG `nourl $i`
879 Exit_error err_no_source_in_repo $i
883 cvs $OPTIONS $TAG $SPECFILE
893 if [ -n "$DEBUG" ]; then
900 if [ -n "$TRY_UPGRADE" ]; then
901 if [ -n "$FLOAT_VERSION" ]; then
902 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
904 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
907 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
909 if [ -n "$TNEWVER" ]; then
910 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
911 echo "New version found, updating spec file to version " $TNEWVER
912 cp -f $SPECFILE $SPECFILE.bak
914 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
915 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
917 if [ -n "$ICONS" ]; then
921 NODIST="yes" UPDATE5="yes" get_files "$SOURCES $PATCHES";
922 unset TOLDVER TNEWVER TNOTIFY
929 BUILD_SWITCH="-ba" ;;
931 BUILD_SWITCH="-bb" ;;
933 BUILD_SWITCH="-bs --nodeps" ;;
935 BUILD_SWITCH="-bp --nodeps" ;;
937 if [ -n "$LOGFILE" ]; then
938 LOG=`eval echo $LOGFILE`
939 if [ -d "$LOG" ]; then
940 echo "Log file $LOG is a directory."
941 echo "Parse error in the spec?"
942 Exit_error err_build_fail;
944 if [ -n "$LASTLOG_FILE" ]; then
945 echo "LASTLOG=$LOG" > $LASTLOG_FILE
947 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
948 (time eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
949 RETVAL=`cat $RES_FILE`
951 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
952 if [ "$RETVAL" -eq "0" ]; then
959 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
962 if [ "$RETVAL" -ne "0" ]; then
963 if [ -n "$TRY_UPGRADE" ]; then
964 echo "\n!!! Package with new version cannot be build automagically\n"
965 mv -f $SPECFILE.bak $SPECFILE
967 Exit_error err_build_fail;
974 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
977 install_required_packages()
985 AVAIL_BCONDS_WITHOUT=""
987 if `grep -q ^%bcond ${SPECFILE}`; then
989 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
995 # expand bconds from ~/.bcondrc
996 # The file structure is like gentoo's package.use:
999 # samba -mysql -pgsql
1000 # w32codec-installer license_agreement
1003 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
1004 # This takes package name, first defined in spec.
1005 # so consider that when defining flags for package.
1006 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
1007 SN=${SPECFILE%%\.spec}
1008 AVAIL=`$RPMBUILD --bcond $SPECFILE`
1010 BCONDRC=$HOME/.bcondrc
1011 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
1013 while read pkg flags; do
1015 [[ "$pkg" == \#* ]] && continue
1017 # any package or current package?
1018 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ] || [ "$pkg" = "$SN" ]; then
1019 for flag in $flags; do
1022 # use only flags which are in this package.
1023 if [[ $AVAIL = *${opt}* ]]; then
1024 if [[ $flag = -* ]]; then
1025 BCOND="$BCOND --without $opt"
1027 BCOND="$BCOND --with $opt"
1035 case "${BCOND_VERSION}" in
1040 echo "Warning: This spec has old style bconds. Fix it || die."
1041 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1043 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1044 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1045 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1047 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1051 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1053 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1054 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1055 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1057 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1062 cond_type="" # with || without
1063 for opt in `$RPMBUILD --bcond $SPECFILE`
1073 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1074 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1075 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1077 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1081 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1082 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1083 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1085 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1089 case "$cond_type" in
1092 AVAIL_BCOND_WITH="$opt"
1093 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1094 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1096 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1101 AVAIL_BCOND_WITHOUT="$opt"
1102 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1103 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1105 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1119 echo -ne "Package installation failed:\t$package_name\n"
1121 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1122 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1123 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1124 # jakby nie bylo tego kawalka kodu.
1126 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1127 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1134 # Istnieje taki spec? ${package}.spec
1135 if [ -f "${SPECS_DIR}${package}.spec" ]; then
1136 parent_spec_name=${package}.spec
1137 elif [ -f "${SPECS_DIR}`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1138 parent_spec_name="`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1140 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1146 if [ "${parent_spec_name}" != "" ]; then
1148 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1149 sub_builder_opts="${sub_builder_opts} -R"
1151 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1152 sub_builder_opts="${sub_builder_opts} -RB"
1153 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1154 sub_builder_opts="${sub_builder_opts} -FRB"
1156 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1157 sub_builder_opts="${sub_builder_opts} -Upi"
1160 ./builder ${sub_builder_opts} ${parent_spec_name}
1162 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1165 remove_build_requires()
1167 if [ "$INSTALLED_PACKAGES" != "" ]; then
1168 case "$REMOVE_BUILD_REQUIRES" in
1170 run_poldek --noask -ve $INSTALLED_PACKAGES
1173 run_poldek --ask -ve $INSTALLED_PACKAGES
1176 echo You may want to manually remove following BuildRequires fetched:
1177 echo $INSTALLED_PACKAGES
1178 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1186 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1187 if [ "$BCOND" != "" ]; then
1188 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1191 echo -ne "\nNo conditional flags passed"
1193 echo -ne "\n\nfrom available:\n"
1194 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1200 if [ "$NOCVSSPEC" != "yes" ]; then
1201 echo -ne "Available branches: "
1202 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1206 # checks a given list of packages/files/provides agains current rpmdb.
1207 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1208 # input can be either STDIN or parameters
1213 if [ "$#" -gt 0 ]; then
1219 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1222 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1224 # other deps (files)
1225 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1228 # checks if given package/files/provides exists in rpmdb.
1229 # inout can be either stdin or parameters
1230 # returns packages wchi hare present in the rpmdb
1235 if [ "$#" -gt 0 ]; then
1241 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1244 fetch_build_requires()
1246 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1247 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1248 CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1249 DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1251 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1252 $SU_SUDO /usr/bin/poldek --update || $SU_SUDO /usr/bin/poldek --upa
1254 if [ -n "$CONF" ]; then
1255 echo "Trying to uninstall conflicting packages ($CONF):"
1256 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1258 if [ -n "$DEPS" ]; then
1259 echo "Trying to install dependencies ($DEPS):"
1260 $SU_SUDO /usr/bin/poldek --caplookup -uGv $DEPS
1265 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1266 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1267 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1268 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1269 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1270 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`
1272 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`"
1274 package=`basename "$package_item"|sed -e "s/}$//g"`
1275 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1278 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1279 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1280 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
1285 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1288 if `echo $COND_TST|grep -q 'without_'`; then
1289 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1290 if `echo $COND_TST|grep -q !`; then
1295 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1296 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1297 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1303 elif `echo $COND_TST|grep -q 'with_'`; then
1304 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1305 if `echo $COND_TST|grep -q !`; then
1310 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1311 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1312 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1318 RESULT="${COND_STATE}-${COND_ARGV}"
1320 "with-wout" | "wout-with" )
1323 "wout-wout" | "with-with" )
1327 echo "Action '$RESULT' was not defined for package '$package_item'"
1333 if [ "$GO" = "yes" ]; then
1334 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1335 echo "Testing if $package has subrequirements..."
1336 run_poldek -t -i $package --dumpn=".$package-req.txt"
1337 if [ -f ".$package-req.txt" ]; then
1338 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1340 if [ "$package_name" = "$package" ]; then
1341 echo -ne "Installing BuildRequired package:\t$package_name\n"
1342 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1343 install_required_packages $package;
1345 echo -ne "Installing (sub)Required package:\t$package_name\n"
1346 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1347 install_required_packages $package_name;
1351 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1352 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1355 echo "Attempting to run spawn sub - builder..."
1356 run_sub_builder $package_name
1357 if [ $? -eq 0 ]; then
1358 install_required_packages $package_name;
1361 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1362 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1365 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1372 rm -f ".$package-req.txt"
1374 echo "Attempting to run spawn sub - builder..."
1375 run_sub_builder $package
1376 if [ $? -eq 0 ]; then
1377 install_required_packages $package;
1380 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1381 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1384 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1390 echo "Package $package is already installed. BuildRequirement satisfied."
1394 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1395 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1396 echo "Unable to install following packages and their dependencies:"
1397 for pkg in "$NOT_INSTALLED_PACKAGES"
1401 remove_build_requires
1409 # vim like diff colourization, glen@pld-linux.org
1411 s,
\e,
\e[44m^[
\e[49m,g;
1412 s,
\a,
\e[44m^G
\e[49m,g;
1413 s,^\(Index:\|diff\|---\|+++\) .*$,
\e[32m&,;
1417 s,
\r,
\e[44m^M
\e[49m,g;
1419 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1
\e[41m\2
\e[49m,g;
1428 tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/adapter-XXXXXX) || exit
1429 awk -f adapter.awk $SPECFILE > $tmpdir/$SPECFILE || exit
1431 if [ "`diff --brief $SPECFILE $tmpdir/$SPECFILE`" ] ; then
1432 diff -u $SPECFILE $tmpdir/$SPECFILE > $tmpdir/$SPECFILE.diff
1434 diffcol $tmpdir/$SPECFILE.diff | less -r
1436 echo -n "Accept? [yn] "
1440 mv -f $tmpdir/$SPECFILE $SPECFILE
1441 echo "Ok, adapterized."
1451 cat $tmpdir/$SPECFILE.diff
1454 echo "The SPEC is perfect ;)"
1460 #---------------------------------------------
1463 if [ "$#" = 0 ]; then
1477 --adapter | --adapterize )
1478 COMMAND="adapterize";
1495 DEBUG="yes"; shift ;;
1497 COMMAND="version"; shift ;;
1499 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1500 -b | -ba | --build )
1501 COMMAND="build"; shift ;;
1502 -bb | --build-binary )
1503 COMMAND="build-binary"; shift ;;
1504 -bs | --build-source )
1505 COMMAND="build-source"; shift ;;
1506 -bp | --build-prep )
1507 COMMAND="build-prep"; shift ;;
1509 COMMAND="branch"; shift; TAG="${1}"; shift;;
1511 CLEAN="--clean --rmspec --rmsource"; shift ;;
1513 shift; CVSROOT="${1}"; shift ;;
1515 COMMAND="get"; shift ;;
1517 COMMAND="usage"; shift ;;
1519 PROTOCOL="http"; shift ;;
1521 shift; LOGFILE="${1}"; shift ;;
1523 shift; DEF_NICE_LEVEL=${1}; shift ;;
1525 COMMAND="mr-proper"; shift ;;
1527 NOCVS="yes"; shift ;;
1528 -ncs | --no-cvs-specs )
1529 NOCVSSPEC="yes"; shift ;;
1530 -nd | --no-distfiles )
1531 NODIST="yes"; shift ;;
1532 -nm | --no-mirrors )
1533 NOMIRRORS="yes"; shift ;;
1535 NOURLS="yes"; shift ;;
1537 NOSRCS="yes"; shift ;;
1538 -ns0 | --no-source0 )
1539 NOSOURCE0="yes"; shift ;;
1549 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1551 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} echo ignoring patch${1} \""; shift ;;
1552 --with | --without )
1553 case $GROUP_BCONDS in
1557 while ! `echo ${1}|grep -qE '(^-|spec)'`
1559 BCOND="$BCOND $COND $1"
1563 if [[ "$2" = *,* ]]; then
1564 for a in $(echo "$2" | tr , ' '); do
1565 BCOND="$BCOND $1 $a"
1568 BCOND="$BCOND $1 $2"
1574 shift; TARGET="${1}"; shift ;;
1576 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1578 QUIET="--quiet"; shift ;;
1580 CVSDATE="${2}"; shift 2 ;;
1582 shift; CVSTAG="${1}"; shift ;;
1583 -R | --fetch-build-requires)
1584 FETCH_BUILD_REQUIRES="yes"
1585 NOT_INSTALLED_PACKAGES=
1587 -RB | --remove-build-requires)
1588 REMOVE_BUILD_REQUIRES="nice"
1590 -FRB | --force-remove-build-requires)
1591 REMOVE_BUILD_REQUIRES="force"
1593 -sf | --sources-files)
1594 COMMAND="list-sources-files"
1596 -sp | --sources-paths)
1597 COMMAND="list-sources-local-paths"
1599 -Tvs | --tag-version-stable )
1604 -Tvn | --tag-version-nest )
1609 -Ts | --tag-stable )
1619 -Tv | --tag-version )
1624 -Tp | --tag-prefix )
1636 -ir | --integer-release-only )
1637 INTEGER_RELEASE="yes"
1646 -Upi | --update-poldek-indexes )
1647 UPDATE_POLDEK_INDEXES="yes"
1649 -u | --try-upgrade )
1650 TRY_UPGRADE="1"; shift ;;
1651 -un | --try-upgrade-with-float-version )
1652 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1654 BE_VERBOSE="1"; shift ;;
1660 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1664 RPMOPTS="${RPMOPTS} --nodeps"
1667 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1670 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1675 if [ -n "$DEBUG" ]; then
1680 if [ -n "$TARGET" ]; then
1683 TARGET_SWITCH="--target $TARGET" ;;
1685 TARGET_SWITCH="--target=$TARGET" ;;
1690 "build" | "build-binary" | "build-source" | "build-prep" )
1692 if [ -n "$SPECFILE" ]; then
1697 fetch_build_requires;
1699 if [ "$INTEGER_RELEASE" = "yes" ]; then
1700 echo "Checking release $PACKAGE_RELEASE..."
1701 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1702 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1706 if [ -n "$TEST_TAG" ]; then
1707 TAGVER=`make_tagver`
1708 echo "Searching for tag $TAGVER..."
1709 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1710 if [ -n "$TAGREL" ]; then
1711 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1714 # - do not allow to build from HEAD when XX-branch exists
1715 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1716 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1717 TAG_BRANCH="${TREE_PREFIX}-branch"
1718 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1719 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1720 Exit_error err_branch_exists "$TAG_STATUS"
1726 if [ -n "$ICONS" ]; then
1730 if [ -n "$NOSOURCE0" ] ; then
1731 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1733 get_files "$SOURCES $PATCHES";
1735 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1736 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1738 remove_build_requires;
1740 Exit_error err_no_spec_in_cmdl;
1745 if [ -n "$SPECFILE" ]; then
1748 if [ -n "$ICONS" ]; then
1752 get_files $SOURCES $PATCHES;
1753 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1755 Exit_error err_no_spec_in_cmdl;
1760 if [ -n "$SPECFILE" ]; then
1763 if [ -n "$ICONS" ]; then
1764 OLD_UPDATE5=$UPDATE5
1765 UPDATE5= get_files $ICONS
1766 UPDATE5=$OLD_UPDATE5
1769 if [ -n "$NOSOURCE0" ] ; then
1770 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1772 get_files $SOURCES $PATCHES
1774 Exit_error err_no_spec_in_cmdl;
1781 if [ -n "$SPECFILE" ]; then
1784 if [ -n "$ICONS" ]; then
1788 # don't fetch sources from remote locations
1790 for file in $SOURCES
1792 [ -n "`src_md5 $file`" ] && continue
1793 new_SOURCES="$new_SOURCES $file"
1795 SOURCES="$new_SOURCES"
1796 get_files $SOURCES $PATCHES;
1797 tag_files "$SOURCES $PATCHES $ICONS";
1799 Exit_error err_no_spec_in_cmdl;
1803 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1805 "list-sources-files" )
1808 DONT_PRINT_REVISION="yes"
1811 SAPS="$SOURCES $PATCHES"
1812 for SAP in $SAPS ; do
1813 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1816 "list-sources-local-paths" )
1819 DONT_PRINT_REVISION="yes"
1822 SAPS="$SOURCES $PATCHES"
1823 for SAP in $SAPS ; do
1824 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1835 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1836 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1840 # vi:syntax=sh:ts=3:sw=4