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 # let get_files skip over files which are present to get those damn files fetched
90 SKIP_EXISTING_FILES="no"
92 if [ -x /usr/bin/rpm-getdeps ]; then
93 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
95 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
98 # Here we load saved user environment used to
99 # predefine options set above, or passed to builder
101 # This one reads global system environment settings:
102 if [ -f ~/etc/builderrc ]; then
105 # And this one cascades settings using user personal
107 # Example of ~/.builderrc:
109 #UPDATE_POLDEK_INDEXES="yes"
110 #FETCH_BUILD_REQUIRES="yes"
111 #REMOVE_BUILD_REQUIRES="force"
113 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
116 if [ -n "$HOME_ETC" ]; then
117 USER_CFG="$HOME_ETC/.builderrc"
119 USER_CFG=~/.builderrc
122 [ -f "$USER_CFG" ] && . "$USER_CFG"
124 wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
126 if [ -n "$USE_PROZILLA" ]; then
127 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
130 elif [ -n "$USE_AXEL" ]; then
131 GETURI="axel -a $AXEL_OPTS"
135 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
136 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
138 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
139 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
145 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
153 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
154 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
158 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
159 if [ -n "$LOGFILE" ]; then
160 LOG=`eval echo $LOGFILE`
161 if [ -n "$LASTLOG_FILE" ]; then
162 echo "LASTLOG=$LOG" > $LASTLOG_FILE
164 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
167 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
168 return `cat ${RES_FILE}`
173 #---------------------------------------------
178 if [ -n "$DEBUG" ]; then set -xv; fi
180 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
182 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
183 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
184 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
185 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
186 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
187 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
188 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
189 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
190 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
192 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
193 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
194 -n5, --no-md5 - ignore md5 comments in spec
195 -D, --debug - enable builder script debugging mode,
196 -debug - produce rpm debug package (same as --opts -debug)
197 -V, --version - output builder version
198 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
199 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
201 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
202 only package from <package>.spec,
203 -bp, --build-prep - execute the %prep phase of <package>.spec,
204 -bc - reserved (not implemented)
205 -bi reserved (not implemented)
206 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
208 --short-circuit - reserved (not implemented)
209 -B, --branch - add branch
210 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
211 SPECS and \$RPM_BUILD_ROOT),
212 -d <cvsroot>, --cvsroot <cvsroot>
214 --define <macro> <value>
215 - define a macro <macro> with value <value>,
216 --nodeps - rpm won't check any dependences
217 -g, --get - get <package>.spec and all related files from CVS repo
219 -h, --help - this message,
220 --http - use http instead of ftp,
221 -l <logfile>, --logtofile <logfile>
223 -m, --mr-proper - only remove all files related to spec file and all work
225 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
227 - don't check specs in CVS
228 -nd, --no-distfiles - don't download from distfiles
229 -nm, --no-mirrors - don't download from mirror, if source URL is given,
230 -nu, --no-urls - don't try to download from FTP/HTTP location,
231 -ns, --no-srcs - don't download Sources
232 -ns0, --no-source0 - don't download Source0
233 -nn, --no-net - don't download anything from the net
235 --skip-existing-files - skip existing files in get_files
236 --opts <rpm opts> - additional options for rpm
237 -q, --quiet - be quiet,
238 --date yyyy-mm-dd - build package using resources from specified CVS date,
239 -r <cvstag>, --cvstag <cvstag>
240 - build package using resources from specified CVS tag,
241 -R, --fetch-build-requires
242 - fetch what is BuildRequired,
243 -RB, --remove-build-requires
244 - remove all you fetched with -R or --fetch-build-requires
245 remember, this option requires confirmation,
246 -FRB, --force-remove-build-requires
247 - remove all you fetched with -R or --fetch-build-requires
248 remember, this option works without confirmation,
249 -sf, --source-files - list sources - bare filenames (intended for offline
250 operations; does not work when Icon field is present
251 but icon file is absent),
252 -sp, --source-paths - list sources - filenames with full local paths (intended for
253 offline operations; does not work when Icon field is present
254 but icon file is absent),
255 -su, --source-urls - list urls - urls to sources and patches
256 intended for copying urls with spec with lots of macros in urls
257 -T <cvstag> , --tag <cvstag>
258 - add cvs tag <cvstag> for files,
259 -Tvs, --tag-version-stable
260 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
261 -Tvn, --tag-version-nest
262 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
264 - add cvs tag STABLE for files,
266 - add cvs tag NEST for files,
268 - add cvs tag NAME-VERSION-RELEASE for files,
269 -Tp, --tag-prefix <prefix>
270 - add <prefix> to NAME-VERSION-RELEASE tags,
271 -tt, --test-tag <prefix>
272 - fail if tag is already present,
273 -ir, --integer-release-only
274 - allow only integer and snapshot releases
275 -v, --verbose - be verbose,
276 -u, --try-upgrade - check version, and try to upgrade package
277 -un, --try-upgrade-with-float-version
278 - as above, but allow float version
279 -U, --update - refetch sources, don't use distfiles, and update md5 comments
280 -Upi, --update-poldek-indexes
281 - refresh or make poldek package index files.
282 -np, --nopatch <patchnumber>
283 - don't apply <patchnumber>
284 --show-bconds - show available conditional builds, which can be used
285 - with --with and/or --without switches.
286 --with/--without <feature>
287 - conditional build package depending on %_with_<feature>/
288 %_without_<feature> macro switch. You may now use
289 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
290 constructions. Set GROUP_BCONDS to yes to make use of it.
291 --target <platform>, --target=<platform>
292 - build for platform <platform>.
296 update_shell_title() {
298 local len=${COLUMNS:-80}
299 local msg=$(echo "$*" | cut -c-$len)
301 msg="builder[$SPECFILE] ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
304 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
307 echo >&2 -ne "\033]0;$msg\007"
312 # set TARGET from BuildArch: from SPECFILE
314 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
315 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
320 TARGET_SWITCH="--target $TARGET" ;;
322 TARGET_SWITCH="--target=$TARGET" ;;
329 if [ -n "$DEBUG" ]; then
334 update_shell_title "cache_rpm_dump"
338 rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
341 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
344 update_shell_title "cache_rpm_dump: OK!"
348 if [ -z "$rpm_dump_cache" ] ; then
349 echo "internal error: cache_rpm_dump not called!" 1>&2
351 echo "$rpm_dump_cache"
356 update_shell_title "parsing specfile"
357 if [ -n "$DEBUG" ]; then
366 if [ "$NOSRCS" != "yes" ]; then
367 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
369 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
370 FAIL_IF_NO_SOURCES="no"
373 update_shell_title "parse_spec: Patches!"
374 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
375 update_shell_title "parse_spec: Icons!"
376 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
377 update_shell_title "parse_spec: PACKAGE_NAME!"
378 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
379 update_shell_title "parse_spec: PACKAGE_VERSION!"
380 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
381 update_shell_title "parse_spec: PACKAGE_RELEASE!"
382 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
384 # These variables may be unset after first cache_rpm_dump call
385 # (because of not-yet-retrieved icon file)
387 # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
388 # Exit_error err_no_package_data;
391 if [ -n "$BE_VERBOSE" ]; then
392 echo "- Sources : `nourl $SOURCES`"
393 if [ -n "$PATCHES" ]; then
394 echo "- Patches : `nourl $PATCHES`"
396 echo "- Patches : *no patches needed*"
398 if [ -n "$ICONS" ]; then
399 echo "- Icon : `nourl $ICONS`"
401 echo "- Icon : *no package icon*"
403 echo "- Name : $PACKAGE_NAME"
404 echo "- Version : $PACKAGE_VERSION"
405 echo "- Release : $PACKAGE_RELEASE"
408 update_shell_title "parse_spec: OK!"
413 if [ -n "$DEBUG" ]; then
421 "err_no_spec_in_cmdl" )
422 remove_build_requires
423 echo "ERROR: spec file name not specified.";
425 "err_no_spec_in_repo" )
426 remove_build_requires
427 echo "Error: spec file not stored in CVS repo.";
429 "err_no_source_in_repo" )
430 remove_build_requires
431 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
434 remove_build_requires
435 echo "Error: package build failed. (${2:-no more info})";
437 "err_no_package_data" )
438 remove_build_requires
439 echo "Error: couldn't get out package name/version/release from spec file."
442 remove_build_requires
443 echo "Tag ${2} already exists (spec release: ${3}).";
446 remove_build_requires
447 echo "Release ${2} not integer and not a snapshot.";
449 "err_branch_exists" )
450 remove_build_requires
451 echo "Tree branch already exists (${2}).";
455 echo "Unknown error."
461 if [ -n "$DEBUG" ]; then
466 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
467 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
475 update_shell_title "get_spec"
477 if [ -n "$DEBUG" ]; then
483 if [ ! -f "$SPECFILE" ]; then
484 SPECFILE="`basename $SPECFILE .spec`.spec";
486 if [ "$NOCVSSPEC" != "yes" ]; then
488 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
489 echo "Warning: No CVS access defined - using local .spec file"
493 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
496 if [ ! -f "$SPECFILE" ]; then
497 Exit_error err_no_spec_in_repo;
500 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
501 chmod $CHMOD_MODE $SPECFILE
504 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
513 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
514 cvs update mirrors >&2
518 while read origin mirror name rest
520 ol=`echo -n "$origin"|wc -c`
521 prefix="`echo -n "$url" | head -c $ol`"
522 if [ "$prefix" = "$origin" ] ; then
523 suffix="`echo "$url"|cut -b $ol-`"
524 echo -n "$mirror$suffix"
535 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
536 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
542 [ X"$NO5" = X"yes" ] && return
544 [ -z "$no" ] && return
546 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
547 if [ -z "$spec_rev" ]; then
548 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
550 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
551 md5=$(grep -s -v '^#' additional-md5sums | \
552 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
553 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
554 grep -E '^[0-9a-f]{32}$')
555 if [ X"$md5" = X"" ] ; then
556 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
557 if [ ! -z "$source_md5" ] ; then
560 # we have empty SourceX-md5, but it is still possible
561 # that we have NoSourceX-md5 AND NoSource: X
562 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
563 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
568 if [ $(echo "$md5" | wc -l) != 1 ] ; then
569 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
571 echo "$md5" | tail -n 1
577 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
580 distfiles_attic_url ()
582 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
589 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
594 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
595 [ -n "$size" -a "$size" -gt 0 ]
600 if [ "$CVSIGNORE_DF" != "yes" ]; then
603 cvsignore=${SOURCE_DIR}/.cvsignore
604 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
605 echo "$1" >> $cvsignore
611 update_shell_title "cvsup"
613 if [ -n "$CVSROOT" ]; then
614 OPTIONS="-d $CVSROOT $OPTIONS"
617 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
618 OPTIONS="$OPTIONS -A"
620 if [ -n "$CVSDATE" ]; then
621 OPTIONS="$OPTIONS -D $CVSDATE"
623 if [ -n "$CVSTAG" ]; then
624 OPTIONS="$OPTIONS -r $CVSTAG"
629 local retries_counter=0
630 update_shell_title "cvsup: $# files"
631 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
632 retries_counter=$(( $retries_counter + 1 ))
633 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
635 [ -n "$output" ] && echo "$output"
636 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
637 echo "Trying again [$*]... ($retries_counter)"
638 update_shell_title "cvsup: retry #$retries_counter"
645 update_shell_title "cvsup: done!"
651 update_shell_title "fetching sources"
653 if [ -n "$DEBUG" ]; then
658 if [ $# -gt 0 ]; then
661 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
662 echo "Warning: No CVS access defined for SOURCES"
667 local get_files_cvs=""
671 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
672 update_shell_title "$i"
673 local fp=`nourl "$i"`
674 if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then
677 if [ -n "$UPDATE5" ]; then
678 if [ -n "$ADD5" ]; then
679 [ "$fp" = "$i" ] && continue
680 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
682 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
686 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
687 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
688 echo "Warning: no URL given for $i"
691 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
692 if good_md5 "$i" && good_size "$i"; then
693 echo "$(nourl "$i") having proper md5sum already exists"
697 url=$(distfiles_url "$i")
698 url_attic=$(distfiles_attic_url "$i")
700 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
701 update_shell_title "${GETLOCAL%% *}: $url"
702 ${GETLOCAL} $url $target
704 if [ -z "$NOMIRRORS" ]; then
705 url="`find_mirror "$url"`"
707 update_shell_title "${GETURI%% *}: $url"
708 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
709 if [ "`echo $url | grep -E 'ftp://'`" ]; then
710 update_shell_title "${GETURI2%% *}: $url"
711 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
714 if ! test -s "$target"; then
716 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
717 update_shell_title "${GETLOCAL%% *}: $url_attic"
718 ${GETLOCAL} $url_attic $target
720 if [ -z "$NOMIRRORS" ]; then
721 url_attic="`find_mirror "$url_attic"`"
723 update_shell_title "${GETURI%% *}: $url_attic"
724 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
725 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
726 update_shell_title "${GETURI2%% *}: $url_attic"
727 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
731 if test -s "$target"; then
737 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
738 get_files_cvs="$get_files_cvs $fp"
739 # we'll do cvs up later
743 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
744 if [ -z "$NOMIRRORS" ]; then
745 im="`find_mirror "$i"`"
749 update_shell_title "${GETURI%% *}: $im"
751 if [ "`echo $im | grep -E 'ftp://'`" ]; then
752 update_shell_title "${GETURI2%% *}: $im"
757 if [ "$cvsup" = 1 ]; then
763 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
764 Exit_error err_no_source_in_repo $i;
765 elif [ -n "$UPDATE5" ] && \
766 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
767 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
768 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
770 echo "Updating source-$srcno md5."
771 md5=$(md5sum "$fp" | cut -f1 -d' ')
773 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
774 print "# Source'$srcno'-md5:\t'$md5'\n"
775 if /^Source'$srcno'\s*:\s+/;
780 if good_md5 "$i" && good_size "$i"; then
782 elif [ "$FROM_DISTFILES" = 1 ]; then
783 # wrong md5 from distfiles: remove the file and try again
785 echo "MD5 sum mismatch. Trying full fetch."
788 update_shell_title "${GETURI%% *}: $url"
789 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
790 if [ "`echo $url | grep -E 'ftp://'`" ]; then
791 update_shell_title "${GETURI2%% *}: $url"
792 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
794 if ! test -s "$target"; then
796 update_shell_title "${GETURI%% *}: $url_attic"
797 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
798 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
799 update_shell_title "${GETURI2%% *}: $url_attic"
800 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
803 test -s "$target" || rm -f "$target"
806 if good_md5 "$i" && good_size "$i" ; then
809 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
810 echo "or -5 to update md5 sums, if you're sure files are correct."
811 Exit_error err_no_source_in_repo $i
814 SHELL_TITLE_PREFIX=""
816 if [ "$get_files_cvs" ]; then
820 if [ "$CHMOD" = "yes" ]; then
821 CHMOD_FILES="`nourl "$@"`"
822 if [ -n "$CHMOD_FILES" ]; then
823 chmod $CHMOD_MODE $CHMOD_FILES
831 if [ -n "$DEBUG" ]; then
836 # Check whether first character of PACKAGE_NAME is legal for tag name
837 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
840 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"`
841 # Remove #kernel.version_release from TAGVER because tagging sources
842 # could occur with different kernel-headers than kernel-headers used at build time.
843 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
851 if [ -n "$DEBUG" ]; then
856 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
857 echo "Version: $PACKAGE_VERSION"
858 echo "Release: $PACKAGE_RELEASE"
862 if [ "$TAG_VERSION" = "yes" ]; then
863 echo "CVS tag: $TAGVER"
865 if [ -n "$TAG" ]; then
870 if [ -n "$CVSROOT" ]; then
871 OPTIONS="-d $CVSROOT $OPTIONS"
877 # don't tag files stored on distfiles
878 [ -n "`src_md5 $i`" ] && continue
879 if [ -f "`nourl $i`" ]; then
880 if [ "$TAG_VERSION" = "yes" ]; then
881 cvs $OPTIONS $TAGVER `nourl $i`
883 if [ -n "$TAG" ]; then
884 cvs $OPTIONS $TAG `nourl $i`
887 Exit_error err_no_source_in_repo $i
892 if [ "$TAG_VERSION" = "yes" ]; then
893 cvs $OPTIONS $TAGVER $SPECFILE
895 if [ -n "$TAG" ]; then
896 cvs $OPTIONS $TAG $SPECFILE
906 echo "CVS branch tag: $TAG"
911 if [ -n "$DEBUG" ]; then
916 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
919 if [ -n "$CVSROOT" ]; then
920 OPTIONS="-d $CVSROOT $OPTIONS"
925 if [ -f `nourl $i` ]; then
926 cvs $OPTIONS $TAG `nourl $i`
928 Exit_error err_no_source_in_repo $i
932 cvs $OPTIONS $TAG $SPECFILE
942 update_shell_title "build_package"
943 if [ -n "$DEBUG" ]; then
950 if [ -n "$TRY_UPGRADE" ]; then
951 update_shell_title "build_package: try_upgrade"
952 if [ -n "$FLOAT_VERSION" ]; then
953 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
955 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
958 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
960 if [ -n "$TNEWVER" ]; then
961 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
962 echo "New version found, updating spec file to version " $TNEWVER
963 cp -f $SPECFILE $SPECFILE.bak
965 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
966 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
968 if [ -n "$ICONS" ]; then
972 NODIST="yes" UPDATE5="yes" get_files "$SOURCES $PATCHES";
973 unset TOLDVER TNEWVER TNOTIFY
980 BUILD_SWITCH="-ba" ;;
982 BUILD_SWITCH="-bb" ;;
984 BUILD_SWITCH="-bs --nodeps" ;;
986 BUILD_SWITCH="-bp --nodeps" ;;
989 update_shell_title "build_package: $COMMAND"
990 if [ -n "$LOGFILE" ]; then
991 LOG=`eval echo $LOGFILE`
992 if [ -d "$LOG" ]; then
993 echo "Log file $LOG is a directory."
994 echo "Parse error in the spec?"
995 Exit_error err_build_fail;
997 if [ -n "$LASTLOG_FILE" ]; then
998 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1000 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1001 (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
1002 RETVAL=`cat $RES_FILE`
1004 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1005 if [ "$RETVAL" -eq "0" ]; then
1012 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
1015 if [ "$RETVAL" -ne "0" ]; then
1016 if [ -n "$TRY_UPGRADE" ]; then
1017 echo "\n!!! Package with new version cannot be build automagically\n"
1018 mv -f $SPECFILE.bak $SPECFILE
1020 Exit_error err_build_fail;
1027 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1030 install_required_packages()
1038 update_shell_title "set bcond values"
1040 AVAIL_BCONDS_WITHOUT=""
1041 AVAIL_BCONDS_WITH=""
1042 if `grep -q ^%bcond ${SPECFILE}`; then
1044 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1047 BCOND_VERSION="NONE"
1050 # expand bconds from ~/.bcondrc
1051 # The file structure is like gentoo's package.use:
1054 # samba -mysql -pgsql
1055 # w32codec-installer license_agreement
1058 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
1059 # This takes package name, first defined in spec.
1060 # so consider that when defining flags for package.
1061 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
1062 SN=${SPECFILE%%\.spec}
1063 AVAIL=`$RPMBUILD --bcond $SPECFILE`
1065 BCONDRC=$HOME/.bcondrc
1066 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
1068 while read pkg flags; do
1070 [[ "$pkg" == \#* ]] && continue
1072 # any package or current package?
1073 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ] || [ "$pkg" = "$SN" ]; then
1074 for flag in $flags; do
1077 # use only flags which are in this package.
1078 if [[ $AVAIL = *${opt}* ]]; then
1079 if [[ $flag = -* ]]; then
1080 BCOND="$BCOND --without $opt"
1082 BCOND="$BCOND --with $opt"
1090 case "${BCOND_VERSION}" in
1095 echo "Warning: This spec has old style bconds. Fix it || die."
1096 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1098 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1099 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1100 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1102 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1106 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1108 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1109 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1110 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1112 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1117 cond_type="" # with || without
1118 for opt in `$RPMBUILD --bcond $SPECFILE`
1128 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1129 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1130 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1132 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1136 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1137 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1138 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1140 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1144 case "$cond_type" in
1147 AVAIL_BCOND_WITH="$opt"
1148 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1149 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1151 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1156 AVAIL_BCOND_WITHOUT="$opt"
1157 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1158 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1160 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1174 update_shell_title "run_sub_builder $package_name"
1176 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1177 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1178 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1179 # jakby nie bylo tego kawalka kodu.
1181 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1182 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1189 # Istnieje taki spec? ${package}.spec
1190 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1191 parent_spec_name=${package}.spec
1192 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1193 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1195 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1201 if [ "${parent_spec_name}" != "" ]; then
1202 spawn_sub_builder $parent_spec_name
1204 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1210 update_shell_title "spawn_sub_builder $package_name"
1213 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1214 sub_builder_opts="${sub_builder_opts} -R"
1216 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1217 sub_builder_opts="${sub_builder_opts} -RB"
1218 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1219 sub_builder_opts="${sub_builder_opts} -FRB"
1221 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1222 sub_builder_opts="${sub_builder_opts} -Upi"
1226 ./builder ${sub_builder_opts} "$@"
1229 remove_build_requires()
1231 if [ "$INSTALLED_PACKAGES" != "" ]; then
1232 case "$REMOVE_BUILD_REQUIRES" in
1234 run_poldek --noask -ve $INSTALLED_PACKAGES
1237 run_poldek --ask -ve $INSTALLED_PACKAGES
1240 echo You may want to manually remove following BuildRequires fetched:
1241 echo $INSTALLED_PACKAGES
1242 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1250 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1251 if [ "$BCOND" != "" ]; then
1252 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1255 echo -ne "\nNo conditional flags passed"
1257 echo -ne "\n\nfrom available:\n"
1258 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1264 if [ "$NOCVSSPEC" != "yes" ]; then
1265 echo -ne "Available branches: "
1266 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1270 # checks a given list of packages/files/provides agains current rpmdb.
1271 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1272 # input can be either STDIN or parameters
1277 if [ "$#" -gt 0 ]; then
1283 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1286 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1288 # other deps (files)
1289 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1292 # checks if given package/files/provides exists in rpmdb.
1293 # inout can be either stdin or parameters
1294 # returns packages wchi hare present in the rpmdb
1299 if [ "$#" -gt 0 ]; then
1305 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1308 fetch_build_requires()
1310 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1311 update_shell_title "fetch build requires"
1312 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1313 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1314 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1316 update_shell_title "poldek: update indexes"
1317 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1318 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1320 if [ -n "$CONF" ]; then
1321 update_shell_title "uninstall conflicting packages: $CONF"
1322 echo "Trying to uninstall conflicting packages ($CONF):"
1323 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1326 while [ "$DEPS" ]; do
1327 update_shell_title "install deps: $DEPS"
1328 echo "Trying to install dependencies ($DEPS):"
1329 local log=.${SPECFILE}_poldek.log
1330 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1331 failed=$(awk -F: '/^error:/{print $2}' $log)
1334 if [ -n "$failed" ]; then
1335 for package in $failed; do
1336 # FIXME: sanitise, deps could be not .spec files
1337 spawn_sub_builder -bb $package && ok="$ok $package"
1347 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1348 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1349 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1350 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1351 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1352 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`
1354 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`"
1356 package=`basename "$package_item"|sed -e "s/}$//g"`
1357 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1360 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1361 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1362 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
1367 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1370 if `echo $COND_TST|grep -q 'without_'`; then
1371 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1372 if `echo $COND_TST|grep -q !`; then
1377 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1378 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1379 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1385 elif `echo $COND_TST|grep -q 'with_'`; then
1386 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1387 if `echo $COND_TST|grep -q !`; then
1392 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1393 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1394 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1400 RESULT="${COND_STATE}-${COND_ARGV}"
1402 "with-wout" | "wout-with" )
1405 "wout-wout" | "with-with" )
1409 echo "Action '$RESULT' was not defined for package '$package_item'"
1415 if [ "$GO" = "yes" ]; then
1416 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1417 echo "Testing if $package has subrequirements..."
1418 run_poldek -t -i $package --dumpn=".$package-req.txt"
1419 if [ -f ".$package-req.txt" ]; then
1420 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1422 if [ "$package_name" = "$package" ]; then
1423 echo -ne "Installing BuildRequired package:\t$package_name\n"
1424 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1425 install_required_packages $package;
1427 echo -ne "Installing (sub)Required package:\t$package_name\n"
1428 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1429 install_required_packages $package_name;
1433 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1434 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1437 echo "Attempting to run spawn sub - builder..."
1438 echo -ne "Package installation failed:\t$package_name\n"
1439 run_sub_builder $package_name
1440 if [ $? -eq 0 ]; then
1441 install_required_packages $package_name;
1444 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1445 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1448 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1455 rm -f ".$package-req.txt"
1457 echo "Attempting to run spawn sub - builder..."
1458 echo -ne "Package installation failed:\t$package\n"
1459 run_sub_builder $package
1460 if [ $? -eq 0 ]; then
1461 install_required_packages $package;
1464 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1465 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1468 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1474 echo "Package $package is already installed. BuildRequirement satisfied."
1478 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1479 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1480 echo "Unable to install following packages and their dependencies:"
1481 for pkg in "$NOT_INSTALLED_PACKAGES"
1485 remove_build_requires
1491 #---------------------------------------------
1494 if [ "$#" = 0 ]; then
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 ;;
1549 -ske | --skip-existing-files)
1550 SKIP_EXISTING_FILES="yes"; shift ;;
1552 COMMAND="mr-proper"; shift ;;
1554 NOCVS="yes"; shift ;;
1555 -ncs | --no-cvs-specs )
1556 NOCVSSPEC="yes"; shift ;;
1557 -nd | --no-distfiles )
1558 NODIST="yes"; shift ;;
1559 -nm | --no-mirrors )
1560 NOMIRRORS="yes"; shift ;;
1562 NOURLS="yes"; shift ;;
1564 NOSRCS="yes"; shift ;;
1565 -ns0 | --no-source0 )
1566 NOSOURCE0="yes"; shift ;;
1577 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1579 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1580 --with | --without )
1581 case $GROUP_BCONDS in
1585 while ! `echo ${1}|grep -qE '(^-|spec)'`
1587 BCOND="$BCOND $COND $1"
1591 if [[ "$2" = *,* ]]; then
1592 for a in $(echo "$2" | tr , ' '); do
1593 BCOND="$BCOND $1 $a"
1596 BCOND="$BCOND $1 $2"
1602 shift; TARGET="${1}"; shift ;;
1604 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1606 QUIET="--quiet"; shift ;;
1608 CVSDATE="${2}"; shift 2 ;;
1610 shift; CVSTAG="${1}"; shift ;;
1611 -R | --fetch-build-requires)
1612 FETCH_BUILD_REQUIRES="yes"
1613 NOT_INSTALLED_PACKAGES=
1615 -RB | --remove-build-requires)
1616 REMOVE_BUILD_REQUIRES="nice"
1618 -FRB | --force-remove-build-requires)
1619 REMOVE_BUILD_REQUIRES="force"
1621 -sf | --sources-files)
1622 COMMAND="list-sources-files"
1624 -sp | --sources-paths)
1625 COMMAND="list-sources-local-paths"
1627 -su | --sources-urls)
1628 COMMAND="list-sources-urls"
1630 -Tvs | --tag-version-stable )
1635 -Tvn | --tag-version-nest )
1640 -Ts | --tag-stable )
1650 -Tv | --tag-version )
1655 -Tp | --tag-prefix )
1667 -ir | --integer-release-only )
1668 INTEGER_RELEASE="yes"
1677 -Upi | --update-poldek-indexes )
1678 UPDATE_POLDEK_INDEXES="yes"
1680 -u | --try-upgrade )
1681 TRY_UPGRADE="1"; shift ;;
1682 -un | --try-upgrade-with-float-version )
1683 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1685 BE_VERBOSE="1"; shift ;;
1691 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1693 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1699 RPMOPTS="${RPMOPTS} --nodeps"
1702 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1705 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1710 if [ -n "$DEBUG" ]; then
1715 if [ -n "$TARGET" ]; then
1718 TARGET_SWITCH="--target $TARGET" ;;
1720 TARGET_SWITCH="--target=$TARGET" ;;
1724 update_shell_title "$COMMAND"
1726 "build" | "build-binary" | "build-source" | "build-prep" )
1728 if [ -n "$SPECFILE" ]; then
1733 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1734 fetch_build_requires;
1736 if [ "$INTEGER_RELEASE" = "yes" ]; then
1737 echo "Checking release $PACKAGE_RELEASE..."
1738 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1739 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1743 if [ -n "$TEST_TAG" ]; then
1744 TAGVER=`make_tagver`
1745 echo "Searching for tag $TAGVER..."
1746 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1747 if [ -n "$TAGREL" ]; then
1748 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1751 # - do not allow to build from HEAD when XX-branch exists
1752 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1753 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1754 TAG_BRANCH="${TREE_PREFIX}-branch"
1755 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1756 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1757 Exit_error err_branch_exists "$TAG_STATUS"
1763 if [ -n "$ICONS" ]; then
1767 if [ -n "$NOSOURCE0" ] ; then
1768 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1770 get_files "$SOURCES $PATCHES";
1772 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1773 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1775 remove_build_requires;
1777 Exit_error err_no_spec_in_cmdl;
1782 if [ -n "$SPECFILE" ]; then
1785 if [ -n "$ICONS" ]; then
1789 get_files $SOURCES $PATCHES;
1790 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1792 Exit_error err_no_spec_in_cmdl;
1797 if [ -n "$SPECFILE" ]; then
1800 if [ -n "$ICONS" ]; then
1801 OLD_UPDATE5=$UPDATE5
1802 UPDATE5= get_files $ICONS
1803 UPDATE5=$OLD_UPDATE5
1806 if [ -n "$NOSOURCE0" ] ; then
1807 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1809 get_files $SOURCES $PATCHES
1811 Exit_error err_no_spec_in_cmdl;
1818 if [ -n "$SPECFILE" ]; then
1821 if [ -n "$ICONS" ]; then
1825 # don't fetch sources from remote locations
1827 for file in $SOURCES
1829 [ -n "`src_md5 $file`" ] && continue
1830 new_SOURCES="$new_SOURCES $file"
1832 SOURCES="$new_SOURCES"
1833 get_files $SOURCES $PATCHES;
1834 tag_files "$SOURCES $PATCHES $ICONS";
1836 Exit_error err_no_spec_in_cmdl;
1840 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1842 "list-sources-files" )
1845 DONT_PRINT_REVISION="yes"
1848 SAPS="$SOURCES $PATCHES"
1849 for SAP in $SAPS ; do
1850 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1853 "list-sources-urls" )
1856 DONT_PRINT_REVISION="yes"
1859 SAPS="$SOURCES $PATCHES"
1860 for SAP in $SAPS ; do
1864 "list-sources-local-paths" )
1867 DONT_PRINT_REVISION="yes"
1870 SAPS="$SOURCES $PATCHES"
1871 for SAP in $SAPS ; do
1872 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1880 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1881 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1885 # vi:syntax=sh:ts=4:sw=4