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)
25 # - does not respect NoSource: X, and tries to cvs up such files [ example: VirtualBox-bin.spec and its Source0 ]
27 # - ability to do ./builder -bb foo.spec foo2.spec foo3.spec
34 Build package utility from PLD Linux CVS repository
35 $VERSION (C) 1999-2009 Free Penguins".
37 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
39 # required rpm-build-macros
59 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
63 # use rpm 4.4.6+ digest format instead of comments if non-zero
66 # user agent when fetching files
67 USER_AGENT="PLD/Builder($VERSION)"
69 # It can be used i.e. in log file naming.
70 # See LOGFILE example.
71 DATE=`date +%Y-%m-%d_%H-%M-%S`
73 # Example: LOGFILE='../log.$PACKAGE_NAME'
74 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
75 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
76 # Example: LOGFILE='$PACKAGE_NAME.$DATE.log'
77 # Yes, you can use variable name! Note _single_ quotes!
92 # create symlinks for tools in PACKAGE_DIR, see get_spec()
103 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
105 CVS_COMMAND=${CVS_COMMAND:-cvs}
108 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
109 CVS_SERVER="cvs.pld-linux.org"
114 DISTFILES_SERVER="://distfiles.pld-linux.org"
115 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
120 FAIL_IF_NO_SOURCES="yes"
122 # let get_files skip over files which are present to get those damn files fetched
123 SKIP_EXISTING_FILES="no"
126 # should the specfile be restored if upgrade failed?
127 REVERT_BROKEN_UPGRADE="yes"
129 if rpm --specsrpm 2>/dev/null; then
130 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
131 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
133 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
134 if [ -x /usr/bin/rpm-getdeps ]; then
135 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
137 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
142 # Here we load saved user environment used to
143 # predefine options set above, or passed to builder
145 # This one reads global system environment settings:
146 if [ -f ~/etc/builderrc ]; then
149 # And this one cascades settings using user personal
151 # Example of ~/.builderrc:
153 #UPDATE_POLDEK_INDEXES="yes"
154 #FETCH_BUILD_REQUIRES="yes"
155 #REMOVE_BUILD_REQUIRES="force"
157 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
161 if [ -n "$HOME_ETC" ]; then
162 USER_CFG="$HOME_ETC/.builderrc"
163 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
165 USER_CFG=~/.builderrc
166 BUILDER_MACROS=~/.builder-rpmmacros
169 [ -f "$USER_CFG" ] && . "$USER_CFG"
171 if [ "$SCHEDTOOL" = "auto" ]; then
172 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
173 SCHEDTOOL="schedtool -B -e"
179 if [ -n "$USE_PROZILLA" ]; then
180 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
183 elif [ -n "$USE_AXEL" ]; then
184 GETURI="axel -a $AXEL_OPTS"
188 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
189 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
190 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
191 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
193 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
194 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
200 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
209 # are we using cvs-nserver ?
212 $CVS_COMMAND --version 2>&1 | grep -q 'CVS-nserver'
213 [ $? -eq 0 ] && CVS_NSERVER=1
215 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
216 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
219 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
220 if [ -n "$LOGFILE" ]; then
221 LOG=`eval echo $LOGFILE`
222 if [ -n "$LASTLOG_FILE" ]; then
223 echo "LASTLOG=$LOG" > $LASTLOG_FILE
225 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
228 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
229 return `cat ${RES_FILE}`
234 #---------------------------------------------
238 if [ -n "$DEBUG" ]; then set -xv; fi
240 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
241 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
242 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
243 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
244 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
245 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
246 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
247 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
248 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
249 <package>[.spec][:cvstag]
251 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
252 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
253 -n5, --no-md5 - ignore md5 comments in spec
254 -D, --debug - enable builder script debugging mode,
255 -debug - produce rpm debug package (same as --opts -debug)
256 -V, --version - output builder version string
257 --short-version - output builder short version
258 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
259 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
261 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
262 only package from <package>.spec,
263 -bp, --build-prep - execute the %prep phase of <package>.spec,
264 -bc - execute the %build phase of <package>.spec,
265 -bi - execute the %install phase of <package>.spec
266 -bl - execute the %files phase of <package>.spec
267 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
269 --short-circuit - short-circuit build
270 -B, --branch - add branch
271 -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
272 may be used with building process.
273 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
274 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
276 -cf, --cvs-force - use -F when tagging (useful when moving branches)
277 -d <cvsroot>, --cvsroot <cvsroot>
279 --define <macro> <value>
280 - define a macro <macro> with value <value>,
281 --alt_kernel <kernel>
282 - same as --define 'alt_kernel <kernel>'
283 --nodeps - rpm won't check any dependences
284 -g, --get - get <package>.spec and all related files from CVS repo
286 -h, --help - this message,
287 --http - use http instead of ftp,
288 -l <logfile>, --logtofile <logfile>
290 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
292 - don't check specs in CVS
293 -nd, --no-distfiles - don't download from distfiles
294 -nm, --no-mirrors - don't download from mirror, if source URL is given,
295 -nu, --no-urls - don't try to download from FTP/HTTP location,
296 -ns, --no-srcs - don't download Sources/Patches
297 -ns0, --no-source0 - don't download Source0
298 -nn, --no-net - don't download anything from the net
299 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
300 --no-init - don't initialize builder paths (SPECS and SOURCES)
302 --skip-existing-files - skip existing files in get_files
303 --opts <rpm opts> - additional options for rpm
304 -q, --quiet - be quiet,
305 --date yyyy-mm-dd - build package using resources from specified CVS date,
306 -r <cvstag>, --cvstag <cvstag>
307 - build package using resources from specified CVS tag,
308 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
309 -R, --fetch-build-requires
310 - fetch what is BuildRequired,
311 -RB, --remove-build-requires
312 - remove all you fetched with -R or --fetch-build-requires
313 remember, this option requires confirmation,
314 -FRB, --force-remove-build-requires
315 - remove all you fetched with -R or --fetch-build-requires
316 remember, this option works without confirmation,
317 -sd, --source-distfiles - list sources available from distfiles (intended for offline
318 operations; does not work when Icon field is present
319 but icon file is absent),
320 -sc, --source-cvs - list sources available from CVS
321 -sdp, --source-distfiles-paths - list sources available from distfiles -
322 paths relative to distfiles directory (intended for offline
323 operations; does not work when Icon field is present
324 but icon file is absent),
325 -sf, --source-files - list sources - bare filenames (intended for offline
326 operations; does not work when Icon field is present
327 but icon file is absent),
328 -sp, --source-paths - list sources - filenames with full local paths (intended for
329 offline operations; does not work when Icon field is present
330 but icon file is absent),
331 -su, --source-urls - list urls - urls to sources and patches
332 intended for copying urls with spec with lots of macros in urls
333 -T <cvstag> , --tag <cvstag>
334 - add cvs tag <cvstag> for files,
335 -Tvs, --tag-version-stable
336 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
338 - add cvs tag STABLE for files,
340 - add cvs tag NAME-VERSION-RELEASE for files,
341 -Tp, --tag-prefix <prefix>
342 - add <prefix> to NAME-VERSION-RELEASE tags,
343 -tt, --test-tag <prefix>
344 - fail if tag is already present,
345 -ir, --integer-release-only
346 - allow only integer and snapshot releases
347 -v, --verbose - be verbose,
348 -u, --try-upgrade - check version, and try to upgrade package
349 -un, --try-upgrade-with-float-version
350 - as above, but allow float version
352 - try download source from tag head if don't find it in
354 -U, --update - refetch sources, don't use distfiles, and update md5 comments
355 -Upi, --update-poldek-indexes
356 - refresh or make poldek package index files.
357 -np, --nopatch <patchnumber>
358 - don't apply <patchnumber>
359 --show-bconds - show available conditional builds, which can be used
360 - with --with and/or --without switches.
361 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
362 ./repackage.sh script. in other words, the output is
363 parseable by scripts.
364 --with/--without <feature>
365 - conditional build package depending on %_with_<feature>/
366 %_without_<feature> macro switch. You may now use
367 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
368 constructions. Set GROUP_BCONDS to yes to make use of it.
369 --target <platform>, --target=<platform>
370 - build for platform <platform>.
371 --init-rpm-dir - initialize ~/rpm directory structure
375 # change dependency to specname
377 # - perl(Package::Name) -> perl-Package-Name
381 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
385 update_shell_title() {
387 local len=${COLUMNS:-80}
388 local msg=$(echo "$*" | cut -c-$len)
390 if [ -n "$BE_VERBOSE" ]; then
391 echo >&2 "$(date +%s.%N) $*"
394 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
396 if [ -n "$PACKAGE_NAME" ]; then
397 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
402 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
403 msg=$(echo $msg | tr -d '\n\r')
406 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
409 echo >&2 -ne "\033]0;$msg\007"
415 # set TARGET from BuildArch: from SPECFILE
417 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
418 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
420 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
424 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
426 TARGET_SWITCH="--target=$TARGET" ;;
432 # runs rpm with minimal macroset
434 # we reset macros not to contain macros.build as all the %() macros are
435 # executed here, while none of them are actually needed.
436 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
437 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
439 # TODO: move these to /usr/lib/rpm/macros
440 cat > $BUILDER_MACROS <<'EOF'
441 %x8664 x86_64 amd64 ia32e
444 %requires_releq_kernel_up(s:n:) %{nil}
445 %requires_releq_kernel_smp(s:n:) %{nil}
446 %requires_releq_kernel(s:n:) %{nil}
447 %requires_releq() %{nil}
448 %pyrequires_eq() %{nil}
449 %requires_eq() %{nil}
450 %requires_eq_to() %{nil}
451 %releq_kernel_up(n:) ERROR
452 %releq_kernel_smp(n:) ERROR
453 %releq_kernel(n:) ERROR
457 %ruby_ver_requires_eq() %{nil}
458 %ruby_mod_ver_requires_eq() %{nil}
459 %__php_api_requires() %{nil}
460 %php_major_version ERROR
461 %php_api_version ERROR
462 %requires_xorg_xserver_extension %{nil}
463 %requires_xorg_xserver_xinput %{nil}
464 %requires_xorg_xserver_font %{nil}
465 %requires_xorg_xserver_videodrv %{nil}
467 %perl_vendorarch ERROR
468 %perl_vendorlib ERROR
469 # damn. need it here! - copied from /usr/lib/rpm/macros.build
470 %tmpdir %(echo "${TMPDIR:-/tmp}")
471 %patchset_source(f:b:) %(
472 base=%{-b*}%{!-b*:10000};
473 start=$(expr $base + %1);
474 end=$(expr $base + %{?2}%{!?2:%{1}});
475 # we need to call seq twice as it doesn't allow two formats
476 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
477 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
478 paste %{tmpdir}/__ps{1,2};
479 rm -f %{tmpdir}/__ps{1,2};
482 %add_etc_shells(p) %{p:<lua>}
483 %remove_etc_shells(p) %{p:<lua>}
484 %lua_add_etc_shells() %{nil}
485 %lua_remove_etc_shells() %{nil}
487 if [ "$NOINIT" = "yes" ] ; then
488 cat >> $BUILDER_MACROS <<'EOF'
493 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
497 if [ -n "$DEBUG" ]; then
502 if [ -x /usr/bin/rpm-specdump ]; then
503 update_shell_title "cache_rpm_dump using rpm-specdump command"
504 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
506 update_shell_title "cache_rpm_dump using rpmbuild command"
509 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
510 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
516 ARGS='--nodigest --nosignature --nobuild'
519 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
521 if [ $? -gt 0 ]; then
522 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
524 Exit_error err_build_fail
527 # make small dump cache
528 rpm_dump_cache=`echo "$rpm_dump" | awk '
529 $2 ~ /^SOURCEURL/ {print}
530 $2 ~ /^PATCHURL/ {print}
531 $2 ~ /^nosource/ {print}
532 $2 ~ /^PACKAGE_/ {print}
536 update_shell_title "cache_rpm_dump: OK!"
540 if [ -z "$rpm_dump_cache" ] ; then
541 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
543 echo "$rpm_dump_cache"
547 update_shell_title "get icons"
548 ICONS=$(awk '/^Icon:/ {print $2}' ${ASSUMED_NAME}/${SPECFILE})
549 if [ -z "$ICONS" ]; then
553 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
557 update_shell_title "parsing specfile"
558 if [ -n "$DEBUG" ]; then
563 # icons are needed for successful spec parse
569 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
570 FAIL_IF_NO_SOURCES="no"
573 if [ "$NOSRCS" != "yes" ]; then
574 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
575 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
576 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
579 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
580 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
581 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
583 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
584 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
587 if [ -n "$BE_VERBOSE" ]; then
588 echo "- Sources : `nourl $SOURCES`"
589 if [ -n "$PATCHES" ]; then
590 echo "- Patches : `nourl $PATCHES`"
592 echo "- Patches : *no patches needed*"
594 if [ -n "$ICONS" ]; then
595 echo "- Icon : `nourl $ICONS`"
597 echo "- Icon : *no package icon*"
599 echo "- Name : $PACKAGE_NAME"
600 echo "- Version : $PACKAGE_VERSION"
601 echo "- Release : $PACKAGE_RELEASE"
604 update_shell_title "parse_spec: OK!"
608 if [ -n "$DEBUG" ]; then
616 "err_no_spec_in_cmdl" )
617 remove_build_requires
618 echo >&2 "ERROR: spec file name not specified."
620 "err_invalid_cmdline" )
621 echo >&2 "ERROR: invalid command line arg ($2)."
623 "err_no_spec_in_repo" )
624 remove_build_requires
625 echo >&2 "Error: spec file not stored in CVS repo."
627 "err_no_source_in_repo" )
628 remove_build_requires
629 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
632 remove_build_requires
633 echo >&2 "Error: package build failed. (${2:-no more info})"
635 "err_no_package_data" )
636 remove_build_requires
637 echo >&2 "Error: couldn't get out package name/version/release from spec file."
640 remove_build_requires
641 echo >&2 "Tag ${2} already exists (spec release: ${3})."
644 remove_build_requires
645 echo >&2 "Release ${2} not integer and not a snapshot."
647 "err_branch_exists" )
648 remove_build_requires
649 echo >&2 "Tree branch already exists (${2})."
652 remove_build_requires
653 echo >&2 "Error: conditions reject building this spec (${2})."
656 echo >&2 "Unknown error."
661 if [ -n "$DEBUG" ]; then
666 if [ "$NOINIT" != "yes" ] ; then
667 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
669 local macros_ver=$(rpm -E %rpm_build_macros)
670 if [ -z "$macros_ver" ]; then
671 REPO_DIR=$TOP_DIR/packages
672 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
674 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
675 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
679 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
691 update_shell_title "get_spec"
693 if [ -n "$DEBUG" ]; then
699 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
701 SPECFILE=$(basename $SPECFILE)
703 if [ "$NOCVSSPEC" != "yes" ]; then
705 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
706 echo "Warning: No CVS access defined - using local .spec file"
710 if [ -d "$ASSUMED_NAME" ]; then
711 cvsup "$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
713 cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
715 # remove Entries.Static -- so 'cvs up' would update all files in a repo
716 rm "$ASSUMED_NAME/CVS/Entries.Static"
717 cvsignore_df .cvsignore
719 # create symlinks for tools
720 if [ "$SYMLINK_TOOLS" != "no" ]; then
721 for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh; do
722 [ -f $a ] || continue
723 ln -s ../$a $ASSUMED_NAME
730 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
731 Exit_error err_no_spec_in_repo
734 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
735 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
738 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
746 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
747 $CVS_COMMAND update mirrors >&2
751 local origin mirror name rest ol prefix
752 while read origin mirror name rest; do
753 # skip comments and empty lines
754 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
757 ol=$(echo -n "$origin" | wc -c)
758 prefix=$(echo -n "$url" | head -c $ol)
759 if [ "$prefix" = "$origin" ] ; then
760 suffix=$(echo "$url" | cut -b $((ol+1))-)
761 echo -n "$mirror$suffix"
768 # Warning: unpredictable results if same URL used twice
772 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
773 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
778 [ "$NO5" = "yes" ] && return
780 [ -z "$no" ] && return
784 if [ -f additional-md5sums ]; then
785 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
786 if [ -z "$spec_rev" ]; then
787 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
789 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
790 md5=$(grep -s -v '^#' additional-md5sums | \
791 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
792 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
793 grep -E '^[0-9a-f]{32}$')
796 if [ $(echo "$md5" | wc -l) != 1 ] ; then
797 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
799 echo "$md5" | tail -n 1
804 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
805 if [ -n "$source_md5" ]; then
808 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
809 if [ -n "$source_md5" ]; then
812 # we have empty SourceX-md5, but it is still possible
813 # that we have NoSourceX-md5 AND NoSource: X
814 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
815 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
823 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
827 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
830 distfiles_attic_url() {
831 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
837 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
841 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
842 [ -n "$size" -a "$size" -gt 0 ]
846 if [ "$CVSIGNORE_DF" != "yes" ]; then
849 cvsignore=${PACKAGE_DIR}/.cvsignore
851 # add only if not yet there
852 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
853 echo "$1" >> $cvsignore
858 update_shell_title "cvsup"
861 if [ "$1" = "-c" ]; then
865 if [ -n "$CVSROOT" ]; then
866 OPTIONS="-d $CVSROOT $OPTIONS"
869 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
870 OPTIONS="$OPTIONS -A"
872 if [ -n "$CVSDATE" ]; then
873 OPTIONS="$OPTIONS -D $CVSDATE"
875 if [ -n "$CVSTAG" ]; then
876 OPTIONS="$OPTIONS -r $CVSTAG"
881 local retries_counter=0
883 update_shell_title "cvsup: $*"
885 update_shell_title "cvsup: $# files"
887 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
888 retries_counter=$(( $retries_counter + 1 ))
889 output=$(LC_ALL=C $CVS_COMMAND $OPTIONS "$@" 2>&1)
891 [ -n "$output" ] && echo "$output"
892 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
893 echo "Trying again [$*]... ($retries_counter)"
894 update_shell_title "cvsup: retry #$retries_counter"
901 update_shell_title "cvsup: done!"
905 # returns true if "$1" is ftp, http or https protocol url
908 ftp://*|http://*|https://*)
916 if [ $# -eq 0 ]; then
920 update_shell_title "update md5"
921 if [ -n "$DEBUG" ]; then
928 # pass 1: check files to be fetched
932 local fp=$(nourl "$i")
933 local srcno=$(src_no "$i")
934 if [ -n "$ADD5" ]; then
935 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
936 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
937 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
939 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
941 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
942 need_files="$need_files $i"
946 # pass 1a: get needed files
947 if [ "$need_files" ]; then
948 get_files $need_files
951 # pass 2: proceed with md5 adding or updating
953 local fp=$(nourl "$i")
954 local srcno=$(src_no "$i")
955 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
956 if [ -z "$md5" ]; then
957 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
959 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
960 local tag="# Source$srcno-md5:\t"
961 if [[ "$md5" == *NoSource* ]]; then
962 tag="# NoSource$srcno-md5:\t"
963 elif [ -n "$USEDIGEST" ]; then
964 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
966 md5=$(md5sum "$fp" | cut -f1 -d' ')
967 echo "Updating Source$srcno ($md5: $fp)."
969 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
970 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
972 $PACKAGE_DIR/$SPECFILE
979 [ "$NO5" = "yes" ] && return
981 update_shell_title "check md5"
985 if ! good_md5 "$i"; then
986 echo -n "MD5 sum mismatch."
989 if ! good_size "$i"; then
990 echo -n "0 sized file."
994 if [ $bad -eq 1 ]; then
995 echo " Use -U to refetch sources,"
996 echo "or -5 to update md5 sums, if you're sure files are correct."
997 Exit_error err_no_source_in_repo $i
1003 update_shell_title "get_files"
1005 if [ -n "$DEBUG" ]; then
1010 if [ $# -gt 0 ]; then
1013 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
1014 echo "Warning: No CVS access defined for SOURCES"
1019 local get_files_cvs=""
1023 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1024 update_shell_title "$i"
1025 local fp=`nourl "$i"`
1026 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1031 local srcmd5=$(src_md5 "$i")
1033 # we know if source/patch is present in cvs/distfiles
1034 # - has md5 (in distfiles)
1035 # - in cvs... ideas?
1037 # CHECK: local file didn't exist or always cvs up (first) requested.
1038 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1039 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1040 echo "Warning: no URL given for $i"
1044 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1045 if good_md5 "$i" && good_size "$i"; then
1046 echo "$fp having proper md5sum already exists"
1050 # optionally prefer mirror over distfiles if there's mirror
1051 # TODO: build url list and then try each url from the list
1052 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1055 url=$(distfiles_url "$i")
1058 url_attic=$(distfiles_attic_url "$i")
1060 # is $url local file?
1061 if [[ "$url" = [./]* ]]; then
1062 update_shell_title "${GETLOCAL%% *}: $url"
1063 ${GETLOCAL} $url $target
1065 if [ -z "$NOMIRRORS" ]; then
1066 url=$(find_mirror "$url")
1070 # make shorter message for distfiles urls
1071 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1072 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1073 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1076 update_shell_title "${GETURI%% *}: $uri"
1077 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1078 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1079 update_shell_title "${GETURI2%% *}: $url"
1080 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1085 if [ ! -s "$target" ]; then
1087 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1088 update_shell_title "${GETLOCAL%% *}: $url_attic"
1089 ${GETLOCAL} $url_attic $target
1091 if [ -z "$NOMIRRORS" ]; then
1092 url_attic=$(find_mirror "$url_attic")
1094 update_shell_title "${GETURI%% *}: $url_attic"
1095 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1096 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1097 update_shell_title "${GETURI2%% *}: $url_attic"
1098 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1100 test -s "$target" || rm -f "$target"
1104 if [ -s "$target" ]; then
1105 cvsignore_df $target
1110 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1111 if [ $# -gt 1 ]; then
1112 get_files_cvs="$get_files_cvs $fp"
1113 update_shell_title "$fp (will cvs up later)"
1120 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1121 if [ -z "$NOMIRRORS" ]; then
1122 im=$(find_mirror "$i")
1126 update_shell_title "${GETURI%% *}: $im"
1127 ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
1128 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1129 update_shell_title "${GETURI2%% *}: $im"
1130 ${GETURI2} "$im" ${OUTFILEOPT} "$target"
1132 test -s "$target" || rm -f "$target"
1135 if [ "$cvsup" = 1 ]; then
1141 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1142 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1143 if [ -n "GREEDSRC" ]; then
1144 get_greed_sources $i
1146 Exit_error err_no_source_in_repo $i
1150 # we check md5 here just only to refetch immediately
1151 if good_md5 "$i" && good_size "$i"; then
1153 elif [ "$FROM_DISTFILES" = 1 ]; then
1154 # wrong md5 from distfiles: remove the file and try again
1156 echo "MD5 sum mismatch. Trying full fetch."
1159 update_shell_title "${GETURI%% *}: $url"
1160 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1161 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1162 update_shell_title "${GETURI2%% *}: $url"
1163 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1165 if [ ! -s "$target" ]; then
1167 update_shell_title "${GETURI%% *}: $url_attic"
1168 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1169 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1170 update_shell_title "${GETURI2%% *}: $url_attic"
1171 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1174 test -s "$target" || rm -f "$target"
1177 SHELL_TITLE_PREFIX=""
1179 if [ "$get_files_cvs" ]; then
1180 cvsup $get_files_cvs
1183 if [ "$CHMOD" = "yes" ]; then
1184 CHMOD_FILES=$(nourl "$@")
1185 if [ -n "$CHMOD_FILES" ]; then
1186 chmod $CHMOD_MODE $CHMOD_FILES
1193 if [ -n "$DEBUG" ]; then
1198 # Check whether first character of PACKAGE_NAME is legal for tag name
1199 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1203 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1204 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1206 # Remove #kernel.version_release from TAGVER because tagging sources
1207 # could occur with different kernel-headers than kernel-headers used at build time.
1208 # besides, %{_kernel_ver_str} is not expanded.
1210 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1211 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1217 # bool is_tag_a_branch(tag)
1219 # returns 1 if a tag is a branch set on SPECFILE
1221 if [ -n "$DEBUG" ]; then
1226 if [ $# -ne 1 ]; then
1233 $CVS_COMMAND status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1240 if [ -n "$DEBUG" ]; then
1245 echo "Version: $PACKAGE_VERSION"
1246 echo "Release: $PACKAGE_RELEASE"
1249 if [ "$TAG_VERSION" = "yes" ]; then
1250 TAGVER=`make_tagver`
1251 echo "CVS tag: $TAGVER"
1253 if [ -n "$TAG" ]; then
1254 echo "CVS tag: $TAG"
1257 local OPTIONS="tag $CVS_FORCE"
1258 if [ -n "$CVSROOT" ]; then
1259 OPTIONS="-d $CVSROOT $OPTIONS"
1262 # if a tagname we are about to set already exists
1263 # and happens to be a branch (common case with AC-branch)
1264 # pass -B (allows -F to disturb branch tag)
1266 if [ "$TAG_VERSION" = "yes" ]; then
1269 is_tag_a_branch $_tag
1270 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1271 OPTIONS="$OPTIONS -B"
1276 for i in $TAG_FILES; do
1277 # don't tag files stored on distfiles
1278 [ -n "`src_md5 $i`" ] && continue
1279 local fp=`nourl "$i"`
1280 if [ -f "$fp" ]; then
1281 tag_files="$tag_files $fp"
1282 elif [ -n "GREEDSRC" ]; then
1283 get_greed_sources $i
1285 Exit_error err_no_source_in_repo $i
1289 if [ "$tag_files" ]; then
1290 if [ "$TAG_VERSION" = "yes" ]; then
1291 update_shell_title "tag sources: $TAGVER"
1292 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1293 $CVS_COMMAND $OPTIONS $TAGVER $tag_files || exit
1295 if [ -n "$TAG" ]; then
1296 update_shell_title "tag sources: $TAG"
1298 while [ "$tag_files" ]; do
1299 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1300 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1301 $CVS_COMMAND $OPTIONS $TAG $chunk || exit
1302 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1308 if [ "$TAG_VERSION" = "yes" ]; then
1309 update_shell_title "tag spec: $TAGVER"
1310 $CVS_COMMAND $OPTIONS $TAGVER $SPECFILE || exit
1312 if [ -n "$TAG" ]; then
1313 update_shell_title "tag spec: $TAG"
1314 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1320 echo "CVS branch tag: $TAG"
1325 if [ -n "$DEBUG" ]; then
1330 local OPTIONS="tag $CVS_FORCE -b"
1333 is_tag_a_branch $TAG
1334 if [ $? -eq 1 ]; then
1335 OPTIONS="$OPTIONS -B"
1338 if [ -n "$CVSROOT" ]; then
1339 OPTIONS="-d $CVSROOT $OPTIONS"
1343 for i in $TAG_FILES; do
1344 local fp=`nourl "$i"`
1345 if [ -f "$fp" ]; then
1346 tag_files="$tag_files $fp"
1347 elif [ -n "GREEDSRC" ]; then
1348 get_greed_sources $i
1350 Exit_error err_no_source_in_repo $i
1353 if [ "$tag_files" ]; then
1354 $CVS_COMMAND $OPTIONS $TAG $tag_files || exit
1358 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1362 # this function should exit early if package can't be built for this arch
1363 # this avoids unneccessary BR filling.
1366 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1368 if [ $ret -ne 0 ]; then
1375 update_shell_title "build_package"
1376 if [ -n "$DEBUG" ]; then
1383 if [ -n "$TRY_UPGRADE" ]; then
1384 update_shell_title "build_package: try_upgrade"
1385 if [ -n "$FLOAT_VERSION" ]; then
1386 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1388 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1391 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1393 if [ -n "$TNEWVER" ]; then
1394 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1395 echo "New version found, updating spec file to version " $TNEWVER
1396 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1397 cp -f $SPECFILE $SPECFILE.bak
1400 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1401 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1403 NODIST="yes" get_files $SOURCES $PATCHES
1406 unset TOLDVER TNEWVER TNOTIFY
1413 BUILD_SWITCH="-ba" ;;
1415 BUILD_SWITCH="-bb" ;;
1417 BUILD_SWITCH="-bs --nodeps" ;;
1419 BUILD_SWITCH="-bp --nodeps" ;;
1421 BUILD_SWITCH="-bc" ;;
1423 BUILD_SWITCH="-bi" ;;
1425 BUILD_SWITCH="-bl" ;;
1429 update_shell_title "build_package: $COMMAND"
1430 if [ -n "$LOGFILE" ]; then
1431 LOG=`eval echo $LOGFILE`
1432 if [ -d "$LOG" ]; then
1433 echo "Log file $LOG is a directory."
1434 echo "Parse error in the spec?"
1435 Exit_error err_build_fail
1437 if [ -n "$LASTLOG_FILE" ]; then
1438 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1440 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1442 (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
1443 RETVAL=`cat $RES_FILE`
1445 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1446 if [ "$RETVAL" -eq "0" ]; then
1453 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1456 if [ "$RETVAL" -ne "0" ]; then
1457 if [ -n "$TRY_UPGRADE" ]; then
1458 echo "\n!!! Package with new version cannot be built automagically\n"
1459 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1460 mv -f $SPECFILE.bak $SPECFILE
1463 Exit_error err_build_fail
1469 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1472 install_required_packages() {
1477 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1480 /^%changelog/ { exit }
1482 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1483 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1484 gsub(/[ \t]+/, "_", bcond);
1486 }' $SPEC | LC_ALL=C sort -u
1490 # expand bconds from ~/.bcondrc
1491 # The file structure is like gentoo's package.use:
1494 # samba -mysql -pgsql
1495 # w32codec-installer license_agreement
1498 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1504 SN=${SPECFILE%%\.spec}
1506 local bcondrc=$HOME/.bcondrc
1507 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1509 local bcond_avail=$(find_spec_bcond $SPECFILE)
1511 while read pkg flags; do
1513 [[ "$pkg" == \#* ]] && continue
1515 # any package or current package?
1516 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1517 for flag in $flags; do
1518 local opt=${flag#[+-]}
1520 # use only flags which are in this package.
1521 if [[ $bcond_avail = *${opt}* ]]; then
1522 if [[ $flag = -* ]]; then
1523 if [[ $BCOND != *--with?${opt}* ]]; then
1524 BCOND="$BCOND --without $opt"
1527 if [[ $BCOND != *--without?${opt}* ]]; then
1528 BCOND="$BCOND --with $opt"
1535 update_shell_title "parse ~/.bcondrc: DONE!"
1538 set_bconds_values() {
1539 update_shell_title "set bcond values"
1541 AVAIL_BCONDS_WITHOUT=""
1542 AVAIL_BCONDS_WITH=""
1544 if egrep -q '^# *_with' ${SPECFILE}; then
1545 echo >&2 "ERROR: This spec has old style bconds."
1549 if ! grep -q '^%bcond' ${SPECFILE}; then
1553 local bcond_avail=$(find_spec_bcond $SPECFILE)
1554 process_bcondrc "$SPECFILE"
1556 update_shell_title "parse bconds"
1559 for opt in $bcond_avail; do
1562 bcond=${opt#without_}
1563 if [[ "$BCOND" = *--without?${bcond}* ]]; then
1564 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1566 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1571 if [[ "$BCOND" = *--with?${bcond}* ]]; then
1572 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1574 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1578 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1587 update_shell_title "run_sub_builder $package_name"
1589 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1590 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1591 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1592 # jakby nie bylo tego kawalka kodu.
1594 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1595 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1599 # kurwa. translate that ^^^^
1603 # Istnieje taki spec? ${package}.spec
1604 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1605 parent_spec_name=${package}.spec
1606 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1607 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1609 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1614 if [ "${parent_spec_name}" != "" ]; then
1615 spawn_sub_builder $parent_spec_name
1617 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1620 spawn_sub_builder() {
1622 update_shell_title "spawn_sub_builder $package_name"
1625 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1626 sub_builder_opts="${sub_builder_opts} -R"
1628 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1629 sub_builder_opts="${sub_builder_opts} -RB"
1630 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1631 sub_builder_opts="${sub_builder_opts} -FRB"
1633 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1634 sub_builder_opts="${sub_builder_opts} -Upi"
1638 ./builder ${sub_builder_opts} "$@"
1641 remove_build_requires() {
1642 if [ "$INSTALLED_PACKAGES" != "" ]; then
1643 case "$REMOVE_BUILD_REQUIRES" in
1645 run_poldek --noask -ve $INSTALLED_PACKAGES
1648 run_poldek --ask -ve $INSTALLED_PACKAGES
1651 echo You may want to manually remove following BuildRequires fetched:
1652 echo $INSTALLED_PACKAGES
1653 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1660 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1661 if [ "$BCOND" ]; then
1662 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1665 echo -ne "\nNo conditional flags passed"
1667 echo -ne "\n\nfrom available:\n"
1668 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1672 display_branches() {
1673 if [ "$NOCVSSPEC" != "yes" ]; then
1674 echo -ne "Available branches: "
1675 $CVS_COMMAND status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1679 # checks a given list of packages/files/provides agains current rpmdb.
1680 # outputs all dependencies which current rpmdb doesn't satisfy.
1681 # input can be either STDIN or parameters
1685 if [ $# -gt 0 ]; then
1691 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1694 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1696 # other deps (files)
1697 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1700 # checks if given package/files/provides exists in rpmdb.
1701 # input can be either stdin or parameters
1702 # returns packages which are present in the rpmdb
1706 if [ $# -gt 0 ]; then
1712 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1715 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1716 install_build_requires_rpmdeps() {
1717 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1718 # TODO: Conflicts list doesn't check versions
1719 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1720 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1722 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1723 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1724 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1727 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1728 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1729 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1730 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1732 if [ -n "$CNFL" ]; then
1733 update_shell_title "uninstall conflicting packages: $CNFL"
1734 echo "Trying to uninstall conflicting packages ($CNFL):"
1735 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1738 while [ "$DEPS" ]; do
1739 update_shell_title "install deps: $DEPS"
1740 echo "Trying to install dependencies ($DEPS):"
1741 local log=.${SPECFILE}_poldek.log
1742 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1743 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1746 if [ -n "$failed" ]; then
1747 for package in $failed; do
1748 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1757 fetch_build_requires()
1759 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1763 update_shell_title "fetch build requires"
1764 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1765 install_build_requires_rpmdeps
1769 # XXX is this ugliest code written in human history still needed?
1770 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1771 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1772 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1773 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1774 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1775 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)
1777 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)
1779 package=$(basename "$package_item"|sed -e "s/}$//g")
1780 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1783 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1784 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1785 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
1790 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1793 if `echo $COND_TST|grep -q 'without_'`; then
1794 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1795 if `echo $COND_TST|grep -q !`; then
1800 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1801 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1802 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1808 elif `echo $COND_TST|grep -q 'with_'`; then
1809 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1810 if `echo $COND_TST|grep -q !`; then
1815 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1816 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1817 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1823 RESULT="${COND_STATE}-${COND_ARGV}"
1825 "with-wout" | "wout-with" )
1828 "wout-wout" | "with-with" )
1832 echo "Action '$RESULT' was not defined for package '$package_item'"
1838 if [ "$GO" = "yes" ]; then
1839 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1840 echo "Testing if $package has subrequirements..."
1841 run_poldek -t -i $package --dumpn=".$package-req.txt"
1842 if [ -f ".$package-req.txt" ]; then
1843 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1845 if [ "$package_name" = "$package" ]; then
1846 echo -ne "Installing BuildRequired package:\t$package_name\n"
1847 update_shell_title "Installing BuildRequired package: ${package_name}"
1848 install_required_packages $package
1850 echo -ne "Installing (sub)Required package:\t$package_name\n"
1851 update_shell_title "Installing (sub)Required package: ${package_name}"
1852 install_required_packages $package_name
1856 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1857 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1860 echo "Attempting to run spawn sub - builder..."
1861 echo -ne "Package installation failed:\t$package_name\n"
1862 run_sub_builder $package_name
1863 if [ $? -eq 0 ]; then
1864 install_required_packages $package_name
1867 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1868 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1871 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1878 rm -f ".$package-req.txt"
1880 echo "Attempting to run spawn sub - builder..."
1881 echo -ne "Package installation failed:\t$package\n"
1882 run_sub_builder $package
1883 if [ $? -eq 0 ]; then
1884 install_required_packages $package
1887 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1888 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1891 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1897 echo "Package $package is already installed. BuildRequirement satisfied."
1901 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1902 echo >&2 "Unable to install following packages and their dependencies:"
1903 for pkg in "$NOT_INSTALLED_PACKAGES"
1907 remove_build_requires
1913 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1914 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1916 echo "Initializing rpm directories to $TOP_DIR from $CVSROOT"
1917 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1919 $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1923 echo "To checkout *all* .spec files (read-only):"
1924 echo "- run cvs co SPECS"
1926 echo "To checkout *all* packages:"
1927 echo "- run cvs up -dP in $TOP_DIR/packages dir"
1930 echo "To commit with your developer account:"
1931 echo "- edit $TOP_DIR/packages/CVS/Root"
1934 get_greed_sources() {
1935 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1936 if [ -n "BE_VERBOSE" ]; then
1937 echo "Try greed download: $1 from: $CVSROOT"
1939 $CVS_COMMAND -d $CVSROOT get SOURCES/$1
1940 if [ $? != 0 ]; then
1941 Exit_error err_no_source_in_repo $1
1946 # remove entries from CVS/Entries
1947 cvs_entry_remove() {
1948 local cvsdir="$1"; shift
1949 if [ ! -d "$cvsdir" ]; then
1950 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1954 for file in "$@"; do
1955 rm -f $cvsdir/CVS/Entries.new || return 1
1956 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1957 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1965 DONT_PRINT_REVISION="yes"
1969 # remove from CVS/Entries
1970 cvs_entry_remove $PACKAGE_DIR $SPECFILE $SOURCES $PATCHES
1972 # remove spec and sources
1973 $RPMBUILD --clean --rmsource --rmspec --nodeps --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1976 #---------------------------------------------
1984 while [ $# -gt 0 ]; do
1987 COMMAND="update_md5"
1992 COMMAND="update_md5"
2002 DEBUG="yes"; shift ;;
2004 COMMAND="version"; shift ;;
2006 COMMAND="short-version"; shift ;;
2008 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
2009 -b | -ba | --build )
2010 COMMAND="build"; shift ;;
2011 -bb | --build-binary )
2012 COMMAND="build-binary"; shift ;;
2014 COMMAND="build-build"; shift ;;
2016 COMMAND="build-install"; shift ;;
2018 COMMAND="build-list"; shift ;;
2019 -bp | --build-prep )
2020 COMMAND="build-prep"; shift ;;
2021 -bs | --build-source )
2022 COMMAND="build-source"; shift ;;
2024 COMMAND="branch"; shift; TAG="${1}"; shift;;
2026 CLEAN="--clean"; shift ;;
2028 CVS_FORCE="-F"; shift;;
2030 shift; CVSROOT="${1}"; shift ;;
2032 COMMAND="get"; shift ;;
2034 COMMAND="usage"; shift ;;
2036 PROTOCOL="http"; shift ;;
2038 shift; LOGFILE="${1}"; shift ;;
2040 shift; DEF_NICE_LEVEL=${1}; shift ;;
2041 -ske | --skip-existing-files)
2042 SKIP_EXISTING_FILES="yes"; shift ;;
2044 COMMAND="mr-proper"; shift ;;
2046 NOCVS="yes"; shift ;;
2047 -ncs | --no-cvs-specs )
2048 NOCVSSPEC="yes"; shift ;;
2049 -nd | --no-distfiles )
2050 NODIST="yes"; shift ;;
2051 -nm | --no-mirrors )
2052 NOMIRRORS="yes"; shift ;;
2054 NOURLS="yes"; shift ;;
2056 NOSRCS="yes"; shift ;;
2057 -ns0 | --no-source0 )
2058 NOSOURCE0="yes"; shift ;;
2068 -pm | --prefer-mirrors )
2075 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2077 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2079 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2082 --with | --without )
2083 case $GROUP_BCONDS in
2087 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2088 while ! `echo ${1}|grep -qE '(^-|spec)'`
2090 BCOND="$BCOND $COND $1"
2094 if [[ "$2" = *,* ]]; then
2095 for a in $(echo "$2" | tr , ' '); do
2096 BCOND="$BCOND $1 $a"
2099 BCOND="$BCOND $1 $2"
2105 shift; TARGET="${1}"; shift ;;
2107 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2109 QUIET="--quiet"; shift ;;
2111 CVSDATE="${2}"; shift 2 ;;
2120 -R | --fetch-build-requires)
2121 FETCH_BUILD_REQUIRES="yes"
2122 NOT_INSTALLED_PACKAGES=
2124 -RB | --remove-build-requires)
2125 REMOVE_BUILD_REQUIRES="nice"
2127 -FRB | --force-remove-build-requires)
2128 REMOVE_BUILD_REQUIRES="force"
2130 -sc | --sources-cvs)
2131 COMMAND="list-sources-cvs"
2133 -sd | --sources-distfiles)
2134 COMMAND="list-sources-distfiles"
2136 -sdp | --sources-distfiles-paths)
2137 COMMAND="list-sources-distfiles-paths"
2139 -sf | --sources-files)
2140 COMMAND="list-sources-files"
2142 -sp | --sources-paths)
2143 COMMAND="list-sources-local-paths"
2145 -su | --sources-urls)
2146 COMMAND="list-sources-urls"
2148 -Tvs | --tag-version-stable )
2153 -Ts | --tag-stable )
2158 -Tv | --tag-version )
2163 -Tp | --tag-prefix )
2175 -ir | --integer-release-only )
2176 INTEGER_RELEASE="yes"
2179 COMMAND="update_md5"
2184 -Upi | --update-poldek-indexes )
2185 UPDATE_POLDEK_INDEXES="yes"
2188 COMMAND="init_rpm_dir"
2190 --use-greed-sources )
2193 -u | --try-upgrade )
2194 TRY_UPGRADE="1"; shift ;;
2195 -un | --try-upgrade-with-float-version )
2196 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2198 BE_VERBOSE="1"; shift ;;
2203 if echo "${MACRO}" | grep -q '\W'; then
2204 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2208 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2213 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2217 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2220 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2221 COMMAND="show_bconds"
2225 COMMAND="show_bcond_args"
2230 RPMOPTS="${RPMOPTS} --nodeps"
2233 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2236 Exit_error err_invalid_cmdline "$1"
2240 # check if specname was passed as specname:cvstag
2241 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2242 CVSTAG="${SPECFILE##*:}"
2243 SPECFILE="${SPECFILE%%:*}"
2245 # always have SPECFILE ending with .spec extension
2246 SPECFILE=${SPECFILE%%.spec}.spec
2247 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2251 [ -d "$ASSUMED_NAME" ] && CVS_ENTRIES="$ASSUMED_NAME/CVS/Entries" || CVS_ENTRIES="CVS/Entries"
2252 if [ -f "$CVS_ENTRIES" ] && [ -z "$CVSTAG" ]; then
2253 CVSTAG=$(awk -vSPECFILE=$(basename $SPECFILE) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' ${CVS_ENTRIES})
2254 if [ "$CVSTAG" ]; then
2255 echo >&2 "builder: Sticky tag $CVSTAG active. Use -r TAGNAME to override."
2257 elif [ "$CVSTAG" = "HEAD" ]; then
2258 # assume -r HEAD is same as -A
2262 if [ "$CVSTAG" ]; then
2263 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2264 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2267 if [ -n "$DEBUG" ]; then
2272 if [ -n "$TARGET" ]; then
2275 TARGET_SWITCH="--target $TARGET" ;;
2277 TARGET_SWITCH="--target=$TARGET" ;;
2281 if [ "$SCHEDTOOL" != "no" ]; then
2282 NICE_COMMAND="$SCHEDTOOL"
2284 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2287 update_shell_title "$COMMAND"
2291 if [ -n "$SPECFILE" ]; then
2292 get_spec > /dev/null
2300 if [ -n "$SPECFILE" ]; then
2301 get_spec > /dev/null
2307 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2309 if [ -n "$SPECFILE" ]; then
2310 # display SMP make flags if set
2311 smp_mflags=$(rpm -E %{?_smp_mflags})
2312 if [ "$smp_mflags" ]; then
2313 echo "builder: SMP make flags are set to $smp_mflags"
2321 if [ "$COMMAND" != "build-source" ]; then
2324 fetch_build_requires
2325 if [ "$INTEGER_RELEASE" = "yes" ]; then
2326 echo "Checking release $PACKAGE_RELEASE..."
2327 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2328 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2332 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2333 if [ -n "$TEST_TAG" ]; then
2334 local TAGVER=`make_tagver`
2335 echo "Searching for tag $TAGVER..."
2336 TAGREL=$($CVS_COMMAND status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2337 if [ -n "$TAGREL" ]; then
2338 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2341 # - do not allow to build from HEAD when XX-branch exists
2342 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2343 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2344 TAG_BRANCH="${TREE_PREFIX}-branch"
2345 TAG_STATUS=$($CVS_COMMAND status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2346 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2347 Exit_error err_branch_exists "$TAG_STATUS"
2353 if [ -n "$NOSOURCE0" ] ; then
2354 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2356 get_files $SOURCES $PATCHES
2359 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2360 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2362 remove_build_requires
2364 Exit_error err_no_spec_in_cmdl
2369 if [ -n "$SPECFILE" ]; then
2372 # don't fetch sources from remote locations
2374 for file in $SOURCES; do
2375 [ -n "`src_md5 $file`" ] && continue
2376 new_SOURCES="$new_SOURCES $file"
2378 SOURCES="$new_SOURCES"
2379 get_files $SOURCES $PATCHES
2381 branch_files $TAG $SOURCES $PATCHES $ICONS
2383 Exit_error err_no_spec_in_cmdl
2388 if [ -n "$SPECFILE" ]; then
2392 if [ -n "$NOSOURCE0" ] ; then
2393 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2395 get_files $SOURCES $PATCHES
2398 Exit_error err_no_spec_in_cmdl
2403 if [ -n "$SPECFILE" ]; then
2407 if [ -n "$NOSOURCE0" ] ; then
2408 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2412 Exit_error err_no_spec_in_cmdl
2419 if [ -n "$SPECFILE" ]; then
2423 # don't fetch sources from remote locations
2425 for file in $SOURCES; do
2426 [ -n "`src_md5 $file`" ] && continue
2427 new_SOURCES="$new_SOURCES $file"
2429 SOURCES="$new_SOURCES"
2430 get_files $SOURCES $PATCHES
2432 tag_files $SOURCES $PATCHES $ICONS
2434 Exit_error err_no_spec_in_cmdl
2440 "list-sources-files" )
2443 DONT_PRINT_REVISION="yes"
2446 for SAP in $SOURCES $PATCHES; do
2447 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2450 "list-sources-urls" )
2453 DONT_PRINT_REVISION="yes"
2456 SAPS="$SOURCES $PATCHES"
2457 for SAP in $SAPS ; do
2461 "list-sources-local-paths" )
2464 DONT_PRINT_REVISION="yes"
2467 for SAP in $SOURCES $PATCHES; do
2468 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2471 "list-sources-distfiles-paths" )
2474 DONT_PRINT_REVISION="yes"
2477 for SAP in $SOURCES $PATCHES; do
2478 if [ -n "$(src_md5 "$SAP")" ]; then
2479 distfiles_path "$SAP"
2483 "list-sources-distfiles" )
2486 DONT_PRINT_REVISION="yes"
2489 for SAP in $SOURCES $PATCHES; do
2490 if [ -n "$(src_md5 "$SAP")" ]; then
2491 distfiles_url "$SAP"
2495 "list-sources-cvs" )
2498 DONT_PRINT_REVISION="yes"
2501 for SAP in $SOURCES $PATCHES; do
2502 if [ -z "$(src_md5 "$SAP")" ]; then
2503 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2517 echo "$VERSIONSTRING"
2520 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2521 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2525 # vi:syntax=sh:ts=4:sw=4:noet