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 Linux 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>] [--show-bconds]
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 <patchnumber>
276 --show-bconds - show available conditional builds, which can be used
277 - with --with and/or --without switches.
278 --with/--without <feature>
279 - conditional build package depending on %_with_<feature>/
280 %_without_<feature> macro switch. You may now use
281 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
282 constructions. Set GROUP_BCONDS to yes to make use of it.
283 --target <platform>, --target=<platform>
284 - build for platform <platform>.
288 # set TARGET from BuildArch: from SPECFILE
290 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
291 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
296 TARGET_SWITCH="--target $TARGET" ;;
298 TARGET_SWITCH="--target=$TARGET" ;;
305 if [ -n "$DEBUG" ]; then
313 rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
316 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
322 if [ -z "$rpm_dump_cache" ] ; then
323 echo "internal error: cache_rpm_dump not called!" 1>&2
325 echo "$rpm_dump_cache"
330 if [ -n "$DEBUG" ]; then
339 if [ "$NOSRCS" != "yes" ]; then
340 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
342 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
343 FAIL_IF_NO_SOURCES="no"
346 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
347 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
348 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
349 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
350 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
352 # These variables may be unset after first cache_rpm_dump call
353 # (because of not-yet-retrieved icon file)
355 # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
356 # Exit_error err_no_package_data;
359 if [ -n "$BE_VERBOSE" ]; then
360 echo "- Sources : `nourl $SOURCES`"
361 if [ -n "$PATCHES" ]; then
362 echo "- Patches : `nourl $PATCHES`"
364 echo "- Patches : *no patches needed*"
366 if [ -n "$ICONS" ]; then
367 echo "- Icon : `nourl $ICONS`"
369 echo "- Icon : *no package icon*"
371 echo "- Name : $PACKAGE_NAME"
372 echo "- Version : $PACKAGE_VERSION"
373 echo "- Release : $PACKAGE_RELEASE"
379 if [ -n "$DEBUG" ]; then
387 "err_no_spec_in_cmdl" )
388 remove_build_requires
389 echo "ERROR: spec file name not specified.";
391 "err_no_spec_in_repo" )
392 remove_build_requires
393 echo "Error: spec file not stored in CVS repo.";
395 "err_no_source_in_repo" )
396 remove_build_requires
397 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
400 remove_build_requires
401 echo "Error: package build failed. (${2:-no more info})";
403 "err_no_package_data" )
404 remove_build_requires
405 echo "Error: couldn't get out package name/version/release from spec file."
408 remove_build_requires
409 echo "Tag ${2} already exists (spec release: ${3}).";
412 remove_build_requires
413 echo "Release ${2} not integer and not a snapshot.";
415 "err_branch_exists" )
416 remove_build_requires
417 echo "Tree branch already exists (${2}).";
421 echo "Unknown error."
427 if [ -n "$DEBUG" ]; then
432 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
433 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
440 if [ -n "$DEBUG" ]; then
446 if [ \! -f "$SPECFILE" ]; then
447 SPECFILE="`basename $SPECFILE .spec`.spec";
449 if [ "$NOCVSSPEC" != "yes" ]; then
452 if [ -n "$CVSROOT" ]; then
453 OPTIONS="-d $CVSROOT $OPTIONS"
455 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
456 echo "warning: No cvs access defined - using local .spec file"
461 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
462 OPTIONS="$OPTIONS -A"
464 if [ -n "$CVSDATE" ]; then
465 OPTIONS="$OPTIONS -D $CVSDATE"
467 if [ -n "$CVSTAG" ]; then
468 OPTIONS="$OPTIONS -r $CVSTAG"
474 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
476 retries_counter=$(( $retries_counter + 1 ))
477 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
479 [ -n "$output" ] && echo "$output"
480 if [ "$result" -ne "0" ]; then
481 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
482 echo "Trying again [$SPECFILE]... ($retries_counter)"
486 Exit_error err_no_spec_in_repo;
490 if [ ! -f "$SPECFILE" ]; then
491 Exit_error err_no_spec_in_repo;
494 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
495 chmod $CHMOD_MODE $SPECFILE
498 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
507 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
508 cvs update mirrors >&2
512 while read origin mirror name rest
514 ol=`echo -n "$origin"|wc -c`
515 prefix="`echo -n "$url" | head -c $ol`"
516 if [ "$prefix" = "$origin" ] ; then
517 suffix="`echo "$url"|cut -b $ol-`"
518 echo -n "$mirror$suffix"
529 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
530 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
536 [ X"$NO5" = X"yes" ] && return
538 [ -z "$no" ] && return
540 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
541 if [ -z "$spec_rev" ]; then
542 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
544 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
545 md5=$(grep -s -v '^#' additional-md5sums | \
546 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
547 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
548 grep -E '^[0-9a-f]{32}$')
549 if [ X"$md5" = X"" ] ; then
550 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
551 if [ ! -z "$source_md5" ] ; then
554 # we have empty SourceX-md5, but it is still possible
555 # that we have NoSourceX-md5 AND NoSource: X
556 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
557 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
562 if [ $(echo "$md5" | wc -l) != 1 ] ; then
563 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
565 echo "$md5" | tail -n 1
571 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
574 distfiles_attic_url ()
576 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
583 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
588 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
589 [ -n "$size" -a "$size" -gt 0 ]
594 if [ "$CVSIGNORE_DF" != "yes" ]; then
597 cvsignore=${SOURCE_DIR}/.cvsignore
598 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
599 echo "$1" >> $cvsignore
607 if [ -n "$DEBUG" ]; then
612 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
616 if [ -n "$CVSROOT" ]; then
617 OPTIONS="-d $CVSROOT $OPTIONS"
619 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
620 echo "warning: No cvs access defined for SOURCES"
624 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
625 OPTIONS="$OPTIONS -A"
627 if [ -n "$CVSDATE" ]; then
628 OPTIONS="$OPTIONS -D $CVSDATE"
630 if [ -n "$CVSTAG" ]; then
631 OPTIONS="$OPTIONS -r $CVSTAG"
636 if [ -n "$UPDATE5" ]; then
637 if [ -n "$ADD5" ]; then
638 [ `nourl $i` = "$i" ] && continue
639 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
641 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
645 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
646 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
647 echo "Warning: no URL given for $i"
650 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
651 if good_md5 "$i" && good_size "$i"; then
652 echo "$(nourl "$i") having proper md5sum already exists"
656 url=$(distfiles_url "$i")
657 url_attic=$(distfiles_attic_url "$i")
659 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
660 ${GETLOCAL} $url $target
662 if [ -z "$NOMIRRORS" ]; then
663 url="`find_mirror "$url"`"
665 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
666 if [ "`echo $url | grep -E 'ftp://'`" ]; then
667 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
670 if ! test -s "$target"; then
672 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
673 ${GETLOCAL} $url_attic $target
675 if [ -z "$NOMIRRORS" ]; then
676 url_attic="`find_mirror "$url_attic"`"
678 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
679 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
680 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
684 if test -s "$target"; then
690 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
691 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
694 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
696 retries_counter=$(( $retries_counter + 1 ))
697 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
699 [ -n "$output" ] && echo "$output"
700 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
701 echo "Trying again [`nourl $i`]... ($retries_counter)"
710 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
711 if [ -z "$NOMIRRORS" ]; then
712 im="`find_mirror "$i"`"
717 if [ "`echo $im | grep -E 'ftp://'`" ]; then
724 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
725 Exit_error err_no_source_in_repo $i;
726 elif [ -n "$UPDATE5" ] && \
727 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
728 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
729 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
731 echo "Updating source-$srcno md5."
732 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
734 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
735 print "# Source'$srcno'-md5:\t'$md5'\n"
736 if /^Source'$srcno'\s*:\s+/;
741 if good_md5 "$i" && good_size "$i"; then
743 elif [ "$FROM_DISTFILES" = 1 ]; then
744 # wrong md5 from distfiles: remove the file and try again
746 echo "MD5 sum mismatch. Trying full fetch."
749 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
750 if [ "`echo $url | grep -E 'ftp://'`" ]; then
751 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
753 if ! test -s "$target"; then
755 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
756 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
757 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
760 test -s "$target" || rm -f "$target"
763 if good_md5 "$i" && good_size "$i" ; then
766 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
767 echo "or -5 to update md5 sums, if you're sure files are correct."
768 Exit_error err_no_source_in_repo $i
772 if [ "$CHMOD" = "yes" ]; then
773 CHMOD_FILES="`nourl $GET_FILES`"
774 if [ -n "$CHMOD_FILES" ]; then
775 chmod $CHMOD_MODE $CHMOD_FILES
784 if [ -n "$DEBUG" ]; then
789 # Check whether first character of PACKAGE_NAME is legal for tag name
790 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
793 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"`
794 # Remove #kernel.version_release from TAGVER because tagging sources
795 # could occur with different kernel-headers than kernel-headers used at build time.
796 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
804 if [ -n "$DEBUG" ]; then
809 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
810 echo "Version: $PACKAGE_VERSION"
811 echo "Release: $PACKAGE_RELEASE"
815 if [ "$TAG_VERSION" = "yes" ]; then
816 echo "CVS tag: $TAGVER"
818 if [ -n "$TAG" ]; then
823 if [ -n "$CVSROOT" ]; then
824 OPTIONS="-d $CVSROOT $OPTIONS"
830 # don't tag files stored on distfiles
831 [ -n "`src_md5 $i`" ] && continue
832 if [ -f "`nourl $i`" ]; then
833 if [ "$TAG_VERSION" = "yes" ]; then
834 cvs $OPTIONS $TAGVER `nourl $i`
836 if [ -n "$TAG" ]; then
837 cvs $OPTIONS $TAG `nourl $i`
840 Exit_error err_no_source_in_repo $i
845 if [ "$TAG_VERSION" = "yes" ]; then
846 cvs $OPTIONS $TAGVER $SPECFILE
848 if [ -n "$TAG" ]; then
849 cvs $OPTIONS $TAG $SPECFILE
859 echo "CVS branch tag: $TAG"
864 if [ -n "$DEBUG" ]; then
869 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
872 if [ -n "$CVSROOT" ]; then
873 OPTIONS="-d $CVSROOT $OPTIONS"
878 if [ -f `nourl $i` ]; then
879 cvs $OPTIONS $TAG `nourl $i`
881 Exit_error err_no_source_in_repo $i
885 cvs $OPTIONS $TAG $SPECFILE
895 if [ -n "$DEBUG" ]; then
902 if [ -n "$TRY_UPGRADE" ]; then
903 if [ -n "$FLOAT_VERSION" ]; then
904 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
906 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
909 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
911 if [ -n "$TNEWVER" ]; then
912 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
913 echo "New version found, updating spec file to version " $TNEWVER
914 cp -f $SPECFILE $SPECFILE.bak
916 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
917 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
919 if [ -n "$ICONS" ]; then
923 NODIST="yes" UPDATE5="yes" get_files "$SOURCES $PATCHES";
924 unset TOLDVER TNEWVER TNOTIFY
931 BUILD_SWITCH="-ba" ;;
933 BUILD_SWITCH="-bb" ;;
935 BUILD_SWITCH="-bs --nodeps" ;;
937 BUILD_SWITCH="-bp --nodeps" ;;
939 if [ -n "$LOGFILE" ]; then
940 LOG=`eval echo $LOGFILE`
941 if [ -d "$LOG" ]; then
942 echo "Log file $LOG is a directory."
943 echo "Parse error in the spec?"
944 Exit_error err_build_fail;
946 if [ -n "$LASTLOG_FILE" ]; then
947 echo "LASTLOG=$LOG" > $LASTLOG_FILE
949 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
950 (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
951 RETVAL=`cat $RES_FILE`
953 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
954 if [ "$RETVAL" -eq "0" ]; then
961 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
964 if [ "$RETVAL" -ne "0" ]; then
965 if [ -n "$TRY_UPGRADE" ]; then
966 echo "\n!!! Package with new version cannot be build automagically\n"
967 mv -f $SPECFILE.bak $SPECFILE
969 Exit_error err_build_fail;
976 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
979 install_required_packages()
987 AVAIL_BCONDS_WITHOUT=""
989 if `grep -q ^%bcond ${SPECFILE}`; then
991 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
997 # expand bconds from ~/.bcondrc
998 # The file structure is like gentoo's package.use:
1001 # samba -mysql -pgsql
1002 # w32codec-installer license_agreement
1005 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
1006 # This takes package name, first defined in spec.
1007 # so consider that when defining flags for package.
1008 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
1009 SN=${SPECFILE%%\.spec}
1010 AVAIL=`$RPMBUILD --bcond $SPECFILE`
1012 BCONDRC=$HOME/.bcondrc
1013 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
1015 while read pkg flags; do
1017 [[ "$pkg" == \#* ]] && continue
1019 # any package or current package?
1020 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ] || [ "$pkg" = "$SN" ]; then
1021 for flag in $flags; do
1024 # use only flags which are in this package.
1025 if [[ $AVAIL = *${opt}* ]]; then
1026 if [[ $flag = -* ]]; then
1027 BCOND="$BCOND --without $opt"
1029 BCOND="$BCOND --with $opt"
1037 case "${BCOND_VERSION}" in
1042 echo "Warning: This spec has old style bconds. Fix it || die."
1043 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1045 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1046 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1047 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1049 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1053 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1055 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1056 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1057 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1059 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1064 cond_type="" # with || without
1065 for opt in `$RPMBUILD --bcond $SPECFILE`
1075 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1076 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1077 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1079 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1083 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1084 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1085 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1087 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1091 case "$cond_type" in
1094 AVAIL_BCOND_WITH="$opt"
1095 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1096 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1098 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1103 AVAIL_BCOND_WITHOUT="$opt"
1104 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1105 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1107 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1121 echo -ne "Package installation failed:\t$package_name\n"
1123 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1124 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1125 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1126 # jakby nie bylo tego kawalka kodu.
1128 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1129 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1136 # Istnieje taki spec? ${package}.spec
1137 if [ -f "${SPECS_DIR}${package}.spec" ]; then
1138 parent_spec_name=${package}.spec
1139 elif [ -f "${SPECS_DIR}`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1140 parent_spec_name="`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1142 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1148 if [ "${parent_spec_name}" != "" ]; then
1150 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1151 sub_builder_opts="${sub_builder_opts} -R"
1153 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1154 sub_builder_opts="${sub_builder_opts} -RB"
1155 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1156 sub_builder_opts="${sub_builder_opts} -FRB"
1158 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1159 sub_builder_opts="${sub_builder_opts} -Upi"
1162 ./builder ${sub_builder_opts} ${parent_spec_name}
1164 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1167 remove_build_requires()
1169 if [ "$INSTALLED_PACKAGES" != "" ]; then
1170 case "$REMOVE_BUILD_REQUIRES" in
1172 run_poldek --noask -ve $INSTALLED_PACKAGES
1175 run_poldek --ask -ve $INSTALLED_PACKAGES
1178 echo You may want to manually remove following BuildRequires fetched:
1179 echo $INSTALLED_PACKAGES
1180 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1188 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1189 if [ "$BCOND" != "" ]; then
1190 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1193 echo -ne "\nNo conditional flags passed"
1195 echo -ne "\n\nfrom available:\n"
1196 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1202 if [ "$NOCVSSPEC" != "yes" ]; then
1203 echo -ne "Available branches: "
1204 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1208 # checks a given list of packages/files/provides agains current rpmdb.
1209 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1210 # input can be either STDIN or parameters
1215 if [ "$#" -gt 0 ]; then
1221 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1224 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1226 # other deps (files)
1227 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1230 # checks if given package/files/provides exists in rpmdb.
1231 # inout can be either stdin or parameters
1232 # returns packages wchi hare present in the rpmdb
1237 if [ "$#" -gt 0 ]; then
1243 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1246 fetch_build_requires()
1248 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1249 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1250 CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1251 DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1253 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1254 $SU_SUDO /usr/bin/poldek --update || $SU_SUDO /usr/bin/poldek --upa
1256 if [ -n "$CONF" ]; then
1257 echo "Trying to uninstall conflicting packages ($CONF):"
1258 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1260 if [ -n "$DEPS" ]; then
1261 echo "Trying to install dependencies ($DEPS):"
1262 $SU_SUDO /usr/bin/poldek --caplookup -uGv $DEPS
1267 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1268 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1269 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1270 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1271 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1272 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`
1274 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`"
1276 package=`basename "$package_item"|sed -e "s/}$//g"`
1277 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1280 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1281 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1282 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
1287 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1290 if `echo $COND_TST|grep -q 'without_'`; then
1291 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1292 if `echo $COND_TST|grep -q !`; then
1297 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1298 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1299 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1305 elif `echo $COND_TST|grep -q 'with_'`; then
1306 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1307 if `echo $COND_TST|grep -q !`; then
1312 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1313 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1314 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1320 RESULT="${COND_STATE}-${COND_ARGV}"
1322 "with-wout" | "wout-with" )
1325 "wout-wout" | "with-with" )
1329 echo "Action '$RESULT' was not defined for package '$package_item'"
1335 if [ "$GO" = "yes" ]; then
1336 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1337 echo "Testing if $package has subrequirements..."
1338 run_poldek -t -i $package --dumpn=".$package-req.txt"
1339 if [ -f ".$package-req.txt" ]; then
1340 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1342 if [ "$package_name" = "$package" ]; then
1343 echo -ne "Installing BuildRequired package:\t$package_name\n"
1344 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1345 install_required_packages $package;
1347 echo -ne "Installing (sub)Required package:\t$package_name\n"
1348 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1349 install_required_packages $package_name;
1353 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1354 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1357 echo "Attempting to run spawn sub - builder..."
1358 run_sub_builder $package_name
1359 if [ $? -eq 0 ]; then
1360 install_required_packages $package_name;
1363 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1364 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1367 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1374 rm -f ".$package-req.txt"
1376 echo "Attempting to run spawn sub - builder..."
1377 run_sub_builder $package
1378 if [ $? -eq 0 ]; then
1379 install_required_packages $package;
1382 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1383 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1386 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1392 echo "Package $package is already installed. BuildRequirement satisfied."
1396 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1397 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1398 echo "Unable to install following packages and their dependencies:"
1399 for pkg in "$NOT_INSTALLED_PACKAGES"
1403 remove_build_requires
1411 # vim like diff colourization, glen@pld-linux.org
1413 s,
\e,
\e[44m^[
\e[49m,g;
1414 s,
\a,
\e[44m^G
\e[49m,g;
1415 s,^\(Index:\|diff\|---\|+++\) .*$,
\e[32m&,;
1419 s,
\r,
\e[44m^M
\e[49m,g;
1421 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1
\e[41m\2
\e[49m,g;
1430 tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/adapter-XXXXXX) || exit
1431 awk -f adapter.awk $SPECFILE > $tmpdir/$SPECFILE || exit
1433 if [ "`diff --brief $SPECFILE $tmpdir/$SPECFILE`" ] ; then
1434 diff -u $SPECFILE $tmpdir/$SPECFILE > $tmpdir/$SPECFILE.diff
1436 diffcol $tmpdir/$SPECFILE.diff | less -r
1438 echo -n "Accept? [yn] "
1442 mv -f $tmpdir/$SPECFILE $SPECFILE
1443 echo "Ok, adapterized."
1453 cat $tmpdir/$SPECFILE.diff
1456 echo "The SPEC is perfect ;)"
1462 #---------------------------------------------
1465 if [ "$#" = 0 ]; then
1479 --adapter | --adapterize )
1480 COMMAND="adapterize";
1497 DEBUG="yes"; shift ;;
1499 COMMAND="version"; shift ;;
1501 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1502 -b | -ba | --build )
1503 COMMAND="build"; shift ;;
1504 -bb | --build-binary )
1505 COMMAND="build-binary"; shift ;;
1506 -bs | --build-source )
1507 COMMAND="build-source"; shift ;;
1508 -bp | --build-prep )
1509 COMMAND="build-prep"; shift ;;
1511 COMMAND="branch"; shift; TAG="${1}"; shift;;
1513 CLEAN="--clean --rmspec --rmsource"; shift ;;
1515 shift; CVSROOT="${1}"; shift ;;
1517 COMMAND="get"; shift ;;
1519 COMMAND="usage"; shift ;;
1521 PROTOCOL="http"; shift ;;
1523 shift; LOGFILE="${1}"; shift ;;
1525 shift; DEF_NICE_LEVEL=${1}; shift ;;
1527 COMMAND="mr-proper"; shift ;;
1529 NOCVS="yes"; shift ;;
1530 -ncs | --no-cvs-specs )
1531 NOCVSSPEC="yes"; shift ;;
1532 -nd | --no-distfiles )
1533 NODIST="yes"; shift ;;
1534 -nm | --no-mirrors )
1535 NOMIRRORS="yes"; shift ;;
1537 NOURLS="yes"; shift ;;
1539 NOSRCS="yes"; shift ;;
1540 -ns0 | --no-source0 )
1541 NOSOURCE0="yes"; shift ;;
1551 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1553 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} echo ignoring patch${1} \""; shift ;;
1554 --with | --without )
1555 case $GROUP_BCONDS in
1559 while ! `echo ${1}|grep -qE '(^-|spec)'`
1561 BCOND="$BCOND $COND $1"
1565 if [[ "$2" = *,* ]]; then
1566 for a in $(echo "$2" | tr , ' '); do
1567 BCOND="$BCOND $1 $a"
1570 BCOND="$BCOND $1 $2"
1576 shift; TARGET="${1}"; shift ;;
1578 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1580 QUIET="--quiet"; shift ;;
1582 CVSDATE="${2}"; shift 2 ;;
1584 shift; CVSTAG="${1}"; shift ;;
1585 -R | --fetch-build-requires)
1586 FETCH_BUILD_REQUIRES="yes"
1587 NOT_INSTALLED_PACKAGES=
1589 -RB | --remove-build-requires)
1590 REMOVE_BUILD_REQUIRES="nice"
1592 -FRB | --force-remove-build-requires)
1593 REMOVE_BUILD_REQUIRES="force"
1595 -sf | --sources-files)
1596 COMMAND="list-sources-files"
1598 -sp | --sources-paths)
1599 COMMAND="list-sources-local-paths"
1601 -Tvs | --tag-version-stable )
1606 -Tvn | --tag-version-nest )
1611 -Ts | --tag-stable )
1621 -Tv | --tag-version )
1626 -Tp | --tag-prefix )
1638 -ir | --integer-release-only )
1639 INTEGER_RELEASE="yes"
1648 -Upi | --update-poldek-indexes )
1649 UPDATE_POLDEK_INDEXES="yes"
1651 -u | --try-upgrade )
1652 TRY_UPGRADE="1"; shift ;;
1653 -un | --try-upgrade-with-float-version )
1654 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1656 BE_VERBOSE="1"; shift ;;
1662 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1664 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1670 RPMOPTS="${RPMOPTS} --nodeps"
1673 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1676 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1681 if [ -n "$DEBUG" ]; then
1686 if [ -n "$TARGET" ]; then
1689 TARGET_SWITCH="--target $TARGET" ;;
1691 TARGET_SWITCH="--target=$TARGET" ;;
1696 "build" | "build-binary" | "build-source" | "build-prep" )
1698 if [ -n "$SPECFILE" ]; then
1702 if [ X"$SHOW_BCONDS" = X"yes" ]; then
1706 fetch_build_requires;
1708 if [ "$INTEGER_RELEASE" = "yes" ]; then
1709 echo "Checking release $PACKAGE_RELEASE..."
1710 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1711 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1715 if [ -n "$TEST_TAG" ]; then
1716 TAGVER=`make_tagver`
1717 echo "Searching for tag $TAGVER..."
1718 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1719 if [ -n "$TAGREL" ]; then
1720 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1723 # - do not allow to build from HEAD when XX-branch exists
1724 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1725 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1726 TAG_BRANCH="${TREE_PREFIX}-branch"
1727 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1728 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1729 Exit_error err_branch_exists "$TAG_STATUS"
1735 if [ -n "$ICONS" ]; then
1739 if [ -n "$NOSOURCE0" ] ; then
1740 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1742 get_files "$SOURCES $PATCHES";
1744 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1745 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1747 remove_build_requires;
1749 Exit_error err_no_spec_in_cmdl;
1754 if [ -n "$SPECFILE" ]; then
1757 if [ -n "$ICONS" ]; then
1761 get_files $SOURCES $PATCHES;
1762 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1764 Exit_error err_no_spec_in_cmdl;
1769 if [ -n "$SPECFILE" ]; then
1772 if [ -n "$ICONS" ]; then
1773 OLD_UPDATE5=$UPDATE5
1774 UPDATE5= get_files $ICONS
1775 UPDATE5=$OLD_UPDATE5
1778 if [ -n "$NOSOURCE0" ] ; then
1779 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1781 get_files $SOURCES $PATCHES
1783 Exit_error err_no_spec_in_cmdl;
1790 if [ -n "$SPECFILE" ]; then
1793 if [ -n "$ICONS" ]; then
1797 # don't fetch sources from remote locations
1799 for file in $SOURCES
1801 [ -n "`src_md5 $file`" ] && continue
1802 new_SOURCES="$new_SOURCES $file"
1804 SOURCES="$new_SOURCES"
1805 get_files $SOURCES $PATCHES;
1806 tag_files "$SOURCES $PATCHES $ICONS";
1808 Exit_error err_no_spec_in_cmdl;
1812 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1814 "list-sources-files" )
1817 DONT_PRINT_REVISION="yes"
1820 SAPS="$SOURCES $PATCHES"
1821 for SAP in $SAPS ; do
1822 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1825 "list-sources-local-paths" )
1828 DONT_PRINT_REVISION="yes"
1831 SAPS="$SOURCES $PATCHES"
1832 for SAP in $SAPS ; do
1833 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1844 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1845 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1849 # vi:syntax=sh:ts=3:sw=4