6 # 2 - no spec file name in cmdl parameters
7 # 3 - spec file not stored in repo
8 # 4 - some source, patch or icon files not stored in repo
9 # 5 - package build failed
10 # 6 - spec file with errors
11 # 7 - wrong source in /etc/poldek.conf
12 # 8 - Failed installing buildrequirements and subrequirements
13 # 9 - Requested tag already exist
14 # 10 - Refused to build fractional release
15 # 100 - Unknown error (should not happen)
18 # - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
19 # - when Icon: field is present, -5 and -a5 doesn't work
20 # - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
27 Build package utility from PLD Linux CVS repository
28 $VERSION (C) 1999-2007 Free Penguins".
30 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
48 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
51 # user agent when fetching files
52 USER_AGENT="PLD/Builder($VERSION)"
54 # It can be used i.e. in log file naming.
55 # See LOGFILE example.
56 DATE=`date +%Y-%m-%d_%H-%M-%S`
58 # Example: LOGFILE='../log.$PACKAGE_NAME'
59 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
60 # Yes, you can use variable name! Note _single_ quotes!
84 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
85 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
91 CVS_SERVER="cvs.pld-linux.org"
92 DISTFILES_SERVER="://distfiles.pld-linux.org"
93 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
98 FAIL_IF_NO_SOURCES="yes"
100 # let get_files skip over files which are present to get those damn files fetched
101 SKIP_EXISTING_FILES="no"
104 # should the specfile be restored if upgrade failed?
105 REVERT_BROKEN_UPGRADE="yes"
107 if [ -x /usr/bin/rpm-getdeps ]; then
108 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
110 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
113 # Here we load saved user environment used to
114 # predefine options set above, or passed to builder
116 # This one reads global system environment settings:
117 if [ -f ~/etc/builderrc ]; then
120 # And this one cascades settings using user personal
122 # Example of ~/.builderrc:
124 #UPDATE_POLDEK_INDEXES="yes"
125 #FETCH_BUILD_REQUIRES="yes"
126 #REMOVE_BUILD_REQUIRES="force"
128 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
132 if [ -n "$HOME_ETC" ]; then
133 USER_CFG="$HOME_ETC/.builderrc"
135 USER_CFG=~/.builderrc
138 [ -f "$USER_CFG" ] && . "$USER_CFG"
140 if [ "$SCHEDTOOL" = "auto" ]; then
141 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
142 SCHEDTOOL="schedtool -B -e"
148 if [ -n "$USE_PROZILLA" ]; then
149 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
152 elif [ -n "$USE_AXEL" ]; then
153 GETURI="axel -a $AXEL_OPTS"
157 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
158 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
159 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
160 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
162 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
163 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
169 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
177 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
178 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
182 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
183 if [ -n "$LOGFILE" ]; then
184 LOG=`eval echo $LOGFILE`
185 if [ -n "$LASTLOG_FILE" ]; then
186 echo "LASTLOG=$LOG" > $LASTLOG_FILE
188 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
191 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
192 return `cat ${RES_FILE}`
197 #---------------------------------------------
202 if [ -n "$DEBUG" ]; then set -xv; fi
204 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
205 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
206 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
207 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
208 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
209 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
210 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
211 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
212 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
213 <package>[.spec][:cvstag]
215 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
216 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
217 -n5, --no-md5 - ignore md5 comments in spec
218 -D, --debug - enable builder script debugging mode,
219 -debug - produce rpm debug package (same as --opts -debug)
220 -V, --version - output builder version string
221 --short-version - output builder short version
222 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
223 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
225 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
226 only package from <package>.spec,
227 -bp, --build-prep - execute the %prep phase of <package>.spec,
228 -bc - execute the %build phase of <package>.spec,
229 -bi - execute the %install phase of <package>.spec
230 -bl - execute the %files phase of <package>.spec
231 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
233 --short-circuit - short-circuit build
234 -B, --branch - add branch
235 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
236 SPECS and \$RPM_BUILD_ROOT),
237 -cf, --cvs-force - use -F when tagging (useful when moving branches)
238 -d <cvsroot>, --cvsroot <cvsroot>
240 --define <macro> <value>
241 - define a macro <macro> with value <value>,
242 --nodeps - rpm won't check any dependences
243 -g, --get - get <package>.spec and all related files from CVS repo
245 -h, --help - this message,
246 --http - use http instead of ftp,
247 -l <logfile>, --logtofile <logfile>
249 -m, --mr-proper - only remove all files related to spec file and all work
251 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
253 - don't check specs in CVS
254 -nd, --no-distfiles - don't download from distfiles
255 -nm, --no-mirrors - don't download from mirror, if source URL is given,
256 -nu, --no-urls - don't try to download from FTP/HTTP location,
257 -ns, --no-srcs - don't download Sources
258 -ns0, --no-source0 - don't download Source0
259 -nn, --no-net - don't download anything from the net
260 --no-init - don't initialize builder paths (SPECS and SOURCES)
262 --skip-existing-files - skip existing files in get_files
263 --opts <rpm opts> - additional options for rpm
264 -q, --quiet - be quiet,
265 --date yyyy-mm-dd - build package using resources from specified CVS date,
266 -r <cvstag>, --cvstag <cvstag>
267 - build package using resources from specified CVS tag,
268 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
269 -R, --fetch-build-requires
270 - fetch what is BuildRequired,
271 -RB, --remove-build-requires
272 - remove all you fetched with -R or --fetch-build-requires
273 remember, this option requires confirmation,
274 -FRB, --force-remove-build-requires
275 - remove all you fetched with -R or --fetch-build-requires
276 remember, this option works without confirmation,
277 -sd, --source-distfiles - list sources available from distfiles (intended for offline
278 operations; does not work when Icon field is present
279 but icon file is absent),
280 -sc, --source-cvs - list sources available from CVS
281 -sdp, --source-distfiles-paths - list sources available from distfiles -
282 paths relative to distfiles directory (intended for offline
283 operations; does not work when Icon field is present
284 but icon file is absent),
285 -sf, --source-files - list sources - bare filenames (intended for offline
286 operations; does not work when Icon field is present
287 but icon file is absent),
288 -sp, --source-paths - list sources - filenames with full local paths (intended for
289 offline operations; does not work when Icon field is present
290 but icon file is absent),
291 -su, --source-urls - list urls - urls to sources and patches
292 intended for copying urls with spec with lots of macros in urls
293 -T <cvstag> , --tag <cvstag>
294 - add cvs tag <cvstag> for files,
295 -Tvs, --tag-version-stable
296 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
298 - add cvs tag STABLE for files,
300 - add cvs tag NAME-VERSION-RELEASE for files,
301 -Tp, --tag-prefix <prefix>
302 - add <prefix> to NAME-VERSION-RELEASE tags,
303 -tt, --test-tag <prefix>
304 - fail if tag is already present,
305 -ir, --integer-release-only
306 - allow only integer and snapshot releases
307 -v, --verbose - be verbose,
308 -u, --try-upgrade - check version, and try to upgrade package
309 -un, --try-upgrade-with-float-version
310 - as above, but allow float version
311 -U, --update - refetch sources, don't use distfiles, and update md5 comments
312 -Upi, --update-poldek-indexes
313 - refresh or make poldek package index files.
314 -np, --nopatch <patchnumber>
315 - don't apply <patchnumber>
316 --show-bconds - show available conditional builds, which can be used
317 - with --with and/or --without switches.
318 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
319 ./repackage.sh script. in other words, the output is
320 parseable by scripts.
321 --with/--without <feature>
322 - conditional build package depending on %_with_<feature>/
323 %_without_<feature> macro switch. You may now use
324 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
325 constructions. Set GROUP_BCONDS to yes to make use of it.
326 --target <platform>, --target=<platform>
327 - build for platform <platform>.
328 --init-rpm-dir - initialize ~/rpm directory structure
332 update_shell_title() {
334 local len=${COLUMNS:-80}
335 local msg=$(echo "$*" | cut -c-$len)
337 if [ -n "$BE_VERBOSE" ]; then
338 echo >&2 "$(date +%s.%N) $*"
341 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
343 if [ -n "$PACKAGE_NAME" ]; then
344 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
349 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
350 msg="$(echo $msg | tr -d '\n\r')"
353 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
356 echo >&2 -ne "\033]0;$msg\007"
362 # set TARGET from BuildArch: from SPECFILE
364 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
365 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
367 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
371 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
373 TARGET_SWITCH="--target=$TARGET" ;;
379 # runs rpm with minimal macroset
381 # we reset macros not to contain macros.build as all the %() macros are
382 # executed here, while none of them are actually needed.
383 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
384 safe_macrofiles=$(rpm --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
386 # TODO: move these to /usr/lib/rpm/macros
387 cat > .builder-rpmmacros <<'EOF'
388 %x8664 x86_64 amd64 ia32e
391 %requires_releq_kernel_up %{nil}
392 %requires_releq_kernel_smp %{nil}
393 %requires_releq_kernel %{nil}
394 %requires_releq() %{nil}
395 %pyrequires_eq() %{nil}
396 %requires_eq() %{nil}
397 %requires_eq_to() %{nil}
398 %releq_kernel_up ERROR
399 %releq_kernel_smp ERROR
404 %ruby_ver_requires_eq() %{nil}
405 %ruby_mod_ver_requires_eq() %{nil}
406 %__php_api_requires() %{nil}
407 %php_major_version ERROR
408 %php_api_version ERROR
410 %perl_vendorarch ERROR
411 %perl_vendorlib ERROR
412 # damn. need it here! - copied from /usr/lib/rpm/macros.build
413 %tmpdir %(echo "${TMPDIR:-/tmp}")
414 %patchset_source(f:b:) %(
415 base=%{-b*}%{!-b*:10000};
416 start=$(expr $base + %1);
417 end=$(expr $base + %{?2}%{!?2:%{1}});
418 # we need to call seq twice as it doesn't allow two formats
419 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
420 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
421 paste %{tmpdir}/__ps{1,2};
422 rm -f %{tmpdir}/__ps{1,2};
426 if [ "$NOINIT" = "yes" ] ; then
427 cat >> .builder-rpmmacros <<'EOF'
432 eval $RPMBUILD --macros "$safe_macrofiles:.builder-rpmmacros" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $* 2>&1
436 if [ -n "$DEBUG" ]; then
441 update_shell_title "cache_rpm_dump"
444 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
445 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
451 ARGS='--nodigest --nosignature --nobuild'
454 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
456 if [ $? -gt 0 ]; then
457 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
459 Exit_error err_build_fail
462 # make small dump cache
463 rpm_dump_cache=`echo "$rpm_dump" | awk '
464 $2 ~ /^SOURCEURL/ {print}
465 $2 ~ /^PATCHURL/ {print}
466 $2 ~ /^nosource/ {print}
467 $2 ~ /^PACKAGE_/ {print}
470 update_shell_title "cache_rpm_dump: OK!"
474 if [ -z "$rpm_dump_cache" ] ; then
475 echo "internal error: cache_rpm_dump not called! (missing %prep?)" 1>&2
477 echo "$rpm_dump_cache"
482 update_shell_title "get icons"
483 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
484 if [ -z "$ICONS" ]; then
488 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
493 update_shell_title "parsing specfile"
494 if [ -n "$DEBUG" ]; then
499 # icons are needed for successful spec parse
505 if [ "$NOSRCS" != "yes" ]; then
506 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
509 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
510 FAIL_IF_NO_SOURCES="no"
513 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
514 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
515 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
516 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
517 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
519 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
520 echo "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
523 if [ -n "$BE_VERBOSE" ]; then
524 echo "- Sources : `nourl $SOURCES`"
525 if [ -n "$PATCHES" ]; then
526 echo "- Patches : `nourl $PATCHES`"
528 echo "- Patches : *no patches needed*"
530 if [ -n "$ICONS" ]; then
531 echo "- Icon : `nourl $ICONS`"
533 echo "- Icon : *no package icon*"
535 echo "- Name : $PACKAGE_NAME"
536 echo "- Version : $PACKAGE_VERSION"
537 echo "- Release : $PACKAGE_RELEASE"
540 update_shell_title "parse_spec: OK!"
545 if [ -n "$DEBUG" ]; then
553 "err_no_spec_in_cmdl" )
554 remove_build_requires
555 echo "ERROR: spec file name not specified."
557 "err_invalid_cmdline" )
558 echo "ERROR: invalid command line arg ($2)."
560 "err_no_spec_in_repo" )
561 remove_build_requires
562 echo "Error: spec file not stored in CVS repo."
564 "err_no_source_in_repo" )
565 remove_build_requires
566 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)"
569 remove_build_requires
570 echo "Error: package build failed. (${2:-no more info})"
572 "err_no_package_data" )
573 remove_build_requires
574 echo "Error: couldn't get out package name/version/release from spec file."
577 remove_build_requires
578 echo "Tag ${2} already exists (spec release: ${3})."
581 remove_build_requires
582 echo "Release ${2} not integer and not a snapshot."
584 "err_branch_exists" )
585 remove_build_requires
586 echo "Tree branch already exists (${2})."
589 remove_build_requires
590 echo "Error: conditions reject building this spec (${2})."
593 echo "Unknown error."
599 if [ -n "$DEBUG" ]; then
604 if [ "$NOINIT" != "yes" ] ; then
605 SOURCE_DIR="`eval $RPM $RPMOPTS --define '"name $ASSUMED_NAME"' --eval '%{_sourcedir}'`"
606 SPECS_DIR="`eval $RPM $RPMOPTS --define '"name $ASSUMED_NAME"' --eval '%{_specdir}'`"
618 update_shell_title "get_spec"
620 if [ -n "$DEBUG" ]; then
626 if [ ! -f "$SPECFILE" ]; then
627 SPECFILE="`basename $SPECFILE .spec`.spec"
629 if [ "$NOCVSSPEC" != "yes" ]; then
631 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
632 echo "Warning: No CVS access defined - using local .spec file"
636 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
639 if [ ! -f "$SPECFILE" ]; then
640 Exit_error err_no_spec_in_repo
643 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
644 chmod $CHMOD_MODE $SPECFILE
647 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
656 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
657 cvs update mirrors >&2
661 local origin mirror name rest ol prefix
662 while read origin mirror name rest; do
663 # skip comments and empty lines
664 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
667 ol=`echo -n "$origin"|wc -c`
668 prefix="`echo -n "$url" | head -c $ol`"
669 if [ "$prefix" = "$origin" ] ; then
670 suffix="`echo "$url"|cut -b $((ol+1))-`"
671 echo -n "$mirror$suffix"
678 # Warning: unpredictable results if same URL used twice
683 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
684 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
690 [ "$NO5" = "yes" ] && return
692 [ -z "$no" ] && return
696 if [ -f additional-md5sums ]; then
697 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
698 if [ -z "$spec_rev" ]; then
699 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
701 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
702 md5=$(grep -s -v '^#' additional-md5sums | \
703 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
704 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
705 grep -E '^[0-9a-f]{32}$')
708 if [ $(echo "$md5" | wc -l) != 1 ] ; then
709 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
711 echo "$md5" | tail -n 1
716 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
717 if [ -n "$source_md5" ]; then
720 # we have empty SourceX-md5, but it is still possible
721 # that we have NoSourceX-md5 AND NoSource: X
722 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
723 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
731 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
736 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
739 distfiles_attic_url ()
741 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
748 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
753 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
754 [ -n "$size" -a "$size" -gt 0 ]
759 if [ "$CVSIGNORE_DF" != "yes" ]; then
762 cvsignore=${SOURCE_DIR}/.cvsignore
763 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
764 echo "$1" >> $cvsignore
770 update_shell_title "cvsup"
772 if [ -n "$CVSROOT" ]; then
773 OPTIONS="-d $CVSROOT $OPTIONS"
776 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
777 OPTIONS="$OPTIONS -A"
779 if [ -n "$CVSDATE" ]; then
780 OPTIONS="$OPTIONS -D $CVSDATE"
782 if [ -n "$CVSTAG" ]; then
783 OPTIONS="$OPTIONS -r $CVSTAG"
788 local retries_counter=0
790 update_shell_title "cvsup: $*"
792 update_shell_title "cvsup: $# files"
794 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
795 retries_counter=$(( $retries_counter + 1 ))
796 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
798 [ -n "$output" ] && echo "$output"
799 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
800 echo "Trying again [$*]... ($retries_counter)"
801 update_shell_title "cvsup: retry #$retries_counter"
808 update_shell_title "cvsup: done!"
812 # returns true if "$1" is ftp, http or https protocol url
816 ftp://*|http://*|https://*)
825 if [ $# -eq 0 ]; then
829 update_shell_title "update md5"
830 if [ -n "$DEBUG" ]; then
837 # pass 1: check files to be fetched
841 local fp=$(nourl "$i")
842 local srcno=$(src_no "$i")
843 if [ -n "$ADD5" ]; then
844 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
845 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
847 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
849 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
850 need_files="$need_files $i"
854 # pass 1a: get needed files
855 if [ "$need_files" ]; then
856 get_files $need_files
859 # pass 2: proceed with md5 adding or updating
861 local fp=$(nourl "$i")
862 local srcno=$(src_no "$i")
863 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
864 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
865 local tag="Source$srcno-md5"
866 if [[ "$md5" == *NoSource* ]]; then
867 tag="NoSource$srcno-md5"
869 md5=$(md5sum "$fp" | cut -f1 -d' ')
870 echo "Updating $tag ($md5: $fp)."
872 print unless /^\s*#\s*(No)?Source'$srcno'-md5\s*:/i;
873 print "# '$tag':\t'$md5'\n" if /^Source'$srcno'\s*:\s+/;
882 update_shell_title "check md5"
885 if good_md5 "$i" && good_size "$i"; then
889 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
890 echo "or -5 to update md5 sums, if you're sure files are correct."
891 Exit_error err_no_source_in_repo $i
897 update_shell_title "get_files"
899 if [ -n "$DEBUG" ]; then
904 if [ $# -gt 0 ]; then
907 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
908 echo "Warning: No CVS access defined for SOURCES"
913 local get_files_cvs=""
917 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
918 update_shell_title "$i"
919 local fp=`nourl "$i"`
920 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
925 local srcmd5=$(src_md5 "$i")
927 # we know if source/patch is present in cvs/distfiles
928 # - has md5 (in distfiles)
931 # CHECK: local file didn't exist or always cvs up (first) requested.
932 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
933 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
934 echo "Warning: no URL given for $i"
937 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
938 if good_md5 "$i" && good_size "$i"; then
939 echo "$fp having proper md5sum already exists"
944 # prefer mirror over distfiles if there's mirror
945 # TODO: build url list and then try each url from the list
946 if [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
949 url=$(distfiles_url "$i")
952 url_attic=$(distfiles_attic_url "$i")
954 # is $url local file?
955 if [[ "$url" = [./]* ]]; then
956 update_shell_title "${GETLOCAL%% *}: $url"
957 ${GETLOCAL} $url $target
959 if [ -z "$NOMIRRORS" ]; then
960 url=$(find_mirror "$url")
964 # make shorter message for distfiles urls
965 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
966 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
967 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
970 update_shell_title "${GETURI%% *}: $uri"
971 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
972 if [ "`echo $url | grep -E 'ftp://'`" ]; then
973 update_shell_title "${GETURI2%% *}: $url"
974 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
979 if [ ! -s "$target" ]; then
981 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
982 update_shell_title "${GETLOCAL%% *}: $url_attic"
983 ${GETLOCAL} $url_attic $target
985 if [ -z "$NOMIRRORS" ]; then
986 url_attic="`find_mirror "$url_attic"`"
988 update_shell_title "${GETURI%% *}: $url_attic"
989 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
990 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
991 update_shell_title "${GETURI2%% *}: $url_attic"
992 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
997 if [ -s "$target" ]; then
1003 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1004 if [ $# -gt 1 ]; then
1005 get_files_cvs="$get_files_cvs $fp"
1006 update_shell_title "$fp (will cvs up later)"
1013 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1014 if [ -z "$NOMIRRORS" ]; then
1015 im="`find_mirror "$i"`"
1019 update_shell_title "${GETURI%% *}: $im"
1020 ${GETURI} "$im" || \
1021 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1022 update_shell_title "${GETURI2%% *}: $im"
1027 if [ "$cvsup" = 1 ]; then
1033 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1034 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1035 Exit_error err_no_source_in_repo $i
1038 # we check md5 here just only to refetch immediately
1039 if good_md5 "$i" && good_size "$i"; then
1041 elif [ "$FROM_DISTFILES" = 1 ]; then
1042 # wrong md5 from distfiles: remove the file and try again
1044 echo "MD5 sum mismatch. Trying full fetch."
1047 update_shell_title "${GETURI%% *}: $url"
1048 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1049 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1050 update_shell_title "${GETURI2%% *}: $url"
1051 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1053 if [ ! -s "$target" ]; then
1055 update_shell_title "${GETURI%% *}: $url_attic"
1056 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1057 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1058 update_shell_title "${GETURI2%% *}: $url_attic"
1059 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1062 test -s "$target" || rm -f "$target"
1065 SHELL_TITLE_PREFIX=""
1067 if [ "$get_files_cvs" ]; then
1068 cvsup $get_files_cvs
1071 if [ "$CHMOD" = "yes" ]; then
1072 CHMOD_FILES="`nourl "$@"`"
1073 if [ -n "$CHMOD_FILES" ]; then
1074 chmod $CHMOD_MODE $CHMOD_FILES
1081 if [ -n "$DEBUG" ]; then
1086 # Check whether first character of PACKAGE_NAME is legal for tag name
1087 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1091 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1092 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1094 # Remove #kernel.version_release from TAGVER because tagging sources
1095 # could occur with different kernel-headers than kernel-headers used at build time.
1096 # besides, %{_kernel_ver_str} is not expanded.
1098 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1099 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1109 if [ -n "$DEBUG" ]; then
1114 echo "Version: $PACKAGE_VERSION"
1115 echo "Release: $PACKAGE_RELEASE"
1118 if [ "$TAG_VERSION" = "yes" ]; then
1119 TAGVER=`make_tagver`
1120 echo "CVS tag: $TAGVER"
1122 if [ -n "$TAG" ]; then
1123 echo "CVS tag: $TAG"
1126 local OPTIONS="tag $CVS_FORCE"
1127 if [ -n "$CVSROOT" ]; then
1128 OPTIONS="-d $CVSROOT $OPTIONS"
1133 for i in $TAG_FILES; do
1134 # don't tag files stored on distfiles
1135 [ -n "`src_md5 $i`" ] && continue
1136 local fp=`nourl "$i"`
1137 if [ -f "$fp" ]; then
1138 tag_files="$tag_files $fp"
1140 Exit_error err_no_source_in_repo $i
1144 if [ "$tag_files" ]; then
1145 if [ "$TAG_VERSION" = "yes" ]; then
1146 update_shell_title "tag sources: $TAGVER"
1147 cvs $OPTIONS $TAGVER $tag_files || exit
1149 if [ -n "$TAG" ]; then
1150 update_shell_title "tag sources: $TAG"
1151 cvs $OPTIONS $TAG $tag_files || exit
1156 if [ "$TAG_VERSION" = "yes" ]; then
1157 update_shell_title "tag spec: $TAGVER"
1158 cvs $OPTIONS $TAGVER $SPECFILE || exit
1160 if [ -n "$TAG" ]; then
1161 update_shell_title "tag spec: $TAG"
1162 cvs $OPTIONS $TAG $SPECFILE || exit
1169 echo "CVS branch tag: $TAG"
1174 if [ -n "$DEBUG" ]; then
1179 local OPTIONS="tag $CVS_FORCE -b"
1180 if [ -n "$CVSROOT" ]; then
1181 OPTIONS="-d $CVSROOT $OPTIONS"
1185 for i in $TAG_FILES; do
1186 local fp=`nourl "$i"`
1187 if [ -f "$fp" ]; then
1188 tag_files="$tag_files $fp"
1190 Exit_error err_no_source_in_repo $i
1193 if [ "$tag_files" ]; then
1194 cvs $OPTIONS $TAG $tag_files || exit
1198 cvs $OPTIONS $TAG $SPECFILE || exit
1202 # this function should exit early if package can't be built for this arch
1203 # this avoids unneccessary BR filling.
1206 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1208 if [ $ret -ne 0 ]; then
1217 update_shell_title "build_package"
1218 if [ -n "$DEBUG" ]; then
1225 if [ -n "$TRY_UPGRADE" ]; then
1226 update_shell_title "build_package: try_upgrade"
1227 if [ -n "$FLOAT_VERSION" ]; then
1228 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1230 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1233 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1235 if [ -n "$TNEWVER" ]; then
1236 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1237 echo "New version found, updating spec file to version " $TNEWVER
1238 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1239 cp -f $SPECFILE $SPECFILE.bak
1242 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1243 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1245 NODIST="yes" get_files $SOURCES $PATCHES
1248 unset TOLDVER TNEWVER TNOTIFY
1255 BUILD_SWITCH="-ba" ;;
1257 BUILD_SWITCH="-bb" ;;
1259 BUILD_SWITCH="-bs --nodeps" ;;
1261 BUILD_SWITCH="-bp --nodeps" ;;
1263 BUILD_SWITCH="-bc" ;;
1265 BUILD_SWITCH="-bi" ;;
1267 BUILD_SWITCH="-bl" ;;
1271 update_shell_title "build_package: $COMMAND"
1272 if [ -n "$LOGFILE" ]; then
1273 LOG=`eval echo $LOGFILE`
1274 if [ -d "$LOG" ]; then
1275 echo "Log file $LOG is a directory."
1276 echo "Parse error in the spec?"
1277 Exit_error err_build_fail
1279 if [ -n "$LASTLOG_FILE" ]; then
1280 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1282 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1283 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1284 RETVAL=`cat $RES_FILE`
1286 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1287 if [ "$RETVAL" -eq "0" ]; then
1294 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1297 if [ "$RETVAL" -ne "0" ]; then
1298 if [ -n "$TRY_UPGRADE" ]; then
1299 echo "\n!!! Package with new version cannot be built automagically\n"
1300 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1301 mv -f $SPECFILE.bak $SPECFILE
1304 Exit_error err_build_fail
1311 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1314 install_required_packages()
1321 # taken from find-spec-bcond, but with just getting the list
1323 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1325 /^%changelog/ { exit }
1326 /_with(out)?_[_a-zA-Z0-9]+/{
1327 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1328 print substr($0, RSTART, RLENGTH);
1331 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1332 bcond = substr($0, RSTART +5 , RLENGTH -5);
1333 gsub(/[ \t]+/,"_",bcond);
1335 }' $SPEC | LC_ALL=C sort -u
1339 # expand bconds from ~/.bcondrc
1340 # The file structure is like gentoo's package.use:
1343 # samba -mysql -pgsql
1344 # w32codec-installer license_agreement
1347 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1353 SN=${SPECFILE%%\.spec}
1355 local bcondrc=$HOME/.bcondrc
1356 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1358 local bcond_avail=$(find_spec_bcond $SPECFILE)
1360 while read pkg flags; do
1362 [[ "$pkg" == \#* ]] && continue
1364 # any package or current package?
1365 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1366 for flag in $flags; do
1367 local opt=${flag#[+-]}
1369 # use only flags which are in this package.
1370 if [[ $bcond_avail = *${opt}* ]]; then
1371 if [[ $flag = -* ]]; then
1372 if [[ $BCOND != *--with?${opt}* ]]; then
1373 BCOND="$BCOND --without $opt"
1376 if [[ $BCOND != *--without?${opt}* ]]; then
1377 BCOND="$BCOND --with $opt"
1384 update_shell_title "parse ~/.bcondrc: DONE!"
1389 update_shell_title "set bcond values"
1391 AVAIL_BCONDS_WITHOUT=""
1392 AVAIL_BCONDS_WITH=""
1393 if `grep -q ^%bcond ${SPECFILE}`; then
1395 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1401 local bcond_avail=$(find_spec_bcond $SPECFILE)
1402 process_bcondrc "$SPECFILE"
1404 update_shell_title "parse bconds"
1405 case "${BCOND_VERSION}" in
1410 echo "Warning: This spec has old style bconds. Fix it || die."
1411 for opt in `echo "$bcond_avail" | grep ^_without_`
1413 AVAIL_BCOND_WITHOUT=${opt#_without_}
1414 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1415 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1417 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1421 for opt in `echo "$bcond_avail" | grep ^_with_`
1423 AVAIL_BCOND_WITH=${opt#_with_}
1424 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1425 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1427 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1432 local cond_type="" # with || without
1433 for opt in $bcond_avail; do
1442 AVAIL_BCOND_WITHOUT=${opt#_without_}
1443 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1444 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1446 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1450 AVAIL_BCOND_WITH=${opt#_with_}
1451 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1452 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1454 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1458 case "$cond_type" in
1461 AVAIL_BCOND_WITH="$opt"
1462 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1463 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1465 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1470 AVAIL_BCOND_WITHOUT="$opt"
1471 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1472 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1474 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1488 update_shell_title "run_sub_builder $package_name"
1490 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1491 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1492 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1493 # jakby nie bylo tego kawalka kodu.
1495 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1496 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1503 # Istnieje taki spec? ${package}.spec
1504 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1505 parent_spec_name=${package}.spec
1506 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1507 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1509 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1515 if [ "${parent_spec_name}" != "" ]; then
1516 spawn_sub_builder $parent_spec_name
1518 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1524 update_shell_title "spawn_sub_builder $package_name"
1527 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1528 sub_builder_opts="${sub_builder_opts} -R"
1530 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1531 sub_builder_opts="${sub_builder_opts} -RB"
1532 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1533 sub_builder_opts="${sub_builder_opts} -FRB"
1535 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1536 sub_builder_opts="${sub_builder_opts} -Upi"
1540 ./builder ${sub_builder_opts} "$@"
1543 remove_build_requires()
1545 if [ "$INSTALLED_PACKAGES" != "" ]; then
1546 case "$REMOVE_BUILD_REQUIRES" in
1548 run_poldek --noask -ve $INSTALLED_PACKAGES
1551 run_poldek --ask -ve $INSTALLED_PACKAGES
1554 echo You may want to manually remove following BuildRequires fetched:
1555 echo $INSTALLED_PACKAGES
1556 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1564 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1565 if [ "$BCOND" != "" ]; then
1566 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1569 echo -ne "\nNo conditional flags passed"
1571 echo -ne "\n\nfrom available:\n"
1572 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1578 if [ "$NOCVSSPEC" != "yes" ]; then
1579 echo -ne "Available branches: "
1580 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1584 # checks a given list of packages/files/provides agains current rpmdb.
1585 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1586 # input can be either STDIN or parameters
1591 if [ "$#" -gt 0 ]; then
1597 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1600 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1602 # other deps (files)
1603 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1606 # checks if given package/files/provides exists in rpmdb.
1607 # inout can be either stdin or parameters
1608 # returns packages wchi hare present in the rpmdb
1613 if [ "$#" -gt 0 ]; then
1619 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1622 fetch_build_requires()
1624 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1625 update_shell_title "fetch build requires"
1626 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1627 # TODO: Conflicts list doesn't check versions
1628 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1629 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1631 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1632 echo "fetch builderequires: install $DEPS; remove $CNFL"
1633 update_shell_title "poldek: install $DEPS; remove $CNFL"
1634 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1636 if [ -n "$CNFL" ]; then
1637 update_shell_title "uninstall conflicting packages: $CNFL"
1638 echo "Trying to uninstall conflicting packages ($CNFL):"
1639 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1642 while [ "$DEPS" ]; do
1643 update_shell_title "install deps: $DEPS"
1644 echo "Trying to install dependencies ($DEPS):"
1645 local log=.${SPECFILE}_poldek.log
1646 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1647 failed=$(awk -F: '/^error:/{print $2}' $log)
1650 if [ -n "$failed" ]; then
1651 for package in $failed; do
1652 # FIXME: sanitise, deps could be not .spec files
1653 spawn_sub_builder -bb $package && ok="$ok $package"
1663 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1664 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1665 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1666 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1667 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1668 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`
1670 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`"
1672 package=`basename "$package_item"|sed -e "s/}$//g"`
1673 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1676 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1677 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1678 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
1683 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1686 if `echo $COND_TST|grep -q 'without_'`; then
1687 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1688 if `echo $COND_TST|grep -q !`; then
1693 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1694 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1695 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1701 elif `echo $COND_TST|grep -q 'with_'`; then
1702 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1703 if `echo $COND_TST|grep -q !`; then
1708 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1709 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1710 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1716 RESULT="${COND_STATE}-${COND_ARGV}"
1718 "with-wout" | "wout-with" )
1721 "wout-wout" | "with-with" )
1725 echo "Action '$RESULT' was not defined for package '$package_item'"
1731 if [ "$GO" = "yes" ]; then
1732 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1733 echo "Testing if $package has subrequirements..."
1734 run_poldek -t -i $package --dumpn=".$package-req.txt"
1735 if [ -f ".$package-req.txt" ]; then
1736 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1738 if [ "$package_name" = "$package" ]; then
1739 echo -ne "Installing BuildRequired package:\t$package_name\n"
1740 update_shell_title "Installing BuildRequired package: ${package_name}"
1741 install_required_packages $package
1743 echo -ne "Installing (sub)Required package:\t$package_name\n"
1744 update_shell_title "Installing (sub)Required package: ${package_name}"
1745 install_required_packages $package_name
1749 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1750 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1753 echo "Attempting to run spawn sub - builder..."
1754 echo -ne "Package installation failed:\t$package_name\n"
1755 run_sub_builder $package_name
1756 if [ $? -eq 0 ]; then
1757 install_required_packages $package_name
1760 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1761 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1764 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1771 rm -f ".$package-req.txt"
1773 echo "Attempting to run spawn sub - builder..."
1774 echo -ne "Package installation failed:\t$package\n"
1775 run_sub_builder $package
1776 if [ $? -eq 0 ]; then
1777 install_required_packages $package
1780 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1781 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1784 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1790 echo "Package $package is already installed. BuildRequirement satisfied."
1794 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1795 echo "Unable to install following packages and their dependencies:"
1796 for pkg in "$NOT_INSTALLED_PACKAGES"
1800 remove_build_requires
1808 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1809 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1811 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1813 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1817 echo "To checkout *all* .spec files:"
1818 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1819 echo "- run cvs up in $SPECS_DIR dir"
1822 echo "To commit with your developer account:"
1823 echo "- edit $SPECS_DIR/CVS/Root"
1824 echo "- edit $SOURCE_DIR/CVS/Root"
1827 #---------------------------------------------
1835 while [ $# -gt 0 ]; do
1838 COMMAND="update_md5"
1843 COMMAND="update_md5"
1853 DEBUG="yes"; shift ;;
1855 COMMAND="version"; shift ;;
1857 COMMAND="short-version"; shift ;;
1859 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1860 -b | -ba | --build )
1861 COMMAND="build"; shift ;;
1862 -bb | --build-binary )
1863 COMMAND="build-binary"; shift ;;
1865 COMMAND="build-build"; shift ;;
1867 COMMAND="build-install"; shift ;;
1869 COMMAND="build-list"; shift ;;
1870 -bp | --build-prep )
1871 COMMAND="build-prep"; shift ;;
1872 -bs | --build-source )
1873 COMMAND="build-source"; shift ;;
1875 COMMAND="branch"; shift; TAG="${1}"; shift;;
1877 CLEAN="--clean --rmspec --rmsource"; shift ;;
1879 CVS_FORCE="-F"; shift;;
1881 shift; CVSROOT="${1}"; shift ;;
1883 COMMAND="get"; shift ;;
1885 COMMAND="usage"; shift ;;
1887 PROTOCOL="http"; shift ;;
1889 shift; LOGFILE="${1}"; shift ;;
1891 shift; DEF_NICE_LEVEL=${1}; shift ;;
1892 -ske | --skip-existing-files)
1893 SKIP_EXISTING_FILES="yes"; shift ;;
1895 COMMAND="mr-proper"; shift ;;
1897 NOCVS="yes"; shift ;;
1898 -ncs | --no-cvs-specs )
1899 NOCVSSPEC="yes"; shift ;;
1900 -nd | --no-distfiles )
1901 NODIST="yes"; shift ;;
1902 -nm | --no-mirrors )
1903 NOMIRRORS="yes"; shift ;;
1905 NOURLS="yes"; shift ;;
1907 NOSRCS="yes"; shift ;;
1908 -ns0 | --no-source0 )
1909 NOSOURCE0="yes"; shift ;;
1923 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
1925 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1926 --with | --without )
1927 case $GROUP_BCONDS in
1931 while ! `echo ${1}|grep -qE '(^-|spec)'`
1933 BCOND="$BCOND $COND $1"
1937 if [[ "$2" = *,* ]]; then
1938 for a in $(echo "$2" | tr , ' '); do
1939 BCOND="$BCOND $1 $a"
1942 BCOND="$BCOND $1 $2"
1948 shift; TARGET="${1}"; shift ;;
1950 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1952 QUIET="--quiet"; shift ;;
1954 CVSDATE="${2}"; shift 2 ;;
1956 shift; CVSTAG="${1}"; shift ;;
1958 shift; CVSTAG="HEAD"; ;;
1959 -R | --fetch-build-requires)
1960 FETCH_BUILD_REQUIRES="yes"
1961 NOT_INSTALLED_PACKAGES=
1963 -RB | --remove-build-requires)
1964 REMOVE_BUILD_REQUIRES="nice"
1966 -FRB | --force-remove-build-requires)
1967 REMOVE_BUILD_REQUIRES="force"
1969 -sc | --sources-cvs)
1970 COMMAND="list-sources-cvs"
1972 -sd | --sources-distfiles)
1973 COMMAND="list-sources-distfiles"
1975 -sdp | --sources-distfiles-paths)
1976 COMMAND="list-sources-distfiles-paths"
1978 -sf | --sources-files)
1979 COMMAND="list-sources-files"
1981 -sp | --sources-paths)
1982 COMMAND="list-sources-local-paths"
1984 -su | --sources-urls)
1985 COMMAND="list-sources-urls"
1987 -Tvs | --tag-version-stable )
1992 -Ts | --tag-stable )
1997 -Tv | --tag-version )
2002 -Tp | --tag-prefix )
2014 -ir | --integer-release-only )
2015 INTEGER_RELEASE="yes"
2018 COMMAND="update_md5"
2023 -Upi | --update-poldek-indexes )
2024 UPDATE_POLDEK_INDEXES="yes"
2027 COMMAND="init_rpm_dir"
2029 -u | --try-upgrade )
2030 TRY_UPGRADE="1"; shift ;;
2031 -un | --try-upgrade-with-float-version )
2032 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2034 BE_VERBOSE="1"; shift ;;
2039 if echo "${MACRO}" | grep -q '\W'; then
2040 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2044 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2048 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2051 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2052 COMMAND="show_bconds"
2056 COMMAND="show_bcond_args"
2061 RPMOPTS="${RPMOPTS} --nodeps"
2064 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2067 Exit_error err_invalid_cmdline "$1"
2071 # check if specname was passed as specname:cvstag
2072 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2073 CVSTAG="${SPECFILE##*:}"
2074 SPECFILE="${SPECFILE%%:*}"
2076 ASSUMED_NAME="${SPECFILE%%.spec}"
2081 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2082 CVSTAG=$(awk -vSPECFILE="${SPECFILE%.spec}.spec" -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2083 if [ "$CVSTAG" ]; then
2084 echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
2086 elif [ "$CVSTAG" = "HEAD" ]; then
2087 # assume -r HEAD is same as -A
2091 if [ -n "$DEBUG" ]; then
2096 if [ -n "$TARGET" ]; then
2099 TARGET_SWITCH="--target $TARGET" ;;
2101 TARGET_SWITCH="--target=$TARGET" ;;
2105 if [ "$SCHEDTOOL" != "no" ]; then
2106 NICE_COMMAND="$SCHEDTOOL"
2108 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2111 update_shell_title "$COMMAND"
2115 if [ -n "$SPECFILE" ]; then
2116 get_spec > /dev/null
2124 if [ -n "$SPECFILE" ]; then
2125 get_spec > /dev/null
2131 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2133 if [ -n "$SPECFILE" ]; then
2139 if [ "$COMMAND" != "build-source" ]; then
2142 fetch_build_requires
2143 if [ "$INTEGER_RELEASE" = "yes" ]; then
2144 echo "Checking release $PACKAGE_RELEASE..."
2145 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2146 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2150 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2151 if [ -n "$TEST_TAG" ]; then
2152 # - do not allow utf8 encoded specs on AC-branch
2153 if [ "$CVSTAG" = "AC-branch-disabled" ]; then
2155 t=$(grep '^Summary(.*\.UTF-8):' $SPECFILE)
2157 Exit_error err_acl_deny "UTF-8 .specs not allowed on $CVSTAG"
2161 local TAGVER=`make_tagver`
2162 echo "Searching for tag $TAGVER..."
2163 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2164 if [ -n "$TAGREL" ]; then
2165 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2168 # - do not allow to build from HEAD when XX-branch exists
2169 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2170 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2171 TAG_BRANCH="${TREE_PREFIX}-branch"
2172 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2173 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2174 Exit_error err_branch_exists "$TAG_STATUS"
2180 if [ -n "$NOSOURCE0" ] ; then
2181 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2183 get_files $SOURCES $PATCHES
2186 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2187 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2189 remove_build_requires
2191 Exit_error err_no_spec_in_cmdl
2196 if [ -n "$SPECFILE" ]; then
2199 # don't fetch sources from remote locations
2201 for file in $SOURCES; do
2202 [ -n "`src_md5 $file`" ] && continue
2203 new_SOURCES="$new_SOURCES $file"
2205 SOURCES="$new_SOURCES"
2206 get_files $SOURCES $PATCHES
2208 branch_files $TAG $SOURCES $PATCHES $ICONS
2210 Exit_error err_no_spec_in_cmdl
2215 if [ -n "$SPECFILE" ]; then
2219 if [ -n "$NOSOURCE0" ] ; then
2220 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2222 get_files $SOURCES $PATCHES
2225 Exit_error err_no_spec_in_cmdl
2230 if [ -n "$SPECFILE" ]; then
2234 if [ -n "$NOSOURCE0" ] ; then
2235 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2239 Exit_error err_no_spec_in_cmdl
2246 if [ -n "$SPECFILE" ]; then
2250 # don't fetch sources from remote locations
2252 for file in $SOURCES; do
2253 [ -n "`src_md5 $file`" ] && continue
2254 new_SOURCES="$new_SOURCES $file"
2256 SOURCES="$new_SOURCES"
2257 get_files $SOURCES $PATCHES
2259 tag_files $SOURCES $PATCHES $ICONS
2261 Exit_error err_no_spec_in_cmdl
2265 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
2267 "list-sources-files" )
2270 DONT_PRINT_REVISION="yes"
2273 for SAP in $SOURCES $PATCHES; do
2274 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2277 "list-sources-urls" )
2280 DONT_PRINT_REVISION="yes"
2283 SAPS="$SOURCES $PATCHES"
2284 for SAP in $SAPS ; do
2288 "list-sources-local-paths" )
2291 DONT_PRINT_REVISION="yes"
2294 for SAP in $SOURCES $PATCHES; do
2295 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2298 "list-sources-distfiles-paths" )
2301 DONT_PRINT_REVISION="yes"
2304 for SAP in $SOURCES $PATCHES; do
2305 if [ -n "$(src_md5 "$SAP")" ]; then
2306 distfiles_path "$SAP"
2310 "list-sources-distfiles" )
2313 DONT_PRINT_REVISION="yes"
2316 for SAP in $SOURCES $PATCHES; do
2317 if [ -n "$(src_md5 "$SAP")" ]; then
2318 distfiles_url "$SAP"
2322 "list-sources-cvs" )
2325 DONT_PRINT_REVISION="yes"
2328 for SAP in $SOURCES $PATCHES; do
2329 if [ -z "$(src_md5 "$SAP")" ]; then
2330 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2344 echo "$VERSIONSTRING"
2347 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2348 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2352 # vi:syntax=sh:ts=4:sw=4:noet