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"}
68 # use rpm 4.4.6+ digest format instead of comments if non-zero
71 # user agent when fetching files
72 USER_AGENT="PLD/Builder($VERSION)"
74 # It can be used i.e. in log file naming.
75 # See LOGFILE example.
76 DATE=`date +%Y-%m-%d_%H-%M-%S`
78 # Example: LOGFILE='../log.$PACKAGE_NAME'
79 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
80 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
81 # Example: LOGFILE='$PACKAGE_NAME.$DATE.log'
82 # Yes, you can use variable name! Note _single_ quotes!
97 # create symlinks for tools in PACKAGE_DIR, see get_spec()
108 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
110 CVS_COMMAND=${CVS_COMMAND:-cvs}
113 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
114 CVS_SERVER="cvs.pld-linux.org"
116 GIT_SERVER="git://github.com/draenog"
121 DISTFILES_SERVER="://distfiles.pld-linux.org"
122 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
127 FAIL_IF_NO_SOURCES="yes"
129 # let get_files skip over files which are present to get those damn files fetched
130 SKIP_EXISTING_FILES="no"
133 # should the specfile be restored if upgrade failed?
134 REVERT_BROKEN_UPGRADE="yes"
136 if rpm --specsrpm 2>/dev/null; then
137 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
138 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
140 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
141 if [ -x /usr/bin/rpm-getdeps ]; then
142 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
144 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
149 # Here we load saved user environment used to
150 # predefine options set above, or passed to builder
152 # This one reads global system environment settings:
153 if [ -f ~/etc/builderrc ]; then
156 # And this one cascades settings using user personal
158 # Example of ~/.builderrc:
160 #UPDATE_POLDEK_INDEXES="yes"
161 #FETCH_BUILD_REQUIRES="yes"
162 #REMOVE_BUILD_REQUIRES="force"
164 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
168 if [ -n "$HOME_ETC" ]; then
169 USER_CFG="$HOME_ETC/.builderrc"
170 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
172 USER_CFG=~/.builderrc
173 BUILDER_MACROS=~/.builder-rpmmacros
176 [ -f "$USER_CFG" ] && . "$USER_CFG"
178 if [ "$SCHEDTOOL" = "auto" ]; then
179 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
180 SCHEDTOOL="schedtool -B -e"
186 if [ -n "$USE_PROZILLA" ]; then
187 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
190 elif [ -n "$USE_AXEL" ]; then
191 GETURI="axel -a $AXEL_OPTS"
195 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
196 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
197 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
198 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
200 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
201 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
207 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
218 if [ -d $HOME/rpm/SOURCES ]; then
219 echo "ERROR: ~/rpm/{SPECS,SOURCES} structure is obsolete" >&2
220 echo "ERROR: get rid of your ~/rpm/SOURCES" >&2
224 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
225 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
229 if [ -n "$LOGFILE" ]; then
230 LOG=`eval echo $LOGFILE`
231 if [ -n "$LASTLOG_FILE" ]; then
232 echo "LASTLOG=$LOG" > $LASTLOG_FILE
234 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
237 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
238 return `cat ${RES_FILE}`
243 #---------------------------------------------
247 if [ -n "$DEBUG" ]; then set -xv; fi
249 Usage: builder [-D|--debug] [-V|--version] [--short-version] [--as_anon] [-a|--add_cvs] [-b|-ba|--build]
250 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
251 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
252 [-g|--get] [-h|--help] [--ftp] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
253 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
254 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
255 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
256 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
257 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
258 <package>[.spec][:cvstag]
260 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
261 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
262 -n5, --no-md5 - ignore md5 comments in spec
263 -D, --debug - enable builder script debugging mode,
264 -debug - produce rpm debug package (same as --opts -debug)
265 -V, --version - output builder version string
266 --short-version - output builder short version
267 --as_anon - get files via pserver as cvs@$CVS_SERVER,
268 -a, --add_cvs - try add new package to CVS.
269 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
271 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
272 only package from <package>.spec,
273 -bp, --build-prep - execute the %prep phase of <package>.spec,
274 -bc - execute the %build phase of <package>.spec,
275 -bi - execute the %install phase of <package>.spec
276 -bl - execute the %files phase of <package>.spec
277 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
279 --short-circuit - short-circuit build
280 -B, --branch - add branch
281 -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
282 may be used with building process.
283 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
284 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
286 -cf, --cvs-force - use -F when tagging (useful when moving branches)
287 -d <cvsroot>, --cvsroot <cvsroot>
289 --define <macro> <value>
290 - define a macro <macro> with value <value>,
291 --alt_kernel <kernel>
292 - same as --define 'alt_kernel <kernel>'
293 --nodeps - rpm won't check any dependences
294 -g, --get - get <package>.spec and all related files from CVS repo
296 -h, --help - this message,
297 -jN, -j N - set %_smp_mflags to propagate concurrent jobs
298 --ftp, --http - use ftp or http protocol to access distfiles server
299 -l <logfile>, --logtofile <logfile>
302 - don't check specs in CVS
303 -nd, --no-distfiles - don't download from distfiles
304 -nm, --no-mirrors - don't download from mirror, if source URL is given,
305 -nu, --no-urls - don't try to download from FTP/HTTP location,
306 -ns, --no-srcs - don't download Sources/Patches
307 -ns0, --no-source0 - don't download Source0
308 -nn, --no-net - don't download anything from the net
309 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
310 --no-init - don't initialize builder paths (SPECS and SOURCES)
312 --skip-existing-files - skip existing files in get_files
313 --opts <rpm opts> - additional options for rpm
314 -q, --quiet - be quiet,
315 --date yyyy-mm-dd - build package using resources from specified CVS date,
316 -r <cvstag>, --cvstag <cvstag>
317 - build package using resources from specified CVS tag,
318 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
319 -R, --fetch-build-requires
320 - fetch what is BuildRequired,
321 -RB, --remove-build-requires
322 - remove all you fetched with -R or --fetch-build-requires
323 remember, this option requires confirmation,
324 -FRB, --force-remove-build-requires
325 - remove all you fetched with -R or --fetch-build-requires
326 remember, this option works without confirmation,
327 -sd, --source-distfiles - list sources available from distfiles (intended for offline
328 operations; does not work when Icon field is present
329 but icon file is absent),
330 -sc, --source-cvs - list sources available from CVS
331 -sdp, --source-distfiles-paths - list sources available from distfiles -
332 paths relative to distfiles directory (intended for offline
333 operations; does not work when Icon field is present
334 but icon file is absent),
335 -sf, --source-files - list sources - bare filenames (intended for offline
336 operations; does not work when Icon field is present
337 but icon file is absent),
338 -lsp, --source-paths - list sources - filenames with full local paths (intended for
339 offline operations; does not work when Icon field is present
340 but icon file is absent),
341 -su, --source-urls - list urls - urls to sources and patches
342 intended for copying urls with spec with lots of macros in urls
343 -T <cvstag> , --tag <cvstag>
344 - add cvs tag <cvstag> for files,
345 -Tvs, --tag-version-stable
346 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
348 - add cvs tag STABLE for files,
350 - add cvs tag NAME-VERSION-RELEASE for files,
351 -Tp, --tag-prefix <prefix>
352 - add <prefix> to NAME-VERSION-RELEASE tags,
353 -tt, --test-tag <prefix>
354 - fail if tag is already present,
355 -ir, --integer-release-only
356 - allow only integer and snapshot releases
357 -v, --verbose - be verbose,
358 -u, --try-upgrade - check version, and try to upgrade package
359 -un, --try-upgrade-with-float-version
360 - as above, but allow float version
361 php-pear-Services_Digg/
362 --upgrade-version - upgrade to specified version in try-upgrade
363 -U, --update - refetch sources, don't use distfiles, and update md5 comments
364 -Upi, --update-poldek-indexes
365 - refresh or make poldek package index files.
366 -sp, --skip-patch <patchnumber>
367 - don't apply <patchnumber>. may be repeated.
368 -np, --nopatch <patchnumber>
369 - abort instead of applying patch <patchnumber>
370 --show-bconds - show available conditional builds, which can be used
371 - with --with and/or --without switches.
372 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
373 ./repackage.sh script. in other words, the output is
374 parseable by scripts.
375 --show-avail-bconds - show available bconds
376 --with/--without <feature>
377 - conditional build package depending on %_with_<feature>/
378 %_without_<feature> macro switch. You may now use
379 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
380 constructions. Set GROUP_BCONDS to yes to make use of it.
381 --target <platform>, --target=<platform>
382 - build for platform <platform>.
383 --init-rpm-dir - initialize ~/rpm directory structure
387 # create tempfile. as secure as possible
389 mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$
392 # change dependency to specname
394 # - perl(Package::Name) -> perl-Package-Name
398 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
402 update_shell_title() {
404 local len=${COLUMNS:-80}
405 local msg="$(echo "$*" | cut -c-$len)"
407 if [ -n "$BE_VERBOSE" ]; then
408 echo >&2 "$(date +%s.%N) $*"
411 if [ "x$TITLECHANGE" = "xyes" -o "x$TITLECHANGE" = "x" ]; then
413 if [ -n "$PACKAGE_NAME" ]; then
414 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
419 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
420 msg=$(echo $msg | tr -d '\n\r')
423 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
426 echo >&2 -ne "\033]0;$msg\007"
432 # set TARGET from BuildArch: from SPECFILE
434 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
435 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
437 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
441 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
443 TARGET_SWITCH="--target=$TARGET" ;;
449 # runs rpm with minimal macroset
451 # we reset macros not to contain macros.build as all the %() macros are
452 # executed here, while none of them are actually needed.
453 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
454 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
456 # TODO: move these to /usr/lib/rpm/macros
457 cat > $BUILDER_MACROS <<'EOF'
458 %x8664 x86_64 amd64 ia32e
461 %bootstrap_release() %{1}
462 %requires_releq_kernel_up(s:n:) %{nil}
463 %requires_releq_kernel_smp(s:n:) %{nil}
464 %requires_releq_kernel(s:n:) %{nil}
465 %requires_releq() %{nil}
466 %pyrequires_eq() %{nil}
467 %requires_eq() %{nil}
468 %requires_eq_to() %{nil}
469 %requires_ge() %{nil}
470 %requires_ge_to() %{nil}
471 %requires_ge() %{nil}
472 %releq_kernel_up(n:) ERROR
473 %releq_kernel_smp(n:) ERROR
474 %releq_kernel(n:) ERROR
478 %ruby_ver_requires_eq() %{nil}
479 %ruby_mod_ver_requires_eq() %{nil}
480 %__php_api_requires() %{nil}
481 %php_major_version ERROR
482 %php_api_version ERROR
483 %requires_xorg_xserver_extension %{nil}
484 %requires_xorg_xserver_xinput %{nil}
485 %requires_xorg_xserver_font %{nil}
486 %requires_xorg_xserver_videodrv %{nil}
488 %perl_vendorarch ERROR
489 %perl_vendorlib ERROR
490 # damn. need it here! - copied from /usr/lib/rpm/macros.build
491 %tmpdir %(echo "${TMPDIR:-/tmp}")
492 %patchset_source(f:b:) %(
493 base=%{-b*}%{!-b*:10000};
494 start=$(expr $base + %1);
495 end=$(expr $base + %{?2}%{!?2:%{1}});
496 # we need to call seq twice as it doesn't allow two formats
497 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
498 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
499 paste %{tmpdir}/__ps{1,2};
500 rm -f %{tmpdir}/__ps{1,2};
503 %add_etc_shells(p) %{p:<lua>}
504 %remove_etc_shells(p) %{p:<lua>}
505 %lua_add_etc_shells() %{nil}
506 %lua_remove_etc_shells() %{nil}
508 %buildrequires_jdk %{nil}
509 %pear_package_print_optionalpackages %{nil}
511 if [ "$NOINIT" = "yes" ] ; then
512 cat >> $BUILDER_MACROS <<'EOF'
517 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
521 if [ -n "$DEBUG" ]; then
526 if [ -x /usr/bin/rpm-specdump ]; then
527 update_shell_title "cache_rpm_dump using rpm-specdump command"
528 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
530 update_shell_title "cache_rpm_dump using rpmbuild command"
533 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
534 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
540 ARGS='--nodigest --nosignature --nobuild'
543 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
545 if [ $? -gt 0 ]; then
546 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
548 Exit_error err_build_fail
551 # make small dump cache
552 rpm_dump_cache=`echo "$rpm_dump" | awk '
553 $2 ~ /^SOURCEURL/ {print}
554 $2 ~ /^PATCHURL/ {print}
555 $2 ~ /^nosource/ {print}
556 $2 ~ /^PACKAGE_/ {print}
560 update_shell_title "cache_rpm_dump: OK!"
564 if [ -z "$rpm_dump_cache" ] ; then
565 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
567 echo "$rpm_dump_cache"
571 update_shell_title "get icons"
572 ICONS=$(awk '/^Icon:/ {print $2}' $PACKAGE_DIR/${SPECFILE})
573 if [ -z "$ICONS" ]; then
577 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
581 update_shell_title "parsing specfile"
582 if [ -n "$DEBUG" ]; then
587 # icons are needed for successful spec parse
593 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
594 FAIL_IF_NO_SOURCES="no"
597 if [ "$NOSRCS" != "yes" ]; then
598 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
599 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
600 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
603 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
604 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
605 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
607 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
608 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
611 if [ -n "$BE_VERBOSE" ]; then
612 echo "- Sources : `nourl $SOURCES`"
613 if [ -n "$PATCHES" ]; then
614 echo "- Patches : `nourl $PATCHES`"
616 echo "- Patches : *no patches needed*"
618 if [ -n "$ICONS" ]; then
619 echo "- Icon : `nourl $ICONS`"
621 echo "- Icon : *no package icon*"
623 echo "- Name : $PACKAGE_NAME"
624 echo "- Version : $PACKAGE_VERSION"
625 echo "- Release : $PACKAGE_RELEASE"
628 update_shell_title "parse_spec: OK!"
632 if [ -n "$DEBUG" ]; then
640 "err_no_spec_in_cmdl" )
641 remove_build_requires
642 echo >&2 "ERROR: spec file name not specified."
644 "err_invalid_cmdline" )
645 echo >&2 "ERROR: invalid command line arg ($2)."
647 "err_no_spec_in_repo" )
648 remove_build_requires
649 echo >&2 "Error: spec file not stored in CVS repo."
651 "err_no_source_in_repo" )
652 remove_build_requires
653 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
655 "err_cvs_add_failed" )
656 echo >&2 "Error: failed to add package to CVS repo."
659 remove_build_requires
660 echo >&2 "Error: package build failed. (${2:-no more info})"
662 "err_no_package_data" )
663 remove_build_requires
664 echo >&2 "Error: couldn't get out package name/version/release from spec file."
667 remove_build_requires
668 echo >&2 "Tag ${2} already exists (spec release: ${3})."
671 remove_build_requires
672 echo >&2 "Release ${2} not integer and not a snapshot."
674 "err_branch_exists" )
675 remove_build_requires
676 echo >&2 "Tree branch already exists (${2})."
679 remove_build_requires
680 echo >&2 "Error: conditions reject building this spec (${2})."
682 "err_not_implemented" )
684 echo >&2 "Error: functionality not yet imlemented"
687 echo >&2 "Unknown error."
692 if [ -n "$DEBUG" ]; then
697 if [ "$NOINIT" != "yes" ] ; then
698 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
700 local macros_ver=$(rpm -E %?rpm_build_macros)
701 if [ -z "$macros_ver" ]; then
702 REPO_DIR=$TOP_DIR/packages
703 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
705 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
706 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
710 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
722 update_shell_title "get_spec"
724 if [ -n "$DEBUG" ]; then
730 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
732 SPECFILE=$(basename $SPECFILE)
735 if [ "$NOCVSSPEC" != "yes" ]; then
736 if [ -d "$ASSUMED_NAME/.git" ]; then
737 GIT_DIR=$PACKAGE_DIR/.git git fetch origin || Exit_error err_no_spec_in_repo
738 elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then
739 if [ ! -r "$ASSUMED_NAME/$SPECFILE" ]; then
740 echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
743 Exit_error err_not_implemented
745 git clone ${GIT_SERVER}/${ASSUMED_NAME}.git || {
746 # softfail if new package, i.e not yet added to cvs
747 [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
748 echo "Warning: package not in CVS - assuming new package"
753 cvsignore_df .gitignore
755 # add default log format to .cvsignore if it is relative to package dir
756 if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then
757 # substitute known "macros" to glob
758 local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\),*,g')
759 if [ "$logfile" ]; then
760 cvsignore_df "$logfile"
764 # create symlinks for tools
765 if [ "$SYMLINK_TOOLS" != "no" ]; then
766 for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do
767 [ -f $a ] || continue
768 ln -sf ../$a $ASSUMED_NAME
774 if [ -n "$CVSTAG" ]; then
775 GIT_WORK_TREE=$PACKAGE_DIR GIT_DIR=$PACKAGE_DIR/.git git checkout "$CVSTAG" || exit
776 GIT_DIR=$PACKAGE_DIR/.git git symbolic-ref -q HEAD > /dev/null &&
777 GIT_WORK_TREE=$PACKAGE_DIR GIT_DIR=$PACKAGE_DIR/.git git merge '@{u}'
780 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
781 Exit_error err_no_spec_in_repo
784 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
785 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
788 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
796 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
797 $CVS_COMMAND update mirrors >&2
801 local origin mirror name rest ol prefix
802 while read origin mirror name rest; do
803 # skip comments and empty lines
804 if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then
807 ol=$(echo -n "$origin" | wc -c)
808 prefix=$(echo -n "$url" | head -c $ol)
809 if [ "$prefix" = "$origin" ] ; then
810 suffix=$(echo "$url" | cut -b $((ol+1))-)
811 echo -n "$mirror$suffix"
818 # Warning: unpredictable results if same URL used twice
822 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
823 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
828 [ "$NO5" = "yes" ] && return
830 [ -z "$no" ] && return
834 if [ -f additional-md5sums ]; then
835 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
836 if [ -z "$spec_rev" ]; then
837 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
839 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
840 md5=$(grep -s -v '^#' additional-md5sums | \
841 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
842 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
843 grep -E '^[0-9a-f]{32}$')
846 if [ $(echo "$md5" | wc -l) != 1 ] ; then
847 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
849 echo "$md5" | tail -n 1
854 source_md5=`grep -i "^#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
855 if [ -n "$source_md5" ]; then
858 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
859 if [ -n "$source_md5" ]; then
862 # we have empty SourceX-md5, but it is still possible
863 # that we have NoSourceX-md5 AND NoSource: X
864 nosource_md5=`grep -i "^#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
865 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
873 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
877 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
880 distfiles_attic_url() {
881 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
887 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
891 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
892 [ -n "$size" -a "$size" -gt 0 ]
896 if [ "$CVSIGNORE_DF" != "yes" ]; then
899 cvsignore=${PACKAGE_DIR}/.gitignore
901 # add only if not yet there
902 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
903 echo "$1" >> $cvsignore
907 # returns true if "$1" is ftp, http or https protocol url
910 ftp://*|http://*|https://*)
918 if [ $# -eq 0 ]; then
922 update_shell_title "update md5"
923 if [ -n "$DEBUG" ]; then
930 # pass 1: check files to be fetched
934 local fp=$(nourl "$i")
935 local srcno=$(src_no "$i")
936 if [ -n "$ADD5" ]; then
937 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
938 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
939 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
941 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
943 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
944 need_files="$need_files $i"
948 # pass 1a: get needed files
949 if [ "$need_files" ]; then
950 get_files $need_files
953 # pass 2: proceed with md5 adding or updating
955 local fp=$(nourl "$i")
956 local srcno=$(src_no "$i")
957 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
958 if [ -z "$md5" ]; then
959 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
961 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
962 local tag="# Source$srcno-md5:\t"
963 if [[ "$md5" == *NoSource* ]]; then
964 tag="# NoSource$srcno-md5:\t"
965 elif [ -n "$USEDIGEST" ]; then
966 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
968 md5=$(md5sum "$fp" | cut -f1 -d' ')
969 echo "Updating Source$srcno ($md5: $fp)."
971 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
972 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
974 $PACKAGE_DIR/$SPECFILE
981 [ "$NO5" = "yes" ] && return
983 update_shell_title "check md5"
987 if ! good_md5 "$i"; then
988 echo -n "MD5 sum mismatch."
991 if ! good_size "$i"; then
992 echo -n "0 sized file."
996 if [ $bad -eq 1 ]; then
997 echo " Use -U to refetch sources,"
998 echo "or -5 to update md5 sums, if you're sure files are correct."
999 Exit_error err_no_source_in_repo $i
1005 update_shell_title "get_files"
1007 if [ -n "$DEBUG" ]; then
1012 if [ $# -gt 0 ]; then
1016 local get_files_cvs=""
1020 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1021 update_shell_title "$i"
1022 local fp=`nourl "$i"`
1023 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1028 local srcmd5=$(src_md5 "$i")
1030 # we know if source/patch is present in cvs/distfiles
1031 # - has md5 (in distfiles)
1032 # - in cvs... ideas?
1034 # CHECK: local file didn't exist or always cvs up (first) requested.
1035 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1036 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1037 echo "Warning: no URL given for $i"
1041 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1042 if good_md5 "$i" && good_size "$i"; then
1043 echo "$fp having proper md5sum already exists"
1047 # optionally prefer mirror over distfiles if there's mirror
1048 # TODO: build url list and then try each url from the list
1049 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1052 url=$(distfiles_url "$i")
1055 url_attic=$(distfiles_attic_url "$i")
1057 # is $url local file?
1058 if [[ "$url" = [./]* ]]; then
1059 update_shell_title "${GETLOCAL%% *}: $url"
1060 ${GETLOCAL} $url $target
1062 if [ -z "$NOMIRRORS" ]; then
1063 url=$(find_mirror "$url")
1067 # make shorter message for distfiles urls
1068 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1069 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1070 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1073 update_shell_title "${GETURI%% *}: $uri"
1074 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1075 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1076 update_shell_title "${GETURI2%% *}: $url"
1077 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1082 if [ ! -s "$target" ]; then
1084 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1085 update_shell_title "${GETLOCAL%% *}: $url_attic"
1086 ${GETLOCAL} $url_attic $target
1088 if [ -z "$NOMIRRORS" ]; then
1089 url_attic=$(find_mirror "$url_attic")
1091 update_shell_title "${GETURI%% *}: $url_attic"
1092 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1093 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1094 update_shell_title "${GETURI2%% *}: $url_attic"
1095 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1097 test -s "$target" || rm -f "$target"
1101 if [ -s "$target" ]; then
1102 cvsignore_df $target
1109 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1110 if [ -z "$NOMIRRORS" ]; then
1111 im=$(find_mirror "$i")
1115 update_shell_title "${GETURI%% *}: $im"
1116 ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
1117 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1118 update_shell_title "${GETURI2%% *}: $im"
1119 ${GETURI2} "$im" ${OUTFILEOPT} "$target"
1121 test -s "$target" || rm -f "$target"
1124 if [ "$cvsup" = 1 ]; then
1130 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1131 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1132 Exit_error err_no_source_in_repo $i
1135 # we check md5 here just only to refetch immediately
1136 if good_md5 "$i" && good_size "$i"; then
1138 elif [ "$FROM_DISTFILES" = 1 ]; then
1139 # wrong md5 from distfiles: remove the file and try again
1141 echo "MD5 sum mismatch. Trying full fetch."
1144 update_shell_title "${GETURI%% *}: $url"
1145 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1146 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1147 update_shell_title "${GETURI2%% *}: $url"
1148 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1150 if [ ! -s "$target" ]; then
1152 update_shell_title "${GETURI%% *}: $url_attic"
1153 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1154 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1155 update_shell_title "${GETURI2%% *}: $url_attic"
1156 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1159 test -s "$target" || rm -f "$target"
1162 SHELL_TITLE_PREFIX=""
1165 if [ "$CHMOD" = "yes" ]; then
1166 CHMOD_FILES=$(nourl "$@")
1167 if [ -n "$CHMOD_FILES" ]; then
1168 chmod $CHMOD_MODE $CHMOD_FILES
1175 if [ -n "$DEBUG" ]; then
1180 # Check whether first character of PACKAGE_NAME is legal for tag name
1181 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1185 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1186 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1188 # Remove #kernel.version_release from TAGVER because tagging sources
1189 # could occur with different kernel-headers than kernel-headers used at build time.
1190 # besides, %{_kernel_ver_str} is not expanded.
1192 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1193 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1202 if [ -n "$DEBUG" ]; then
1207 echo "Version: $PACKAGE_VERSION"
1208 echo "Release: $PACKAGE_RELEASE"
1211 if [ "$TAG_VERSION" = "yes" ]; then
1212 TAGVER=`make_tagver`
1215 if [ -n "$TAG" ]; then
1219 local OPTIONS="tag $CVS_FORCE"
1222 if [ "$TAG_VERSION" = "yes" ]; then
1228 if [ "$TAG_VERSION" = "yes" ]; then
1229 update_shell_title "tag sources: $TAGVER"
1230 git $OPTIONS $TAGVER || exit
1232 if [ -n "$TAG" ]; then
1233 update_shell_title "tag sources: $TAG"
1234 git $OPTIONS $TAG $chunk || exit
1240 echo "Git branch: $TAG"
1243 if [ -n "$DEBUG" ]; then
1248 local OPTIONS="branch $CVS_FORCE"
1251 git $OPTIONS $TAG || exit
1255 # this function should exit early if package can't be built for this arch
1256 # this avoids unneccessary BR filling.
1259 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1261 if [ $ret -ne 0 ]; then
1273 s/^\(%define[ \t]\+_\?rel[ \t]\+\)$rel\$/\1$newrel/
1274 s/^\(Release:[ \t]\+\)$rel\$/\1$newrel/
1280 local ver="$2" subver=$ver
1281 local newver="$3" newsubver=$newver
1283 # try handling subver, everything that's not numeric-dotted in version
1284 if grep -Eq '%define\s+subver' $specfile; then
1285 subver=$(echo "$ver" | sed -re 's,^[0-9.]+,,')
1287 newsubver=$(echo "$newver" | sed -re 's,^[0-9.]+,,')
1288 newver=${newver%$newsubver}
1291 s/^\(%define[ \t]\+_\?ver[ \t]\+\)$ver\$/\1$newver/
1292 s/^\(%define[ \t]\+subver[ \t]\+\)$subver\$/\1$newsubver/
1293 s/^\(Version:[ \t]\+\)$ver\$/\1$newver/
1298 if [ -n "$TRY_UPGRADE" ]; then
1299 local TNOTIFY TNEWVER TOLDVER
1300 update_shell_title "build_package: try_upgrade"
1304 if [ "$UPGRADE_VERSION" ]; then
1305 TNEWVER=$UPGRADE_VERSION
1307 if [ -n "$FLOAT_VERSION" ]; then
1308 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
1310 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
1313 # pldnotify.awk does not set exit codes, but it has match for ERROR
1314 # in output which means so.
1315 if [[ "$TNOTIFY" = *ERROR* ]]; then
1320 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1323 if [ -n "$TNEWVER" ]; then
1324 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1325 echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
1326 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1327 cp -f $SPECFILE $SPECFILE.bak
1330 set_release $SPECFILE $PACKAGE_RELEASE 1
1331 set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
1333 if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
1334 echo >&2 "Upgrading version failed, you need to update spec yourself"
1344 update_shell_title "build_package"
1345 if [ -n "$DEBUG" ]; then
1354 BUILD_SWITCH="-ba" ;;
1356 BUILD_SWITCH="-bb" ;;
1358 BUILD_SWITCH="-bs --nodeps" ;;
1360 BUILD_SWITCH="-bp --nodeps" ;;
1362 BUILD_SWITCH="-bc" ;;
1364 BUILD_SWITCH="-bi" ;;
1366 BUILD_SWITCH="-bl" ;;
1370 update_shell_title "build_package: $COMMAND"
1371 if [ -n "$LOGFILE" ]; then
1372 LOG=`eval echo $LOGFILE`
1373 if [ -d "$LOG" ]; then
1374 echo "Log file $LOG is a directory."
1375 echo "Parse error in the spec?"
1376 Exit_error err_build_fail
1378 if [ -n "$LASTLOG_FILE" ]; then
1379 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1381 RES_FILE=$(tempfile)
1383 (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
1384 RETVAL=`cat $RES_FILE`
1386 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1387 if [ "$RETVAL" -eq "0" ]; then
1394 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1397 if [ "$RETVAL" -ne "0" ]; then
1398 if [ -n "$TRY_UPGRADE" ]; then
1399 echo "\nUpgrade package to new version failed."
1400 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1401 echo "Restoring old spec file."
1402 mv -f $SPECFILE.bak $SPECFILE
1406 Exit_error err_build_fail
1412 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1415 install_required_packages() {
1420 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1423 /^%changelog/ { exit }
1425 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1426 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1427 gsub(/[ \t]+/, "_", bcond);
1429 }' $SPEC | LC_ALL=C sort -u
1433 # expand bconds from ~/.bcondrc
1434 # The file structure is like gentoo's package.use:
1437 # samba -mysql -pgsql
1438 # w32codec-installer license_agreement
1441 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1447 SN=${SPECFILE%%\.spec}
1449 local bcondrc=$HOME/.bcondrc
1450 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1452 local bcond_avail=$(find_spec_bcond $SPECFILE)
1454 while read pkg flags; do
1456 [[ "$pkg" == \#* ]] && continue
1458 # any package or current package?
1459 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1460 for flag in $flags; do
1461 local opt=${flag#[+-]}
1463 # use only flags which are in this package.
1464 if [[ $bcond_avail = *${opt}* ]]; then
1465 if [[ $flag = -* ]]; then
1466 if [[ $BCOND != *--with?${opt}* ]]; then
1467 BCOND="$BCOND --without $opt"
1470 if [[ $BCOND != *--without?${opt}* ]]; then
1471 BCOND="$BCOND --with $opt"
1478 update_shell_title "parse ~/.bcondrc: DONE!"
1481 set_bconds_values() {
1482 update_shell_title "set bcond values"
1484 AVAIL_BCONDS_WITHOUT=""
1485 AVAIL_BCONDS_WITH=""
1487 if grep -Eq '^# *_with' ${SPECFILE}; then
1488 echo >&2 "ERROR: This spec has old style bconds."
1492 if ! grep -q '^%bcond' ${SPECFILE}; then
1496 local bcond_avail=$(find_spec_bcond $SPECFILE)
1497 process_bcondrc "$SPECFILE"
1499 update_shell_title "parse bconds"
1502 for opt in $bcond_avail; do
1505 bcond=${opt#without_}
1507 *--without?${bcond}*)
1508 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1511 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1519 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1522 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1527 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1536 update_shell_title "run_sub_builder $package_name"
1538 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1539 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1540 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1541 # jakby nie bylo tego kawalka kodu.
1543 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1544 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1548 # kurwa. translate that ^^^^
1552 # Istnieje taki spec? ${package}.spec
1553 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1554 parent_spec_name=${package}.spec
1555 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1556 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1558 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1563 if [ "${parent_spec_name}" != "" ]; then
1564 spawn_sub_builder $parent_spec_name
1566 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1569 spawn_sub_builder() {
1571 update_shell_title "spawn_sub_builder $package_name"
1574 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1575 sub_builder_opts="${sub_builder_opts} -R"
1577 if [ "${REMOVE_BUILD_REQUIRES}" = "nice" ]; then
1578 sub_builder_opts="${sub_builder_opts} -RB"
1579 elif [ "${REMOVE_BUILD_REQUIRES}" = "force" ]; then
1580 sub_builder_opts="${sub_builder_opts} -FRB"
1582 if [ "${UPDATE_POLDEK_INDEXES}" = "yes" ]; then
1583 sub_builder_opts="${sub_builder_opts} -Upi"
1587 ./builder ${sub_builder_opts} "$@"
1590 remove_build_requires() {
1591 if [ "$INSTALLED_PACKAGES" != "" ]; then
1592 case "$REMOVE_BUILD_REQUIRES" in
1594 run_poldek --noask -ve $INSTALLED_PACKAGES
1597 run_poldek --ask -ve $INSTALLED_PACKAGES
1600 echo You may want to manually remove following BuildRequires fetched:
1601 echo $INSTALLED_PACKAGES
1602 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1609 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1610 if [ "$BCOND" ]; then
1612 echo "Building $SPECFILE with the following conditional flags:"
1616 echo "No conditional flags passed"
1619 echo "from available:"
1620 echo "--with :\t$AVAIL_BCONDS_WITH"
1621 echo "--without:\t$AVAIL_BCONDS_WITHOUT"
1626 display_branches() {
1627 if [ "$NOCVSSPEC" != "yes" ]; then
1628 echo -n "Available branches: "
1629 git branch -r | grep '^ origin' | grep -v origin/HEAD | sed 's#^ *origin/##' | xargs
1633 # checks a given list of packages/files/provides agains current rpmdb.
1634 # outputs all dependencies which current rpmdb doesn't satisfy.
1635 # input can be either STDIN or parameters
1639 if [ $# -gt 0 ]; then
1645 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1648 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1650 # other deps (files)
1651 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1654 # checks if given package/files/provides exists in rpmdb.
1655 # input can be either stdin or parameters
1656 # returns packages which are present in the rpmdb
1660 if [ $# -gt 0 ]; then
1666 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1669 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1670 install_build_requires_rpmdeps() {
1671 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1672 # TODO: Conflicts list doesn't check versions
1673 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1674 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1676 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1677 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1678 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1681 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1682 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1683 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1684 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1686 if [ -n "$CNFL" ]; then
1687 update_shell_title "uninstall conflicting packages: $CNFL"
1688 echo "Trying to uninstall conflicting packages ($CNFL):"
1689 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1692 while [ "$DEPS" ]; do
1693 update_shell_title "install deps: $DEPS"
1694 echo "Trying to install dependencies ($DEPS):"
1695 local log=.${SPECFILE}_poldek.log
1696 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1697 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1700 if [ -n "$failed" ]; then
1701 for package in $failed; do
1702 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1711 fetch_build_requires()
1713 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1717 update_shell_title "fetch build requires"
1718 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1719 install_build_requires_rpmdeps
1723 # XXX is this ugliest code written in human history still needed?
1724 echo "All packages installed by fetch_build_requires() are written to:"
1725 echo "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1727 echo "If anything fails, you may get rid of them by executing:"
1728 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`"
1730 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1731 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)
1733 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)
1735 package=$(basename "$package_item"|sed -e "s/}$//g")
1736 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1739 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1740 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1741 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
1746 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1749 if `echo $COND_TST|grep -q 'without_'`; then
1750 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1751 if `echo $COND_TST|grep -q !`; then
1756 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1757 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1758 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1764 elif `echo $COND_TST|grep -q 'with_'`; then
1765 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1766 if `echo $COND_TST|grep -q !`; then
1771 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1772 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1773 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1779 RESULT="${COND_STATE}-${COND_ARGV}"
1781 "with-wout" | "wout-with" )
1784 "wout-wout" | "with-with" )
1788 echo "Action '$RESULT' was not defined for package '$package_item'"
1794 if [ "$GO" = "yes" ]; then
1795 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1796 echo "Testing if $package has subrequirements..."
1797 run_poldek -t -i $package --dumpn=".$package-req.txt"
1798 if [ -f ".$package-req.txt" ]; then
1799 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1801 if [ "$package_name" = "$package" ]; then
1802 echo "Installing BuildRequired package:\t$package_name"
1803 update_shell_title "Installing BuildRequired package: ${package_name}"
1804 install_required_packages $package
1806 echo "Installing (sub)Required package:\t$package_name"
1807 update_shell_title "Installing (sub)Required package: ${package_name}"
1808 install_required_packages $package_name
1812 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1813 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1816 echo "Attempting to run spawn sub - builder..."
1817 echo "Package installation failed:\t$package_name"
1818 run_sub_builder $package_name
1819 if [ $? -eq 0 ]; then
1820 install_required_packages $package_name
1823 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1824 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1827 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1834 rm -f ".$package-req.txt"
1836 echo "Attempting to run spawn sub - builder..."
1837 echo "Package installation failed:\t$package"
1838 run_sub_builder $package
1839 if [ $? -eq 0 ]; then
1840 install_required_packages $package
1843 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1844 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1847 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1853 echo "Package $package is already installed. BuildRequirement satisfied."
1857 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1858 echo >&2 "Unable to install following packages and their dependencies:"
1859 for pkg in "$NOT_INSTALLED_PACKAGES"
1863 remove_build_requires
1869 local CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1870 local TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1871 local rpmdir=$(eval $RPM $RPMOPTS --eval '%{_rpmdir}')
1872 local buildir=$(eval $RPM $RPMOPTS --eval '%{_builddir}')
1873 local srpmdir=$(eval $RPM $RPMOPTS --eval '%{_srcrpmdir}')
1876 echo "Initializing rpm directories to $TOP_DIR from $CVSROOT"
1877 mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
1879 # need to checkout to tmp dir or we can't name our topdir
1880 tmp=$(TMPDIR= TEMPDIR= mktemp -p $TOP_DIR -d) || exit 1
1882 $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh,ci,civim}
1884 mv $tmp/packages/* $TOP_DIR
1889 echo "To checkout *all* .spec files (read-only):"
1890 echo "- run cvs co SPECS"
1892 echo "To checkout *all* packages:"
1893 echo "- run cvs up -dP in $TOP_DIR dir"
1896 echo "To commit with your developer account:"
1897 echo "- edit $TOP_DIR/CVS/Root"
1900 # remove entries from CVS/Entries
1901 cvs_entry_remove() {
1902 local cvsdir="$1"; shift
1903 if [ ! -d "$cvsdir" ]; then
1904 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1908 for file in "$@"; do
1909 rm -f $cvsdir/CVS/Entries.new || return 1
1910 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1911 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1919 DONT_PRINT_REVISION="yes"
1920 Exit_error err_not_implemented
1923 #---------------------------------------------
1931 while [ $# -gt 0 ]; do
1934 COMMAND="update_md5"
1939 COMMAND="update_md5"
1948 DEBUG="yes"; shift ;;
1950 COMMAND="version"; shift ;;
1952 COMMAND="short-version"; shift ;;
1954 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1958 -b | -ba | --build )
1959 COMMAND="build"; shift ;;
1960 -bb | --build-binary )
1961 COMMAND="build-binary"; shift ;;
1963 COMMAND="build-build"; shift ;;
1965 COMMAND="build-install"; shift ;;
1967 COMMAND="build-list"; shift ;;
1968 -bp | --build-prep )
1969 COMMAND="build-prep"; shift ;;
1970 -bs | --build-source )
1971 COMMAND="build-source"; shift ;;
1973 COMMAND="branch"; shift; TAG="${1}"; shift;;
1975 CLEAN="--clean"; shift ;;
1977 CVS_FORCE="-f"; shift;;
1979 shift; CVSROOT="${1}"; shift ;;
1981 COMMAND="get"; shift ;;
1983 COMMAND="usage"; shift ;;
1985 PROTOCOL="ftp"; shift ;;
1987 PROTOCOL="http"; shift ;;
1989 RPMOPTS="${RPMOPTS} --define \"_smp_mflags -j$2\""
1993 RPMOPTS="${RPMOPTS} --define \"_smp_mflags $1\""
1997 shift; LOGFILE="${1}"; shift ;;
1999 shift; DEF_NICE_LEVEL=${1}; shift ;;
2000 -ske | --skip-existing-files)
2001 SKIP_EXISTING_FILES="yes"; shift ;;
2003 COMMAND="mr-proper"; shift ;;
2004 -ncs | --no-cvs-specs )
2005 NOCVSSPEC="yes"; shift ;;
2006 -nd | --no-distfiles )
2007 NODIST="yes"; shift ;;
2008 -nm | --no-mirrors )
2009 NOMIRRORS="yes"; shift ;;
2011 NOURLS="yes"; shift ;;
2013 NOSRCS="yes"; shift ;;
2014 -ns0 | --no-source0 )
2015 NOSOURCE0="yes"; shift ;;
2024 -pm | --prefer-mirrors )
2031 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2033 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2034 --skip-patch | -sp )
2035 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : skiping patch${1}\""; shift ;;
2037 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2040 --with | --without )
2041 case $GROUP_BCONDS in
2045 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2046 while ! `echo ${1}|grep -qE '(^-|spec)'`
2048 BCOND="$BCOND $COND $1"
2052 if [[ "$2" = *,* ]]; then
2053 for a in $(echo "$2" | tr , ' '); do
2054 BCOND="$BCOND $1 $a"
2057 BCOND="$BCOND $1 $2"
2063 shift; TARGET="${1}"; shift ;;
2065 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2067 QUIET="--quiet"; shift ;;
2069 CVSDATE="${2}"; shift 2 ;;
2078 -R | --fetch-build-requires)
2079 FETCH_BUILD_REQUIRES="yes"
2080 NOT_INSTALLED_PACKAGES=
2082 -RB | --remove-build-requires)
2083 REMOVE_BUILD_REQUIRES="nice"
2085 -FRB | --force-remove-build-requires)
2086 REMOVE_BUILD_REQUIRES="force"
2088 -sc | --sources-cvs)
2089 COMMAND="list-sources-cvs"
2091 -sd | --source-distfiles)
2092 COMMAND="list-sources-distfiles"
2094 -sdp | --source-distfiles-paths)
2095 COMMAND="list-sources-distfiles-paths"
2097 -sf | --source-files)
2098 COMMAND="list-sources-files"
2100 -lsp | --source-paths)
2101 COMMAND="list-sources-local-paths"
2103 -su | --source-urls)
2104 COMMAND="list-sources-urls"
2106 -Tvs | --tag-version-stable )
2111 -Ts | --tag-stable )
2116 -Tv | --tag-version )
2121 -Tp | --tag-prefix )
2133 -ir | --integer-release-only )
2134 INTEGER_RELEASE="yes"
2137 COMMAND="update_md5"
2142 -Upi | --update-poldek-indexes )
2143 UPDATE_POLDEK_INDEXES="yes"
2146 COMMAND="init_rpm_dir"
2148 -u | --try-upgrade )
2149 TRY_UPGRADE="1"; shift ;;
2151 shift; UPGRADE_VERSION="$1"; shift;;
2152 -un | --try-upgrade-with-float-version )
2153 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2155 BE_VERBOSE="1"; shift ;;
2160 if echo "${MACRO}" | grep -q '\W'; then
2161 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2165 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2170 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2174 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2177 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2178 COMMAND="show_bconds"
2182 COMMAND="show_bcond_args"
2185 --show-avail-bconds)
2186 COMMAND="show_avail_bconds"
2191 RPMOPTS="${RPMOPTS} --nodeps"
2194 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2197 Exit_error err_invalid_cmdline "$1"
2200 SPECFILE=${1%/}; shift
2201 # check if specname was passed as specname:cvstag
2202 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2203 CVSTAG="${SPECFILE##*:}"
2204 SPECFILE="${SPECFILE%%:*}"
2206 # always have SPECFILE ending with .spec extension
2207 SPECFILE=${SPECFILE%%.spec}.spec
2208 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2212 [ -d "$ASSUMED_NAME" ] && GIT_DIR="$ASSUMED_NAME/.git" || GIT_DIR=.git
2213 if [ -d "$GIT_DIR" ] && [ -z "$CVSTAG" ]; then
2214 if CVSTAG=$(GIT_DIR=$GIT_DIR git symbolic-ref HEAD) 2>/dev/null; then
2215 CVSTAG=${CVSTAG#refs/heads/}
2216 if [ "$CVSTAG" != "master" ]; then
2217 echo >&2 "builder: Active branch $CVSTAG. Use -r BRANCHNAME to override"
2220 echo >&2 "On detached HEAD. Use -r BRANCHNAME to override"
2223 elif [ "$CVSTAG" = "HEAD" ]; then
2224 # assume -r HEAD is same as -A
2228 if [ "$CVSTAG" ]; then
2229 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2230 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2233 if [ -n "$DEBUG" ]; then
2238 if [ -n "$TARGET" ]; then
2241 TARGET_SWITCH="--target $TARGET" ;;
2243 TARGET_SWITCH="--target=$TARGET" ;;
2247 if [ "$SCHEDTOOL" != "no" ]; then
2248 NICE_COMMAND="$SCHEDTOOL"
2250 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2253 update_shell_title "$COMMAND"
2257 if [ -z "$SPECFILE" ]; then
2258 Exit_error err_no_spec_in_cmdl
2260 get_spec > /dev/null
2267 if [ -z "$SPECFILE" ]; then
2268 Exit_error err_no_spec_in_cmdl
2270 get_spec > /dev/null
2275 "show_avail_bconds")
2277 if [ -z "$SPECFILE" ]; then
2278 Exit_error err_no_spec_in_cmdl
2281 get_spec > /dev/null
2283 local bcond_avail=$(find_spec_bcond $SPECFILE)
2284 local opt bcond bconds
2285 for opt in $bcond_avail; do
2288 bcond=${opt#without_}
2289 bconds="$bconds $bcond"
2293 bconds="$bconds $bcond"
2296 echo >&2 "ERROR: unexpected '$opt' in show_avail_bconds"
2304 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2306 if [ -z "$SPECFILE" ]; then
2307 Exit_error err_no_spec_in_cmdl
2310 # display SMP make flags if set
2311 smp_mflags=$(rpm -E %{?_smp_mflags})
2312 if [ "$smp_mflags" ]; then
2313 echo "builder: SMP make flags are set to $smp_mflags"
2321 if [ "$COMMAND" != "build-source" ]; then
2324 fetch_build_requires
2325 if [ "$INTEGER_RELEASE" = "yes" ]; then
2326 echo "Checking release $PACKAGE_RELEASE..."
2327 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2328 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2332 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2333 if [ -n "$TEST_TAG" ]; then
2334 local TAGVER=`make_tagver`
2335 echo "Searching for tag $TAGVER..."
2336 git show-ref --quiet --verify "refs/tags/$TAGVER" && Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2338 # - do not allow to build from HEAD when XX-branch exists
2339 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2340 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2341 TAG_BRANCH="${TREE_PREFIX}-branch"
2342 TAG_STATUS=$(git branch -r | grep -i "origin/$TAG_BRANCH$" | sed 's# *origin/##')
2343 if [ -n "$TAG_STATUS" -a -z "$CVSTAG" ]; then
2344 Exit_error err_branch_exists "$TAG_STATUS"
2350 if [ -n "$NOSOURCE0" ] ; then
2351 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2356 get_files $SOURCES $PATCHES
2360 NODIST="yes" get_files $SOURCES $PATCHES
2365 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2366 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2368 remove_build_requires
2372 if [ -z "$SPECFILE" ]; then
2373 Exit_error err_no_spec_in_cmdl
2382 if [ -z "$SPECFILE" ]; then
2383 Exit_error err_no_spec_in_cmdl
2386 ADD_PACKAGE_CVS=yes get_spec
2389 if [ -n "$NOSOURCE0" ] ; then
2390 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2392 get_files $SOURCES $PATCHES
2397 if [ -z "$SPECFILE" ]; then
2398 Exit_error err_no_spec_in_cmdl
2404 if [ -n "$NOSOURCE0" ] ; then
2405 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2407 get_files $SOURCES $PATCHES
2412 if [ -z "$SPECFILE" ]; then
2413 Exit_error err_no_spec_in_cmdl
2419 if [ -n "$NOSOURCE0" ] ; then
2420 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2428 if [ -z "$SPECFILE" ]; then
2429 Exit_error err_no_spec_in_cmdl
2439 "list-sources-files" )
2442 DONT_PRINT_REVISION="yes"
2445 for SAP in $SOURCES $PATCHES; do
2446 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2449 "list-sources-urls" )
2452 DONT_PRINT_REVISION="yes"
2455 SAPS="$SOURCES $PATCHES"
2456 for SAP in $SAPS ; do
2460 "list-sources-local-paths" )
2463 DONT_PRINT_REVISION="yes"
2466 for SAP in $SOURCES $PATCHES; do
2467 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2470 "list-sources-distfiles-paths" )
2473 DONT_PRINT_REVISION="yes"
2476 for SAP in $SOURCES $PATCHES; do
2477 if [ -n "$(src_md5 "$SAP")" ]; then
2478 distfiles_path "$SAP"
2482 "list-sources-distfiles" )
2485 DONT_PRINT_REVISION="yes"
2488 for SAP in $SOURCES $PATCHES; do
2489 if [ -n "$(src_md5 "$SAP")" ]; then
2490 distfiles_url "$SAP"
2494 "list-sources-cvs" )
2497 DONT_PRINT_REVISION="yes"
2500 for SAP in $SOURCES $PATCHES; do
2501 if [ -z "$(src_md5 "$SAP")" ]; then
2502 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2516 echo "$VERSIONSTRING"
2519 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2520 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2524 # vi:syntax=sh:ts=4:sw=4:noet