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 [ -n "$BE_VERBOSE" ]; then
520 echo "- Sources : `nourl $SOURCES`"
521 if [ -n "$PATCHES" ]; then
522 echo "- Patches : `nourl $PATCHES`"
524 echo "- Patches : *no patches needed*"
526 if [ -n "$ICONS" ]; then
527 echo "- Icon : `nourl $ICONS`"
529 echo "- Icon : *no package icon*"
531 echo "- Name : $PACKAGE_NAME"
532 echo "- Version : $PACKAGE_VERSION"
533 echo "- Release : $PACKAGE_RELEASE"
536 update_shell_title "parse_spec: OK!"
541 if [ -n "$DEBUG" ]; then
549 "err_no_spec_in_cmdl" )
550 remove_build_requires
551 echo "ERROR: spec file name not specified."
553 "err_invalid_cmdline" )
554 echo "ERROR: invalid command line arg ($2)."
556 "err_no_spec_in_repo" )
557 remove_build_requires
558 echo "Error: spec file not stored in CVS repo."
560 "err_no_source_in_repo" )
561 remove_build_requires
562 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)"
565 remove_build_requires
566 echo "Error: package build failed. (${2:-no more info})"
568 "err_no_package_data" )
569 remove_build_requires
570 echo "Error: couldn't get out package name/version/release from spec file."
573 remove_build_requires
574 echo "Tag ${2} already exists (spec release: ${3})."
577 remove_build_requires
578 echo "Release ${2} not integer and not a snapshot."
580 "err_branch_exists" )
581 remove_build_requires
582 echo "Tree branch already exists (${2})."
585 remove_build_requires
586 echo "Error: conditions reject building this spec (${2})."
589 echo "Unknown error."
595 if [ -n "$DEBUG" ]; then
600 if [ "$NOINIT" != "yes" ] ; then
601 SOURCE_DIR="`eval $RPM $RPMOPTS --define '"name $ASSUMED_NAME"' --eval '%{_sourcedir}'`"
602 SPECS_DIR="`eval $RPM $RPMOPTS --define '"name $ASSUMED_NAME"' --eval '%{_specdir}'`"
614 update_shell_title "get_spec"
616 if [ -n "$DEBUG" ]; then
622 if [ ! -f "$SPECFILE" ]; then
623 SPECFILE="`basename $SPECFILE .spec`.spec"
625 if [ "$NOCVSSPEC" != "yes" ]; then
627 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
628 echo "Warning: No CVS access defined - using local .spec file"
632 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
635 if [ ! -f "$SPECFILE" ]; then
636 Exit_error err_no_spec_in_repo
639 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
640 chmod $CHMOD_MODE $SPECFILE
643 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
652 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
653 cvs update mirrors >&2
657 local origin mirror name rest ol prefix
658 while read origin mirror name rest; do
659 # skip comments and empty lines
660 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
663 ol=`echo -n "$origin"|wc -c`
664 prefix="`echo -n "$url" | head -c $ol`"
665 if [ "$prefix" = "$origin" ] ; then
666 suffix="`echo "$url"|cut -b $((ol+1))-`"
667 echo -n "$mirror$suffix"
674 # Warning: unpredictable results if same URL used twice
679 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
680 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
686 [ "$NO5" = "yes" ] && return
688 [ -z "$no" ] && return
692 if [ -f additional-md5sums ]; then
693 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
694 if [ -z "$spec_rev" ]; then
695 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
697 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
698 md5=$(grep -s -v '^#' additional-md5sums | \
699 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
700 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
701 grep -E '^[0-9a-f]{32}$')
704 if [ $(echo "$md5" | wc -l) != 1 ] ; then
705 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
707 echo "$md5" | tail -n 1
712 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
713 if [ -n "$source_md5" ]; then
716 # we have empty SourceX-md5, but it is still possible
717 # that we have NoSourceX-md5 AND NoSource: X
718 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
719 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
727 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
732 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
735 distfiles_attic_url ()
737 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
744 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
749 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
750 [ -n "$size" -a "$size" -gt 0 ]
755 if [ "$CVSIGNORE_DF" != "yes" ]; then
758 cvsignore=${SOURCE_DIR}/.cvsignore
759 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
760 echo "$1" >> $cvsignore
766 update_shell_title "cvsup"
768 if [ -n "$CVSROOT" ]; then
769 OPTIONS="-d $CVSROOT $OPTIONS"
772 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
773 OPTIONS="$OPTIONS -A"
775 if [ -n "$CVSDATE" ]; then
776 OPTIONS="$OPTIONS -D $CVSDATE"
778 if [ -n "$CVSTAG" ]; then
779 OPTIONS="$OPTIONS -r $CVSTAG"
784 local retries_counter=0
786 update_shell_title "cvsup: $*"
788 update_shell_title "cvsup: $# files"
790 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
791 retries_counter=$(( $retries_counter + 1 ))
792 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
794 [ -n "$output" ] && echo "$output"
795 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
796 echo "Trying again [$*]... ($retries_counter)"
797 update_shell_title "cvsup: retry #$retries_counter"
804 update_shell_title "cvsup: done!"
808 # returns true if "$1" is ftp, http or https protocol url
812 ftp://*|http://*|https://*)
821 if [ $# -eq 0 ]; then
825 update_shell_title "update md5"
826 if [ -n "$DEBUG" ]; then
833 # pass 1: check files to be fetched
837 local fp=$(nourl "$i")
838 local srcno=$(src_no "$i")
839 if [ -n "$ADD5" ]; then
840 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
841 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
843 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
845 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
846 need_files="$need_files $i"
850 # pass 1a: get needed files
851 if [ "$need_files" ]; then
852 get_files $need_files
855 # pass 2: proceed with md5 adding or updating
857 local fp=$(nourl "$i")
858 local srcno=$(src_no "$i")
859 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
860 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
861 local tag="Source$srcno-md5"
862 if [[ "$md5" == *NoSource* ]]; then
863 tag="NoSource$srcno-md5"
865 md5=$(md5sum "$fp" | cut -f1 -d' ')
866 echo "Updating $tag ($md5: $fp)."
868 print unless /^\s*#\s*(No)?Source'$srcno'-md5\s*:/i;
869 print "# '$tag':\t'$md5'\n" if /^Source'$srcno'\s*:\s+/;
878 update_shell_title "check md5"
881 if good_md5 "$i" && good_size "$i"; then
885 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
886 echo "or -5 to update md5 sums, if you're sure files are correct."
887 Exit_error err_no_source_in_repo $i
893 update_shell_title "get_files"
895 if [ -n "$DEBUG" ]; then
900 if [ $# -gt 0 ]; then
903 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
904 echo "Warning: No CVS access defined for SOURCES"
909 local get_files_cvs=""
913 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
914 update_shell_title "$i"
915 local fp=`nourl "$i"`
916 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
921 local srcmd5=$(src_md5 "$i")
923 # we know if source/patch is present in cvs/distfiles
924 # - has md5 (in distfiles)
927 # CHECK: local file didn't exist or always cvs up (first) requested.
928 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
929 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
930 echo "Warning: no URL given for $i"
933 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
934 if good_md5 "$i" && good_size "$i"; then
935 echo "$fp having proper md5sum already exists"
940 # prefer mirror over distfiles if there's mirror
941 # TODO: build url list and then try each url from the list
942 if [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
945 url=$(distfiles_url "$i")
948 url_attic=$(distfiles_attic_url "$i")
950 # is $url local file?
951 if [[ "$url" = [./]* ]]; then
952 update_shell_title "${GETLOCAL%% *}: $url"
953 ${GETLOCAL} $url $target
955 if [ -z "$NOMIRRORS" ]; then
956 url=$(find_mirror "$url")
960 # make shorter message for distfiles urls
961 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
962 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
963 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
966 update_shell_title "${GETURI%% *}: $uri"
967 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
968 if [ "`echo $url | grep -E 'ftp://'`" ]; then
969 update_shell_title "${GETURI2%% *}: $url"
970 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
975 if [ ! -s "$target" ]; then
977 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
978 update_shell_title "${GETLOCAL%% *}: $url_attic"
979 ${GETLOCAL} $url_attic $target
981 if [ -z "$NOMIRRORS" ]; then
982 url_attic="`find_mirror "$url_attic"`"
984 update_shell_title "${GETURI%% *}: $url_attic"
985 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
986 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
987 update_shell_title "${GETURI2%% *}: $url_attic"
988 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
993 if [ -s "$target" ]; then
999 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1000 if [ $# -gt 1 ]; then
1001 get_files_cvs="$get_files_cvs $fp"
1002 update_shell_title "$fp (will cvs up later)"
1009 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1010 if [ -z "$NOMIRRORS" ]; then
1011 im="`find_mirror "$i"`"
1015 update_shell_title "${GETURI%% *}: $im"
1016 ${GETURI} "$im" || \
1017 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1018 update_shell_title "${GETURI2%% *}: $im"
1023 if [ "$cvsup" = 1 ]; then
1029 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1030 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1031 Exit_error err_no_source_in_repo $i
1034 # we check md5 here just only to refetch immediately
1035 if good_md5 "$i" && good_size "$i"; then
1037 elif [ "$FROM_DISTFILES" = 1 ]; then
1038 # wrong md5 from distfiles: remove the file and try again
1040 echo "MD5 sum mismatch. Trying full fetch."
1043 update_shell_title "${GETURI%% *}: $url"
1044 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1045 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1046 update_shell_title "${GETURI2%% *}: $url"
1047 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1049 if [ ! -s "$target" ]; then
1051 update_shell_title "${GETURI%% *}: $url_attic"
1052 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1053 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1054 update_shell_title "${GETURI2%% *}: $url_attic"
1055 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1058 test -s "$target" || rm -f "$target"
1061 SHELL_TITLE_PREFIX=""
1063 if [ "$get_files_cvs" ]; then
1064 cvsup $get_files_cvs
1067 if [ "$CHMOD" = "yes" ]; then
1068 CHMOD_FILES="`nourl "$@"`"
1069 if [ -n "$CHMOD_FILES" ]; then
1070 chmod $CHMOD_MODE $CHMOD_FILES
1077 if [ -n "$DEBUG" ]; then
1082 # Check whether first character of PACKAGE_NAME is legal for tag name
1083 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1087 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1088 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1090 # Remove #kernel.version_release from TAGVER because tagging sources
1091 # could occur with different kernel-headers than kernel-headers used at build time.
1092 # besides, %{_kernel_ver_str} is not expanded.
1094 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1095 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1105 if [ -n "$DEBUG" ]; then
1110 echo "Version: $PACKAGE_VERSION"
1111 echo "Release: $PACKAGE_RELEASE"
1114 if [ "$TAG_VERSION" = "yes" ]; then
1115 TAGVER=`make_tagver`
1116 echo "CVS tag: $TAGVER"
1118 if [ -n "$TAG" ]; then
1119 echo "CVS tag: $TAG"
1122 local OPTIONS="tag $CVS_FORCE"
1123 if [ -n "$CVSROOT" ]; then
1124 OPTIONS="-d $CVSROOT $OPTIONS"
1129 for i in $TAG_FILES; do
1130 # don't tag files stored on distfiles
1131 [ -n "`src_md5 $i`" ] && continue
1132 local fp=`nourl "$i"`
1133 if [ -f "$fp" ]; then
1134 tag_files="$tag_files $fp"
1136 Exit_error err_no_source_in_repo $i
1140 if [ "$tag_files" ]; then
1141 if [ "$TAG_VERSION" = "yes" ]; then
1142 update_shell_title "tag sources: $TAGVER"
1143 cvs $OPTIONS $TAGVER $tag_files || exit
1145 if [ -n "$TAG" ]; then
1146 update_shell_title "tag sources: $TAG"
1147 cvs $OPTIONS $TAG $tag_files || exit
1152 if [ "$TAG_VERSION" = "yes" ]; then
1153 update_shell_title "tag spec: $TAGVER"
1154 cvs $OPTIONS $TAGVER $SPECFILE || exit
1156 if [ -n "$TAG" ]; then
1157 update_shell_title "tag spec: $TAG"
1158 cvs $OPTIONS $TAG $SPECFILE || exit
1165 echo "CVS branch tag: $TAG"
1170 if [ -n "$DEBUG" ]; then
1175 local OPTIONS="tag $CVS_FORCE -b"
1176 if [ -n "$CVSROOT" ]; then
1177 OPTIONS="-d $CVSROOT $OPTIONS"
1181 for i in $TAG_FILES; do
1182 local fp=`nourl "$i"`
1183 if [ -f "$fp" ]; then
1184 tag_files="$tag_files $fp"
1186 Exit_error err_no_source_in_repo $i
1189 if [ "$tag_files" ]; then
1190 cvs $OPTIONS $TAG $tag_files || exit
1194 cvs $OPTIONS $TAG $SPECFILE || exit
1198 # this function should exit early if package can't be built for this arch
1199 # this avoids unneccessary BR filling.
1202 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1204 if [ $ret -ne 0 ]; then
1213 update_shell_title "build_package"
1214 if [ -n "$DEBUG" ]; then
1221 if [ -n "$TRY_UPGRADE" ]; then
1222 update_shell_title "build_package: try_upgrade"
1223 if [ -n "$FLOAT_VERSION" ]; then
1224 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1226 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1229 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1231 if [ -n "$TNEWVER" ]; then
1232 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1233 echo "New version found, updating spec file to version " $TNEWVER
1234 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1235 cp -f $SPECFILE $SPECFILE.bak
1238 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1239 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1241 NODIST="yes" get_files $SOURCES $PATCHES
1244 unset TOLDVER TNEWVER TNOTIFY
1251 BUILD_SWITCH="-ba" ;;
1253 BUILD_SWITCH="-bb" ;;
1255 BUILD_SWITCH="-bs --nodeps" ;;
1257 BUILD_SWITCH="-bp --nodeps" ;;
1259 BUILD_SWITCH="-bc" ;;
1261 BUILD_SWITCH="-bi" ;;
1263 BUILD_SWITCH="-bl" ;;
1267 update_shell_title "build_package: $COMMAND"
1268 if [ -n "$LOGFILE" ]; then
1269 LOG=`eval echo $LOGFILE`
1270 if [ -d "$LOG" ]; then
1271 echo "Log file $LOG is a directory."
1272 echo "Parse error in the spec?"
1273 Exit_error err_build_fail
1275 if [ -n "$LASTLOG_FILE" ]; then
1276 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1278 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1279 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1280 RETVAL=`cat $RES_FILE`
1282 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1283 if [ "$RETVAL" -eq "0" ]; then
1290 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1293 if [ "$RETVAL" -ne "0" ]; then
1294 if [ -n "$TRY_UPGRADE" ]; then
1295 echo "\n!!! Package with new version cannot be built automagically\n"
1296 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1297 mv -f $SPECFILE.bak $SPECFILE
1300 Exit_error err_build_fail
1307 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1310 install_required_packages()
1317 # taken from find-spec-bcond, but with just getting the list
1319 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1321 /^%changelog/ { exit }
1322 /_with(out)?_[_a-zA-Z0-9]+/{
1323 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1324 print substr($0, RSTART, RLENGTH);
1327 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1328 bcond = substr($0, RSTART +5 , RLENGTH -5);
1329 gsub(/[ \t]+/,"_",bcond);
1331 }' $SPEC | LC_ALL=C sort -u
1335 # expand bconds from ~/.bcondrc
1336 # The file structure is like gentoo's package.use:
1339 # samba -mysql -pgsql
1340 # w32codec-installer license_agreement
1343 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1349 SN=${SPECFILE%%\.spec}
1351 local bcondrc=$HOME/.bcondrc
1352 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1354 local bcond_avail=$(find_spec_bcond $SPECFILE)
1356 while read pkg flags; do
1358 [[ "$pkg" == \#* ]] && continue
1360 # any package or current package?
1361 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1362 for flag in $flags; do
1363 local opt=${flag#[+-]}
1365 # use only flags which are in this package.
1366 if [[ $bcond_avail = *${opt}* ]]; then
1367 if [[ $flag = -* ]]; then
1368 if [[ $BCOND != *--with?${opt}* ]]; then
1369 BCOND="$BCOND --without $opt"
1372 if [[ $BCOND != *--without?${opt}* ]]; then
1373 BCOND="$BCOND --with $opt"
1380 update_shell_title "parse ~/.bcondrc: DONE!"
1385 update_shell_title "set bcond values"
1387 AVAIL_BCONDS_WITHOUT=""
1388 AVAIL_BCONDS_WITH=""
1389 if `grep -q ^%bcond ${SPECFILE}`; then
1391 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1397 local bcond_avail=$(find_spec_bcond $SPECFILE)
1398 process_bcondrc "$SPECFILE"
1400 update_shell_title "parse bconds"
1401 case "${BCOND_VERSION}" in
1406 echo "Warning: This spec has old style bconds. Fix it || die."
1407 for opt in `echo "$bcond_avail" | grep ^_without_`
1409 AVAIL_BCOND_WITHOUT=${opt#_without_}
1410 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1411 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1413 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1417 for opt in `echo "$bcond_avail" | grep ^_with_`
1419 AVAIL_BCOND_WITH=${opt#_with_}
1420 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1421 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1423 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1428 local cond_type="" # with || without
1429 for opt in $bcond_avail; do
1438 AVAIL_BCOND_WITHOUT=${opt#_without_}
1439 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1440 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1442 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1446 AVAIL_BCOND_WITH=${opt#_with_}
1447 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1448 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1450 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1454 case "$cond_type" in
1457 AVAIL_BCOND_WITH="$opt"
1458 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1459 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1461 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1466 AVAIL_BCOND_WITHOUT="$opt"
1467 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1468 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1470 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1484 update_shell_title "run_sub_builder $package_name"
1486 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1487 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1488 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1489 # jakby nie bylo tego kawalka kodu.
1491 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1492 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1499 # Istnieje taki spec? ${package}.spec
1500 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1501 parent_spec_name=${package}.spec
1502 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1503 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1505 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1511 if [ "${parent_spec_name}" != "" ]; then
1512 spawn_sub_builder $parent_spec_name
1514 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1520 update_shell_title "spawn_sub_builder $package_name"
1523 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1524 sub_builder_opts="${sub_builder_opts} -R"
1526 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1527 sub_builder_opts="${sub_builder_opts} -RB"
1528 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1529 sub_builder_opts="${sub_builder_opts} -FRB"
1531 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1532 sub_builder_opts="${sub_builder_opts} -Upi"
1536 ./builder ${sub_builder_opts} "$@"
1539 remove_build_requires()
1541 if [ "$INSTALLED_PACKAGES" != "" ]; then
1542 case "$REMOVE_BUILD_REQUIRES" in
1544 run_poldek --noask -ve $INSTALLED_PACKAGES
1547 run_poldek --ask -ve $INSTALLED_PACKAGES
1550 echo You may want to manually remove following BuildRequires fetched:
1551 echo $INSTALLED_PACKAGES
1552 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1560 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1561 if [ "$BCOND" != "" ]; then
1562 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1565 echo -ne "\nNo conditional flags passed"
1567 echo -ne "\n\nfrom available:\n"
1568 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1574 if [ "$NOCVSSPEC" != "yes" ]; then
1575 echo -ne "Available branches: "
1576 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1580 # checks a given list of packages/files/provides agains current rpmdb.
1581 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1582 # input can be either STDIN or parameters
1587 if [ "$#" -gt 0 ]; then
1593 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1596 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1598 # other deps (files)
1599 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1602 # checks if given package/files/provides exists in rpmdb.
1603 # inout can be either stdin or parameters
1604 # returns packages wchi hare present in the rpmdb
1609 if [ "$#" -gt 0 ]; then
1615 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1618 fetch_build_requires()
1620 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1621 update_shell_title "fetch build requires"
1622 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1623 # TODO: Conflicts list doesn't check versions
1624 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1625 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1627 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1628 echo "fetch builderequires: install $DEPS; remove $CNFL"
1629 update_shell_title "poldek: install $DEPS; remove $CNFL"
1630 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1632 if [ -n "$CNFL" ]; then
1633 update_shell_title "uninstall conflicting packages: $CNFL"
1634 echo "Trying to uninstall conflicting packages ($CNFL):"
1635 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1638 while [ "$DEPS" ]; do
1639 update_shell_title "install deps: $DEPS"
1640 echo "Trying to install dependencies ($DEPS):"
1641 local log=.${SPECFILE}_poldek.log
1642 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1643 failed=$(awk -F: '/^error:/{print $2}' $log)
1646 if [ -n "$failed" ]; then
1647 for package in $failed; do
1648 # FIXME: sanitise, deps could be not .spec files
1649 spawn_sub_builder -bb $package && ok="$ok $package"
1659 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1660 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1661 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1662 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1663 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1664 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`
1666 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`"
1668 package=`basename "$package_item"|sed -e "s/}$//g"`
1669 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1672 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1673 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1674 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
1679 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1682 if `echo $COND_TST|grep -q 'without_'`; then
1683 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1684 if `echo $COND_TST|grep -q !`; then
1689 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1690 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1691 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1697 elif `echo $COND_TST|grep -q 'with_'`; then
1698 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1699 if `echo $COND_TST|grep -q !`; then
1704 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1705 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1706 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1712 RESULT="${COND_STATE}-${COND_ARGV}"
1714 "with-wout" | "wout-with" )
1717 "wout-wout" | "with-with" )
1721 echo "Action '$RESULT' was not defined for package '$package_item'"
1727 if [ "$GO" = "yes" ]; then
1728 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1729 echo "Testing if $package has subrequirements..."
1730 run_poldek -t -i $package --dumpn=".$package-req.txt"
1731 if [ -f ".$package-req.txt" ]; then
1732 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1734 if [ "$package_name" = "$package" ]; then
1735 echo -ne "Installing BuildRequired package:\t$package_name\n"
1736 update_shell_title "Installing BuildRequired package: ${package_name}"
1737 install_required_packages $package
1739 echo -ne "Installing (sub)Required package:\t$package_name\n"
1740 update_shell_title "Installing (sub)Required package: ${package_name}"
1741 install_required_packages $package_name
1745 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1746 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1749 echo "Attempting to run spawn sub - builder..."
1750 echo -ne "Package installation failed:\t$package_name\n"
1751 run_sub_builder $package_name
1752 if [ $? -eq 0 ]; then
1753 install_required_packages $package_name
1756 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1757 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1760 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1767 rm -f ".$package-req.txt"
1769 echo "Attempting to run spawn sub - builder..."
1770 echo -ne "Package installation failed:\t$package\n"
1771 run_sub_builder $package
1772 if [ $? -eq 0 ]; then
1773 install_required_packages $package
1776 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1777 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1780 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1786 echo "Package $package is already installed. BuildRequirement satisfied."
1790 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1791 echo "Unable to install following packages and their dependencies:"
1792 for pkg in "$NOT_INSTALLED_PACKAGES"
1796 remove_build_requires
1804 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1805 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1807 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1809 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1813 echo "To checkout *all* .spec files:"
1814 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1815 echo "- run cvs up in $SPECS_DIR dir"
1818 echo "To commit with your developer account:"
1819 echo "- edit $SPECS_DIR/CVS/Root"
1820 echo "- edit $SOURCE_DIR/CVS/Root"
1823 #---------------------------------------------
1831 while [ $# -gt 0 ]; do
1834 COMMAND="update_md5"
1839 COMMAND="update_md5"
1849 DEBUG="yes"; shift ;;
1851 COMMAND="version"; shift ;;
1853 COMMAND="short-version"; shift ;;
1855 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1856 -b | -ba | --build )
1857 COMMAND="build"; shift ;;
1858 -bb | --build-binary )
1859 COMMAND="build-binary"; shift ;;
1861 COMMAND="build-build"; shift ;;
1863 COMMAND="build-install"; shift ;;
1865 COMMAND="build-list"; shift ;;
1866 -bp | --build-prep )
1867 COMMAND="build-prep"; shift ;;
1868 -bs | --build-source )
1869 COMMAND="build-source"; shift ;;
1871 COMMAND="branch"; shift; TAG="${1}"; shift;;
1873 CLEAN="--clean --rmspec --rmsource"; shift ;;
1875 CVS_FORCE="-F"; shift;;
1877 shift; CVSROOT="${1}"; shift ;;
1879 COMMAND="get"; shift ;;
1881 COMMAND="usage"; shift ;;
1883 PROTOCOL="http"; shift ;;
1885 shift; LOGFILE="${1}"; shift ;;
1887 shift; DEF_NICE_LEVEL=${1}; shift ;;
1888 -ske | --skip-existing-files)
1889 SKIP_EXISTING_FILES="yes"; shift ;;
1891 COMMAND="mr-proper"; shift ;;
1893 NOCVS="yes"; shift ;;
1894 -ncs | --no-cvs-specs )
1895 NOCVSSPEC="yes"; shift ;;
1896 -nd | --no-distfiles )
1897 NODIST="yes"; shift ;;
1898 -nm | --no-mirrors )
1899 NOMIRRORS="yes"; shift ;;
1901 NOURLS="yes"; shift ;;
1903 NOSRCS="yes"; shift ;;
1904 -ns0 | --no-source0 )
1905 NOSOURCE0="yes"; shift ;;
1919 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
1921 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1922 --with | --without )
1923 case $GROUP_BCONDS in
1927 while ! `echo ${1}|grep -qE '(^-|spec)'`
1929 BCOND="$BCOND $COND $1"
1933 if [[ "$2" = *,* ]]; then
1934 for a in $(echo "$2" | tr , ' '); do
1935 BCOND="$BCOND $1 $a"
1938 BCOND="$BCOND $1 $2"
1944 shift; TARGET="${1}"; shift ;;
1946 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1948 QUIET="--quiet"; shift ;;
1950 CVSDATE="${2}"; shift 2 ;;
1952 shift; CVSTAG="${1}"; shift ;;
1954 shift; CVSTAG="HEAD"; ;;
1955 -R | --fetch-build-requires)
1956 FETCH_BUILD_REQUIRES="yes"
1957 NOT_INSTALLED_PACKAGES=
1959 -RB | --remove-build-requires)
1960 REMOVE_BUILD_REQUIRES="nice"
1962 -FRB | --force-remove-build-requires)
1963 REMOVE_BUILD_REQUIRES="force"
1965 -sc | --sources-cvs)
1966 COMMAND="list-sources-cvs"
1968 -sd | --sources-distfiles)
1969 COMMAND="list-sources-distfiles"
1971 -sdp | --sources-distfiles-paths)
1972 COMMAND="list-sources-distfiles-paths"
1974 -sf | --sources-files)
1975 COMMAND="list-sources-files"
1977 -sp | --sources-paths)
1978 COMMAND="list-sources-local-paths"
1980 -su | --sources-urls)
1981 COMMAND="list-sources-urls"
1983 -Tvs | --tag-version-stable )
1988 -Ts | --tag-stable )
1993 -Tv | --tag-version )
1998 -Tp | --tag-prefix )
2010 -ir | --integer-release-only )
2011 INTEGER_RELEASE="yes"
2014 COMMAND="update_md5"
2019 -Upi | --update-poldek-indexes )
2020 UPDATE_POLDEK_INDEXES="yes"
2023 COMMAND="init_rpm_dir"
2025 -u | --try-upgrade )
2026 TRY_UPGRADE="1"; shift ;;
2027 -un | --try-upgrade-with-float-version )
2028 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2030 BE_VERBOSE="1"; shift ;;
2035 if echo "${MACRO}" | grep -q '\W'; then
2036 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2040 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2044 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2047 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2048 COMMAND="show_bconds"
2052 COMMAND="show_bcond_args"
2057 RPMOPTS="${RPMOPTS} --nodeps"
2060 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2063 Exit_error err_invalid_cmdline "$1"
2067 # check if specname was passed as specname:cvstag
2068 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2069 CVSTAG="${SPECFILE##*:}"
2070 SPECFILE="${SPECFILE%%:*}"
2072 ASSUMED_NAME="${SPECFILE%%.spec}"
2077 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2078 CVSTAG=$(awk -vSPECFILE="${SPECFILE%.spec}.spec" -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2079 if [ "$CVSTAG" ]; then
2080 echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
2082 elif [ "$CVSTAG" = "HEAD" ]; then
2083 # assume -r HEAD is same as -A
2087 if [ -n "$DEBUG" ]; then
2092 if [ -n "$TARGET" ]; then
2095 TARGET_SWITCH="--target $TARGET" ;;
2097 TARGET_SWITCH="--target=$TARGET" ;;
2101 if [ "$SCHEDTOOL" != "no" ]; then
2102 NICE_COMMAND="$SCHEDTOOL"
2104 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2107 update_shell_title "$COMMAND"
2111 if [ -n "$SPECFILE" ]; then
2112 get_spec > /dev/null
2120 if [ -n "$SPECFILE" ]; then
2121 get_spec > /dev/null
2127 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2129 if [ -n "$SPECFILE" ]; then
2135 if [ "$COMMAND" != "build-source" ]; then
2138 fetch_build_requires
2139 if [ "$INTEGER_RELEASE" = "yes" ]; then
2140 echo "Checking release $PACKAGE_RELEASE..."
2141 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2142 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2146 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2147 if [ -n "$TEST_TAG" ]; then
2148 # - do not allow utf8 encoded specs on AC-branch
2149 if [ "$CVSTAG" = "AC-branch-disabled" ]; then
2151 t=$(grep '^Summary(.*\.UTF-8):' $SPECFILE)
2153 Exit_error err_acl_deny "UTF-8 .specs not allowed on $CVSTAG"
2157 local TAGVER=`make_tagver`
2158 echo "Searching for tag $TAGVER..."
2159 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2160 if [ -n "$TAGREL" ]; then
2161 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2164 # - do not allow to build from HEAD when XX-branch exists
2165 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2166 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2167 TAG_BRANCH="${TREE_PREFIX}-branch"
2168 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2169 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2170 Exit_error err_branch_exists "$TAG_STATUS"
2176 if [ -n "$NOSOURCE0" ] ; then
2177 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2179 get_files $SOURCES $PATCHES
2182 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2183 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2185 remove_build_requires
2187 Exit_error err_no_spec_in_cmdl
2192 if [ -n "$SPECFILE" ]; then
2195 # don't fetch sources from remote locations
2197 for file in $SOURCES; do
2198 [ -n "`src_md5 $file`" ] && continue
2199 new_SOURCES="$new_SOURCES $file"
2201 SOURCES="$new_SOURCES"
2202 get_files $SOURCES $PATCHES
2204 branch_files $TAG $SOURCES $PATCHES $ICONS
2206 Exit_error err_no_spec_in_cmdl
2211 if [ -n "$SPECFILE" ]; then
2215 if [ -n "$NOSOURCE0" ] ; then
2216 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2218 get_files $SOURCES $PATCHES
2221 Exit_error err_no_spec_in_cmdl
2226 if [ -n "$SPECFILE" ]; then
2230 if [ -n "$NOSOURCE0" ] ; then
2231 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2235 Exit_error err_no_spec_in_cmdl
2242 if [ -n "$SPECFILE" ]; then
2246 # don't fetch sources from remote locations
2248 for file in $SOURCES; do
2249 [ -n "`src_md5 $file`" ] && continue
2250 new_SOURCES="$new_SOURCES $file"
2252 SOURCES="$new_SOURCES"
2253 get_files $SOURCES $PATCHES
2255 tag_files $SOURCES $PATCHES $ICONS
2257 Exit_error err_no_spec_in_cmdl
2261 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
2263 "list-sources-files" )
2266 DONT_PRINT_REVISION="yes"
2269 for SAP in $SOURCES $PATCHES; do
2270 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2273 "list-sources-urls" )
2276 DONT_PRINT_REVISION="yes"
2279 SAPS="$SOURCES $PATCHES"
2280 for SAP in $SAPS ; do
2284 "list-sources-local-paths" )
2287 DONT_PRINT_REVISION="yes"
2290 for SAP in $SOURCES $PATCHES; do
2291 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2294 "list-sources-distfiles-paths" )
2297 DONT_PRINT_REVISION="yes"
2300 for SAP in $SOURCES $PATCHES; do
2301 if [ -n "$(src_md5 "$SAP")" ]; then
2302 distfiles_path "$SAP"
2306 "list-sources-distfiles" )
2309 DONT_PRINT_REVISION="yes"
2312 for SAP in $SOURCES $PATCHES; do
2313 if [ -n "$(src_md5 "$SAP")" ]; then
2314 distfiles_url "$SAP"
2318 "list-sources-cvs" )
2321 DONT_PRINT_REVISION="yes"
2324 for SAP in $SOURCES $PATCHES; do
2325 if [ -z "$(src_md5 "$SAP")" ]; then
2326 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2340 echo "$VERSIONSTRING"
2343 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2344 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2348 # vi:syntax=sh:ts=4:sw=4:noet