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 update_shell_title() {
291 echo -ne "\033]1;builder: $*\007\033]2;builder: $*\007"
294 echo -ne "\033]0;builder: $*\007"
299 # set TARGET from BuildArch: from SPECFILE
301 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
302 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
307 TARGET_SWITCH="--target $TARGET" ;;
309 TARGET_SWITCH="--target=$TARGET" ;;
316 if [ -n "$DEBUG" ]; then
324 rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
327 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
333 if [ -z "$rpm_dump_cache" ] ; then
334 echo "internal error: cache_rpm_dump not called!" 1>&2
336 echo "$rpm_dump_cache"
341 update_shell_title "parse_spec: $SPECFILE"
342 if [ -n "$DEBUG" ]; then
351 if [ "$NOSRCS" != "yes" ]; then
352 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
354 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
355 FAIL_IF_NO_SOURCES="no"
358 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
359 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
360 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
361 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
362 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
364 # These variables may be unset after first cache_rpm_dump call
365 # (because of not-yet-retrieved icon file)
367 # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
368 # Exit_error err_no_package_data;
371 if [ -n "$BE_VERBOSE" ]; then
372 echo "- Sources : `nourl $SOURCES`"
373 if [ -n "$PATCHES" ]; then
374 echo "- Patches : `nourl $PATCHES`"
376 echo "- Patches : *no patches needed*"
378 if [ -n "$ICONS" ]; then
379 echo "- Icon : `nourl $ICONS`"
381 echo "- Icon : *no package icon*"
383 echo "- Name : $PACKAGE_NAME"
384 echo "- Version : $PACKAGE_VERSION"
385 echo "- Release : $PACKAGE_RELEASE"
391 if [ -n "$DEBUG" ]; then
399 "err_no_spec_in_cmdl" )
400 remove_build_requires
401 echo "ERROR: spec file name not specified.";
403 "err_no_spec_in_repo" )
404 remove_build_requires
405 echo "Error: spec file not stored in CVS repo.";
407 "err_no_source_in_repo" )
408 remove_build_requires
409 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
412 remove_build_requires
413 echo "Error: package build failed. (${2:-no more info})";
415 "err_no_package_data" )
416 remove_build_requires
417 echo "Error: couldn't get out package name/version/release from spec file."
420 remove_build_requires
421 echo "Tag ${2} already exists (spec release: ${3}).";
424 remove_build_requires
425 echo "Release ${2} not integer and not a snapshot.";
427 "err_branch_exists" )
428 remove_build_requires
429 echo "Tree branch already exists (${2}).";
433 echo "Unknown error."
439 if [ -n "$DEBUG" ]; then
444 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
445 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
453 update_shell_title "get_spec: $SPECFILE"
455 if [ -n "$DEBUG" ]; then
461 if [ \! -f "$SPECFILE" ]; then
462 SPECFILE="`basename $SPECFILE .spec`.spec";
464 if [ "$NOCVSSPEC" != "yes" ]; then
467 if [ -n "$CVSROOT" ]; then
468 OPTIONS="-d $CVSROOT $OPTIONS"
470 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
471 echo "warning: No cvs access defined - using local .spec file"
476 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
477 OPTIONS="$OPTIONS -A"
479 if [ -n "$CVSDATE" ]; then
480 OPTIONS="$OPTIONS -D $CVSDATE"
482 if [ -n "$CVSTAG" ]; then
483 OPTIONS="$OPTIONS -r $CVSTAG"
489 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
491 retries_counter=$(( $retries_counter + 1 ))
492 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
494 [ -n "$output" ] && echo "$output"
495 if [ "$result" -ne "0" ]; then
496 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
497 echo "Trying again [$SPECFILE]... ($retries_counter)"
501 Exit_error err_no_spec_in_repo;
505 if [ ! -f "$SPECFILE" ]; then
506 Exit_error err_no_spec_in_repo;
509 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
510 chmod $CHMOD_MODE $SPECFILE
513 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
522 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
523 cvs update mirrors >&2
527 while read origin mirror name rest
529 ol=`echo -n "$origin"|wc -c`
530 prefix="`echo -n "$url" | head -c $ol`"
531 if [ "$prefix" = "$origin" ] ; then
532 suffix="`echo "$url"|cut -b $ol-`"
533 echo -n "$mirror$suffix"
544 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
545 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
551 [ X"$NO5" = X"yes" ] && return
553 [ -z "$no" ] && return
555 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
556 if [ -z "$spec_rev" ]; then
557 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
559 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
560 md5=$(grep -s -v '^#' additional-md5sums | \
561 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
562 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
563 grep -E '^[0-9a-f]{32}$')
564 if [ X"$md5" = X"" ] ; then
565 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
566 if [ ! -z "$source_md5" ] ; then
569 # we have empty SourceX-md5, but it is still possible
570 # that we have NoSourceX-md5 AND NoSource: X
571 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
572 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
577 if [ $(echo "$md5" | wc -l) != 1 ] ; then
578 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
580 echo "$md5" | tail -n 1
586 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
589 distfiles_attic_url ()
591 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
598 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
603 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
604 [ -n "$size" -a "$size" -gt 0 ]
609 if [ "$CVSIGNORE_DF" != "yes" ]; then
612 cvsignore=${SOURCE_DIR}/.cvsignore
613 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
614 echo "$1" >> $cvsignore
621 update_shell_title "get_files: $@"
623 if [ -n "$DEBUG" ]; then
628 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
632 if [ -n "$CVSROOT" ]; then
633 OPTIONS="-d $CVSROOT $OPTIONS"
635 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
636 echo "warning: No cvs access defined for SOURCES"
640 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
641 OPTIONS="$OPTIONS -A"
643 if [ -n "$CVSDATE" ]; then
644 OPTIONS="$OPTIONS -D $CVSDATE"
646 if [ -n "$CVSTAG" ]; then
647 OPTIONS="$OPTIONS -r $CVSTAG"
652 if [ -n "$UPDATE5" ]; then
653 if [ -n "$ADD5" ]; then
654 [ `nourl $i` = "$i" ] && continue
655 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
657 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
661 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
662 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
663 echo "Warning: no URL given for $i"
666 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
667 if good_md5 "$i" && good_size "$i"; then
668 echo "$(nourl "$i") having proper md5sum already exists"
672 url=$(distfiles_url "$i")
673 url_attic=$(distfiles_attic_url "$i")
675 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
676 ${GETLOCAL} $url $target
678 if [ -z "$NOMIRRORS" ]; then
679 url="`find_mirror "$url"`"
681 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
682 if [ "`echo $url | grep -E 'ftp://'`" ]; then
683 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
686 if ! test -s "$target"; then
688 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
689 ${GETLOCAL} $url_attic $target
691 if [ -z "$NOMIRRORS" ]; then
692 url_attic="`find_mirror "$url_attic"`"
694 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
695 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
696 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
700 if test -s "$target"; then
706 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
707 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
710 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
712 retries_counter=$(( $retries_counter + 1 ))
713 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
715 [ -n "$output" ] && echo "$output"
716 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
717 echo "Trying again [`nourl $i`]... ($retries_counter)"
726 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
727 if [ -z "$NOMIRRORS" ]; then
728 im="`find_mirror "$i"`"
733 if [ "`echo $im | grep -E 'ftp://'`" ]; then
740 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
741 Exit_error err_no_source_in_repo $i;
742 elif [ -n "$UPDATE5" ] && \
743 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
744 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
745 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
747 echo "Updating source-$srcno md5."
748 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
750 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
751 print "# Source'$srcno'-md5:\t'$md5'\n"
752 if /^Source'$srcno'\s*:\s+/;
757 if good_md5 "$i" && good_size "$i"; then
759 elif [ "$FROM_DISTFILES" = 1 ]; then
760 # wrong md5 from distfiles: remove the file and try again
762 echo "MD5 sum mismatch. Trying full fetch."
765 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
766 if [ "`echo $url | grep -E 'ftp://'`" ]; then
767 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
769 if ! test -s "$target"; then
771 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
772 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
773 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
776 test -s "$target" || rm -f "$target"
779 if good_md5 "$i" && good_size "$i" ; then
782 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
783 echo "or -5 to update md5 sums, if you're sure files are correct."
784 Exit_error err_no_source_in_repo $i
788 if [ "$CHMOD" = "yes" ]; then
789 CHMOD_FILES="`nourl $GET_FILES`"
790 if [ -n "$CHMOD_FILES" ]; then
791 chmod $CHMOD_MODE $CHMOD_FILES
800 if [ -n "$DEBUG" ]; then
805 # Check whether first character of PACKAGE_NAME is legal for tag name
806 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
809 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"`
810 # Remove #kernel.version_release from TAGVER because tagging sources
811 # could occur with different kernel-headers than kernel-headers used at build time.
812 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
820 if [ -n "$DEBUG" ]; then
825 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
826 echo "Version: $PACKAGE_VERSION"
827 echo "Release: $PACKAGE_RELEASE"
831 if [ "$TAG_VERSION" = "yes" ]; then
832 echo "CVS tag: $TAGVER"
834 if [ -n "$TAG" ]; then
839 if [ -n "$CVSROOT" ]; then
840 OPTIONS="-d $CVSROOT $OPTIONS"
846 # don't tag files stored on distfiles
847 [ -n "`src_md5 $i`" ] && continue
848 if [ -f "`nourl $i`" ]; then
849 if [ "$TAG_VERSION" = "yes" ]; then
850 cvs $OPTIONS $TAGVER `nourl $i`
852 if [ -n "$TAG" ]; then
853 cvs $OPTIONS $TAG `nourl $i`
856 Exit_error err_no_source_in_repo $i
861 if [ "$TAG_VERSION" = "yes" ]; then
862 cvs $OPTIONS $TAGVER $SPECFILE
864 if [ -n "$TAG" ]; then
865 cvs $OPTIONS $TAG $SPECFILE
875 echo "CVS branch tag: $TAG"
880 if [ -n "$DEBUG" ]; then
885 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
888 if [ -n "$CVSROOT" ]; then
889 OPTIONS="-d $CVSROOT $OPTIONS"
894 if [ -f `nourl $i` ]; then
895 cvs $OPTIONS $TAG `nourl $i`
897 Exit_error err_no_source_in_repo $i
901 cvs $OPTIONS $TAG $SPECFILE
911 update_shell_title "build_package: $SPECFILE"
912 if [ -n "$DEBUG" ]; then
919 if [ -n "$TRY_UPGRADE" ]; then
920 update_shell_title "build_package: try_upgrade: $SPECFILE"
921 if [ -n "$FLOAT_VERSION" ]; then
922 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
924 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
927 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
929 if [ -n "$TNEWVER" ]; then
930 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
931 echo "New version found, updating spec file to version " $TNEWVER
932 cp -f $SPECFILE $SPECFILE.bak
934 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
935 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
937 if [ -n "$ICONS" ]; then
941 NODIST="yes" UPDATE5="yes" get_files "$SOURCES $PATCHES";
942 unset TOLDVER TNEWVER TNOTIFY
949 BUILD_SWITCH="-ba" ;;
951 BUILD_SWITCH="-bb" ;;
953 BUILD_SWITCH="-bs --nodeps" ;;
955 BUILD_SWITCH="-bp --nodeps" ;;
958 update_shell_title "build_package: $COMMAND: $SPECFILE"
959 if [ -n "$LOGFILE" ]; then
960 LOG=`eval echo $LOGFILE`
961 if [ -d "$LOG" ]; then
962 echo "Log file $LOG is a directory."
963 echo "Parse error in the spec?"
964 Exit_error err_build_fail;
966 if [ -n "$LASTLOG_FILE" ]; then
967 echo "LASTLOG=$LOG" > $LASTLOG_FILE
969 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
970 (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
971 RETVAL=`cat $RES_FILE`
973 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
974 if [ "$RETVAL" -eq "0" ]; then
981 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
984 if [ "$RETVAL" -ne "0" ]; then
985 if [ -n "$TRY_UPGRADE" ]; then
986 echo "\n!!! Package with new version cannot be build automagically\n"
987 mv -f $SPECFILE.bak $SPECFILE
989 Exit_error err_build_fail;
996 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
999 install_required_packages()
1007 update_shell_title "set_bconds_values: $SPECFILE"
1009 AVAIL_BCONDS_WITHOUT=""
1010 AVAIL_BCONDS_WITH=""
1011 if `grep -q ^%bcond ${SPECFILE}`; then
1013 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1016 BCOND_VERSION="NONE"
1019 # expand bconds from ~/.bcondrc
1020 # The file structure is like gentoo's package.use:
1023 # samba -mysql -pgsql
1024 # w32codec-installer license_agreement
1027 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
1028 # This takes package name, first defined in spec.
1029 # so consider that when defining flags for package.
1030 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
1031 SN=${SPECFILE%%\.spec}
1032 AVAIL=`$RPMBUILD --bcond $SPECFILE`
1034 BCONDRC=$HOME/.bcondrc
1035 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
1037 while read pkg flags; do
1039 [[ "$pkg" == \#* ]] && continue
1041 # any package or current package?
1042 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ] || [ "$pkg" = "$SN" ]; then
1043 for flag in $flags; do
1046 # use only flags which are in this package.
1047 if [[ $AVAIL = *${opt}* ]]; then
1048 if [[ $flag = -* ]]; then
1049 BCOND="$BCOND --without $opt"
1051 BCOND="$BCOND --with $opt"
1059 case "${BCOND_VERSION}" in
1064 echo "Warning: This spec has old style bconds. Fix it || die."
1065 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1067 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1068 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1069 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1071 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1075 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1077 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1078 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1079 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1081 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1086 cond_type="" # with || without
1087 for opt in `$RPMBUILD --bcond $SPECFILE`
1097 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1098 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1099 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1101 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1105 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1106 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1107 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1109 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1113 case "$cond_type" in
1116 AVAIL_BCOND_WITH="$opt"
1117 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1118 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1120 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1125 AVAIL_BCOND_WITHOUT="$opt"
1126 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1127 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1129 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1143 echo -ne "Package installation failed:\t$package_name\n"
1145 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1146 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1147 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1148 # jakby nie bylo tego kawalka kodu.
1150 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1151 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1158 # Istnieje taki spec? ${package}.spec
1159 if [ -f "${SPECS_DIR}${package}.spec" ]; then
1160 parent_spec_name=${package}.spec
1161 elif [ -f "${SPECS_DIR}`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1162 parent_spec_name="`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1164 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1170 if [ "${parent_spec_name}" != "" ]; then
1172 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1173 sub_builder_opts="${sub_builder_opts} -R"
1175 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1176 sub_builder_opts="${sub_builder_opts} -RB"
1177 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1178 sub_builder_opts="${sub_builder_opts} -FRB"
1180 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1181 sub_builder_opts="${sub_builder_opts} -Upi"
1184 ./builder ${sub_builder_opts} ${parent_spec_name}
1186 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1189 remove_build_requires()
1191 if [ "$INSTALLED_PACKAGES" != "" ]; then
1192 case "$REMOVE_BUILD_REQUIRES" in
1194 run_poldek --noask -ve $INSTALLED_PACKAGES
1197 run_poldek --ask -ve $INSTALLED_PACKAGES
1200 echo You may want to manually remove following BuildRequires fetched:
1201 echo $INSTALLED_PACKAGES
1202 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1210 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1211 if [ "$BCOND" != "" ]; then
1212 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1215 echo -ne "\nNo conditional flags passed"
1217 echo -ne "\n\nfrom available:\n"
1218 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1224 if [ "$NOCVSSPEC" != "yes" ]; then
1225 echo -ne "Available branches: "
1226 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1230 # checks a given list of packages/files/provides agains current rpmdb.
1231 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1232 # input can be either STDIN or parameters
1237 if [ "$#" -gt 0 ]; then
1243 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1246 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1248 # other deps (files)
1249 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1252 # checks if given package/files/provides exists in rpmdb.
1253 # inout can be either stdin or parameters
1254 # returns packages wchi hare present in the rpmdb
1259 if [ "$#" -gt 0 ]; then
1265 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1268 fetch_build_requires()
1270 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1271 update_shell_title "fetc_build_requires: $SPECFILE"
1272 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1273 CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1274 DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1276 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1277 $SU_SUDO /usr/bin/poldek --update || $SU_SUDO /usr/bin/poldek --upa
1279 if [ -n "$CONF" ]; then
1280 echo "Trying to uninstall conflicting packages ($CONF):"
1281 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1283 if [ -n "$DEPS" ]; then
1284 echo "Trying to install dependencies ($DEPS):"
1285 $SU_SUDO /usr/bin/poldek --caplookup -uGv $DEPS
1290 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1291 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1292 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1293 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1294 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1295 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`
1297 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`"
1299 package=`basename "$package_item"|sed -e "s/}$//g"`
1300 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1303 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1304 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1305 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
1310 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1313 if `echo $COND_TST|grep -q 'without_'`; then
1314 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1315 if `echo $COND_TST|grep -q !`; then
1320 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1321 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1322 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1328 elif `echo $COND_TST|grep -q 'with_'`; then
1329 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1330 if `echo $COND_TST|grep -q !`; then
1335 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1336 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1337 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1343 RESULT="${COND_STATE}-${COND_ARGV}"
1345 "with-wout" | "wout-with" )
1348 "wout-wout" | "with-with" )
1352 echo "Action '$RESULT' was not defined for package '$package_item'"
1358 if [ "$GO" = "yes" ]; then
1359 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1360 echo "Testing if $package has subrequirements..."
1361 run_poldek -t -i $package --dumpn=".$package-req.txt"
1362 if [ -f ".$package-req.txt" ]; then
1363 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1365 if [ "$package_name" = "$package" ]; then
1366 echo -ne "Installing BuildRequired package:\t$package_name\n"
1367 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1368 install_required_packages $package;
1370 echo -ne "Installing (sub)Required package:\t$package_name\n"
1371 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1372 install_required_packages $package_name;
1376 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1377 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1380 echo "Attempting to run spawn sub - builder..."
1381 run_sub_builder $package_name
1382 if [ $? -eq 0 ]; then
1383 install_required_packages $package_name;
1386 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1387 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1390 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1397 rm -f ".$package-req.txt"
1399 echo "Attempting to run spawn sub - builder..."
1400 run_sub_builder $package
1401 if [ $? -eq 0 ]; then
1402 install_required_packages $package;
1405 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1406 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1409 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1415 echo "Package $package is already installed. BuildRequirement satisfied."
1419 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1420 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1421 echo "Unable to install following packages and their dependencies:"
1422 for pkg in "$NOT_INSTALLED_PACKAGES"
1426 remove_build_requires
1434 # vim like diff colourization, glen@pld-linux.org
1436 s,
\e,
\e[44m^[
\e[49m,g;
1437 s,
\a,
\e[44m^G
\e[49m,g;
1438 s,^\(Index:\|diff\|---\|+++\) .*$,
\e[32m&,;
1442 s,
\r,
\e[44m^M
\e[49m,g;
1444 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1
\e[41m\2
\e[49m,g;
1453 tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/adapter-XXXXXX) || exit
1454 awk -f adapter.awk $SPECFILE > $tmpdir/$SPECFILE || exit
1456 if [ "`diff --brief $SPECFILE $tmpdir/$SPECFILE`" ] ; then
1457 diff -u $SPECFILE $tmpdir/$SPECFILE > $tmpdir/$SPECFILE.diff
1459 diffcol $tmpdir/$SPECFILE.diff | less -r
1461 echo -n "Accept? [yn] "
1465 mv -f $tmpdir/$SPECFILE $SPECFILE
1466 echo "Ok, adapterized."
1476 cat $tmpdir/$SPECFILE.diff
1479 echo "The SPEC is perfect ;)"
1485 #---------------------------------------------
1488 if [ "$#" = 0 ]; then
1502 --adapter | --adapterize )
1503 COMMAND="adapterize";
1520 DEBUG="yes"; shift ;;
1522 COMMAND="version"; shift ;;
1524 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1525 -b | -ba | --build )
1526 COMMAND="build"; shift ;;
1527 -bb | --build-binary )
1528 COMMAND="build-binary"; shift ;;
1529 -bs | --build-source )
1530 COMMAND="build-source"; shift ;;
1531 -bp | --build-prep )
1532 COMMAND="build-prep"; shift ;;
1534 COMMAND="branch"; shift; TAG="${1}"; shift;;
1536 CLEAN="--clean --rmspec --rmsource"; shift ;;
1538 shift; CVSROOT="${1}"; shift ;;
1540 COMMAND="get"; shift ;;
1542 COMMAND="usage"; shift ;;
1544 PROTOCOL="http"; shift ;;
1546 shift; LOGFILE="${1}"; shift ;;
1548 shift; DEF_NICE_LEVEL=${1}; shift ;;
1550 COMMAND="mr-proper"; shift ;;
1552 NOCVS="yes"; shift ;;
1553 -ncs | --no-cvs-specs )
1554 NOCVSSPEC="yes"; shift ;;
1555 -nd | --no-distfiles )
1556 NODIST="yes"; shift ;;
1557 -nm | --no-mirrors )
1558 NOMIRRORS="yes"; shift ;;
1560 NOURLS="yes"; shift ;;
1562 NOSRCS="yes"; shift ;;
1563 -ns0 | --no-source0 )
1564 NOSOURCE0="yes"; shift ;;
1574 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1576 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} echo ignoring patch${1} \""; shift ;;
1577 --with | --without )
1578 case $GROUP_BCONDS in
1582 while ! `echo ${1}|grep -qE '(^-|spec)'`
1584 BCOND="$BCOND $COND $1"
1588 if [[ "$2" = *,* ]]; then
1589 for a in $(echo "$2" | tr , ' '); do
1590 BCOND="$BCOND $1 $a"
1593 BCOND="$BCOND $1 $2"
1599 shift; TARGET="${1}"; shift ;;
1601 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1603 QUIET="--quiet"; shift ;;
1605 CVSDATE="${2}"; shift 2 ;;
1607 shift; CVSTAG="${1}"; shift ;;
1608 -R | --fetch-build-requires)
1609 FETCH_BUILD_REQUIRES="yes"
1610 NOT_INSTALLED_PACKAGES=
1612 -RB | --remove-build-requires)
1613 REMOVE_BUILD_REQUIRES="nice"
1615 -FRB | --force-remove-build-requires)
1616 REMOVE_BUILD_REQUIRES="force"
1618 -sf | --sources-files)
1619 COMMAND="list-sources-files"
1621 -sp | --sources-paths)
1622 COMMAND="list-sources-local-paths"
1624 -Tvs | --tag-version-stable )
1629 -Tvn | --tag-version-nest )
1634 -Ts | --tag-stable )
1644 -Tv | --tag-version )
1649 -Tp | --tag-prefix )
1661 -ir | --integer-release-only )
1662 INTEGER_RELEASE="yes"
1671 -Upi | --update-poldek-indexes )
1672 UPDATE_POLDEK_INDEXES="yes"
1674 -u | --try-upgrade )
1675 TRY_UPGRADE="1"; shift ;;
1676 -un | --try-upgrade-with-float-version )
1677 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1679 BE_VERBOSE="1"; shift ;;
1685 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1687 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1693 RPMOPTS="${RPMOPTS} --nodeps"
1696 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1699 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1704 if [ -n "$DEBUG" ]; then
1709 if [ -n "$TARGET" ]; then
1712 TARGET_SWITCH="--target $TARGET" ;;
1714 TARGET_SWITCH="--target=$TARGET" ;;
1718 update_shell_title "$COMMAND"
1720 "build" | "build-binary" | "build-source" | "build-prep" )
1722 if [ -n "$SPECFILE" ]; then
1727 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1728 fetch_build_requires;
1730 if [ "$INTEGER_RELEASE" = "yes" ]; then
1731 echo "Checking release $PACKAGE_RELEASE..."
1732 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1733 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1737 if [ -n "$TEST_TAG" ]; then
1738 TAGVER=`make_tagver`
1739 echo "Searching for tag $TAGVER..."
1740 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1741 if [ -n "$TAGREL" ]; then
1742 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1745 # - do not allow to build from HEAD when XX-branch exists
1746 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1747 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1748 TAG_BRANCH="${TREE_PREFIX}-branch"
1749 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1750 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1751 Exit_error err_branch_exists "$TAG_STATUS"
1757 if [ -n "$ICONS" ]; then
1761 if [ -n "$NOSOURCE0" ] ; then
1762 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1764 get_files "$SOURCES $PATCHES";
1766 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1767 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1769 remove_build_requires;
1771 Exit_error err_no_spec_in_cmdl;
1776 if [ -n "$SPECFILE" ]; then
1779 if [ -n "$ICONS" ]; then
1783 get_files $SOURCES $PATCHES;
1784 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1786 Exit_error err_no_spec_in_cmdl;
1791 if [ -n "$SPECFILE" ]; then
1794 if [ -n "$ICONS" ]; then
1795 OLD_UPDATE5=$UPDATE5
1796 UPDATE5= get_files $ICONS
1797 UPDATE5=$OLD_UPDATE5
1800 if [ -n "$NOSOURCE0" ] ; then
1801 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1803 get_files $SOURCES $PATCHES
1805 Exit_error err_no_spec_in_cmdl;
1812 if [ -n "$SPECFILE" ]; then
1815 if [ -n "$ICONS" ]; then
1819 # don't fetch sources from remote locations
1821 for file in $SOURCES
1823 [ -n "`src_md5 $file`" ] && continue
1824 new_SOURCES="$new_SOURCES $file"
1826 SOURCES="$new_SOURCES"
1827 get_files $SOURCES $PATCHES;
1828 tag_files "$SOURCES $PATCHES $ICONS";
1830 Exit_error err_no_spec_in_cmdl;
1834 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1836 "list-sources-files" )
1839 DONT_PRINT_REVISION="yes"
1842 SAPS="$SOURCES $PATCHES"
1843 for SAP in $SAPS ; do
1844 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1847 "list-sources-local-paths" )
1850 DONT_PRINT_REVISION="yes"
1853 SAPS="$SOURCES $PATCHES"
1854 for SAP in $SAPS ; do
1855 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1866 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1867 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1871 # vi:syntax=sh:ts=3:sw=4