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
28 # - funny bug, if source-md5 is set then builder will download from distfiles even if there is no url present:
29 # Source10: forwardfix.pl
30 # # Source10-md5: 8bf85f7368933a4e0cb4f875bac28733
37 Build package utility from PLD Linux CVS repository
38 $VERSION (C) 1999-2009 Free Penguins".
40 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
42 # required rpm-build-macros
62 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
66 # use rpm 4.4.6+ digest format instead of comments if non-zero
69 # user agent when fetching files
70 USER_AGENT="PLD/Builder($VERSION)"
72 # It can be used i.e. in log file naming.
73 # See LOGFILE example.
74 DATE=`date +%Y-%m-%d_%H-%M-%S`
76 # Example: LOGFILE='../log.$PACKAGE_NAME'
77 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
78 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
79 # Example: LOGFILE='$PACKAGE_NAME.$DATE.log'
80 # Yes, you can use variable name! Note _single_ quotes!
95 # create symlinks for tools in PACKAGE_DIR, see get_spec()
106 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
108 CVS_COMMAND=${CVS_COMMAND:-cvs}
111 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
112 CVS_SERVER="cvs.pld-linux.org"
117 DISTFILES_SERVER="://distfiles.pld-linux.org"
118 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
123 FAIL_IF_NO_SOURCES="yes"
125 # let get_files skip over files which are present to get those damn files fetched
126 SKIP_EXISTING_FILES="no"
129 # should the specfile be restored if upgrade failed?
130 REVERT_BROKEN_UPGRADE="yes"
132 if rpm --specsrpm 2>/dev/null; then
133 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
134 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
136 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
137 if [ -x /usr/bin/rpm-getdeps ]; then
138 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
140 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
145 # Here we load saved user environment used to
146 # predefine options set above, or passed to builder
148 # This one reads global system environment settings:
149 if [ -f ~/etc/builderrc ]; then
152 # And this one cascades settings using user personal
154 # Example of ~/.builderrc:
156 #UPDATE_POLDEK_INDEXES="yes"
157 #FETCH_BUILD_REQUIRES="yes"
158 #REMOVE_BUILD_REQUIRES="force"
160 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
164 if [ -n "$HOME_ETC" ]; then
165 USER_CFG="$HOME_ETC/.builderrc"
166 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
168 USER_CFG=~/.builderrc
169 BUILDER_MACROS=~/.builder-rpmmacros
172 [ -f "$USER_CFG" ] && . "$USER_CFG"
174 if [ "$SCHEDTOOL" = "auto" ]; then
175 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
176 SCHEDTOOL="schedtool -B -e"
182 if [ -n "$USE_PROZILLA" ]; then
183 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
186 elif [ -n "$USE_AXEL" ]; then
187 GETURI="axel -a $AXEL_OPTS"
191 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
192 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
193 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
194 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
196 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
197 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
203 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
212 # are we using cvs-nserver ?
215 $CVS_COMMAND --version 2>&1 | grep -q 'CVS-nserver'
216 [ $? -eq 0 ] && CVS_NSERVER=1
218 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
219 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
222 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
223 if [ -n "$LOGFILE" ]; then
224 LOG=`eval echo $LOGFILE`
225 if [ -n "$LASTLOG_FILE" ]; then
226 echo "LASTLOG=$LOG" > $LASTLOG_FILE
228 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
231 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
232 return `cat ${RES_FILE}`
237 #---------------------------------------------
241 if [ -n "$DEBUG" ]; then set -xv; fi
243 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
244 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
245 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
246 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
247 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
248 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
249 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
250 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
251 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
252 <package>[.spec][:cvstag]
254 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
255 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
256 -n5, --no-md5 - ignore md5 comments in spec
257 -D, --debug - enable builder script debugging mode,
258 -debug - produce rpm debug package (same as --opts -debug)
259 -V, --version - output builder version string
260 --short-version - output builder short version
261 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
262 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
264 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
265 only package from <package>.spec,
266 -bp, --build-prep - execute the %prep phase of <package>.spec,
267 -bc - execute the %build phase of <package>.spec,
268 -bi - execute the %install phase of <package>.spec
269 -bl - execute the %files phase of <package>.spec
270 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
272 --short-circuit - short-circuit build
273 -B, --branch - add branch
274 -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
275 may be used with building process.
276 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
277 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
279 -cf, --cvs-force - use -F when tagging (useful when moving branches)
280 -d <cvsroot>, --cvsroot <cvsroot>
282 --define <macro> <value>
283 - define a macro <macro> with value <value>,
284 --alt_kernel <kernel>
285 - same as --define 'alt_kernel <kernel>'
286 --nodeps - rpm won't check any dependences
287 -g, --get - get <package>.spec and all related files from CVS repo
289 -h, --help - this message,
290 --http - use http instead of ftp,
291 -l <logfile>, --logtofile <logfile>
293 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
295 - don't check specs in CVS
296 -nd, --no-distfiles - don't download from distfiles
297 -nm, --no-mirrors - don't download from mirror, if source URL is given,
298 -nu, --no-urls - don't try to download from FTP/HTTP location,
299 -ns, --no-srcs - don't download Sources/Patches
300 -ns0, --no-source0 - don't download Source0
301 -nn, --no-net - don't download anything from the net
302 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
303 --no-init - don't initialize builder paths (SPECS and SOURCES)
305 --skip-existing-files - skip existing files in get_files
306 --opts <rpm opts> - additional options for rpm
307 -q, --quiet - be quiet,
308 --date yyyy-mm-dd - build package using resources from specified CVS date,
309 -r <cvstag>, --cvstag <cvstag>
310 - build package using resources from specified CVS tag,
311 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
312 -R, --fetch-build-requires
313 - fetch what is BuildRequired,
314 -RB, --remove-build-requires
315 - remove all you fetched with -R or --fetch-build-requires
316 remember, this option requires confirmation,
317 -FRB, --force-remove-build-requires
318 - remove all you fetched with -R or --fetch-build-requires
319 remember, this option works without confirmation,
320 -sd, --source-distfiles - list sources available from distfiles (intended for offline
321 operations; does not work when Icon field is present
322 but icon file is absent),
323 -sc, --source-cvs - list sources available from CVS
324 -sdp, --source-distfiles-paths - list sources available from distfiles -
325 paths relative to distfiles directory (intended for offline
326 operations; does not work when Icon field is present
327 but icon file is absent),
328 -sf, --source-files - list sources - bare filenames (intended for offline
329 operations; does not work when Icon field is present
330 but icon file is absent),
331 -sp, --source-paths - list sources - filenames with full local paths (intended for
332 offline operations; does not work when Icon field is present
333 but icon file is absent),
334 -su, --source-urls - list urls - urls to sources and patches
335 intended for copying urls with spec with lots of macros in urls
336 -T <cvstag> , --tag <cvstag>
337 - add cvs tag <cvstag> for files,
338 -Tvs, --tag-version-stable
339 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
341 - add cvs tag STABLE for files,
343 - add cvs tag NAME-VERSION-RELEASE for files,
344 -Tp, --tag-prefix <prefix>
345 - add <prefix> to NAME-VERSION-RELEASE tags,
346 -tt, --test-tag <prefix>
347 - fail if tag is already present,
348 -ir, --integer-release-only
349 - allow only integer and snapshot releases
350 -v, --verbose - be verbose,
351 -u, --try-upgrade - check version, and try to upgrade package
352 -un, --try-upgrade-with-float-version
353 - as above, but allow float version
355 - try download source from tag head if don't find it in
357 -U, --update - refetch sources, don't use distfiles, and update md5 comments
358 -Upi, --update-poldek-indexes
359 - refresh or make poldek package index files.
360 -np, --nopatch <patchnumber>
361 - don't apply <patchnumber>
362 --show-bconds - show available conditional builds, which can be used
363 - with --with and/or --without switches.
364 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
365 ./repackage.sh script. in other words, the output is
366 parseable by scripts.
367 --show-avail-bconds - show available bconds
368 --with/--without <feature>
369 - conditional build package depending on %_with_<feature>/
370 %_without_<feature> macro switch. You may now use
371 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
372 constructions. Set GROUP_BCONDS to yes to make use of it.
373 --target <platform>, --target=<platform>
374 - build for platform <platform>.
375 --init-rpm-dir - initialize ~/rpm directory structure
379 # change dependency to specname
381 # - perl(Package::Name) -> perl-Package-Name
385 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
389 update_shell_title() {
391 local len=${COLUMNS:-80}
392 local msg=$(echo "$*" | cut -c-$len)
394 if [ -n "$BE_VERBOSE" ]; then
395 echo >&2 "$(date +%s.%N) $*"
398 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
400 if [ -n "$PACKAGE_NAME" ]; then
401 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
406 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
407 msg=$(echo $msg | tr -d '\n\r')
410 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
413 echo >&2 -ne "\033]0;$msg\007"
419 # set TARGET from BuildArch: from SPECFILE
421 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
422 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
424 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
428 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
430 TARGET_SWITCH="--target=$TARGET" ;;
436 # runs rpm with minimal macroset
438 # we reset macros not to contain macros.build as all the %() macros are
439 # executed here, while none of them are actually needed.
440 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
441 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
443 # TODO: move these to /usr/lib/rpm/macros
444 cat > $BUILDER_MACROS <<'EOF'
445 %x8664 x86_64 amd64 ia32e
448 %requires_releq_kernel_up(s:n:) %{nil}
449 %requires_releq_kernel_smp(s:n:) %{nil}
450 %requires_releq_kernel(s:n:) %{nil}
451 %requires_releq() %{nil}
452 %pyrequires_eq() %{nil}
453 %requires_eq() %{nil}
454 %requires_eq_to() %{nil}
455 %releq_kernel_up(n:) ERROR
456 %releq_kernel_smp(n:) ERROR
457 %releq_kernel(n:) ERROR
461 %ruby_ver_requires_eq() %{nil}
462 %ruby_mod_ver_requires_eq() %{nil}
463 %__php_api_requires() %{nil}
464 %php_major_version ERROR
465 %php_api_version ERROR
466 %requires_xorg_xserver_extension %{nil}
467 %requires_xorg_xserver_xinput %{nil}
468 %requires_xorg_xserver_font %{nil}
469 %requires_xorg_xserver_videodrv %{nil}
471 %perl_vendorarch ERROR
472 %perl_vendorlib ERROR
473 # damn. need it here! - copied from /usr/lib/rpm/macros.build
474 %tmpdir %(echo "${TMPDIR:-/tmp}")
475 %patchset_source(f:b:) %(
476 base=%{-b*}%{!-b*:10000};
477 start=$(expr $base + %1);
478 end=$(expr $base + %{?2}%{!?2:%{1}});
479 # we need to call seq twice as it doesn't allow two formats
480 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
481 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
482 paste %{tmpdir}/__ps{1,2};
483 rm -f %{tmpdir}/__ps{1,2};
486 %add_etc_shells(p) %{p:<lua>}
487 %remove_etc_shells(p) %{p:<lua>}
488 %lua_add_etc_shells() %{nil}
489 %lua_remove_etc_shells() %{nil}
491 if [ "$NOINIT" = "yes" ] ; then
492 cat >> $BUILDER_MACROS <<'EOF'
497 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
501 if [ -n "$DEBUG" ]; then
506 if [ -x /usr/bin/rpm-specdump ]; then
507 update_shell_title "cache_rpm_dump using rpm-specdump command"
508 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
510 update_shell_title "cache_rpm_dump using rpmbuild command"
513 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
514 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
520 ARGS='--nodigest --nosignature --nobuild'
523 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
525 if [ $? -gt 0 ]; then
526 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
528 Exit_error err_build_fail
531 # make small dump cache
532 rpm_dump_cache=`echo "$rpm_dump" | awk '
533 $2 ~ /^SOURCEURL/ {print}
534 $2 ~ /^PATCHURL/ {print}
535 $2 ~ /^nosource/ {print}
536 $2 ~ /^PACKAGE_/ {print}
540 update_shell_title "cache_rpm_dump: OK!"
544 if [ -z "$rpm_dump_cache" ] ; then
545 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
547 echo "$rpm_dump_cache"
551 update_shell_title "get icons"
552 ICONS=$(awk '/^Icon:/ {print $2}' ${ASSUMED_NAME}/${SPECFILE})
553 if [ -z "$ICONS" ]; then
557 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
561 update_shell_title "parsing specfile"
562 if [ -n "$DEBUG" ]; then
567 # icons are needed for successful spec parse
573 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
574 FAIL_IF_NO_SOURCES="no"
577 if [ "$NOSRCS" != "yes" ]; then
578 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
579 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
580 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
583 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
584 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
585 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
587 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
588 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
591 if [ -n "$BE_VERBOSE" ]; then
592 echo "- Sources : `nourl $SOURCES`"
593 if [ -n "$PATCHES" ]; then
594 echo "- Patches : `nourl $PATCHES`"
596 echo "- Patches : *no patches needed*"
598 if [ -n "$ICONS" ]; then
599 echo "- Icon : `nourl $ICONS`"
601 echo "- Icon : *no package icon*"
603 echo "- Name : $PACKAGE_NAME"
604 echo "- Version : $PACKAGE_VERSION"
605 echo "- Release : $PACKAGE_RELEASE"
608 update_shell_title "parse_spec: OK!"
612 if [ -n "$DEBUG" ]; then
620 "err_no_spec_in_cmdl" )
621 remove_build_requires
622 echo >&2 "ERROR: spec file name not specified."
624 "err_invalid_cmdline" )
625 echo >&2 "ERROR: invalid command line arg ($2)."
627 "err_no_spec_in_repo" )
628 remove_build_requires
629 echo >&2 "Error: spec file not stored in CVS repo."
631 "err_no_source_in_repo" )
632 remove_build_requires
633 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
636 remove_build_requires
637 echo >&2 "Error: package build failed. (${2:-no more info})"
639 "err_no_package_data" )
640 remove_build_requires
641 echo >&2 "Error: couldn't get out package name/version/release from spec file."
644 remove_build_requires
645 echo >&2 "Tag ${2} already exists (spec release: ${3})."
648 remove_build_requires
649 echo >&2 "Release ${2} not integer and not a snapshot."
651 "err_branch_exists" )
652 remove_build_requires
653 echo >&2 "Tree branch already exists (${2})."
656 remove_build_requires
657 echo >&2 "Error: conditions reject building this spec (${2})."
660 echo >&2 "Unknown error."
665 if [ -n "$DEBUG" ]; then
670 if [ "$NOINIT" != "yes" ] ; then
671 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
673 local macros_ver=$(rpm -E %?rpm_build_macros)
674 if [ -z "$macros_ver" ]; then
675 REPO_DIR=$TOP_DIR/packages
676 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
678 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
679 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
683 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
695 update_shell_title "get_spec"
697 if [ -n "$DEBUG" ]; then
703 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
705 SPECFILE=$(basename $SPECFILE)
707 if [ "$NOCVSSPEC" != "yes" ]; then
709 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
710 echo "Warning: No CVS access defined - using local .spec file"
714 if [ -d "$ASSUMED_NAME" ]; then
715 cvsup "$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
717 cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
719 # remove Entries.Static -- so 'cvs up' would update all files in a repo
720 rm "$ASSUMED_NAME/CVS/Entries.Static"
721 cvsignore_df .cvsignore
723 # create symlinks for tools
724 if [ "$SYMLINK_TOOLS" != "no" ]; then
725 for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh; do
726 [ -f $a ] || continue
727 ln -s ../$a $ASSUMED_NAME
734 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
735 Exit_error err_no_spec_in_repo
738 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
739 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
742 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
750 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
751 $CVS_COMMAND update mirrors >&2
755 local origin mirror name rest ol prefix
756 while read origin mirror name rest; do
757 # skip comments and empty lines
758 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
761 ol=$(echo -n "$origin" | wc -c)
762 prefix=$(echo -n "$url" | head -c $ol)
763 if [ "$prefix" = "$origin" ] ; then
764 suffix=$(echo "$url" | cut -b $((ol+1))-)
765 echo -n "$mirror$suffix"
772 # Warning: unpredictable results if same URL used twice
776 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
777 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
782 [ "$NO5" = "yes" ] && return
784 [ -z "$no" ] && return
788 if [ -f additional-md5sums ]; then
789 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
790 if [ -z "$spec_rev" ]; then
791 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
793 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
794 md5=$(grep -s -v '^#' additional-md5sums | \
795 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
796 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
797 grep -E '^[0-9a-f]{32}$')
800 if [ $(echo "$md5" | wc -l) != 1 ] ; then
801 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
803 echo "$md5" | tail -n 1
808 source_md5=`grep -i "^#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
809 if [ -n "$source_md5" ]; then
812 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
813 if [ -n "$source_md5" ]; then
816 # we have empty SourceX-md5, but it is still possible
817 # that we have NoSourceX-md5 AND NoSource: X
818 nosource_md5=`grep -i "^#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
819 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
827 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
831 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
834 distfiles_attic_url() {
835 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
841 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
845 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
846 [ -n "$size" -a "$size" -gt 0 ]
850 if [ "$CVSIGNORE_DF" != "yes" ]; then
853 cvsignore=${PACKAGE_DIR}/.cvsignore
855 # add only if not yet there
856 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
857 echo "$1" >> $cvsignore
862 update_shell_title "cvsup"
865 if [ "$1" = "-c" ]; then
869 if [ -n "$CVSROOT" ]; then
870 OPTIONS="-d $CVSROOT $OPTIONS"
873 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
874 OPTIONS="$OPTIONS -A"
876 if [ -n "$CVSDATE" ]; then
877 OPTIONS="$OPTIONS -D $CVSDATE"
879 if [ -n "$CVSTAG" ]; then
880 OPTIONS="$OPTIONS -r $CVSTAG"
885 local retries_counter=0
887 update_shell_title "cvsup: $*"
889 update_shell_title "cvsup: $# files"
891 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
892 retries_counter=$(( $retries_counter + 1 ))
893 output=$(LC_ALL=C $CVS_COMMAND $OPTIONS "$@" 2>&1)
895 [ -n "$output" ] && echo "$output"
896 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
897 echo "Trying again [$*]... ($retries_counter)"
898 update_shell_title "cvsup: retry #$retries_counter"
905 update_shell_title "cvsup: done!"
909 # returns true if "$1" is ftp, http or https protocol url
912 ftp://*|http://*|https://*)
920 if [ $# -eq 0 ]; then
924 update_shell_title "update md5"
925 if [ -n "$DEBUG" ]; then
932 # pass 1: check files to be fetched
936 local fp=$(nourl "$i")
937 local srcno=$(src_no "$i")
938 if [ -n "$ADD5" ]; then
939 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
940 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
941 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
943 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
945 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
946 need_files="$need_files $i"
950 # pass 1a: get needed files
951 if [ "$need_files" ]; then
952 get_files $need_files
955 # pass 2: proceed with md5 adding or updating
957 local fp=$(nourl "$i")
958 local srcno=$(src_no "$i")
959 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
960 if [ -z "$md5" ]; then
961 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
963 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
964 local tag="# Source$srcno-md5:\t"
965 if [[ "$md5" == *NoSource* ]]; then
966 tag="# NoSource$srcno-md5:\t"
967 elif [ -n "$USEDIGEST" ]; then
968 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
970 md5=$(md5sum "$fp" | cut -f1 -d' ')
971 echo "Updating Source$srcno ($md5: $fp)."
973 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
974 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
976 $PACKAGE_DIR/$SPECFILE
983 [ "$NO5" = "yes" ] && return
985 update_shell_title "check md5"
989 if ! good_md5 "$i"; then
990 echo -n "MD5 sum mismatch."
993 if ! good_size "$i"; then
994 echo -n "0 sized file."
998 if [ $bad -eq 1 ]; then
999 echo " Use -U to refetch sources,"
1000 echo "or -5 to update md5 sums, if you're sure files are correct."
1001 Exit_error err_no_source_in_repo $i
1007 update_shell_title "get_files"
1009 if [ -n "$DEBUG" ]; then
1014 if [ $# -gt 0 ]; then
1017 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
1018 echo "Warning: No CVS access defined for SOURCES"
1023 local get_files_cvs=""
1027 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1028 update_shell_title "$i"
1029 local fp=`nourl "$i"`
1030 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1035 local srcmd5=$(src_md5 "$i")
1037 # we know if source/patch is present in cvs/distfiles
1038 # - has md5 (in distfiles)
1039 # - in cvs... ideas?
1041 # CHECK: local file didn't exist or always cvs up (first) requested.
1042 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1043 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1044 echo "Warning: no URL given for $i"
1048 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1049 if good_md5 "$i" && good_size "$i"; then
1050 echo "$fp having proper md5sum already exists"
1054 # optionally prefer mirror over distfiles if there's mirror
1055 # TODO: build url list and then try each url from the list
1056 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1059 url=$(distfiles_url "$i")
1062 url_attic=$(distfiles_attic_url "$i")
1064 # is $url local file?
1065 if [[ "$url" = [./]* ]]; then
1066 update_shell_title "${GETLOCAL%% *}: $url"
1067 ${GETLOCAL} $url $target
1069 if [ -z "$NOMIRRORS" ]; then
1070 url=$(find_mirror "$url")
1074 # make shorter message for distfiles urls
1075 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1076 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1077 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1080 update_shell_title "${GETURI%% *}: $uri"
1081 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1082 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1083 update_shell_title "${GETURI2%% *}: $url"
1084 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1089 if [ ! -s "$target" ]; then
1091 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1092 update_shell_title "${GETLOCAL%% *}: $url_attic"
1093 ${GETLOCAL} $url_attic $target
1095 if [ -z "$NOMIRRORS" ]; then
1096 url_attic=$(find_mirror "$url_attic")
1098 update_shell_title "${GETURI%% *}: $url_attic"
1099 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1100 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1101 update_shell_title "${GETURI2%% *}: $url_attic"
1102 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1104 test -s "$target" || rm -f "$target"
1108 if [ -s "$target" ]; then
1109 cvsignore_df $target
1114 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1115 if [ $# -gt 1 ]; then
1116 get_files_cvs="$get_files_cvs $fp"
1117 update_shell_title "$fp (will cvs up later)"
1124 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1125 if [ -z "$NOMIRRORS" ]; then
1126 im=$(find_mirror "$i")
1130 update_shell_title "${GETURI%% *}: $im"
1131 ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
1132 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1133 update_shell_title "${GETURI2%% *}: $im"
1134 ${GETURI2} "$im" ${OUTFILEOPT} "$target"
1136 test -s "$target" || rm -f "$target"
1139 if [ "$cvsup" = 1 ]; then
1145 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1146 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1147 if [ -n "GREEDSRC" ]; then
1148 get_greed_sources $i
1150 Exit_error err_no_source_in_repo $i
1154 # we check md5 here just only to refetch immediately
1155 if good_md5 "$i" && good_size "$i"; then
1157 elif [ "$FROM_DISTFILES" = 1 ]; then
1158 # wrong md5 from distfiles: remove the file and try again
1160 echo "MD5 sum mismatch. Trying full fetch."
1163 update_shell_title "${GETURI%% *}: $url"
1164 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1165 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1166 update_shell_title "${GETURI2%% *}: $url"
1167 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1169 if [ ! -s "$target" ]; then
1171 update_shell_title "${GETURI%% *}: $url_attic"
1172 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1173 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1174 update_shell_title "${GETURI2%% *}: $url_attic"
1175 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1178 test -s "$target" || rm -f "$target"
1181 SHELL_TITLE_PREFIX=""
1183 if [ "$get_files_cvs" ]; then
1184 cvsup $get_files_cvs
1187 if [ "$CHMOD" = "yes" ]; then
1188 CHMOD_FILES=$(nourl "$@")
1189 if [ -n "$CHMOD_FILES" ]; then
1190 chmod $CHMOD_MODE $CHMOD_FILES
1197 if [ -n "$DEBUG" ]; then
1202 # Check whether first character of PACKAGE_NAME is legal for tag name
1203 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1207 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1208 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1210 # Remove #kernel.version_release from TAGVER because tagging sources
1211 # could occur with different kernel-headers than kernel-headers used at build time.
1212 # besides, %{_kernel_ver_str} is not expanded.
1214 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1215 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1221 # bool is_tag_a_branch(tag)
1223 # returns 1 if a tag is a branch set on SPECFILE
1225 if [ -n "$DEBUG" ]; then
1230 if [ $# -ne 1 ]; then
1237 $CVS_COMMAND status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1244 if [ -n "$DEBUG" ]; then
1249 echo "Version: $PACKAGE_VERSION"
1250 echo "Release: $PACKAGE_RELEASE"
1253 if [ "$TAG_VERSION" = "yes" ]; then
1254 TAGVER=`make_tagver`
1255 echo "CVS tag: $TAGVER"
1257 if [ -n "$TAG" ]; then
1258 echo "CVS tag: $TAG"
1261 local OPTIONS="tag $CVS_FORCE"
1262 if [ -n "$CVSROOT" ]; then
1263 OPTIONS="-d $CVSROOT $OPTIONS"
1266 # if a tagname we are about to set already exists
1267 # and happens to be a branch (common case with AC-branch)
1268 # pass -B (allows -F to disturb branch tag)
1270 if [ "$TAG_VERSION" = "yes" ]; then
1273 is_tag_a_branch $_tag
1274 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1275 OPTIONS="$OPTIONS -B"
1280 for i in $TAG_FILES; do
1281 # don't tag files stored on distfiles
1282 [ -n "`src_md5 $i`" ] && continue
1283 local fp=`nourl "$i"`
1284 if [ -f "$fp" ]; then
1285 tag_files="$tag_files $fp"
1286 elif [ -n "GREEDSRC" ]; then
1287 get_greed_sources $i
1289 Exit_error err_no_source_in_repo $i
1293 if [ "$tag_files" ]; then
1294 if [ "$TAG_VERSION" = "yes" ]; then
1295 update_shell_title "tag sources: $TAGVER"
1296 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1297 $CVS_COMMAND $OPTIONS $TAGVER $tag_files || exit
1299 if [ -n "$TAG" ]; then
1300 update_shell_title "tag sources: $TAG"
1302 while [ "$tag_files" ]; do
1303 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1304 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1305 $CVS_COMMAND $OPTIONS $TAG $chunk || exit
1306 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1312 if [ "$TAG_VERSION" = "yes" ]; then
1313 update_shell_title "tag spec: $TAGVER"
1314 $CVS_COMMAND $OPTIONS $TAGVER $SPECFILE || exit
1316 if [ -n "$TAG" ]; then
1317 update_shell_title "tag spec: $TAG"
1318 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1324 echo "CVS branch tag: $TAG"
1329 if [ -n "$DEBUG" ]; then
1334 local OPTIONS="tag $CVS_FORCE -b"
1337 is_tag_a_branch $TAG
1338 if [ $? -eq 1 ]; then
1339 OPTIONS="$OPTIONS -B"
1342 if [ -n "$CVSROOT" ]; then
1343 OPTIONS="-d $CVSROOT $OPTIONS"
1347 for i in $TAG_FILES; do
1348 local fp=`nourl "$i"`
1349 if [ -f "$fp" ]; then
1350 tag_files="$tag_files $fp"
1351 elif [ -n "GREEDSRC" ]; then
1352 get_greed_sources $i
1354 Exit_error err_no_source_in_repo $i
1357 if [ "$tag_files" ]; then
1358 $CVS_COMMAND $OPTIONS $TAG $tag_files || exit
1362 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1366 # this function should exit early if package can't be built for this arch
1367 # this avoids unneccessary BR filling.
1370 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1372 if [ $ret -ne 0 ]; then
1379 update_shell_title "build_package"
1380 if [ -n "$DEBUG" ]; then
1387 if [ -n "$TRY_UPGRADE" ]; then
1388 update_shell_title "build_package: try_upgrade"
1389 if [ -n "$FLOAT_VERSION" ]; then
1390 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1392 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1395 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1397 if [ -n "$TNEWVER" ]; then
1398 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1399 echo "New version found, updating spec file to version " $TNEWVER
1400 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1401 cp -f $SPECFILE $SPECFILE.bak
1404 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1405 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1407 NODIST="yes" get_files $SOURCES $PATCHES
1410 unset TOLDVER TNEWVER TNOTIFY
1417 BUILD_SWITCH="-ba" ;;
1419 BUILD_SWITCH="-bb" ;;
1421 BUILD_SWITCH="-bs --nodeps" ;;
1423 BUILD_SWITCH="-bp --nodeps" ;;
1425 BUILD_SWITCH="-bc" ;;
1427 BUILD_SWITCH="-bi" ;;
1429 BUILD_SWITCH="-bl" ;;
1433 update_shell_title "build_package: $COMMAND"
1434 if [ -n "$LOGFILE" ]; then
1435 LOG=`eval echo $LOGFILE`
1436 if [ -d "$LOG" ]; then
1437 echo "Log file $LOG is a directory."
1438 echo "Parse error in the spec?"
1439 Exit_error err_build_fail
1441 if [ -n "$LASTLOG_FILE" ]; then
1442 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1444 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1446 (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
1447 RETVAL=`cat $RES_FILE`
1449 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1450 if [ "$RETVAL" -eq "0" ]; then
1457 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1460 if [ "$RETVAL" -ne "0" ]; then
1461 if [ -n "$TRY_UPGRADE" ]; then
1462 echo "\n!!! Package with new version cannot be built automagically\n"
1463 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1464 mv -f $SPECFILE.bak $SPECFILE
1467 Exit_error err_build_fail
1473 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1476 install_required_packages() {
1481 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1484 /^%changelog/ { exit }
1486 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1487 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1488 gsub(/[ \t]+/, "_", bcond);
1490 }' $SPEC | LC_ALL=C sort -u
1494 # expand bconds from ~/.bcondrc
1495 # The file structure is like gentoo's package.use:
1498 # samba -mysql -pgsql
1499 # w32codec-installer license_agreement
1502 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1508 SN=${SPECFILE%%\.spec}
1510 local bcondrc=$HOME/.bcondrc
1511 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1513 local bcond_avail=$(find_spec_bcond $SPECFILE)
1515 while read pkg flags; do
1517 [[ "$pkg" == \#* ]] && continue
1519 # any package or current package?
1520 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1521 for flag in $flags; do
1522 local opt=${flag#[+-]}
1524 # use only flags which are in this package.
1525 if [[ $bcond_avail = *${opt}* ]]; then
1526 if [[ $flag = -* ]]; then
1527 if [[ $BCOND != *--with?${opt}* ]]; then
1528 BCOND="$BCOND --without $opt"
1531 if [[ $BCOND != *--without?${opt}* ]]; then
1532 BCOND="$BCOND --with $opt"
1539 update_shell_title "parse ~/.bcondrc: DONE!"
1542 set_bconds_values() {
1543 update_shell_title "set bcond values"
1545 AVAIL_BCONDS_WITHOUT=""
1546 AVAIL_BCONDS_WITH=""
1548 if egrep -q '^# *_with' ${SPECFILE}; then
1549 echo >&2 "ERROR: This spec has old style bconds."
1553 if ! grep -q '^%bcond' ${SPECFILE}; then
1557 local bcond_avail=$(find_spec_bcond $SPECFILE)
1558 process_bcondrc "$SPECFILE"
1560 update_shell_title "parse bconds"
1563 for opt in $bcond_avail; do
1566 bcond=${opt#without_}
1567 if [[ "$BCOND" = *--without?${bcond}* ]]; then
1568 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1570 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1575 if [[ "$BCOND" = *--with?${bcond}* ]]; then
1576 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1578 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1582 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1591 update_shell_title "run_sub_builder $package_name"
1593 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1594 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1595 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1596 # jakby nie bylo tego kawalka kodu.
1598 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1599 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1603 # kurwa. translate that ^^^^
1607 # Istnieje taki spec? ${package}.spec
1608 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1609 parent_spec_name=${package}.spec
1610 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1611 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1613 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1618 if [ "${parent_spec_name}" != "" ]; then
1619 spawn_sub_builder $parent_spec_name
1621 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1624 spawn_sub_builder() {
1626 update_shell_title "spawn_sub_builder $package_name"
1629 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1630 sub_builder_opts="${sub_builder_opts} -R"
1632 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1633 sub_builder_opts="${sub_builder_opts} -RB"
1634 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1635 sub_builder_opts="${sub_builder_opts} -FRB"
1637 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1638 sub_builder_opts="${sub_builder_opts} -Upi"
1642 ./builder ${sub_builder_opts} "$@"
1645 remove_build_requires() {
1646 if [ "$INSTALLED_PACKAGES" != "" ]; then
1647 case "$REMOVE_BUILD_REQUIRES" in
1649 run_poldek --noask -ve $INSTALLED_PACKAGES
1652 run_poldek --ask -ve $INSTALLED_PACKAGES
1655 echo You may want to manually remove following BuildRequires fetched:
1656 echo $INSTALLED_PACKAGES
1657 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1664 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1665 if [ "$BCOND" ]; then
1666 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1669 echo -ne "\nNo conditional flags passed"
1671 echo -ne "\n\nfrom available:\n"
1672 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1676 display_branches() {
1677 if [ "$NOCVSSPEC" != "yes" ]; then
1678 echo -ne "Available branches: "
1679 $CVS_COMMAND status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1683 # checks a given list of packages/files/provides agains current rpmdb.
1684 # outputs all dependencies which current rpmdb doesn't satisfy.
1685 # input can be either STDIN or parameters
1689 if [ $# -gt 0 ]; then
1695 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1698 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1700 # other deps (files)
1701 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1704 # checks if given package/files/provides exists in rpmdb.
1705 # input can be either stdin or parameters
1706 # returns packages which are present in the rpmdb
1710 if [ $# -gt 0 ]; then
1716 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1719 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1720 install_build_requires_rpmdeps() {
1721 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1722 # TODO: Conflicts list doesn't check versions
1723 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1724 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1726 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1727 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1728 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1731 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1732 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1733 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1734 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1736 if [ -n "$CNFL" ]; then
1737 update_shell_title "uninstall conflicting packages: $CNFL"
1738 echo "Trying to uninstall conflicting packages ($CNFL):"
1739 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1742 while [ "$DEPS" ]; do
1743 update_shell_title "install deps: $DEPS"
1744 echo "Trying to install dependencies ($DEPS):"
1745 local log=.${SPECFILE}_poldek.log
1746 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1747 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1750 if [ -n "$failed" ]; then
1751 for package in $failed; do
1752 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1761 fetch_build_requires()
1763 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1767 update_shell_title "fetch build requires"
1768 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1769 install_build_requires_rpmdeps
1773 # XXX is this ugliest code written in human history still needed?
1774 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1775 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1776 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1777 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1778 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1779 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)
1781 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)
1783 package=$(basename "$package_item"|sed -e "s/}$//g")
1784 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1787 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1788 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1789 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
1794 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1797 if `echo $COND_TST|grep -q 'without_'`; then
1798 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1799 if `echo $COND_TST|grep -q !`; then
1804 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1805 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1806 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1812 elif `echo $COND_TST|grep -q 'with_'`; then
1813 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1814 if `echo $COND_TST|grep -q !`; then
1819 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1820 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1821 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1827 RESULT="${COND_STATE}-${COND_ARGV}"
1829 "with-wout" | "wout-with" )
1832 "wout-wout" | "with-with" )
1836 echo "Action '$RESULT' was not defined for package '$package_item'"
1842 if [ "$GO" = "yes" ]; then
1843 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1844 echo "Testing if $package has subrequirements..."
1845 run_poldek -t -i $package --dumpn=".$package-req.txt"
1846 if [ -f ".$package-req.txt" ]; then
1847 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1849 if [ "$package_name" = "$package" ]; then
1850 echo -ne "Installing BuildRequired package:\t$package_name\n"
1851 update_shell_title "Installing BuildRequired package: ${package_name}"
1852 install_required_packages $package
1854 echo -ne "Installing (sub)Required package:\t$package_name\n"
1855 update_shell_title "Installing (sub)Required package: ${package_name}"
1856 install_required_packages $package_name
1860 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1861 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1864 echo "Attempting to run spawn sub - builder..."
1865 echo -ne "Package installation failed:\t$package_name\n"
1866 run_sub_builder $package_name
1867 if [ $? -eq 0 ]; then
1868 install_required_packages $package_name
1871 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1872 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1875 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1882 rm -f ".$package-req.txt"
1884 echo "Attempting to run spawn sub - builder..."
1885 echo -ne "Package installation failed:\t$package\n"
1886 run_sub_builder $package
1887 if [ $? -eq 0 ]; then
1888 install_required_packages $package
1891 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1892 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1895 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1901 echo "Package $package is already installed. BuildRequirement satisfied."
1905 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1906 echo >&2 "Unable to install following packages and their dependencies:"
1907 for pkg in "$NOT_INSTALLED_PACKAGES"
1911 remove_build_requires
1917 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1918 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1920 echo "Initializing rpm directories to $TOP_DIR from $CVSROOT"
1921 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1923 $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1927 echo "To checkout *all* .spec files (read-only):"
1928 echo "- run cvs co SPECS"
1930 echo "To checkout *all* packages:"
1931 echo "- run cvs up -dP in $TOP_DIR/packages dir"
1934 echo "To commit with your developer account:"
1935 echo "- edit $TOP_DIR/packages/CVS/Root"
1938 get_greed_sources() {
1939 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1940 if [ -n "BE_VERBOSE" ]; then
1941 echo "Try greed download: $1 from: $CVSROOT"
1943 $CVS_COMMAND -d $CVSROOT get SOURCES/$1
1944 if [ $? != 0 ]; then
1945 Exit_error err_no_source_in_repo $1
1950 # remove entries from CVS/Entries
1951 cvs_entry_remove() {
1952 local cvsdir="$1"; shift
1953 if [ ! -d "$cvsdir" ]; then
1954 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1958 for file in "$@"; do
1959 rm -f $cvsdir/CVS/Entries.new || return 1
1960 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1961 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1969 DONT_PRINT_REVISION="yes"
1973 # remove from CVS/Entries
1974 cvs_entry_remove $PACKAGE_DIR $SPECFILE $SOURCES $PATCHES
1976 # remove spec and sources
1977 $RPMBUILD --clean --rmsource --rmspec --nodeps --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1980 #---------------------------------------------
1988 while [ $# -gt 0 ]; do
1991 COMMAND="update_md5"
1996 COMMAND="update_md5"
2006 DEBUG="yes"; shift ;;
2008 COMMAND="version"; shift ;;
2010 COMMAND="short-version"; shift ;;
2012 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
2013 -b | -ba | --build )
2014 COMMAND="build"; shift ;;
2015 -bb | --build-binary )
2016 COMMAND="build-binary"; shift ;;
2018 COMMAND="build-build"; shift ;;
2020 COMMAND="build-install"; shift ;;
2022 COMMAND="build-list"; shift ;;
2023 -bp | --build-prep )
2024 COMMAND="build-prep"; shift ;;
2025 -bs | --build-source )
2026 COMMAND="build-source"; shift ;;
2028 COMMAND="branch"; shift; TAG="${1}"; shift;;
2030 CLEAN="--clean"; shift ;;
2032 CVS_FORCE="-F"; shift;;
2034 shift; CVSROOT="${1}"; shift ;;
2036 COMMAND="get"; shift ;;
2038 COMMAND="usage"; shift ;;
2040 PROTOCOL="http"; shift ;;
2042 shift; LOGFILE="${1}"; shift ;;
2044 shift; DEF_NICE_LEVEL=${1}; shift ;;
2045 -ske | --skip-existing-files)
2046 SKIP_EXISTING_FILES="yes"; shift ;;
2048 COMMAND="mr-proper"; shift ;;
2050 NOCVS="yes"; shift ;;
2051 -ncs | --no-cvs-specs )
2052 NOCVSSPEC="yes"; shift ;;
2053 -nd | --no-distfiles )
2054 NODIST="yes"; shift ;;
2055 -nm | --no-mirrors )
2056 NOMIRRORS="yes"; shift ;;
2058 NOURLS="yes"; shift ;;
2060 NOSRCS="yes"; shift ;;
2061 -ns0 | --no-source0 )
2062 NOSOURCE0="yes"; shift ;;
2072 -pm | --prefer-mirrors )
2079 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2081 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2083 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2086 --with | --without )
2087 case $GROUP_BCONDS in
2091 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2092 while ! `echo ${1}|grep -qE '(^-|spec)'`
2094 BCOND="$BCOND $COND $1"
2098 if [[ "$2" = *,* ]]; then
2099 for a in $(echo "$2" | tr , ' '); do
2100 BCOND="$BCOND $1 $a"
2103 BCOND="$BCOND $1 $2"
2109 shift; TARGET="${1}"; shift ;;
2111 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2113 QUIET="--quiet"; shift ;;
2115 CVSDATE="${2}"; shift 2 ;;
2124 -R | --fetch-build-requires)
2125 FETCH_BUILD_REQUIRES="yes"
2126 NOT_INSTALLED_PACKAGES=
2128 -RB | --remove-build-requires)
2129 REMOVE_BUILD_REQUIRES="nice"
2131 -FRB | --force-remove-build-requires)
2132 REMOVE_BUILD_REQUIRES="force"
2134 -sc | --sources-cvs)
2135 COMMAND="list-sources-cvs"
2137 -sd | --sources-distfiles)
2138 COMMAND="list-sources-distfiles"
2140 -sdp | --sources-distfiles-paths)
2141 COMMAND="list-sources-distfiles-paths"
2143 -sf | --sources-files)
2144 COMMAND="list-sources-files"
2146 -sp | --sources-paths)
2147 COMMAND="list-sources-local-paths"
2149 -su | --sources-urls)
2150 COMMAND="list-sources-urls"
2152 -Tvs | --tag-version-stable )
2157 -Ts | --tag-stable )
2162 -Tv | --tag-version )
2167 -Tp | --tag-prefix )
2179 -ir | --integer-release-only )
2180 INTEGER_RELEASE="yes"
2183 COMMAND="update_md5"
2188 -Upi | --update-poldek-indexes )
2189 UPDATE_POLDEK_INDEXES="yes"
2192 COMMAND="init_rpm_dir"
2194 --use-greed-sources )
2197 -u | --try-upgrade )
2198 TRY_UPGRADE="1"; shift ;;
2199 -un | --try-upgrade-with-float-version )
2200 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2202 BE_VERBOSE="1"; shift ;;
2207 if echo "${MACRO}" | grep -q '\W'; then
2208 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2212 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2217 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2221 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2224 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2225 COMMAND="show_bconds"
2229 COMMAND="show_bcond_args"
2232 --show-avail-bconds)
2233 COMMAND="show_avail_bconds"
2238 RPMOPTS="${RPMOPTS} --nodeps"
2241 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2244 Exit_error err_invalid_cmdline "$1"
2248 # check if specname was passed as specname:cvstag
2249 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2250 CVSTAG="${SPECFILE##*:}"
2251 SPECFILE="${SPECFILE%%:*}"
2253 # always have SPECFILE ending with .spec extension
2254 SPECFILE=${SPECFILE%%.spec}.spec
2255 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2259 [ -d "$ASSUMED_NAME" ] && CVS_ENTRIES="$ASSUMED_NAME/CVS/Entries" || CVS_ENTRIES="CVS/Entries"
2260 if [ -f "$CVS_ENTRIES" ] && [ -z "$CVSTAG" ]; then
2261 CVSTAG=$(awk -vSPECFILE=$(basename $SPECFILE) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' ${CVS_ENTRIES})
2262 if [ "$CVSTAG" ]; then
2263 echo >&2 "builder: Sticky tag $CVSTAG active. Use -r TAGNAME to override."
2265 elif [ "$CVSTAG" = "HEAD" ]; then
2266 # assume -r HEAD is same as -A
2270 if [ "$CVSTAG" ]; then
2271 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2272 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2275 if [ -n "$DEBUG" ]; then
2280 if [ -n "$TARGET" ]; then
2283 TARGET_SWITCH="--target $TARGET" ;;
2285 TARGET_SWITCH="--target=$TARGET" ;;
2289 if [ "$SCHEDTOOL" != "no" ]; then
2290 NICE_COMMAND="$SCHEDTOOL"
2292 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2295 update_shell_title "$COMMAND"
2299 if [ -n "$SPECFILE" ]; then
2300 get_spec > /dev/null
2308 if [ -n "$SPECFILE" ]; then
2309 get_spec > /dev/null
2315 "show_avail_bconds")
2317 if [ -n "$SPECFILE" ]; then
2318 get_spec > /dev/null
2320 local bcond_avail=$(find_spec_bcond $SPECFILE)
2321 local opt bcond bconds
2322 for opt in $bcond_avail; do
2325 bcond=${opt#without_}
2326 bconds="$bconds $bcond"
2330 bconds="$bconds $bcond"
2333 echo >&2 "ERROR: unexpected '$opt' in show_avail_bconds"
2342 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2344 if [ -n "$SPECFILE" ]; then
2345 # display SMP make flags if set
2346 smp_mflags=$(rpm -E %{?_smp_mflags})
2347 if [ "$smp_mflags" ]; then
2348 echo "builder: SMP make flags are set to $smp_mflags"
2356 if [ "$COMMAND" != "build-source" ]; then
2359 fetch_build_requires
2360 if [ "$INTEGER_RELEASE" = "yes" ]; then
2361 echo "Checking release $PACKAGE_RELEASE..."
2362 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2363 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2367 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2368 if [ -n "$TEST_TAG" ]; then
2369 local TAGVER=`make_tagver`
2370 echo "Searching for tag $TAGVER..."
2371 TAGREL=$($CVS_COMMAND status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2372 if [ -n "$TAGREL" ]; then
2373 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2376 # - do not allow to build from HEAD when XX-branch exists
2377 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2378 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2379 TAG_BRANCH="${TREE_PREFIX}-branch"
2380 TAG_STATUS=$($CVS_COMMAND status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2381 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2382 Exit_error err_branch_exists "$TAG_STATUS"
2388 if [ -n "$NOSOURCE0" ] ; then
2389 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2391 get_files $SOURCES $PATCHES
2394 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2395 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2397 remove_build_requires
2399 Exit_error err_no_spec_in_cmdl
2404 if [ -n "$SPECFILE" ]; then
2407 # don't fetch sources from remote locations
2409 for file in $SOURCES; do
2410 [ -n "`src_md5 $file`" ] && continue
2411 new_SOURCES="$new_SOURCES $file"
2413 SOURCES="$new_SOURCES"
2414 get_files $SOURCES $PATCHES
2416 branch_files $TAG $SOURCES $PATCHES $ICONS
2418 Exit_error err_no_spec_in_cmdl
2423 if [ -n "$SPECFILE" ]; then
2427 if [ -n "$NOSOURCE0" ] ; then
2428 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2430 get_files $SOURCES $PATCHES
2433 Exit_error err_no_spec_in_cmdl
2438 if [ -n "$SPECFILE" ]; then
2442 if [ -n "$NOSOURCE0" ] ; then
2443 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2447 Exit_error err_no_spec_in_cmdl
2454 if [ -n "$SPECFILE" ]; then
2458 # don't fetch sources from remote locations
2460 for file in $SOURCES; do
2461 [ -n "`src_md5 $file`" ] && continue
2462 new_SOURCES="$new_SOURCES $file"
2464 SOURCES="$new_SOURCES"
2465 get_files $SOURCES $PATCHES
2467 tag_files $SOURCES $PATCHES $ICONS
2469 Exit_error err_no_spec_in_cmdl
2475 "list-sources-files" )
2478 DONT_PRINT_REVISION="yes"
2481 for SAP in $SOURCES $PATCHES; do
2482 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2485 "list-sources-urls" )
2488 DONT_PRINT_REVISION="yes"
2491 SAPS="$SOURCES $PATCHES"
2492 for SAP in $SAPS ; do
2496 "list-sources-local-paths" )
2499 DONT_PRINT_REVISION="yes"
2502 for SAP in $SOURCES $PATCHES; do
2503 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2506 "list-sources-distfiles-paths" )
2509 DONT_PRINT_REVISION="yes"
2512 for SAP in $SOURCES $PATCHES; do
2513 if [ -n "$(src_md5 "$SAP")" ]; then
2514 distfiles_path "$SAP"
2518 "list-sources-distfiles" )
2521 DONT_PRINT_REVISION="yes"
2524 for SAP in $SOURCES $PATCHES; do
2525 if [ -n "$(src_md5 "$SAP")" ]; then
2526 distfiles_url "$SAP"
2530 "list-sources-cvs" )
2533 DONT_PRINT_REVISION="yes"
2536 for SAP in $SOURCES $PATCHES; do
2537 if [ -z "$(src_md5 "$SAP")" ]; then
2538 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2552 echo "$VERSIONSTRING"
2555 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2556 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2560 # vi:syntax=sh:ts=4:sw=4:noet