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"
49 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
52 # user agent when fetching files
53 USER_AGENT="PLD/Builder($VERSION)"
55 # It can be used i.e. in log file naming.
56 # See LOGFILE example.
57 DATE=`date +%Y-%m-%d_%H-%M-%S`
59 # Example: LOGFILE='../log.$PACKAGE_NAME'
60 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
61 # Yes, you can use variable name! Note _single_ quotes!
85 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
86 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
92 CVS_SERVER="cvs.pld-linux.org"
93 DISTFILES_SERVER="://distfiles.pld-linux.org"
94 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
99 FAIL_IF_NO_SOURCES="yes"
101 # let get_files skip over files which are present to get those damn files fetched
102 SKIP_EXISTING_FILES="no"
105 # should the specfile be restored if upgrade failed?
106 REVERT_BROKEN_UPGRADE="yes"
108 if [ -x /usr/bin/rpm-getdeps ]; then
109 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
111 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
114 # Here we load saved user environment used to
115 # predefine options set above, or passed to builder
117 # This one reads global system environment settings:
118 if [ -f ~/etc/builderrc ]; then
121 # And this one cascades settings using user personal
123 # Example of ~/.builderrc:
125 #UPDATE_POLDEK_INDEXES="yes"
126 #FETCH_BUILD_REQUIRES="yes"
127 #REMOVE_BUILD_REQUIRES="force"
129 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
133 if [ -n "$HOME_ETC" ]; then
134 USER_CFG="$HOME_ETC/.builderrc"
135 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
137 USER_CFG=~/.builderrc
138 BUILDER_MACROS=~/.builder-rpmmacros
141 [ -f "$USER_CFG" ] && . "$USER_CFG"
143 if [ "$SCHEDTOOL" = "auto" ]; then
144 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
145 SCHEDTOOL="schedtool -B -e"
151 if [ -n "$USE_PROZILLA" ]; then
152 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
155 elif [ -n "$USE_AXEL" ]; then
156 GETURI="axel -a $AXEL_OPTS"
160 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
161 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
162 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
163 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
165 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
166 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
172 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
180 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
181 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
185 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
186 if [ -n "$LOGFILE" ]; then
187 LOG=`eval echo $LOGFILE`
188 if [ -n "$LASTLOG_FILE" ]; then
189 echo "LASTLOG=$LOG" > $LASTLOG_FILE
191 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
194 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
195 return `cat ${RES_FILE}`
200 #---------------------------------------------
205 if [ -n "$DEBUG" ]; then set -xv; fi
207 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
208 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
209 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
210 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
211 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
212 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
213 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
214 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
215 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
216 <package>[.spec][:cvstag]
218 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
219 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
220 -n5, --no-md5 - ignore md5 comments in spec
221 -D, --debug - enable builder script debugging mode,
222 -debug - produce rpm debug package (same as --opts -debug)
223 -V, --version - output builder version string
224 --short-version - output builder short version
225 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
226 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
228 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
229 only package from <package>.spec,
230 -bp, --build-prep - execute the %prep phase of <package>.spec,
231 -bc - execute the %build phase of <package>.spec,
232 -bi - execute the %install phase of <package>.spec
233 -bl - execute the %files phase of <package>.spec
234 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
236 --short-circuit - short-circuit build
237 -B, --branch - add branch
238 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
239 SPECS and \$RPM_BUILD_ROOT),
240 -cf, --cvs-force - use -F when tagging (useful when moving branches)
241 -d <cvsroot>, --cvsroot <cvsroot>
243 --define <macro> <value>
244 - define a macro <macro> with value <value>,
245 --nodeps - rpm won't check any dependences
246 -g, --get - get <package>.spec and all related files from CVS repo
248 -h, --help - this message,
249 --http - use http instead of ftp,
250 -l <logfile>, --logtofile <logfile>
252 -m, --mr-proper - only remove all files related to spec file and all work
254 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
256 - don't check specs in CVS
257 -nd, --no-distfiles - don't download from distfiles
258 -nm, --no-mirrors - don't download from mirror, if source URL is given,
259 -nu, --no-urls - don't try to download from FTP/HTTP location,
260 -ns, --no-srcs - don't download Sources
261 -ns0, --no-source0 - don't download Source0
262 -nn, --no-net - don't download anything from the net
263 --no-init - don't initialize builder paths (SPECS and SOURCES)
265 --skip-existing-files - skip existing files in get_files
266 --opts <rpm opts> - additional options for rpm
267 -q, --quiet - be quiet,
268 --date yyyy-mm-dd - build package using resources from specified CVS date,
269 -r <cvstag>, --cvstag <cvstag>
270 - build package using resources from specified CVS tag,
271 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
272 -R, --fetch-build-requires
273 - fetch what is BuildRequired,
274 -RB, --remove-build-requires
275 - remove all you fetched with -R or --fetch-build-requires
276 remember, this option requires confirmation,
277 -FRB, --force-remove-build-requires
278 - remove all you fetched with -R or --fetch-build-requires
279 remember, this option works without confirmation,
280 -sd, --source-distfiles - list sources available from distfiles (intended for offline
281 operations; does not work when Icon field is present
282 but icon file is absent),
283 -sc, --source-cvs - list sources available from CVS
284 -sdp, --source-distfiles-paths - list sources available from distfiles -
285 paths relative to distfiles directory (intended for offline
286 operations; does not work when Icon field is present
287 but icon file is absent),
288 -sf, --source-files - list sources - bare filenames (intended for offline
289 operations; does not work when Icon field is present
290 but icon file is absent),
291 -sp, --source-paths - list sources - filenames with full local paths (intended for
292 offline operations; does not work when Icon field is present
293 but icon file is absent),
294 -su, --source-urls - list urls - urls to sources and patches
295 intended for copying urls with spec with lots of macros in urls
296 -T <cvstag> , --tag <cvstag>
297 - add cvs tag <cvstag> for files,
298 -Tvs, --tag-version-stable
299 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
301 - add cvs tag STABLE for files,
303 - add cvs tag NAME-VERSION-RELEASE for files,
304 -Tp, --tag-prefix <prefix>
305 - add <prefix> to NAME-VERSION-RELEASE tags,
306 -tt, --test-tag <prefix>
307 - fail if tag is already present,
308 -ir, --integer-release-only
309 - allow only integer and snapshot releases
310 -v, --verbose - be verbose,
311 -u, --try-upgrade - check version, and try to upgrade package
312 -un, --try-upgrade-with-float-version
313 - as above, but allow float version
314 -U, --update - refetch sources, don't use distfiles, and update md5 comments
315 -Upi, --update-poldek-indexes
316 - refresh or make poldek package index files.
317 -np, --nopatch <patchnumber>
318 - don't apply <patchnumber>
319 --show-bconds - show available conditional builds, which can be used
320 - with --with and/or --without switches.
321 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
322 ./repackage.sh script. in other words, the output is
323 parseable by scripts.
324 --with/--without <feature>
325 - conditional build package depending on %_with_<feature>/
326 %_without_<feature> macro switch. You may now use
327 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
328 constructions. Set GROUP_BCONDS to yes to make use of it.
329 --target <platform>, --target=<platform>
330 - build for platform <platform>.
331 --init-rpm-dir - initialize ~/rpm directory structure
335 update_shell_title() {
337 local len=${COLUMNS:-80}
338 local msg=$(echo "$*" | cut -c-$len)
340 if [ -n "$BE_VERBOSE" ]; then
341 echo >&2 "$(date +%s.%N) $*"
344 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
346 if [ -n "$PACKAGE_NAME" ]; then
347 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
352 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
353 msg="$(echo $msg | tr -d '\n\r')"
356 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
359 echo >&2 -ne "\033]0;$msg\007"
365 # set TARGET from BuildArch: from SPECFILE
367 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
368 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
370 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
374 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
376 TARGET_SWITCH="--target=$TARGET" ;;
382 # runs rpm with minimal macroset
384 # we reset macros not to contain macros.build as all the %() macros are
385 # executed here, while none of them are actually needed.
386 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
387 safe_macrofiles=$(rpm --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
389 # TODO: move these to /usr/lib/rpm/macros
390 cat > $BUILDER_MACROS <<'EOF'
391 %x8664 x86_64 amd64 ia32e
394 %requires_releq_kernel_up %{nil}
395 %requires_releq_kernel_smp %{nil}
396 %requires_releq_kernel %{nil}
397 %requires_releq() %{nil}
398 %pyrequires_eq() %{nil}
399 %requires_eq() %{nil}
400 %requires_eq_to() %{nil}
401 %releq_kernel_up ERROR
402 %releq_kernel_smp ERROR
407 %ruby_ver_requires_eq() %{nil}
408 %ruby_mod_ver_requires_eq() %{nil}
409 %__php_api_requires() %{nil}
410 %php_major_version ERROR
411 %php_api_version ERROR
413 %perl_vendorarch ERROR
414 %perl_vendorlib ERROR
415 # damn. need it here! - copied from /usr/lib/rpm/macros.build
416 %tmpdir %(echo "${TMPDIR:-/tmp}")
417 %patchset_source(f:b:) %(
418 base=%{-b*}%{!-b*:10000};
419 start=$(expr $base + %1);
420 end=$(expr $base + %{?2}%{!?2:%{1}});
421 # we need to call seq twice as it doesn't allow two formats
422 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
423 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
424 paste %{tmpdir}/__ps{1,2};
425 rm -f %{tmpdir}/__ps{1,2};
429 if [ "$NOINIT" = "yes" ] ; then
430 cat >> $BUILDER_MACROS <<'EOF'
435 eval $RPMBUILD --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $* 2>&1
439 if [ -n "$DEBUG" ]; then
444 update_shell_title "cache_rpm_dump"
447 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
448 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
454 ARGS='--nodigest --nosignature --nobuild'
457 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
459 if [ $? -gt 0 ]; then
460 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
462 Exit_error err_build_fail
465 # make small dump cache
466 rpm_dump_cache=`echo "$rpm_dump" | awk '
467 $2 ~ /^SOURCEURL/ {print}
468 $2 ~ /^PATCHURL/ {print}
469 $2 ~ /^nosource/ {print}
470 $2 ~ /^PACKAGE_/ {print}
473 update_shell_title "cache_rpm_dump: OK!"
477 if [ -z "$rpm_dump_cache" ] ; then
478 echo "internal error: cache_rpm_dump not called! (missing %prep?)" 1>&2
480 echo "$rpm_dump_cache"
485 update_shell_title "get icons"
486 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
487 if [ -z "$ICONS" ]; then
491 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
496 update_shell_title "parsing specfile"
497 if [ -n "$DEBUG" ]; then
502 # icons are needed for successful spec parse
508 if [ "$NOSRCS" != "yes" ]; then
509 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
512 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
513 FAIL_IF_NO_SOURCES="no"
516 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
517 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
518 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
519 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
520 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
522 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
523 echo "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
526 if [ -n "$BE_VERBOSE" ]; then
527 echo "- Sources : `nourl $SOURCES`"
528 if [ -n "$PATCHES" ]; then
529 echo "- Patches : `nourl $PATCHES`"
531 echo "- Patches : *no patches needed*"
533 if [ -n "$ICONS" ]; then
534 echo "- Icon : `nourl $ICONS`"
536 echo "- Icon : *no package icon*"
538 echo "- Name : $PACKAGE_NAME"
539 echo "- Version : $PACKAGE_VERSION"
540 echo "- Release : $PACKAGE_RELEASE"
543 update_shell_title "parse_spec: OK!"
548 if [ -n "$DEBUG" ]; then
556 "err_no_spec_in_cmdl" )
557 remove_build_requires
558 echo "ERROR: spec file name not specified."
560 "err_invalid_cmdline" )
561 echo "ERROR: invalid command line arg ($2)."
563 "err_no_spec_in_repo" )
564 remove_build_requires
565 echo "Error: spec file not stored in CVS repo."
567 "err_no_source_in_repo" )
568 remove_build_requires
569 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)"
572 remove_build_requires
573 echo "Error: package build failed. (${2:-no more info})"
575 "err_no_package_data" )
576 remove_build_requires
577 echo "Error: couldn't get out package name/version/release from spec file."
580 remove_build_requires
581 echo "Tag ${2} already exists (spec release: ${3})."
584 remove_build_requires
585 echo "Release ${2} not integer and not a snapshot."
587 "err_branch_exists" )
588 remove_build_requires
589 echo "Tree branch already exists (${2})."
592 remove_build_requires
593 echo "Error: conditions reject building this spec (${2})."
596 echo "Unknown error."
602 if [ -n "$DEBUG" ]; then
607 if [ "$NOINIT" != "yes" ] ; then
608 SOURCE_DIR="`eval $RPM $RPMOPTS --define '"name $ASSUMED_NAME"' --eval '%{_sourcedir}'`"
609 SPECS_DIR="`eval $RPM $RPMOPTS --define '"name $ASSUMED_NAME"' --eval '%{_specdir}'`"
621 update_shell_title "get_spec"
623 if [ -n "$DEBUG" ]; then
629 if [ ! -f "$SPECFILE" ]; then
630 SPECFILE="`basename $SPECFILE .spec`.spec"
632 if [ "$NOCVSSPEC" != "yes" ]; then
634 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
635 echo "Warning: No CVS access defined - using local .spec file"
639 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
642 if [ ! -f "$SPECFILE" ]; then
643 Exit_error err_no_spec_in_repo
646 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
647 chmod $CHMOD_MODE $SPECFILE
650 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
659 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
660 cvs update mirrors >&2
664 local origin mirror name rest ol prefix
665 while read origin mirror name rest; do
666 # skip comments and empty lines
667 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
670 ol=`echo -n "$origin"|wc -c`
671 prefix="`echo -n "$url" | head -c $ol`"
672 if [ "$prefix" = "$origin" ] ; then
673 suffix="`echo "$url"|cut -b $((ol+1))-`"
674 echo -n "$mirror$suffix"
681 # Warning: unpredictable results if same URL used twice
686 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
687 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
693 [ "$NO5" = "yes" ] && return
695 [ -z "$no" ] && return
699 if [ -f additional-md5sums ]; then
700 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
701 if [ -z "$spec_rev" ]; then
702 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
704 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
705 md5=$(grep -s -v '^#' additional-md5sums | \
706 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
707 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
708 grep -E '^[0-9a-f]{32}$')
711 if [ $(echo "$md5" | wc -l) != 1 ] ; then
712 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
714 echo "$md5" | tail -n 1
719 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
720 if [ -n "$source_md5" ]; then
723 # we have empty SourceX-md5, but it is still possible
724 # that we have NoSourceX-md5 AND NoSource: X
725 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
726 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
734 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
739 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
742 distfiles_attic_url ()
744 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
751 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
756 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
757 [ -n "$size" -a "$size" -gt 0 ]
762 if [ "$CVSIGNORE_DF" != "yes" ]; then
765 cvsignore=${SOURCE_DIR}/.cvsignore
766 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
767 echo "$1" >> $cvsignore
773 update_shell_title "cvsup"
775 if [ -n "$CVSROOT" ]; then
776 OPTIONS="-d $CVSROOT $OPTIONS"
779 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
780 OPTIONS="$OPTIONS -A"
782 if [ -n "$CVSDATE" ]; then
783 OPTIONS="$OPTIONS -D $CVSDATE"
785 if [ -n "$CVSTAG" ]; then
786 OPTIONS="$OPTIONS -r $CVSTAG"
791 local retries_counter=0
793 update_shell_title "cvsup: $*"
795 update_shell_title "cvsup: $# files"
797 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
798 retries_counter=$(( $retries_counter + 1 ))
799 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
801 [ -n "$output" ] && echo "$output"
802 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
803 echo "Trying again [$*]... ($retries_counter)"
804 update_shell_title "cvsup: retry #$retries_counter"
811 update_shell_title "cvsup: done!"
815 # returns true if "$1" is ftp, http or https protocol url
819 ftp://*|http://*|https://*)
828 if [ $# -eq 0 ]; then
832 update_shell_title "update md5"
833 if [ -n "$DEBUG" ]; then
840 # pass 1: check files to be fetched
844 local fp=$(nourl "$i")
845 local srcno=$(src_no "$i")
846 if [ -n "$ADD5" ]; then
847 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
848 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
850 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
852 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
853 need_files="$need_files $i"
857 # pass 1a: get needed files
858 if [ "$need_files" ]; then
859 get_files $need_files
862 # pass 2: proceed with md5 adding or updating
864 local fp=$(nourl "$i")
865 local srcno=$(src_no "$i")
866 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
867 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
868 local tag="Source$srcno-md5"
869 if [[ "$md5" == *NoSource* ]]; then
870 tag="NoSource$srcno-md5"
872 md5=$(md5sum "$fp" | cut -f1 -d' ')
873 echo "Updating $tag ($md5: $fp)."
875 print unless /^\s*#\s*(No)?Source'$srcno'-md5\s*:/i;
876 print "# '$tag':\t'$md5'\n" if /^Source'$srcno'\s*:\s+/;
885 update_shell_title "check md5"
888 if good_md5 "$i" && good_size "$i"; then
892 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
893 echo "or -5 to update md5 sums, if you're sure files are correct."
894 Exit_error err_no_source_in_repo $i
900 update_shell_title "get_files"
902 if [ -n "$DEBUG" ]; then
907 if [ $# -gt 0 ]; then
910 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
911 echo "Warning: No CVS access defined for SOURCES"
916 local get_files_cvs=""
920 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
921 update_shell_title "$i"
922 local fp=`nourl "$i"`
923 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
928 local srcmd5=$(src_md5 "$i")
930 # we know if source/patch is present in cvs/distfiles
931 # - has md5 (in distfiles)
934 # CHECK: local file didn't exist or always cvs up (first) requested.
935 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
936 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
937 echo "Warning: no URL given for $i"
940 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
941 if good_md5 "$i" && good_size "$i"; then
942 echo "$fp having proper md5sum already exists"
947 # optionally prefer mirror over distfiles if there's mirror
948 # TODO: build url list and then try each url from the list
949 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
952 url=$(distfiles_url "$i")
955 url_attic=$(distfiles_attic_url "$i")
957 # is $url local file?
958 if [[ "$url" = [./]* ]]; then
959 update_shell_title "${GETLOCAL%% *}: $url"
960 ${GETLOCAL} $url $target
962 if [ -z "$NOMIRRORS" ]; then
963 url=$(find_mirror "$url")
967 # make shorter message for distfiles urls
968 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
969 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
970 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
973 update_shell_title "${GETURI%% *}: $uri"
974 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
975 if [ "`echo $url | grep -E 'ftp://'`" ]; then
976 update_shell_title "${GETURI2%% *}: $url"
977 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
982 if [ ! -s "$target" ]; then
984 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
985 update_shell_title "${GETLOCAL%% *}: $url_attic"
986 ${GETLOCAL} $url_attic $target
988 if [ -z "$NOMIRRORS" ]; then
989 url_attic="`find_mirror "$url_attic"`"
991 update_shell_title "${GETURI%% *}: $url_attic"
992 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
993 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
994 update_shell_title "${GETURI2%% *}: $url_attic"
995 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1000 if [ -s "$target" ]; then
1001 cvsignore_df $target
1006 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1007 if [ $# -gt 1 ]; then
1008 get_files_cvs="$get_files_cvs $fp"
1009 update_shell_title "$fp (will cvs up later)"
1016 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1017 if [ -z "$NOMIRRORS" ]; then
1018 im="`find_mirror "$i"`"
1022 update_shell_title "${GETURI%% *}: $im"
1023 ${GETURI} "$im" || \
1024 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1025 update_shell_title "${GETURI2%% *}: $im"
1030 if [ "$cvsup" = 1 ]; then
1036 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1037 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1038 Exit_error err_no_source_in_repo $i
1041 # we check md5 here just only to refetch immediately
1042 if good_md5 "$i" && good_size "$i"; then
1044 elif [ "$FROM_DISTFILES" = 1 ]; then
1045 # wrong md5 from distfiles: remove the file and try again
1047 echo "MD5 sum mismatch. Trying full fetch."
1050 update_shell_title "${GETURI%% *}: $url"
1051 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1052 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1053 update_shell_title "${GETURI2%% *}: $url"
1054 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1056 if [ ! -s "$target" ]; then
1058 update_shell_title "${GETURI%% *}: $url_attic"
1059 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1060 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1061 update_shell_title "${GETURI2%% *}: $url_attic"
1062 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1065 test -s "$target" || rm -f "$target"
1068 SHELL_TITLE_PREFIX=""
1070 if [ "$get_files_cvs" ]; then
1071 cvsup $get_files_cvs
1074 if [ "$CHMOD" = "yes" ]; then
1075 CHMOD_FILES="`nourl "$@"`"
1076 if [ -n "$CHMOD_FILES" ]; then
1077 chmod $CHMOD_MODE $CHMOD_FILES
1084 if [ -n "$DEBUG" ]; then
1089 # Check whether first character of PACKAGE_NAME is legal for tag name
1090 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1094 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1095 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1097 # Remove #kernel.version_release from TAGVER because tagging sources
1098 # could occur with different kernel-headers than kernel-headers used at build time.
1099 # besides, %{_kernel_ver_str} is not expanded.
1101 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1102 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1112 if [ -n "$DEBUG" ]; then
1117 echo "Version: $PACKAGE_VERSION"
1118 echo "Release: $PACKAGE_RELEASE"
1121 if [ "$TAG_VERSION" = "yes" ]; then
1122 TAGVER=`make_tagver`
1123 echo "CVS tag: $TAGVER"
1125 if [ -n "$TAG" ]; then
1126 echo "CVS tag: $TAG"
1129 local OPTIONS="tag $CVS_FORCE"
1130 if [ -n "$CVSROOT" ]; then
1131 OPTIONS="-d $CVSROOT $OPTIONS"
1136 for i in $TAG_FILES; do
1137 # don't tag files stored on distfiles
1138 [ -n "`src_md5 $i`" ] && continue
1139 local fp=`nourl "$i"`
1140 if [ -f "$fp" ]; then
1141 tag_files="$tag_files $fp"
1143 Exit_error err_no_source_in_repo $i
1147 if [ "$tag_files" ]; then
1148 if [ "$TAG_VERSION" = "yes" ]; then
1149 update_shell_title "tag sources: $TAGVER"
1150 cvs $OPTIONS $TAGVER $tag_files || exit
1152 if [ -n "$TAG" ]; then
1153 update_shell_title "tag sources: $TAG"
1154 cvs $OPTIONS $TAG $tag_files || exit
1159 if [ "$TAG_VERSION" = "yes" ]; then
1160 update_shell_title "tag spec: $TAGVER"
1161 cvs $OPTIONS $TAGVER $SPECFILE || exit
1163 if [ -n "$TAG" ]; then
1164 update_shell_title "tag spec: $TAG"
1165 cvs $OPTIONS $TAG $SPECFILE || exit
1172 echo "CVS branch tag: $TAG"
1177 if [ -n "$DEBUG" ]; then
1182 local OPTIONS="tag $CVS_FORCE -b"
1183 if [ -n "$CVSROOT" ]; then
1184 OPTIONS="-d $CVSROOT $OPTIONS"
1188 for i in $TAG_FILES; do
1189 local fp=`nourl "$i"`
1190 if [ -f "$fp" ]; then
1191 tag_files="$tag_files $fp"
1193 Exit_error err_no_source_in_repo $i
1196 if [ "$tag_files" ]; then
1197 cvs $OPTIONS $TAG $tag_files || exit
1201 cvs $OPTIONS $TAG $SPECFILE || exit
1205 # this function should exit early if package can't be built for this arch
1206 # this avoids unneccessary BR filling.
1209 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1211 if [ $ret -ne 0 ]; then
1220 update_shell_title "build_package"
1221 if [ -n "$DEBUG" ]; then
1228 if [ -n "$TRY_UPGRADE" ]; then
1229 update_shell_title "build_package: try_upgrade"
1230 if [ -n "$FLOAT_VERSION" ]; then
1231 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1233 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1236 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1238 if [ -n "$TNEWVER" ]; then
1239 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1240 echo "New version found, updating spec file to version " $TNEWVER
1241 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1242 cp -f $SPECFILE $SPECFILE.bak
1245 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1246 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1248 NODIST="yes" get_files $SOURCES $PATCHES
1251 unset TOLDVER TNEWVER TNOTIFY
1258 BUILD_SWITCH="-ba" ;;
1260 BUILD_SWITCH="-bb" ;;
1262 BUILD_SWITCH="-bs --nodeps" ;;
1264 BUILD_SWITCH="-bp --nodeps" ;;
1266 BUILD_SWITCH="-bc" ;;
1268 BUILD_SWITCH="-bi" ;;
1270 BUILD_SWITCH="-bl" ;;
1274 update_shell_title "build_package: $COMMAND"
1275 if [ -n "$LOGFILE" ]; then
1276 LOG=`eval echo $LOGFILE`
1277 if [ -d "$LOG" ]; then
1278 echo "Log file $LOG is a directory."
1279 echo "Parse error in the spec?"
1280 Exit_error err_build_fail
1282 if [ -n "$LASTLOG_FILE" ]; then
1283 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1285 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1286 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1287 RETVAL=`cat $RES_FILE`
1289 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1290 if [ "$RETVAL" -eq "0" ]; then
1297 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1300 if [ "$RETVAL" -ne "0" ]; then
1301 if [ -n "$TRY_UPGRADE" ]; then
1302 echo "\n!!! Package with new version cannot be built automagically\n"
1303 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1304 mv -f $SPECFILE.bak $SPECFILE
1307 Exit_error err_build_fail
1314 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1317 install_required_packages()
1324 # taken from find-spec-bcond, but with just getting the list
1326 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1328 /^%changelog/ { exit }
1329 /_with(out)?_[_a-zA-Z0-9]+/{
1330 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1331 print substr($0, RSTART, RLENGTH);
1334 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1335 bcond = substr($0, RSTART +5 , RLENGTH -5);
1336 gsub(/[ \t]+/,"_",bcond);
1338 }' $SPEC | LC_ALL=C sort -u
1342 # expand bconds from ~/.bcondrc
1343 # The file structure is like gentoo's package.use:
1346 # samba -mysql -pgsql
1347 # w32codec-installer license_agreement
1350 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1356 SN=${SPECFILE%%\.spec}
1358 local bcondrc=$HOME/.bcondrc
1359 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1361 local bcond_avail=$(find_spec_bcond $SPECFILE)
1363 while read pkg flags; do
1365 [[ "$pkg" == \#* ]] && continue
1367 # any package or current package?
1368 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1369 for flag in $flags; do
1370 local opt=${flag#[+-]}
1372 # use only flags which are in this package.
1373 if [[ $bcond_avail = *${opt}* ]]; then
1374 if [[ $flag = -* ]]; then
1375 if [[ $BCOND != *--with?${opt}* ]]; then
1376 BCOND="$BCOND --without $opt"
1379 if [[ $BCOND != *--without?${opt}* ]]; then
1380 BCOND="$BCOND --with $opt"
1387 update_shell_title "parse ~/.bcondrc: DONE!"
1392 update_shell_title "set bcond values"
1394 AVAIL_BCONDS_WITHOUT=""
1395 AVAIL_BCONDS_WITH=""
1396 if `grep -q ^%bcond ${SPECFILE}`; then
1398 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1404 local bcond_avail=$(find_spec_bcond $SPECFILE)
1405 process_bcondrc "$SPECFILE"
1407 update_shell_title "parse bconds"
1408 case "${BCOND_VERSION}" in
1413 echo "Warning: This spec has old style bconds. Fix it || die."
1414 for opt in `echo "$bcond_avail" | grep ^_without_`
1416 AVAIL_BCOND_WITHOUT=${opt#_without_}
1417 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1418 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1420 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1424 for opt in `echo "$bcond_avail" | grep ^_with_`
1426 AVAIL_BCOND_WITH=${opt#_with_}
1427 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1428 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1430 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1435 local cond_type="" # with || without
1436 for opt in $bcond_avail; do
1445 AVAIL_BCOND_WITHOUT=${opt#_without_}
1446 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1447 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1449 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1453 AVAIL_BCOND_WITH=${opt#_with_}
1454 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1455 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1457 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1461 case "$cond_type" in
1464 AVAIL_BCOND_WITH="$opt"
1465 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1466 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1468 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1473 AVAIL_BCOND_WITHOUT="$opt"
1474 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1475 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1477 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1491 update_shell_title "run_sub_builder $package_name"
1493 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1494 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1495 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1496 # jakby nie bylo tego kawalka kodu.
1498 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1499 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1506 # Istnieje taki spec? ${package}.spec
1507 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1508 parent_spec_name=${package}.spec
1509 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1510 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1512 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1518 if [ "${parent_spec_name}" != "" ]; then
1519 spawn_sub_builder $parent_spec_name
1521 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1527 update_shell_title "spawn_sub_builder $package_name"
1530 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1531 sub_builder_opts="${sub_builder_opts} -R"
1533 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1534 sub_builder_opts="${sub_builder_opts} -RB"
1535 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1536 sub_builder_opts="${sub_builder_opts} -FRB"
1538 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1539 sub_builder_opts="${sub_builder_opts} -Upi"
1543 ./builder ${sub_builder_opts} "$@"
1546 remove_build_requires()
1548 if [ "$INSTALLED_PACKAGES" != "" ]; then
1549 case "$REMOVE_BUILD_REQUIRES" in
1551 run_poldek --noask -ve $INSTALLED_PACKAGES
1554 run_poldek --ask -ve $INSTALLED_PACKAGES
1557 echo You may want to manually remove following BuildRequires fetched:
1558 echo $INSTALLED_PACKAGES
1559 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1567 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1568 if [ "$BCOND" != "" ]; then
1569 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1572 echo -ne "\nNo conditional flags passed"
1574 echo -ne "\n\nfrom available:\n"
1575 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1581 if [ "$NOCVSSPEC" != "yes" ]; then
1582 echo -ne "Available branches: "
1583 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1587 # checks a given list of packages/files/provides agains current rpmdb.
1588 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1589 # input can be either STDIN or parameters
1594 if [ "$#" -gt 0 ]; then
1600 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1603 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1605 # other deps (files)
1606 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1609 # checks if given package/files/provides exists in rpmdb.
1610 # inout can be either stdin or parameters
1611 # returns packages wchi hare present in the rpmdb
1616 if [ "$#" -gt 0 ]; then
1622 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1625 fetch_build_requires()
1627 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1628 update_shell_title "fetch build requires"
1629 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1630 # TODO: Conflicts list doesn't check versions
1631 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1632 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1634 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1635 echo "fetch builderequires: install $DEPS; remove $CNFL"
1636 update_shell_title "poldek: install $DEPS; remove $CNFL"
1637 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1639 if [ -n "$CNFL" ]; then
1640 update_shell_title "uninstall conflicting packages: $CNFL"
1641 echo "Trying to uninstall conflicting packages ($CNFL):"
1642 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1645 while [ "$DEPS" ]; do
1646 update_shell_title "install deps: $DEPS"
1647 echo "Trying to install dependencies ($DEPS):"
1648 local log=.${SPECFILE}_poldek.log
1649 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1650 failed=$(awk -F: '/^error:/{print $2}' $log)
1653 if [ -n "$failed" ]; then
1654 for package in $failed; do
1655 # FIXME: sanitise, deps could be not .spec files
1656 spawn_sub_builder -bb $package && ok="$ok $package"
1666 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1667 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1668 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1669 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1670 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1671 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`
1673 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`"
1675 package=`basename "$package_item"|sed -e "s/}$//g"`
1676 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1679 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1680 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1681 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
1686 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1689 if `echo $COND_TST|grep -q 'without_'`; then
1690 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1691 if `echo $COND_TST|grep -q !`; then
1696 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1697 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1698 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1704 elif `echo $COND_TST|grep -q 'with_'`; then
1705 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1706 if `echo $COND_TST|grep -q !`; then
1711 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1712 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1713 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1719 RESULT="${COND_STATE}-${COND_ARGV}"
1721 "with-wout" | "wout-with" )
1724 "wout-wout" | "with-with" )
1728 echo "Action '$RESULT' was not defined for package '$package_item'"
1734 if [ "$GO" = "yes" ]; then
1735 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1736 echo "Testing if $package has subrequirements..."
1737 run_poldek -t -i $package --dumpn=".$package-req.txt"
1738 if [ -f ".$package-req.txt" ]; then
1739 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1741 if [ "$package_name" = "$package" ]; then
1742 echo -ne "Installing BuildRequired package:\t$package_name\n"
1743 update_shell_title "Installing BuildRequired package: ${package_name}"
1744 install_required_packages $package
1746 echo -ne "Installing (sub)Required package:\t$package_name\n"
1747 update_shell_title "Installing (sub)Required package: ${package_name}"
1748 install_required_packages $package_name
1752 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1753 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1756 echo "Attempting to run spawn sub - builder..."
1757 echo -ne "Package installation failed:\t$package_name\n"
1758 run_sub_builder $package_name
1759 if [ $? -eq 0 ]; then
1760 install_required_packages $package_name
1763 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1764 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1767 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1774 rm -f ".$package-req.txt"
1776 echo "Attempting to run spawn sub - builder..."
1777 echo -ne "Package installation failed:\t$package\n"
1778 run_sub_builder $package
1779 if [ $? -eq 0 ]; then
1780 install_required_packages $package
1783 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1784 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1787 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1793 echo "Package $package is already installed. BuildRequirement satisfied."
1797 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1798 echo "Unable to install following packages and their dependencies:"
1799 for pkg in "$NOT_INSTALLED_PACKAGES"
1803 remove_build_requires
1811 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1812 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1814 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1816 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1820 echo "To checkout *all* .spec files:"
1821 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1822 echo "- run cvs up in $SPECS_DIR dir"
1825 echo "To commit with your developer account:"
1826 echo "- edit $SPECS_DIR/CVS/Root"
1827 echo "- edit $SOURCE_DIR/CVS/Root"
1830 #---------------------------------------------
1838 while [ $# -gt 0 ]; do
1841 COMMAND="update_md5"
1846 COMMAND="update_md5"
1856 DEBUG="yes"; shift ;;
1858 COMMAND="version"; shift ;;
1860 COMMAND="short-version"; shift ;;
1862 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1863 -b | -ba | --build )
1864 COMMAND="build"; shift ;;
1865 -bb | --build-binary )
1866 COMMAND="build-binary"; shift ;;
1868 COMMAND="build-build"; shift ;;
1870 COMMAND="build-install"; shift ;;
1872 COMMAND="build-list"; shift ;;
1873 -bp | --build-prep )
1874 COMMAND="build-prep"; shift ;;
1875 -bs | --build-source )
1876 COMMAND="build-source"; shift ;;
1878 COMMAND="branch"; shift; TAG="${1}"; shift;;
1880 CLEAN="--clean --rmspec --rmsource"; shift ;;
1882 CVS_FORCE="-F"; shift;;
1884 shift; CVSROOT="${1}"; shift ;;
1886 COMMAND="get"; shift ;;
1888 COMMAND="usage"; shift ;;
1890 PROTOCOL="http"; shift ;;
1892 shift; LOGFILE="${1}"; shift ;;
1894 shift; DEF_NICE_LEVEL=${1}; shift ;;
1895 -ske | --skip-existing-files)
1896 SKIP_EXISTING_FILES="yes"; shift ;;
1898 COMMAND="mr-proper"; shift ;;
1900 NOCVS="yes"; shift ;;
1901 -ncs | --no-cvs-specs )
1902 NOCVSSPEC="yes"; shift ;;
1903 -nd | --no-distfiles )
1904 NODIST="yes"; shift ;;
1905 -nm | --no-mirrors )
1906 NOMIRRORS="yes"; shift ;;
1908 NOURLS="yes"; shift ;;
1910 NOSRCS="yes"; shift ;;
1911 -ns0 | --no-source0 )
1912 NOSOURCE0="yes"; shift ;;
1922 -pm | --prefer-mirrors )
1929 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
1931 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1932 --with | --without )
1933 case $GROUP_BCONDS in
1937 while ! `echo ${1}|grep -qE '(^-|spec)'`
1939 BCOND="$BCOND $COND $1"
1943 if [[ "$2" = *,* ]]; then
1944 for a in $(echo "$2" | tr , ' '); do
1945 BCOND="$BCOND $1 $a"
1948 BCOND="$BCOND $1 $2"
1954 shift; TARGET="${1}"; shift ;;
1956 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1958 QUIET="--quiet"; shift ;;
1960 CVSDATE="${2}"; shift 2 ;;
1962 shift; CVSTAG="${1}"; shift ;;
1964 shift; CVSTAG="HEAD"; ;;
1965 -R | --fetch-build-requires)
1966 FETCH_BUILD_REQUIRES="yes"
1967 NOT_INSTALLED_PACKAGES=
1969 -RB | --remove-build-requires)
1970 REMOVE_BUILD_REQUIRES="nice"
1972 -FRB | --force-remove-build-requires)
1973 REMOVE_BUILD_REQUIRES="force"
1975 -sc | --sources-cvs)
1976 COMMAND="list-sources-cvs"
1978 -sd | --sources-distfiles)
1979 COMMAND="list-sources-distfiles"
1981 -sdp | --sources-distfiles-paths)
1982 COMMAND="list-sources-distfiles-paths"
1984 -sf | --sources-files)
1985 COMMAND="list-sources-files"
1987 -sp | --sources-paths)
1988 COMMAND="list-sources-local-paths"
1990 -su | --sources-urls)
1991 COMMAND="list-sources-urls"
1993 -Tvs | --tag-version-stable )
1998 -Ts | --tag-stable )
2003 -Tv | --tag-version )
2008 -Tp | --tag-prefix )
2020 -ir | --integer-release-only )
2021 INTEGER_RELEASE="yes"
2024 COMMAND="update_md5"
2029 -Upi | --update-poldek-indexes )
2030 UPDATE_POLDEK_INDEXES="yes"
2033 COMMAND="init_rpm_dir"
2035 -u | --try-upgrade )
2036 TRY_UPGRADE="1"; shift ;;
2037 -un | --try-upgrade-with-float-version )
2038 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2040 BE_VERBOSE="1"; shift ;;
2045 if echo "${MACRO}" | grep -q '\W'; then
2046 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2050 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2054 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2057 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2058 COMMAND="show_bconds"
2062 COMMAND="show_bcond_args"
2067 RPMOPTS="${RPMOPTS} --nodeps"
2070 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2073 Exit_error err_invalid_cmdline "$1"
2077 # check if specname was passed as specname:cvstag
2078 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2079 CVSTAG="${SPECFILE##*:}"
2080 SPECFILE="${SPECFILE%%:*}"
2082 ASSUMED_NAME="$(basename ${SPECFILE%%.spec})"
2087 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2088 CVSTAG=$(awk -vSPECFILE="${SPECFILE%.spec}.spec" -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2089 if [ "$CVSTAG" ]; then
2090 echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
2092 elif [ "$CVSTAG" = "HEAD" ]; then
2093 # assume -r HEAD is same as -A
2097 if [ -n "$DEBUG" ]; then
2102 if [ -n "$TARGET" ]; then
2105 TARGET_SWITCH="--target $TARGET" ;;
2107 TARGET_SWITCH="--target=$TARGET" ;;
2111 if [ "$SCHEDTOOL" != "no" ]; then
2112 NICE_COMMAND="$SCHEDTOOL"
2114 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2117 update_shell_title "$COMMAND"
2121 if [ -n "$SPECFILE" ]; then
2122 get_spec > /dev/null
2130 if [ -n "$SPECFILE" ]; then
2131 get_spec > /dev/null
2137 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2139 if [ -n "$SPECFILE" ]; then
2145 if [ "$COMMAND" != "build-source" ]; then
2148 fetch_build_requires
2149 if [ "$INTEGER_RELEASE" = "yes" ]; then
2150 echo "Checking release $PACKAGE_RELEASE..."
2151 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2152 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2156 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2157 if [ -n "$TEST_TAG" ]; then
2158 # - do not allow utf8 encoded specs on AC-branch
2159 if [ "$CVSTAG" = "AC-branch-disabled" ]; then
2161 t=$(grep '^Summary(.*\.UTF-8):' $SPECFILE)
2163 Exit_error err_acl_deny "UTF-8 .specs not allowed on $CVSTAG"
2167 local TAGVER=`make_tagver`
2168 echo "Searching for tag $TAGVER..."
2169 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2170 if [ -n "$TAGREL" ]; then
2171 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2174 # - do not allow to build from HEAD when XX-branch exists
2175 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2176 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2177 TAG_BRANCH="${TREE_PREFIX}-branch"
2178 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2179 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2180 Exit_error err_branch_exists "$TAG_STATUS"
2186 if [ -n "$NOSOURCE0" ] ; then
2187 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2189 get_files $SOURCES $PATCHES
2192 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2193 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2195 remove_build_requires
2197 Exit_error err_no_spec_in_cmdl
2202 if [ -n "$SPECFILE" ]; then
2205 # don't fetch sources from remote locations
2207 for file in $SOURCES; do
2208 [ -n "`src_md5 $file`" ] && continue
2209 new_SOURCES="$new_SOURCES $file"
2211 SOURCES="$new_SOURCES"
2212 get_files $SOURCES $PATCHES
2214 branch_files $TAG $SOURCES $PATCHES $ICONS
2216 Exit_error err_no_spec_in_cmdl
2221 if [ -n "$SPECFILE" ]; then
2225 if [ -n "$NOSOURCE0" ] ; then
2226 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2228 get_files $SOURCES $PATCHES
2231 Exit_error err_no_spec_in_cmdl
2236 if [ -n "$SPECFILE" ]; then
2240 if [ -n "$NOSOURCE0" ] ; then
2241 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2245 Exit_error err_no_spec_in_cmdl
2252 if [ -n "$SPECFILE" ]; then
2256 # don't fetch sources from remote locations
2258 for file in $SOURCES; do
2259 [ -n "`src_md5 $file`" ] && continue
2260 new_SOURCES="$new_SOURCES $file"
2262 SOURCES="$new_SOURCES"
2263 get_files $SOURCES $PATCHES
2265 tag_files $SOURCES $PATCHES $ICONS
2267 Exit_error err_no_spec_in_cmdl
2271 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
2273 "list-sources-files" )
2276 DONT_PRINT_REVISION="yes"
2279 for SAP in $SOURCES $PATCHES; do
2280 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2283 "list-sources-urls" )
2286 DONT_PRINT_REVISION="yes"
2289 SAPS="$SOURCES $PATCHES"
2290 for SAP in $SAPS ; do
2294 "list-sources-local-paths" )
2297 DONT_PRINT_REVISION="yes"
2300 for SAP in $SOURCES $PATCHES; do
2301 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2304 "list-sources-distfiles-paths" )
2307 DONT_PRINT_REVISION="yes"
2310 for SAP in $SOURCES $PATCHES; do
2311 if [ -n "$(src_md5 "$SAP")" ]; then
2312 distfiles_path "$SAP"
2316 "list-sources-distfiles" )
2319 DONT_PRINT_REVISION="yes"
2322 for SAP in $SOURCES $PATCHES; do
2323 if [ -n "$(src_md5 "$SAP")" ]; then
2324 distfiles_url "$SAP"
2328 "list-sources-cvs" )
2331 DONT_PRINT_REVISION="yes"
2334 for SAP in $SOURCES $PATCHES; do
2335 if [ -z "$(src_md5 "$SAP")" ]; then
2336 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2350 echo "$VERSIONSTRING"
2353 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2354 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2358 # vi:syntax=sh:ts=4:sw=4:noet