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};
471 %add_etc_shells(p) %{p:<lua>}
472 %remove_etc_shells(p) %{p:<lua>}
474 if [ "$NOINIT" = "yes" ] ; then
475 cat >> $BUILDER_MACROS <<'EOF'
480 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
484 if [ -n "$DEBUG" ]; then
489 if [ -x /usr/bin/rpm-specdump ]; then
490 update_shell_title "cache_rpm_dump using rpm-specdump command"
491 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
493 update_shell_title "cache_rpm_dump using rpmbuild command"
496 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
497 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
503 ARGS='--nodigest --nosignature --nobuild'
506 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
508 if [ $? -gt 0 ]; then
509 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
511 Exit_error err_build_fail
514 # make small dump cache
515 rpm_dump_cache=`echo "$rpm_dump" | awk '
516 $2 ~ /^SOURCEURL/ {print}
517 $2 ~ /^PATCHURL/ {print}
518 $2 ~ /^nosource/ {print}
519 $2 ~ /^PACKAGE_/ {print}
523 update_shell_title "cache_rpm_dump: OK!"
527 if [ -z "$rpm_dump_cache" ] ; then
528 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
530 echo "$rpm_dump_cache"
535 update_shell_title "get icons"
536 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
537 if [ -z "$ICONS" ]; then
541 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
546 update_shell_title "parsing specfile"
547 if [ -n "$DEBUG" ]; then
552 # icons are needed for successful spec parse
558 if [ "$NOSRCS" != "yes" ]; then
559 SOURCES=$(rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}')
562 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
563 FAIL_IF_NO_SOURCES="no"
566 PATCHES=$(rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}')
567 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
568 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
569 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
570 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
572 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
573 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
576 if [ -n "$BE_VERBOSE" ]; then
577 echo "- Sources : `nourl $SOURCES`"
578 if [ -n "$PATCHES" ]; then
579 echo "- Patches : `nourl $PATCHES`"
581 echo "- Patches : *no patches needed*"
583 if [ -n "$ICONS" ]; then
584 echo "- Icon : `nourl $ICONS`"
586 echo "- Icon : *no package icon*"
588 echo "- Name : $PACKAGE_NAME"
589 echo "- Version : $PACKAGE_VERSION"
590 echo "- Release : $PACKAGE_RELEASE"
593 update_shell_title "parse_spec: OK!"
598 if [ -n "$DEBUG" ]; then
606 "err_no_spec_in_cmdl" )
607 remove_build_requires
608 echo >&2 "ERROR: spec file name not specified."
610 "err_invalid_cmdline" )
611 echo >&2 "ERROR: invalid command line arg ($2)."
613 "err_no_spec_in_repo" )
614 remove_build_requires
615 echo >&2 "Error: spec file not stored in CVS repo."
617 "err_no_source_in_repo" )
618 remove_build_requires
619 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
622 remove_build_requires
623 echo >&2 "Error: package build failed. (${2:-no more info})"
625 "err_no_package_data" )
626 remove_build_requires
627 echo >&2 "Error: couldn't get out package name/version/release from spec file."
630 remove_build_requires
631 echo >&2 "Tag ${2} already exists (spec release: ${3})."
634 remove_build_requires
635 echo >&2 "Release ${2} not integer and not a snapshot."
637 "err_branch_exists" )
638 remove_build_requires
639 echo >&2 "Tree branch already exists (${2})."
642 remove_build_requires
643 echo >&2 "Error: conditions reject building this spec (${2})."
646 echo >&2 "Unknown error."
652 if [ -n "$DEBUG" ]; then
657 if [ "$NOINIT" != "yes" ] ; then
659 if [ "$ASSUMED_NAME" ]; then
660 extra="--define 'name $ASSUMED_NAME'"
662 SOURCE_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_sourcedir}')
663 SPEC_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_specdir}')
675 update_shell_title "get_spec"
677 if [ -n "$DEBUG" ]; then
683 if [ ! -f "$SPECFILE" ]; then
684 SPECFILE="$(basename $SPECFILE .spec).spec"
686 if [ "$NOCVSSPEC" != "yes" ]; then
688 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
689 echo "Warning: No CVS access defined - using local .spec file"
693 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
696 if [ ! -f "$SPECFILE" ]; then
697 Exit_error err_no_spec_in_repo
700 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
701 chmod $CHMOD_MODE $SPECFILE
704 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
713 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
714 cvs update mirrors >&2
718 local origin mirror name rest ol prefix
719 while read origin mirror name rest; do
720 # skip comments and empty lines
721 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
724 ol=$(echo -n "$origin" | wc -c)
725 prefix=$(echo -n "$url" | head -c $ol)
726 if [ "$prefix" = "$origin" ] ; then
727 suffix=$(echo "$url" | cut -b $((ol+1))-)
728 echo -n "$mirror$suffix"
735 # Warning: unpredictable results if same URL used twice
740 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
741 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
747 [ "$NO5" = "yes" ] && return
749 [ -z "$no" ] && return
753 if [ -f additional-md5sums ]; then
754 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
755 if [ -z "$spec_rev" ]; then
756 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
758 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
759 md5=$(grep -s -v '^#' additional-md5sums | \
760 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
761 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
762 grep -E '^[0-9a-f]{32}$')
765 if [ $(echo "$md5" | wc -l) != 1 ] ; then
766 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
768 echo "$md5" | tail -n 1
773 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
774 if [ -n "$source_md5" ]; then
777 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
778 if [ -n "$source_md5" ]; then
781 # we have empty SourceX-md5, but it is still possible
782 # that we have NoSourceX-md5 AND NoSource: X
783 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
784 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
793 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
798 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
801 distfiles_attic_url ()
803 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
810 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
815 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
816 [ -n "$size" -a "$size" -gt 0 ]
821 if [ "$CVSIGNORE_DF" != "yes" ]; then
824 cvsignore=${SOURCE_DIR}/.cvsignore
825 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
826 echo "$1" >> $cvsignore
832 update_shell_title "cvsup"
834 if [ -n "$CVSROOT" ]; then
835 OPTIONS="-d $CVSROOT $OPTIONS"
838 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
839 OPTIONS="$OPTIONS -A"
841 if [ -n "$CVSDATE" ]; then
842 OPTIONS="$OPTIONS -D $CVSDATE"
844 if [ -n "$CVSTAG" ]; then
845 OPTIONS="$OPTIONS -r $CVSTAG"
850 local retries_counter=0
852 update_shell_title "cvsup: $*"
854 update_shell_title "cvsup: $# files"
856 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
857 retries_counter=$(( $retries_counter + 1 ))
858 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
860 [ -n "$output" ] && echo "$output"
861 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
862 echo "Trying again [$*]... ($retries_counter)"
863 update_shell_title "cvsup: retry #$retries_counter"
870 update_shell_title "cvsup: done!"
874 # returns true if "$1" is ftp, http or https protocol url
878 ftp://*|http://*|https://*)
887 if [ $# -eq 0 ]; then
891 update_shell_title "update md5"
892 if [ -n "$DEBUG" ]; then
899 # pass 1: check files to be fetched
903 local fp=$(nourl "$i")
904 local srcno=$(src_no "$i")
905 if [ -n "$ADD5" ]; then
906 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
907 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE && continue
908 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE && continue
910 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE || continue
912 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
913 need_files="$need_files $i"
917 # pass 1a: get needed files
918 if [ "$need_files" ]; then
919 get_files $need_files
922 # pass 2: proceed with md5 adding or updating
924 local fp=$(nourl "$i")
925 local srcno=$(src_no "$i")
926 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE )
927 if [ -z "$md5" ]; then
928 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE )
930 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
931 local tag="# Source$srcno-md5:\t"
932 if [[ "$md5" == *NoSource* ]]; then
933 tag="# NoSource$srcno-md5:\t"
934 elif [ -n "$USEDIGEST" ]; then
935 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
937 md5=$(md5sum "$fp" | cut -f1 -d' ')
938 echo "Updating Source$srcno ($md5: $fp)."
940 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
941 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
950 [ "$NO5" = "yes" ] && return
952 update_shell_title "check md5"
955 if good_md5 "$i" && good_size "$i"; then
959 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
960 echo "or -5 to update md5 sums, if you're sure files are correct."
961 Exit_error err_no_source_in_repo $i
967 update_shell_title "get_files"
969 if [ -n "$DEBUG" ]; then
974 if [ $# -gt 0 ]; then
977 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
978 echo "Warning: No CVS access defined for SOURCES"
983 local get_files_cvs=""
987 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
988 update_shell_title "$i"
989 local fp=`nourl "$i"`
990 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
995 local srcmd5=$(src_md5 "$i")
997 # we know if source/patch is present in cvs/distfiles
998 # - has md5 (in distfiles)
1001 # CHECK: local file didn't exist or always cvs up (first) requested.
1002 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1003 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1004 echo "Warning: no URL given for $i"
1007 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1008 if good_md5 "$i" && good_size "$i"; then
1009 echo "$fp having proper md5sum already exists"
1014 # optionally prefer mirror over distfiles if there's mirror
1015 # TODO: build url list and then try each url from the list
1016 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1019 url=$(distfiles_url "$i")
1022 url_attic=$(distfiles_attic_url "$i")
1024 # is $url local file?
1025 if [[ "$url" = [./]* ]]; then
1026 update_shell_title "${GETLOCAL%% *}: $url"
1027 ${GETLOCAL} $url $target
1029 if [ -z "$NOMIRRORS" ]; then
1030 url=$(find_mirror "$url")
1034 # make shorter message for distfiles urls
1035 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1036 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1037 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1040 update_shell_title "${GETURI%% *}: $uri"
1041 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1042 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1043 update_shell_title "${GETURI2%% *}: $url"
1044 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1049 if [ ! -s "$target" ]; then
1051 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1052 update_shell_title "${GETLOCAL%% *}: $url_attic"
1053 ${GETLOCAL} $url_attic $target
1055 if [ -z "$NOMIRRORS" ]; then
1056 url_attic=$(find_mirror "$url_attic")
1058 update_shell_title "${GETURI%% *}: $url_attic"
1059 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1060 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1061 update_shell_title "${GETURI2%% *}: $url_attic"
1062 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1067 if [ -s "$target" ]; then
1068 cvsignore_df $target
1073 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1074 if [ $# -gt 1 ]; then
1075 get_files_cvs="$get_files_cvs $fp"
1076 update_shell_title "$fp (will cvs up later)"
1083 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1084 if [ -z "$NOMIRRORS" ]; then
1085 im=$(find_mirror "$i")
1089 update_shell_title "${GETURI%% *}: $im"
1090 ${GETURI} "$im" || \
1091 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1092 update_shell_title "${GETURI2%% *}: $im"
1097 if [ "$cvsup" = 1 ]; then
1103 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1104 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1105 if [ -n "GREEDSRC" ]; then
1106 get_greed_sources $i
1108 Exit_error err_no_source_in_repo $i
1112 # we check md5 here just only to refetch immediately
1113 if good_md5 "$i" && good_size "$i"; then
1115 elif [ "$FROM_DISTFILES" = 1 ]; then
1116 # wrong md5 from distfiles: remove the file and try again
1118 echo "MD5 sum mismatch. Trying full fetch."
1121 update_shell_title "${GETURI%% *}: $url"
1122 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1123 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1124 update_shell_title "${GETURI2%% *}: $url"
1125 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1127 if [ ! -s "$target" ]; then
1129 update_shell_title "${GETURI%% *}: $url_attic"
1130 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1131 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1132 update_shell_title "${GETURI2%% *}: $url_attic"
1133 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1136 test -s "$target" || rm -f "$target"
1139 SHELL_TITLE_PREFIX=""
1141 if [ "$get_files_cvs" ]; then
1142 cvsup $get_files_cvs
1145 if [ "$CHMOD" = "yes" ]; then
1146 CHMOD_FILES=$(nourl "$@")
1147 if [ -n "$CHMOD_FILES" ]; then
1148 chmod $CHMOD_MODE $CHMOD_FILES
1155 if [ -n "$DEBUG" ]; then
1160 # Check whether first character of PACKAGE_NAME is legal for tag name
1161 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1165 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1166 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1168 # Remove #kernel.version_release from TAGVER because tagging sources
1169 # could occur with different kernel-headers than kernel-headers used at build time.
1170 # besides, %{_kernel_ver_str} is not expanded.
1172 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1173 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1179 # bool is_tag_a_branch(tag)
1181 # returns 1 if a tag is a branch set on SPECFILE
1183 if [ -n "$DEBUG" ]; then
1188 if [ $# -ne 1 ]; then
1195 cvs status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1203 if [ -n "$DEBUG" ]; then
1208 echo "Version: $PACKAGE_VERSION"
1209 echo "Release: $PACKAGE_RELEASE"
1212 if [ "$TAG_VERSION" = "yes" ]; then
1213 TAGVER=`make_tagver`
1214 echo "CVS tag: $TAGVER"
1216 if [ -n "$TAG" ]; then
1217 echo "CVS tag: $TAG"
1220 local OPTIONS="tag $CVS_FORCE"
1221 if [ -n "$CVSROOT" ]; then
1222 OPTIONS="-d $CVSROOT $OPTIONS"
1225 # if a tagname we are about to set already exists
1226 # and happens to be a branch (common case with AC-branch)
1227 # pass -B (allows -F to disturb branch tag)
1229 if [ "$TAG_VERSION" = "yes" ]; then
1232 is_tag_a_branch $_tag
1233 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1234 OPTIONS="$OPTIONS -B"
1239 for i in $TAG_FILES; do
1240 # don't tag files stored on distfiles
1241 [ -n "`src_md5 $i`" ] && continue
1242 local fp=`nourl "$i"`
1243 if [ -f "$fp" ]; then
1244 tag_files="$tag_files $fp"
1245 elif [ -n "GREEDSRC" ]; then
1246 get_greed_sources $i
1248 Exit_error err_no_source_in_repo $i
1252 if [ "$tag_files" ]; then
1253 if [ "$TAG_VERSION" = "yes" ]; then
1254 update_shell_title "tag sources: $TAGVER"
1255 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1256 cvs $OPTIONS $TAGVER $tag_files || exit
1258 if [ -n "$TAG" ]; then
1259 update_shell_title "tag sources: $TAG"
1261 while [ "$tag_files" ]; do
1262 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1263 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1264 cvs $OPTIONS $TAG $chunk || exit
1265 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1271 if [ "$TAG_VERSION" = "yes" ]; then
1272 update_shell_title "tag spec: $TAGVER"
1273 cvs $OPTIONS $TAGVER $SPECFILE || exit
1275 if [ -n "$TAG" ]; then
1276 update_shell_title "tag spec: $TAG"
1277 cvs $OPTIONS $TAG $SPECFILE || exit
1284 echo "CVS branch tag: $TAG"
1289 if [ -n "$DEBUG" ]; then
1294 local OPTIONS="tag $CVS_FORCE -b"
1295 if [ -n "$CVSROOT" ]; then
1296 OPTIONS="-d $CVSROOT $OPTIONS"
1300 for i in $TAG_FILES; do
1301 local fp=`nourl "$i"`
1302 if [ -f "$fp" ]; then
1303 tag_files="$tag_files $fp"
1304 elif [ -n "GREEDSRC" ]; then
1305 get_greed_sources $i
1307 Exit_error err_no_source_in_repo $i
1310 if [ "$tag_files" ]; then
1311 cvs $OPTIONS $TAG $tag_files || exit
1315 cvs $OPTIONS $TAG $SPECFILE || exit
1319 # this function should exit early if package can't be built for this arch
1320 # this avoids unneccessary BR filling.
1323 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1325 if [ $ret -ne 0 ]; then
1334 update_shell_title "build_package"
1335 if [ -n "$DEBUG" ]; then
1342 if [ -n "$TRY_UPGRADE" ]; then
1343 update_shell_title "build_package: try_upgrade"
1344 if [ -n "$FLOAT_VERSION" ]; then
1345 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1347 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1350 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1352 if [ -n "$TNEWVER" ]; then
1353 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1354 echo "New version found, updating spec file to version " $TNEWVER
1355 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1356 cp -f $SPECFILE $SPECFILE.bak
1359 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1360 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1362 NODIST="yes" get_files $SOURCES $PATCHES
1365 unset TOLDVER TNEWVER TNOTIFY
1372 BUILD_SWITCH="-ba" ;;
1374 BUILD_SWITCH="-bb" ;;
1376 BUILD_SWITCH="-bs --nodeps" ;;
1378 BUILD_SWITCH="-bp --nodeps" ;;
1380 BUILD_SWITCH="-bc" ;;
1382 BUILD_SWITCH="-bi" ;;
1384 BUILD_SWITCH="-bl" ;;
1388 update_shell_title "build_package: $COMMAND"
1389 if [ -n "$LOGFILE" ]; then
1390 LOG=`eval echo $LOGFILE`
1391 if [ -d "$LOG" ]; then
1392 echo "Log file $LOG is a directory."
1393 echo "Parse error in the spec?"
1394 Exit_error err_build_fail
1396 if [ -n "$LASTLOG_FILE" ]; then
1397 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1399 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1401 (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1402 RETVAL=`cat $RES_FILE`
1404 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1405 if [ "$RETVAL" -eq "0" ]; then
1412 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $SPECFILE
1415 if [ "$RETVAL" -ne "0" ]; then
1416 if [ -n "$TRY_UPGRADE" ]; then
1417 echo "\n!!! Package with new version cannot be built automagically\n"
1418 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1419 mv -f $SPECFILE.bak $SPECFILE
1422 Exit_error err_build_fail
1429 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1432 install_required_packages()
1439 # taken from find-spec-bcond, but with just getting the list
1442 /^%changelog/ { exit }
1443 /_with(out)?_[_a-zA-Z0-9]+/{
1444 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1445 print substr($0, RSTART, RLENGTH);
1448 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1449 bcond = substr($0, RSTART +5 , RLENGTH -5);
1450 gsub(/[ \t]+/,"_",bcond);
1452 }' $SPEC | LC_ALL=C sort -u
1456 # expand bconds from ~/.bcondrc
1457 # The file structure is like gentoo's package.use:
1460 # samba -mysql -pgsql
1461 # w32codec-installer license_agreement
1464 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1470 SN=${SPECFILE%%\.spec}
1472 local bcondrc=$HOME/.bcondrc
1473 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1475 local bcond_avail=$(find_spec_bcond $SPECFILE)
1477 while read pkg flags; do
1479 [[ "$pkg" == \#* ]] && continue
1481 # any package or current package?
1482 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1483 for flag in $flags; do
1484 local opt=${flag#[+-]}
1486 # use only flags which are in this package.
1487 if [[ $bcond_avail = *${opt}* ]]; then
1488 if [[ $flag = -* ]]; then
1489 if [[ $BCOND != *--with?${opt}* ]]; then
1490 BCOND="$BCOND --without $opt"
1493 if [[ $BCOND != *--without?${opt}* ]]; then
1494 BCOND="$BCOND --with $opt"
1501 update_shell_title "parse ~/.bcondrc: DONE!"
1506 update_shell_title "set bcond values"
1508 AVAIL_BCONDS_WITHOUT=""
1509 AVAIL_BCONDS_WITH=""
1510 if `grep -q ^%bcond ${SPECFILE}`; then
1512 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1518 local bcond_avail=$(find_spec_bcond $SPECFILE)
1519 process_bcondrc "$SPECFILE"
1521 update_shell_title "parse bconds"
1522 case "${BCOND_VERSION}" in
1527 echo "Warning: This spec has old style bconds. Fix it || die."
1528 for opt in `echo "$bcond_avail" | grep ^_without_`
1530 AVAIL_BCOND_WITHOUT=${opt#_without_}
1531 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1532 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1534 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1538 for opt in `echo "$bcond_avail" | grep ^_with_`
1540 AVAIL_BCOND_WITH=${opt#_with_}
1541 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1542 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1544 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1549 local cond_type="" # with || without
1550 for opt in $bcond_avail; do
1559 AVAIL_BCOND_WITHOUT=${opt#_without_}
1560 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1561 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1563 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1567 AVAIL_BCOND_WITH=${opt#_with_}
1568 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1569 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1571 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1575 case "$cond_type" in
1578 AVAIL_BCOND_WITH="$opt"
1579 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1580 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1582 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1587 AVAIL_BCOND_WITHOUT="$opt"
1588 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1589 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1591 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1605 update_shell_title "run_sub_builder $package_name"
1607 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1608 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1609 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1610 # jakby nie bylo tego kawalka kodu.
1612 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1613 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1617 # kurwa. translate that ^^^^
1621 # Istnieje taki spec? ${package}.spec
1622 if [ -f "${SPEC_DIR}/${package}.spec" ]; then
1623 parent_spec_name=${package}.spec
1624 elif [ -f "${SPEC_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1625 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1627 for provides_line in $(grep -r ^Provides:.*$package ${SPEC_DIR}); do
1632 if [ "${parent_spec_name}" != "" ]; then
1633 spawn_sub_builder $parent_spec_name
1635 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1641 update_shell_title "spawn_sub_builder $package_name"
1644 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1645 sub_builder_opts="${sub_builder_opts} -R"
1647 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1648 sub_builder_opts="${sub_builder_opts} -RB"
1649 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1650 sub_builder_opts="${sub_builder_opts} -FRB"
1652 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1653 sub_builder_opts="${sub_builder_opts} -Upi"
1657 ./builder ${sub_builder_opts} "$@"
1660 remove_build_requires()
1662 if [ "$INSTALLED_PACKAGES" != "" ]; then
1663 case "$REMOVE_BUILD_REQUIRES" in
1665 run_poldek --noask -ve $INSTALLED_PACKAGES
1668 run_poldek --ask -ve $INSTALLED_PACKAGES
1671 echo You may want to manually remove following BuildRequires fetched:
1672 echo $INSTALLED_PACKAGES
1673 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1681 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1682 if [ "$BCOND" != "" ]; then
1683 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1686 echo -ne "\nNo conditional flags passed"
1688 echo -ne "\n\nfrom available:\n"
1689 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1695 if [ "$NOCVSSPEC" != "yes" ]; then
1696 echo -ne "Available branches: "
1697 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1701 # checks a given list of packages/files/provides agains current rpmdb.
1702 # outputs all dependencies which current rpmdb doesn't satisfy.
1703 # input can be either STDIN or parameters
1708 if [ $# -gt 0 ]; then
1714 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1717 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1719 # other deps (files)
1720 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1723 # checks if given package/files/provides exists in rpmdb.
1724 # input can be either stdin or parameters
1725 # returns packages which are present in the rpmdb
1730 if [ $# -gt 0 ]; then
1736 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1739 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1740 install_build_requires_rpmdeps() {
1741 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1742 # TODO: Conflicts list doesn't check versions
1743 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1744 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1746 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1747 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1748 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1751 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1752 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1753 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1754 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1756 if [ -n "$CNFL" ]; then
1757 update_shell_title "uninstall conflicting packages: $CNFL"
1758 echo "Trying to uninstall conflicting packages ($CNFL):"
1759 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1762 while [ "$DEPS" ]; do
1763 update_shell_title "install deps: $DEPS"
1764 echo "Trying to install dependencies ($DEPS):"
1765 local log=.${SPECFILE}_poldek.log
1766 $SU_SUDO /usr/bin/poldek --caplookup -uGqQ $DEPS | tee $log
1767 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1770 if [ -n "$failed" ]; then
1771 for package in $failed; do
1772 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1781 fetch_build_requires()
1783 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1787 update_shell_title "fetch build requires"
1788 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1789 install_build_requires_rpmdeps
1793 # XXX is this ugliest code written in human history still needed?
1794 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1795 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1796 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1797 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1798 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1799 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)
1801 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)
1803 package=$(basename "$package_item"|sed -e "s/}$//g")
1804 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1807 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1808 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1809 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
1814 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1817 if `echo $COND_TST|grep -q 'without_'`; then
1818 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1819 if `echo $COND_TST|grep -q !`; then
1824 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1825 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1826 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1832 elif `echo $COND_TST|grep -q 'with_'`; then
1833 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1834 if `echo $COND_TST|grep -q !`; then
1839 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1840 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1841 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1847 RESULT="${COND_STATE}-${COND_ARGV}"
1849 "with-wout" | "wout-with" )
1852 "wout-wout" | "with-with" )
1856 echo "Action '$RESULT' was not defined for package '$package_item'"
1862 if [ "$GO" = "yes" ]; then
1863 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1864 echo "Testing if $package has subrequirements..."
1865 run_poldek -t -i $package --dumpn=".$package-req.txt"
1866 if [ -f ".$package-req.txt" ]; then
1867 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1869 if [ "$package_name" = "$package" ]; then
1870 echo -ne "Installing BuildRequired package:\t$package_name\n"
1871 update_shell_title "Installing BuildRequired package: ${package_name}"
1872 install_required_packages $package
1874 echo -ne "Installing (sub)Required package:\t$package_name\n"
1875 update_shell_title "Installing (sub)Required package: ${package_name}"
1876 install_required_packages $package_name
1880 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1881 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1884 echo "Attempting to run spawn sub - builder..."
1885 echo -ne "Package installation failed:\t$package_name\n"
1886 run_sub_builder $package_name
1887 if [ $? -eq 0 ]; then
1888 install_required_packages $package_name
1891 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1892 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1895 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1902 rm -f ".$package-req.txt"
1904 echo "Attempting to run spawn sub - builder..."
1905 echo -ne "Package installation failed:\t$package\n"
1906 run_sub_builder $package
1907 if [ $? -eq 0 ]; then
1908 install_required_packages $package
1911 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1912 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1915 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1921 echo "Package $package is already installed. BuildRequirement satisfied."
1925 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1926 echo >&2 "Unable to install following packages and their dependencies:"
1927 for pkg in "$NOT_INSTALLED_PACKAGES"
1931 remove_build_requires
1937 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1938 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1940 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1942 cvs -d $CVSROOT co SOURCES/{.cvsignore,dropin} SPECS/{mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1946 echo "To checkout *all* .spec files:"
1947 echo "- remove $SPEC_DIR/CVS/Entries.Static"
1948 echo "- run cvs up in $SPEC_DIR dir"
1951 echo "To commit with your developer account:"
1952 echo "- edit $SPEC_DIR/CVS/Root"
1953 echo "- edit $SOURCE_DIR/CVS/Root"
1956 get_greed_sources() {
1957 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1958 if [ -n "BE_VERBOSE" ]; then
1959 echo "Try greed download: $1 from: $CVSROOT"
1961 cvs -d $CVSROOT get SOURCES/$1
1962 if [ $? != 0 ]; then
1963 Exit_error err_no_source_in_repo $1
1968 # remove entries from CVS/Entries
1969 cvs_entry_remove() {
1970 local cvsdir="$1"; shift
1971 if [ ! -d "$cvsdir" ]; then
1972 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1976 for file in "$@"; do
1977 rm -f $cvsdir/CVS/Entries.new || return 1
1978 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1979 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1987 DONT_PRINT_REVISION="yes"
1991 # remove from CVS/Entries
1992 cvs_entry_remove $SPEC_DIR $SPECFILE
1993 cvs_entry_remove $SOURCE_DIR $SOURCES $PATCHES
1995 # remove spec and sources
1996 $RPMBUILD --clean --rmsource --rmspec --nodeps $SPECFILE
1999 #---------------------------------------------
2007 while [ $# -gt 0 ]; do
2010 COMMAND="update_md5"
2015 COMMAND="update_md5"
2025 DEBUG="yes"; shift ;;
2027 COMMAND="version"; shift ;;
2029 COMMAND="short-version"; shift ;;
2031 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
2032 -b | -ba | --build )
2033 COMMAND="build"; shift ;;
2034 -bb | --build-binary )
2035 COMMAND="build-binary"; shift ;;
2037 COMMAND="build-build"; shift ;;
2039 COMMAND="build-install"; shift ;;
2041 COMMAND="build-list"; shift ;;
2042 -bp | --build-prep )
2043 COMMAND="build-prep"; shift ;;
2044 -bs | --build-source )
2045 COMMAND="build-source"; shift ;;
2047 COMMAND="branch"; shift; TAG="${1}"; shift;;
2049 CLEAN="--clean --rmspec --rmsource"; shift ;;
2051 CVS_FORCE="-F"; shift;;
2053 shift; CVSROOT="${1}"; shift ;;
2055 COMMAND="get"; shift ;;
2057 COMMAND="usage"; shift ;;
2059 PROTOCOL="http"; shift ;;
2061 shift; LOGFILE="${1}"; shift ;;
2063 shift; DEF_NICE_LEVEL=${1}; shift ;;
2064 -ske | --skip-existing-files)
2065 SKIP_EXISTING_FILES="yes"; shift ;;
2067 COMMAND="mr-proper"; shift ;;
2069 NOCVS="yes"; shift ;;
2070 -ncs | --no-cvs-specs )
2071 NOCVSSPEC="yes"; shift ;;
2072 -nd | --no-distfiles )
2073 NODIST="yes"; shift ;;
2074 -nm | --no-mirrors )
2075 NOMIRRORS="yes"; shift ;;
2077 NOURLS="yes"; shift ;;
2079 NOSRCS="yes"; shift ;;
2080 -ns0 | --no-source0 )
2081 NOSOURCE0="yes"; shift ;;
2091 -pm | --prefer-mirrors )
2098 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2100 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2101 --with | --without )
2102 case $GROUP_BCONDS in
2106 while ! `echo ${1}|grep -qE '(^-|spec)'`
2108 BCOND="$BCOND $COND $1"
2112 if [[ "$2" = *,* ]]; then
2113 for a in $(echo "$2" | tr , ' '); do
2114 BCOND="$BCOND $1 $a"
2117 BCOND="$BCOND $1 $2"
2123 shift; TARGET="${1}"; shift ;;
2125 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2127 QUIET="--quiet"; shift ;;
2129 CVSDATE="${2}"; shift 2 ;;
2131 shift; CVSTAG="${1}"; shift ;;
2133 shift; CVSTAG="HEAD"; ;;
2134 -R | --fetch-build-requires)
2135 FETCH_BUILD_REQUIRES="yes"
2136 NOT_INSTALLED_PACKAGES=
2138 -RB | --remove-build-requires)
2139 REMOVE_BUILD_REQUIRES="nice"
2141 -FRB | --force-remove-build-requires)
2142 REMOVE_BUILD_REQUIRES="force"
2144 -sc | --sources-cvs)
2145 COMMAND="list-sources-cvs"
2147 -sd | --sources-distfiles)
2148 COMMAND="list-sources-distfiles"
2150 -sdp | --sources-distfiles-paths)
2151 COMMAND="list-sources-distfiles-paths"
2153 -sf | --sources-files)
2154 COMMAND="list-sources-files"
2156 -sp | --sources-paths)
2157 COMMAND="list-sources-local-paths"
2159 -su | --sources-urls)
2160 COMMAND="list-sources-urls"
2162 -Tvs | --tag-version-stable )
2167 -Ts | --tag-stable )
2172 -Tv | --tag-version )
2177 -Tp | --tag-prefix )
2189 -ir | --integer-release-only )
2190 INTEGER_RELEASE="yes"
2193 COMMAND="update_md5"
2198 -Upi | --update-poldek-indexes )
2199 UPDATE_POLDEK_INDEXES="yes"
2202 COMMAND="init_rpm_dir"
2204 --use-greed-sources )
2207 -u | --try-upgrade )
2208 TRY_UPGRADE="1"; shift ;;
2209 -un | --try-upgrade-with-float-version )
2210 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2212 BE_VERBOSE="1"; shift ;;
2217 if echo "${MACRO}" | grep -q '\W'; then
2218 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2222 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2227 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2231 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2234 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2235 COMMAND="show_bconds"
2239 COMMAND="show_bcond_args"
2244 RPMOPTS="${RPMOPTS} --nodeps"
2247 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2250 Exit_error err_invalid_cmdline "$1"
2254 # check if specname was passed as specname:cvstag
2255 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2256 CVSTAG="${SPECFILE##*:}"
2257 SPECFILE="${SPECFILE%%:*}"
2259 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2264 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2265 CVSTAG=$(awk -vSPECFILE=$(basename ${SPECFILE%.spec}.spec) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2266 if [ "$CVSTAG" ]; then
2267 echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
2269 elif [ "$CVSTAG" = "HEAD" ]; then
2270 # assume -r HEAD is same as -A
2274 if [ -n "$DEBUG" ]; then
2279 if [ -n "$TARGET" ]; then
2282 TARGET_SWITCH="--target $TARGET" ;;
2284 TARGET_SWITCH="--target=$TARGET" ;;
2288 if [ "$SCHEDTOOL" != "no" ]; then
2289 NICE_COMMAND="$SCHEDTOOL"
2291 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2294 update_shell_title "$COMMAND"
2298 if [ -n "$SPECFILE" ]; then
2299 get_spec > /dev/null
2307 if [ -n "$SPECFILE" ]; then
2308 get_spec > /dev/null
2314 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2316 if [ -n "$SPECFILE" ]; then
2322 if [ "$COMMAND" != "build-source" ]; then
2325 fetch_build_requires
2326 if [ "$INTEGER_RELEASE" = "yes" ]; then
2327 echo "Checking release $PACKAGE_RELEASE..."
2328 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2329 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2333 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2334 if [ -n "$TEST_TAG" ]; then
2335 local TAGVER=`make_tagver`
2336 echo "Searching for tag $TAGVER..."
2337 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2338 if [ -n "$TAGREL" ]; then
2339 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2342 # - do not allow to build from HEAD when XX-branch exists
2343 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2344 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2345 TAG_BRANCH="${TREE_PREFIX}-branch"
2346 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2347 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2348 Exit_error err_branch_exists "$TAG_STATUS"
2354 if [ -n "$NOSOURCE0" ] ; then
2355 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2357 get_files $SOURCES $PATCHES
2360 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2361 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2363 remove_build_requires
2365 Exit_error err_no_spec_in_cmdl
2370 if [ -n "$SPECFILE" ]; then
2373 # don't fetch sources from remote locations
2375 for file in $SOURCES; do
2376 [ -n "`src_md5 $file`" ] && continue
2377 new_SOURCES="$new_SOURCES $file"
2379 SOURCES="$new_SOURCES"
2380 get_files $SOURCES $PATCHES
2382 branch_files $TAG $SOURCES $PATCHES $ICONS
2384 Exit_error err_no_spec_in_cmdl
2389 if [ -n "$SPECFILE" ]; then
2393 if [ -n "$NOSOURCE0" ] ; then
2394 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2396 get_files $SOURCES $PATCHES
2399 Exit_error err_no_spec_in_cmdl
2404 if [ -n "$SPECFILE" ]; then
2408 if [ -n "$NOSOURCE0" ] ; then
2409 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2413 Exit_error err_no_spec_in_cmdl
2420 if [ -n "$SPECFILE" ]; then
2424 # don't fetch sources from remote locations
2426 for file in $SOURCES; do
2427 [ -n "`src_md5 $file`" ] && continue
2428 new_SOURCES="$new_SOURCES $file"
2430 SOURCES="$new_SOURCES"
2431 get_files $SOURCES $PATCHES
2433 tag_files $SOURCES $PATCHES $ICONS
2435 Exit_error err_no_spec_in_cmdl
2441 "list-sources-files" )
2444 DONT_PRINT_REVISION="yes"
2447 for SAP in $SOURCES $PATCHES; do
2448 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2451 "list-sources-urls" )
2454 DONT_PRINT_REVISION="yes"
2457 SAPS="$SOURCES $PATCHES"
2458 for SAP in $SAPS ; do
2462 "list-sources-local-paths" )
2465 DONT_PRINT_REVISION="yes"
2468 for SAP in $SOURCES $PATCHES; do
2469 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2472 "list-sources-distfiles-paths" )
2475 DONT_PRINT_REVISION="yes"
2478 for SAP in $SOURCES $PATCHES; do
2479 if [ -n "$(src_md5 "$SAP")" ]; then
2480 distfiles_path "$SAP"
2484 "list-sources-distfiles" )
2487 DONT_PRINT_REVISION="yes"
2490 for SAP in $SOURCES $PATCHES; do
2491 if [ -n "$(src_md5 "$SAP")" ]; then
2492 distfiles_url "$SAP"
2496 "list-sources-cvs" )
2499 DONT_PRINT_REVISION="yes"
2502 for SAP in $SOURCES $PATCHES; do
2503 if [ -z "$(src_md5 "$SAP")" ]; then
2504 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2518 echo "$VERSIONSTRING"
2521 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2522 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2526 # vi:syntax=sh:ts=4:sw=4:noet