3 # This program is free software, distributed under the terms of
4 # the GNU General Public License Version 2.
10 # 2 - no spec file name in cmdl parameters
11 # 3 - spec file not stored in repo
12 # 4 - some source, patch or icon files not stored in repo
13 # 5 - package build failed
14 # 6 - spec file with errors
15 # 7 - wrong source in /etc/poldek.conf
16 # 8 - Failed installing buildrequirements and subrequirements
17 # 9 - Requested tag already exist
18 # 10 - Refused to build fractional release
19 # 100 - Unknown error (should not happen)
22 # - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
23 # - when Icon: field is present, -5 and -a5 doesn't work
24 # - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
31 Build package utility from PLD Linux CVS repository
32 $VERSION (C) 1999-2008 Free Penguins".
34 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
53 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
57 # use rpm 4.4.6+ digest format instead of comments if non-zero
60 # user agent when fetching files
61 USER_AGENT="PLD/Builder($VERSION)"
63 # It can be used i.e. in log file naming.
64 # See LOGFILE example.
65 DATE=`date +%Y-%m-%d_%H-%M-%S`
67 # Example: LOGFILE='../log.$PACKAGE_NAME'
68 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
69 # Yes, you can use variable name! Note _single_ quotes!
93 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
94 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
100 CVS_SERVER="cvs.pld-linux.org"
101 DISTFILES_SERVER="://distfiles.pld-linux.org"
102 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
107 FAIL_IF_NO_SOURCES="yes"
109 # let get_files skip over files which are present to get those damn files fetched
110 SKIP_EXISTING_FILES="no"
113 # should the specfile be restored if upgrade failed?
114 REVERT_BROKEN_UPGRADE="yes"
116 if rpm --specsrpm 2>/dev/null; then
117 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
118 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
120 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
121 if [ -x /usr/bin/rpm-getdeps ]; then
122 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
124 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
129 # Here we load saved user environment used to
130 # predefine options set above, or passed to builder
132 # This one reads global system environment settings:
133 if [ -f ~/etc/builderrc ]; then
136 # And this one cascades settings using user personal
138 # Example of ~/.builderrc:
140 #UPDATE_POLDEK_INDEXES="yes"
141 #FETCH_BUILD_REQUIRES="yes"
142 #REMOVE_BUILD_REQUIRES="force"
144 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
148 if [ -n "$HOME_ETC" ]; then
149 USER_CFG="$HOME_ETC/.builderrc"
150 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
152 USER_CFG=~/.builderrc
153 BUILDER_MACROS=~/.builder-rpmmacros
156 [ -f "$USER_CFG" ] && . "$USER_CFG"
158 if [ "$SCHEDTOOL" = "auto" ]; then
159 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
160 SCHEDTOOL="schedtool -B -e"
166 if [ -n "$USE_PROZILLA" ]; then
167 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
170 elif [ -n "$USE_AXEL" ]; then
171 GETURI="axel -a $AXEL_OPTS"
175 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
176 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
177 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
178 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
180 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
181 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
187 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
196 # are we using cvs-nserver ?
199 cvs --version 2>&1 | grep -q 'CVS-nserver'
200 [ $? -eq 0 ] && CVS_NSERVER=1
202 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
203 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
207 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
208 if [ -n "$LOGFILE" ]; then
209 LOG=`eval echo $LOGFILE`
210 if [ -n "$LASTLOG_FILE" ]; then
211 echo "LASTLOG=$LOG" > $LASTLOG_FILE
213 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
216 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
217 return `cat ${RES_FILE}`
222 #---------------------------------------------
227 if [ -n "$DEBUG" ]; then set -xv; fi
229 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
230 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
231 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
232 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
233 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
234 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
235 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
236 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
237 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
238 <package>[.spec][:cvstag]
240 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
241 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
242 -n5, --no-md5 - ignore md5 comments in spec
243 -D, --debug - enable builder script debugging mode,
244 -debug - produce rpm debug package (same as --opts -debug)
245 -V, --version - output builder version string
246 --short-version - output builder short version
247 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
248 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
250 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
251 only package from <package>.spec,
252 -bp, --build-prep - execute the %prep phase of <package>.spec,
253 -bc - execute the %build phase of <package>.spec,
254 -bi - execute the %install phase of <package>.spec
255 -bl - execute the %files phase of <package>.spec
256 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
258 --short-circuit - short-circuit build
259 -B, --branch - add branch
260 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
261 SPECS and \$RPM_BUILD_ROOT and CVS/Entries) after rpmbuild commands.
262 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
263 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
265 -cf, --cvs-force - use -F when tagging (useful when moving branches)
266 -d <cvsroot>, --cvsroot <cvsroot>
268 --define <macro> <value>
269 - define a macro <macro> with value <value>,
270 --alt_kernel <kernel>
271 - same as --define 'alt_kernel <kernel>'
272 --nodeps - rpm won't check any dependences
273 -g, --get - get <package>.spec and all related files from CVS repo
275 -h, --help - this message,
276 --http - use http instead of ftp,
277 -l <logfile>, --logtofile <logfile>
279 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
281 - don't check specs in CVS
282 -nd, --no-distfiles - don't download from distfiles
283 -nm, --no-mirrors - don't download from mirror, if source URL is given,
284 -nu, --no-urls - don't try to download from FTP/HTTP location,
285 -ns, --no-srcs - don't download Sources
286 -ns0, --no-source0 - don't download Source0
287 -nn, --no-net - don't download anything from the net
288 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
289 --no-init - don't initialize builder paths (SPECS and SOURCES)
291 --skip-existing-files - skip existing files in get_files
292 --opts <rpm opts> - additional options for rpm
293 -q, --quiet - be quiet,
294 --date yyyy-mm-dd - build package using resources from specified CVS date,
295 -r <cvstag>, --cvstag <cvstag>
296 - build package using resources from specified CVS tag,
297 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
298 -R, --fetch-build-requires
299 - fetch what is BuildRequired,
300 -RB, --remove-build-requires
301 - remove all you fetched with -R or --fetch-build-requires
302 remember, this option requires confirmation,
303 -FRB, --force-remove-build-requires
304 - remove all you fetched with -R or --fetch-build-requires
305 remember, this option works without confirmation,
306 -sd, --source-distfiles - list sources available from distfiles (intended for offline
307 operations; does not work when Icon field is present
308 but icon file is absent),
309 -sc, --source-cvs - list sources available from CVS
310 -sdp, --source-distfiles-paths - list sources available from distfiles -
311 paths relative to distfiles directory (intended for offline
312 operations; does not work when Icon field is present
313 but icon file is absent),
314 -sf, --source-files - list sources - bare filenames (intended for offline
315 operations; does not work when Icon field is present
316 but icon file is absent),
317 -sp, --source-paths - list sources - filenames with full local paths (intended for
318 offline operations; does not work when Icon field is present
319 but icon file is absent),
320 -su, --source-urls - list urls - urls to sources and patches
321 intended for copying urls with spec with lots of macros in urls
322 -T <cvstag> , --tag <cvstag>
323 - add cvs tag <cvstag> for files,
324 -Tvs, --tag-version-stable
325 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
327 - add cvs tag STABLE for files,
329 - add cvs tag NAME-VERSION-RELEASE for files,
330 -Tp, --tag-prefix <prefix>
331 - add <prefix> to NAME-VERSION-RELEASE tags,
332 -tt, --test-tag <prefix>
333 - fail if tag is already present,
334 -ir, --integer-release-only
335 - allow only integer and snapshot releases
336 -v, --verbose - be verbose,
337 -u, --try-upgrade - check version, and try to upgrade package
338 -un, --try-upgrade-with-float-version
339 - as above, but allow float version
341 - try download source from tag head if don't find it in
343 -U, --update - refetch sources, don't use distfiles, and update md5 comments
344 -Upi, --update-poldek-indexes
345 - refresh or make poldek package index files.
346 -np, --nopatch <patchnumber>
347 - don't apply <patchnumber>
348 --show-bconds - show available conditional builds, which can be used
349 - with --with and/or --without switches.
350 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
351 ./repackage.sh script. in other words, the output is
352 parseable by scripts.
353 --with/--without <feature>
354 - conditional build package depending on %_with_<feature>/
355 %_without_<feature> macro switch. You may now use
356 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
357 constructions. Set GROUP_BCONDS to yes to make use of it.
358 --target <platform>, --target=<platform>
359 - build for platform <platform>.
360 --init-rpm-dir - initialize ~/rpm directory structure
364 # change dependency to specname
366 # - perl(Package::Name) -> perl-Package-Name
370 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g}')
374 update_shell_title() {
376 local len=${COLUMNS:-80}
377 local msg=$(echo "$*" | cut -c-$len)
379 if [ -n "$BE_VERBOSE" ]; then
380 echo >&2 "$(date +%s.%N) $*"
383 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
385 if [ -n "$PACKAGE_NAME" ]; then
386 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
391 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
392 msg=$(echo $msg | tr -d '\n\r')
395 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
398 echo >&2 -ne "\033]0;$msg\007"
404 # set TARGET from BuildArch: from SPECFILE
406 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
407 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
409 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
413 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
415 TARGET_SWITCH="--target=$TARGET" ;;
421 # runs rpm with minimal macroset
423 # we reset macros not to contain macros.build as all the %() macros are
424 # executed here, while none of them are actually needed.
425 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
426 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
428 # TODO: move these to /usr/lib/rpm/macros
429 cat > $BUILDER_MACROS <<'EOF'
430 %x8664 x86_64 amd64 ia32e
433 %requires_releq_kernel_up %{nil}
434 %requires_releq_kernel_smp %{nil}
435 %requires_releq_kernel %{nil}
436 %requires_releq() %{nil}
437 %pyrequires_eq() %{nil}
438 %requires_eq() %{nil}
439 %requires_eq_to() %{nil}
440 %releq_kernel_up ERROR
441 %releq_kernel_smp ERROR
446 %ruby_ver_requires_eq() %{nil}
447 %ruby_mod_ver_requires_eq() %{nil}
448 %__php_api_requires() %{nil}
449 %php_major_version ERROR
450 %php_api_version ERROR
451 %requires_xorg_xserver_extension %{nil}
452 %requires_xorg_xserver_xinput %{nil}
453 %requires_xorg_xserver_font %{nil}
454 %requires_xorg_xserver_videodrv %{nil}
456 %perl_vendorarch ERROR
457 %perl_vendorlib ERROR
458 # damn. need it here! - copied from /usr/lib/rpm/macros.build
459 %tmpdir %(echo "${TMPDIR:-/tmp}")
460 %patchset_source(f:b:) %(
461 base=%{-b*}%{!-b*:10000};
462 start=$(expr $base + %1);
463 end=$(expr $base + %{?2}%{!?2:%{1}});
464 # we need to call seq twice as it doesn't allow two formats
465 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
466 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
467 paste %{tmpdir}/__ps{1,2};
468 rm -f %{tmpdir}/__ps{1,2};
472 if [ "$NOINIT" = "yes" ] ; then
473 cat >> $BUILDER_MACROS <<'EOF'
478 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
482 if [ -n "$DEBUG" ]; then
487 if [ -x /usr/bin/rpm-specdump ]; then
488 update_shell_title "cache_rpm_dump using rpm-specdump command"
489 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
491 update_shell_title "cache_rpm_dump using rpmbuild command"
494 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
495 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
501 ARGS='--nodigest --nosignature --nobuild'
504 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
506 if [ $? -gt 0 ]; then
507 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
509 Exit_error err_build_fail
512 # make small dump cache
513 rpm_dump_cache=`echo "$rpm_dump" | awk '
514 $2 ~ /^SOURCEURL/ {print}
515 $2 ~ /^PATCHURL/ {print}
516 $2 ~ /^nosource/ {print}
517 $2 ~ /^PACKAGE_/ {print}
521 update_shell_title "cache_rpm_dump: OK!"
525 if [ -z "$rpm_dump_cache" ] ; then
526 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
528 echo "$rpm_dump_cache"
533 update_shell_title "get icons"
534 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
535 if [ -z "$ICONS" ]; then
539 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
544 update_shell_title "parsing specfile"
545 if [ -n "$DEBUG" ]; then
550 # icons are needed for successful spec parse
556 if [ "$NOSRCS" != "yes" ]; then
557 SOURCES=$(rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}')
560 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
561 FAIL_IF_NO_SOURCES="no"
564 PATCHES=$(rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}')
565 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
566 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
567 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
568 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
570 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
571 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
574 if [ -n "$BE_VERBOSE" ]; then
575 echo "- Sources : `nourl $SOURCES`"
576 if [ -n "$PATCHES" ]; then
577 echo "- Patches : `nourl $PATCHES`"
579 echo "- Patches : *no patches needed*"
581 if [ -n "$ICONS" ]; then
582 echo "- Icon : `nourl $ICONS`"
584 echo "- Icon : *no package icon*"
586 echo "- Name : $PACKAGE_NAME"
587 echo "- Version : $PACKAGE_VERSION"
588 echo "- Release : $PACKAGE_RELEASE"
591 update_shell_title "parse_spec: OK!"
596 if [ -n "$DEBUG" ]; then
604 "err_no_spec_in_cmdl" )
605 remove_build_requires
606 echo >&2 "ERROR: spec file name not specified."
608 "err_invalid_cmdline" )
609 echo >&2 "ERROR: invalid command line arg ($2)."
611 "err_no_spec_in_repo" )
612 remove_build_requires
613 echo >&2 "Error: spec file not stored in CVS repo."
615 "err_no_source_in_repo" )
616 remove_build_requires
617 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
620 remove_build_requires
621 echo >&2 "Error: package build failed. (${2:-no more info})"
623 "err_no_package_data" )
624 remove_build_requires
625 echo >&2 "Error: couldn't get out package name/version/release from spec file."
628 remove_build_requires
629 echo >&2 "Tag ${2} already exists (spec release: ${3})."
632 remove_build_requires
633 echo >&2 "Release ${2} not integer and not a snapshot."
635 "err_branch_exists" )
636 remove_build_requires
637 echo >&2 "Tree branch already exists (${2})."
640 remove_build_requires
641 echo >&2 "Error: conditions reject building this spec (${2})."
644 echo >&2 "Unknown error."
650 if [ -n "$DEBUG" ]; then
655 if [ "$NOINIT" != "yes" ] ; then
657 if [ "$ASSUMED_NAME" ]; then
658 extra="--define 'name $ASSUMED_NAME'"
660 SOURCE_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_sourcedir}')
661 SPEC_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_specdir}')
673 update_shell_title "get_spec"
675 if [ -n "$DEBUG" ]; then
681 if [ ! -f "$SPECFILE" ]; then
682 SPECFILE="$(basename $SPECFILE .spec).spec"
684 if [ "$NOCVSSPEC" != "yes" ]; then
686 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
687 echo "Warning: No CVS access defined - using local .spec file"
691 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
694 if [ ! -f "$SPECFILE" ]; then
695 Exit_error err_no_spec_in_repo
698 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
699 chmod $CHMOD_MODE $SPECFILE
702 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
711 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
712 cvs update mirrors >&2
716 local origin mirror name rest ol prefix
717 while read origin mirror name rest; do
718 # skip comments and empty lines
719 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
722 ol=$(echo -n "$origin" | wc -c)
723 prefix=$(echo -n "$url" | head -c $ol)
724 if [ "$prefix" = "$origin" ] ; then
725 suffix=$(echo "$url" | cut -b $((ol+1))-)
726 echo -n "$mirror$suffix"
733 # Warning: unpredictable results if same URL used twice
738 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
739 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
745 [ "$NO5" = "yes" ] && return
747 [ -z "$no" ] && return
751 if [ -f additional-md5sums ]; then
752 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
753 if [ -z "$spec_rev" ]; then
754 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
756 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
757 md5=$(grep -s -v '^#' additional-md5sums | \
758 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
759 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
760 grep -E '^[0-9a-f]{32}$')
763 if [ $(echo "$md5" | wc -l) != 1 ] ; then
764 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
766 echo "$md5" | tail -n 1
771 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
772 if [ -n "$source_md5" ]; then
775 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
776 if [ -n "$source_md5" ]; then
779 # we have empty SourceX-md5, but it is still possible
780 # that we have NoSourceX-md5 AND NoSource: X
781 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
782 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
791 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
796 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
799 distfiles_attic_url ()
801 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
808 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
813 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
814 [ -n "$size" -a "$size" -gt 0 ]
819 if [ "$CVSIGNORE_DF" != "yes" ]; then
822 cvsignore=${SOURCE_DIR}/.cvsignore
823 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
824 echo "$1" >> $cvsignore
830 update_shell_title "cvsup"
832 if [ -n "$CVSROOT" ]; then
833 OPTIONS="-d $CVSROOT $OPTIONS"
836 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
837 OPTIONS="$OPTIONS -A"
839 if [ -n "$CVSDATE" ]; then
840 OPTIONS="$OPTIONS -D $CVSDATE"
842 if [ -n "$CVSTAG" ]; then
843 OPTIONS="$OPTIONS -r $CVSTAG"
848 local retries_counter=0
850 update_shell_title "cvsup: $*"
852 update_shell_title "cvsup: $# files"
854 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
855 retries_counter=$(( $retries_counter + 1 ))
856 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
858 [ -n "$output" ] && echo "$output"
859 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
860 echo "Trying again [$*]... ($retries_counter)"
861 update_shell_title "cvsup: retry #$retries_counter"
868 update_shell_title "cvsup: done!"
872 # returns true if "$1" is ftp, http or https protocol url
876 ftp://*|http://*|https://*)
885 if [ $# -eq 0 ]; then
889 update_shell_title "update md5"
890 if [ -n "$DEBUG" ]; then
897 # pass 1: check files to be fetched
901 local fp=$(nourl "$i")
902 local srcno=$(src_no "$i")
903 if [ -n "$ADD5" ]; then
904 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
905 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE && continue
906 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE && continue
908 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE || continue
910 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
911 need_files="$need_files $i"
915 # pass 1a: get needed files
916 if [ "$need_files" ]; then
917 get_files $need_files
920 # pass 2: proceed with md5 adding or updating
922 local fp=$(nourl "$i")
923 local srcno=$(src_no "$i")
924 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE )
925 if [ -z "$md5" ]; then
926 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE )
928 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
929 local tag="# Source$srcno-md5:\t"
930 if [[ "$md5" == *NoSource* ]]; then
931 tag="# NoSource$srcno-md5:\t"
932 elif [ -n "$USEDIGEST" ]; then
933 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
935 md5=$(md5sum "$fp" | cut -f1 -d' ')
936 echo "Updating Source$srcno ($md5: $fp)."
938 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
939 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
948 [ "$NO5" = "yes" ] && return
950 update_shell_title "check md5"
953 if good_md5 "$i" && good_size "$i"; then
957 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
958 echo "or -5 to update md5 sums, if you're sure files are correct."
959 Exit_error err_no_source_in_repo $i
965 update_shell_title "get_files"
967 if [ -n "$DEBUG" ]; then
972 if [ $# -gt 0 ]; then
975 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
976 echo "Warning: No CVS access defined for SOURCES"
981 local get_files_cvs=""
985 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
986 update_shell_title "$i"
987 local fp=`nourl "$i"`
988 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
993 local srcmd5=$(src_md5 "$i")
995 # we know if source/patch is present in cvs/distfiles
996 # - has md5 (in distfiles)
999 # CHECK: local file didn't exist or always cvs up (first) requested.
1000 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1001 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1002 echo "Warning: no URL given for $i"
1005 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1006 if good_md5 "$i" && good_size "$i"; then
1007 echo "$fp having proper md5sum already exists"
1012 # optionally prefer mirror over distfiles if there's mirror
1013 # TODO: build url list and then try each url from the list
1014 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1017 url=$(distfiles_url "$i")
1020 url_attic=$(distfiles_attic_url "$i")
1022 # is $url local file?
1023 if [[ "$url" = [./]* ]]; then
1024 update_shell_title "${GETLOCAL%% *}: $url"
1025 ${GETLOCAL} $url $target
1027 if [ -z "$NOMIRRORS" ]; then
1028 url=$(find_mirror "$url")
1032 # make shorter message for distfiles urls
1033 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1034 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1035 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1038 update_shell_title "${GETURI%% *}: $uri"
1039 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1040 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1041 update_shell_title "${GETURI2%% *}: $url"
1042 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1047 if [ ! -s "$target" ]; then
1049 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1050 update_shell_title "${GETLOCAL%% *}: $url_attic"
1051 ${GETLOCAL} $url_attic $target
1053 if [ -z "$NOMIRRORS" ]; then
1054 url_attic=$(find_mirror "$url_attic")
1056 update_shell_title "${GETURI%% *}: $url_attic"
1057 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1058 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1059 update_shell_title "${GETURI2%% *}: $url_attic"
1060 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1065 if [ -s "$target" ]; then
1066 cvsignore_df $target
1071 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1072 if [ $# -gt 1 ]; then
1073 get_files_cvs="$get_files_cvs $fp"
1074 update_shell_title "$fp (will cvs up later)"
1081 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1082 if [ -z "$NOMIRRORS" ]; then
1083 im=$(find_mirror "$i")
1087 update_shell_title "${GETURI%% *}: $im"
1088 ${GETURI} "$im" || \
1089 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1090 update_shell_title "${GETURI2%% *}: $im"
1095 if [ "$cvsup" = 1 ]; then
1101 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1102 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1103 if [ -n "GREEDSRC" ]; then
1104 get_greed_sources $i
1106 Exit_error err_no_source_in_repo $i
1110 # we check md5 here just only to refetch immediately
1111 if good_md5 "$i" && good_size "$i"; then
1113 elif [ "$FROM_DISTFILES" = 1 ]; then
1114 # wrong md5 from distfiles: remove the file and try again
1116 echo "MD5 sum mismatch. Trying full fetch."
1119 update_shell_title "${GETURI%% *}: $url"
1120 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1121 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1122 update_shell_title "${GETURI2%% *}: $url"
1123 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1125 if [ ! -s "$target" ]; then
1127 update_shell_title "${GETURI%% *}: $url_attic"
1128 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1129 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1130 update_shell_title "${GETURI2%% *}: $url_attic"
1131 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1134 test -s "$target" || rm -f "$target"
1137 SHELL_TITLE_PREFIX=""
1139 if [ "$get_files_cvs" ]; then
1140 cvsup $get_files_cvs
1143 if [ "$CHMOD" = "yes" ]; then
1144 CHMOD_FILES=$(nourl "$@")
1145 if [ -n "$CHMOD_FILES" ]; then
1146 chmod $CHMOD_MODE $CHMOD_FILES
1153 if [ -n "$DEBUG" ]; then
1158 # Check whether first character of PACKAGE_NAME is legal for tag name
1159 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1163 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1164 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1166 # Remove #kernel.version_release from TAGVER because tagging sources
1167 # could occur with different kernel-headers than kernel-headers used at build time.
1168 # besides, %{_kernel_ver_str} is not expanded.
1170 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1171 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1177 # bool is_tag_a_branch(tag)
1179 # returns 1 if a tag is a branch set on SPECFILE
1181 if [ -n "$DEBUG" ]; then
1186 if [ $# -ne 1 ]; then
1193 cvs status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1201 if [ -n "$DEBUG" ]; then
1206 echo "Version: $PACKAGE_VERSION"
1207 echo "Release: $PACKAGE_RELEASE"
1210 if [ "$TAG_VERSION" = "yes" ]; then
1211 TAGVER=`make_tagver`
1212 echo "CVS tag: $TAGVER"
1214 if [ -n "$TAG" ]; then
1215 echo "CVS tag: $TAG"
1218 local OPTIONS="tag $CVS_FORCE"
1219 if [ -n "$CVSROOT" ]; then
1220 OPTIONS="-d $CVSROOT $OPTIONS"
1223 # if a tagname we are about to set already exists
1224 # and happens to be a branch (common case with AC-branch)
1225 # pass -B (allows -F to disturb branch tag)
1227 if [ "$TAG_VERSION" = "yes" ]; then
1230 is_tag_a_branch $_tag
1231 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1232 OPTIONS="$OPTIONS -B"
1237 for i in $TAG_FILES; do
1238 # don't tag files stored on distfiles
1239 [ -n "`src_md5 $i`" ] && continue
1240 local fp=`nourl "$i"`
1241 if [ -f "$fp" ]; then
1242 tag_files="$tag_files $fp"
1243 elif [ -n "GREEDSRC" ]; then
1244 get_greed_sources $i
1246 Exit_error err_no_source_in_repo $i
1250 if [ "$tag_files" ]; then
1251 if [ "$TAG_VERSION" = "yes" ]; then
1252 update_shell_title "tag sources: $TAGVER"
1253 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1254 cvs $OPTIONS $TAGVER $tag_files || exit
1256 if [ -n "$TAG" ]; then
1257 update_shell_title "tag sources: $TAG"
1259 while [ "$tag_files" ]; do
1260 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1261 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1262 cvs $OPTIONS $TAG $chunk || exit
1263 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1269 if [ "$TAG_VERSION" = "yes" ]; then
1270 update_shell_title "tag spec: $TAGVER"
1271 cvs $OPTIONS $TAGVER $SPECFILE || exit
1273 if [ -n "$TAG" ]; then
1274 update_shell_title "tag spec: $TAG"
1275 cvs $OPTIONS $TAG $SPECFILE || exit
1282 echo "CVS branch tag: $TAG"
1287 if [ -n "$DEBUG" ]; then
1292 local OPTIONS="tag $CVS_FORCE -b"
1293 if [ -n "$CVSROOT" ]; then
1294 OPTIONS="-d $CVSROOT $OPTIONS"
1298 for i in $TAG_FILES; do
1299 local fp=`nourl "$i"`
1300 if [ -f "$fp" ]; then
1301 tag_files="$tag_files $fp"
1302 elif [ -n "GREEDSRC" ]; then
1303 get_greed_sources $i
1305 Exit_error err_no_source_in_repo $i
1308 if [ "$tag_files" ]; then
1309 cvs $OPTIONS $TAG $tag_files || exit
1313 cvs $OPTIONS $TAG $SPECFILE || exit
1317 # this function should exit early if package can't be built for this arch
1318 # this avoids unneccessary BR filling.
1321 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1323 if [ $ret -ne 0 ]; then
1332 update_shell_title "build_package"
1333 if [ -n "$DEBUG" ]; then
1340 if [ -n "$TRY_UPGRADE" ]; then
1341 update_shell_title "build_package: try_upgrade"
1342 if [ -n "$FLOAT_VERSION" ]; then
1343 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1345 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1348 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1350 if [ -n "$TNEWVER" ]; then
1351 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1352 echo "New version found, updating spec file to version " $TNEWVER
1353 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1354 cp -f $SPECFILE $SPECFILE.bak
1357 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1358 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1360 NODIST="yes" get_files $SOURCES $PATCHES
1363 unset TOLDVER TNEWVER TNOTIFY
1370 BUILD_SWITCH="-ba" ;;
1372 BUILD_SWITCH="-bb" ;;
1374 BUILD_SWITCH="-bs --nodeps" ;;
1376 BUILD_SWITCH="-bp --nodeps" ;;
1378 BUILD_SWITCH="-bc" ;;
1380 BUILD_SWITCH="-bi" ;;
1382 BUILD_SWITCH="-bl" ;;
1386 update_shell_title "build_package: $COMMAND"
1387 if [ -n "$LOGFILE" ]; then
1388 LOG=`eval echo $LOGFILE`
1389 if [ -d "$LOG" ]; then
1390 echo "Log file $LOG is a directory."
1391 echo "Parse error in the spec?"
1392 Exit_error err_build_fail
1394 if [ -n "$LASTLOG_FILE" ]; then
1395 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1397 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1399 (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1400 RETVAL=`cat $RES_FILE`
1402 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1403 if [ "$RETVAL" -eq "0" ]; then
1410 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $SPECFILE
1413 if [ "$RETVAL" -ne "0" ]; then
1414 if [ -n "$TRY_UPGRADE" ]; then
1415 echo "\n!!! Package with new version cannot be built automagically\n"
1416 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1417 mv -f $SPECFILE.bak $SPECFILE
1420 Exit_error err_build_fail
1427 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1430 install_required_packages()
1437 # taken from find-spec-bcond, but with just getting the list
1440 /^%changelog/ { exit }
1441 /_with(out)?_[_a-zA-Z0-9]+/{
1442 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1443 print substr($0, RSTART, RLENGTH);
1446 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1447 bcond = substr($0, RSTART +5 , RLENGTH -5);
1448 gsub(/[ \t]+/,"_",bcond);
1450 }' $SPEC | LC_ALL=C sort -u
1454 # expand bconds from ~/.bcondrc
1455 # The file structure is like gentoo's package.use:
1458 # samba -mysql -pgsql
1459 # w32codec-installer license_agreement
1462 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1468 SN=${SPECFILE%%\.spec}
1470 local bcondrc=$HOME/.bcondrc
1471 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1473 local bcond_avail=$(find_spec_bcond $SPECFILE)
1475 while read pkg flags; do
1477 [[ "$pkg" == \#* ]] && continue
1479 # any package or current package?
1480 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1481 for flag in $flags; do
1482 local opt=${flag#[+-]}
1484 # use only flags which are in this package.
1485 if [[ $bcond_avail = *${opt}* ]]; then
1486 if [[ $flag = -* ]]; then
1487 if [[ $BCOND != *--with?${opt}* ]]; then
1488 BCOND="$BCOND --without $opt"
1491 if [[ $BCOND != *--without?${opt}* ]]; then
1492 BCOND="$BCOND --with $opt"
1499 update_shell_title "parse ~/.bcondrc: DONE!"
1504 update_shell_title "set bcond values"
1506 AVAIL_BCONDS_WITHOUT=""
1507 AVAIL_BCONDS_WITH=""
1508 if `grep -q ^%bcond ${SPECFILE}`; then
1510 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1516 local bcond_avail=$(find_spec_bcond $SPECFILE)
1517 process_bcondrc "$SPECFILE"
1519 update_shell_title "parse bconds"
1520 case "${BCOND_VERSION}" in
1525 echo "Warning: This spec has old style bconds. Fix it || die."
1526 for opt in `echo "$bcond_avail" | grep ^_without_`
1528 AVAIL_BCOND_WITHOUT=${opt#_without_}
1529 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1530 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1532 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1536 for opt in `echo "$bcond_avail" | grep ^_with_`
1538 AVAIL_BCOND_WITH=${opt#_with_}
1539 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1540 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1542 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1547 local cond_type="" # with || without
1548 for opt in $bcond_avail; do
1557 AVAIL_BCOND_WITHOUT=${opt#_without_}
1558 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1559 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1561 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1565 AVAIL_BCOND_WITH=${opt#_with_}
1566 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1567 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1569 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1573 case "$cond_type" in
1576 AVAIL_BCOND_WITH="$opt"
1577 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1578 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1580 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1585 AVAIL_BCOND_WITHOUT="$opt"
1586 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1587 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1589 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1603 update_shell_title "run_sub_builder $package_name"
1605 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1606 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1607 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1608 # jakby nie bylo tego kawalka kodu.
1610 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1611 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1615 # kurwa. translate that ^^^^
1619 # Istnieje taki spec? ${package}.spec
1620 if [ -f "${SPEC_DIR}/${package}.spec" ]; then
1621 parent_spec_name=${package}.spec
1622 elif [ -f "${SPEC_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1623 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1625 for provides_line in $(grep -r ^Provides:.*$package ${SPEC_DIR}); do
1630 if [ "${parent_spec_name}" != "" ]; then
1631 spawn_sub_builder $parent_spec_name
1633 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1639 update_shell_title "spawn_sub_builder $package_name"
1642 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1643 sub_builder_opts="${sub_builder_opts} -R"
1645 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1646 sub_builder_opts="${sub_builder_opts} -RB"
1647 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1648 sub_builder_opts="${sub_builder_opts} -FRB"
1650 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1651 sub_builder_opts="${sub_builder_opts} -Upi"
1655 ./builder ${sub_builder_opts} "$@"
1658 remove_build_requires()
1660 if [ "$INSTALLED_PACKAGES" != "" ]; then
1661 case "$REMOVE_BUILD_REQUIRES" in
1663 run_poldek --noask -ve $INSTALLED_PACKAGES
1666 run_poldek --ask -ve $INSTALLED_PACKAGES
1669 echo You may want to manually remove following BuildRequires fetched:
1670 echo $INSTALLED_PACKAGES
1671 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1679 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1680 if [ "$BCOND" != "" ]; then
1681 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1684 echo -ne "\nNo conditional flags passed"
1686 echo -ne "\n\nfrom available:\n"
1687 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1693 if [ "$NOCVSSPEC" != "yes" ]; then
1694 echo -ne "Available branches: "
1695 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1699 # checks a given list of packages/files/provides agains current rpmdb.
1700 # outputs all dependencies which current rpmdb doesn't satisfy.
1701 # input can be either STDIN or parameters
1706 if [ $# -gt 0 ]; then
1712 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1715 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1717 # other deps (files)
1718 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1721 # checks if given package/files/provides exists in rpmdb.
1722 # input can be either stdin or parameters
1723 # returns packages which are present in the rpmdb
1728 if [ $# -gt 0 ]; then
1734 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1737 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1738 install_build_requires_rpmdeps() {
1739 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1740 # TODO: Conflicts list doesn't check versions
1741 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1742 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1744 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1745 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1746 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1749 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1750 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1751 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1752 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1754 if [ -n "$CNFL" ]; then
1755 update_shell_title "uninstall conflicting packages: $CNFL"
1756 echo "Trying to uninstall conflicting packages ($CNFL):"
1757 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1760 while [ "$DEPS" ]; do
1761 update_shell_title "install deps: $DEPS"
1762 echo "Trying to install dependencies ($DEPS):"
1763 local log=.${SPECFILE}_poldek.log
1764 $SU_SUDO /usr/bin/poldek --caplookup -uGqQ $DEPS | tee $log
1765 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1768 if [ -n "$failed" ]; then
1769 for package in $failed; do
1770 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1779 fetch_build_requires()
1781 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1785 update_shell_title "fetch build requires"
1786 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1787 install_build_requires_rpmdeps
1791 # XXX is this ugliest code written in human history still needed?
1792 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1793 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1794 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1795 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1796 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1797 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)
1799 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)
1801 package=$(basename "$package_item"|sed -e "s/}$//g")
1802 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1805 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1806 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1807 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
1812 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1815 if `echo $COND_TST|grep -q 'without_'`; then
1816 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1817 if `echo $COND_TST|grep -q !`; then
1822 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1823 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1824 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1830 elif `echo $COND_TST|grep -q 'with_'`; then
1831 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1832 if `echo $COND_TST|grep -q !`; then
1837 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1838 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1839 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1845 RESULT="${COND_STATE}-${COND_ARGV}"
1847 "with-wout" | "wout-with" )
1850 "wout-wout" | "with-with" )
1854 echo "Action '$RESULT' was not defined for package '$package_item'"
1860 if [ "$GO" = "yes" ]; then
1861 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1862 echo "Testing if $package has subrequirements..."
1863 run_poldek -t -i $package --dumpn=".$package-req.txt"
1864 if [ -f ".$package-req.txt" ]; then
1865 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1867 if [ "$package_name" = "$package" ]; then
1868 echo -ne "Installing BuildRequired package:\t$package_name\n"
1869 update_shell_title "Installing BuildRequired package: ${package_name}"
1870 install_required_packages $package
1872 echo -ne "Installing (sub)Required package:\t$package_name\n"
1873 update_shell_title "Installing (sub)Required package: ${package_name}"
1874 install_required_packages $package_name
1878 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1879 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1882 echo "Attempting to run spawn sub - builder..."
1883 echo -ne "Package installation failed:\t$package_name\n"
1884 run_sub_builder $package_name
1885 if [ $? -eq 0 ]; then
1886 install_required_packages $package_name
1889 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1890 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1893 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1900 rm -f ".$package-req.txt"
1902 echo "Attempting to run spawn sub - builder..."
1903 echo -ne "Package installation failed:\t$package\n"
1904 run_sub_builder $package
1905 if [ $? -eq 0 ]; then
1906 install_required_packages $package
1909 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1910 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1913 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1919 echo "Package $package is already installed. BuildRequirement satisfied."
1923 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1924 echo >&2 "Unable to install following packages and their dependencies:"
1925 for pkg in "$NOT_INSTALLED_PACKAGES"
1929 remove_build_requires
1935 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1936 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1938 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1940 cvs -d $CVSROOT co SOURCES/{.cvsignore,dropin} SPECS/{mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1944 echo "To checkout *all* .spec files:"
1945 echo "- remove $SPEC_DIR/CVS/Entries.Static"
1946 echo "- run cvs up in $SPEC_DIR dir"
1949 echo "To commit with your developer account:"
1950 echo "- edit $SPEC_DIR/CVS/Root"
1951 echo "- edit $SOURCE_DIR/CVS/Root"
1954 get_greed_sources() {
1955 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1956 if [ -n "BE_VERBOSE" ]; then
1957 echo "Try greed download: $1 from: $CVSROOT"
1959 cvs -d $CVSROOT get SOURCES/$1
1960 if [ $? != 0 ]; then
1961 Exit_error err_no_source_in_repo $1
1966 # remove entries from CVS/Entries
1967 cvs_entry_remove() {
1968 local cvsdir="$1"; shift
1969 if [ ! -d "$cvsdir" ]; then
1970 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1974 for file in "$@"; do
1975 rm -f $cvsdir/CVS/Entries.new || return 1
1976 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1977 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1985 DONT_PRINT_REVISION="yes"
1989 # remove from CVS/Entries
1990 cvs_entry_remove $SPEC_DIR $SPECFILE
1991 cvs_entry_remove $SOURCE_DIR $SOURCES $PATCHES
1993 # remove spec and sources
1994 $RPMBUILD --clean --rmsource --rmspec --nodeps $SPECFILE
1997 #---------------------------------------------
2005 while [ $# -gt 0 ]; do
2008 COMMAND="update_md5"
2013 COMMAND="update_md5"
2023 DEBUG="yes"; shift ;;
2025 COMMAND="version"; shift ;;
2027 COMMAND="short-version"; shift ;;
2029 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
2030 -b | -ba | --build )
2031 COMMAND="build"; shift ;;
2032 -bb | --build-binary )
2033 COMMAND="build-binary"; shift ;;
2035 COMMAND="build-build"; shift ;;
2037 COMMAND="build-install"; shift ;;
2039 COMMAND="build-list"; shift ;;
2040 -bp | --build-prep )
2041 COMMAND="build-prep"; shift ;;
2042 -bs | --build-source )
2043 COMMAND="build-source"; shift ;;
2045 COMMAND="branch"; shift; TAG="${1}"; shift;;
2047 CLEAN="--clean --rmspec --rmsource"; shift ;;
2049 CVS_FORCE="-F"; shift;;
2051 shift; CVSROOT="${1}"; shift ;;
2053 COMMAND="get"; shift ;;
2055 COMMAND="usage"; shift ;;
2057 PROTOCOL="http"; shift ;;
2059 shift; LOGFILE="${1}"; shift ;;
2061 shift; DEF_NICE_LEVEL=${1}; shift ;;
2062 -ske | --skip-existing-files)
2063 SKIP_EXISTING_FILES="yes"; shift ;;
2065 COMMAND="mr-proper"; shift ;;
2067 NOCVS="yes"; shift ;;
2068 -ncs | --no-cvs-specs )
2069 NOCVSSPEC="yes"; shift ;;
2070 -nd | --no-distfiles )
2071 NODIST="yes"; shift ;;
2072 -nm | --no-mirrors )
2073 NOMIRRORS="yes"; shift ;;
2075 NOURLS="yes"; shift ;;
2077 NOSRCS="yes"; shift ;;
2078 -ns0 | --no-source0 )
2079 NOSOURCE0="yes"; shift ;;
2089 -pm | --prefer-mirrors )
2096 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2098 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2099 --with | --without )
2100 case $GROUP_BCONDS in
2104 while ! `echo ${1}|grep -qE '(^-|spec)'`
2106 BCOND="$BCOND $COND $1"
2110 if [[ "$2" = *,* ]]; then
2111 for a in $(echo "$2" | tr , ' '); do
2112 BCOND="$BCOND $1 $a"
2115 BCOND="$BCOND $1 $2"
2121 shift; TARGET="${1}"; shift ;;
2123 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2125 QUIET="--quiet"; shift ;;
2127 CVSDATE="${2}"; shift 2 ;;
2129 shift; CVSTAG="${1}"; shift ;;
2131 shift; CVSTAG="HEAD"; ;;
2132 -R | --fetch-build-requires)
2133 FETCH_BUILD_REQUIRES="yes"
2134 NOT_INSTALLED_PACKAGES=
2136 -RB | --remove-build-requires)
2137 REMOVE_BUILD_REQUIRES="nice"
2139 -FRB | --force-remove-build-requires)
2140 REMOVE_BUILD_REQUIRES="force"
2142 -sc | --sources-cvs)
2143 COMMAND="list-sources-cvs"
2145 -sd | --sources-distfiles)
2146 COMMAND="list-sources-distfiles"
2148 -sdp | --sources-distfiles-paths)
2149 COMMAND="list-sources-distfiles-paths"
2151 -sf | --sources-files)
2152 COMMAND="list-sources-files"
2154 -sp | --sources-paths)
2155 COMMAND="list-sources-local-paths"
2157 -su | --sources-urls)
2158 COMMAND="list-sources-urls"
2160 -Tvs | --tag-version-stable )
2165 -Ts | --tag-stable )
2170 -Tv | --tag-version )
2175 -Tp | --tag-prefix )
2187 -ir | --integer-release-only )
2188 INTEGER_RELEASE="yes"
2191 COMMAND="update_md5"
2196 -Upi | --update-poldek-indexes )
2197 UPDATE_POLDEK_INDEXES="yes"
2200 COMMAND="init_rpm_dir"
2202 --use-greed-sources )
2205 -u | --try-upgrade )
2206 TRY_UPGRADE="1"; shift ;;
2207 -un | --try-upgrade-with-float-version )
2208 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2210 BE_VERBOSE="1"; shift ;;
2215 if echo "${MACRO}" | grep -q '\W'; then
2216 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2220 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2225 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2229 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2232 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2233 COMMAND="show_bconds"
2237 COMMAND="show_bcond_args"
2242 RPMOPTS="${RPMOPTS} --nodeps"
2245 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2248 Exit_error err_invalid_cmdline "$1"
2252 # check if specname was passed as specname:cvstag
2253 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2254 CVSTAG="${SPECFILE##*:}"
2255 SPECFILE="${SPECFILE%%:*}"
2257 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2262 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2263 CVSTAG=$(awk -vSPECFILE=$(basename ${SPECFILE%.spec}.spec) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2264 if [ "$CVSTAG" ]; then
2265 echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
2267 elif [ "$CVSTAG" = "HEAD" ]; then
2268 # assume -r HEAD is same as -A
2272 if [ -n "$DEBUG" ]; then
2277 if [ -n "$TARGET" ]; then
2280 TARGET_SWITCH="--target $TARGET" ;;
2282 TARGET_SWITCH="--target=$TARGET" ;;
2286 if [ "$SCHEDTOOL" != "no" ]; then
2287 NICE_COMMAND="$SCHEDTOOL"
2289 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2292 update_shell_title "$COMMAND"
2296 if [ -n "$SPECFILE" ]; then
2297 get_spec > /dev/null
2305 if [ -n "$SPECFILE" ]; then
2306 get_spec > /dev/null
2312 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2314 if [ -n "$SPECFILE" ]; then
2320 if [ "$COMMAND" != "build-source" ]; then
2323 fetch_build_requires
2324 if [ "$INTEGER_RELEASE" = "yes" ]; then
2325 echo "Checking release $PACKAGE_RELEASE..."
2326 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2327 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2331 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2332 if [ -n "$TEST_TAG" ]; then
2333 local TAGVER=`make_tagver`
2334 echo "Searching for tag $TAGVER..."
2335 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2336 if [ -n "$TAGREL" ]; then
2337 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2340 # - do not allow to build from HEAD when XX-branch exists
2341 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2342 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2343 TAG_BRANCH="${TREE_PREFIX}-branch"
2344 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2345 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2346 Exit_error err_branch_exists "$TAG_STATUS"
2352 if [ -n "$NOSOURCE0" ] ; then
2353 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2355 get_files $SOURCES $PATCHES
2358 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2359 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2361 remove_build_requires
2363 Exit_error err_no_spec_in_cmdl
2368 if [ -n "$SPECFILE" ]; then
2371 # don't fetch sources from remote locations
2373 for file in $SOURCES; do
2374 [ -n "`src_md5 $file`" ] && continue
2375 new_SOURCES="$new_SOURCES $file"
2377 SOURCES="$new_SOURCES"
2378 get_files $SOURCES $PATCHES
2380 branch_files $TAG $SOURCES $PATCHES $ICONS
2382 Exit_error err_no_spec_in_cmdl
2387 if [ -n "$SPECFILE" ]; then
2391 if [ -n "$NOSOURCE0" ] ; then
2392 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2394 get_files $SOURCES $PATCHES
2397 Exit_error err_no_spec_in_cmdl
2402 if [ -n "$SPECFILE" ]; then
2406 if [ -n "$NOSOURCE0" ] ; then
2407 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2411 Exit_error err_no_spec_in_cmdl
2418 if [ -n "$SPECFILE" ]; then
2422 # don't fetch sources from remote locations
2424 for file in $SOURCES; do
2425 [ -n "`src_md5 $file`" ] && continue
2426 new_SOURCES="$new_SOURCES $file"
2428 SOURCES="$new_SOURCES"
2429 get_files $SOURCES $PATCHES
2431 tag_files $SOURCES $PATCHES $ICONS
2433 Exit_error err_no_spec_in_cmdl
2439 "list-sources-files" )
2442 DONT_PRINT_REVISION="yes"
2445 for SAP in $SOURCES $PATCHES; do
2446 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2449 "list-sources-urls" )
2452 DONT_PRINT_REVISION="yes"
2455 SAPS="$SOURCES $PATCHES"
2456 for SAP in $SAPS ; do
2460 "list-sources-local-paths" )
2463 DONT_PRINT_REVISION="yes"
2466 for SAP in $SOURCES $PATCHES; do
2467 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2470 "list-sources-distfiles-paths" )
2473 DONT_PRINT_REVISION="yes"
2476 for SAP in $SOURCES $PATCHES; do
2477 if [ -n "$(src_md5 "$SAP")" ]; then
2478 distfiles_path "$SAP"
2482 "list-sources-distfiles" )
2485 DONT_PRINT_REVISION="yes"
2488 for SAP in $SOURCES $PATCHES; do
2489 if [ -n "$(src_md5 "$SAP")" ]; then
2490 distfiles_url "$SAP"
2494 "list-sources-cvs" )
2497 DONT_PRINT_REVISION="yes"
2500 for SAP in $SOURCES $PATCHES; do
2501 if [ -z "$(src_md5 "$SAP")" ]; then
2502 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2516 echo "$VERSIONSTRING"
2519 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2520 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2524 # vi:syntax=sh:ts=4:sw=4:noet