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 v0.18 (C) 1999-2007 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!
76 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
77 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
83 CVS_SERVER="cvs.pld-linux.org"
84 DISTFILES_SERVER="://distfiles.pld-linux.org"
85 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
90 FAIL_IF_NO_SOURCES="yes"
92 # let get_files skip over files which are present to get those damn files fetched
93 SKIP_EXISTING_FILES="no"
96 # should the specfile be restored if upgrade failed?
97 REVERT_BROKEN_UPGRADE="yes"
99 if [ -x /usr/bin/rpm-getdeps ]; then
100 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
102 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
105 # Here we load saved user environment used to
106 # predefine options set above, or passed to builder
108 # This one reads global system environment settings:
109 if [ -f ~/etc/builderrc ]; then
112 # And this one cascades settings using user personal
114 # Example of ~/.builderrc:
116 #UPDATE_POLDEK_INDEXES="yes"
117 #FETCH_BUILD_REQUIRES="yes"
118 #REMOVE_BUILD_REQUIRES="force"
120 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
124 if [ -n "$HOME_ETC" ]; then
125 USER_CFG="$HOME_ETC/.builderrc"
127 USER_CFG=~/.builderrc
130 [ -f "$USER_CFG" ] && . "$USER_CFG"
132 if [ "$SCHEDTOOL" = "auto" ]; then
133 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
134 SCHEDTOOL="schedtool -B -e"
140 if [ -n "$USE_PROZILLA" ]; then
141 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
144 elif [ -n "$USE_AXEL" ]; then
145 GETURI="axel -a $AXEL_OPTS"
149 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
150 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
151 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
153 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
154 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
160 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
168 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
169 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
173 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
174 if [ -n "$LOGFILE" ]; then
175 LOG=`eval echo $LOGFILE`
176 if [ -n "$LASTLOG_FILE" ]; then
177 echo "LASTLOG=$LOG" > $LASTLOG_FILE
179 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
182 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
183 return `cat ${RES_FILE}`
188 #---------------------------------------------
193 if [ -n "$DEBUG" ]; then set -xv; fi
195 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
196 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
197 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
198 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
199 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
200 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
201 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
202 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
203 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
204 <package>[.spec][:cvstag]
206 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
207 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
208 -n5, --no-md5 - ignore md5 comments in spec
209 -D, --debug - enable builder script debugging mode,
210 -debug - produce rpm debug package (same as --opts -debug)
211 -V, --version - output builder version
212 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
213 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
215 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
216 only package from <package>.spec,
217 -bp, --build-prep - execute the %prep phase of <package>.spec,
218 -bc - execute the %build phase of <package>.spec,
219 -bi - execute the %install phase of <package>.spec
220 -bl - execute the %files phase of <package>.spec
221 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
223 --short-circuit - short-circuit build
224 -B, --branch - add branch
225 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
226 SPECS and \$RPM_BUILD_ROOT),
227 -cf, --cvs-force - use -F when tagging (useful when moving branches)
228 -d <cvsroot>, --cvsroot <cvsroot>
230 --define <macro> <value>
231 - define a macro <macro> with value <value>,
232 --nodeps - rpm won't check any dependences
233 -g, --get - get <package>.spec and all related files from CVS repo
235 -h, --help - this message,
236 --http - use http instead of ftp,
237 -l <logfile>, --logtofile <logfile>
239 -m, --mr-proper - only remove all files related to spec file and all work
241 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
243 - don't check specs in CVS
244 -nd, --no-distfiles - don't download from distfiles
245 -nm, --no-mirrors - don't download from mirror, if source URL is given,
246 -nu, --no-urls - don't try to download from FTP/HTTP location,
247 -ns, --no-srcs - don't download Sources
248 -ns0, --no-source0 - don't download Source0
249 -nn, --no-net - don't download anything from the net
250 --no-init - don't initialize builder paths (SPECS and SOURCES)
252 --skip-existing-files - skip existing files in get_files
253 --opts <rpm opts> - additional options for rpm
254 -q, --quiet - be quiet,
255 --date yyyy-mm-dd - build package using resources from specified CVS date,
256 -r <cvstag>, --cvstag <cvstag>
257 - build package using resources from specified CVS tag,
258 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
259 -R, --fetch-build-requires
260 - fetch what is BuildRequired,
261 -RB, --remove-build-requires
262 - remove all you fetched with -R or --fetch-build-requires
263 remember, this option requires confirmation,
264 -FRB, --force-remove-build-requires
265 - remove all you fetched with -R or --fetch-build-requires
266 remember, this option works without confirmation,
267 -sd, --source-distfiles - list sources available from distfiles (intended for offline
268 operations; does not work when Icon field is present
269 but icon file is absent),
270 -sdp, --source-distfiles-paths - list sources available from distfiles -
271 paths relative to distfiles directory (intended for offline
272 operations; does not work when Icon field is present
273 but icon file is absent),
274 -sf, --source-files - list sources - bare filenames (intended for offline
275 operations; does not work when Icon field is present
276 but icon file is absent),
277 -sp, --source-paths - list sources - filenames with full local paths (intended for
278 offline operations; does not work when Icon field is present
279 but icon file is absent),
280 -su, --source-urls - list urls - urls to sources and patches
281 intended for copying urls with spec with lots of macros in urls
282 -T <cvstag> , --tag <cvstag>
283 - add cvs tag <cvstag> for files,
284 -Tvs, --tag-version-stable
285 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
287 - add cvs tag STABLE for files,
289 - add cvs tag NAME-VERSION-RELEASE for files,
290 -Tp, --tag-prefix <prefix>
291 - add <prefix> to NAME-VERSION-RELEASE tags,
292 -tt, --test-tag <prefix>
293 - fail if tag is already present,
294 -ir, --integer-release-only
295 - allow only integer and snapshot releases
296 -v, --verbose - be verbose,
297 -u, --try-upgrade - check version, and try to upgrade package
298 -un, --try-upgrade-with-float-version
299 - as above, but allow float version
300 -U, --update - refetch sources, don't use distfiles, and update md5 comments
301 -Upi, --update-poldek-indexes
302 - refresh or make poldek package index files.
303 -np, --nopatch <patchnumber>
304 - don't apply <patchnumber>
305 --show-bconds - show available conditional builds, which can be used
306 - with --with and/or --without switches.
307 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
308 ./repackage.sh script. in other words, the output is
309 parseable by scripts.
310 --with/--without <feature>
311 - conditional build package depending on %_with_<feature>/
312 %_without_<feature> macro switch. You may now use
313 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
314 constructions. Set GROUP_BCONDS to yes to make use of it.
315 --target <platform>, --target=<platform>
316 - build for platform <platform>.
317 --init-rpm-dir - initialize ~/rpm directory structure
321 update_shell_title() {
323 local len=${COLUMNS:-80}
324 local msg=$(echo "$*" | cut -c-$len)
326 if [ -n "$BE_VERBOSE" ]; then
327 echo >&2 "$(date +%s.%N) $*"
330 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
332 if [ -n "$PACKAGE_NAME" ]; then
333 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
338 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
339 msg="$(echo $msg | tr -d '\n\r')"
342 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
345 echo >&2 -ne "\033]0;$msg\007"
351 # set TARGET from BuildArch: from SPECFILE
353 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
354 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
356 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
360 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
362 TARGET_SWITCH="--target=$TARGET" ;;
369 if [ -n "$DEBUG" ]; then
374 update_shell_title "cache_rpm_dump"
378 # we reset macros not to contain macros.build as all the %() macros are
379 # executed here, while none of them are actually needed.
380 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
381 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
382 macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.builder-rpmmacros:~/etc/.rpmmacros:~/.rpmmacros"
383 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
384 if [ -f /usr/lib/rpm/rpmrc ]; then
385 # FIXME: better ideas than .rpmrc?
386 printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .builder-rpmrc
388 printf 'macrofiles:%s\n' $macrofiles > .builder-rpmrc
390 # TODO: move these to /usr/lib/rpm/macros
391 cat > .builder-rpmmacros <<'EOF'
394 %requires_releq_kernel_up %{nil}
395 %requires_releq_kernel_smp %{nil}
396 %requires_releq() %{nil}
397 %pyrequires_eq() %{nil}
398 %requires_eq() %{nil}
399 %requires_eq_to() %{nil}
400 %releq_kernel_up ERROR
401 %releq_kernel_smp ERROR
405 %ruby_ver_requires_eq() %{nil}
406 %ruby_mod_ver_requires_eq() %{nil}
407 %__php_api_requires() %{nil}
408 %php_major_version ERROR
409 %php_api_version ERROR
411 %perl_vendorarch ERROR
412 %perl_vendorlib ERROR
413 # damn. need it here! - copied from /usr/lib/rpm/macros.build
414 %tmpdir %(echo "${TMPDIR:-/tmp}")
415 %patchset_source(f:b:) %(
416 base=%{-b*}%{!-b*:10000};
417 start=$(expr $base + %1);
418 end=$(expr $base + %{?2}%{!?2:%{1}});
419 # we need to call seq twice as it doesn't allow two formats
420 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
421 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
422 paste %{tmpdir}/__ps{1,2};
423 rm -f %{tmpdir}/__ps{1,2};
432 ARGS='--nodigest --nosignature --nobuild'
435 if [ "$NOINIT" = "yes" ] ; then
436 cat >> .builder-rpmmacros <<'EOF'
441 $RPMBUILD --rcfile .builder-rpmrc $ARGS $ARGDIRS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
443 if [ $? -gt 0 ]; then
444 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
446 Exit_error err_build_fail
449 # make small dump cache
450 rpm_dump_cache=`echo "$rpm_dump" | awk '
451 $2 ~ /^SOURCEURL/ {print}
452 $2 ~ /^PATCHURL/ {print}
453 $2 ~ /^nosource/ {print}
454 $2 ~ /^PACKAGE_/ {print}
457 update_shell_title "cache_rpm_dump: OK!"
461 if [ -z "$rpm_dump_cache" ] ; then
462 echo "internal error: cache_rpm_dump not called! (missing %prep?)" 1>&2
464 echo "$rpm_dump_cache"
469 update_shell_title "get icons"
470 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
471 if [ -z "$ICONS" ]; then
475 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
480 update_shell_title "parsing specfile"
481 if [ -n "$DEBUG" ]; then
486 # icons are needed for successful spec parse
492 if [ "$NOSRCS" != "yes" ]; then
493 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
496 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
497 FAIL_IF_NO_SOURCES="no"
500 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
501 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
502 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
503 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
504 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
506 if [ -n "$BE_VERBOSE" ]; then
507 echo "- Sources : `nourl $SOURCES`"
508 if [ -n "$PATCHES" ]; then
509 echo "- Patches : `nourl $PATCHES`"
511 echo "- Patches : *no patches needed*"
513 if [ -n "$ICONS" ]; then
514 echo "- Icon : `nourl $ICONS`"
516 echo "- Icon : *no package icon*"
518 echo "- Name : $PACKAGE_NAME"
519 echo "- Version : $PACKAGE_VERSION"
520 echo "- Release : $PACKAGE_RELEASE"
523 update_shell_title "parse_spec: OK!"
528 if [ -n "$DEBUG" ]; then
536 "err_no_spec_in_cmdl" )
537 remove_build_requires
538 echo "ERROR: spec file name not specified."
540 "err_invalid_cmdline" )
541 echo "ERROR: invalid command line arg ($2)."
543 "err_no_spec_in_repo" )
544 remove_build_requires
545 echo "Error: spec file not stored in CVS repo."
547 "err_no_source_in_repo" )
548 remove_build_requires
549 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)"
552 remove_build_requires
553 echo "Error: package build failed. (${2:-no more info})"
555 "err_no_package_data" )
556 remove_build_requires
557 echo "Error: couldn't get out package name/version/release from spec file."
560 remove_build_requires
561 echo "Tag ${2} already exists (spec release: ${3})."
564 remove_build_requires
565 echo "Release ${2} not integer and not a snapshot."
567 "err_branch_exists" )
568 remove_build_requires
569 echo "Tree branch already exists (${2})."
572 remove_build_requires
573 echo "Error: conditions reject building this spec (${2})."
577 echo "Unknown error."
583 if [ -n "$DEBUG" ]; then
588 if [ "$NOINIT" != "yes" ] ; then
589 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
590 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
602 update_shell_title "get_spec"
604 if [ -n "$DEBUG" ]; then
610 if [ ! -f "$SPECFILE" ]; then
611 SPECFILE="`basename $SPECFILE .spec`.spec"
613 if [ "$NOCVSSPEC" != "yes" ]; then
615 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
616 echo "Warning: No CVS access defined - using local .spec file"
620 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
623 if [ ! -f "$SPECFILE" ]; then
624 Exit_error err_no_spec_in_repo
627 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
628 chmod $CHMOD_MODE $SPECFILE
631 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
640 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
641 cvs update mirrors >&2
645 local origin mirror name rest ol prefix
646 while read origin mirror name rest; do
647 # skip comments and empty lines
648 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
651 ol=`echo -n "$origin"|wc -c`
652 prefix="`echo -n "$url" | head -c $ol`"
653 if [ "$prefix" = "$origin" ] ; then
654 suffix="`echo "$url"|cut -b $((ol+1))-`"
655 echo -n "$mirror$suffix"
662 # Warning: unpredictable results if same URL used twice
667 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
668 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
674 [ "$NO5" = "yes" ] && return
676 [ -z "$no" ] && return
680 if [ -f additional-md5sums ]; then
681 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
682 if [ -z "$spec_rev" ]; then
683 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
685 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
686 md5=$(grep -s -v '^#' additional-md5sums | \
687 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
688 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
689 grep -E '^[0-9a-f]{32}$')
692 if [ $(echo "$md5" | wc -l) != 1 ] ; then
693 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
695 echo "$md5" | tail -n 1
700 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
701 if [ -n "$source_md5" ]; then
704 # we have empty SourceX-md5, but it is still possible
705 # that we have NoSourceX-md5 AND NoSource: X
706 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
707 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
715 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
720 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
723 distfiles_attic_url ()
725 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
732 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
737 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
738 [ -n "$size" -a "$size" -gt 0 ]
743 if [ "$CVSIGNORE_DF" != "yes" ]; then
746 cvsignore=${SOURCE_DIR}/.cvsignore
747 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
748 echo "$1" >> $cvsignore
754 update_shell_title "cvsup"
756 if [ -n "$CVSROOT" ]; then
757 OPTIONS="-d $CVSROOT $OPTIONS"
760 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
761 OPTIONS="$OPTIONS -A"
763 if [ -n "$CVSDATE" ]; then
764 OPTIONS="$OPTIONS -D $CVSDATE"
766 if [ -n "$CVSTAG" ]; then
767 OPTIONS="$OPTIONS -r $CVSTAG"
772 local retries_counter=0
774 update_shell_title "cvsup: $*"
776 update_shell_title "cvsup: $# files"
778 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
779 retries_counter=$(( $retries_counter + 1 ))
780 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
782 [ -n "$output" ] && echo "$output"
783 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
784 echo "Trying again [$*]... ($retries_counter)"
785 update_shell_title "cvsup: retry #$retries_counter"
792 update_shell_title "cvsup: done!"
796 # returns true if "$1" is ftp, http or https protocol url
800 ftp://*|http://*|https://*)
809 if [ $# -eq 0 ]; then
813 update_shell_title "update md5"
814 if [ -n "$DEBUG" ]; then
821 # pass 1: check files to be fetched
825 local fp=$(nourl "$i")
826 local srcno=$(src_no "$i")
827 if [ -n "$ADD5" ]; then
828 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
829 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
831 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
833 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
834 need_files="$need_files $i"
838 # pass 1a: get needed files
839 if [ "$need_files" ]; then
840 get_files $need_files
843 # pass 2: proceed with md5 adding or updating
845 local fp=$(nourl "$i")
846 local srcno=$(src_no "$i")
847 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
848 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
849 local tag="Source$srcno-md5"
850 if [[ "$md5" == *NoSource* ]]; then
851 tag="NoSource$srcno-md5"
853 md5=$(md5sum "$fp" | cut -f1 -d' ')
854 echo "Updating $tag ($md5: $fp)."
856 print unless /^\s*#\s*(No)?Source'$srcno'-md5\s*:/i;
857 print "# '$tag':\t'$md5'\n" if /^Source'$srcno'\s*:\s+/;
866 update_shell_title "check md5"
869 if good_md5 "$i" && good_size "$i"; then
873 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
874 echo "or -5 to update md5 sums, if you're sure files are correct."
875 Exit_error err_no_source_in_repo $i
881 update_shell_title "get_files"
883 if [ -n "$DEBUG" ]; then
888 if [ $# -gt 0 ]; then
891 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
892 echo "Warning: No CVS access defined for SOURCES"
897 local get_files_cvs=""
901 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
902 update_shell_title "$i"
903 local fp=`nourl "$i"`
904 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
909 local srcmd5=$(src_md5 "$i")
911 # we know if source/patch is present in cvs/distfiles
912 # - has md5 (in distfiles)
915 # CHECK: local file didn't exist or always cvs up (first) requested.
916 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
917 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
918 echo "Warning: no URL given for $i"
921 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
922 if good_md5 "$i" && good_size "$i"; then
923 echo "$fp having proper md5sum already exists"
928 # prefer mirror over distfiles if there's mirror
929 # TODO: build url list and then try each url from the list
930 if [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
933 url=$(distfiles_url "$i")
936 url_attic=$(distfiles_attic_url "$i")
938 # is $url local file?
939 if [[ "$url" = [./]* ]]; then
940 update_shell_title "${GETLOCAL%% *}: $url"
941 ${GETLOCAL} $url $target
943 if [ -z "$NOMIRRORS" ]; then
944 url=$(find_mirror "$url")
948 # make shorter message for distfiles urls
949 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
950 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
951 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
954 update_shell_title "${GETURI%% *}: $uri"
955 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
956 if [ "`echo $url | grep -E 'ftp://'`" ]; then
957 update_shell_title "${GETURI2%% *}: $url"
958 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
963 if [ ! -s "$target" ]; then
965 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
966 update_shell_title "${GETLOCAL%% *}: $url_attic"
967 ${GETLOCAL} $url_attic $target
969 if [ -z "$NOMIRRORS" ]; then
970 url_attic="`find_mirror "$url_attic"`"
972 update_shell_title "${GETURI%% *}: $url_attic"
973 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
974 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
975 update_shell_title "${GETURI2%% *}: $url_attic"
976 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
981 if [ -s "$target" ]; then
987 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
988 if [ $# -gt 1 ]; then
989 get_files_cvs="$get_files_cvs $fp"
990 update_shell_title "$fp (will cvs up later)"
997 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
998 if [ -z "$NOMIRRORS" ]; then
999 im="`find_mirror "$i"`"
1003 update_shell_title "${GETURI%% *}: $im"
1004 ${GETURI} "$im" || \
1005 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1006 update_shell_title "${GETURI2%% *}: $im"
1011 if [ "$cvsup" = 1 ]; then
1017 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1018 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1019 Exit_error err_no_source_in_repo $i
1022 # we check md5 here just only to refetch immediately
1023 if good_md5 "$i" && good_size "$i"; then
1025 elif [ "$FROM_DISTFILES" = 1 ]; then
1026 # wrong md5 from distfiles: remove the file and try again
1028 echo "MD5 sum mismatch. Trying full fetch."
1031 update_shell_title "${GETURI%% *}: $url"
1032 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1033 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1034 update_shell_title "${GETURI2%% *}: $url"
1035 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1037 if [ ! -s "$target" ]; then
1039 update_shell_title "${GETURI%% *}: $url_attic"
1040 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1041 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1042 update_shell_title "${GETURI2%% *}: $url_attic"
1043 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1046 test -s "$target" || rm -f "$target"
1049 SHELL_TITLE_PREFIX=""
1051 if [ "$get_files_cvs" ]; then
1052 cvsup $get_files_cvs
1055 if [ "$CHMOD" = "yes" ]; then
1056 CHMOD_FILES="`nourl "$@"`"
1057 if [ -n "$CHMOD_FILES" ]; then
1058 chmod $CHMOD_MODE $CHMOD_FILES
1065 if [ -n "$DEBUG" ]; then
1070 # Check whether first character of PACKAGE_NAME is legal for tag name
1071 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1074 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"`
1075 # Remove #kernel.version_release from TAGVER because tagging sources
1076 # could occur with different kernel-headers than kernel-headers used at build time.
1077 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
1085 if [ -n "$DEBUG" ]; then
1090 echo "Version: $PACKAGE_VERSION"
1091 echo "Release: $PACKAGE_RELEASE"
1093 TAGVER=`make_tagver`
1095 if [ "$TAG_VERSION" = "yes" ]; then
1096 echo "CVS tag: $TAGVER"
1098 if [ -n "$TAG" ]; then
1099 echo "CVS tag: $TAG"
1102 local OPTIONS="tag $CVS_FORCE"
1103 if [ -n "$CVSROOT" ]; then
1104 OPTIONS="-d $CVSROOT $OPTIONS"
1109 for i in $TAG_FILES; do
1110 # don't tag files stored on distfiles
1111 [ -n "`src_md5 $i`" ] && continue
1112 local fp=`nourl "$i"`
1113 if [ -f "$fp" ]; then
1114 tag_files="$tag_files $fp"
1116 Exit_error err_no_source_in_repo $i
1120 if [ "$tag_files" ]; then
1121 if [ "$TAG_VERSION" = "yes" ]; then
1122 update_shell_title "tag sources: $TAGVER"
1123 cvs $OPTIONS $TAGVER $tag_files
1125 if [ -n "$TAG" ]; then
1126 update_shell_title "tag sources: $TAG"
1127 cvs $OPTIONS $TAG $tag_files
1132 if [ "$TAG_VERSION" = "yes" ]; then
1133 update_shell_title "tag spec: $TAGVER"
1134 cvs $OPTIONS $TAGVER $SPECFILE
1136 if [ -n "$TAG" ]; then
1137 update_shell_title "tag spec: $TAG"
1138 cvs $OPTIONS $TAG $SPECFILE
1145 echo "CVS branch tag: $TAG"
1150 if [ -n "$DEBUG" ]; then
1155 local OPTIONS="tag $CVS_FORCE -b"
1156 if [ -n "$CVSROOT" ]; then
1157 OPTIONS="-d $CVSROOT $OPTIONS"
1161 for i in $TAG_FILES; do
1162 local fp=`nourl "$i"`
1163 if [ -f "$fp" ]; then
1164 tag_files="$tag_files $fp"
1166 Exit_error err_no_source_in_repo $i
1169 if [ "$tag_files" ]; then
1170 cvs $OPTIONS $TAG $tag_files
1174 cvs $OPTIONS $TAG $SPECFILE
1181 update_shell_title "build_package"
1182 if [ -n "$DEBUG" ]; then
1189 if [ -n "$TRY_UPGRADE" ]; then
1190 update_shell_title "build_package: try_upgrade"
1191 if [ -n "$FLOAT_VERSION" ]; then
1192 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1194 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1197 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1199 if [ -n "$TNEWVER" ]; then
1200 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1201 echo "New version found, updating spec file to version " $TNEWVER
1202 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1203 cp -f $SPECFILE $SPECFILE.bak
1206 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1207 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1209 NODIST="yes" get_files $SOURCES $PATCHES
1212 unset TOLDVER TNEWVER TNOTIFY
1219 BUILD_SWITCH="-ba" ;;
1221 BUILD_SWITCH="-bb" ;;
1223 BUILD_SWITCH="-bs --nodeps" ;;
1225 BUILD_SWITCH="-bp --nodeps" ;;
1227 BUILD_SWITCH="-bc" ;;
1229 BUILD_SWITCH="-bi" ;;
1231 BUILD_SWITCH="-bl" ;;
1235 update_shell_title "build_package: $COMMAND"
1236 if [ -n "$LOGFILE" ]; then
1237 LOG=`eval echo $LOGFILE`
1238 if [ -d "$LOG" ]; then
1239 echo "Log file $LOG is a directory."
1240 echo "Parse error in the spec?"
1241 Exit_error err_build_fail
1243 if [ -n "$LASTLOG_FILE" ]; then
1244 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1246 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1247 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1248 RETVAL=`cat $RES_FILE`
1250 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1251 if [ "$RETVAL" -eq "0" ]; then
1258 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1261 if [ "$RETVAL" -ne "0" ]; then
1262 if [ -n "$TRY_UPGRADE" ]; then
1263 echo "\n!!! Package with new version cannot be built automagically\n"
1264 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1265 mv -f $SPECFILE.bak $SPECFILE
1268 Exit_error err_build_fail
1275 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1278 install_required_packages()
1285 # taken from find-spec-bcond, but with just getting the list
1287 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1289 /^%changelog/ { exit }
1290 /_with(out)?_[_a-zA-Z0-9]+/{
1291 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1292 print substr($0, RSTART, RLENGTH);
1295 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1296 bcond = substr($0, RSTART +5 , RLENGTH -5);
1297 gsub(/[ \t]+/,"_",bcond);
1299 }' $SPEC | LC_ALL=C sort -u
1303 # expand bconds from ~/.bcondrc
1304 # The file structure is like gentoo's package.use:
1307 # samba -mysql -pgsql
1308 # w32codec-installer license_agreement
1311 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1317 SN=${SPECFILE%%\.spec}
1319 local bcondrc=$HOME/.bcondrc
1320 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1322 local bcond_avail=$(find_spec_bcond $SPECFILE)
1324 while read pkg flags; do
1326 [[ "$pkg" == \#* ]] && continue
1328 # any package or current package?
1329 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1330 for flag in $flags; do
1331 local opt=${flag#[+-]}
1333 # use only flags which are in this package.
1334 if [[ $bcond_avail = *${opt}* ]]; then
1335 if [[ $flag = -* ]]; then
1336 if [[ $BCOND != *--with?${opt}* ]]; then
1337 BCOND="$BCOND --without $opt"
1340 if [[ $BCOND != *--without?${opt}* ]]; then
1341 BCOND="$BCOND --with $opt"
1348 update_shell_title "parse ~/.bcondrc: DONE!"
1353 update_shell_title "set bcond values"
1355 AVAIL_BCONDS_WITHOUT=""
1356 AVAIL_BCONDS_WITH=""
1357 if `grep -q ^%bcond ${SPECFILE}`; then
1359 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1365 local bcond_avail=$(find_spec_bcond $SPECFILE)
1366 process_bcondrc "$SPECFILE"
1368 update_shell_title "parse bconds"
1369 case "${BCOND_VERSION}" in
1374 echo "Warning: This spec has old style bconds. Fix it || die."
1375 for opt in `echo "$bcond_avail" | grep ^_without_`
1377 AVAIL_BCOND_WITHOUT=${opt#_without_}
1378 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1379 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1381 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1385 for opt in `echo "$bcond_avail" | grep ^_with_`
1387 AVAIL_BCOND_WITH=${opt#_with_}
1388 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1389 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1391 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1396 local cond_type="" # with || without
1397 for opt in $bcond_avail; do
1406 AVAIL_BCOND_WITHOUT=${opt#_without_}
1407 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1408 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1410 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1414 AVAIL_BCOND_WITH=${opt#_with_}
1415 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1416 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1418 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1422 case "$cond_type" in
1425 AVAIL_BCOND_WITH="$opt"
1426 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1427 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1429 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1434 AVAIL_BCOND_WITHOUT="$opt"
1435 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1436 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1438 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1452 update_shell_title "run_sub_builder $package_name"
1454 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1455 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1456 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1457 # jakby nie bylo tego kawalka kodu.
1459 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1460 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1467 # Istnieje taki spec? ${package}.spec
1468 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1469 parent_spec_name=${package}.spec
1470 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1471 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1473 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1479 if [ "${parent_spec_name}" != "" ]; then
1480 spawn_sub_builder $parent_spec_name
1482 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1488 update_shell_title "spawn_sub_builder $package_name"
1491 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1492 sub_builder_opts="${sub_builder_opts} -R"
1494 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1495 sub_builder_opts="${sub_builder_opts} -RB"
1496 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1497 sub_builder_opts="${sub_builder_opts} -FRB"
1499 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1500 sub_builder_opts="${sub_builder_opts} -Upi"
1504 ./builder ${sub_builder_opts} "$@"
1507 remove_build_requires()
1509 if [ "$INSTALLED_PACKAGES" != "" ]; then
1510 case "$REMOVE_BUILD_REQUIRES" in
1512 run_poldek --noask -ve $INSTALLED_PACKAGES
1515 run_poldek --ask -ve $INSTALLED_PACKAGES
1518 echo You may want to manually remove following BuildRequires fetched:
1519 echo $INSTALLED_PACKAGES
1520 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1528 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1529 if [ "$BCOND" != "" ]; then
1530 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1533 echo -ne "\nNo conditional flags passed"
1535 echo -ne "\n\nfrom available:\n"
1536 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1542 if [ "$NOCVSSPEC" != "yes" ]; then
1543 echo -ne "Available branches: "
1544 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1548 # checks a given list of packages/files/provides agains current rpmdb.
1549 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1550 # input can be either STDIN or parameters
1555 if [ "$#" -gt 0 ]; then
1561 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1564 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1566 # other deps (files)
1567 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1570 # checks if given package/files/provides exists in rpmdb.
1571 # inout can be either stdin or parameters
1572 # returns packages wchi hare present in the rpmdb
1577 if [ "$#" -gt 0 ]; then
1583 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1586 fetch_build_requires()
1588 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1589 update_shell_title "fetch build requires"
1590 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1591 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1592 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1594 update_shell_title "poldek: update indexes"
1595 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1596 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1598 if [ -n "$CONF" ]; then
1599 update_shell_title "uninstall conflicting packages: $CONF"
1600 echo "Trying to uninstall conflicting packages ($CONF):"
1601 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1604 while [ "$DEPS" ]; do
1605 update_shell_title "install deps: $DEPS"
1606 echo "Trying to install dependencies ($DEPS):"
1607 local log=.${SPECFILE}_poldek.log
1608 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1609 failed=$(awk -F: '/^error:/{print $2}' $log)
1612 if [ -n "$failed" ]; then
1613 for package in $failed; do
1614 # FIXME: sanitise, deps could be not .spec files
1615 spawn_sub_builder -bb $package && ok="$ok $package"
1625 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1626 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1627 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1628 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1629 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1630 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`
1632 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`"
1634 package=`basename "$package_item"|sed -e "s/}$//g"`
1635 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1638 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1639 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1640 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
1645 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1648 if `echo $COND_TST|grep -q 'without_'`; then
1649 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1650 if `echo $COND_TST|grep -q !`; then
1655 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1656 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1657 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1663 elif `echo $COND_TST|grep -q 'with_'`; then
1664 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1665 if `echo $COND_TST|grep -q !`; then
1670 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1671 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1672 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1678 RESULT="${COND_STATE}-${COND_ARGV}"
1680 "with-wout" | "wout-with" )
1683 "wout-wout" | "with-with" )
1687 echo "Action '$RESULT' was not defined for package '$package_item'"
1693 if [ "$GO" = "yes" ]; then
1694 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1695 echo "Testing if $package has subrequirements..."
1696 run_poldek -t -i $package --dumpn=".$package-req.txt"
1697 if [ -f ".$package-req.txt" ]; then
1698 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1700 if [ "$package_name" = "$package" ]; then
1701 echo -ne "Installing BuildRequired package:\t$package_name\n"
1702 update_shell_title "Installing BuildRequired package: ${package_name}"
1703 install_required_packages $package
1705 echo -ne "Installing (sub)Required package:\t$package_name\n"
1706 update_shell_title "Installing (sub)Required package: ${package_name}"
1707 install_required_packages $package_name
1711 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1712 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1715 echo "Attempting to run spawn sub - builder..."
1716 echo -ne "Package installation failed:\t$package_name\n"
1717 run_sub_builder $package_name
1718 if [ $? -eq 0 ]; then
1719 install_required_packages $package_name
1722 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1723 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1726 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1733 rm -f ".$package-req.txt"
1735 echo "Attempting to run spawn sub - builder..."
1736 echo -ne "Package installation failed:\t$package\n"
1737 run_sub_builder $package
1738 if [ $? -eq 0 ]; then
1739 install_required_packages $package
1742 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1743 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1746 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1752 echo "Package $package is already installed. BuildRequirement satisfied."
1756 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1757 echo "Unable to install following packages and their dependencies:"
1758 for pkg in "$NOT_INSTALLED_PACKAGES"
1762 remove_build_requires
1770 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1771 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1773 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1775 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,{relup,repackage}.sh}
1779 echo "To checkout *all* .spec files:"
1780 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1781 echo "- run cvs up in $SPECS_DIR dir"
1784 echo "To commit with your developer account:"
1785 echo "- edit $SPECS_DIR/CVS/Root"
1786 echo "- edit $SOURCE_DIR/CVS/Root"
1789 #---------------------------------------------
1797 while [ $# -gt 0 ]; do
1800 COMMAND="update_md5"
1805 COMMAND="update_md5"
1815 DEBUG="yes"; shift ;;
1817 COMMAND="version"; shift ;;
1819 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1820 -b | -ba | --build )
1821 COMMAND="build"; shift ;;
1822 -bb | --build-binary )
1823 COMMAND="build-binary"; shift ;;
1825 COMMAND="build-build"; shift ;;
1827 COMMAND="build-install"; shift ;;
1829 COMMAND="build-list"; shift ;;
1830 -bp | --build-prep )
1831 COMMAND="build-prep"; shift ;;
1832 -bs | --build-source )
1833 COMMAND="build-source"; shift ;;
1835 COMMAND="branch"; shift; TAG="${1}"; shift;;
1837 CLEAN="--clean --rmspec --rmsource"; shift ;;
1839 CVS_FORCE="-F"; shift;;
1841 shift; CVSROOT="${1}"; shift ;;
1843 COMMAND="get"; shift ;;
1845 COMMAND="usage"; shift ;;
1847 PROTOCOL="http"; shift ;;
1849 shift; LOGFILE="${1}"; shift ;;
1851 shift; DEF_NICE_LEVEL=${1}; shift ;;
1852 -ske | --skip-existing-files)
1853 SKIP_EXISTING_FILES="yes"; shift ;;
1855 COMMAND="mr-proper"; shift ;;
1857 NOCVS="yes"; shift ;;
1858 -ncs | --no-cvs-specs )
1859 NOCVSSPEC="yes"; shift ;;
1860 -nd | --no-distfiles )
1861 NODIST="yes"; shift ;;
1862 -nm | --no-mirrors )
1863 NOMIRRORS="yes"; shift ;;
1865 NOURLS="yes"; shift ;;
1867 NOSRCS="yes"; shift ;;
1868 -ns0 | --no-source0 )
1869 NOSOURCE0="yes"; shift ;;
1883 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
1885 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1886 --with | --without )
1887 case $GROUP_BCONDS in
1891 while ! `echo ${1}|grep -qE '(^-|spec)'`
1893 BCOND="$BCOND $COND $1"
1897 if [[ "$2" = *,* ]]; then
1898 for a in $(echo "$2" | tr , ' '); do
1899 BCOND="$BCOND $1 $a"
1902 BCOND="$BCOND $1 $2"
1908 shift; TARGET="${1}"; shift ;;
1910 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1912 QUIET="--quiet"; shift ;;
1914 CVSDATE="${2}"; shift 2 ;;
1916 shift; CVSTAG="${1}"; shift ;;
1918 shift; CVSTAG="HEAD"; ;;
1919 -R | --fetch-build-requires)
1920 FETCH_BUILD_REQUIRES="yes"
1921 NOT_INSTALLED_PACKAGES=
1923 -RB | --remove-build-requires)
1924 REMOVE_BUILD_REQUIRES="nice"
1926 -FRB | --force-remove-build-requires)
1927 REMOVE_BUILD_REQUIRES="force"
1929 -sd | --sources-distfiles)
1930 COMMAND="list-sources-distfiles"
1932 -sdp | --sources-distfiles-paths)
1933 COMMAND="list-sources-distfiles-paths"
1935 -sf | --sources-files)
1936 COMMAND="list-sources-files"
1938 -sp | --sources-paths)
1939 COMMAND="list-sources-local-paths"
1941 -su | --sources-urls)
1942 COMMAND="list-sources-urls"
1944 -Tvs | --tag-version-stable )
1949 -Ts | --tag-stable )
1954 -Tv | --tag-version )
1959 -Tp | --tag-prefix )
1971 -ir | --integer-release-only )
1972 INTEGER_RELEASE="yes"
1975 COMMAND="update_md5"
1980 -Upi | --update-poldek-indexes )
1981 UPDATE_POLDEK_INDEXES="yes"
1984 COMMAND="init_rpm_dir"
1986 -u | --try-upgrade )
1987 TRY_UPGRADE="1"; shift ;;
1988 -un | --try-upgrade-with-float-version )
1989 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1991 BE_VERBOSE="1"; shift ;;
1996 if echo "${MACRO}" | grep -q '\W'; then
1997 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2001 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2005 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2008 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2009 COMMAND="show_bconds"
2013 COMMAND="show_bcond_args"
2018 RPMOPTS="${RPMOPTS} --nodeps"
2021 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2024 Exit_error err_invalid_cmdline "$1"
2028 # check if specname was passed as specname:cvstag
2029 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2030 CVSTAG="${SPECFILE##*:}"
2031 SPECFILE="${SPECFILE%%:*}"
2037 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2038 CVSTAG=$(awk -vSPECFILE="${SPECFILE%.spec}.spec" -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2039 if [ "$CVSTAG" ]; then
2040 echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
2042 elif [ "$CVSTAG" = "HEAD" ]; then
2043 # assume -r HEAD is same as -A
2047 if [ -n "$DEBUG" ]; then
2052 if [ -n "$TARGET" ]; then
2055 TARGET_SWITCH="--target $TARGET" ;;
2057 TARGET_SWITCH="--target=$TARGET" ;;
2061 if [ "$SCHEDTOOL" != "no" ]; then
2062 NICE_COMMAND="$SCHEDTOOL"
2064 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2067 update_shell_title "$COMMAND"
2071 if [ -n "$SPECFILE" ]; then
2072 get_spec > /dev/null
2080 if [ -n "$SPECFILE" ]; then
2081 get_spec > /dev/null
2087 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2089 if [ -n "$SPECFILE" ]; then
2095 fetch_build_requires
2096 if [ "$INTEGER_RELEASE" = "yes" ]; then
2097 echo "Checking release $PACKAGE_RELEASE..."
2098 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2099 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2103 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2104 if [ -n "$TEST_TAG" ]; then
2105 # - do not allow utf8 encoded specs on AC-branch
2106 if [ "$CVSTAG" = "AC-branch-disabled" ]; then
2108 t=$(grep '^Summary(.*\.UTF-8):' $SPECFILE)
2110 Exit_error err_acl_deny "UTF-8 .specs not allowed on $CVSTAG"
2114 TAGVER=`make_tagver`
2115 echo "Searching for tag $TAGVER..."
2116 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2117 if [ -n "$TAGREL" ]; then
2118 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2121 # - do not allow to build from HEAD when XX-branch exists
2122 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2123 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2124 TAG_BRANCH="${TREE_PREFIX}-branch"
2125 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2126 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2127 Exit_error err_branch_exists "$TAG_STATUS"
2133 if [ -n "$NOSOURCE0" ] ; then
2134 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2136 get_files $SOURCES $PATCHES
2139 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2140 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2142 remove_build_requires
2144 Exit_error err_no_spec_in_cmdl
2149 if [ -n "$SPECFILE" ]; then
2152 # don't fetch sources from remote locations
2154 for file in $SOURCES; do
2155 [ -n "`src_md5 $file`" ] && continue
2156 new_SOURCES="$new_SOURCES $file"
2158 SOURCES="$new_SOURCES"
2159 get_files $SOURCES $PATCHES
2161 branch_files $TAG $SOURCES $PATCHES $ICONS
2163 Exit_error err_no_spec_in_cmdl
2168 if [ -n "$SPECFILE" ]; then
2172 if [ -n "$NOSOURCE0" ] ; then
2173 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2175 get_files $SOURCES $PATCHES
2178 Exit_error err_no_spec_in_cmdl
2183 if [ -n "$SPECFILE" ]; then
2187 if [ -n "$NOSOURCE0" ] ; then
2188 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2192 Exit_error err_no_spec_in_cmdl
2199 if [ -n "$SPECFILE" ]; then
2203 # don't fetch sources from remote locations
2205 for file in $SOURCES; do
2206 [ -n "`src_md5 $file`" ] && continue
2207 new_SOURCES="$new_SOURCES $file"
2209 SOURCES="$new_SOURCES"
2210 get_files $SOURCES $PATCHES
2212 tag_files $SOURCES $PATCHES $ICONS
2214 Exit_error err_no_spec_in_cmdl
2218 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
2220 "list-sources-files" )
2223 DONT_PRINT_REVISION="yes"
2226 for SAP in $SOURCES $PATCHES; do
2227 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2230 "list-sources-urls" )
2233 DONT_PRINT_REVISION="yes"
2236 SAPS="$SOURCES $PATCHES"
2237 for SAP in $SAPS ; do
2241 "list-sources-local-paths" )
2244 DONT_PRINT_REVISION="yes"
2247 for SAP in $SOURCES $PATCHES; do
2248 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2251 "list-sources-distfiles-paths" )
2254 DONT_PRINT_REVISION="yes"
2257 for SAP in $SOURCES $PATCHES; do
2258 if [ -n "$(src_md5 "$SAP")" ]; then
2259 distfiles_path "$SAP"
2263 "list-sources-distfiles" )
2266 DONT_PRINT_REVISION="yes"
2269 for SAP in $SOURCES $PATCHES; do
2270 if [ -n "$(src_md5 "$SAP")" ]; then
2271 distfiles_url "$SAP"
2283 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2284 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2288 # vi:syntax=sh:ts=4:sw=4:noet