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
23 Build package utility from PLD CVS repository
24 V 0.13 (C) 1999-2005 Free Penguins".
25 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
44 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
47 # It can be used i.e. in log file naming.
48 # See LOGFILE example.
49 DATE=`date +%Y-%m-%d_%H-%M-%S`
51 # Example: LOGFILE='../log.$PACKAGE_NAME'
52 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
53 # Yes, you can use variable name! Note _single_ quotes!
75 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
76 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
81 CVS_SERVER="cvs.pld-linux.org"
82 DISTFILES_SERVER="://distfiles.pld-linux.org"
83 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
87 FAIL_IF_NO_SOURCES="yes"
89 if [ -x /usr/bin/rpm-getdeps ]; then
90 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
92 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
95 # Here we load saved user environment used to
96 # predefine options set above, or passed to builder
98 # This one reads global system environment settings:
99 if [ -f ~/etc/builderrc ]; then
102 # And this one cascades settings using user personal
104 # Example of ~/.builderrc:
106 #UPDATE_POLDEK_INDEXES="yes"
107 #FETCH_BUILD_REQUIRES="yes"
108 #REMOVE_BUILD_REQUIRES="force"
110 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
113 if [ -n "$HOME_ETC" ]; then
114 USER_CFG="$HOME_ETC/.builderrc"
116 USER_CFG=~/.builderrc
119 [ -f "$USER_CFG" ] && . "$USER_CFG"
121 wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
123 if [ -n "$USE_PROZILLA" ]; then
124 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
127 elif [ -n "$USE_AXEL" ]; then
128 GETURI="axel -a $AXEL_OPTS"
132 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
133 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
135 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
136 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
142 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
150 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
151 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
155 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
156 if [ -n "$LOGFILE" ]; then
157 LOG=`eval echo $LOGFILE`
158 if [ -n "$LASTLOG_FILE" ]; then
159 echo "LASTLOG=$LOG" > $LASTLOG_FILE
161 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
164 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
165 return `cat ${RES_FILE}`
170 #---------------------------------------------
175 if [ -n "$DEBUG" ]; then set -xv; fi
177 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
179 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
180 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
181 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
182 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
183 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
184 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
185 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
186 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
187 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
189 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
190 --adapter[ize] - run adapter.awk on SPECFILE
191 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
192 -n5, --no-md5 - ignore md5 comments in spec
193 -D, --debug - enable builder script debugging mode,
194 -debug - produce rpm debug package (same as --opts -debug)
195 -V, --version - output builder version
196 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
197 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
199 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
200 only package from <package>.spec,
201 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
203 -bp, --build-prep - execute the %prep phase of <package>.spec,
204 -B, --branch - add branch
205 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
206 SPECS and \$RPM_BUILD_ROOT),
207 -d <cvsroot>, --cvsroot <cvsroot>
209 --define <macro> <value>
210 - define a macro <macro> with value <value>,
211 --nodeps - rpm won't check any dependences
212 -g, --get - get <package>.spec and all related files from CVS repo
214 -h, --help - this message,
215 --http - use http instead of ftp,
216 -l <logfile>, --logtofile <logfile>
218 -m, --mr-proper - only remove all files related to spec file and all work
220 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
222 - don't check specs in CVS
223 -nd, --no-distfiles - don't download from distfiles
224 -nm, --no-mirrors - don't download from mirror, if source URL is given,
225 -nu, --no-urls - don't try to download from FTP/HTTP location,
226 -ns, --no-srcs - don't download Sources
227 -ns0, --no-source0 - don't download Source0
228 -nn, --no-net - don't download anything from the net
229 --opts <rpm opts> - additional options for rpm
230 -q, --quiet - be quiet,
231 --date yyyy-mm-dd - build package using resources from specified CVS date,
232 -r <cvstag>, --cvstag <cvstag>
233 - build package using resources from specified CVS tag,
234 -R, --fetch-build-requires
235 - fetch what is BuildRequired,
236 -RB, --remove-build-requires
237 - remove all you fetched with -R or --fetch-build-requires
238 remember, this option requires confirmation,
239 -FRB, --force-remove-build-requires
240 - remove all you fetched with -R or --fetch-build-requires
241 remember, this option works without confirmation,
242 -sf, --source-files - list sources - bare filenames (intended for offline
243 operations; does not work when Icon field is present
244 but icon file is absent),
245 -sp, --source-paths - list sources - filenames with full local paths (intended for
246 offline operations; does not work when Icon field is present
247 but icon file is absent),
248 -T <cvstag> , --tag <cvstag>
249 - add cvs tag <cvstag> for files,
250 -Tvs, --tag-version-stable
251 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
252 -Tvn, --tag-version-nest
253 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
255 - add cvs tag STABLE for files,
257 - add cvs tag NEST for files,
259 - add cvs tag NAME-VERSION-RELEASE for files,
260 -Tp, --tag-prefix <prefix>
261 - add <prefix> to NAME-VERSION-RELEASE tags,
262 -tt, --test-tag <prefix>
263 - fail if tag is already present,
264 -ir, --integer-release-only
265 - allow only integer and snapshot releases
266 -v, --verbose - be verbose,
267 -u, --try-upgrade - check version, and try to upgrade package
268 -un, --try-upgrade-with-float-version
269 - as above, but allow float version
270 -U, --update - refetch sources, don't use distfiles, and update md5 comments
271 -Upi, --update-poldek-indexes
272 - refresh or make poldek package index files.
273 -np, --nopatch <patchnumber>
274 - don't apply patches
275 --with/--without <feature>
276 - conditional build package depending on %_with_<feature>/
277 %_without_<feature> macro switch. You may now use
278 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
279 constructions. Set GROUP_BCONDS to yes to make use of it.
280 --target <platform>, --target=<platform>
281 - build for platform <platform>.
285 # set TARGET from BuildArch: from SPECFILE
287 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
288 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
293 TARGET_SWITCH="--target $TARGET" ;;
295 TARGET_SWITCH="--target=$TARGET" ;;
302 if [ -n "$DEBUG" ]; then
310 rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
313 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
319 if [ -z "$rpm_dump_cache" ] ; then
320 echo "internal error: cache_rpm_dump not called!" 1>&2
322 echo "$rpm_dump_cache"
327 if [ -n "$DEBUG" ]; then
336 if [ "$NOSRCS" != "yes" ]; then
337 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
339 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
340 FAIL_IF_NO_SOURCES="no"
343 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
344 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
345 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
346 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
347 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
349 # These variables may be unset after first cache_rpm_dump call
350 # (because of not-yet-retrieved icon file)
352 # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
353 # Exit_error err_no_package_data;
356 if [ -n "$BE_VERBOSE" ]; then
357 echo "- Sources : `nourl $SOURCES`"
358 if [ -n "$PATCHES" ]; then
359 echo "- Patches : `nourl $PATCHES`"
361 echo "- Patches : *no patches needed*"
363 if [ -n "$ICONS" ]; then
364 echo "- Icon : `nourl $ICONS`"
366 echo "- Icon : *no package icon*"
368 echo "- Name : $PACKAGE_NAME"
369 echo "- Version : $PACKAGE_VERSION"
370 echo "- Release : $PACKAGE_RELEASE"
376 if [ -n "$DEBUG" ]; then
384 "err_no_spec_in_cmdl" )
385 remove_build_requires
386 echo "ERROR: spec file name not specified.";
388 "err_no_spec_in_repo" )
389 remove_build_requires
390 echo "Error: spec file not stored in CVS repo.";
392 "err_no_source_in_repo" )
393 remove_build_requires
394 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
397 remove_build_requires
398 echo "Error: package build failed. (${2:-no more info})";
400 "err_no_package_data" )
401 remove_build_requires
402 echo "Error: couldn't get out package name/version/release from spec file."
405 remove_build_requires
406 echo "Tag ${2} already exists (spec release: ${3}).";
409 remove_build_requires
410 echo "Release ${2} not integer and not a snapshot.";
412 "err_branch_exists" )
413 remove_build_requires
414 echo "Tree branch already exists (${2}).";
418 echo "Unknown error."
424 if [ -n "$DEBUG" ]; then
429 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
430 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
437 if [ -n "$DEBUG" ]; then
443 if [ \! -f "$SPECFILE" ]; then
444 SPECFILE="`basename $SPECFILE .spec`.spec";
446 if [ "$NOCVSSPEC" != "yes" ]; then
449 if [ -n "$CVSROOT" ]; then
450 OPTIONS="-d $CVSROOT $OPTIONS"
452 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
453 echo "warning: No cvs access defined - using local .spec file"
458 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
459 OPTIONS="$OPTIONS -A"
461 if [ -n "$CVSDATE" ]; then
462 OPTIONS="$OPTIONS -D $CVSDATE"
464 if [ -n "$CVSTAG" ]; then
465 OPTIONS="$OPTIONS -r $CVSTAG"
471 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
473 retries_counter=$(( $retries_counter + 1 ))
474 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
476 [ -n "$output" ] && echo "$output"
477 if [ "$result" -ne "0" ]; then
478 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
479 echo "Trying again [$SPECFILE]... ($retries_counter)"
483 Exit_error err_no_spec_in_repo;
487 if [ ! -f "$SPECFILE" ]; then
488 Exit_error err_no_spec_in_repo;
491 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
492 chmod $CHMOD_MODE $SPECFILE
495 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
504 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
505 cvs update mirrors >&2
509 while read origin mirror name rest
511 ol=`echo -n "$origin"|wc -c`
512 prefix="`echo -n "$url" | head -c $ol`"
513 if [ "$prefix" = "$origin" ] ; then
514 suffix="`echo "$url"|cut -b $ol-`"
515 echo -n "$mirror$suffix"
526 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
527 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
533 [ X"$NO5" = X"yes" ] && return
535 [ -z "$no" ] && return
537 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
538 if [ -z "$spec_rev" ]; then
539 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
541 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
542 md5=$(grep -s -v '^#' additional-md5sums | \
543 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
544 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
545 grep -E '^[0-9a-f]{32}$')
546 if [ X"$md5" = X"" ] ; then
547 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
548 if [ ! -z "$source_md5" ] ; then
551 # we have empty SourceX-md5, but it is still possible
552 # that we have NoSourceX-md5 AND NoSource: X
553 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
554 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
559 if [ $(echo "$md5" | wc -l) != 1 ] ; then
560 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
562 echo "$md5" | tail -n 1
568 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
571 distfiles_attic_url ()
573 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
580 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
585 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
586 [ -n "$size" -a "$size" -gt 0 ]
591 if [ "$CVSIGNORE_DF" != "yes" ]; then
594 cvsignore=${SOURCE_DIR}/.cvsignore
595 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
596 echo "$1" >> $cvsignore
604 if [ -n "$DEBUG" ]; then
609 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
613 if [ -n "$CVSROOT" ]; then
614 OPTIONS="-d $CVSROOT $OPTIONS"
616 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
617 echo "warning: No cvs access defined for SOURCES"
621 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
622 OPTIONS="$OPTIONS -A"
624 if [ -n "$CVSDATE" ]; then
625 OPTIONS="$OPTIONS -D $CVSDATE"
627 if [ -n "$CVSTAG" ]; then
628 OPTIONS="$OPTIONS -r $CVSTAG"
633 if [ -n "$UPDATE5" ]; then
634 if [ -n "$ADD5" ]; then
635 [ `nourl $i` = "$i" ] && continue
636 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
638 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
642 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
643 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
644 echo "Warning: no URL given for $i"
647 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
648 if good_md5 "$i" && good_size "$i"; then
649 echo "$(nourl "$i") having proper md5sum already exists"
653 url=$(distfiles_url "$i")
654 url_attic=$(distfiles_attic_url "$i")
656 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
657 ${GETLOCAL} $url $target
659 if [ -z "$NOMIRRORS" ]; then
660 url="`find_mirror "$url"`"
662 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
663 if [ "`echo $url | grep -E 'ftp://'`" ]; then
664 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
667 if ! test -s "$target"; then
669 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
670 ${GETLOCAL} $url_attic $target
672 if [ -z "$NOMIRRORS" ]; then
673 url_attic="`find_mirror "$url_attic"`"
675 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
676 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
677 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
681 if test -s "$target"; then
687 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
688 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
691 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
693 retries_counter=$(( $retries_counter + 1 ))
694 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
696 [ -n "$output" ] && echo "$output"
697 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
698 echo "Trying again [`nourl $i`]... ($retries_counter)"
707 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
708 if [ -z "$NOMIRRORS" ]; then
709 im="`find_mirror "$i"`"
714 if [ "`echo $im | grep -E 'ftp://'`" ]; then
721 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
722 Exit_error err_no_source_in_repo $i;
723 elif [ -n "$UPDATE5" ] && \
724 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
725 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
726 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
728 echo "Updating source-$srcno md5."
729 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
731 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
732 print "# Source'$srcno'-md5:\t'$md5'\n"
733 if /^Source'$srcno'\s*:\s+/;
738 if good_md5 "$i" && good_size "$i"; then
740 elif [ "$FROM_DISTFILES" = 1 ]; then
741 # wrong md5 from distfiles: remove the file and try again
743 echo "MD5 sum mismatch. Trying full fetch."
746 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
747 if [ "`echo $url | grep -E 'ftp://'`" ]; then
748 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
750 if ! test -s "$target"; then
752 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
753 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
754 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
757 test -s "$target" || rm -f "$target"
760 if good_md5 "$i" && good_size "$i" ; then
763 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
764 echo "or -5 to update md5 sums, if you're sure files are correct."
765 Exit_error err_no_source_in_repo $i
769 if [ "$CHMOD" = "yes" ]; then
770 CHMOD_FILES="`nourl $GET_FILES`"
771 if [ -n "$CHMOD_FILES" ]; then
772 chmod $CHMOD_MODE $CHMOD_FILES
781 if [ -n "$DEBUG" ]; then
786 # Check whether first character of PACKAGE_NAME is legal for tag name
787 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
790 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"`
791 # Remove #kernel.version_release from TAGVER because tagging sources
792 # could occur with different kernel-headers than kernel-headers used at build time.
793 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
801 if [ -n "$DEBUG" ]; then
806 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
807 echo "Version: $PACKAGE_VERSION"
808 echo "Release: $PACKAGE_RELEASE"
812 if [ "$TAG_VERSION" = "yes" ]; then
813 echo "CVS tag: $TAGVER"
815 if [ -n "$TAG" ]; then
820 if [ -n "$CVSROOT" ]; then
821 OPTIONS="-d $CVSROOT $OPTIONS"
827 # don't tag files stored on distfiles
828 [ -n "`src_md5 $i`" ] && continue
829 if [ -f "`nourl $i`" ]; then
830 if [ "$TAG_VERSION" = "yes" ]; then
831 cvs $OPTIONS $TAGVER `nourl $i`
833 if [ -n "$TAG" ]; then
834 cvs $OPTIONS $TAG `nourl $i`
837 Exit_error err_no_source_in_repo $i
842 if [ "$TAG_VERSION" = "yes" ]; then
843 cvs $OPTIONS $TAGVER $SPECFILE
845 if [ -n "$TAG" ]; then
846 cvs $OPTIONS $TAG $SPECFILE
856 echo "CVS branch tag: $TAG"
861 if [ -n "$DEBUG" ]; then
866 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
869 if [ -n "$CVSROOT" ]; then
870 OPTIONS="-d $CVSROOT $OPTIONS"
875 if [ -f `nourl $i` ]; then
876 cvs $OPTIONS $TAG `nourl $i`
878 Exit_error err_no_source_in_repo $i
882 cvs $OPTIONS $TAG $SPECFILE
892 if [ -n "$DEBUG" ]; then
899 if [ -n "$TRY_UPGRADE" ]; then
900 if [ -n "$FLOAT_VERSION" ]; then
901 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
903 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
906 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
908 if [ -n "$TNEWVER" ]; then
909 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
910 echo "New version found, updating spec file to version " $TNEWVER
911 cp -f $SPECFILE $SPECFILE.bak
913 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
914 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
916 if [ -n "$ICONS" ]; then
920 NODIST="yes" UPDATE5="yes" get_files "$SOURCES $PATCHES";
921 unset TOLDVER TNEWVER TNOTIFY
928 BUILD_SWITCH="-ba" ;;
930 BUILD_SWITCH="-bb" ;;
932 BUILD_SWITCH="-bs --nodeps" ;;
934 BUILD_SWITCH="-bp --nodeps" ;;
936 if [ -n "$LOGFILE" ]; then
937 LOG=`eval echo $LOGFILE`
938 if [ -d "$LOG" ]; then
939 echo "Log file $LOG is a directory."
940 echo "Parse error in the spec?"
941 Exit_error err_build_fail;
943 if [ -n "$LASTLOG_FILE" ]; then
944 echo "LASTLOG=$LOG" > $LASTLOG_FILE
946 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
947 (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
948 RETVAL=`cat $RES_FILE`
950 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
951 if [ "$RETVAL" -eq "0" ]; then
958 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
961 if [ "$RETVAL" -ne "0" ]; then
962 if [ -n "$TRY_UPGRADE" ]; then
963 echo "\n!!! Package with new version cannot be build automagically\n"
964 mv -f $SPECFILE.bak $SPECFILE
966 Exit_error err_build_fail;
973 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
976 install_required_packages()
984 AVAIL_BCONDS_WITHOUT=""
986 if `grep -q ^%bcond ${SPECFILE}`; then
988 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
994 # expand bconds from ~/.bcondrc
995 # The file structure is like gentoo's package.use:
998 # samba -mysql -pgsql
999 # w32codec-installer license_agreement
1002 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
1003 # This takes package name, first defined in spec.
1004 # so consider that when defining flags for package.
1005 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
1006 SN=${SPECFILE%%\.spec}
1007 AVAIL=`$RPMBUILD --bcond $SPECFILE`
1009 BCONDRC=$HOME/.bcondrc
1010 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
1012 while read pkg flags; do
1014 [[ "$pkg" == \#* ]] && continue
1016 # any package or current package?
1017 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ] || [ "$pkg" = "$SN" ]; then
1018 for flag in $flags; do
1021 # use only flags which are in this package.
1022 if [[ $AVAIL = *${opt}* ]]; then
1023 if [[ $flag = -* ]]; then
1024 BCOND="$BCOND --without $opt"
1026 BCOND="$BCOND --with $opt"
1034 case "${BCOND_VERSION}" in
1039 echo "Warning: This spec has old style bconds. Fix it || die."
1040 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1042 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1043 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1044 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1046 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1050 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1052 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1053 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1054 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1056 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1061 cond_type="" # with || without
1062 for opt in `$RPMBUILD --bcond $SPECFILE`
1072 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1073 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1074 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1076 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1080 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1081 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1082 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1084 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1088 case "$cond_type" in
1091 AVAIL_BCOND_WITH="$opt"
1092 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1093 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1095 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1100 AVAIL_BCOND_WITHOUT="$opt"
1101 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1102 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1104 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1118 echo -ne "Package installation failed:\t$package_name\n"
1120 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1121 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1122 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1123 # jakby nie bylo tego kawalka kodu.
1125 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1126 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1133 # Istnieje taki spec? ${package}.spec
1134 if [ -f "${SPECS_DIR}${package}.spec" ]; then
1135 parent_spec_name=${package}.spec
1136 elif [ -f "${SPECS_DIR}`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1137 parent_spec_name="`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1139 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1145 if [ "${parent_spec_name}" != "" ]; then
1147 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1148 sub_builder_opts="${sub_builder_opts} -R"
1150 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1151 sub_builder_opts="${sub_builder_opts} -RB"
1152 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1153 sub_builder_opts="${sub_builder_opts} -FRB"
1155 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1156 sub_builder_opts="${sub_builder_opts} -Upi"
1159 ./builder ${sub_builder_opts} ${parent_spec_name}
1161 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1164 remove_build_requires()
1166 if [ "$INSTALLED_PACKAGES" != "" ]; then
1167 case "$REMOVE_BUILD_REQUIRES" in
1169 run_poldek --noask -ve $INSTALLED_PACKAGES
1172 run_poldek --ask -ve $INSTALLED_PACKAGES
1175 echo You may want to manually remove following BuildRequires fetched:
1176 echo $INSTALLED_PACKAGES
1177 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1185 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1186 if [ "$BCOND" != "" ]; then
1187 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1190 echo -ne "\nNo conditional flags passed"
1192 echo -ne "\n\nfrom available:\n"
1193 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1197 # checks a given list of packages/files/provides agains current rpmdb.
1198 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1199 # input can be either STDIN or parameters
1204 if [ "$#" -gt 0 ]; then
1210 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1213 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1215 # other deps (files)
1216 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1219 # checks if given package/files/provides exists in rpmdb.
1220 # inout can be either stdin or parameters
1221 # returns packages wchi hare present in the rpmdb
1226 if [ "$#" -gt 0 ]; then
1232 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1235 fetch_build_requires()
1237 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1238 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1239 CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1240 DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1242 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1243 $SU_SUDO /usr/bin/poldek --update || $SU_SUDO /usr/bin/poldek --upa
1245 if [ -n "$CONF" ]; then
1246 echo "Trying to uninstall conflicting packages ($CONF):"
1247 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1249 if [ -n "$DEPS" ]; then
1250 echo "Trying to install dependencies ($DEPS):"
1251 $SU_SUDO /usr/bin/poldek --caplookup -uGv $DEPS
1256 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1257 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1258 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1259 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1260 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1261 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`
1263 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`"
1265 package=`basename "$package_item"|sed -e "s/}$//g"`
1266 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1269 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1270 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1271 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
1276 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1279 if `echo $COND_TST|grep -q 'without_'`; then
1280 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1281 if `echo $COND_TST|grep -q !`; then
1286 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1287 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1288 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1294 elif `echo $COND_TST|grep -q 'with_'`; then
1295 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1296 if `echo $COND_TST|grep -q !`; then
1301 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1302 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1303 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1309 RESULT="${COND_STATE}-${COND_ARGV}"
1311 "with-wout" | "wout-with" )
1314 "wout-wout" | "with-with" )
1318 echo "Action '$RESULT' was not defined for package '$package_item'"
1324 if [ "$GO" = "yes" ]; then
1325 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1326 echo "Testing if $package has subrequirements..."
1327 run_poldek -t -i $package --dumpn=".$package-req.txt"
1328 if [ -f ".$package-req.txt" ]; then
1329 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1331 if [ "$package_name" = "$package" ]; then
1332 echo -ne "Installing BuildRequired package:\t$package_name\n"
1333 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1334 install_required_packages $package;
1336 echo -ne "Installing (sub)Required package:\t$package_name\n"
1337 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1338 install_required_packages $package_name;
1342 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1343 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1346 echo "Attempting to run spawn sub - builder..."
1347 run_sub_builder $package_name
1348 if [ $? -eq 0 ]; then
1349 install_required_packages $package_name;
1352 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1353 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1356 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1363 rm -f ".$package-req.txt"
1365 echo "Attempting to run spawn sub - builder..."
1366 run_sub_builder $package
1367 if [ $? -eq 0 ]; then
1368 install_required_packages $package;
1371 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1372 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1375 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1381 echo "Package $package is already installed. BuildRequirement satisfied."
1385 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1386 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1387 echo "Unable to install following packages and their dependencies:"
1388 for pkg in "$NOT_INSTALLED_PACKAGES"
1392 remove_build_requires
1400 # vim like diff colourization, glen@pld-linux.org
1402 s,
\e,
\e[44m^[
\e[49m,g;
1403 s,
\a,
\e[44m^G
\e[49m,g;
1404 s,^\(Index:\|diff\|---\|+++\) .*$,
\e[32m&,;
1408 s,
\r,
\e[44m^M
\e[49m,g;
1410 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1
\e[41m\2
\e[49m,g;
1419 tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/adapter-XXXXXX) || exit
1420 awk -f adapter.awk $SPECFILE > $tmpdir/$SPECFILE || exit
1422 if [ "`diff --brief $SPECFILE $tmpdir/$SPECFILE`" ] ; then
1423 diff -u $SPECFILE $tmpdir/$SPECFILE > $tmpdir/$SPECFILE.diff
1425 diffcol $tmpdir/$SPECFILE.diff | less -r
1427 echo -n "Accept? [yn] "
1431 mv -f $tmpdir/$SPECFILE $SPECFILE
1432 echo "Ok, adapterized."
1442 cat $tmpdir/$SPECFILE.diff
1445 echo "The SPEC is perfect ;)"
1451 #---------------------------------------------
1454 if [ "$#" = 0 ]; then
1468 --adapter | --adapterize )
1469 COMMAND="adapterize";
1486 DEBUG="yes"; shift ;;
1488 COMMAND="version"; shift ;;
1490 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1491 -b | -ba | --build )
1492 COMMAND="build"; shift ;;
1493 -bb | --build-binary )
1494 COMMAND="build-binary"; shift ;;
1495 -bs | --build-source )
1496 COMMAND="build-source"; shift ;;
1497 -bp | --build-prep )
1498 COMMAND="build-prep"; shift ;;
1500 COMMAND="branch"; shift; TAG="${1}"; shift;;
1502 CLEAN="--clean --rmspec --rmsource"; shift ;;
1504 shift; CVSROOT="${1}"; shift ;;
1506 COMMAND="get"; shift ;;
1508 COMMAND="usage"; shift ;;
1510 PROTOCOL="http"; shift ;;
1512 shift; LOGFILE="${1}"; shift ;;
1514 shift; DEF_NICE_LEVEL=${1}; shift ;;
1516 COMMAND="mr-proper"; shift ;;
1518 NOCVS="yes"; shift ;;
1519 -ncs | --no-cvs-specs )
1520 NOCVSSPEC="yes"; shift ;;
1521 -nd | --no-distfiles )
1522 NODIST="yes"; shift ;;
1523 -nm | --no-mirrors )
1524 NOMIRRORS="yes"; shift ;;
1526 NOURLS="yes"; shift ;;
1528 NOSRCS="yes"; shift ;;
1529 -ns0 | --no-source0 )
1530 NOSOURCE0="yes"; shift ;;
1540 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1542 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} echo ignoring patch${1} \""; shift ;;
1543 --with | --without )
1544 case $GROUP_BCONDS in
1548 while ! `echo ${1}|grep -qE '(^-|spec)'`
1550 BCOND="$BCOND $COND $1"
1554 if [[ "$2" = *,* ]]; then
1555 for a in $(echo "$2" | tr , ' '); do
1556 BCOND="$BCOND $1 $a"
1559 BCOND="$BCOND $1 $2"
1565 shift; TARGET="${1}"; shift ;;
1567 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1569 QUIET="--quiet"; shift ;;
1571 CVSDATE="${2}"; shift 2 ;;
1573 shift; CVSTAG="${1}"; shift ;;
1574 -R | --fetch-build-requires)
1575 FETCH_BUILD_REQUIRES="yes"
1576 NOT_INSTALLED_PACKAGES=
1578 -RB | --remove-build-requires)
1579 REMOVE_BUILD_REQUIRES="nice"
1581 -FRB | --force-remove-build-requires)
1582 REMOVE_BUILD_REQUIRES="force"
1584 -sf | --sources-files)
1585 COMMAND="list-sources-files"
1587 -sp | --sources-paths)
1588 COMMAND="list-sources-local-paths"
1590 -Tvs | --tag-version-stable )
1595 -Tvn | --tag-version-nest )
1600 -Ts | --tag-stable )
1610 -Tv | --tag-version )
1615 -Tp | --tag-prefix )
1627 -ir | --integer-release-only )
1628 INTEGER_RELEASE="yes"
1637 -Upi | --update-poldek-indexes )
1638 UPDATE_POLDEK_INDEXES="yes"
1640 -u | --try-upgrade )
1641 TRY_UPGRADE="1"; shift ;;
1642 -un | --try-upgrade-with-float-version )
1643 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1645 BE_VERBOSE="1"; shift ;;
1651 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1655 RPMOPTS="${RPMOPTS} --nodeps"
1658 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1661 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1666 if [ -n "$DEBUG" ]; then
1671 if [ -n "$TARGET" ]; then
1674 TARGET_SWITCH="--target $TARGET" ;;
1676 TARGET_SWITCH="--target=$TARGET" ;;
1681 "build" | "build-binary" | "build-source" | "build-prep" )
1683 if [ -n "$SPECFILE" ]; then
1687 fetch_build_requires;
1689 if [ "$INTEGER_RELEASE" = "yes" ]; then
1690 echo "Checking release $PACKAGE_RELEASE..."
1691 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1692 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1696 if [ -n "$TEST_TAG" ]; then
1697 TAGVER=`make_tagver`
1698 echo "Searching for tag $TAGVER..."
1699 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1700 if [ -n "$TAGREL" ]; then
1701 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1704 # - do not allow to build from HEAD when XX-branch exists
1705 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1706 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1707 TAG_BRANCH="${TREE_PREFIX}-branch"
1708 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1709 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1710 Exit_error err_branch_exists "$TAG_STATUS"
1716 if [ -n "$ICONS" ]; then
1720 if [ -n "$NOSOURCE0" ] ; then
1721 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1723 get_files "$SOURCES $PATCHES";
1725 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1726 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1728 remove_build_requires;
1730 Exit_error err_no_spec_in_cmdl;
1735 if [ -n "$SPECFILE" ]; then
1738 if [ -n "$ICONS" ]; then
1742 get_files $SOURCES $PATCHES;
1743 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1745 Exit_error err_no_spec_in_cmdl;
1750 if [ -n "$SPECFILE" ]; then
1753 if [ -n "$ICONS" ]; then
1754 OLD_UPDATE5=$UPDATE5
1755 UPDATE5= get_files $ICONS
1756 UPDATE5=$OLD_UPDATE5
1759 if [ -n "$NOSOURCE0" ] ; then
1760 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1762 get_files $SOURCES $PATCHES
1764 Exit_error err_no_spec_in_cmdl;
1771 if [ -n "$SPECFILE" ]; then
1774 if [ -n "$ICONS" ]; then
1778 # don't fetch sources from remote locations
1780 for file in $SOURCES
1782 [ -n "`src_md5 $file`" ] && continue
1783 new_SOURCES="$new_SOURCES $file"
1785 SOURCES="$new_SOURCES"
1786 get_files $SOURCES $PATCHES;
1787 tag_files "$SOURCES $PATCHES $ICONS";
1789 Exit_error err_no_spec_in_cmdl;
1793 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1795 "list-sources-files" )
1798 DONT_PRINT_REVISION="yes"
1801 SAPS="$SOURCES $PATCHES"
1802 for SAP in $SAPS ; do
1803 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1806 "list-sources-local-paths" )
1809 DONT_PRINT_REVISION="yes"
1812 SAPS="$SOURCES $PATCHES"
1813 for SAP in $SAPS ; do
1814 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1825 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1826 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1830 # vi:syntax=sh:ts=3:sw=4