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)
26 # - ability to do ./builder -bb foo.spec foo2.spec foo3.spec
33 Build package utility from PLD Linux CVS repository
34 $VERSION (C) 1999-2008 Free Penguins".
36 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
55 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
59 # use rpm 4.4.6+ digest format instead of comments if non-zero
62 # user agent when fetching files
63 USER_AGENT="PLD/Builder($VERSION)"
65 # It can be used i.e. in log file naming.
66 # See LOGFILE example.
67 DATE=`date +%Y-%m-%d_%H-%M-%S`
69 # Example: LOGFILE='../log.$PACKAGE_NAME'
70 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
71 # Yes, you can use variable name! Note _single_ quotes!
95 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
96 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
102 CVS_SERVER="cvs.pld-linux.org"
103 DISTFILES_SERVER="://distfiles.pld-linux.org"
104 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
109 FAIL_IF_NO_SOURCES="yes"
111 # let get_files skip over files which are present to get those damn files fetched
112 SKIP_EXISTING_FILES="no"
115 # should the specfile be restored if upgrade failed?
116 REVERT_BROKEN_UPGRADE="yes"
118 if rpm --specsrpm 2>/dev/null; then
119 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
120 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
122 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
123 if [ -x /usr/bin/rpm-getdeps ]; then
124 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
126 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
131 # Here we load saved user environment used to
132 # predefine options set above, or passed to builder
134 # This one reads global system environment settings:
135 if [ -f ~/etc/builderrc ]; then
138 # And this one cascades settings using user personal
140 # Example of ~/.builderrc:
142 #UPDATE_POLDEK_INDEXES="yes"
143 #FETCH_BUILD_REQUIRES="yes"
144 #REMOVE_BUILD_REQUIRES="force"
146 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
150 if [ -n "$HOME_ETC" ]; then
151 USER_CFG="$HOME_ETC/.builderrc"
152 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
154 USER_CFG=~/.builderrc
155 BUILDER_MACROS=~/.builder-rpmmacros
158 [ -f "$USER_CFG" ] && . "$USER_CFG"
160 if [ "$SCHEDTOOL" = "auto" ]; then
161 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
162 SCHEDTOOL="schedtool -B -e"
168 if [ -n "$USE_PROZILLA" ]; then
169 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
172 elif [ -n "$USE_AXEL" ]; then
173 GETURI="axel -a $AXEL_OPTS"
177 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
178 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
179 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
180 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
182 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
183 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
189 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
198 # are we using cvs-nserver ?
201 cvs --version 2>&1 | grep -q 'CVS-nserver'
202 [ $? -eq 0 ] && CVS_NSERVER=1
204 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
205 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
209 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
210 if [ -n "$LOGFILE" ]; then
211 LOG=`eval echo $LOGFILE`
212 if [ -n "$LASTLOG_FILE" ]; then
213 echo "LASTLOG=$LOG" > $LASTLOG_FILE
215 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
218 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
219 return `cat ${RES_FILE}`
224 #---------------------------------------------
229 if [ -n "$DEBUG" ]; then set -xv; fi
231 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
232 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
233 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
234 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
235 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
236 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
237 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
238 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
239 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
240 <package>[.spec][:cvstag]
242 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
243 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
244 -n5, --no-md5 - ignore md5 comments in spec
245 -D, --debug - enable builder script debugging mode,
246 -debug - produce rpm debug package (same as --opts -debug)
247 -V, --version - output builder version string
248 --short-version - output builder short version
249 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
250 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
252 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
253 only package from <package>.spec,
254 -bp, --build-prep - execute the %prep phase of <package>.spec,
255 -bc - execute the %build phase of <package>.spec,
256 -bi - execute the %install phase of <package>.spec
257 -bl - execute the %files phase of <package>.spec
258 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
260 --short-circuit - short-circuit build
261 -B, --branch - add branch
262 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
263 SPECS and \$RPM_BUILD_ROOT and CVS/Entries) after rpmbuild commands.
264 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
265 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
267 -cf, --cvs-force - use -F when tagging (useful when moving branches)
268 -d <cvsroot>, --cvsroot <cvsroot>
270 --define <macro> <value>
271 - define a macro <macro> with value <value>,
272 --alt_kernel <kernel>
273 - same as --define 'alt_kernel <kernel>'
274 --nodeps - rpm won't check any dependences
275 -g, --get - get <package>.spec and all related files from CVS repo
277 -h, --help - this message,
278 --http - use http instead of ftp,
279 -l <logfile>, --logtofile <logfile>
281 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
283 - don't check specs in CVS
284 -nd, --no-distfiles - don't download from distfiles
285 -nm, --no-mirrors - don't download from mirror, if source URL is given,
286 -nu, --no-urls - don't try to download from FTP/HTTP location,
287 -ns, --no-srcs - don't download Sources
288 -ns0, --no-source0 - don't download Source0
289 -nn, --no-net - don't download anything from the net
290 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
291 --no-init - don't initialize builder paths (SPECS and SOURCES)
293 --skip-existing-files - skip existing files in get_files
294 --opts <rpm opts> - additional options for rpm
295 -q, --quiet - be quiet,
296 --date yyyy-mm-dd - build package using resources from specified CVS date,
297 -r <cvstag>, --cvstag <cvstag>
298 - build package using resources from specified CVS tag,
299 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
300 -R, --fetch-build-requires
301 - fetch what is BuildRequired,
302 -RB, --remove-build-requires
303 - remove all you fetched with -R or --fetch-build-requires
304 remember, this option requires confirmation,
305 -FRB, --force-remove-build-requires
306 - remove all you fetched with -R or --fetch-build-requires
307 remember, this option works without confirmation,
308 -sd, --source-distfiles - list sources available from distfiles (intended for offline
309 operations; does not work when Icon field is present
310 but icon file is absent),
311 -sc, --source-cvs - list sources available from CVS
312 -sdp, --source-distfiles-paths - list sources available from distfiles -
313 paths relative to distfiles directory (intended for offline
314 operations; does not work when Icon field is present
315 but icon file is absent),
316 -sf, --source-files - list sources - bare filenames (intended for offline
317 operations; does not work when Icon field is present
318 but icon file is absent),
319 -sp, --source-paths - list sources - filenames with full local paths (intended for
320 offline operations; does not work when Icon field is present
321 but icon file is absent),
322 -su, --source-urls - list urls - urls to sources and patches
323 intended for copying urls with spec with lots of macros in urls
324 -T <cvstag> , --tag <cvstag>
325 - add cvs tag <cvstag> for files,
326 -Tvs, --tag-version-stable
327 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
329 - add cvs tag STABLE for files,
331 - add cvs tag NAME-VERSION-RELEASE for files,
332 -Tp, --tag-prefix <prefix>
333 - add <prefix> to NAME-VERSION-RELEASE tags,
334 -tt, --test-tag <prefix>
335 - fail if tag is already present,
336 -ir, --integer-release-only
337 - allow only integer and snapshot releases
338 -v, --verbose - be verbose,
339 -u, --try-upgrade - check version, and try to upgrade package
340 -un, --try-upgrade-with-float-version
341 - as above, but allow float version
343 - try download source from tag head if don't find it in
345 -U, --update - refetch sources, don't use distfiles, and update md5 comments
346 -Upi, --update-poldek-indexes
347 - refresh or make poldek package index files.
348 -np, --nopatch <patchnumber>
349 - don't apply <patchnumber>
350 --show-bconds - show available conditional builds, which can be used
351 - with --with and/or --without switches.
352 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
353 ./repackage.sh script. in other words, the output is
354 parseable by scripts.
355 --with/--without <feature>
356 - conditional build package depending on %_with_<feature>/
357 %_without_<feature> macro switch. You may now use
358 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
359 constructions. Set GROUP_BCONDS to yes to make use of it.
360 --target <platform>, --target=<platform>
361 - build for platform <platform>.
362 --init-rpm-dir - initialize ~/rpm directory structure
366 # change dependency to specname
368 # - perl(Package::Name) -> perl-Package-Name
372 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g}')
376 update_shell_title() {
378 local len=${COLUMNS:-80}
379 local msg=$(echo "$*" | cut -c-$len)
381 if [ -n "$BE_VERBOSE" ]; then
382 echo >&2 "$(date +%s.%N) $*"
385 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
387 if [ -n "$PACKAGE_NAME" ]; then
388 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
393 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
394 msg=$(echo $msg | tr -d '\n\r')
397 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
400 echo >&2 -ne "\033]0;$msg\007"
406 # set TARGET from BuildArch: from SPECFILE
408 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
409 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
411 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
415 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
417 TARGET_SWITCH="--target=$TARGET" ;;
423 # runs rpm with minimal macroset
425 # we reset macros not to contain macros.build as all the %() macros are
426 # executed here, while none of them are actually needed.
427 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
428 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
430 # TODO: move these to /usr/lib/rpm/macros
431 cat > $BUILDER_MACROS <<'EOF'
432 %x8664 x86_64 amd64 ia32e
435 %requires_releq_kernel_up %{nil}
436 %requires_releq_kernel_smp %{nil}
437 %requires_releq_kernel %{nil}
438 %requires_releq() %{nil}
439 %pyrequires_eq() %{nil}
440 %requires_eq() %{nil}
441 %requires_eq_to() %{nil}
442 %releq_kernel_up ERROR
443 %releq_kernel_smp ERROR
448 %ruby_ver_requires_eq() %{nil}
449 %ruby_mod_ver_requires_eq() %{nil}
450 %__php_api_requires() %{nil}
451 %php_major_version ERROR
452 %php_api_version ERROR
453 %requires_xorg_xserver_extension %{nil}
454 %requires_xorg_xserver_xinput %{nil}
455 %requires_xorg_xserver_font %{nil}
456 %requires_xorg_xserver_videodrv %{nil}
458 %perl_vendorarch ERROR
459 %perl_vendorlib ERROR
460 # damn. need it here! - copied from /usr/lib/rpm/macros.build
461 %tmpdir %(echo "${TMPDIR:-/tmp}")
462 %patchset_source(f:b:) %(
463 base=%{-b*}%{!-b*:10000};
464 start=$(expr $base + %1);
465 end=$(expr $base + %{?2}%{!?2:%{1}});
466 # we need to call seq twice as it doesn't allow two formats
467 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
468 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
469 paste %{tmpdir}/__ps{1,2};
470 rm -f %{tmpdir}/__ps{1,2};
473 %add_etc_shells(p) %{p:<lua>}
474 %remove_etc_shells(p) %{p:<lua>}
476 if [ "$NOINIT" = "yes" ] ; then
477 cat >> $BUILDER_MACROS <<'EOF'
482 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
486 if [ -n "$DEBUG" ]; then
491 if [ -x /usr/bin/rpm-specdump ]; then
492 update_shell_title "cache_rpm_dump using rpm-specdump command"
493 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
495 update_shell_title "cache_rpm_dump using rpmbuild command"
498 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
499 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
505 ARGS='--nodigest --nosignature --nobuild'
508 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
510 if [ $? -gt 0 ]; then
511 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
513 Exit_error err_build_fail
516 # make small dump cache
517 rpm_dump_cache=`echo "$rpm_dump" | awk '
518 $2 ~ /^SOURCEURL/ {print}
519 $2 ~ /^PATCHURL/ {print}
520 $2 ~ /^nosource/ {print}
521 $2 ~ /^PACKAGE_/ {print}
525 update_shell_title "cache_rpm_dump: OK!"
529 if [ -z "$rpm_dump_cache" ] ; then
530 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
532 echo "$rpm_dump_cache"
537 update_shell_title "get icons"
538 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
539 if [ -z "$ICONS" ]; then
543 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
548 update_shell_title "parsing specfile"
549 if [ -n "$DEBUG" ]; then
554 # icons are needed for successful spec parse
560 if [ "$NOSRCS" != "yes" ]; then
561 SOURCES=$(rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}')
564 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
565 FAIL_IF_NO_SOURCES="no"
568 PATCHES=$(rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}')
569 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
570 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
571 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
572 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
574 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
575 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
578 if [ -n "$BE_VERBOSE" ]; then
579 echo "- Sources : `nourl $SOURCES`"
580 if [ -n "$PATCHES" ]; then
581 echo "- Patches : `nourl $PATCHES`"
583 echo "- Patches : *no patches needed*"
585 if [ -n "$ICONS" ]; then
586 echo "- Icon : `nourl $ICONS`"
588 echo "- Icon : *no package icon*"
590 echo "- Name : $PACKAGE_NAME"
591 echo "- Version : $PACKAGE_VERSION"
592 echo "- Release : $PACKAGE_RELEASE"
595 update_shell_title "parse_spec: OK!"
600 if [ -n "$DEBUG" ]; then
608 "err_no_spec_in_cmdl" )
609 remove_build_requires
610 echo >&2 "ERROR: spec file name not specified."
612 "err_invalid_cmdline" )
613 echo >&2 "ERROR: invalid command line arg ($2)."
615 "err_no_spec_in_repo" )
616 remove_build_requires
617 echo >&2 "Error: spec file not stored in CVS repo."
619 "err_no_source_in_repo" )
620 remove_build_requires
621 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
624 remove_build_requires
625 echo >&2 "Error: package build failed. (${2:-no more info})"
627 "err_no_package_data" )
628 remove_build_requires
629 echo >&2 "Error: couldn't get out package name/version/release from spec file."
632 remove_build_requires
633 echo >&2 "Tag ${2} already exists (spec release: ${3})."
636 remove_build_requires
637 echo >&2 "Release ${2} not integer and not a snapshot."
639 "err_branch_exists" )
640 remove_build_requires
641 echo >&2 "Tree branch already exists (${2})."
644 remove_build_requires
645 echo >&2 "Error: conditions reject building this spec (${2})."
648 echo >&2 "Unknown error."
654 if [ -n "$DEBUG" ]; then
659 if [ "$NOINIT" != "yes" ] ; then
661 if [ "$ASSUMED_NAME" ]; then
662 extra="--define 'name $ASSUMED_NAME'"
664 SOURCE_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_sourcedir}')
665 SPEC_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_specdir}')
677 update_shell_title "get_spec"
679 if [ -n "$DEBUG" ]; then
685 if [ ! -f "$SPECFILE" ]; then
686 SPECFILE="$(basename $SPECFILE .spec).spec"
688 if [ "$NOCVSSPEC" != "yes" ]; then
690 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
691 echo "Warning: No CVS access defined - using local .spec file"
695 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
698 if [ ! -f "$SPECFILE" ]; then
699 Exit_error err_no_spec_in_repo
702 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
703 chmod $CHMOD_MODE $SPECFILE
706 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
715 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
716 cvs update mirrors >&2
720 local origin mirror name rest ol prefix
721 while read origin mirror name rest; do
722 # skip comments and empty lines
723 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
726 ol=$(echo -n "$origin" | wc -c)
727 prefix=$(echo -n "$url" | head -c $ol)
728 if [ "$prefix" = "$origin" ] ; then
729 suffix=$(echo "$url" | cut -b $((ol+1))-)
730 echo -n "$mirror$suffix"
737 # Warning: unpredictable results if same URL used twice
742 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
743 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
749 [ "$NO5" = "yes" ] && return
751 [ -z "$no" ] && return
755 if [ -f additional-md5sums ]; then
756 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
757 if [ -z "$spec_rev" ]; then
758 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
760 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
761 md5=$(grep -s -v '^#' additional-md5sums | \
762 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
763 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
764 grep -E '^[0-9a-f]{32}$')
767 if [ $(echo "$md5" | wc -l) != 1 ] ; then
768 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
770 echo "$md5" | tail -n 1
775 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
776 if [ -n "$source_md5" ]; then
779 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
780 if [ -n "$source_md5" ]; then
783 # we have empty SourceX-md5, but it is still possible
784 # that we have NoSourceX-md5 AND NoSource: X
785 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
786 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
795 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
800 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
803 distfiles_attic_url ()
805 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
812 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
817 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
818 [ -n "$size" -a "$size" -gt 0 ]
823 if [ "$CVSIGNORE_DF" != "yes" ]; then
826 cvsignore=${SOURCE_DIR}/.cvsignore
827 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
828 echo "$1" >> $cvsignore
834 update_shell_title "cvsup"
836 if [ -n "$CVSROOT" ]; then
837 OPTIONS="-d $CVSROOT $OPTIONS"
840 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
841 OPTIONS="$OPTIONS -A"
843 if [ -n "$CVSDATE" ]; then
844 OPTIONS="$OPTIONS -D $CVSDATE"
846 if [ -n "$CVSTAG" ]; then
847 OPTIONS="$OPTIONS -r $CVSTAG"
852 local retries_counter=0
854 update_shell_title "cvsup: $*"
856 update_shell_title "cvsup: $# files"
858 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
859 retries_counter=$(( $retries_counter + 1 ))
860 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
862 [ -n "$output" ] && echo "$output"
863 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
864 echo "Trying again [$*]... ($retries_counter)"
865 update_shell_title "cvsup: retry #$retries_counter"
872 update_shell_title "cvsup: done!"
876 # returns true if "$1" is ftp, http or https protocol url
880 ftp://*|http://*|https://*)
889 if [ $# -eq 0 ]; then
893 update_shell_title "update md5"
894 if [ -n "$DEBUG" ]; then
901 # pass 1: check files to be fetched
905 local fp=$(nourl "$i")
906 local srcno=$(src_no "$i")
907 if [ -n "$ADD5" ]; then
908 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
909 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE && continue
910 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE && continue
912 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE || continue
914 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
915 need_files="$need_files $i"
919 # pass 1a: get needed files
920 if [ "$need_files" ]; then
921 get_files $need_files
924 # pass 2: proceed with md5 adding or updating
926 local fp=$(nourl "$i")
927 local srcno=$(src_no "$i")
928 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE )
929 if [ -z "$md5" ]; then
930 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE )
932 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
933 local tag="# Source$srcno-md5:\t"
934 if [[ "$md5" == *NoSource* ]]; then
935 tag="# NoSource$srcno-md5:\t"
936 elif [ -n "$USEDIGEST" ]; then
937 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
939 md5=$(md5sum "$fp" | cut -f1 -d' ')
940 echo "Updating Source$srcno ($md5: $fp)."
942 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
943 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
952 [ "$NO5" = "yes" ] && return
954 update_shell_title "check md5"
957 if good_md5 "$i" && good_size "$i"; then
961 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
962 echo "or -5 to update md5 sums, if you're sure files are correct."
963 Exit_error err_no_source_in_repo $i
969 update_shell_title "get_files"
971 if [ -n "$DEBUG" ]; then
976 if [ $# -gt 0 ]; then
979 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
980 echo "Warning: No CVS access defined for SOURCES"
985 local get_files_cvs=""
989 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
990 update_shell_title "$i"
991 local fp=`nourl "$i"`
992 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
997 local srcmd5=$(src_md5 "$i")
999 # we know if source/patch is present in cvs/distfiles
1000 # - has md5 (in distfiles)
1001 # - in cvs... ideas?
1003 # CHECK: local file didn't exist or always cvs up (first) requested.
1004 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1005 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1006 echo "Warning: no URL given for $i"
1009 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1010 if good_md5 "$i" && good_size "$i"; then
1011 echo "$fp having proper md5sum already exists"
1016 # optionally prefer mirror over distfiles if there's mirror
1017 # TODO: build url list and then try each url from the list
1018 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1021 url=$(distfiles_url "$i")
1024 url_attic=$(distfiles_attic_url "$i")
1026 # is $url local file?
1027 if [[ "$url" = [./]* ]]; then
1028 update_shell_title "${GETLOCAL%% *}: $url"
1029 ${GETLOCAL} $url $target
1031 if [ -z "$NOMIRRORS" ]; then
1032 url=$(find_mirror "$url")
1036 # make shorter message for distfiles urls
1037 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1038 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1039 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1042 update_shell_title "${GETURI%% *}: $uri"
1043 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1044 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1045 update_shell_title "${GETURI2%% *}: $url"
1046 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1051 if [ ! -s "$target" ]; then
1053 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1054 update_shell_title "${GETLOCAL%% *}: $url_attic"
1055 ${GETLOCAL} $url_attic $target
1057 if [ -z "$NOMIRRORS" ]; then
1058 url_attic=$(find_mirror "$url_attic")
1060 update_shell_title "${GETURI%% *}: $url_attic"
1061 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1062 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1063 update_shell_title "${GETURI2%% *}: $url_attic"
1064 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1069 if [ -s "$target" ]; then
1070 cvsignore_df $target
1075 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1076 if [ $# -gt 1 ]; then
1077 get_files_cvs="$get_files_cvs $fp"
1078 update_shell_title "$fp (will cvs up later)"
1085 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1086 if [ -z "$NOMIRRORS" ]; then
1087 im=$(find_mirror "$i")
1091 update_shell_title "${GETURI%% *}: $im"
1092 ${GETURI} "$im" || \
1093 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1094 update_shell_title "${GETURI2%% *}: $im"
1099 if [ "$cvsup" = 1 ]; then
1105 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1106 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1107 if [ -n "GREEDSRC" ]; then
1108 get_greed_sources $i
1110 Exit_error err_no_source_in_repo $i
1114 # we check md5 here just only to refetch immediately
1115 if good_md5 "$i" && good_size "$i"; then
1117 elif [ "$FROM_DISTFILES" = 1 ]; then
1118 # wrong md5 from distfiles: remove the file and try again
1120 echo "MD5 sum mismatch. Trying full fetch."
1123 update_shell_title "${GETURI%% *}: $url"
1124 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1125 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1126 update_shell_title "${GETURI2%% *}: $url"
1127 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1129 if [ ! -s "$target" ]; then
1131 update_shell_title "${GETURI%% *}: $url_attic"
1132 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1133 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1134 update_shell_title "${GETURI2%% *}: $url_attic"
1135 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1138 test -s "$target" || rm -f "$target"
1141 SHELL_TITLE_PREFIX=""
1143 if [ "$get_files_cvs" ]; then
1144 cvsup $get_files_cvs
1147 if [ "$CHMOD" = "yes" ]; then
1148 CHMOD_FILES=$(nourl "$@")
1149 if [ -n "$CHMOD_FILES" ]; then
1150 chmod $CHMOD_MODE $CHMOD_FILES
1157 if [ -n "$DEBUG" ]; then
1162 # Check whether first character of PACKAGE_NAME is legal for tag name
1163 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1167 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1168 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1170 # Remove #kernel.version_release from TAGVER because tagging sources
1171 # could occur with different kernel-headers than kernel-headers used at build time.
1172 # besides, %{_kernel_ver_str} is not expanded.
1174 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1175 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1181 # bool is_tag_a_branch(tag)
1183 # returns 1 if a tag is a branch set on SPECFILE
1185 if [ -n "$DEBUG" ]; then
1190 if [ $# -ne 1 ]; then
1197 cvs status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1205 if [ -n "$DEBUG" ]; then
1210 echo "Version: $PACKAGE_VERSION"
1211 echo "Release: $PACKAGE_RELEASE"
1214 if [ "$TAG_VERSION" = "yes" ]; then
1215 TAGVER=`make_tagver`
1216 echo "CVS tag: $TAGVER"
1218 if [ -n "$TAG" ]; then
1219 echo "CVS tag: $TAG"
1222 local OPTIONS="tag $CVS_FORCE"
1223 if [ -n "$CVSROOT" ]; then
1224 OPTIONS="-d $CVSROOT $OPTIONS"
1227 # if a tagname we are about to set already exists
1228 # and happens to be a branch (common case with AC-branch)
1229 # pass -B (allows -F to disturb branch tag)
1231 if [ "$TAG_VERSION" = "yes" ]; then
1234 is_tag_a_branch $_tag
1235 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1236 OPTIONS="$OPTIONS -B"
1241 for i in $TAG_FILES; do
1242 # don't tag files stored on distfiles
1243 [ -n "`src_md5 $i`" ] && continue
1244 local fp=`nourl "$i"`
1245 if [ -f "$fp" ]; then
1246 tag_files="$tag_files $fp"
1247 elif [ -n "GREEDSRC" ]; then
1248 get_greed_sources $i
1250 Exit_error err_no_source_in_repo $i
1254 if [ "$tag_files" ]; then
1255 if [ "$TAG_VERSION" = "yes" ]; then
1256 update_shell_title "tag sources: $TAGVER"
1257 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1258 cvs $OPTIONS $TAGVER $tag_files || exit
1260 if [ -n "$TAG" ]; then
1261 update_shell_title "tag sources: $TAG"
1263 while [ "$tag_files" ]; do
1264 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1265 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1266 cvs $OPTIONS $TAG $chunk || exit
1267 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1273 if [ "$TAG_VERSION" = "yes" ]; then
1274 update_shell_title "tag spec: $TAGVER"
1275 cvs $OPTIONS $TAGVER $SPECFILE || exit
1277 if [ -n "$TAG" ]; then
1278 update_shell_title "tag spec: $TAG"
1279 cvs $OPTIONS $TAG $SPECFILE || exit
1286 echo "CVS branch tag: $TAG"
1291 if [ -n "$DEBUG" ]; then
1296 local OPTIONS="tag $CVS_FORCE -b"
1299 is_tag_a_branch $TAG
1300 if [ $? -eq 1 ]; then
1301 OPTIONS="$OPTIONS -B"
1304 if [ -n "$CVSROOT" ]; then
1305 OPTIONS="-d $CVSROOT $OPTIONS"
1309 for i in $TAG_FILES; do
1310 local fp=`nourl "$i"`
1311 if [ -f "$fp" ]; then
1312 tag_files="$tag_files $fp"
1313 elif [ -n "GREEDSRC" ]; then
1314 get_greed_sources $i
1316 Exit_error err_no_source_in_repo $i
1319 if [ "$tag_files" ]; then
1320 cvs $OPTIONS $TAG $tag_files || exit
1324 cvs $OPTIONS $TAG $SPECFILE || exit
1328 # this function should exit early if package can't be built for this arch
1329 # this avoids unneccessary BR filling.
1332 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1334 if [ $ret -ne 0 ]; then
1343 update_shell_title "build_package"
1344 if [ -n "$DEBUG" ]; then
1351 if [ -n "$TRY_UPGRADE" ]; then
1352 update_shell_title "build_package: try_upgrade"
1353 if [ -n "$FLOAT_VERSION" ]; then
1354 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1356 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1359 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1361 if [ -n "$TNEWVER" ]; then
1362 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1363 echo "New version found, updating spec file to version " $TNEWVER
1364 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1365 cp -f $SPECFILE $SPECFILE.bak
1368 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1369 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1371 NODIST="yes" get_files $SOURCES $PATCHES
1374 unset TOLDVER TNEWVER TNOTIFY
1381 BUILD_SWITCH="-ba" ;;
1383 BUILD_SWITCH="-bb" ;;
1385 BUILD_SWITCH="-bs --nodeps" ;;
1387 BUILD_SWITCH="-bp --nodeps" ;;
1389 BUILD_SWITCH="-bc" ;;
1391 BUILD_SWITCH="-bi" ;;
1393 BUILD_SWITCH="-bl" ;;
1397 update_shell_title "build_package: $COMMAND"
1398 if [ -n "$LOGFILE" ]; then
1399 LOG=`eval echo $LOGFILE`
1400 if [ -d "$LOG" ]; then
1401 echo "Log file $LOG is a directory."
1402 echo "Parse error in the spec?"
1403 Exit_error err_build_fail
1405 if [ -n "$LASTLOG_FILE" ]; then
1406 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1408 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1410 (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1411 RETVAL=`cat $RES_FILE`
1413 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1414 if [ "$RETVAL" -eq "0" ]; then
1421 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $SPECFILE
1424 if [ "$RETVAL" -ne "0" ]; then
1425 if [ -n "$TRY_UPGRADE" ]; then
1426 echo "\n!!! Package with new version cannot be built automagically\n"
1427 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1428 mv -f $SPECFILE.bak $SPECFILE
1431 Exit_error err_build_fail
1438 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1441 install_required_packages()
1448 # taken from find-spec-bcond, but with just getting the list
1451 /^%changelog/ { exit }
1452 /_with(out)?_[_a-zA-Z0-9]+/{
1453 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1454 print substr($0, RSTART, RLENGTH);
1457 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1458 bcond = substr($0, RSTART +5 , RLENGTH -5);
1459 gsub(/[ \t]+/,"_",bcond);
1461 }' $SPEC | LC_ALL=C sort -u
1465 # expand bconds from ~/.bcondrc
1466 # The file structure is like gentoo's package.use:
1469 # samba -mysql -pgsql
1470 # w32codec-installer license_agreement
1473 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1479 SN=${SPECFILE%%\.spec}
1481 local bcondrc=$HOME/.bcondrc
1482 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1484 local bcond_avail=$(find_spec_bcond $SPECFILE)
1486 while read pkg flags; do
1488 [[ "$pkg" == \#* ]] && continue
1490 # any package or current package?
1491 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1492 for flag in $flags; do
1493 local opt=${flag#[+-]}
1495 # use only flags which are in this package.
1496 if [[ $bcond_avail = *${opt}* ]]; then
1497 if [[ $flag = -* ]]; then
1498 if [[ $BCOND != *--with?${opt}* ]]; then
1499 BCOND="$BCOND --without $opt"
1502 if [[ $BCOND != *--without?${opt}* ]]; then
1503 BCOND="$BCOND --with $opt"
1510 update_shell_title "parse ~/.bcondrc: DONE!"
1515 update_shell_title "set bcond values"
1517 AVAIL_BCONDS_WITHOUT=""
1518 AVAIL_BCONDS_WITH=""
1519 if `grep -q ^%bcond ${SPECFILE}`; then
1521 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1527 local bcond_avail=$(find_spec_bcond $SPECFILE)
1528 process_bcondrc "$SPECFILE"
1530 update_shell_title "parse bconds"
1531 case "${BCOND_VERSION}" in
1536 echo "Warning: This spec has old style bconds. Fix it || die."
1537 for opt in `echo "$bcond_avail" | grep ^_without_`
1539 AVAIL_BCOND_WITHOUT=${opt#_without_}
1540 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1541 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1543 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1547 for opt in `echo "$bcond_avail" | grep ^_with_`
1549 AVAIL_BCOND_WITH=${opt#_with_}
1550 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1551 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1553 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1558 local cond_type="" # with || without
1559 for opt in $bcond_avail; do
1568 AVAIL_BCOND_WITHOUT=${opt#_without_}
1569 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1570 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1572 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1576 AVAIL_BCOND_WITH=${opt#_with_}
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"
1584 case "$cond_type" in
1587 AVAIL_BCOND_WITH="$opt"
1588 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1589 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1591 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1596 AVAIL_BCOND_WITHOUT="$opt"
1597 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1598 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1600 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1614 update_shell_title "run_sub_builder $package_name"
1616 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1617 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1618 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1619 # jakby nie bylo tego kawalka kodu.
1621 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1622 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1626 # kurwa. translate that ^^^^
1630 # Istnieje taki spec? ${package}.spec
1631 if [ -f "${SPEC_DIR}/${package}.spec" ]; then
1632 parent_spec_name=${package}.spec
1633 elif [ -f "${SPEC_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1634 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1636 for provides_line in $(grep -r ^Provides:.*$package ${SPEC_DIR}); do
1641 if [ "${parent_spec_name}" != "" ]; then
1642 spawn_sub_builder $parent_spec_name
1644 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1650 update_shell_title "spawn_sub_builder $package_name"
1653 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1654 sub_builder_opts="${sub_builder_opts} -R"
1656 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1657 sub_builder_opts="${sub_builder_opts} -RB"
1658 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1659 sub_builder_opts="${sub_builder_opts} -FRB"
1661 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1662 sub_builder_opts="${sub_builder_opts} -Upi"
1666 ./builder ${sub_builder_opts} "$@"
1669 remove_build_requires()
1671 if [ "$INSTALLED_PACKAGES" != "" ]; then
1672 case "$REMOVE_BUILD_REQUIRES" in
1674 run_poldek --noask -ve $INSTALLED_PACKAGES
1677 run_poldek --ask -ve $INSTALLED_PACKAGES
1680 echo You may want to manually remove following BuildRequires fetched:
1681 echo $INSTALLED_PACKAGES
1682 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1690 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1691 if [ "$BCOND" != "" ]; then
1692 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1695 echo -ne "\nNo conditional flags passed"
1697 echo -ne "\n\nfrom available:\n"
1698 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1704 if [ "$NOCVSSPEC" != "yes" ]; then
1705 echo -ne "Available branches: "
1706 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1710 # checks a given list of packages/files/provides agains current rpmdb.
1711 # outputs all dependencies which current rpmdb doesn't satisfy.
1712 # input can be either STDIN or parameters
1717 if [ $# -gt 0 ]; then
1723 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1726 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1728 # other deps (files)
1729 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1732 # checks if given package/files/provides exists in rpmdb.
1733 # input can be either stdin or parameters
1734 # returns packages which are present in the rpmdb
1739 if [ $# -gt 0 ]; then
1745 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1748 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1749 install_build_requires_rpmdeps() {
1750 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1751 # TODO: Conflicts list doesn't check versions
1752 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1753 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1755 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1756 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1757 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1760 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1761 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1762 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1763 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1765 if [ -n "$CNFL" ]; then
1766 update_shell_title "uninstall conflicting packages: $CNFL"
1767 echo "Trying to uninstall conflicting packages ($CNFL):"
1768 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1771 while [ "$DEPS" ]; do
1772 update_shell_title "install deps: $DEPS"
1773 echo "Trying to install dependencies ($DEPS):"
1774 local log=.${SPECFILE}_poldek.log
1775 $SU_SUDO /usr/bin/poldek --caplookup -uGqQ $DEPS | tee $log
1776 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1779 if [ -n "$failed" ]; then
1780 for package in $failed; do
1781 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1790 fetch_build_requires()
1792 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1796 update_shell_title "fetch build requires"
1797 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1798 install_build_requires_rpmdeps
1802 # XXX is this ugliest code written in human history still needed?
1803 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1804 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1805 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1806 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1807 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1808 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)
1810 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)
1812 package=$(basename "$package_item"|sed -e "s/}$//g")
1813 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1816 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1817 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1818 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
1823 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1826 if `echo $COND_TST|grep -q 'without_'`; then
1827 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1828 if `echo $COND_TST|grep -q !`; then
1833 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1834 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1835 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1841 elif `echo $COND_TST|grep -q 'with_'`; then
1842 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1843 if `echo $COND_TST|grep -q !`; then
1848 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1849 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1850 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1856 RESULT="${COND_STATE}-${COND_ARGV}"
1858 "with-wout" | "wout-with" )
1861 "wout-wout" | "with-with" )
1865 echo "Action '$RESULT' was not defined for package '$package_item'"
1871 if [ "$GO" = "yes" ]; then
1872 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1873 echo "Testing if $package has subrequirements..."
1874 run_poldek -t -i $package --dumpn=".$package-req.txt"
1875 if [ -f ".$package-req.txt" ]; then
1876 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1878 if [ "$package_name" = "$package" ]; then
1879 echo -ne "Installing BuildRequired package:\t$package_name\n"
1880 update_shell_title "Installing BuildRequired package: ${package_name}"
1881 install_required_packages $package
1883 echo -ne "Installing (sub)Required package:\t$package_name\n"
1884 update_shell_title "Installing (sub)Required package: ${package_name}"
1885 install_required_packages $package_name
1889 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1890 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1893 echo "Attempting to run spawn sub - builder..."
1894 echo -ne "Package installation failed:\t$package_name\n"
1895 run_sub_builder $package_name
1896 if [ $? -eq 0 ]; then
1897 install_required_packages $package_name
1900 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1901 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1904 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1911 rm -f ".$package-req.txt"
1913 echo "Attempting to run spawn sub - builder..."
1914 echo -ne "Package installation failed:\t$package\n"
1915 run_sub_builder $package
1916 if [ $? -eq 0 ]; then
1917 install_required_packages $package
1920 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1921 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1924 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1930 echo "Package $package is already installed. BuildRequirement satisfied."
1934 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1935 echo >&2 "Unable to install following packages and their dependencies:"
1936 for pkg in "$NOT_INSTALLED_PACKAGES"
1940 remove_build_requires
1946 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1947 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1949 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1951 cvs -d $CVSROOT co SOURCES/{.cvsignore,dropin} SPECS/{mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1955 echo "To checkout *all* .spec files:"
1956 echo "- remove $SPEC_DIR/CVS/Entries.Static"
1957 echo "- run cvs up in $SPEC_DIR dir"
1960 echo "To commit with your developer account:"
1961 echo "- edit $SPEC_DIR/CVS/Root"
1962 echo "- edit $SOURCE_DIR/CVS/Root"
1965 get_greed_sources() {
1966 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1967 if [ -n "BE_VERBOSE" ]; then
1968 echo "Try greed download: $1 from: $CVSROOT"
1970 cvs -d $CVSROOT get SOURCES/$1
1971 if [ $? != 0 ]; then
1972 Exit_error err_no_source_in_repo $1
1977 # remove entries from CVS/Entries
1978 cvs_entry_remove() {
1979 local cvsdir="$1"; shift
1980 if [ ! -d "$cvsdir" ]; then
1981 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1985 for file in "$@"; do
1986 rm -f $cvsdir/CVS/Entries.new || return 1
1987 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1988 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1996 DONT_PRINT_REVISION="yes"
2000 # remove from CVS/Entries
2001 cvs_entry_remove $SPEC_DIR $SPECFILE
2002 cvs_entry_remove $SOURCE_DIR $SOURCES $PATCHES
2004 # remove spec and sources
2005 $RPMBUILD --clean --rmsource --rmspec --nodeps $SPECFILE
2008 #---------------------------------------------
2016 while [ $# -gt 0 ]; do
2019 COMMAND="update_md5"
2024 COMMAND="update_md5"
2034 DEBUG="yes"; shift ;;
2036 COMMAND="version"; shift ;;
2038 COMMAND="short-version"; shift ;;
2040 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
2041 -b | -ba | --build )
2042 COMMAND="build"; shift ;;
2043 -bb | --build-binary )
2044 COMMAND="build-binary"; shift ;;
2046 COMMAND="build-build"; shift ;;
2048 COMMAND="build-install"; shift ;;
2050 COMMAND="build-list"; shift ;;
2051 -bp | --build-prep )
2052 COMMAND="build-prep"; shift ;;
2053 -bs | --build-source )
2054 COMMAND="build-source"; shift ;;
2056 COMMAND="branch"; shift; TAG="${1}"; shift;;
2058 CLEAN="--clean --rmspec --rmsource"; shift ;;
2060 CVS_FORCE="-F"; shift;;
2062 shift; CVSROOT="${1}"; shift ;;
2064 COMMAND="get"; shift ;;
2066 COMMAND="usage"; shift ;;
2068 PROTOCOL="http"; shift ;;
2070 shift; LOGFILE="${1}"; shift ;;
2072 shift; DEF_NICE_LEVEL=${1}; shift ;;
2073 -ske | --skip-existing-files)
2074 SKIP_EXISTING_FILES="yes"; shift ;;
2076 COMMAND="mr-proper"; shift ;;
2078 NOCVS="yes"; shift ;;
2079 -ncs | --no-cvs-specs )
2080 NOCVSSPEC="yes"; shift ;;
2081 -nd | --no-distfiles )
2082 NODIST="yes"; shift ;;
2083 -nm | --no-mirrors )
2084 NOMIRRORS="yes"; shift ;;
2086 NOURLS="yes"; shift ;;
2088 NOSRCS="yes"; shift ;;
2089 -ns0 | --no-source0 )
2090 NOSOURCE0="yes"; shift ;;
2100 -pm | --prefer-mirrors )
2107 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2109 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2110 --with | --without )
2111 case $GROUP_BCONDS in
2115 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2116 while ! `echo ${1}|grep -qE '(^-|spec)'`
2118 BCOND="$BCOND $COND $1"
2122 if [[ "$2" = *,* ]]; then
2123 for a in $(echo "$2" | tr , ' '); do
2124 BCOND="$BCOND $1 $a"
2127 BCOND="$BCOND $1 $2"
2133 shift; TARGET="${1}"; shift ;;
2135 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2137 QUIET="--quiet"; shift ;;
2139 CVSDATE="${2}"; shift 2 ;;
2141 shift; CVSTAG="${1}"; shift ;;
2143 shift; CVSTAG="HEAD"; ;;
2144 -R | --fetch-build-requires)
2145 FETCH_BUILD_REQUIRES="yes"
2146 NOT_INSTALLED_PACKAGES=
2148 -RB | --remove-build-requires)
2149 REMOVE_BUILD_REQUIRES="nice"
2151 -FRB | --force-remove-build-requires)
2152 REMOVE_BUILD_REQUIRES="force"
2154 -sc | --sources-cvs)
2155 COMMAND="list-sources-cvs"
2157 -sd | --sources-distfiles)
2158 COMMAND="list-sources-distfiles"
2160 -sdp | --sources-distfiles-paths)
2161 COMMAND="list-sources-distfiles-paths"
2163 -sf | --sources-files)
2164 COMMAND="list-sources-files"
2166 -sp | --sources-paths)
2167 COMMAND="list-sources-local-paths"
2169 -su | --sources-urls)
2170 COMMAND="list-sources-urls"
2172 -Tvs | --tag-version-stable )
2177 -Ts | --tag-stable )
2182 -Tv | --tag-version )
2187 -Tp | --tag-prefix )
2199 -ir | --integer-release-only )
2200 INTEGER_RELEASE="yes"
2203 COMMAND="update_md5"
2208 -Upi | --update-poldek-indexes )
2209 UPDATE_POLDEK_INDEXES="yes"
2212 COMMAND="init_rpm_dir"
2214 --use-greed-sources )
2217 -u | --try-upgrade )
2218 TRY_UPGRADE="1"; shift ;;
2219 -un | --try-upgrade-with-float-version )
2220 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2222 BE_VERBOSE="1"; shift ;;
2227 if echo "${MACRO}" | grep -q '\W'; then
2228 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2232 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2237 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2241 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2244 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2245 COMMAND="show_bconds"
2249 COMMAND="show_bcond_args"
2254 RPMOPTS="${RPMOPTS} --nodeps"
2257 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2260 Exit_error err_invalid_cmdline "$1"
2264 # check if specname was passed as specname:cvstag
2265 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2266 CVSTAG="${SPECFILE##*:}"
2267 SPECFILE="${SPECFILE%%:*}"
2269 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2274 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2275 CVSTAG=$(awk -vSPECFILE=$(basename ${SPECFILE%.spec}.spec) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2276 if [ "$CVSTAG" ]; then
2277 echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
2279 elif [ "$CVSTAG" = "HEAD" ]; then
2280 # assume -r HEAD is same as -A
2284 if [ -n "$DEBUG" ]; then
2289 if [ -n "$TARGET" ]; then
2292 TARGET_SWITCH="--target $TARGET" ;;
2294 TARGET_SWITCH="--target=$TARGET" ;;
2298 if [ "$SCHEDTOOL" != "no" ]; then
2299 NICE_COMMAND="$SCHEDTOOL"
2301 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2304 update_shell_title "$COMMAND"
2308 if [ -n "$SPECFILE" ]; then
2309 get_spec > /dev/null
2317 if [ -n "$SPECFILE" ]; then
2318 get_spec > /dev/null
2324 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2326 if [ -n "$SPECFILE" ]; then
2332 if [ "$COMMAND" != "build-source" ]; then
2335 fetch_build_requires
2336 if [ "$INTEGER_RELEASE" = "yes" ]; then
2337 echo "Checking release $PACKAGE_RELEASE..."
2338 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2339 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2343 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2344 if [ -n "$TEST_TAG" ]; then
2345 local TAGVER=`make_tagver`
2346 echo "Searching for tag $TAGVER..."
2347 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2348 if [ -n "$TAGREL" ]; then
2349 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2352 # - do not allow to build from HEAD when XX-branch exists
2353 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2354 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2355 TAG_BRANCH="${TREE_PREFIX}-branch"
2356 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2357 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2358 Exit_error err_branch_exists "$TAG_STATUS"
2364 if [ -n "$NOSOURCE0" ] ; then
2365 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2367 get_files $SOURCES $PATCHES
2370 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2371 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2373 remove_build_requires
2375 Exit_error err_no_spec_in_cmdl
2380 if [ -n "$SPECFILE" ]; then
2383 # don't fetch sources from remote locations
2385 for file in $SOURCES; do
2386 [ -n "`src_md5 $file`" ] && continue
2387 new_SOURCES="$new_SOURCES $file"
2389 SOURCES="$new_SOURCES"
2390 get_files $SOURCES $PATCHES
2392 branch_files $TAG $SOURCES $PATCHES $ICONS
2394 Exit_error err_no_spec_in_cmdl
2399 if [ -n "$SPECFILE" ]; then
2403 if [ -n "$NOSOURCE0" ] ; then
2404 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2406 get_files $SOURCES $PATCHES
2409 Exit_error err_no_spec_in_cmdl
2414 if [ -n "$SPECFILE" ]; then
2418 if [ -n "$NOSOURCE0" ] ; then
2419 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2423 Exit_error err_no_spec_in_cmdl
2430 if [ -n "$SPECFILE" ]; then
2434 # don't fetch sources from remote locations
2436 for file in $SOURCES; do
2437 [ -n "`src_md5 $file`" ] && continue
2438 new_SOURCES="$new_SOURCES $file"
2440 SOURCES="$new_SOURCES"
2441 get_files $SOURCES $PATCHES
2443 tag_files $SOURCES $PATCHES $ICONS
2445 Exit_error err_no_spec_in_cmdl
2451 "list-sources-files" )
2454 DONT_PRINT_REVISION="yes"
2457 for SAP in $SOURCES $PATCHES; do
2458 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2461 "list-sources-urls" )
2464 DONT_PRINT_REVISION="yes"
2467 SAPS="$SOURCES $PATCHES"
2468 for SAP in $SAPS ; do
2472 "list-sources-local-paths" )
2475 DONT_PRINT_REVISION="yes"
2478 for SAP in $SOURCES $PATCHES; do
2479 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2482 "list-sources-distfiles-paths" )
2485 DONT_PRINT_REVISION="yes"
2488 for SAP in $SOURCES $PATCHES; do
2489 if [ -n "$(src_md5 "$SAP")" ]; then
2490 distfiles_path "$SAP"
2494 "list-sources-distfiles" )
2497 DONT_PRINT_REVISION="yes"
2500 for SAP in $SOURCES $PATCHES; do
2501 if [ -n "$(src_md5 "$SAP")" ]; then
2502 distfiles_url "$SAP"
2506 "list-sources-cvs" )
2509 DONT_PRINT_REVISION="yes"
2512 for SAP in $SOURCES $PATCHES; do
2513 if [ -z "$(src_md5 "$SAP")" ]; then
2514 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2528 echo "$VERSIONSTRING"
2531 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2532 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2536 # vi:syntax=sh:ts=4:sw=4:noet