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-2009 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!
94 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
96 CVS_COMMAND=${CVS_COMMAND:-cvs}
99 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
100 CVS_SERVER="cvs.pld-linux.org"
105 DISTFILES_SERVER="://distfiles.pld-linux.org"
106 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
111 FAIL_IF_NO_SOURCES="yes"
113 # let get_files skip over files which are present to get those damn files fetched
114 SKIP_EXISTING_FILES="no"
117 # should the specfile be restored if upgrade failed?
118 REVERT_BROKEN_UPGRADE="yes"
120 if rpm --specsrpm 2>/dev/null; then
121 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
122 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
124 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
125 if [ -x /usr/bin/rpm-getdeps ]; then
126 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
128 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
133 # Here we load saved user environment used to
134 # predefine options set above, or passed to builder
136 # This one reads global system environment settings:
137 if [ -f ~/etc/builderrc ]; then
140 # And this one cascades settings using user personal
142 # Example of ~/.builderrc:
144 #UPDATE_POLDEK_INDEXES="yes"
145 #FETCH_BUILD_REQUIRES="yes"
146 #REMOVE_BUILD_REQUIRES="force"
148 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
152 if [ -n "$HOME_ETC" ]; then
153 USER_CFG="$HOME_ETC/.builderrc"
154 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
156 USER_CFG=~/.builderrc
157 BUILDER_MACROS=~/.builder-rpmmacros
160 [ -f "$USER_CFG" ] && . "$USER_CFG"
162 if [ "$SCHEDTOOL" = "auto" ]; then
163 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
164 SCHEDTOOL="schedtool -B -e"
170 if [ -n "$USE_PROZILLA" ]; then
171 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
174 elif [ -n "$USE_AXEL" ]; then
175 GETURI="axel -a $AXEL_OPTS"
179 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
180 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
181 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
182 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
184 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
185 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
191 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
200 # are we using cvs-nserver ?
203 $CVS_COMMAND --version 2>&1 | grep -q 'CVS-nserver'
204 [ $? -eq 0 ] && CVS_NSERVER=1
206 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
207 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
210 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
211 if [ -n "$LOGFILE" ]; then
212 LOG=`eval echo $LOGFILE`
213 if [ -n "$LASTLOG_FILE" ]; then
214 echo "LASTLOG=$LOG" > $LASTLOG_FILE
216 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
219 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
220 return `cat ${RES_FILE}`
225 #---------------------------------------------
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}' $ASSUMED_NAME/$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>}
475 %lua_add_etc_shells() %{nil}
476 %lua_remove_etc_shells() %{nil}
478 if [ "$NOINIT" = "yes" ] ; then
479 cat >> $BUILDER_MACROS <<'EOF'
484 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
488 if [ -n "$DEBUG" ]; then
493 if [ -x /usr/bin/rpm-specdump ]; then
494 update_shell_title "cache_rpm_dump using rpm-specdump command"
495 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
497 update_shell_title "cache_rpm_dump using rpmbuild command"
500 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
501 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
507 ARGS='--nodigest --nosignature --nobuild'
510 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
512 if [ $? -gt 0 ]; then
513 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
515 Exit_error err_build_fail
518 # make small dump cache
519 rpm_dump_cache=`echo "$rpm_dump" | awk '
520 $2 ~ /^SOURCEURL/ {print}
521 $2 ~ /^PATCHURL/ {print}
522 $2 ~ /^nosource/ {print}
523 $2 ~ /^PACKAGE_/ {print}
527 update_shell_title "cache_rpm_dump: OK!"
531 if [ -z "$rpm_dump_cache" ] ; then
532 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
534 echo "$rpm_dump_cache"
538 update_shell_title "get icons"
539 ICONS=$(awk '/^Icon:/ {print $2}' ${ASSUMED_NAME}/${SPECFILE})
540 if [ -z "$ICONS" ]; then
544 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 '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
564 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
565 FAIL_IF_NO_SOURCES="no"
568 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
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!"
599 if [ -n "$DEBUG" ]; then
607 "err_no_spec_in_cmdl" )
608 remove_build_requires
609 echo >&2 "ERROR: spec file name not specified."
611 "err_invalid_cmdline" )
612 echo >&2 "ERROR: invalid command line arg ($2)."
614 "err_no_spec_in_repo" )
615 remove_build_requires
616 echo >&2 "Error: spec file not stored in CVS repo."
618 "err_no_source_in_repo" )
619 remove_build_requires
620 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
623 remove_build_requires
624 echo >&2 "Error: package build failed. (${2:-no more info})"
626 "err_no_package_data" )
627 remove_build_requires
628 echo >&2 "Error: couldn't get out package name/version/release from spec file."
631 remove_build_requires
632 echo >&2 "Tag ${2} already exists (spec release: ${3})."
635 remove_build_requires
636 echo >&2 "Release ${2} not integer and not a snapshot."
638 "err_branch_exists" )
639 remove_build_requires
640 echo >&2 "Tree branch already exists (${2})."
643 remove_build_requires
644 echo >&2 "Error: conditions reject building this spec (${2})."
647 echo >&2 "Unknown error."
652 if [ -n "$DEBUG" ]; then
657 if [ "$NOINIT" != "yes" ] ; then
658 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
659 REPO_DIR=$TOP_DIR/packages
660 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
671 update_shell_title "get_spec"
673 if [ -n "$DEBUG" ]; then
679 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
680 SPECFILE="$(basename $SPECFILE .spec).spec"
682 if [ "$NOCVSSPEC" != "yes" ]; then
684 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
685 echo "Warning: No CVS access defined - using local .spec file"
689 if [ -d "$ASSUMED_NAME" ]; then
690 cvsup "$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
692 cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
696 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
697 Exit_error err_no_spec_in_repo
700 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
701 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
704 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
712 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
713 $CVS_COMMAND update mirrors >&2
717 local origin mirror name rest ol prefix
718 while read origin mirror name rest; do
719 # skip comments and empty lines
720 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
723 ol=$(echo -n "$origin" | wc -c)
724 prefix=$(echo -n "$url" | head -c $ol)
725 if [ "$prefix" = "$origin" ] ; then
726 suffix=$(echo "$url" | cut -b $((ol+1))-)
727 echo -n "$mirror$suffix"
734 # Warning: unpredictable results if same URL used twice
738 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
739 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
744 [ "$NO5" = "yes" ] && return
746 [ -z "$no" ] && return
750 if [ -f additional-md5sums ]; then
751 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
752 if [ -z "$spec_rev" ]; then
753 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
755 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
756 md5=$(grep -s -v '^#' additional-md5sums | \
757 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
758 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
759 grep -E '^[0-9a-f]{32}$')
762 if [ $(echo "$md5" | wc -l) != 1 ] ; then
763 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
765 echo "$md5" | tail -n 1
770 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
771 if [ -n "$source_md5" ]; then
774 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
775 if [ -n "$source_md5" ]; then
778 # we have empty SourceX-md5, but it is still possible
779 # that we have NoSourceX-md5 AND NoSource: X
780 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
781 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
789 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
793 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
796 distfiles_attic_url() {
797 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
803 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
807 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
808 [ -n "$size" -a "$size" -gt 0 ]
812 if [ "$CVSIGNORE_DF" != "yes" ]; then
815 cvsignore=${PACKAGE_DIR}/.cvsignore
816 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
817 echo "$1" >> $cvsignore
822 update_shell_title "cvsup"
825 if [ "$1" = "-c" ]; then
829 if [ -n "$CVSROOT" ]; then
830 OPTIONS="-d $CVSROOT $OPTIONS"
833 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
834 OPTIONS="$OPTIONS -A"
836 if [ -n "$CVSDATE" ]; then
837 OPTIONS="$OPTIONS -D $CVSDATE"
839 if [ -n "$CVSTAG" ]; then
840 OPTIONS="$OPTIONS -r $CVSTAG"
845 local retries_counter=0
847 update_shell_title "cvsup: $*"
849 update_shell_title "cvsup: $# files"
851 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
852 retries_counter=$(( $retries_counter + 1 ))
853 output=$(LC_ALL=C $CVS_COMMAND $OPTIONS "$@" 2>&1)
855 [ -n "$output" ] && echo "$output"
856 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
857 echo "Trying again [$*]... ($retries_counter)"
858 update_shell_title "cvsup: retry #$retries_counter"
865 update_shell_title "cvsup: done!"
869 # returns true if "$1" is ftp, http or https protocol url
872 ftp://*|http://*|https://*)
880 if [ $# -eq 0 ]; then
884 update_shell_title "update md5"
885 if [ -n "$DEBUG" ]; then
892 # pass 1: check files to be fetched
896 local fp=$(nourl "$i")
897 local srcno=$(src_no "$i")
898 if [ -n "$ADD5" ]; then
899 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
900 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
901 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
903 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
905 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
906 need_files="$need_files $i"
910 # pass 1a: get needed files
911 if [ "$need_files" ]; then
912 get_files $need_files
915 # pass 2: proceed with md5 adding or updating
917 local fp=$(nourl "$i")
918 local srcno=$(src_no "$i")
919 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
920 if [ -z "$md5" ]; then
921 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
923 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
924 local tag="# Source$srcno-md5:\t"
925 if [[ "$md5" == *NoSource* ]]; then
926 tag="# NoSource$srcno-md5:\t"
927 elif [ -n "$USEDIGEST" ]; then
928 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
930 md5=$(md5sum "$fp" | cut -f1 -d' ')
931 echo "Updating Source$srcno ($md5: $fp)."
933 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
934 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
936 $PACKAGE_DIR/$SPECFILE
942 [ "$NO5" = "yes" ] && return
944 update_shell_title "check md5"
947 if good_md5 "$i" && good_size "$i"; then
951 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
952 echo "or -5 to update md5 sums, if you're sure files are correct."
953 Exit_error err_no_source_in_repo $i
958 update_shell_title "get_files"
960 if [ -n "$DEBUG" ]; then
965 if [ $# -gt 0 ]; then
968 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
969 echo "Warning: No CVS access defined for SOURCES"
974 local get_files_cvs=""
978 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
979 update_shell_title "$i"
980 local fp=`nourl "$i"`
981 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
986 local srcmd5=$(src_md5 "$i")
988 # we know if source/patch is present in cvs/distfiles
989 # - has md5 (in distfiles)
992 # CHECK: local file didn't exist or always cvs up (first) requested.
993 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
994 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
995 echo "Warning: no URL given for $i"
998 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
999 if good_md5 "$i" && good_size "$i"; then
1000 echo "$fp having proper md5sum already exists"
1005 # optionally prefer mirror over distfiles if there's mirror
1006 # TODO: build url list and then try each url from the list
1007 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1010 url=$(distfiles_url "$i")
1013 url_attic=$(distfiles_attic_url "$i")
1015 # is $url local file?
1016 if [[ "$url" = [./]* ]]; then
1017 update_shell_title "${GETLOCAL%% *}: $url"
1018 ${GETLOCAL} $url $target
1020 if [ -z "$NOMIRRORS" ]; then
1021 url=$(find_mirror "$url")
1025 # make shorter message for distfiles urls
1026 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1027 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1028 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1031 update_shell_title "${GETURI%% *}: $uri"
1032 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1033 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1034 update_shell_title "${GETURI2%% *}: $url"
1035 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1040 if [ ! -s "$target" ]; then
1042 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1043 update_shell_title "${GETLOCAL%% *}: $url_attic"
1044 ${GETLOCAL} $url_attic $target
1046 if [ -z "$NOMIRRORS" ]; then
1047 url_attic=$(find_mirror "$url_attic")
1049 update_shell_title "${GETURI%% *}: $url_attic"
1050 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1051 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1052 update_shell_title "${GETURI2%% *}: $url_attic"
1053 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1058 if [ -s "$target" ]; then
1059 cvsignore_df $target
1064 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1065 if [ $# -gt 1 ]; then
1066 get_files_cvs="$get_files_cvs $fp"
1067 update_shell_title "$fp (will cvs up later)"
1074 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1075 if [ -z "$NOMIRRORS" ]; then
1076 im=$(find_mirror "$i")
1080 update_shell_title "${GETURI%% *}: $im"
1081 ${GETURI} "$im" || \
1082 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1083 update_shell_title "${GETURI2%% *}: $im"
1088 if [ "$cvsup" = 1 ]; then
1094 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1095 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1096 if [ -n "GREEDSRC" ]; then
1097 get_greed_sources $i
1099 Exit_error err_no_source_in_repo $i
1103 # we check md5 here just only to refetch immediately
1104 if good_md5 "$i" && good_size "$i"; then
1106 elif [ "$FROM_DISTFILES" = 1 ]; then
1107 # wrong md5 from distfiles: remove the file and try again
1109 echo "MD5 sum mismatch. Trying full fetch."
1112 update_shell_title "${GETURI%% *}: $url"
1113 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1114 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1115 update_shell_title "${GETURI2%% *}: $url"
1116 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1118 if [ ! -s "$target" ]; then
1120 update_shell_title "${GETURI%% *}: $url_attic"
1121 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1122 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1123 update_shell_title "${GETURI2%% *}: $url_attic"
1124 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1127 test -s "$target" || rm -f "$target"
1130 SHELL_TITLE_PREFIX=""
1132 if [ "$get_files_cvs" ]; then
1133 cvsup $get_files_cvs
1136 if [ "$CHMOD" = "yes" ]; then
1137 CHMOD_FILES=$(nourl "$@")
1138 if [ -n "$CHMOD_FILES" ]; then
1139 chmod $CHMOD_MODE $CHMOD_FILES
1146 if [ -n "$DEBUG" ]; then
1151 # Check whether first character of PACKAGE_NAME is legal for tag name
1152 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1156 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1157 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1159 # Remove #kernel.version_release from TAGVER because tagging sources
1160 # could occur with different kernel-headers than kernel-headers used at build time.
1161 # besides, %{_kernel_ver_str} is not expanded.
1163 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1164 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1170 # bool is_tag_a_branch(tag)
1172 # returns 1 if a tag is a branch set on SPECFILE
1174 if [ -n "$DEBUG" ]; then
1179 if [ $# -ne 1 ]; then
1186 $CVS_COMMAND status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1193 if [ -n "$DEBUG" ]; then
1198 echo "Version: $PACKAGE_VERSION"
1199 echo "Release: $PACKAGE_RELEASE"
1202 if [ "$TAG_VERSION" = "yes" ]; then
1203 TAGVER=`make_tagver`
1204 echo "CVS tag: $TAGVER"
1206 if [ -n "$TAG" ]; then
1207 echo "CVS tag: $TAG"
1210 local OPTIONS="tag $CVS_FORCE"
1211 if [ -n "$CVSROOT" ]; then
1212 OPTIONS="-d $CVSROOT $OPTIONS"
1215 # if a tagname we are about to set already exists
1216 # and happens to be a branch (common case with AC-branch)
1217 # pass -B (allows -F to disturb branch tag)
1219 if [ "$TAG_VERSION" = "yes" ]; then
1222 is_tag_a_branch $_tag
1223 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1224 OPTIONS="$OPTIONS -B"
1229 for i in $TAG_FILES; do
1230 # don't tag files stored on distfiles
1231 [ -n "`src_md5 $i`" ] && continue
1232 local fp=`nourl "$i"`
1233 if [ -f "$fp" ]; then
1234 tag_files="$tag_files $fp"
1235 elif [ -n "GREEDSRC" ]; then
1236 get_greed_sources $i
1238 Exit_error err_no_source_in_repo $i
1242 if [ "$tag_files" ]; then
1243 if [ "$TAG_VERSION" = "yes" ]; then
1244 update_shell_title "tag sources: $TAGVER"
1245 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1246 $CVS_COMMAND $OPTIONS $TAGVER $tag_files || exit
1248 if [ -n "$TAG" ]; then
1249 update_shell_title "tag sources: $TAG"
1251 while [ "$tag_files" ]; do
1252 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1253 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1254 $CVS_COMMAND $OPTIONS $TAG $chunk || exit
1255 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1261 if [ "$TAG_VERSION" = "yes" ]; then
1262 update_shell_title "tag spec: $TAGVER"
1263 $CVS_COMMAND $OPTIONS $TAGVER $SPECFILE || exit
1265 if [ -n "$TAG" ]; then
1266 update_shell_title "tag spec: $TAG"
1267 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1273 echo "CVS branch tag: $TAG"
1278 if [ -n "$DEBUG" ]; then
1283 local OPTIONS="tag $CVS_FORCE -b"
1286 is_tag_a_branch $TAG
1287 if [ $? -eq 1 ]; then
1288 OPTIONS="$OPTIONS -B"
1291 if [ -n "$CVSROOT" ]; then
1292 OPTIONS="-d $CVSROOT $OPTIONS"
1296 for i in $TAG_FILES; do
1297 local fp=`nourl "$i"`
1298 if [ -f "$fp" ]; then
1299 tag_files="$tag_files $fp"
1300 elif [ -n "GREEDSRC" ]; then
1301 get_greed_sources $i
1303 Exit_error err_no_source_in_repo $i
1306 if [ "$tag_files" ]; then
1307 $CVS_COMMAND $OPTIONS $TAG $tag_files || exit
1311 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1315 # this function should exit early if package can't be built for this arch
1316 # this avoids unneccessary BR filling.
1319 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1321 if [ $ret -ne 0 ]; then
1328 update_shell_title "build_package"
1329 if [ -n "$DEBUG" ]; then
1336 if [ -n "$TRY_UPGRADE" ]; then
1337 update_shell_title "build_package: try_upgrade"
1338 if [ -n "$FLOAT_VERSION" ]; then
1339 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1341 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1344 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1346 if [ -n "$TNEWVER" ]; then
1347 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1348 echo "New version found, updating spec file to version " $TNEWVER
1349 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1350 cp -f $SPECFILE $SPECFILE.bak
1353 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1354 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1356 NODIST="yes" get_files $SOURCES $PATCHES
1359 unset TOLDVER TNEWVER TNOTIFY
1366 BUILD_SWITCH="-ba" ;;
1368 BUILD_SWITCH="-bb" ;;
1370 BUILD_SWITCH="-bs --nodeps" ;;
1372 BUILD_SWITCH="-bp --nodeps" ;;
1374 BUILD_SWITCH="-bc" ;;
1376 BUILD_SWITCH="-bi" ;;
1378 BUILD_SWITCH="-bl" ;;
1382 update_shell_title "build_package: $COMMAND"
1383 if [ -n "$LOGFILE" ]; then
1384 LOG=`eval echo $LOGFILE`
1385 if [ -d "$LOG" ]; then
1386 echo "Log file $LOG is a directory."
1387 echo "Parse error in the spec?"
1388 Exit_error err_build_fail
1390 if [ -n "$LASTLOG_FILE" ]; then
1391 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1393 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1395 (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1396 RETVAL=`cat $RES_FILE`
1398 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1399 if [ "$RETVAL" -eq "0" ]; then
1406 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1409 if [ "$RETVAL" -ne "0" ]; then
1410 if [ -n "$TRY_UPGRADE" ]; then
1411 echo "\n!!! Package with new version cannot be built automagically\n"
1412 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1413 mv -f $SPECFILE.bak $SPECFILE
1416 Exit_error err_build_fail
1422 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1425 install_required_packages() {
1430 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1433 /^%changelog/ { exit }
1435 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1436 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1437 gsub(/[ \t]+/, "_", bcond);
1439 }' $SPEC | LC_ALL=C sort -u
1443 # expand bconds from ~/.bcondrc
1444 # The file structure is like gentoo's package.use:
1447 # samba -mysql -pgsql
1448 # w32codec-installer license_agreement
1451 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1457 SN=${SPECFILE%%\.spec}
1459 local bcondrc=$HOME/.bcondrc
1460 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1462 local bcond_avail=$(find_spec_bcond $SPECFILE)
1464 while read pkg flags; do
1466 [[ "$pkg" == \#* ]] && continue
1468 # any package or current package?
1469 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1470 for flag in $flags; do
1471 local opt=${flag#[+-]}
1473 # use only flags which are in this package.
1474 if [[ $bcond_avail = *${opt}* ]]; then
1475 if [[ $flag = -* ]]; then
1476 if [[ $BCOND != *--with?${opt}* ]]; then
1477 BCOND="$BCOND --without $opt"
1480 if [[ $BCOND != *--without?${opt}* ]]; then
1481 BCOND="$BCOND --with $opt"
1488 update_shell_title "parse ~/.bcondrc: DONE!"
1491 set_bconds_values() {
1492 update_shell_title "set bcond values"
1494 AVAIL_BCONDS_WITHOUT=""
1495 AVAIL_BCONDS_WITH=""
1497 if egrep -q '^# *_with' ${SPECFILE}; then
1498 echo >&2 "ERROR: This spec has old style bconds."
1502 if ! grep -q '^%bcond' ${SPECFILE}; then
1506 local bcond_avail=$(find_spec_bcond $SPECFILE)
1507 process_bcondrc "$SPECFILE"
1509 update_shell_title "parse bconds"
1512 for opt in $bcond_avail; do
1515 bcond=${opt#without_}
1516 if [[ "$BCOND" = *--without?${bcond}* ]]; then
1517 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1519 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1524 if [[ "$BCOND" = *--with?${bcond}* ]]; then
1525 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1527 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1531 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1540 update_shell_title "run_sub_builder $package_name"
1542 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1543 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1544 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1545 # jakby nie bylo tego kawalka kodu.
1547 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1548 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1552 # kurwa. translate that ^^^^
1556 # Istnieje taki spec? ${package}.spec
1557 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1558 parent_spec_name=${package}.spec
1559 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1560 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1562 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1567 if [ "${parent_spec_name}" != "" ]; then
1568 spawn_sub_builder $parent_spec_name
1570 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1573 spawn_sub_builder() {
1575 update_shell_title "spawn_sub_builder $package_name"
1578 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1579 sub_builder_opts="${sub_builder_opts} -R"
1581 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1582 sub_builder_opts="${sub_builder_opts} -RB"
1583 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1584 sub_builder_opts="${sub_builder_opts} -FRB"
1586 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1587 sub_builder_opts="${sub_builder_opts} -Upi"
1591 ./builder ${sub_builder_opts} "$@"
1594 remove_build_requires() {
1595 if [ "$INSTALLED_PACKAGES" != "" ]; then
1596 case "$REMOVE_BUILD_REQUIRES" in
1598 run_poldek --noask -ve $INSTALLED_PACKAGES
1601 run_poldek --ask -ve $INSTALLED_PACKAGES
1604 echo You may want to manually remove following BuildRequires fetched:
1605 echo $INSTALLED_PACKAGES
1606 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1613 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1614 if [ "$BCOND" ]; then
1615 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1618 echo -ne "\nNo conditional flags passed"
1620 echo -ne "\n\nfrom available:\n"
1621 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1625 display_branches() {
1626 if [ "$NOCVSSPEC" != "yes" ]; then
1627 echo -ne "Available branches: "
1628 $CVS_COMMAND status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1632 # checks a given list of packages/files/provides agains current rpmdb.
1633 # outputs all dependencies which current rpmdb doesn't satisfy.
1634 # input can be either STDIN or parameters
1638 if [ $# -gt 0 ]; then
1644 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1647 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1649 # other deps (files)
1650 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1653 # checks if given package/files/provides exists in rpmdb.
1654 # input can be either stdin or parameters
1655 # returns packages which are present in the rpmdb
1659 if [ $# -gt 0 ]; then
1665 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1668 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1669 install_build_requires_rpmdeps() {
1670 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1671 # TODO: Conflicts list doesn't check versions
1672 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1673 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1675 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1676 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1677 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1680 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1681 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1682 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1683 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1685 if [ -n "$CNFL" ]; then
1686 update_shell_title "uninstall conflicting packages: $CNFL"
1687 echo "Trying to uninstall conflicting packages ($CNFL):"
1688 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1691 while [ "$DEPS" ]; do
1692 update_shell_title "install deps: $DEPS"
1693 echo "Trying to install dependencies ($DEPS):"
1694 local log=.${SPECFILE}_poldek.log
1695 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1696 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1699 if [ -n "$failed" ]; then
1700 for package in $failed; do
1701 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1710 fetch_build_requires()
1712 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1716 update_shell_title "fetch build requires"
1717 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1718 install_build_requires_rpmdeps
1722 # XXX is this ugliest code written in human history still needed?
1723 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1724 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1725 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1726 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1727 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1728 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)
1730 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)
1732 package=$(basename "$package_item"|sed -e "s/}$//g")
1733 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1736 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1737 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1738 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
1743 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1746 if `echo $COND_TST|grep -q 'without_'`; then
1747 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1748 if `echo $COND_TST|grep -q !`; then
1753 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1754 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1755 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1761 elif `echo $COND_TST|grep -q 'with_'`; then
1762 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1763 if `echo $COND_TST|grep -q !`; then
1768 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1769 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1770 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1776 RESULT="${COND_STATE}-${COND_ARGV}"
1778 "with-wout" | "wout-with" )
1781 "wout-wout" | "with-with" )
1785 echo "Action '$RESULT' was not defined for package '$package_item'"
1791 if [ "$GO" = "yes" ]; then
1792 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1793 echo "Testing if $package has subrequirements..."
1794 run_poldek -t -i $package --dumpn=".$package-req.txt"
1795 if [ -f ".$package-req.txt" ]; then
1796 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1798 if [ "$package_name" = "$package" ]; then
1799 echo -ne "Installing BuildRequired package:\t$package_name\n"
1800 update_shell_title "Installing BuildRequired package: ${package_name}"
1801 install_required_packages $package
1803 echo -ne "Installing (sub)Required package:\t$package_name\n"
1804 update_shell_title "Installing (sub)Required package: ${package_name}"
1805 install_required_packages $package_name
1809 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1810 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1813 echo "Attempting to run spawn sub - builder..."
1814 echo -ne "Package installation failed:\t$package_name\n"
1815 run_sub_builder $package_name
1816 if [ $? -eq 0 ]; then
1817 install_required_packages $package_name
1820 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1821 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1824 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1831 rm -f ".$package-req.txt"
1833 echo "Attempting to run spawn sub - builder..."
1834 echo -ne "Package installation failed:\t$package\n"
1835 run_sub_builder $package
1836 if [ $? -eq 0 ]; then
1837 install_required_packages $package
1840 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1841 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1844 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1850 echo "Package $package is already installed. BuildRequirement satisfied."
1854 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1855 echo >&2 "Unable to install following packages and their dependencies:"
1856 for pkg in "$NOT_INSTALLED_PACKAGES"
1860 remove_build_requires
1866 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1867 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1869 echo "Initialising rpm directories to $TOP_DIR from $CVSROOT"
1870 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1872 $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1876 echo "To checkout *all* .spec files (read-only):"
1877 echo "- run cvs co SPECS"
1879 echo "To checkout *all* packages:"
1880 echo "- run cvs up in $TOP_DIR/packages dir"
1883 echo "To commit with your developer account:"
1884 echo "- edit $TOP_DIR/packages/CVS/Root"
1887 get_greed_sources() {
1888 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1889 if [ -n "BE_VERBOSE" ]; then
1890 echo "Try greed download: $1 from: $CVSROOT"
1892 $CVS_COMMAND -d $CVSROOT get SOURCES/$1
1893 if [ $? != 0 ]; then
1894 Exit_error err_no_source_in_repo $1
1899 # remove entries from CVS/Entries
1900 cvs_entry_remove() {
1901 local cvsdir="$1"; shift
1902 if [ ! -d "$cvsdir" ]; then
1903 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1907 for file in "$@"; do
1908 rm -f $cvsdir/CVS/Entries.new || return 1
1909 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1910 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1918 DONT_PRINT_REVISION="yes"
1922 # remove from CVS/Entries
1923 cvs_entry_remove $PACKAGE_DIR $SPECFILE $SOURCES $PATCHES
1925 # remove spec and sources
1926 $RPMBUILD --clean --rmsource --rmspec --nodeps --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1929 #---------------------------------------------
1937 while [ $# -gt 0 ]; do
1940 COMMAND="update_md5"
1945 COMMAND="update_md5"
1955 DEBUG="yes"; shift ;;
1957 COMMAND="version"; shift ;;
1959 COMMAND="short-version"; shift ;;
1961 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1962 -b | -ba | --build )
1963 COMMAND="build"; shift ;;
1964 -bb | --build-binary )
1965 COMMAND="build-binary"; shift ;;
1967 COMMAND="build-build"; shift ;;
1969 COMMAND="build-install"; shift ;;
1971 COMMAND="build-list"; shift ;;
1972 -bp | --build-prep )
1973 COMMAND="build-prep"; shift ;;
1974 -bs | --build-source )
1975 COMMAND="build-source"; shift ;;
1977 COMMAND="branch"; shift; TAG="${1}"; shift;;
1979 CLEAN="--clean --rmspec --rmsource"; shift ;;
1981 CVS_FORCE="-F"; shift;;
1983 shift; CVSROOT="${1}"; shift ;;
1985 COMMAND="get"; shift ;;
1987 COMMAND="usage"; shift ;;
1989 PROTOCOL="http"; shift ;;
1991 shift; LOGFILE="${1}"; shift ;;
1993 shift; DEF_NICE_LEVEL=${1}; shift ;;
1994 -ske | --skip-existing-files)
1995 SKIP_EXISTING_FILES="yes"; shift ;;
1997 COMMAND="mr-proper"; shift ;;
1999 NOCVS="yes"; shift ;;
2000 -ncs | --no-cvs-specs )
2001 NOCVSSPEC="yes"; shift ;;
2002 -nd | --no-distfiles )
2003 NODIST="yes"; shift ;;
2004 -nm | --no-mirrors )
2005 NOMIRRORS="yes"; shift ;;
2007 NOURLS="yes"; shift ;;
2009 NOSRCS="yes"; shift ;;
2010 -ns0 | --no-source0 )
2011 NOSOURCE0="yes"; shift ;;
2021 -pm | --prefer-mirrors )
2028 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2030 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2032 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2035 --with | --without )
2036 case $GROUP_BCONDS in
2040 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2041 while ! `echo ${1}|grep -qE '(^-|spec)'`
2043 BCOND="$BCOND $COND $1"
2047 if [[ "$2" = *,* ]]; then
2048 for a in $(echo "$2" | tr , ' '); do
2049 BCOND="$BCOND $1 $a"
2052 BCOND="$BCOND $1 $2"
2058 shift; TARGET="${1}"; shift ;;
2060 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2062 QUIET="--quiet"; shift ;;
2064 CVSDATE="${2}"; shift 2 ;;
2073 -R | --fetch-build-requires)
2074 FETCH_BUILD_REQUIRES="yes"
2075 NOT_INSTALLED_PACKAGES=
2077 -RB | --remove-build-requires)
2078 REMOVE_BUILD_REQUIRES="nice"
2080 -FRB | --force-remove-build-requires)
2081 REMOVE_BUILD_REQUIRES="force"
2083 -sc | --sources-cvs)
2084 COMMAND="list-sources-cvs"
2086 -sd | --sources-distfiles)
2087 COMMAND="list-sources-distfiles"
2089 -sdp | --sources-distfiles-paths)
2090 COMMAND="list-sources-distfiles-paths"
2092 -sf | --sources-files)
2093 COMMAND="list-sources-files"
2095 -sp | --sources-paths)
2096 COMMAND="list-sources-local-paths"
2098 -su | --sources-urls)
2099 COMMAND="list-sources-urls"
2101 -Tvs | --tag-version-stable )
2106 -Ts | --tag-stable )
2111 -Tv | --tag-version )
2116 -Tp | --tag-prefix )
2128 -ir | --integer-release-only )
2129 INTEGER_RELEASE="yes"
2132 COMMAND="update_md5"
2137 -Upi | --update-poldek-indexes )
2138 UPDATE_POLDEK_INDEXES="yes"
2141 COMMAND="init_rpm_dir"
2143 --use-greed-sources )
2146 -u | --try-upgrade )
2147 TRY_UPGRADE="1"; shift ;;
2148 -un | --try-upgrade-with-float-version )
2149 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2151 BE_VERBOSE="1"; shift ;;
2156 if echo "${MACRO}" | grep -q '\W'; then
2157 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2161 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2166 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2170 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2173 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2174 COMMAND="show_bconds"
2178 COMMAND="show_bcond_args"
2183 RPMOPTS="${RPMOPTS} --nodeps"
2186 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2189 Exit_error err_invalid_cmdline "$1"
2193 # check if specname was passed as specname:cvstag
2194 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2195 CVSTAG="${SPECFILE##*:}"
2196 SPECFILE="${SPECFILE%%:*}"
2198 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2203 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2204 CVSTAG=$(awk -vSPECFILE=$(basename ${SPECFILE%.spec}.spec) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2205 if [ "$CVSTAG" ]; then
2206 echo >&2 "builder: Sticky tag $CVSTAG active. Use -r TAGNAME to override."
2208 elif [ "$CVSTAG" = "HEAD" ]; then
2209 # assume -r HEAD is same as -A
2213 if [ "$CVSTAG" ]; then
2214 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2215 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2218 if [ -n "$DEBUG" ]; then
2223 if [ -n "$TARGET" ]; then
2226 TARGET_SWITCH="--target $TARGET" ;;
2228 TARGET_SWITCH="--target=$TARGET" ;;
2232 if [ "$SCHEDTOOL" != "no" ]; then
2233 NICE_COMMAND="$SCHEDTOOL"
2235 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2238 update_shell_title "$COMMAND"
2242 if [ -n "$SPECFILE" ]; then
2243 get_spec > /dev/null
2251 if [ -n "$SPECFILE" ]; then
2252 get_spec > /dev/null
2258 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2260 if [ -n "$SPECFILE" ]; then
2261 # display SMP make flags if set
2262 smp_mflags=$(rpm -E %{?_smp_mflags})
2263 if [ "$smp_mflags" ]; then
2264 echo >&2 "builder: SMP make flags are set to $smp_mflags"
2272 if [ "$COMMAND" != "build-source" ]; then
2275 fetch_build_requires
2276 if [ "$INTEGER_RELEASE" = "yes" ]; then
2277 echo "Checking release $PACKAGE_RELEASE..."
2278 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2279 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2283 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2284 if [ -n "$TEST_TAG" ]; then
2285 local TAGVER=`make_tagver`
2286 echo "Searching for tag $TAGVER..."
2287 TAGREL=$($CVS_COMMAND status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2288 if [ -n "$TAGREL" ]; then
2289 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2292 # - do not allow to build from HEAD when XX-branch exists
2293 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2294 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2295 TAG_BRANCH="${TREE_PREFIX}-branch"
2296 TAG_STATUS=$($CVS_COMMAND status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2297 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2298 Exit_error err_branch_exists "$TAG_STATUS"
2304 if [ -n "$NOSOURCE0" ] ; then
2305 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2307 get_files $SOURCES $PATCHES
2310 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2311 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2313 remove_build_requires
2315 Exit_error err_no_spec_in_cmdl
2320 if [ -n "$SPECFILE" ]; then
2323 # don't fetch sources from remote locations
2325 for file in $SOURCES; do
2326 [ -n "`src_md5 $file`" ] && continue
2327 new_SOURCES="$new_SOURCES $file"
2329 SOURCES="$new_SOURCES"
2330 get_files $SOURCES $PATCHES
2332 branch_files $TAG $SOURCES $PATCHES $ICONS
2334 Exit_error err_no_spec_in_cmdl
2339 if [ -n "$SPECFILE" ]; then
2343 if [ -n "$NOSOURCE0" ] ; then
2344 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2346 get_files $SOURCES $PATCHES
2349 Exit_error err_no_spec_in_cmdl
2354 if [ -n "$SPECFILE" ]; then
2358 if [ -n "$NOSOURCE0" ] ; then
2359 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2363 Exit_error err_no_spec_in_cmdl
2370 if [ -n "$SPECFILE" ]; then
2374 # don't fetch sources from remote locations
2376 for file in $SOURCES; do
2377 [ -n "`src_md5 $file`" ] && continue
2378 new_SOURCES="$new_SOURCES $file"
2380 SOURCES="$new_SOURCES"
2381 get_files $SOURCES $PATCHES
2383 tag_files $SOURCES $PATCHES $ICONS
2385 Exit_error err_no_spec_in_cmdl
2391 "list-sources-files" )
2394 DONT_PRINT_REVISION="yes"
2397 for SAP in $SOURCES $PATCHES; do
2398 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2401 "list-sources-urls" )
2404 DONT_PRINT_REVISION="yes"
2407 SAPS="$SOURCES $PATCHES"
2408 for SAP in $SAPS ; do
2412 "list-sources-local-paths" )
2415 DONT_PRINT_REVISION="yes"
2418 for SAP in $SOURCES $PATCHES; do
2419 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2422 "list-sources-distfiles-paths" )
2425 DONT_PRINT_REVISION="yes"
2428 for SAP in $SOURCES $PATCHES; do
2429 if [ -n "$(src_md5 "$SAP")" ]; then
2430 distfiles_path "$SAP"
2434 "list-sources-distfiles" )
2437 DONT_PRINT_REVISION="yes"
2440 for SAP in $SOURCES $PATCHES; do
2441 if [ -n "$(src_md5 "$SAP")" ]; then
2442 distfiles_url "$SAP"
2446 "list-sources-cvs" )
2449 DONT_PRINT_REVISION="yes"
2452 for SAP in $SOURCES $PATCHES; do
2453 if [ -z "$(src_md5 "$SAP")" ]; then
2454 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2468 echo "$VERSIONSTRING"
2471 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2472 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2476 # vi:syntax=sh:ts=4:sw=4:noet