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)
20 # 110 - Functions not yet implemented
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 --
37 APPDIR=$(d=$0; [ -L "$d" ] && d=$(readlink -f "$d"); dirname "$d")
38 RCSID='$Id: builder,v 1.645 2011/02/13 17:54:10 glen Exp $' r=${RCSID#* * } rev=${r%% *}
41 Build package utility from PLD Linux Packages repository
42 $VERSION (C) 1999-2011 Free Penguins".
44 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
46 # required rpm-build-macros
65 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
67 # use rpm 4.4.6+ digest format instead of comments if non-zero
70 # user agent when fetching files
71 USER_AGENT="PLD/Builder($VERSION)"
73 # It can be used i.e. in log file naming.
74 # See LOGFILE example.
75 DATE=`date +%Y-%m-%d_%H-%M-%S`
77 # Example: LOGFILE='../log.$PACKAGE_NAME'
78 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
79 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
80 # Example: LOGFILE='$PACKAGE_NAME.$DATE.log'
81 # Yes, you can use variable name! Note _single_ quotes!
96 # create symlinks for tools in PACKAGE_DIR, see get_spec()
107 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
112 GIT_SERVER="git://github.com/draenog"
118 DISTFILES_SERVER="://distfiles.pld-linux.org"
119 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
124 FAIL_IF_NO_SOURCES="yes"
126 # let get_files skip over files which are present to get those damn files fetched
127 SKIP_EXISTING_FILES="no"
130 # should the specfile be restored if upgrade failed?
131 REVERT_BROKEN_UPGRADE="yes"
133 if rpm --specsrpm 2>/dev/null; then
134 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
135 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
137 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
138 if [ -x /usr/bin/rpm-getdeps ]; then
139 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
141 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
146 # Here we load saved user environment used to
147 # predefine options set above, or passed to builder
149 # This one reads global system environment settings:
150 if [ -f ~/etc/builderrc ]; then
153 # And this one cascades settings using user personal
155 # Example of ~/.builderrc:
157 #UPDATE_POLDEK_INDEXES="yes"
158 #FETCH_BUILD_REQUIRES="yes"
159 #REMOVE_BUILD_REQUIRES="force"
161 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
165 if [ -n "$HOME_ETC" ]; then
166 USER_CFG="$HOME_ETC/.builderrc"
167 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
169 USER_CFG=~/.builderrc
170 BUILDER_MACROS=~/.builder-rpmmacros
173 [ -f "$USER_CFG" ] && . "$USER_CFG"
175 if [ "$SCHEDTOOL" = "auto" ]; then
176 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
177 SCHEDTOOL="schedtool -B -e"
183 if [ -n "$USE_PROZILLA" ]; then
184 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
187 elif [ -n "$USE_AXEL" ]; then
188 GETURI="axel -a $AXEL_OPTS"
192 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
193 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
194 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
195 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
197 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
198 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
204 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
215 if [ -d $HOME/rpm/SOURCES ]; then
216 echo "ERROR: ~/rpm/{SPECS,SOURCES} structure is obsolete" >&2
217 echo "ERROR: get rid of your ~/rpm/SOURCES" >&2
221 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
222 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
226 if [ -n "$LOGFILE" ]; then
227 LOG=`eval echo $LOGFILE`
228 if [ -n "$LASTLOG_FILE" ]; then
229 echo "LASTLOG=$LOG" > $LASTLOG_FILE
231 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
234 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
235 return `cat ${RES_FILE}`
240 #---------------------------------------------
244 if [ -n "$DEBUG" ]; then set -xv; fi
246 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--add_cvs] [-b|-ba|--build]
247 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
248 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [--depth <number>]
249 [-g|--get] [-h|--help] [--ftp] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
250 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
251 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
252 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
253 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
254 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
255 <package>[.spec][:cvstag]
257 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
258 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
259 -n5, --no-md5 - ignore md5 comments in spec
260 -D, --debug - enable builder script debugging mode,
261 -debug - produce rpm debug package (same as --opts -debug)
262 -V, --version - output builder version string
263 --short-version - output builder short version
264 -a, --add_cvs - try add new package to CVS.
265 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
267 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
268 only package from <package>.spec,
269 -bp, --build-prep - execute the %prep phase of <package>.spec,
270 -bc - execute the %build phase of <package>.spec,
271 -bi - execute the %install phase of <package>.spec
272 -bl - execute the %files phase of <package>.spec
273 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
275 --short-circuit - short-circuit build
276 -B, --branch - add branch
277 -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
278 may be used with building process.
279 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
280 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
282 -cf, --cvs-force - use -F when tagging (useful when moving branches)
283 --define <macro> <value>
284 - define a macro <macro> with value <value>,
287 --alt_kernel <kernel>
288 - same as --define 'alt_kernel <kernel>'
289 --nodeps - rpm won't check any dependences
290 -g, --get - get <package>.spec and all related files from CVS repo
292 -h, --help - this message,
293 -jN, -j N - set %_smp_mflags to propagate concurrent jobs
294 --ftp, --http - use ftp or http protocol to access distfiles server
295 -l <logfile>, --logtofile <logfile>
298 - don't check specs in CVS
299 -nd, --no-distfiles - don't download from distfiles
300 -nm, --no-mirrors - don't download from mirror, if source URL is given,
301 -nu, --no-urls - don't try to download from FTP/HTTP location,
302 -ns, --no-srcs - don't download Sources/Patches
303 -ns0, --no-source0 - don't download Source0
304 -nn, --no-net - don't download anything from the net
305 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
306 --no-init - don't initialize builder paths (SPECS and SOURCES)
308 --skip-existing-files - skip existing files in get_files
309 --opts <rpm opts> - additional options for rpm
310 -q, --quiet - be quiet,
311 --date yyyy-mm-dd - build package using resources from specified CVS date,
312 -r <cvstag>, --cvstag <cvstag>
313 - build package using resources from specified CVS tag,
314 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
315 -R, --fetch-build-requires
316 - fetch what is BuildRequired,
317 -RB, --remove-build-requires
318 - remove all you fetched with -R or --fetch-build-requires
319 remember, this option requires confirmation,
320 -FRB, --force-remove-build-requires
321 - remove all you fetched with -R or --fetch-build-requires
322 remember, this option works without confirmation,
323 -sd, --source-distfiles - list sources available from distfiles (intended for offline
324 operations; does not work when Icon field is present
325 but icon file is absent),
326 -sc, --source-cvs - list sources available from CVS
327 -sdp, --source-distfiles-paths - list sources available from distfiles -
328 paths relative to distfiles directory (intended for offline
329 operations; does not work when Icon field is present
330 but icon file is absent),
331 -sf, --source-files - list sources - bare filenames (intended for offline
332 operations; does not work when Icon field is present
333 but icon file is absent),
334 -lsp, --source-paths - list sources - filenames with full local paths (intended for
335 offline operations; does not work when Icon field is present
336 but icon file is absent),
337 -su, --source-urls - list urls - urls to sources and patches
338 intended for copying urls with spec with lots of macros in urls
339 -T <cvstag> , --tag <cvstag>
340 - add cvs tag <cvstag> for files,
341 -Tvs, --tag-version-stable
342 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
344 - add cvs tag STABLE for files,
346 - add cvs tag NAME-VERSION-RELEASE for files,
347 -Tp, --tag-prefix <prefix>
348 - add <prefix> to NAME-VERSION-RELEASE tags,
349 -tt, --test-tag <prefix>
350 - fail if tag is already present,
351 -ir, --integer-release-only
352 - allow only integer and snapshot releases
353 -v, --verbose - be verbose,
354 -u, --try-upgrade - check version, and try to upgrade package
355 -un, --try-upgrade-with-float-version
356 - as above, but allow float version
357 php-pear-Services_Digg/
358 --upgrade-version - upgrade to specified version in try-upgrade
359 -U, --update - refetch sources, don't use distfiles, and update md5 comments
360 -Upi, --update-poldek-indexes
361 - refresh or make poldek package index files.
362 -sp, --skip-patch <patchnumber>
363 - don't apply <patchnumber>. may be repeated.
364 -np, --nopatch <patchnumber>
365 - abort instead of applying patch <patchnumber>
366 --show-bconds - show available conditional builds, which can be used
367 - with --with and/or --without switches.
368 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
369 ./repackage.sh script. in other words, the output is
370 parseable by scripts.
371 --show-avail-bconds - show available bconds
372 --with/--without <feature>
373 - conditional build package depending on %_with_<feature>/
374 %_without_<feature> macro switch. You may now use
375 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
376 constructions. Set GROUP_BCONDS to yes to make use of it.
377 --target <platform>, --target=<platform>
378 - build for platform <platform>.
379 --init-rpm-dir - initialize ~/rpm directory structure
383 # create tempfile. as secure as possible
385 mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$
388 # inserts git log instead of %changelog
389 # outputs name of modified file created by tempfile
391 local SPECFILE=$1 specfile=$(tempfile) gitlog=$(tempfile) speclog=$(tempfile)
393 # allow this being customized
394 local log_entries=$(rpm -E '%{?_buildchangelogtruncate}')
396 # rpm5.org/rpm.org do not parse any other date format than 'Wed Jan 1 1997'
397 # otherwise i'd use --date=iso here
398 # http://rpm5.org/cvs/fileview?f=rpm/build/parseChangelog.c&v=2.44.2.1
399 # http://rpm.org/gitweb?p=rpm.git;a=blob;f=build/parseChangelog.c#l31
400 # NOTE: changelog date is always in UTC for rpmbuild
401 # * 1265749244 +0000 Random Hacker <nikt@pld-linux.org> 9370900
402 git log -${log_entries:-20} --format=format:"* %ad %an <%ae> %h%n%s%n" --date=raw > $gitlog
403 gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog > $speclog
404 sed '/^%changelog/,$d' $SPECFILE | sed -e "\${
409 rm -f $gitlog $speclog
413 # change dependency to specname
415 # - perl(Package::Name) -> perl-Package-Name
419 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
423 update_shell_title() {
425 local len=${COLUMNS:-80}
426 local msg="$(echo "$*" | cut -c-$len)"
428 if [ -n "$BE_VERBOSE" ]; then
429 echo >&2 "$(date +%s.%N) $*"
432 if [ "x$TITLECHANGE" = "xyes" -o "x$TITLECHANGE" = "x" ]; then
434 if [ -n "$PACKAGE_NAME" ]; then
435 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
440 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
441 msg=$(echo $msg | tr -d '\n\r')
444 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
447 echo >&2 -ne "\033]0;$msg\007"
453 # set TARGET from BuildArch: from SPECFILE
455 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
456 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
458 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
462 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
464 TARGET_SWITCH="--target=$TARGET" ;;
470 # runs rpm with minimal macroset
472 # we reset macros not to contain macros.build as all the %() macros are
473 # executed here, while none of them are actually needed.
474 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
475 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
477 # TODO: move these to /usr/lib/rpm/macros
478 cat > $BUILDER_MACROS <<'EOF'
479 %x8664 x86_64 amd64 ia32e
482 %bootstrap_release() %{1}
483 %requires_releq_kernel_up(s:n:) %{nil}
484 %requires_releq_kernel_smp(s:n:) %{nil}
485 %requires_releq_kernel(s:n:) %{nil}
486 %requires_releq() %{nil}
487 %pyrequires_eq() %{nil}
488 %requires_eq() %{nil}
489 %requires_eq_to() %{nil}
490 %requires_ge() %{nil}
491 %requires_ge_to() %{nil}
492 %requires_ge() %{nil}
493 %releq_kernel_up(n:) ERROR
494 %releq_kernel_smp(n:) ERROR
495 %releq_kernel(n:) ERROR
499 %ruby_ver_requires_eq() %{nil}
500 %ruby_mod_ver_requires_eq() %{nil}
501 %__php_api_requires() %{nil}
502 %php_major_version ERROR
503 %php_api_version ERROR
504 %requires_xorg_xserver_extension %{nil}
505 %requires_xorg_xserver_xinput %{nil}
506 %requires_xorg_xserver_font %{nil}
507 %requires_xorg_xserver_videodrv %{nil}
509 %perl_vendorarch ERROR
510 %perl_vendorlib ERROR
511 # damn. need it here! - copied from /usr/lib/rpm/macros.build
512 %tmpdir %(echo "${TMPDIR:-/tmp}")
513 %patchset_source(f:b:) %(
514 base=%{-b*}%{!-b*:10000};
515 start=$(expr $base + %1);
516 end=$(expr $base + %{?2}%{!?2:%{1}});
517 # we need to call seq twice as it doesn't allow two formats
518 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
519 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
520 paste %{tmpdir}/__ps{1,2};
521 rm -f %{tmpdir}/__ps{1,2};
524 %add_etc_shells(p) %{p:<lua>}
525 %remove_etc_shells(p) %{p:<lua>}
526 %lua_add_etc_shells() %{nil}
527 %lua_remove_etc_shells() %{nil}
529 %buildrequires_jdk %{nil}
530 %pear_package_print_optionalpackages %{nil}
532 if [ "$NOINIT" = "yes" ] ; then
533 cat >> $BUILDER_MACROS <<'EOF'
538 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
542 if [ -n "$DEBUG" ]; then
547 if [ -x /usr/bin/rpm-specdump ]; then
548 update_shell_title "cache_rpm_dump using rpm-specdump command"
549 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
551 update_shell_title "cache_rpm_dump using rpmbuild command"
554 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
555 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
561 ARGS='--nodigest --nosignature --nobuild'
564 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
566 if [ $? -gt 0 ]; then
567 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
569 Exit_error err_build_fail
572 # make small dump cache
573 rpm_dump_cache=`echo "$rpm_dump" | awk '
574 $2 ~ /^SOURCEURL/ {print}
575 $2 ~ /^PATCHURL/ {print}
576 $2 ~ /^nosource/ {print}
577 $2 ~ /^PACKAGE_/ {print}
581 update_shell_title "cache_rpm_dump: OK!"
585 if [ -z "$rpm_dump_cache" ] ; then
586 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
588 echo "$rpm_dump_cache"
592 update_shell_title "get icons"
593 ICONS=$(awk '/^Icon:/ {print $2}' $PACKAGE_DIR/${SPECFILE})
594 if [ -z "$ICONS" ]; then
598 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
602 update_shell_title "parsing specfile"
603 if [ -n "$DEBUG" ]; then
608 # icons are needed for successful spec parse
614 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
615 FAIL_IF_NO_SOURCES="no"
618 if [ "$NOSRCS" != "yes" ]; then
619 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
620 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
621 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
624 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
625 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
626 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
628 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
629 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
632 if [ -n "$BE_VERBOSE" ]; then
633 echo "- Sources : `nourl $SOURCES`"
634 if [ -n "$PATCHES" ]; then
635 echo "- Patches : `nourl $PATCHES`"
637 echo "- Patches : *no patches needed*"
639 if [ -n "$ICONS" ]; then
640 echo "- Icon : `nourl $ICONS`"
642 echo "- Icon : *no package icon*"
644 echo "- Name : $PACKAGE_NAME"
645 echo "- Version : $PACKAGE_VERSION"
646 echo "- Release : $PACKAGE_RELEASE"
649 update_shell_title "parse_spec: OK!"
653 if [ -n "$DEBUG" ]; then
661 "err_no_spec_in_cmdl" )
662 remove_build_requires
663 echo >&2 "ERROR: spec file name not specified."
665 "err_invalid_cmdline" )
666 echo >&2 "ERROR: invalid command line arg ($2)."
668 "err_no_spec_in_repo" )
669 remove_build_requires
670 echo >&2 "Error: spec file not stored in CVS repo."
672 "err_no_source_in_repo" )
673 remove_build_requires
674 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
676 "err_cvs_add_failed" )
677 echo >&2 "Error: failed to add package to CVS repo."
680 remove_build_requires
681 echo >&2 "Error: package build failed. (${2:-no more info})"
683 "err_no_package_data" )
684 remove_build_requires
685 echo >&2 "Error: couldn't get out package name/version/release from spec file."
688 remove_build_requires
689 echo >&2 "Tag ${2} already exists (spec release: ${3})."
692 remove_build_requires
693 echo >&2 "Release ${2} not integer and not a snapshot."
695 "err_branch_exists" )
696 remove_build_requires
697 echo >&2 "Tree branch already exists (${2})."
700 remove_build_requires
701 echo >&2 "Error: conditions reject building this spec (${2})."
703 "err_not_implemented" )
704 remove_build_requires
705 echo >&2 "Error: functionality not yet imlemented"
708 echo >&2 "Unknown error."
713 if [ -n "$DEBUG" ]; then
718 if [ "$NOINIT" != "yes" ] ; then
719 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
721 local macros_ver=$(rpm -E %?rpm_build_macros)
722 if [ -z "$macros_ver" ]; then
723 REPO_DIR=$TOP_DIR/packages
724 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
726 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
727 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
731 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
737 export GIT_WORK_TREE=$PACKAGE_DIR
738 export GIT_DIR=$PACKAGE_DIR/.git
745 update_shell_title "get_spec"
747 if [ -n "$DEBUG" ]; then
753 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
755 SPECFILE=$(basename $SPECFILE)
758 if [ "$NOCVSSPEC" != "yes" ]; then
759 if [ -z "$DEPTH" ]; then
760 if [ -d "$ASSUMED_NAME/.git" ]; then
761 git fetch origin || Exit_error err_no_spec_in_repo
762 elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then
763 if [ ! -r "$ASSUMED_NAME/$SPECFILE" ]; then
764 echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
767 Exit_error err_not_implemented
771 git clone ${GIT_SERVER}/${ASSUMED_NAME}.git || {
772 # softfail if new package, i.e not yet added to cvs
773 [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
774 echo "Warning: package not in CVS - assuming new package"
780 if [ ! -d "$ASSUMED_NAME/.git" ]; then
781 if [ ! -d "$ASSUMED_NAME" ]; then
785 git remote add origin ${GIT_SERVER}/${ASSUMED_NAME}.git
787 git fetch "$DEPTH" origin ${CVSTAG}:remotes/origin/${CVSTAG} || {
788 echo >&2 "Error: branch $CVSTAG does not exist"
793 cvsignore_df .gitignore
795 # add default log format to .cvsignore if it is relative to package dir
796 if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then
797 # substitute known "macros" to glob
798 local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\),*,g')
799 if [ "$logfile" ]; then
800 cvsignore_df "$logfile"
804 # create symlinks for tools
805 if [ "$SYMLINK_TOOLS" != "no" ]; then
806 for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do
807 [ -f $a ] || continue
808 ln -sf ../$a $ASSUMED_NAME
814 if [ -n "$CVSTAG" ]; then
815 git checkout "$CVSTAG" -- 2>/dev/null || git checkout -t "origin/$CVSTAG" > /dev/null || exit
816 git symbolic-ref -q HEAD > /dev/null &&
818 if [ -n "$CVSDATE" ]; then
819 git checkout $(git rev-list -n1 --before="'$CVSDATE'" $CVSTAG) || exit 1
823 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
824 Exit_error err_no_spec_in_repo
827 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
828 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
831 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
839 if [ ! -f "mirrors" ] ; then
840 ln -s rpm-build-toos/mirrors .
844 local origin mirror name rest ol prefix
845 while read origin mirror name rest; do
846 # skip comments and empty lines
847 if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then
850 ol=$(echo -n "$origin" | wc -c)
851 prefix=$(echo -n "$url" | head -c $ol)
852 if [ "$prefix" = "$origin" ] ; then
853 suffix=$(echo "$url" | cut -b $((ol+1))-)
854 echo -n "$mirror$suffix"
861 # Warning: unpredictable results if same URL used twice
865 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
866 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
871 [ "$NO5" = "yes" ] && return
873 [ -z "$no" ] && return
877 if [ -f additional-md5sums ]; then
878 md5=$(grep -s -v '^#' additional-md5sums | \
879 grep -E "[ ]$(basename "$1")([ ,]|\$)" | \
880 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
881 grep -E '^[0-9a-f]{32}$')
884 if [ $(echo "$md5" | wc -l) != 1 ] ; then
885 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
887 echo "$md5" | tail -n 1
892 source_md5=`grep -i "^#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
893 if [ -n "$source_md5" ]; then
896 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
897 if [ -n "$source_md5" ]; then
900 # we have empty SourceX-md5, but it is still possible
901 # that we have NoSourceX-md5 AND NoSource: X
902 nosource_md5=`grep -i "^#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
903 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
911 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
915 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
918 distfiles_attic_url() {
919 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
925 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
929 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
930 [ -n "$size" -a "$size" -gt 0 ]
934 if [ "$CVSIGNORE_DF" != "yes" ]; then
937 cvsignore=${PACKAGE_DIR}/.gitignore
939 # add only if not yet there
940 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
941 echo "$1" >> $cvsignore
945 # returns true if "$1" is ftp, http or https protocol url
948 ftp://*|http://*|https://*)
956 if [ $# -eq 0 ]; then
960 update_shell_title "update md5"
961 if [ -n "$DEBUG" ]; then
968 # pass 1: check files to be fetched
972 local fp=$(nourl "$i")
973 local srcno=$(src_no "$i")
974 if [ -n "$ADD5" ]; then
975 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
976 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
977 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
979 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
981 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
982 need_files="$need_files $i"
986 # pass 1a: get needed files
987 if [ "$need_files" ]; then
988 get_files $need_files
991 # pass 2: proceed with md5 adding or updating
993 local fp=$(nourl "$i")
994 local srcno=$(src_no "$i")
995 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
996 if [ -z "$md5" ]; then
997 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
999 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
1000 local tag="# Source$srcno-md5:\t"
1001 if [[ "$md5" == *NoSource* ]]; then
1002 tag="# NoSource$srcno-md5:\t"
1003 elif [ -n "$USEDIGEST" ]; then
1004 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
1006 md5=$(md5sum "$fp" | cut -f1 -d' ')
1007 echo "Updating Source$srcno ($md5: $fp)."
1009 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
1010 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
1012 $PACKAGE_DIR/$SPECFILE
1019 [ "$NO5" = "yes" ] && return
1021 update_shell_title "check md5"
1025 if ! good_md5 "$i"; then
1026 echo -n "MD5 sum mismatch."
1029 if ! good_size "$i"; then
1030 echo -n "0 sized file."
1034 if [ $bad -eq 1 ]; then
1035 echo " Use -U to refetch sources,"
1036 echo "or -5 to update md5 sums, if you're sure files are correct."
1037 Exit_error err_no_source_in_repo $i
1043 update_shell_title "get_files"
1045 if [ -n "$DEBUG" ]; then
1050 if [ $# -gt 0 ]; then
1054 local get_files_cvs=""
1058 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1059 update_shell_title "$i"
1060 local fp=`nourl "$i"`
1061 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1066 local srcmd5=$(src_md5 "$i")
1068 # we know if source/patch is present in cvs/distfiles
1069 # - has md5 (in distfiles)
1070 # - in cvs... ideas?
1072 # CHECK: local file didn't exist or always cvs up (first) requested.
1073 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1074 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1075 echo "Warning: no URL given for $i"
1079 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1080 if good_md5 "$i" && good_size "$i"; then
1081 echo "$fp having proper md5sum already exists"
1085 # optionally prefer mirror over distfiles if there's mirror
1086 # TODO: build url list and then try each url from the list
1087 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1090 url=$(distfiles_url "$i")
1093 url_attic=$(distfiles_attic_url "$i")
1095 # is $url local file?
1096 if [[ "$url" = [./]* ]]; then
1097 update_shell_title "${GETLOCAL%% *}: $url"
1098 ${GETLOCAL} $url $target
1100 if [ -z "$NOMIRRORS" ]; then
1101 url=$(find_mirror "$url")
1105 # make shorter message for distfiles urls
1106 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1107 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1108 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1111 update_shell_title "${GETURI%% *}: $uri"
1112 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1113 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1114 update_shell_title "${GETURI2%% *}: $url"
1115 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1120 if [ ! -s "$target" ]; then
1122 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1123 update_shell_title "${GETLOCAL%% *}: $url_attic"
1124 ${GETLOCAL} $url_attic $target
1126 if [ -z "$NOMIRRORS" ]; then
1127 url_attic=$(find_mirror "$url_attic")
1129 update_shell_title "${GETURI%% *}: $url_attic"
1130 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1131 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1132 update_shell_title "${GETURI2%% *}: $url_attic"
1133 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1135 test -s "$target" || rm -f "$target"
1139 if [ -s "$target" ]; then
1140 cvsignore_df $target
1147 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1148 if [ -z "$NOMIRRORS" ]; then
1149 im=$(find_mirror "$i")
1153 update_shell_title "${GETURI%% *}: $im"
1154 ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
1155 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1156 update_shell_title "${GETURI2%% *}: $im"
1157 ${GETURI2} "$im" ${OUTFILEOPT} "$target"
1159 test -s "$target" || rm -f "$target"
1162 if [ "$cvsup" = 1 ]; then
1168 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1169 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1170 Exit_error err_no_source_in_repo $i
1173 # we check md5 here just only to refetch immediately
1174 if good_md5 "$i" && good_size "$i"; then
1176 elif [ "$FROM_DISTFILES" = 1 ]; then
1177 # wrong md5 from distfiles: remove the file and try again
1179 echo "MD5 sum mismatch. Trying full fetch."
1182 update_shell_title "${GETURI%% *}: $url"
1183 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1184 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1185 update_shell_title "${GETURI2%% *}: $url"
1186 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1188 if [ ! -s "$target" ]; then
1190 update_shell_title "${GETURI%% *}: $url_attic"
1191 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1192 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1193 update_shell_title "${GETURI2%% *}: $url_attic"
1194 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1197 test -s "$target" || rm -f "$target"
1200 SHELL_TITLE_PREFIX=""
1203 if [ "$CHMOD" = "yes" ]; then
1204 CHMOD_FILES=$(nourl "$@")
1205 if [ -n "$CHMOD_FILES" ]; then
1206 chmod $CHMOD_MODE $CHMOD_FILES
1213 if [ -n "$DEBUG" ]; then
1218 # Check whether first character of PACKAGE_NAME is legal for tag name
1219 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1223 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1224 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1226 # Remove #kernel.version_release from TAGVER because tagging sources
1227 # could occur with different kernel-headers than kernel-headers used at build time.
1228 # besides, %{_kernel_ver_str} is not expanded.
1230 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1231 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1240 if [ -n "$DEBUG" ]; then
1245 echo "Version: $PACKAGE_VERSION"
1246 echo "Release: $PACKAGE_RELEASE"
1249 if [ "$TAG_VERSION" = "yes" ]; then
1250 TAGVER=`make_tagver`
1253 if [ -n "$TAG" ]; then
1257 local OPTIONS="tag $CVS_FORCE"
1260 if [ "$TAG_VERSION" = "yes" ]; then
1266 if [ "$TAG_VERSION" = "yes" ]; then
1267 update_shell_title "tag sources: $TAGVER"
1268 git $OPTIONS $TAGVER || exit
1270 if [ -n "$TAG" ]; then
1271 update_shell_title "tag sources: $TAG"
1272 git $OPTIONS $TAG $chunk || exit
1278 echo "Git branch: $TAG"
1281 if [ -n "$DEBUG" ]; then
1286 local OPTIONS="branch $CVS_FORCE"
1289 git $OPTIONS $TAG || exit
1293 # this function should exit early if package can't be built for this arch
1294 # this avoids unneccessary BR filling.
1297 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1299 if [ $ret -ne 0 ]; then
1311 s/^\(%define[ \t]\+_\?rel[ \t]\+\)$rel\$/\1$newrel/
1312 s/^\(Release:[ \t]\+\)$rel\$/\1$newrel/
1318 local ver="$2" subver=$ver
1319 local newver="$3" newsubver=$newver
1321 # try handling subver, everything that's not numeric-dotted in version
1322 if grep -Eq '%define\s+subver' $specfile; then
1323 subver=$(echo "$ver" | sed -re 's,^[0-9.]+,,')
1325 newsubver=$(echo "$newver" | sed -re 's,^[0-9.]+,,')
1326 newver=${newver%$newsubver}
1329 s/^\(%define[ \t]\+_\?ver[ \t]\+\)$ver\$/\1$newver/
1330 s/^\(%define[ \t]\+subver[ \t]\+\)$subver\$/\1$newsubver/
1331 s/^\(Version:[ \t]\+\)$ver\$/\1$newver/
1336 if [ -n "$TRY_UPGRADE" ]; then
1337 local TNOTIFY TNEWVER TOLDVER
1338 update_shell_title "build_package: try_upgrade"
1342 if [ "$UPGRADE_VERSION" ]; then
1343 TNEWVER=$UPGRADE_VERSION
1345 if [ -n "$FLOAT_VERSION" ]; then
1346 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
1348 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
1351 # pldnotify.awk does not set exit codes, but it has match for ERROR
1352 # in output which means so.
1353 if [[ "$TNOTIFY" = *ERROR* ]]; then
1358 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1361 if [ -n "$TNEWVER" ]; then
1362 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1363 echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
1364 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1365 cp -f $SPECFILE $SPECFILE.bak
1368 set_release $SPECFILE $PACKAGE_RELEASE 1
1369 set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
1371 if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
1372 echo >&2 "Upgrading version failed, you need to update spec yourself"
1382 update_shell_title "build_package"
1383 if [ -n "$DEBUG" ]; then
1392 BUILD_SWITCH="-ba" ;;
1394 BUILD_SWITCH="-bb" ;;
1396 BUILD_SWITCH="-bs --nodeps" ;;
1398 BUILD_SWITCH="-bp --nodeps" ;;
1400 BUILD_SWITCH="-bc" ;;
1402 BUILD_SWITCH="-bi" ;;
1404 BUILD_SWITCH="-bl" ;;
1408 update_shell_title "build_package: $COMMAND"
1409 if [ -n "$LOGFILE" ]; then
1410 LOG=`eval echo $LOGFILE`
1411 if [ -d "$LOG" ]; then
1412 echo "Log file $LOG is a directory."
1413 echo "Parse error in the spec?"
1414 Exit_error err_build_fail
1416 if [ -n "$LASTLOG_FILE" ]; then
1417 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1419 RES_FILE=$(tempfile)
1420 local specfile=$(insert_gitlog $SPECFILE)
1422 (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
1423 RETVAL=`cat $RES_FILE`
1424 rm $RES_FILE $specfile
1425 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1426 if [ "$RETVAL" -eq "0" ]; then
1433 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1436 if [ "$RETVAL" -ne "0" ]; then
1437 if [ -n "$TRY_UPGRADE" ]; then
1438 echo "\nUpgrade package to new version failed."
1439 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1440 echo "Restoring old spec file."
1441 mv -f $SPECFILE.bak $SPECFILE
1445 Exit_error err_build_fail
1451 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1454 install_required_packages() {
1459 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1462 /^%changelog/ { exit }
1464 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1465 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1466 gsub(/[ \t]+/, "_", bcond);
1468 }' $SPEC | LC_ALL=C sort -u
1472 # expand bconds from ~/.bcondrc
1473 # The file structure is like gentoo's package.use:
1476 # samba -mysql -pgsql
1477 # w32codec-installer license_agreement
1480 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1486 SN=${SPECFILE%%\.spec}
1488 local bcondrc=$HOME/.bcondrc
1489 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1491 local bcond_avail=$(find_spec_bcond $SPECFILE)
1493 while read pkg flags; do
1495 [[ "$pkg" == \#* ]] && continue
1497 # any package or current package?
1498 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1499 for flag in $flags; do
1500 local opt=${flag#[+-]}
1502 # use only flags which are in this package.
1503 if [[ $bcond_avail = *${opt}* ]]; then
1504 if [[ $flag = -* ]]; then
1505 if [[ $BCOND != *--with?${opt}* ]]; then
1506 BCOND="$BCOND --without $opt"
1509 if [[ $BCOND != *--without?${opt}* ]]; then
1510 BCOND="$BCOND --with $opt"
1517 update_shell_title "parse ~/.bcondrc: DONE!"
1520 set_bconds_values() {
1521 update_shell_title "set bcond values"
1523 AVAIL_BCONDS_WITHOUT=""
1524 AVAIL_BCONDS_WITH=""
1526 if grep -Eq '^# *_with' ${SPECFILE}; then
1527 echo >&2 "ERROR: This spec has old style bconds."
1531 if ! grep -q '^%bcond' ${SPECFILE}; then
1535 local bcond_avail=$(find_spec_bcond $SPECFILE)
1536 process_bcondrc "$SPECFILE"
1538 update_shell_title "parse bconds"
1541 for opt in $bcond_avail; do
1544 bcond=${opt#without_}
1546 *--without?${bcond}*)
1547 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1550 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1558 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1561 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1566 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1575 update_shell_title "run_sub_builder $package_name"
1577 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1578 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1579 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1580 # jakby nie bylo tego kawalka kodu.
1582 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1583 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1587 # kurwa. translate that ^^^^
1591 # Istnieje taki spec? ${package}.spec
1592 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1593 parent_spec_name=${package}.spec
1594 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1595 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1597 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1602 if [ "${parent_spec_name}" != "" ]; then
1603 spawn_sub_builder $parent_spec_name
1605 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1608 spawn_sub_builder() {
1610 update_shell_title "spawn_sub_builder $package_name"
1613 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1614 sub_builder_opts="${sub_builder_opts} -R"
1616 if [ "${REMOVE_BUILD_REQUIRES}" = "nice" ]; then
1617 sub_builder_opts="${sub_builder_opts} -RB"
1618 elif [ "${REMOVE_BUILD_REQUIRES}" = "force" ]; then
1619 sub_builder_opts="${sub_builder_opts} -FRB"
1621 if [ "${UPDATE_POLDEK_INDEXES}" = "yes" ]; then
1622 sub_builder_opts="${sub_builder_opts} -Upi"
1626 ./builder ${sub_builder_opts} "$@"
1629 remove_build_requires() {
1630 if [ "$INSTALLED_PACKAGES" != "" ]; then
1631 case "$REMOVE_BUILD_REQUIRES" in
1633 run_poldek --noask -ve $INSTALLED_PACKAGES
1636 run_poldek --ask -ve $INSTALLED_PACKAGES
1639 echo You may want to manually remove following BuildRequires fetched:
1640 echo $INSTALLED_PACKAGES
1641 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1648 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1649 if [ "$BCOND" ]; then
1651 echo "Building $SPECFILE with the following conditional flags:"
1655 echo "No conditional flags passed"
1658 echo "from available:"
1659 echo "--with :\t$AVAIL_BCONDS_WITH"
1660 echo "--without:\t$AVAIL_BCONDS_WITHOUT"
1665 display_branches() {
1666 if [ "$NOCVSSPEC" != "yes" ]; then
1667 echo -n "Available branches: "
1668 git branch -r | grep '^ origin' | grep -v origin/HEAD | sed 's#^ *origin/##' | xargs
1672 # checks a given list of packages/files/provides agains current rpmdb.
1673 # outputs all dependencies which current rpmdb doesn't satisfy.
1674 # input can be either STDIN or parameters
1678 if [ $# -gt 0 ]; then
1684 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1687 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1689 # other deps (files)
1690 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1693 # checks if given package/files/provides exists in rpmdb.
1694 # input can be either stdin or parameters
1695 # returns packages which are present in the rpmdb
1699 if [ $# -gt 0 ]; then
1705 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1708 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1709 install_build_requires_rpmdeps() {
1710 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1711 # TODO: Conflicts list doesn't check versions
1712 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1713 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1715 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1716 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1717 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1720 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1721 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1722 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1723 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1725 if [ -n "$CNFL" ]; then
1726 update_shell_title "uninstall conflicting packages: $CNFL"
1727 echo "Trying to uninstall conflicting packages ($CNFL):"
1728 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1731 while [ "$DEPS" ]; do
1732 update_shell_title "install deps: $DEPS"
1733 echo "Trying to install dependencies ($DEPS):"
1734 local log=.${SPECFILE}_poldek.log
1735 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1736 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1739 if [ -n "$failed" ]; then
1740 for package in $failed; do
1741 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1750 fetch_build_requires()
1752 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1756 update_shell_title "fetch build requires"
1757 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1758 install_build_requires_rpmdeps
1762 # XXX is this ugliest code written in human history still needed?
1763 echo "All packages installed by fetch_build_requires() are written to:"
1764 echo "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1766 echo "If anything fails, you may get rid of them by executing:"
1767 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`"
1769 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1770 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)
1772 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)
1774 package=$(basename "$package_item"|sed -e "s/}$//g")
1775 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1778 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1779 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1780 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
1785 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1788 if `echo $COND_TST|grep -q 'without_'`; then
1789 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1790 if `echo $COND_TST|grep -q !`; then
1795 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1796 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1797 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1803 elif `echo $COND_TST|grep -q 'with_'`; then
1804 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1805 if `echo $COND_TST|grep -q !`; then
1810 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1811 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1812 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1818 RESULT="${COND_STATE}-${COND_ARGV}"
1820 "with-wout" | "wout-with" )
1823 "wout-wout" | "with-with" )
1827 echo "Action '$RESULT' was not defined for package '$package_item'"
1833 if [ "$GO" = "yes" ]; then
1834 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1835 echo "Testing if $package has subrequirements..."
1836 run_poldek -t -i $package --dumpn=".$package-req.txt"
1837 if [ -f ".$package-req.txt" ]; then
1838 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1840 if [ "$package_name" = "$package" ]; then
1841 echo "Installing BuildRequired package:\t$package_name"
1842 update_shell_title "Installing BuildRequired package: ${package_name}"
1843 install_required_packages $package
1845 echo "Installing (sub)Required package:\t$package_name"
1846 update_shell_title "Installing (sub)Required package: ${package_name}"
1847 install_required_packages $package_name
1851 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1852 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1855 echo "Attempting to run spawn sub - builder..."
1856 echo "Package installation failed:\t$package_name"
1857 run_sub_builder $package_name
1858 if [ $? -eq 0 ]; then
1859 install_required_packages $package_name
1862 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1863 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1866 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1873 rm -f ".$package-req.txt"
1875 echo "Attempting to run spawn sub - builder..."
1876 echo "Package installation failed:\t$package"
1877 run_sub_builder $package
1878 if [ $? -eq 0 ]; then
1879 install_required_packages $package
1882 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1883 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1886 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1892 echo "Package $package is already installed. BuildRequirement satisfied."
1896 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1897 echo >&2 "Unable to install following packages and their dependencies:"
1898 for pkg in "$NOT_INSTALLED_PACKAGES"
1902 remove_build_requires
1908 local TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1909 local rpmdir=$(eval $RPM $RPMOPTS --eval '%{_rpmdir}')
1910 local buildir=$(eval $RPM $RPMOPTS --eval '%{_builddir}')
1911 local srpmdir=$(eval $RPM $RPMOPTS --eval '%{_srcrpmdir}')
1914 echo "Initializing rpm directories to $TOP_DIR from $GIT_SERVER"
1915 mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
1917 GIT_WORK_TREE=${TOP_DIR}/rpm-build-tools git clone ${GIT_SERVER}/rpm-build-tools.git ||
1918 for a in dropin md5 adapter builder mirrors {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do
1919 ln -s rpm-build-tools/$a .
1927 DONT_PRINT_REVISION="yes"
1931 # remove spec and sources
1932 $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $SPECFILE
1933 rm -rf $PACKAGE_DIR/.git .gitignore
1935 rmdir --ignore-fail-on-non-empty $PACKAGE_DIR
1938 #---------------------------------------------
1946 while [ $# -gt 0 ]; do
1949 COMMAND="update_md5"
1954 COMMAND="update_md5"
1963 DEBUG="yes"; shift ;;
1965 COMMAND="version"; shift ;;
1967 COMMAND="short-version"; shift ;;
1971 -b | -ba | --build )
1972 COMMAND="build"; shift ;;
1973 -bb | --build-binary )
1974 COMMAND="build-binary"; shift ;;
1976 COMMAND="build-build"; shift ;;
1978 COMMAND="build-install"; shift ;;
1980 COMMAND="build-list"; shift ;;
1981 -bp | --build-prep )
1982 COMMAND="build-prep"; shift ;;
1983 -bs | --build-source )
1984 COMMAND="build-source"; shift ;;
1986 COMMAND="branch"; shift; TAG="${1}"; shift;;
1988 CLEAN="--clean"; shift ;;
1990 CVS_FORCE="-f"; shift;;
1996 COMMAND="get"; shift ;;
1998 COMMAND="usage"; shift ;;
2000 PROTOCOL="ftp"; shift ;;
2002 PROTOCOL="http"; shift ;;
2004 RPMOPTS="${RPMOPTS} --define \"_smp_mflags -j$2\""
2008 RPMOPTS="${RPMOPTS} --define \"_smp_mflags $1\""
2012 shift; LOGFILE="${1}"; shift ;;
2014 shift; DEF_NICE_LEVEL=${1}; shift ;;
2015 -ske | --skip-existing-files)
2016 SKIP_EXISTING_FILES="yes"; shift ;;
2018 COMMAND="mr-proper"; shift ;;
2019 -ncs | --no-cvs-specs )
2020 NOCVSSPEC="yes"; shift ;;
2021 -nd | --no-distfiles )
2022 NODIST="yes"; shift ;;
2023 -nm | --no-mirrors )
2024 NOMIRRORS="yes"; shift ;;
2026 NOURLS="yes"; shift ;;
2028 NOSRCS="yes"; shift ;;
2029 -ns0 | --no-source0 )
2030 NOSOURCE0="yes"; shift ;;
2039 -pm | --prefer-mirrors )
2046 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2048 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2049 --skip-patch | -sp )
2050 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : skiping patch${1}\""; shift ;;
2052 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2055 --with | --without )
2056 case $GROUP_BCONDS in
2060 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2061 while ! `echo ${1}|grep -qE '(^-|spec)'`
2063 BCOND="$BCOND $COND $1"
2067 if [[ "$2" = *,* ]]; then
2068 for a in $(echo "$2" | tr , ' '); do
2069 BCOND="$BCOND $1 $a"
2072 BCOND="$BCOND $1 $2"
2078 shift; TARGET="${1}"; shift ;;
2080 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2082 QUIET="--quiet"; shift ;;
2084 CVSDATE="${2}"; shift 2
2085 date -d "$CVSDATE" > /dev/null 2>&1 || { echo >&2 "No valid date specified"; exit 3; }
2095 -R | --fetch-build-requires)
2096 FETCH_BUILD_REQUIRES="yes"
2097 NOT_INSTALLED_PACKAGES=
2099 -RB | --remove-build-requires)
2100 REMOVE_BUILD_REQUIRES="nice"
2102 -FRB | --force-remove-build-requires)
2103 REMOVE_BUILD_REQUIRES="force"
2105 -sc | --sources-cvs)
2106 COMMAND="list-sources-cvs"
2108 -sd | --source-distfiles)
2109 COMMAND="list-sources-distfiles"
2111 -sdp | --source-distfiles-paths)
2112 COMMAND="list-sources-distfiles-paths"
2114 -sf | --source-files)
2115 COMMAND="list-sources-files"
2117 -lsp | --source-paths)
2118 COMMAND="list-sources-local-paths"
2120 -su | --source-urls)
2121 COMMAND="list-sources-urls"
2123 -Tvs | --tag-version-stable )
2128 -Ts | --tag-stable )
2133 -Tv | --tag-version )
2138 -Tp | --tag-prefix )
2150 -ir | --integer-release-only )
2151 INTEGER_RELEASE="yes"
2154 COMMAND="update_md5"
2159 -Upi | --update-poldek-indexes )
2160 UPDATE_POLDEK_INDEXES="yes"
2163 COMMAND="init_rpm_dir"
2165 -u | --try-upgrade )
2166 TRY_UPGRADE="1"; shift ;;
2168 shift; UPGRADE_VERSION="$1"; shift;;
2169 -un | --try-upgrade-with-float-version )
2170 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2172 BE_VERBOSE="1"; shift ;;
2177 if echo "${MACRO}" | grep -q '\W'; then
2178 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2182 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2187 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2191 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2194 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2195 COMMAND="show_bconds"
2199 COMMAND="show_bcond_args"
2202 --show-avail-bconds)
2203 COMMAND="show_avail_bconds"
2208 RPMOPTS="${RPMOPTS} --nodeps"
2211 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2214 Exit_error err_invalid_cmdline "$1"
2217 SPECFILE=${1%/}; shift
2218 # check if specname was passed as specname:cvstag
2219 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2220 CVSTAG="${SPECFILE##*:}"
2221 SPECFILE="${SPECFILE%%:*}"
2223 # always have SPECFILE ending with .spec extension
2224 SPECFILE=${SPECFILE%%.spec}.spec
2225 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2229 [ -d "$ASSUMED_NAME" ] && GIT_DIR="$ASSUMED_NAME/.git" || GIT_DIR=.git
2230 if [ -d "$GIT_DIR" ] && [ -z "$CVSTAG" ]; then
2231 if CVSTAG=$(GIT_DIR=$GIT_DIR git symbolic-ref HEAD) 2>/dev/null; then
2232 CVSTAG=${CVSTAG#refs/heads/}
2233 if [ "$CVSTAG" != "master" ]; then
2234 echo >&2 "builder: Active branch $CVSTAG. Use -r BRANCHNAME to override"
2237 echo >&2 "On detached HEAD. Use -r BRANCHNAME to override"
2240 elif [ "$CVSTAG" = "HEAD" ]; then
2241 # assume -r HEAD is same as -A
2245 if [ "$CVSTAG" ]; then
2246 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2247 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2250 if [ -n "$DEBUG" ]; then
2255 if [ -n "$TARGET" ]; then
2258 TARGET_SWITCH="--target $TARGET" ;;
2260 TARGET_SWITCH="--target=$TARGET" ;;
2264 if [ "$SCHEDTOOL" != "no" ]; then
2265 NICE_COMMAND="$SCHEDTOOL"
2267 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2270 update_shell_title "$COMMAND"
2274 if [ -z "$SPECFILE" ]; then
2275 Exit_error err_no_spec_in_cmdl
2277 get_spec > /dev/null
2284 if [ -z "$SPECFILE" ]; then
2285 Exit_error err_no_spec_in_cmdl
2287 get_spec > /dev/null
2292 "show_avail_bconds")
2294 if [ -z "$SPECFILE" ]; then
2295 Exit_error err_no_spec_in_cmdl
2298 get_spec > /dev/null
2300 local bcond_avail=$(find_spec_bcond $SPECFILE)
2301 local opt bcond bconds
2302 for opt in $bcond_avail; do
2305 bcond=${opt#without_}
2306 bconds="$bconds $bcond"
2310 bconds="$bconds $bcond"
2313 echo >&2 "ERROR: unexpected '$opt' in show_avail_bconds"
2321 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2323 if [ -z "$SPECFILE" ]; then
2324 Exit_error err_no_spec_in_cmdl
2327 # display SMP make flags if set
2328 smp_mflags=$(rpm -E %{?_smp_mflags})
2329 if [ "$smp_mflags" ]; then
2330 echo "builder: SMP make flags are set to $smp_mflags"
2338 if [ "$COMMAND" != "build-source" ]; then
2341 fetch_build_requires
2342 if [ "$INTEGER_RELEASE" = "yes" ]; then
2343 echo "Checking release $PACKAGE_RELEASE..."
2344 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2345 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2349 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2350 if [ -n "$TEST_TAG" ]; then
2351 local TAGVER=`make_tagver`
2352 echo "Searching for tag $TAGVER..."
2353 git show-ref --quiet --verify "refs/tags/$TAGVER" && Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2355 # - do not allow to build from HEAD when XX-branch exists
2356 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2357 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2358 TAG_BRANCH="${TREE_PREFIX}-branch"
2359 TAG_STATUS=$(git branch -r | grep -i "origin/$TAG_BRANCH$" | sed 's# *origin/##')
2360 if [ -n "$TAG_STATUS" -a -z "$CVSTAG" ]; then
2361 Exit_error err_branch_exists "$TAG_STATUS"
2367 if [ -n "$NOSOURCE0" ] ; then
2368 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2373 get_files $SOURCES $PATCHES
2377 NODIST="yes" get_files $SOURCES $PATCHES
2382 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2383 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2385 remove_build_requires
2389 if [ -z "$SPECFILE" ]; then
2390 Exit_error err_no_spec_in_cmdl
2399 if [ -z "$SPECFILE" ]; then
2400 Exit_error err_no_spec_in_cmdl
2403 ADD_PACKAGE_CVS=yes get_spec
2406 if [ -n "$NOSOURCE0" ] ; then
2407 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2409 get_files $SOURCES $PATCHES
2414 if [ -z "$SPECFILE" ]; then
2415 Exit_error err_no_spec_in_cmdl
2421 if [ -n "$NOSOURCE0" ] ; then
2422 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2424 get_files $SOURCES $PATCHES
2429 if [ -z "$SPECFILE" ]; then
2430 Exit_error err_no_spec_in_cmdl
2436 if [ -n "$NOSOURCE0" ] ; then
2437 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2445 if [ -z "$SPECFILE" ]; then
2446 Exit_error err_no_spec_in_cmdl
2456 "list-sources-files" )
2459 DONT_PRINT_REVISION="yes"
2462 for SAP in $SOURCES $PATCHES; do
2463 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2466 "list-sources-urls" )
2469 DONT_PRINT_REVISION="yes"
2472 SAPS="$SOURCES $PATCHES"
2473 for SAP in $SAPS ; do
2477 "list-sources-local-paths" )
2480 DONT_PRINT_REVISION="yes"
2483 for SAP in $SOURCES $PATCHES; do
2484 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2487 "list-sources-distfiles-paths" )
2490 DONT_PRINT_REVISION="yes"
2493 for SAP in $SOURCES $PATCHES; do
2494 if [ -n "$(src_md5 "$SAP")" ]; then
2495 distfiles_path "$SAP"
2499 "list-sources-distfiles" )
2502 DONT_PRINT_REVISION="yes"
2505 for SAP in $SOURCES $PATCHES; do
2506 if [ -n "$(src_md5 "$SAP")" ]; then
2507 distfiles_url "$SAP"
2511 "list-sources-cvs" )
2514 DONT_PRINT_REVISION="yes"
2517 for SAP in $SOURCES $PATCHES; do
2518 if [ -z "$(src_md5 "$SAP")" ]; then
2519 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2533 echo "$VERSIONSTRING"
2536 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2537 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2541 # vi:syntax=sh:ts=4:sw=4:noet