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"
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>] [--show-bconds]
187 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
189 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
190 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
191 -n5, --no-md5 - ignore md5 comments in spec
192 -D, --debug - enable builder script debugging mode,
193 -debug - produce rpm debug package (same as --opts -debug)
194 -V, --version - output builder version
195 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
196 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
198 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
199 only package from <package>.spec,
200 -bp, --build-prep - execute the %prep phase of <package>.spec,
201 -bc - reserved (not implemented)
202 -bi reserved (not implemented)
203 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
205 --short-circuit - reserved (not implemented)
206 -B, --branch - add branch
207 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
208 SPECS and \$RPM_BUILD_ROOT),
209 -d <cvsroot>, --cvsroot <cvsroot>
211 --define <macro> <value>
212 - define a macro <macro> with value <value>,
213 --nodeps - rpm won't check any dependences
214 -g, --get - get <package>.spec and all related files from CVS repo
216 -h, --help - this message,
217 --http - use http instead of ftp,
218 -l <logfile>, --logtofile <logfile>
220 -m, --mr-proper - only remove all files related to spec file and all work
222 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
224 - don't check specs in CVS
225 -nd, --no-distfiles - don't download from distfiles
226 -nm, --no-mirrors - don't download from mirror, if source URL is given,
227 -nu, --no-urls - don't try to download from FTP/HTTP location,
228 -ns, --no-srcs - don't download Sources
229 -ns0, --no-source0 - don't download Source0
230 -nn, --no-net - don't download anything from the net
231 --opts <rpm opts> - additional options for rpm
232 -q, --quiet - be quiet,
233 --date yyyy-mm-dd - build package using resources from specified CVS date,
234 -r <cvstag>, --cvstag <cvstag>
235 - build package using resources from specified CVS tag,
236 -R, --fetch-build-requires
237 - fetch what is BuildRequired,
238 -RB, --remove-build-requires
239 - remove all you fetched with -R or --fetch-build-requires
240 remember, this option requires confirmation,
241 -FRB, --force-remove-build-requires
242 - remove all you fetched with -R or --fetch-build-requires
243 remember, this option works without confirmation,
244 -sf, --source-files - list sources - bare filenames (intended for offline
245 operations; does not work when Icon field is present
246 but icon file is absent),
247 -sp, --source-paths - list sources - filenames with full local paths (intended for
248 offline operations; does not work when Icon field is present
249 but icon file is absent),
250 -T <cvstag> , --tag <cvstag>
251 - add cvs tag <cvstag> for files,
252 -Tvs, --tag-version-stable
253 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
254 -Tvn, --tag-version-nest
255 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
257 - add cvs tag STABLE for files,
259 - add cvs tag NEST for files,
261 - add cvs tag NAME-VERSION-RELEASE for files,
262 -Tp, --tag-prefix <prefix>
263 - add <prefix> to NAME-VERSION-RELEASE tags,
264 -tt, --test-tag <prefix>
265 - fail if tag is already present,
266 -ir, --integer-release-only
267 - allow only integer and snapshot releases
268 -v, --verbose - be verbose,
269 -u, --try-upgrade - check version, and try to upgrade package
270 -un, --try-upgrade-with-float-version
271 - as above, but allow float version
272 -U, --update - refetch sources, don't use distfiles, and update md5 comments
273 -Upi, --update-poldek-indexes
274 - refresh or make poldek package index files.
275 -np, --nopatch <patchnumber>
276 - don't apply <patchnumber>
277 --show-bconds - show available conditional builds, which can be used
278 - with --with and/or --without switches.
279 --with/--without <feature>
280 - conditional build package depending on %_with_<feature>/
281 %_without_<feature> macro switch. You may now use
282 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
283 constructions. Set GROUP_BCONDS to yes to make use of it.
284 --target <platform>, --target=<platform>
285 - build for platform <platform>.
289 update_shell_title() {
292 local msg="builder[$SPECFILE] $*"
295 echo -ne "\033]1;$msg\007\033]2;$msg\007"
298 echo -ne "\033]0;$msg\007"
303 # set TARGET from BuildArch: from SPECFILE
305 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
306 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
311 TARGET_SWITCH="--target $TARGET" ;;
313 TARGET_SWITCH="--target=$TARGET" ;;
320 if [ -n "$DEBUG" ]; then
328 rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
331 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
337 if [ -z "$rpm_dump_cache" ] ; then
338 echo "internal error: cache_rpm_dump not called!" 1>&2
340 echo "$rpm_dump_cache"
345 update_shell_title "parse_spec"
346 if [ -n "$DEBUG" ]; then
355 if [ "$NOSRCS" != "yes" ]; then
356 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
358 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
359 FAIL_IF_NO_SOURCES="no"
362 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
363 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
364 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
365 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
366 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
368 # These variables may be unset after first cache_rpm_dump call
369 # (because of not-yet-retrieved icon file)
371 # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
372 # Exit_error err_no_package_data;
375 if [ -n "$BE_VERBOSE" ]; then
376 echo "- Sources : `nourl $SOURCES`"
377 if [ -n "$PATCHES" ]; then
378 echo "- Patches : `nourl $PATCHES`"
380 echo "- Patches : *no patches needed*"
382 if [ -n "$ICONS" ]; then
383 echo "- Icon : `nourl $ICONS`"
385 echo "- Icon : *no package icon*"
387 echo "- Name : $PACKAGE_NAME"
388 echo "- Version : $PACKAGE_VERSION"
389 echo "- Release : $PACKAGE_RELEASE"
395 if [ -n "$DEBUG" ]; then
403 "err_no_spec_in_cmdl" )
404 remove_build_requires
405 echo "ERROR: spec file name not specified.";
407 "err_no_spec_in_repo" )
408 remove_build_requires
409 echo "Error: spec file not stored in CVS repo.";
411 "err_no_source_in_repo" )
412 remove_build_requires
413 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
416 remove_build_requires
417 echo "Error: package build failed. (${2:-no more info})";
419 "err_no_package_data" )
420 remove_build_requires
421 echo "Error: couldn't get out package name/version/release from spec file."
424 remove_build_requires
425 echo "Tag ${2} already exists (spec release: ${3}).";
428 remove_build_requires
429 echo "Release ${2} not integer and not a snapshot.";
431 "err_branch_exists" )
432 remove_build_requires
433 echo "Tree branch already exists (${2}).";
437 echo "Unknown error."
443 if [ -n "$DEBUG" ]; then
448 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
449 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
457 update_shell_title "get_spec"
459 if [ -n "$DEBUG" ]; then
465 if [ \! -f "$SPECFILE" ]; then
466 SPECFILE="`basename $SPECFILE .spec`.spec";
468 if [ "$NOCVSSPEC" != "yes" ]; then
471 if [ -n "$CVSROOT" ]; then
472 OPTIONS="-d $CVSROOT $OPTIONS"
474 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
475 echo "warning: No cvs access defined - using local .spec file"
480 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
481 OPTIONS="$OPTIONS -A"
483 if [ -n "$CVSDATE" ]; then
484 OPTIONS="$OPTIONS -D $CVSDATE"
486 if [ -n "$CVSTAG" ]; then
487 OPTIONS="$OPTIONS -r $CVSTAG"
493 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
495 retries_counter=$(( $retries_counter + 1 ))
496 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
498 [ -n "$output" ] && echo "$output"
499 if [ "$result" -ne "0" ]; then
500 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
501 echo "Trying again [$SPECFILE]... ($retries_counter)"
505 Exit_error err_no_spec_in_repo;
509 if [ ! -f "$SPECFILE" ]; then
510 Exit_error err_no_spec_in_repo;
513 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
514 chmod $CHMOD_MODE $SPECFILE
517 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
526 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
527 cvs update mirrors >&2
531 while read origin mirror name rest
533 ol=`echo -n "$origin"|wc -c`
534 prefix="`echo -n "$url" | head -c $ol`"
535 if [ "$prefix" = "$origin" ] ; then
536 suffix="`echo "$url"|cut -b $ol-`"
537 echo -n "$mirror$suffix"
548 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
549 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
555 [ X"$NO5" = X"yes" ] && return
557 [ -z "$no" ] && return
559 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
560 if [ -z "$spec_rev" ]; then
561 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
563 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
564 md5=$(grep -s -v '^#' additional-md5sums | \
565 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
566 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
567 grep -E '^[0-9a-f]{32}$')
568 if [ X"$md5" = X"" ] ; then
569 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
570 if [ ! -z "$source_md5" ] ; then
573 # we have empty SourceX-md5, but it is still possible
574 # that we have NoSourceX-md5 AND NoSource: X
575 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
576 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
581 if [ $(echo "$md5" | wc -l) != 1 ] ; then
582 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
584 echo "$md5" | tail -n 1
590 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
593 distfiles_attic_url ()
595 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
602 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
607 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
608 [ -n "$size" -a "$size" -gt 0 ]
613 if [ "$CVSIGNORE_DF" != "yes" ]; then
616 cvsignore=${SOURCE_DIR}/.cvsignore
617 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
618 echo "$1" >> $cvsignore
625 update_shell_title "get_files"
627 if [ -n "$DEBUG" ]; then
632 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
636 if [ -n "$CVSROOT" ]; then
637 OPTIONS="-d $CVSROOT $OPTIONS"
639 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
640 echo "warning: No cvs access defined for SOURCES"
644 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
645 OPTIONS="$OPTIONS -A"
647 if [ -n "$CVSDATE" ]; then
648 OPTIONS="$OPTIONS -D $CVSDATE"
650 if [ -n "$CVSTAG" ]; then
651 OPTIONS="$OPTIONS -r $CVSTAG"
656 if [ -n "$UPDATE5" ]; then
657 if [ -n "$ADD5" ]; then
658 [ `nourl $i` = "$i" ] && continue
659 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
661 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
665 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
666 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
667 echo "Warning: no URL given for $i"
670 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
671 if good_md5 "$i" && good_size "$i"; then
672 echo "$(nourl "$i") having proper md5sum already exists"
676 url=$(distfiles_url "$i")
677 url_attic=$(distfiles_attic_url "$i")
679 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
680 update_shell_title "get_files: $url"
681 ${GETLOCAL} $url $target
683 if [ -z "$NOMIRRORS" ]; then
684 url="`find_mirror "$url"`"
686 update_shell_title "get_files: $url"
687 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
688 if [ "`echo $url | grep -E 'ftp://'`" ]; then
689 update_shell_title "get_files: $url"
690 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
693 if ! test -s "$target"; then
695 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
696 update_shell_title "get_files: $url_attic"
697 ${GETLOCAL} $url_attic $target
699 if [ -z "$NOMIRRORS" ]; then
700 url_attic="`find_mirror "$url_attic"`"
702 update_shell_title "get_files: $url_attic"
703 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
704 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
705 update_shell_title "get_files: $url_attic"
706 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
710 if test -s "$target"; then
716 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
717 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
720 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
722 retries_counter=$(( $retries_counter + 1 ))
723 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
725 [ -n "$output" ] && echo "$output"
726 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
727 echo "Trying again [`nourl $i`]... ($retries_counter)"
736 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
737 if [ -z "$NOMIRRORS" ]; then
738 im="`find_mirror "$i"`"
742 update_shell_title "get_files: $im"
744 if [ "`echo $im | grep -E 'ftp://'`" ]; then
745 update_shell_title "get_files: $im"
752 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
753 Exit_error err_no_source_in_repo $i;
754 elif [ -n "$UPDATE5" ] && \
755 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
756 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
757 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
759 echo "Updating source-$srcno md5."
760 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
762 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
763 print "# Source'$srcno'-md5:\t'$md5'\n"
764 if /^Source'$srcno'\s*:\s+/;
769 if good_md5 "$i" && good_size "$i"; then
771 elif [ "$FROM_DISTFILES" = 1 ]; then
772 # wrong md5 from distfiles: remove the file and try again
774 echo "MD5 sum mismatch. Trying full fetch."
777 update_shell_title "get_files: $url"
778 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
779 if [ "`echo $url | grep -E 'ftp://'`" ]; then
780 update_shell_title "get_files: $url"
781 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
783 if ! test -s "$target"; then
785 update_shell_title "get_files: $url_attic"
786 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
787 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
788 update_shell_title "get_files: $url_attic"
789 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
792 test -s "$target" || rm -f "$target"
795 if good_md5 "$i" && good_size "$i" ; then
798 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
799 echo "or -5 to update md5 sums, if you're sure files are correct."
800 Exit_error err_no_source_in_repo $i
804 if [ "$CHMOD" = "yes" ]; then
805 CHMOD_FILES="`nourl $GET_FILES`"
806 if [ -n "$CHMOD_FILES" ]; then
807 chmod $CHMOD_MODE $CHMOD_FILES
816 if [ -n "$DEBUG" ]; then
821 # Check whether first character of PACKAGE_NAME is legal for tag name
822 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
825 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"`
826 # Remove #kernel.version_release from TAGVER because tagging sources
827 # could occur with different kernel-headers than kernel-headers used at build time.
828 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
836 if [ -n "$DEBUG" ]; then
841 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
842 echo "Version: $PACKAGE_VERSION"
843 echo "Release: $PACKAGE_RELEASE"
847 if [ "$TAG_VERSION" = "yes" ]; then
848 echo "CVS tag: $TAGVER"
850 if [ -n "$TAG" ]; then
855 if [ -n "$CVSROOT" ]; then
856 OPTIONS="-d $CVSROOT $OPTIONS"
862 # don't tag files stored on distfiles
863 [ -n "`src_md5 $i`" ] && continue
864 if [ -f "`nourl $i`" ]; then
865 if [ "$TAG_VERSION" = "yes" ]; then
866 cvs $OPTIONS $TAGVER `nourl $i`
868 if [ -n "$TAG" ]; then
869 cvs $OPTIONS $TAG `nourl $i`
872 Exit_error err_no_source_in_repo $i
877 if [ "$TAG_VERSION" = "yes" ]; then
878 cvs $OPTIONS $TAGVER $SPECFILE
880 if [ -n "$TAG" ]; then
881 cvs $OPTIONS $TAG $SPECFILE
891 echo "CVS branch tag: $TAG"
896 if [ -n "$DEBUG" ]; then
901 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
904 if [ -n "$CVSROOT" ]; then
905 OPTIONS="-d $CVSROOT $OPTIONS"
910 if [ -f `nourl $i` ]; then
911 cvs $OPTIONS $TAG `nourl $i`
913 Exit_error err_no_source_in_repo $i
917 cvs $OPTIONS $TAG $SPECFILE
927 update_shell_title "build_package"
928 if [ -n "$DEBUG" ]; then
935 if [ -n "$TRY_UPGRADE" ]; then
936 update_shell_title "build_package: try_upgrade"
937 if [ -n "$FLOAT_VERSION" ]; then
938 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
940 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
943 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
945 if [ -n "$TNEWVER" ]; then
946 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
947 echo "New version found, updating spec file to version " $TNEWVER
948 cp -f $SPECFILE $SPECFILE.bak
950 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
951 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
953 if [ -n "$ICONS" ]; then
957 NODIST="yes" UPDATE5="yes" get_files "$SOURCES $PATCHES";
958 unset TOLDVER TNEWVER TNOTIFY
965 BUILD_SWITCH="-ba" ;;
967 BUILD_SWITCH="-bb" ;;
969 BUILD_SWITCH="-bs --nodeps" ;;
971 BUILD_SWITCH="-bp --nodeps" ;;
974 update_shell_title "build_package: $COMMAND"
975 if [ -n "$LOGFILE" ]; then
976 LOG=`eval echo $LOGFILE`
977 if [ -d "$LOG" ]; then
978 echo "Log file $LOG is a directory."
979 echo "Parse error in the spec?"
980 Exit_error err_build_fail;
982 if [ -n "$LASTLOG_FILE" ]; then
983 echo "LASTLOG=$LOG" > $LASTLOG_FILE
985 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
986 (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
987 RETVAL=`cat $RES_FILE`
989 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
990 if [ "$RETVAL" -eq "0" ]; then
997 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
1000 if [ "$RETVAL" -ne "0" ]; then
1001 if [ -n "$TRY_UPGRADE" ]; then
1002 echo "\n!!! Package with new version cannot be build automagically\n"
1003 mv -f $SPECFILE.bak $SPECFILE
1005 Exit_error err_build_fail;
1012 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1015 install_required_packages()
1023 update_shell_title "set_bconds_values"
1025 AVAIL_BCONDS_WITHOUT=""
1026 AVAIL_BCONDS_WITH=""
1027 if `grep -q ^%bcond ${SPECFILE}`; then
1029 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1032 BCOND_VERSION="NONE"
1035 # expand bconds from ~/.bcondrc
1036 # The file structure is like gentoo's package.use:
1039 # samba -mysql -pgsql
1040 # w32codec-installer license_agreement
1043 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
1044 # This takes package name, first defined in spec.
1045 # so consider that when defining flags for package.
1046 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
1047 SN=${SPECFILE%%\.spec}
1048 AVAIL=`$RPMBUILD --bcond $SPECFILE`
1050 BCONDRC=$HOME/.bcondrc
1051 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
1053 while read pkg flags; do
1055 [[ "$pkg" == \#* ]] && continue
1057 # any package or current package?
1058 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ] || [ "$pkg" = "$SN" ]; then
1059 for flag in $flags; do
1062 # use only flags which are in this package.
1063 if [[ $AVAIL = *${opt}* ]]; then
1064 if [[ $flag = -* ]]; then
1065 BCOND="$BCOND --without $opt"
1067 BCOND="$BCOND --with $opt"
1075 case "${BCOND_VERSION}" in
1080 echo "Warning: This spec has old style bconds. Fix it || die."
1081 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1083 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1084 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1085 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1087 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1091 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1093 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1094 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1095 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1097 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1102 cond_type="" # with || without
1103 for opt in `$RPMBUILD --bcond $SPECFILE`
1113 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1114 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1115 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1117 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1121 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1122 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1123 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1125 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1129 case "$cond_type" in
1132 AVAIL_BCOND_WITH="$opt"
1133 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1134 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1136 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1141 AVAIL_BCOND_WITHOUT="$opt"
1142 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1143 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1145 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1159 update_shell_title "run_sub_builder $package_name"
1161 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1162 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1163 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1164 # jakby nie bylo tego kawalka kodu.
1166 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1167 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1174 # Istnieje taki spec? ${package}.spec
1175 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1176 parent_spec_name=${package}.spec
1177 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1178 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1180 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1186 if [ "${parent_spec_name}" != "" ]; then
1187 spawn_sub_builder $parent_spec_name
1189 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1195 update_shell_title "spawn_sub_builder $package_name"
1198 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1199 sub_builder_opts="${sub_builder_opts} -R"
1201 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1202 sub_builder_opts="${sub_builder_opts} -RB"
1203 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1204 sub_builder_opts="${sub_builder_opts} -FRB"
1206 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1207 sub_builder_opts="${sub_builder_opts} -Upi"
1211 ./builder ${sub_builder_opts} "$@"
1214 remove_build_requires()
1216 if [ "$INSTALLED_PACKAGES" != "" ]; then
1217 case "$REMOVE_BUILD_REQUIRES" in
1219 run_poldek --noask -ve $INSTALLED_PACKAGES
1222 run_poldek --ask -ve $INSTALLED_PACKAGES
1225 echo You may want to manually remove following BuildRequires fetched:
1226 echo $INSTALLED_PACKAGES
1227 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1235 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1236 if [ "$BCOND" != "" ]; then
1237 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1240 echo -ne "\nNo conditional flags passed"
1242 echo -ne "\n\nfrom available:\n"
1243 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1249 if [ "$NOCVSSPEC" != "yes" ]; then
1250 echo -ne "Available branches: "
1251 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1255 # checks a given list of packages/files/provides agains current rpmdb.
1256 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1257 # input can be either STDIN or parameters
1262 if [ "$#" -gt 0 ]; then
1268 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1271 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1273 # other deps (files)
1274 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1277 # checks if given package/files/provides exists in rpmdb.
1278 # inout can be either stdin or parameters
1279 # returns packages wchi hare present in the rpmdb
1284 if [ "$#" -gt 0 ]; then
1290 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1293 fetch_build_requires()
1295 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1296 update_shell_title "fetch_build_requires"
1297 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1298 CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1299 DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1301 update_shell_title "fetch_build_requires: update indexes"
1302 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1303 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1305 if [ -n "$CONF" ]; then
1306 update_shell_title "fetch_build_requires: uninstall conflicting packages"
1307 echo "Trying to uninstall conflicting packages ($CONF):"
1308 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1310 if [ -n "$DEPS" ]; then
1311 update_shell_title "fetch_build_requires: install deps ($DEPS)"
1312 echo "Trying to install dependencies ($DEPS):"
1313 local log=.${SPECFILE}_poldek.log
1314 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1315 failed=$(awk -F: '/^error:/{print $2}' $log)
1317 if [ -n "$failed" ]; then
1318 for package in $failed; do
1319 # FIXME: sanitise, deps could be not .spec files
1320 spawn_sub_builder -bb $package
1327 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1328 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1329 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1330 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1331 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1332 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`
1334 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`"
1336 package=`basename "$package_item"|sed -e "s/}$//g"`
1337 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1340 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1341 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1342 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
1347 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1350 if `echo $COND_TST|grep -q 'without_'`; then
1351 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1352 if `echo $COND_TST|grep -q !`; then
1357 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1358 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1359 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1365 elif `echo $COND_TST|grep -q 'with_'`; then
1366 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1367 if `echo $COND_TST|grep -q !`; then
1372 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1373 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1374 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1380 RESULT="${COND_STATE}-${COND_ARGV}"
1382 "with-wout" | "wout-with" )
1385 "wout-wout" | "with-with" )
1389 echo "Action '$RESULT' was not defined for package '$package_item'"
1395 if [ "$GO" = "yes" ]; then
1396 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1397 echo "Testing if $package has subrequirements..."
1398 run_poldek -t -i $package --dumpn=".$package-req.txt"
1399 if [ -f ".$package-req.txt" ]; then
1400 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1402 if [ "$package_name" = "$package" ]; then
1403 echo -ne "Installing BuildRequired package:\t$package_name\n"
1404 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1405 install_required_packages $package;
1407 echo -ne "Installing (sub)Required package:\t$package_name\n"
1408 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1409 install_required_packages $package_name;
1413 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1414 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1417 echo "Attempting to run spawn sub - builder..."
1418 echo -ne "Package installation failed:\t$package_name\n"
1419 run_sub_builder $package_name
1420 if [ $? -eq 0 ]; then
1421 install_required_packages $package_name;
1424 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1425 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1428 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1435 rm -f ".$package-req.txt"
1437 echo "Attempting to run spawn sub - builder..."
1438 echo -ne "Package installation failed:\t$package\n"
1439 run_sub_builder $package
1440 if [ $? -eq 0 ]; then
1441 install_required_packages $package;
1444 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1445 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1448 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1454 echo "Package $package is already installed. BuildRequirement satisfied."
1458 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1459 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1460 echo "Unable to install following packages and their dependencies:"
1461 for pkg in "$NOT_INSTALLED_PACKAGES"
1465 remove_build_requires
1471 #---------------------------------------------
1474 if [ "$#" = 0 ]; then
1500 DEBUG="yes"; shift ;;
1502 COMMAND="version"; shift ;;
1504 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1505 -b | -ba | --build )
1506 COMMAND="build"; shift ;;
1507 -bb | --build-binary )
1508 COMMAND="build-binary"; shift ;;
1509 -bs | --build-source )
1510 COMMAND="build-source"; shift ;;
1511 -bp | --build-prep )
1512 COMMAND="build-prep"; shift ;;
1514 COMMAND="branch"; shift; TAG="${1}"; shift;;
1516 CLEAN="--clean --rmspec --rmsource"; shift ;;
1518 shift; CVSROOT="${1}"; shift ;;
1520 COMMAND="get"; shift ;;
1522 COMMAND="usage"; shift ;;
1524 PROTOCOL="http"; shift ;;
1526 shift; LOGFILE="${1}"; shift ;;
1528 shift; DEF_NICE_LEVEL=${1}; shift ;;
1530 COMMAND="mr-proper"; shift ;;
1532 NOCVS="yes"; shift ;;
1533 -ncs | --no-cvs-specs )
1534 NOCVSSPEC="yes"; shift ;;
1535 -nd | --no-distfiles )
1536 NODIST="yes"; shift ;;
1537 -nm | --no-mirrors )
1538 NOMIRRORS="yes"; shift ;;
1540 NOURLS="yes"; shift ;;
1542 NOSRCS="yes"; shift ;;
1543 -ns0 | --no-source0 )
1544 NOSOURCE0="yes"; shift ;;
1554 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1556 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} echo ignoring patch${1} \""; shift ;;
1557 --with | --without )
1558 case $GROUP_BCONDS in
1562 while ! `echo ${1}|grep -qE '(^-|spec)'`
1564 BCOND="$BCOND $COND $1"
1568 if [[ "$2" = *,* ]]; then
1569 for a in $(echo "$2" | tr , ' '); do
1570 BCOND="$BCOND $1 $a"
1573 BCOND="$BCOND $1 $2"
1579 shift; TARGET="${1}"; shift ;;
1581 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1583 QUIET="--quiet"; shift ;;
1585 CVSDATE="${2}"; shift 2 ;;
1587 shift; CVSTAG="${1}"; shift ;;
1588 -R | --fetch-build-requires)
1589 FETCH_BUILD_REQUIRES="yes"
1590 NOT_INSTALLED_PACKAGES=
1592 -RB | --remove-build-requires)
1593 REMOVE_BUILD_REQUIRES="nice"
1595 -FRB | --force-remove-build-requires)
1596 REMOVE_BUILD_REQUIRES="force"
1598 -sf | --sources-files)
1599 COMMAND="list-sources-files"
1601 -sp | --sources-paths)
1602 COMMAND="list-sources-local-paths"
1604 -Tvs | --tag-version-stable )
1609 -Tvn | --tag-version-nest )
1614 -Ts | --tag-stable )
1624 -Tv | --tag-version )
1629 -Tp | --tag-prefix )
1641 -ir | --integer-release-only )
1642 INTEGER_RELEASE="yes"
1651 -Upi | --update-poldek-indexes )
1652 UPDATE_POLDEK_INDEXES="yes"
1654 -u | --try-upgrade )
1655 TRY_UPGRADE="1"; shift ;;
1656 -un | --try-upgrade-with-float-version )
1657 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1659 BE_VERBOSE="1"; shift ;;
1665 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1667 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1673 RPMOPTS="${RPMOPTS} --nodeps"
1676 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1679 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1684 if [ -n "$DEBUG" ]; then
1689 if [ -n "$TARGET" ]; then
1692 TARGET_SWITCH="--target $TARGET" ;;
1694 TARGET_SWITCH="--target=$TARGET" ;;
1698 update_shell_title "$COMMAND"
1700 "build" | "build-binary" | "build-source" | "build-prep" )
1702 if [ -n "$SPECFILE" ]; then
1707 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1708 fetch_build_requires;
1710 if [ "$INTEGER_RELEASE" = "yes" ]; then
1711 echo "Checking release $PACKAGE_RELEASE..."
1712 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1713 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1717 if [ -n "$TEST_TAG" ]; then
1718 TAGVER=`make_tagver`
1719 echo "Searching for tag $TAGVER..."
1720 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1721 if [ -n "$TAGREL" ]; then
1722 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1725 # - do not allow to build from HEAD when XX-branch exists
1726 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1727 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1728 TAG_BRANCH="${TREE_PREFIX}-branch"
1729 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1730 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1731 Exit_error err_branch_exists "$TAG_STATUS"
1737 if [ -n "$ICONS" ]; then
1741 if [ -n "$NOSOURCE0" ] ; then
1742 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1744 get_files "$SOURCES $PATCHES";
1746 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1747 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1749 remove_build_requires;
1751 Exit_error err_no_spec_in_cmdl;
1756 if [ -n "$SPECFILE" ]; then
1759 if [ -n "$ICONS" ]; then
1763 get_files $SOURCES $PATCHES;
1764 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1766 Exit_error err_no_spec_in_cmdl;
1771 if [ -n "$SPECFILE" ]; then
1774 if [ -n "$ICONS" ]; then
1775 OLD_UPDATE5=$UPDATE5
1776 UPDATE5= get_files $ICONS
1777 UPDATE5=$OLD_UPDATE5
1780 if [ -n "$NOSOURCE0" ] ; then
1781 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1783 get_files $SOURCES $PATCHES
1785 Exit_error err_no_spec_in_cmdl;
1792 if [ -n "$SPECFILE" ]; then
1795 if [ -n "$ICONS" ]; then
1799 # don't fetch sources from remote locations
1801 for file in $SOURCES
1803 [ -n "`src_md5 $file`" ] && continue
1804 new_SOURCES="$new_SOURCES $file"
1806 SOURCES="$new_SOURCES"
1807 get_files $SOURCES $PATCHES;
1808 tag_files "$SOURCES $PATCHES $ICONS";
1810 Exit_error err_no_spec_in_cmdl;
1814 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1816 "list-sources-files" )
1819 DONT_PRINT_REVISION="yes"
1822 SAPS="$SOURCES $PATCHES"
1823 for SAP in $SAPS ; do
1824 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1827 "list-sources-local-paths" )
1830 DONT_PRINT_REVISION="yes"
1833 SAPS="$SOURCES $PATCHES"
1834 for SAP in $SAPS ; do
1835 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1843 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1844 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1848 # vi:syntax=sh:ts=3:sw=4