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
32 # basename: missing operand
33 # Try `basename --help' for more information.
34 # -- and the normal usage info --
42 Build package utility from PLD Linux CVS repository
43 $VERSION (C) 1999-2010 Free Penguins".
45 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
47 # required rpm-build-macros
67 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
71 # use rpm 4.4.6+ digest format instead of comments if non-zero
74 # user agent when fetching files
75 USER_AGENT="PLD/Builder($VERSION)"
77 # It can be used i.e. in log file naming.
78 # See LOGFILE example.
79 DATE=`date +%Y-%m-%d_%H-%M-%S`
81 # Example: LOGFILE='../log.$PACKAGE_NAME'
82 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
83 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
84 # Example: LOGFILE='$PACKAGE_NAME.$DATE.log'
85 # Yes, you can use variable name! Note _single_ quotes!
100 # create symlinks for tools in PACKAGE_DIR, see get_spec()
111 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
113 CVS_COMMAND=${CVS_COMMAND:-cvs}
116 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
117 CVS_SERVER="cvs.pld-linux.org"
122 DISTFILES_SERVER="://distfiles.pld-linux.org"
123 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
128 FAIL_IF_NO_SOURCES="yes"
130 # let get_files skip over files which are present to get those damn files fetched
131 SKIP_EXISTING_FILES="no"
134 # should the specfile be restored if upgrade failed?
135 REVERT_BROKEN_UPGRADE="yes"
137 if rpm --specsrpm 2>/dev/null; then
138 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
139 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
141 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
142 if [ -x /usr/bin/rpm-getdeps ]; then
143 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
145 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
150 # Here we load saved user environment used to
151 # predefine options set above, or passed to builder
153 # This one reads global system environment settings:
154 if [ -f ~/etc/builderrc ]; then
157 # And this one cascades settings using user personal
159 # Example of ~/.builderrc:
161 #UPDATE_POLDEK_INDEXES="yes"
162 #FETCH_BUILD_REQUIRES="yes"
163 #REMOVE_BUILD_REQUIRES="force"
165 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
169 if [ -n "$HOME_ETC" ]; then
170 USER_CFG="$HOME_ETC/.builderrc"
171 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
173 USER_CFG=~/.builderrc
174 BUILDER_MACROS=~/.builder-rpmmacros
177 [ -f "$USER_CFG" ] && . "$USER_CFG"
179 if [ "$SCHEDTOOL" = "auto" ]; then
180 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
181 SCHEDTOOL="schedtool -B -e"
187 if [ -n "$USE_PROZILLA" ]; then
188 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
191 elif [ -n "$USE_AXEL" ]; then
192 GETURI="axel -a $AXEL_OPTS"
196 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
197 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
198 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
199 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
201 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
202 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
208 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
217 # are we using cvs-nserver ?
220 $CVS_COMMAND --version 2>&1 | grep -q 'CVS-nserver'
221 [ $? -eq 0 ] && CVS_NSERVER=1
223 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
224 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
227 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
228 if [ -n "$LOGFILE" ]; then
229 LOG=`eval echo $LOGFILE`
230 if [ -n "$LASTLOG_FILE" ]; then
231 echo "LASTLOG=$LOG" > $LASTLOG_FILE
233 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
236 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
237 return `cat ${RES_FILE}`
242 #---------------------------------------------
246 if [ -n "$DEBUG" ]; then set -xv; fi
248 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
249 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
250 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
251 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
252 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
253 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
254 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
255 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
256 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
257 <package>[.spec][:cvstag]
259 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
260 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
261 -n5, --no-md5 - ignore md5 comments in spec
262 -D, --debug - enable builder script debugging mode,
263 -debug - produce rpm debug package (same as --opts -debug)
264 -V, --version - output builder version string
265 --short-version - output builder short version
266 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
267 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
269 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
270 only package from <package>.spec,
271 -bp, --build-prep - execute the %prep phase of <package>.spec,
272 -bc - execute the %build phase of <package>.spec,
273 -bi - execute the %install phase of <package>.spec
274 -bl - execute the %files phase of <package>.spec
275 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
277 --short-circuit - short-circuit build
278 -B, --branch - add branch
279 -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
280 may be used with building process.
281 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
282 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
284 -cf, --cvs-force - use -F when tagging (useful when moving branches)
285 -d <cvsroot>, --cvsroot <cvsroot>
287 --define <macro> <value>
288 - define a macro <macro> with value <value>,
289 --alt_kernel <kernel>
290 - same as --define 'alt_kernel <kernel>'
291 --nodeps - rpm won't check any dependences
292 -g, --get - get <package>.spec and all related files from CVS repo
294 -h, --help - this message,
295 --http - use http instead of ftp,
296 -l <logfile>, --logtofile <logfile>
298 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
300 - don't check specs in CVS
301 -nd, --no-distfiles - don't download from distfiles
302 -nm, --no-mirrors - don't download from mirror, if source URL is given,
303 -nu, --no-urls - don't try to download from FTP/HTTP location,
304 -ns, --no-srcs - don't download Sources/Patches
305 -ns0, --no-source0 - don't download Source0
306 -nn, --no-net - don't download anything from the net
307 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
308 --no-init - don't initialize builder paths (SPECS and SOURCES)
310 --skip-existing-files - skip existing files in get_files
311 --opts <rpm opts> - additional options for rpm
312 -q, --quiet - be quiet,
313 --date yyyy-mm-dd - build package using resources from specified CVS date,
314 -r <cvstag>, --cvstag <cvstag>
315 - build package using resources from specified CVS tag,
316 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
317 -R, --fetch-build-requires
318 - fetch what is BuildRequired,
319 -RB, --remove-build-requires
320 - remove all you fetched with -R or --fetch-build-requires
321 remember, this option requires confirmation,
322 -FRB, --force-remove-build-requires
323 - remove all you fetched with -R or --fetch-build-requires
324 remember, this option works without confirmation,
325 -sd, --source-distfiles - list sources available from distfiles (intended for offline
326 operations; does not work when Icon field is present
327 but icon file is absent),
328 -sc, --source-cvs - list sources available from CVS
329 -sdp, --source-distfiles-paths - list sources available from distfiles -
330 paths relative to distfiles directory (intended for offline
331 operations; does not work when Icon field is present
332 but icon file is absent),
333 -sf, --source-files - list sources - bare filenames (intended for offline
334 operations; does not work when Icon field is present
335 but icon file is absent),
336 -sp, --source-paths - list sources - filenames with full local paths (intended for
337 offline operations; does not work when Icon field is present
338 but icon file is absent),
339 -su, --source-urls - list urls - urls to sources and patches
340 intended for copying urls with spec with lots of macros in urls
341 -T <cvstag> , --tag <cvstag>
342 - add cvs tag <cvstag> for files,
343 -Tvs, --tag-version-stable
344 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
346 - add cvs tag STABLE for files,
348 - add cvs tag NAME-VERSION-RELEASE for files,
349 -Tp, --tag-prefix <prefix>
350 - add <prefix> to NAME-VERSION-RELEASE tags,
351 -tt, --test-tag <prefix>
352 - fail if tag is already present,
353 -ir, --integer-release-only
354 - allow only integer and snapshot releases
355 -v, --verbose - be verbose,
356 -u, --try-upgrade - check version, and try to upgrade package
357 -un, --try-upgrade-with-float-version
358 - as above, but allow float version
360 - try download source from tag head if don't find it in
362 -U, --update - refetch sources, don't use distfiles, and update md5 comments
363 -Upi, --update-poldek-indexes
364 - refresh or make poldek package index files.
365 -np, --nopatch <patchnumber>
366 - don't apply <patchnumber>
367 --show-bconds - show available conditional builds, which can be used
368 - with --with and/or --without switches.
369 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
370 ./repackage.sh script. in other words, the output is
371 parseable by scripts.
372 --show-avail-bconds - show available bconds
373 --with/--without <feature>
374 - conditional build package depending on %_with_<feature>/
375 %_without_<feature> macro switch. You may now use
376 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
377 constructions. Set GROUP_BCONDS to yes to make use of it.
378 --target <platform>, --target=<platform>
379 - build for platform <platform>.
380 --init-rpm-dir - initialize ~/rpm directory structure
384 # change dependency to specname
386 # - perl(Package::Name) -> perl-Package-Name
390 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
394 update_shell_title() {
396 local len=${COLUMNS:-80}
397 local msg="$(echo "$*" | cut -c-$len)"
399 if [ -n "$BE_VERBOSE" ]; then
400 echo >&2 "$(date +%s.%N) $*"
403 if [ "x$TITLECHANGE" = "xyes" -o "x$TITLECHANGE" = "x" ]; then
405 if [ -n "$PACKAGE_NAME" ]; then
406 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
411 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
412 msg=$(echo $msg | tr -d '\n\r')
415 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
418 echo >&2 -ne "\033]0;$msg\007"
424 # set TARGET from BuildArch: from SPECFILE
426 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
427 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
429 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
433 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
435 TARGET_SWITCH="--target=$TARGET" ;;
441 # runs rpm with minimal macroset
443 # we reset macros not to contain macros.build as all the %() macros are
444 # executed here, while none of them are actually needed.
445 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
446 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
448 # TODO: move these to /usr/lib/rpm/macros
449 cat > $BUILDER_MACROS <<'EOF'
450 %x8664 x86_64 amd64 ia32e
453 %requires_releq_kernel_up(s:n:) %{nil}
454 %requires_releq_kernel_smp(s:n:) %{nil}
455 %requires_releq_kernel(s:n:) %{nil}
456 %requires_releq() %{nil}
457 %pyrequires_eq() %{nil}
458 %requires_eq() %{nil}
459 %requires_eq_to() %{nil}
460 %releq_kernel_up(n:) ERROR
461 %releq_kernel_smp(n:) ERROR
462 %releq_kernel(n:) ERROR
466 %ruby_ver_requires_eq() %{nil}
467 %ruby_mod_ver_requires_eq() %{nil}
468 %__php_api_requires() %{nil}
469 %php_major_version ERROR
470 %php_api_version ERROR
471 %requires_xorg_xserver_extension %{nil}
472 %requires_xorg_xserver_xinput %{nil}
473 %requires_xorg_xserver_font %{nil}
474 %requires_xorg_xserver_videodrv %{nil}
476 %perl_vendorarch ERROR
477 %perl_vendorlib ERROR
478 # damn. need it here! - copied from /usr/lib/rpm/macros.build
479 %tmpdir %(echo "${TMPDIR:-/tmp}")
480 %patchset_source(f:b:) %(
481 base=%{-b*}%{!-b*:10000};
482 start=$(expr $base + %1);
483 end=$(expr $base + %{?2}%{!?2:%{1}});
484 # we need to call seq twice as it doesn't allow two formats
485 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
486 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
487 paste %{tmpdir}/__ps{1,2};
488 rm -f %{tmpdir}/__ps{1,2};
491 %add_etc_shells(p) %{p:<lua>}
492 %remove_etc_shells(p) %{p:<lua>}
493 %lua_add_etc_shells() %{nil}
494 %lua_remove_etc_shells() %{nil}
496 if [ "$NOINIT" = "yes" ] ; then
497 cat >> $BUILDER_MACROS <<'EOF'
502 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
506 if [ -n "$DEBUG" ]; then
511 if [ -x /usr/bin/rpm-specdump ]; then
512 update_shell_title "cache_rpm_dump using rpm-specdump command"
513 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
515 update_shell_title "cache_rpm_dump using rpmbuild command"
518 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
519 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
525 ARGS='--nodigest --nosignature --nobuild'
528 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
530 if [ $? -gt 0 ]; then
531 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
533 Exit_error err_build_fail
536 # make small dump cache
537 rpm_dump_cache=`echo "$rpm_dump" | awk '
538 $2 ~ /^SOURCEURL/ {print}
539 $2 ~ /^PATCHURL/ {print}
540 $2 ~ /^nosource/ {print}
541 $2 ~ /^PACKAGE_/ {print}
545 update_shell_title "cache_rpm_dump: OK!"
549 if [ -z "$rpm_dump_cache" ] ; then
550 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
552 echo "$rpm_dump_cache"
556 update_shell_title "get icons"
557 ICONS=$(awk '/^Icon:/ {print $2}' ${ASSUMED_NAME}/${SPECFILE})
558 if [ -z "$ICONS" ]; then
562 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
566 update_shell_title "parsing specfile"
567 if [ -n "$DEBUG" ]; then
572 # icons are needed for successful spec parse
578 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
579 FAIL_IF_NO_SOURCES="no"
582 if [ "$NOSRCS" != "yes" ]; then
583 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
584 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
585 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
588 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
589 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
590 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
592 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
593 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
596 if [ -n "$BE_VERBOSE" ]; then
597 echo "- Sources : `nourl $SOURCES`"
598 if [ -n "$PATCHES" ]; then
599 echo "- Patches : `nourl $PATCHES`"
601 echo "- Patches : *no patches needed*"
603 if [ -n "$ICONS" ]; then
604 echo "- Icon : `nourl $ICONS`"
606 echo "- Icon : *no package icon*"
608 echo "- Name : $PACKAGE_NAME"
609 echo "- Version : $PACKAGE_VERSION"
610 echo "- Release : $PACKAGE_RELEASE"
613 update_shell_title "parse_spec: OK!"
617 if [ -n "$DEBUG" ]; then
625 "err_no_spec_in_cmdl" )
626 remove_build_requires
627 echo >&2 "ERROR: spec file name not specified."
629 "err_invalid_cmdline" )
630 echo >&2 "ERROR: invalid command line arg ($2)."
632 "err_no_spec_in_repo" )
633 remove_build_requires
634 echo >&2 "Error: spec file not stored in CVS repo."
636 "err_no_source_in_repo" )
637 remove_build_requires
638 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
641 remove_build_requires
642 echo >&2 "Error: package build failed. (${2:-no more info})"
644 "err_no_package_data" )
645 remove_build_requires
646 echo >&2 "Error: couldn't get out package name/version/release from spec file."
649 remove_build_requires
650 echo >&2 "Tag ${2} already exists (spec release: ${3})."
653 remove_build_requires
654 echo >&2 "Release ${2} not integer and not a snapshot."
656 "err_branch_exists" )
657 remove_build_requires
658 echo >&2 "Tree branch already exists (${2})."
661 remove_build_requires
662 echo >&2 "Error: conditions reject building this spec (${2})."
665 echo >&2 "Unknown error."
670 if [ -n "$DEBUG" ]; then
675 if [ "$NOINIT" != "yes" ] ; then
676 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
678 local macros_ver=$(rpm -E %?rpm_build_macros)
679 if [ -z "$macros_ver" ]; then
680 REPO_DIR=$TOP_DIR/packages
681 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
683 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
684 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
688 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
700 update_shell_title "get_spec"
702 if [ -n "$DEBUG" ]; then
708 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
710 SPECFILE=$(basename $SPECFILE)
712 if [ "$NOCVSSPEC" != "yes" ]; then
714 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
715 echo "Warning: No CVS access defined - using local .spec file"
719 if [ -d "$ASSUMED_NAME" ]; then
720 cvsup "$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
722 cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
724 # remove Entries.Static -- so 'cvs up' would update all files in a repo
725 rm "$ASSUMED_NAME/CVS/Entries.Static"
726 cvsignore_df .cvsignore
728 # create symlinks for tools
729 if [ "$SYMLINK_TOOLS" != "no" ]; then
730 for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh; do
731 [ -f $a ] || continue
732 ln -s ../$a $ASSUMED_NAME
739 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
740 Exit_error err_no_spec_in_repo
743 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
744 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
747 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
755 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
756 $CVS_COMMAND update mirrors >&2
760 local origin mirror name rest ol prefix
761 while read origin mirror name rest; do
762 # skip comments and empty lines
763 if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then
766 ol=$(echo -n "$origin" | wc -c)
767 prefix=$(echo -n "$url" | head -c $ol)
768 if [ "$prefix" = "$origin" ] ; then
769 suffix=$(echo "$url" | cut -b $((ol+1))-)
770 echo -n "$mirror$suffix"
777 # Warning: unpredictable results if same URL used twice
781 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
782 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
787 [ "$NO5" = "yes" ] && return
789 [ -z "$no" ] && return
793 if [ -f additional-md5sums ]; then
794 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
795 if [ -z "$spec_rev" ]; then
796 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
798 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
799 md5=$(grep -s -v '^#' additional-md5sums | \
800 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
801 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
802 grep -E '^[0-9a-f]{32}$')
805 if [ $(echo "$md5" | wc -l) != 1 ] ; then
806 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
808 echo "$md5" | tail -n 1
813 source_md5=`grep -i "^#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
814 if [ -n "$source_md5" ]; then
817 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
818 if [ -n "$source_md5" ]; then
821 # we have empty SourceX-md5, but it is still possible
822 # that we have NoSourceX-md5 AND NoSource: X
823 nosource_md5=`grep -i "^#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
824 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
832 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
836 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
839 distfiles_attic_url() {
840 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
846 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
850 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
851 [ -n "$size" -a "$size" -gt 0 ]
855 if [ "$CVSIGNORE_DF" != "yes" ]; then
858 cvsignore=${PACKAGE_DIR}/.cvsignore
860 # add only if not yet there
861 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
862 echo "$1" >> $cvsignore
867 update_shell_title "cvsup"
870 if [ "$1" = "-c" ]; then
874 if [ -n "$CVSROOT" ]; then
875 OPTIONS="-d $CVSROOT $OPTIONS"
878 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
879 OPTIONS="$OPTIONS -A"
881 if [ -n "$CVSDATE" ]; then
882 OPTIONS="$OPTIONS -D $CVSDATE"
884 if [ -n "$CVSTAG" ]; then
885 OPTIONS="$OPTIONS -r $CVSTAG"
890 local retries_counter=0
892 update_shell_title "cvsup: $*"
894 update_shell_title "cvsup: $# files"
896 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
897 retries_counter=$(( $retries_counter + 1 ))
898 output=$(LC_ALL=C $CVS_COMMAND $OPTIONS "$@" 2>&1)
900 [ -n "$output" ] && echo "$output"
901 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
902 echo "Trying again [$*]... ($retries_counter)"
903 update_shell_title "cvsup: retry #$retries_counter"
910 update_shell_title "cvsup: done!"
914 # returns true if "$1" is ftp, http or https protocol url
917 ftp://*|http://*|https://*)
925 if [ $# -eq 0 ]; then
929 update_shell_title "update md5"
930 if [ -n "$DEBUG" ]; then
937 # pass 1: check files to be fetched
941 local fp=$(nourl "$i")
942 local srcno=$(src_no "$i")
943 if [ -n "$ADD5" ]; then
944 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
945 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
946 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
948 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
950 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
951 need_files="$need_files $i"
955 # pass 1a: get needed files
956 if [ "$need_files" ]; then
957 get_files $need_files
960 # pass 2: proceed with md5 adding or updating
962 local fp=$(nourl "$i")
963 local srcno=$(src_no "$i")
964 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
965 if [ -z "$md5" ]; then
966 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
968 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
969 local tag="# Source$srcno-md5:\t"
970 if [[ "$md5" == *NoSource* ]]; then
971 tag="# NoSource$srcno-md5:\t"
972 elif [ -n "$USEDIGEST" ]; then
973 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
975 md5=$(md5sum "$fp" | cut -f1 -d' ')
976 echo "Updating Source$srcno ($md5: $fp)."
978 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
979 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
981 $PACKAGE_DIR/$SPECFILE
988 [ "$NO5" = "yes" ] && return
990 update_shell_title "check md5"
994 if ! good_md5 "$i"; then
995 echo -n "MD5 sum mismatch."
998 if ! good_size "$i"; then
999 echo -n "0 sized file."
1003 if [ $bad -eq 1 ]; then
1004 echo " Use -U to refetch sources,"
1005 echo "or -5 to update md5 sums, if you're sure files are correct."
1006 Exit_error err_no_source_in_repo $i
1012 update_shell_title "get_files"
1014 if [ -n "$DEBUG" ]; then
1019 if [ $# -gt 0 ]; then
1022 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
1023 echo "Warning: No CVS access defined for SOURCES"
1028 local get_files_cvs=""
1032 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1033 update_shell_title "$i"
1034 local fp=`nourl "$i"`
1035 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1040 local srcmd5=$(src_md5 "$i")
1042 # we know if source/patch is present in cvs/distfiles
1043 # - has md5 (in distfiles)
1044 # - in cvs... ideas?
1046 # CHECK: local file didn't exist or always cvs up (first) requested.
1047 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1048 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1049 echo "Warning: no URL given for $i"
1053 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1054 if good_md5 "$i" && good_size "$i"; then
1055 echo "$fp having proper md5sum already exists"
1059 # optionally prefer mirror over distfiles if there's mirror
1060 # TODO: build url list and then try each url from the list
1061 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1064 url=$(distfiles_url "$i")
1067 url_attic=$(distfiles_attic_url "$i")
1069 # is $url local file?
1070 if [[ "$url" = [./]* ]]; then
1071 update_shell_title "${GETLOCAL%% *}: $url"
1072 ${GETLOCAL} $url $target
1074 if [ -z "$NOMIRRORS" ]; then
1075 url=$(find_mirror "$url")
1079 # make shorter message for distfiles urls
1080 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1081 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1082 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1085 update_shell_title "${GETURI%% *}: $uri"
1086 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1087 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1088 update_shell_title "${GETURI2%% *}: $url"
1089 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1094 if [ ! -s "$target" ]; then
1096 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1097 update_shell_title "${GETLOCAL%% *}: $url_attic"
1098 ${GETLOCAL} $url_attic $target
1100 if [ -z "$NOMIRRORS" ]; then
1101 url_attic=$(find_mirror "$url_attic")
1103 update_shell_title "${GETURI%% *}: $url_attic"
1104 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1105 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1106 update_shell_title "${GETURI2%% *}: $url_attic"
1107 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1109 test -s "$target" || rm -f "$target"
1113 if [ -s "$target" ]; then
1114 cvsignore_df $target
1119 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1120 if [ $# -gt 1 ]; then
1121 get_files_cvs="$get_files_cvs $fp"
1122 update_shell_title "$fp (will cvs up later)"
1129 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1130 if [ -z "$NOMIRRORS" ]; then
1131 im=$(find_mirror "$i")
1135 update_shell_title "${GETURI%% *}: $im"
1136 ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
1137 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1138 update_shell_title "${GETURI2%% *}: $im"
1139 ${GETURI2} "$im" ${OUTFILEOPT} "$target"
1141 test -s "$target" || rm -f "$target"
1144 if [ "$cvsup" = 1 ]; then
1150 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1151 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1152 if [ -n "GREEDSRC" ]; then
1153 get_greed_sources $i
1155 Exit_error err_no_source_in_repo $i
1159 # we check md5 here just only to refetch immediately
1160 if good_md5 "$i" && good_size "$i"; then
1162 elif [ "$FROM_DISTFILES" = 1 ]; then
1163 # wrong md5 from distfiles: remove the file and try again
1165 echo "MD5 sum mismatch. Trying full fetch."
1168 update_shell_title "${GETURI%% *}: $url"
1169 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1170 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1171 update_shell_title "${GETURI2%% *}: $url"
1172 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1174 if [ ! -s "$target" ]; then
1176 update_shell_title "${GETURI%% *}: $url_attic"
1177 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1178 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1179 update_shell_title "${GETURI2%% *}: $url_attic"
1180 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1183 test -s "$target" || rm -f "$target"
1186 SHELL_TITLE_PREFIX=""
1188 if [ "$get_files_cvs" ]; then
1189 cvsup $get_files_cvs
1192 if [ "$CHMOD" = "yes" ]; then
1193 CHMOD_FILES=$(nourl "$@")
1194 if [ -n "$CHMOD_FILES" ]; then
1195 chmod $CHMOD_MODE $CHMOD_FILES
1202 if [ -n "$DEBUG" ]; then
1207 # Check whether first character of PACKAGE_NAME is legal for tag name
1208 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1212 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1213 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1215 # Remove #kernel.version_release from TAGVER because tagging sources
1216 # could occur with different kernel-headers than kernel-headers used at build time.
1217 # besides, %{_kernel_ver_str} is not expanded.
1219 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1220 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1226 # bool is_tag_a_branch(tag)
1228 # returns 1 if a tag is a branch set on SPECFILE
1230 if [ -n "$DEBUG" ]; then
1235 if [ $# -ne 1 ]; then
1242 $CVS_COMMAND status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1249 if [ -n "$DEBUG" ]; then
1254 echo "Version: $PACKAGE_VERSION"
1255 echo "Release: $PACKAGE_RELEASE"
1258 if [ "$TAG_VERSION" = "yes" ]; then
1259 TAGVER=`make_tagver`
1260 echo "CVS tag: $TAGVER"
1262 if [ -n "$TAG" ]; then
1263 echo "CVS tag: $TAG"
1266 local OPTIONS="tag $CVS_FORCE"
1267 if [ -n "$CVSROOT" ]; then
1268 OPTIONS="-d $CVSROOT $OPTIONS"
1271 # if a tagname we are about to set already exists
1272 # and happens to be a branch (common case with AC-branch)
1273 # pass -B (allows -F to disturb branch tag)
1275 if [ "$TAG_VERSION" = "yes" ]; then
1278 is_tag_a_branch $_tag
1279 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1280 OPTIONS="$OPTIONS -B"
1285 for i in $TAG_FILES; do
1286 # don't tag files stored on distfiles
1287 [ -n "`src_md5 $i`" ] && continue
1288 local fp=`nourl "$i"`
1289 if [ -f "$fp" ]; then
1290 tag_files="$tag_files $fp"
1291 elif [ -n "GREEDSRC" ]; then
1292 get_greed_sources $i
1294 Exit_error err_no_source_in_repo $i
1298 if [ "$tag_files" ]; then
1299 if [ "$TAG_VERSION" = "yes" ]; then
1300 update_shell_title "tag sources: $TAGVER"
1301 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1302 $CVS_COMMAND $OPTIONS $TAGVER $tag_files || exit
1304 if [ -n "$TAG" ]; then
1305 update_shell_title "tag sources: $TAG"
1307 while [ "$tag_files" ]; do
1308 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1309 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1310 $CVS_COMMAND $OPTIONS $TAG $chunk || exit
1311 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1317 if [ "$TAG_VERSION" = "yes" ]; then
1318 update_shell_title "tag spec: $TAGVER"
1319 $CVS_COMMAND $OPTIONS $TAGVER $SPECFILE || exit
1321 if [ -n "$TAG" ]; then
1322 update_shell_title "tag spec: $TAG"
1323 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1329 echo "CVS branch tag: $TAG"
1334 if [ -n "$DEBUG" ]; then
1339 local OPTIONS="tag $CVS_FORCE -b"
1342 is_tag_a_branch $TAG
1343 if [ $? -eq 1 ]; then
1344 OPTIONS="$OPTIONS -B"
1347 if [ -n "$CVSROOT" ]; then
1348 OPTIONS="-d $CVSROOT $OPTIONS"
1352 for i in $TAG_FILES; do
1353 local fp=`nourl "$i"`
1354 if [ -f "$fp" ]; then
1355 tag_files="$tag_files $fp"
1356 elif [ -n "GREEDSRC" ]; then
1357 get_greed_sources $i
1359 Exit_error err_no_source_in_repo $i
1362 if [ "$tag_files" ]; then
1363 $CVS_COMMAND $OPTIONS $TAG $tag_files || exit
1367 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1371 # this function should exit early if package can't be built for this arch
1372 # this avoids unneccessary BR filling.
1375 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1377 if [ $ret -ne 0 ]; then
1384 update_shell_title "build_package"
1385 if [ -n "$DEBUG" ]; then
1392 if [ -n "$TRY_UPGRADE" ]; then
1393 update_shell_title "build_package: try_upgrade"
1394 if [ -n "$FLOAT_VERSION" ]; then
1395 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1397 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1400 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1402 if [ -n "$TNEWVER" ]; then
1403 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1404 echo "New version found, updating spec file to version " $TNEWVER
1405 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1406 cp -f $SPECFILE $SPECFILE.bak
1409 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1410 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1412 NODIST="yes" get_files $SOURCES $PATCHES
1415 unset TOLDVER TNEWVER TNOTIFY
1422 BUILD_SWITCH="-ba" ;;
1424 BUILD_SWITCH="-bb" ;;
1426 BUILD_SWITCH="-bs --nodeps" ;;
1428 BUILD_SWITCH="-bp --nodeps" ;;
1430 BUILD_SWITCH="-bc" ;;
1432 BUILD_SWITCH="-bi" ;;
1434 BUILD_SWITCH="-bl" ;;
1438 update_shell_title "build_package: $COMMAND"
1439 if [ -n "$LOGFILE" ]; then
1440 LOG=`eval echo $LOGFILE`
1441 if [ -d "$LOG" ]; then
1442 echo "Log file $LOG is a directory."
1443 echo "Parse error in the spec?"
1444 Exit_error err_build_fail
1446 if [ -n "$LASTLOG_FILE" ]; then
1447 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1449 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1451 (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
1452 RETVAL=`cat $RES_FILE`
1454 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1455 if [ "$RETVAL" -eq "0" ]; then
1462 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1465 if [ "$RETVAL" -ne "0" ]; then
1466 if [ -n "$TRY_UPGRADE" ]; then
1467 echo "\n!!! Package with new version cannot be built automagically\n"
1468 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1469 mv -f $SPECFILE.bak $SPECFILE
1472 Exit_error err_build_fail
1478 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1481 install_required_packages() {
1486 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1489 /^%changelog/ { exit }
1491 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1492 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1493 gsub(/[ \t]+/, "_", bcond);
1495 }' $SPEC | LC_ALL=C sort -u
1499 # expand bconds from ~/.bcondrc
1500 # The file structure is like gentoo's package.use:
1503 # samba -mysql -pgsql
1504 # w32codec-installer license_agreement
1507 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1513 SN=${SPECFILE%%\.spec}
1515 local bcondrc=$HOME/.bcondrc
1516 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1518 local bcond_avail=$(find_spec_bcond $SPECFILE)
1520 while read pkg flags; do
1522 [[ "$pkg" == \#* ]] && continue
1524 # any package or current package?
1525 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1526 for flag in $flags; do
1527 local opt=${flag#[+-]}
1529 # use only flags which are in this package.
1530 if [[ $bcond_avail = *${opt}* ]]; then
1531 if [[ $flag = -* ]]; then
1532 if [[ $BCOND != *--with?${opt}* ]]; then
1533 BCOND="$BCOND --without $opt"
1536 if [[ $BCOND != *--without?${opt}* ]]; then
1537 BCOND="$BCOND --with $opt"
1544 update_shell_title "parse ~/.bcondrc: DONE!"
1547 set_bconds_values() {
1548 update_shell_title "set bcond values"
1550 AVAIL_BCONDS_WITHOUT=""
1551 AVAIL_BCONDS_WITH=""
1553 if egrep -q '^# *_with' ${SPECFILE}; then
1554 echo >&2 "ERROR: This spec has old style bconds."
1558 if ! grep -q '^%bcond' ${SPECFILE}; then
1562 local bcond_avail=$(find_spec_bcond $SPECFILE)
1563 process_bcondrc "$SPECFILE"
1565 update_shell_title "parse bconds"
1568 for opt in $bcond_avail; do
1571 bcond=${opt#without_}
1573 *--without?${bcond}*)
1574 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1577 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1585 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1588 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1593 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1602 update_shell_title "run_sub_builder $package_name"
1604 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1605 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1606 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1607 # jakby nie bylo tego kawalka kodu.
1609 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1610 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1614 # kurwa. translate that ^^^^
1618 # Istnieje taki spec? ${package}.spec
1619 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1620 parent_spec_name=${package}.spec
1621 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1622 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1624 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1629 if [ "${parent_spec_name}" != "" ]; then
1630 spawn_sub_builder $parent_spec_name
1632 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1635 spawn_sub_builder() {
1637 update_shell_title "spawn_sub_builder $package_name"
1640 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1641 sub_builder_opts="${sub_builder_opts} -R"
1643 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1644 sub_builder_opts="${sub_builder_opts} -RB"
1645 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1646 sub_builder_opts="${sub_builder_opts} -FRB"
1648 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1649 sub_builder_opts="${sub_builder_opts} -Upi"
1653 ./builder ${sub_builder_opts} "$@"
1656 remove_build_requires() {
1657 if [ "$INSTALLED_PACKAGES" != "" ]; then
1658 case "$REMOVE_BUILD_REQUIRES" in
1660 run_poldek --noask -ve $INSTALLED_PACKAGES
1663 run_poldek --ask -ve $INSTALLED_PACKAGES
1666 echo You may want to manually remove following BuildRequires fetched:
1667 echo $INSTALLED_PACKAGES
1668 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1675 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1676 if [ "$BCOND" ]; then
1678 echo "Building $SPECFILE with the following conditional flags:"
1682 echo "No conditional flags passed"
1685 echo "from available:"
1686 echo "--with :\t$AVAIL_BCONDS_WITH"
1687 echo "--without:\t$AVAIL_BCONDS_WITHOUT"
1692 display_branches() {
1693 if [ "$NOCVSSPEC" != "yes" ]; then
1694 echo -n "Available branches: "
1695 $CVS_COMMAND status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1699 # checks a given list of packages/files/provides agains current rpmdb.
1700 # outputs all dependencies which current rpmdb doesn't satisfy.
1701 # input can be either STDIN or parameters
1705 if [ $# -gt 0 ]; then
1711 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1714 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1716 # other deps (files)
1717 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1720 # checks if given package/files/provides exists in rpmdb.
1721 # input can be either stdin or parameters
1722 # returns packages which are present in the rpmdb
1726 if [ $# -gt 0 ]; then
1732 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1735 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1736 install_build_requires_rpmdeps() {
1737 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1738 # TODO: Conflicts list doesn't check versions
1739 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1740 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1742 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1743 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1744 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1747 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1748 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1749 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1750 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1752 if [ -n "$CNFL" ]; then
1753 update_shell_title "uninstall conflicting packages: $CNFL"
1754 echo "Trying to uninstall conflicting packages ($CNFL):"
1755 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1758 while [ "$DEPS" ]; do
1759 update_shell_title "install deps: $DEPS"
1760 echo "Trying to install dependencies ($DEPS):"
1761 local log=.${SPECFILE}_poldek.log
1762 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1763 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1766 if [ -n "$failed" ]; then
1767 for package in $failed; do
1768 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1777 fetch_build_requires()
1779 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1783 update_shell_title "fetch build requires"
1784 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1785 install_build_requires_rpmdeps
1789 # XXX is this ugliest code written in human history still needed?
1790 echo "All packages installed by fetch_build_requires() are written to:"
1791 echo "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1793 echo "If anything fails, you may get rid of them by executing:"
1794 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`"
1796 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1797 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)
1799 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)
1801 package=$(basename "$package_item"|sed -e "s/}$//g")
1802 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1805 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1806 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1807 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
1812 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1815 if `echo $COND_TST|grep -q 'without_'`; then
1816 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1817 if `echo $COND_TST|grep -q !`; then
1822 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1823 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1824 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1830 elif `echo $COND_TST|grep -q 'with_'`; then
1831 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1832 if `echo $COND_TST|grep -q !`; then
1837 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1838 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1839 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1845 RESULT="${COND_STATE}-${COND_ARGV}"
1847 "with-wout" | "wout-with" )
1850 "wout-wout" | "with-with" )
1854 echo "Action '$RESULT' was not defined for package '$package_item'"
1860 if [ "$GO" = "yes" ]; then
1861 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1862 echo "Testing if $package has subrequirements..."
1863 run_poldek -t -i $package --dumpn=".$package-req.txt"
1864 if [ -f ".$package-req.txt" ]; then
1865 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1867 if [ "$package_name" = "$package" ]; then
1868 echo "Installing BuildRequired package:\t$package_name"
1869 update_shell_title "Installing BuildRequired package: ${package_name}"
1870 install_required_packages $package
1872 echo "Installing (sub)Required package:\t$package_name"
1873 update_shell_title "Installing (sub)Required package: ${package_name}"
1874 install_required_packages $package_name
1878 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1879 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1882 echo "Attempting to run spawn sub - builder..."
1883 echo "Package installation failed:\t$package_name"
1884 run_sub_builder $package_name
1885 if [ $? -eq 0 ]; then
1886 install_required_packages $package_name
1889 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1890 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1893 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1900 rm -f ".$package-req.txt"
1902 echo "Attempting to run spawn sub - builder..."
1903 echo "Package installation failed:\t$package"
1904 run_sub_builder $package
1905 if [ $? -eq 0 ]; then
1906 install_required_packages $package
1909 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1910 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1913 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1919 echo "Package $package is already installed. BuildRequirement satisfied."
1923 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1924 echo >&2 "Unable to install following packages and their dependencies:"
1925 for pkg in "$NOT_INSTALLED_PACKAGES"
1929 remove_build_requires
1935 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1936 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1938 echo "Initializing rpm directories to $TOP_DIR from $CVSROOT"
1939 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1941 $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1945 echo "To checkout *all* .spec files (read-only):"
1946 echo "- run cvs co SPECS"
1948 echo "To checkout *all* packages:"
1949 echo "- run cvs up -dP in $TOP_DIR/packages dir"
1952 echo "To commit with your developer account:"
1953 echo "- edit $TOP_DIR/packages/CVS/Root"
1956 get_greed_sources() {
1957 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1958 if [ -n "BE_VERBOSE" ]; then
1959 echo "Try greed download: $1 from: $CVSROOT"
1961 $CVS_COMMAND -d $CVSROOT get SOURCES/$1
1962 if [ $? != 0 ]; then
1963 Exit_error err_no_source_in_repo $1
1968 # remove entries from CVS/Entries
1969 cvs_entry_remove() {
1970 local cvsdir="$1"; shift
1971 if [ ! -d "$cvsdir" ]; then
1972 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1976 for file in "$@"; do
1977 rm -f $cvsdir/CVS/Entries.new || return 1
1978 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1979 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1987 DONT_PRINT_REVISION="yes"
1991 # remove from CVS/Entries
1992 cvs_entry_remove $PACKAGE_DIR $SPECFILE $SOURCES $PATCHES
1994 # remove spec and sources
1995 $RPMBUILD --clean --rmsource --rmspec --nodeps --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1998 #---------------------------------------------
2006 while [ $# -gt 0 ]; do
2009 COMMAND="update_md5"
2014 COMMAND="update_md5"
2024 DEBUG="yes"; shift ;;
2026 COMMAND="version"; shift ;;
2028 COMMAND="short-version"; shift ;;
2030 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
2031 -b | -ba | --build )
2032 COMMAND="build"; shift ;;
2033 -bb | --build-binary )
2034 COMMAND="build-binary"; shift ;;
2036 COMMAND="build-build"; shift ;;
2038 COMMAND="build-install"; shift ;;
2040 COMMAND="build-list"; shift ;;
2041 -bp | --build-prep )
2042 COMMAND="build-prep"; shift ;;
2043 -bs | --build-source )
2044 COMMAND="build-source"; shift ;;
2046 COMMAND="branch"; shift; TAG="${1}"; shift;;
2048 CLEAN="--clean"; shift ;;
2050 CVS_FORCE="-F"; shift;;
2052 shift; CVSROOT="${1}"; shift ;;
2054 COMMAND="get"; shift ;;
2056 COMMAND="usage"; shift ;;
2058 PROTOCOL="http"; shift ;;
2060 shift; LOGFILE="${1}"; shift ;;
2062 shift; DEF_NICE_LEVEL=${1}; shift ;;
2063 -ske | --skip-existing-files)
2064 SKIP_EXISTING_FILES="yes"; shift ;;
2066 COMMAND="mr-proper"; shift ;;
2068 NOCVS="yes"; shift ;;
2069 -ncs | --no-cvs-specs )
2070 NOCVSSPEC="yes"; shift ;;
2071 -nd | --no-distfiles )
2072 NODIST="yes"; shift ;;
2073 -nm | --no-mirrors )
2074 NOMIRRORS="yes"; shift ;;
2076 NOURLS="yes"; shift ;;
2078 NOSRCS="yes"; shift ;;
2079 -ns0 | --no-source0 )
2080 NOSOURCE0="yes"; shift ;;
2090 -pm | --prefer-mirrors )
2097 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2099 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2101 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2104 --with | --without )
2105 case $GROUP_BCONDS in
2109 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2110 while ! `echo ${1}|grep -qE '(^-|spec)'`
2112 BCOND="$BCOND $COND $1"
2116 if [[ "$2" = *,* ]]; then
2117 for a in $(echo "$2" | tr , ' '); do
2118 BCOND="$BCOND $1 $a"
2121 BCOND="$BCOND $1 $2"
2127 shift; TARGET="${1}"; shift ;;
2129 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2131 QUIET="--quiet"; shift ;;
2133 CVSDATE="${2}"; shift 2 ;;
2142 -R | --fetch-build-requires)
2143 FETCH_BUILD_REQUIRES="yes"
2144 NOT_INSTALLED_PACKAGES=
2146 -RB | --remove-build-requires)
2147 REMOVE_BUILD_REQUIRES="nice"
2149 -FRB | --force-remove-build-requires)
2150 REMOVE_BUILD_REQUIRES="force"
2152 -sc | --sources-cvs)
2153 COMMAND="list-sources-cvs"
2155 -sd | --sources-distfiles)
2156 COMMAND="list-sources-distfiles"
2158 -sdp | --sources-distfiles-paths)
2159 COMMAND="list-sources-distfiles-paths"
2161 -sf | --sources-files)
2162 COMMAND="list-sources-files"
2164 -sp | --sources-paths)
2165 COMMAND="list-sources-local-paths"
2167 -su | --sources-urls)
2168 COMMAND="list-sources-urls"
2170 -Tvs | --tag-version-stable )
2175 -Ts | --tag-stable )
2180 -Tv | --tag-version )
2185 -Tp | --tag-prefix )
2197 -ir | --integer-release-only )
2198 INTEGER_RELEASE="yes"
2201 COMMAND="update_md5"
2206 -Upi | --update-poldek-indexes )
2207 UPDATE_POLDEK_INDEXES="yes"
2210 COMMAND="init_rpm_dir"
2212 --use-greed-sources )
2215 -u | --try-upgrade )
2216 TRY_UPGRADE="1"; shift ;;
2217 -un | --try-upgrade-with-float-version )
2218 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2220 BE_VERBOSE="1"; shift ;;
2225 if echo "${MACRO}" | grep -q '\W'; then
2226 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2230 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2235 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2239 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2242 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2243 COMMAND="show_bconds"
2247 COMMAND="show_bcond_args"
2250 --show-avail-bconds)
2251 COMMAND="show_avail_bconds"
2256 RPMOPTS="${RPMOPTS} --nodeps"
2259 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2262 Exit_error err_invalid_cmdline "$1"
2266 # check if specname was passed as specname:cvstag
2267 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2268 CVSTAG="${SPECFILE##*:}"
2269 SPECFILE="${SPECFILE%%:*}"
2271 # always have SPECFILE ending with .spec extension
2272 SPECFILE=${SPECFILE%%.spec}.spec
2273 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2277 [ -d "$ASSUMED_NAME" ] && CVS_ENTRIES="$ASSUMED_NAME/CVS/Entries" || CVS_ENTRIES="CVS/Entries"
2278 if [ -f "$CVS_ENTRIES" ] && [ -z "$CVSTAG" ]; then
2279 CVSTAG=$(awk -vSPECFILE=$(basename $SPECFILE) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' ${CVS_ENTRIES})
2280 if [ "$CVSTAG" ]; then
2281 echo >&2 "builder: Sticky tag $CVSTAG active. Use -r TAGNAME to override."
2283 elif [ "$CVSTAG" = "HEAD" ]; then
2284 # assume -r HEAD is same as -A
2288 if [ "$CVSTAG" ]; then
2289 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2290 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2293 if [ -n "$DEBUG" ]; then
2298 if [ -n "$TARGET" ]; then
2301 TARGET_SWITCH="--target $TARGET" ;;
2303 TARGET_SWITCH="--target=$TARGET" ;;
2307 if [ "$SCHEDTOOL" != "no" ]; then
2308 NICE_COMMAND="$SCHEDTOOL"
2310 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2313 update_shell_title "$COMMAND"
2317 if [ -n "$SPECFILE" ]; then
2318 get_spec > /dev/null
2326 if [ -n "$SPECFILE" ]; then
2327 get_spec > /dev/null
2333 "show_avail_bconds")
2335 if [ -n "$SPECFILE" ]; then
2336 get_spec > /dev/null
2338 local bcond_avail=$(find_spec_bcond $SPECFILE)
2339 local opt bcond bconds
2340 for opt in $bcond_avail; do
2343 bcond=${opt#without_}
2344 bconds="$bconds $bcond"
2348 bconds="$bconds $bcond"
2351 echo >&2 "ERROR: unexpected '$opt' in show_avail_bconds"
2360 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2362 if [ -n "$SPECFILE" ]; then
2363 # display SMP make flags if set
2364 smp_mflags=$(rpm -E %{?_smp_mflags})
2365 if [ "$smp_mflags" ]; then
2366 echo "builder: SMP make flags are set to $smp_mflags"
2374 if [ "$COMMAND" != "build-source" ]; then
2377 fetch_build_requires
2378 if [ "$INTEGER_RELEASE" = "yes" ]; then
2379 echo "Checking release $PACKAGE_RELEASE..."
2380 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2381 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2385 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2386 if [ -n "$TEST_TAG" ]; then
2387 local TAGVER=`make_tagver`
2388 echo "Searching for tag $TAGVER..."
2389 TAGREL=$($CVS_COMMAND status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2390 if [ -n "$TAGREL" ]; then
2391 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2394 # - do not allow to build from HEAD when XX-branch exists
2395 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2396 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2397 TAG_BRANCH="${TREE_PREFIX}-branch"
2398 TAG_STATUS=$($CVS_COMMAND status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2399 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2400 Exit_error err_branch_exists "$TAG_STATUS"
2406 if [ -n "$NOSOURCE0" ] ; then
2407 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2409 get_files $SOURCES $PATCHES
2412 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2413 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2415 remove_build_requires
2417 Exit_error err_no_spec_in_cmdl
2422 if [ -n "$SPECFILE" ]; then
2425 # don't fetch sources from remote locations
2427 for file in $SOURCES; do
2428 [ -n "`src_md5 $file`" ] && continue
2429 new_SOURCES="$new_SOURCES $file"
2431 SOURCES="$new_SOURCES"
2432 get_files $SOURCES $PATCHES
2434 branch_files $TAG $SOURCES $PATCHES $ICONS
2436 Exit_error err_no_spec_in_cmdl
2441 if [ -n "$SPECFILE" ]; then
2445 if [ -n "$NOSOURCE0" ] ; then
2446 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2448 get_files $SOURCES $PATCHES
2451 Exit_error err_no_spec_in_cmdl
2456 if [ -n "$SPECFILE" ]; then
2460 if [ -n "$NOSOURCE0" ] ; then
2461 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2465 Exit_error err_no_spec_in_cmdl
2472 if [ -n "$SPECFILE" ]; then
2476 # don't fetch sources from remote locations
2478 for file in $SOURCES; do
2479 [ -n "`src_md5 $file`" ] && continue
2480 new_SOURCES="$new_SOURCES $file"
2482 SOURCES="$new_SOURCES"
2483 get_files $SOURCES $PATCHES
2485 tag_files $SOURCES $PATCHES $ICONS
2487 Exit_error err_no_spec_in_cmdl
2493 "list-sources-files" )
2496 DONT_PRINT_REVISION="yes"
2499 for SAP in $SOURCES $PATCHES; do
2500 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2503 "list-sources-urls" )
2506 DONT_PRINT_REVISION="yes"
2509 SAPS="$SOURCES $PATCHES"
2510 for SAP in $SAPS ; do
2514 "list-sources-local-paths" )
2517 DONT_PRINT_REVISION="yes"
2520 for SAP in $SOURCES $PATCHES; do
2521 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2524 "list-sources-distfiles-paths" )
2527 DONT_PRINT_REVISION="yes"
2530 for SAP in $SOURCES $PATCHES; do
2531 if [ -n "$(src_md5 "$SAP")" ]; then
2532 distfiles_path "$SAP"
2536 "list-sources-distfiles" )
2539 DONT_PRINT_REVISION="yes"
2542 for SAP in $SOURCES $PATCHES; do
2543 if [ -n "$(src_md5 "$SAP")" ]; then
2544 distfiles_url "$SAP"
2548 "list-sources-cvs" )
2551 DONT_PRINT_REVISION="yes"
2554 for SAP in $SOURCES $PATCHES; do
2555 if [ -z "$(src_md5 "$SAP")" ]; then
2556 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2570 echo "$VERSIONSTRING"
2573 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2574 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2578 # vi:syntax=sh:ts=4:sw=4:noet