3 # This program is free software, distributed under the terms of
4 # the GNU General Public License Version 2.
10 # 2 - no spec file name in cmdl parameters
11 # 3 - spec file not stored in repo
12 # 4 - some source, patch or icon files not stored in repo
13 # 5 - package build failed
14 # 6 - spec file with errors
15 # 7 - wrong source in /etc/poldek.conf
16 # 8 - Failed installing buildrequirements and subrequirements
17 # 9 - Requested tag already exist
18 # 10 - Refused to build fractional release
19 # 100 - Unknown error (should not happen)
22 # - when Icon: field is present, -5 and -a5 doesn't work
23 # - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
24 # - does not respect NoSource: X, and tries to cvs up such files [ example: VirtualBox-bin.spec and its Source0 ]
26 # - ability to do ./builder -bb foo.spec foo2.spec foo3.spec
27 # - funny bug, if source-md5 is set then builder will download from distfiles even if there is no url present:
28 # Source10: forwardfix.pl
29 # # Source10-md5: 8bf85f7368933a4e0cb4f875bac28733
31 # basename: missing operand
32 # Try `basename --help' for more information.
33 # -- and the normal usage info --
36 APPDIR=$(d=$0; [ -L "$d" ] && d=$(readlink -f "$d"); dirname "$d")
37 RCSID='$Id$' r=${RCSID#* * } rev=${r%% *}
40 Build package utility from PLD Linux Packages repository
41 $VERSION (C) 1999-2011 Free Penguins".
43 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
45 # required rpm-build-macros
65 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
69 # use rpm 4.4.6+ digest format instead of comments if non-zero
72 # user agent when fetching files
73 USER_AGENT="PLD/Builder($VERSION)"
75 # It can be used i.e. in log file naming.
76 # See LOGFILE example.
77 DATE=`date +%Y-%m-%d_%H-%M-%S`
79 # Example: LOGFILE='../log.$PACKAGE_NAME'
80 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
81 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
82 # Example: LOGFILE='$PACKAGE_NAME.$DATE.log'
83 # Yes, you can use variable name! Note _single_ quotes!
98 # create symlinks for tools in PACKAGE_DIR, see get_spec()
109 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
111 CVS_COMMAND=${CVS_COMMAND:-cvs}
114 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
115 CVS_SERVER="cvs.pld-linux.org"
120 DISTFILES_SERVER="://distfiles.pld-linux.org"
121 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
126 FAIL_IF_NO_SOURCES="yes"
128 # let get_files skip over files which are present to get those damn files fetched
129 SKIP_EXISTING_FILES="no"
132 # should the specfile be restored if upgrade failed?
133 REVERT_BROKEN_UPGRADE="yes"
135 if rpm --specsrpm 2>/dev/null; then
136 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
137 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
139 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
140 if [ -x /usr/bin/rpm-getdeps ]; then
141 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
143 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
148 # Here we load saved user environment used to
149 # predefine options set above, or passed to builder
151 # This one reads global system environment settings:
152 if [ -f ~/etc/builderrc ]; then
155 # And this one cascades settings using user personal
157 # Example of ~/.builderrc:
159 #UPDATE_POLDEK_INDEXES="yes"
160 #FETCH_BUILD_REQUIRES="yes"
161 #REMOVE_BUILD_REQUIRES="force"
163 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
167 if [ -n "$HOME_ETC" ]; then
168 USER_CFG="$HOME_ETC/.builderrc"
169 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
171 USER_CFG=~/.builderrc
172 BUILDER_MACROS=~/.builder-rpmmacros
175 [ -f "$USER_CFG" ] && . "$USER_CFG"
177 if [ "$SCHEDTOOL" = "auto" ]; then
178 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
179 SCHEDTOOL="schedtool -B -e"
185 if [ -n "$USE_PROZILLA" ]; then
186 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
189 elif [ -n "$USE_AXEL" ]; then
190 GETURI="axel -a $AXEL_OPTS"
194 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
195 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
196 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
197 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
199 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
200 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
206 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
217 if [ -d $HOME/rpm/SOURCES ]; then
218 echo "ERROR: ~/rpm/{SPECS,SOURCES} structure is obsolete" >&2
219 echo "ERROR: get rid of your ~/rpm/SOURCES" >&2
224 # are we using cvs-nserver ?
227 $CVS_COMMAND --version 2>&1 | grep -q 'CVS-nserver'
228 [ $? -eq 0 ] && CVS_NSERVER=1
230 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
231 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
235 if [ -n "$LOGFILE" ]; then
236 LOG=`eval echo $LOGFILE`
237 if [ -n "$LASTLOG_FILE" ]; then
238 echo "LASTLOG=$LOG" > $LASTLOG_FILE
240 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
243 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
244 return `cat ${RES_FILE}`
249 #---------------------------------------------
253 if [ -n "$DEBUG" ]; then set -xv; fi
255 Usage: builder [-D|--debug] [-V|--version] [--short-version] [--as_anon] [-a|--add_cvs] [-b|-ba|--build]
256 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
257 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
258 [-g|--get] [-h|--help] [--ftp] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
259 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
260 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
261 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
262 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
263 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
264 <package>[.spec][:cvstag]
266 -4 - force ipv4 when transferring files
267 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
268 -6 - force ipv6 when transferring files
269 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
270 -n5, --no-md5 - ignore md5 comments in spec
271 -D, --debug - enable builder script debugging mode,
272 -debug - produce rpm debug package (same as --opts -debug)
273 -V, --version - output builder version string
274 --short-version - output builder short version
275 --as_anon - get files via pserver as cvs@$CVS_SERVER,
276 -a, --add_cvs - try add new package to CVS.
277 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
279 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
280 only package from <package>.spec,
281 -bp, --build-prep - execute the %prep phase of <package>.spec,
282 -bc - execute the %build phase of <package>.spec,
283 -bi - execute the %install phase of <package>.spec
284 -bl - execute the %files phase of <package>.spec
285 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
287 --short-circuit - short-circuit build
288 -B, --branch - add branch
289 -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
290 may be used with building process.
291 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
292 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
294 -cf, --cvs-force - use -F when tagging (useful when moving branches)
295 -d <cvsroot>, --cvsroot <cvsroot>
297 --define <macro> <value>
298 - define a macro <macro> with value <value>,
299 --alt_kernel <kernel>
300 - same as --define 'alt_kernel <kernel>'
301 --nodeps - rpm won't check any dependences
302 -g, --get - get <package>.spec and all related files from CVS repo
304 -h, --help - this message,
305 -jN, -j N - set %_smp_mflags to propagate concurrent jobs
306 --ftp, --http - use ftp or http protocol to access distfiles server
307 -l <logfile>, --logtofile <logfile>
309 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
311 - don't check specs in CVS
312 -nd, --no-distfiles - don't download from distfiles
313 -nm, --no-mirrors - don't download from mirror, if source URL is given,
314 -nu, --no-urls - don't try to download from FTP/HTTP location,
315 -ns, --no-srcs - don't download Sources/Patches
316 -ns0, --no-source0 - don't download Source0
317 -nn, --no-net - don't download anything from the net
318 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
319 --no-init - don't initialize builder paths (SPECS and SOURCES)
321 --skip-existing-files - skip existing files in get_files
322 --opts <rpm opts> - additional options for rpm
323 -q, --quiet - be quiet,
324 --date yyyy-mm-dd - build package using resources from specified CVS date,
325 -r <cvstag>, --cvstag <cvstag>
326 - build package using resources from specified CVS tag,
327 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
328 -R, --fetch-build-requires
329 - fetch what is BuildRequired,
330 -RB, --remove-build-requires
331 - remove all you fetched with -R or --fetch-build-requires
332 remember, this option requires confirmation,
333 -FRB, --force-remove-build-requires
334 - remove all you fetched with -R or --fetch-build-requires
335 remember, this option works without confirmation,
336 -sd, --source-distfiles - list sources available from distfiles (intended for offline
337 operations; does not work when Icon field is present
338 but icon file is absent),
339 -sc, --source-cvs - list sources available from CVS
340 -sdp, --source-distfiles-paths - list sources available from distfiles -
341 paths relative to distfiles directory (intended for offline
342 operations; does not work when Icon field is present
343 but icon file is absent),
344 -sf, --source-files - list sources - bare filenames (intended for offline
345 operations; does not work when Icon field is present
346 but icon file is absent),
347 -lsp, --source-paths - list sources - filenames with full local paths (intended for
348 offline operations; does not work when Icon field is present
349 but icon file is absent),
350 -su, --source-urls - list urls - urls to sources and patches
351 intended for copying urls with spec with lots of macros in urls
352 -T <cvstag> , --tag <cvstag>
353 - add cvs tag <cvstag> for files,
354 -Tvs, --tag-version-stable
355 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
357 - add cvs tag STABLE for files,
359 - add cvs tag NAME-VERSION-RELEASE for files,
360 -Tp, --tag-prefix <prefix>
361 - add <prefix> to NAME-VERSION-RELEASE tags,
362 -tt, --test-tag <prefix>
363 - fail if tag is already present,
364 -ir, --integer-release-only
365 - allow only integer and snapshot releases
366 -v, --verbose - be verbose,
367 -u, --try-upgrade - check version, and try to upgrade package
368 -un, --try-upgrade-with-float-version
369 - as above, but allow float version
370 php-pear-Services_Digg/
371 --upgrade-version - upgrade to specified version in try-upgrade
373 - try download source from tag head if don't find it in
375 -U, --update - refetch sources, don't use distfiles, and update md5 comments
376 -Upi, --update-poldek-indexes
377 - refresh or make poldek package index files.
378 -sp, --skip-patch <patchnumber>
379 - don't apply <patchnumber>. may be repeated.
380 -np, --nopatch <patchnumber>
381 - abort instead of applying patch <patchnumber>
382 --show-bconds - show available conditional builds, which can be used
383 - with --with and/or --without switches.
384 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
385 ./repackage.sh script. in other words, the output is
386 parseable by scripts.
387 --show-avail-bconds - show available bconds
388 --with/--without <feature>
389 - conditional build package depending on %_with_<feature>/
390 %_without_<feature> macro switch. You may now use
391 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
392 constructions. Set GROUP_BCONDS to yes to make use of it.
393 --target <platform>, --target=<platform>
394 - build for platform <platform>.
395 --init-rpm-dir - initialize ~/rpm directory structure
399 # create tempfile. as secure as possible
401 mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$
404 # change dependency to specname
406 # - perl(Package::Name) -> perl-Package-Name
410 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
414 update_shell_title() {
416 local len=${COLUMNS:-80}
417 local msg="$(echo "$*" | cut -c-$len)"
419 if [ -n "$BE_VERBOSE" ]; then
420 echo >&2 "$(date +%s.%N) $*"
423 if [ "x$TITLECHANGE" = "xyes" -o "x$TITLECHANGE" = "x" ]; then
425 if [ -n "$PACKAGE_NAME" ]; then
426 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
431 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
432 msg=$(echo $msg | tr -d '\n\r')
435 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
438 echo >&2 -ne "\033]0;$msg\007"
444 # set TARGET from BuildArch: from SPECFILE
446 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
447 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
449 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
453 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
455 TARGET_SWITCH="--target=$TARGET" ;;
461 # runs rpm with minimal macroset
463 # we reset macros not to contain macros.build as all the %() macros are
464 # executed here, while none of them are actually needed.
465 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
466 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
468 # TODO: move these to /usr/lib/rpm/macros
469 cat > $BUILDER_MACROS <<'EOF'
470 %x8664 x86_64 amd64 ia32e
473 %bootstrap_release() %{1}
474 %requires_releq_kernel_up(s:n:) %{nil}
475 %requires_releq_kernel_smp(s:n:) %{nil}
476 %requires_releq_kernel(s:n:) %{nil}
477 %requires_releq() %{nil}
478 %pyrequires_eq() %{nil}
479 %requires_eq() %{nil}
480 %requires_eq_to() %{nil}
481 %requires_ge() %{nil}
482 %requires_ge_to() %{nil}
483 %requires_ge() %{nil}
484 %releq_kernel_up(n:) ERROR
485 %releq_kernel_smp(n:) ERROR
486 %releq_kernel(n:) ERROR
490 %ruby_ver_requires_eq() %{nil}
491 %ruby_mod_ver_requires_eq() %{nil}
492 %__php_api_requires() %{nil}
493 %php_major_version ERROR
494 %php_api_version ERROR
495 %requires_xorg_xserver_extension %{nil}
496 %requires_xorg_xserver_xinput %{nil}
497 %requires_xorg_xserver_font %{nil}
498 %requires_xorg_xserver_videodrv %{nil}
500 %perl_vendorarch ERROR
501 %perl_vendorlib ERROR
502 # damn. need it here! - copied from /usr/lib/rpm/macros.build
503 %tmpdir %(echo "${TMPDIR:-/tmp}")
504 %patchset_source(f:b:) %(
505 base=%{-b*}%{!-b*:10000};
506 start=$(expr $base + %1);
507 end=$(expr $base + %{?2}%{!?2:%{1}});
508 # we need to call seq twice as it doesn't allow two formats
509 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
510 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
511 paste %{tmpdir}/__ps{1,2};
512 rm -f %{tmpdir}/__ps{1,2};
515 %add_etc_shells(p) %{p:<lua>}
516 %remove_etc_shells(p) %{p:<lua>}
517 %lua_add_etc_shells() %{nil}
518 %lua_remove_etc_shells() %{nil}
520 %buildrequires_jdk %{nil}
521 %pear_package_print_optionalpackages %{nil}
523 if [ "$NOINIT" = "yes" ] ; then
524 cat >> $BUILDER_MACROS <<'EOF'
529 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
533 if [ -n "$DEBUG" ]; then
538 if [ -x /usr/bin/rpm-specdump ]; then
539 update_shell_title "cache_rpm_dump using rpm-specdump command"
540 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
542 update_shell_title "cache_rpm_dump using rpmbuild command"
545 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
546 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
552 ARGS='--nodigest --nosignature --nobuild'
555 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
557 if [ $? -gt 0 ]; then
558 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
560 Exit_error err_build_fail
563 # make small dump cache
564 rpm_dump_cache=`echo "$rpm_dump" | awk '
565 $2 ~ /^SOURCEURL/ {print}
566 $2 ~ /^PATCHURL/ {print}
567 $2 ~ /^nosource/ {print}
568 $2 ~ /^PACKAGE_/ {print}
572 update_shell_title "cache_rpm_dump: OK!"
576 if [ -z "$rpm_dump_cache" ] ; then
577 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
579 echo "$rpm_dump_cache"
583 update_shell_title "get icons"
584 ICONS=$(awk '/^Icon:/ {print $2}' $PACKAGE_DIR/${SPECFILE})
585 if [ -z "$ICONS" ]; then
589 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
593 update_shell_title "parsing specfile"
594 if [ -n "$DEBUG" ]; then
599 # icons are needed for successful spec parse
605 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
606 FAIL_IF_NO_SOURCES="no"
609 if [ "$NOSRCS" != "yes" ]; then
610 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
611 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
612 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
615 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
616 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
617 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
619 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
620 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
623 if [ -n "$BE_VERBOSE" ]; then
624 echo "- Sources : `nourl $SOURCES`"
625 if [ -n "$PATCHES" ]; then
626 echo "- Patches : `nourl $PATCHES`"
628 echo "- Patches : *no patches needed*"
630 if [ -n "$ICONS" ]; then
631 echo "- Icon : `nourl $ICONS`"
633 echo "- Icon : *no package icon*"
635 echo "- Name : $PACKAGE_NAME"
636 echo "- Version : $PACKAGE_VERSION"
637 echo "- Release : $PACKAGE_RELEASE"
640 update_shell_title "parse_spec: OK!"
644 if [ -n "$DEBUG" ]; then
652 "err_no_spec_in_cmdl" )
653 remove_build_requires
654 echo >&2 "ERROR: spec file name not specified."
656 "err_invalid_cmdline" )
657 echo >&2 "ERROR: invalid command line arg ($2)."
659 "err_no_spec_in_repo" )
660 remove_build_requires
661 echo >&2 "Error: spec file not stored in CVS repo."
663 "err_no_source_in_repo" )
664 remove_build_requires
665 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
667 "err_cvs_add_failed" )
668 echo >&2 "Error: failed to add package to CVS repo."
671 remove_build_requires
672 echo >&2 "Error: package build failed. (${2:-no more info})"
674 "err_no_package_data" )
675 remove_build_requires
676 echo >&2 "Error: couldn't get out package name/version/release from spec file."
679 remove_build_requires
680 echo >&2 "Tag ${2} already exists (spec release: ${3})."
683 remove_build_requires
684 echo >&2 "Release ${2} not integer and not a snapshot."
686 "err_branch_exists" )
687 remove_build_requires
688 echo >&2 "Tree branch already exists (${2})."
691 remove_build_requires
692 echo >&2 "Error: conditions reject building this spec (${2})."
695 echo >&2 "Unknown error."
700 if [ -n "$DEBUG" ]; then
705 if [ "$NOINIT" != "yes" ] ; then
706 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
708 local macros_ver=$(rpm -E %?rpm_build_macros)
709 if [ -z "$macros_ver" ]; then
710 REPO_DIR=$TOP_DIR/packages
711 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
713 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
714 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
718 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
730 update_shell_title "get_spec"
732 if [ -n "$DEBUG" ]; then
738 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
740 SPECFILE=$(basename $SPECFILE)
743 if [ "$NOCVSSPEC" != "yes" ]; then
744 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
745 echo "Warning: No CVS access defined - using local .spec file"
749 if [ -d "$ASSUMED_NAME" -a -s "$ASSUMED_NAME/CVS/Root" ]; then
750 cvsup "$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
751 elif [ "$ADD_PACKAGE_CVS" = "yes" ]; then
752 if [ ! -r "$ASSUMED_NAME/$SPECFILE" ]; then
753 echo "ERROR: No package to add ($ASSUMED_NAME/$SPECFILE)" >&2
756 if [ ! -s "$ASSUMED_NAME/CVS/Root" ]; then
757 cvsup -a $ASSUMED_NAME || Exit_error err_cvs_add_failed
759 cvsup -a "$ASSUMED_NAME/$SPECFILE" || Exit_error err_cvs_add_failed
761 cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || {
762 # softfail if new package, i.e not yet added to cvs
763 [ ! -f "$ASSUMED_NAME/$SPECFILE" ] && Exit_error err_no_spec_in_repo
764 echo "Warning: package not in CVS - assuming new package"
769 # remove Entries.Static -- so 'cvs up' would update all files in a repo
770 rm -f "$ASSUMED_NAME/CVS/Entries.Static"
773 cvsignore_df .cvsignore
775 # add default log format to .cvsignore if it is relative to package dir
776 if [ -n "$LOGFILE" -a "$LOGFILE" = "${LOGFILE##*/}" ]; then
777 # substitute known "macros" to glob
778 local logfile=$(echo "$LOGFILE" | sed -e 's,\$\(PACKAGE_NAME\|DATE\),*,g')
779 if [ "$logfile" ]; then
780 cvsignore_df "$logfile"
784 # create symlinks for tools
785 if [ "$SYMLINK_TOOLS" != "no" ]; then
786 for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do
787 [ -f $a ] || continue
788 ln -s ../$a $ASSUMED_NAME
794 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
795 Exit_error err_no_spec_in_repo
798 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
799 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
802 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
810 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
811 $CVS_COMMAND update mirrors >&2
815 local origin mirror name rest ol prefix
816 while read origin mirror name rest; do
817 # skip comments and empty lines
818 if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then
821 ol=$(echo -n "$origin" | wc -c)
822 prefix=$(echo -n "$url" | head -c $ol)
823 if [ "$prefix" = "$origin" ] ; then
824 suffix=$(echo "$url" | cut -b $((ol+1))-)
825 echo -n "$mirror$suffix"
832 # Warning: unpredictable results if same URL used twice
835 # escape some regexp characters if part of file name
836 file=$(echo "$file" | sed -e 's#\([\+\*\.]\)#\\\1#g')
839 grep -E "(SOURCE|PATCH)URL[0-9]*[ ]*${file}""[ ]*$" | \
840 sed -e 's/.*\(SOURCE\|PATCH\)URL\([0-9][0-9]*\).*/\1\2/' | \
841 head -n 1 | tr OURCEATH ourceath | xargs
845 [ "$NO5" = "yes" ] && return
847 [ -z "$no" ] && return
851 if [ -f additional-md5sums ]; then
852 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
853 if [ -z "$spec_rev" ]; then
854 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
856 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
857 md5=$(grep -s -v '^#' additional-md5sums | \
858 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
859 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
860 grep -E '^[0-9a-f]{32}$')
863 if [ $(echo "$md5" | wc -l) != 1 ] ; then
864 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
866 echo "$md5" | tail -n 1
871 source_md5=`grep -i "^#[ ]*$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
872 if [ -n "$source_md5" ]; then
875 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
876 if [ -n "$source_md5" ]; then
879 # we have empty SourceX-md5, but it is still possible
880 # that we have NoSourceX-md5 AND NoSource: X
881 nosource_md5=`grep -i "^#[ ]*No$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
882 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
890 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
894 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
897 distfiles_attic_url() {
898 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
904 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
908 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
909 [ -n "$size" -a "$size" -gt 0 ]
913 if [ "$CVSIGNORE_DF" != "yes" ]; then
916 cvsignore=${PACKAGE_DIR}/.cvsignore
918 # add only if not yet there
919 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
920 echo "$1" >> $cvsignore
925 update_shell_title "cvsup"
926 local OPTIONS="" ACTION="up"
929 if [ "$1" = "-c" ]; then
934 if [ "$1" = "-a" ]; then
941 if [ -n "$CVSROOT" ]; then
942 OPTIONS="-d $CVSROOT $OPTIONS"
945 if [ "$ACTION" != "add" ]; then
946 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
947 OPTIONS="$OPTIONS -A"
949 if [ -n "$CVSDATE" ]; then
950 OPTIONS="$OPTIONS -D $CVSDATE"
952 if [ -n "$CVSTAG" ]; then
953 # FIXME: cvs add actually works with -r ?
954 OPTIONS="$OPTIONS -r $CVSTAG"
960 local retries_counter=0
962 update_shell_title "cvsup: $*"
964 update_shell_title "cvsup: $# files"
966 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
967 retries_counter=$(( $retries_counter + 1 ))
968 output=$(LC_ALL=C $CVS_COMMAND $OPTIONS "$@" 2>&1)
970 [ -n "$output" ] && echo "$output"
971 if echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out|Unknown host)" \
972 && [ "$result" -ne "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; then
973 echo "Trying again [$*]... ($retries_counter)"
974 update_shell_title "cvsup: retry #$retries_counter"
981 update_shell_title "cvsup: done!"
985 # returns true if "$1" is ftp, http or https protocol url
988 ftp://*|http://*|https://*)
996 if [ $# -eq 0 ]; then
1000 update_shell_title "update md5"
1001 if [ -n "$DEBUG" ]; then
1008 # pass 1: check files to be fetched
1012 local fp=$(nourl "$i")
1013 local srcno=$(src_no "$i")
1014 if [ -n "$ADD5" ]; then
1015 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
1016 grep -qiE '^#[ ]*'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
1017 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
1019 grep -qiE '^#[ ]*'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
1021 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1022 need_files="$need_files $i"
1026 # pass 1a: get needed files
1027 if [ "$need_files" ]; then
1028 get_files $need_files
1031 # pass 2: proceed with md5 adding or updating
1033 local fp=$(nourl "$i")
1034 local srcno=$(src_no "$i")
1035 local md5=$(grep -iE '^#[ ]*(No)?'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
1036 if [ -z "$md5" ]; then
1037 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
1039 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
1040 local tag="# $srcno-md5:\t"
1041 if [[ "$md5" == *NoSource* ]]; then
1042 tag="# NoSource$srcno-md5:\t"
1043 elif [ -n "$USEDIGEST" ]; then
1044 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
1046 md5=$(md5sum "$fp" | cut -f1 -d' ')
1047 echo "Updating $srcno ($md5: $fp)."
1049 print unless (/^\s*#\s*(No)?'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
1050 print "'"$tag$md5"'\n" if /^'$srcno'\s*:\s+/i;
1052 $PACKAGE_DIR/$SPECFILE
1059 [ "$NO5" = "yes" ] && return
1061 update_shell_title "check md5"
1065 if ! good_md5 "$i"; then
1066 echo -n "MD5 sum mismatch."
1069 if ! good_size "$i"; then
1070 echo -n "0 sized file."
1074 if [ $bad -eq 1 ]; then
1075 echo " Use -U to refetch sources,"
1076 echo "or -5 to update md5 sums, if you're sure files are correct."
1077 Exit_error err_no_source_in_repo $i
1083 update_shell_title "get_files"
1085 if [ -n "$DEBUG" ]; then
1090 if [ $# -gt 0 ]; then
1093 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
1094 echo "Warning: No CVS access defined for SOURCES"
1099 local get_files_cvs=""
1103 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1104 update_shell_title "$i"
1105 local fp=`nourl "$i"`
1106 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1111 local srcmd5=$(src_md5 "$i")
1113 # we know if source/patch is present in cvs/distfiles
1114 # - has md5 (in distfiles)
1115 # - in cvs... ideas?
1117 # CHECK: local file didn't exist or always cvs up (first) requested.
1118 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1119 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1120 echo "Warning: no URL given for $i"
1124 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1125 if good_md5 "$i" && good_size "$i"; then
1126 echo "$fp having proper md5sum already exists"
1130 # optionally prefer mirror over distfiles if there's mirror
1131 # TODO: build url list and then try each url from the list
1132 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1135 url=$(distfiles_url "$i")
1138 url_attic=$(distfiles_attic_url "$i")
1140 # is $url local file?
1141 if [[ "$url" = [./]* ]]; then
1142 update_shell_title "${GETLOCAL%% *}: $url"
1143 ${GETLOCAL} $url $target
1145 if [ -z "$NOMIRRORS" ]; then
1146 url=$(find_mirror "$url")
1150 # make shorter message for distfiles urls
1151 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1152 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1153 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1156 update_shell_title "${GETURI%% *}: $uri"
1157 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1158 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1159 update_shell_title "${GETURI2%% *}: $url"
1160 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1165 if [ ! -s "$target" ]; then
1167 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1168 update_shell_title "${GETLOCAL%% *}: $url_attic"
1169 ${GETLOCAL} $url_attic $target
1171 if [ -z "$NOMIRRORS" ]; then
1172 url_attic=$(find_mirror "$url_attic")
1174 update_shell_title "${GETURI%% *}: $url_attic"
1175 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1176 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1177 update_shell_title "${GETURI2%% *}: $url_attic"
1178 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1180 test -s "$target" || rm -f "$target"
1184 if [ -s "$target" ]; then
1185 cvsignore_df $target
1190 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1191 if [ $# -gt 1 ]; then
1192 get_files_cvs="$get_files_cvs $fp"
1193 update_shell_title "$fp (will cvs up later)"
1200 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1201 if [ -z "$NOMIRRORS" ]; then
1202 im=$(find_mirror "$i")
1206 update_shell_title "${GETURI%% *}: $im"
1207 ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
1208 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1209 update_shell_title "${GETURI2%% *}: $im"
1210 ${GETURI2} "$im" ${OUTFILEOPT} "$target"
1212 test -s "$target" || rm -f "$target"
1215 if [ "$cvsup" = 1 ]; then
1221 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1222 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1223 if [ -n "GREEDSRC" ]; then
1224 get_greed_sources $i
1226 Exit_error err_no_source_in_repo $i
1230 # we check md5 here just only to refetch immediately
1231 if good_md5 "$i" && good_size "$i"; then
1233 elif [ "$FROM_DISTFILES" = 1 ]; then
1234 # wrong md5 from distfiles: remove the file and try again
1236 echo "MD5 sum mismatch. Trying full fetch."
1239 update_shell_title "${GETURI%% *}: $url"
1240 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1241 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1242 update_shell_title "${GETURI2%% *}: $url"
1243 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1245 if [ ! -s "$target" ]; then
1247 update_shell_title "${GETURI%% *}: $url_attic"
1248 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1249 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1250 update_shell_title "${GETURI2%% *}: $url_attic"
1251 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1254 test -s "$target" || rm -f "$target"
1257 SHELL_TITLE_PREFIX=""
1259 if [ "$get_files_cvs" ]; then
1260 cvsup $get_files_cvs
1263 if [ "$CHMOD" = "yes" ]; then
1264 CHMOD_FILES=$(nourl "$@")
1265 if [ -n "$CHMOD_FILES" ]; then
1266 chmod $CHMOD_MODE $CHMOD_FILES
1273 if [ -n "$DEBUG" ]; then
1278 # Check whether first character of PACKAGE_NAME is legal for tag name
1279 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1283 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1284 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1286 # Remove #kernel.version_release from TAGVER because tagging sources
1287 # could occur with different kernel-headers than kernel-headers used at build time.
1288 # besides, %{_kernel_ver_str} is not expanded.
1290 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1291 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1297 # bool is_tag_a_branch(tag)
1299 # returns 1 if a tag is a branch set on SPECFILE
1301 if [ -n "$DEBUG" ]; then
1306 if [ $# -ne 1 ]; then
1311 # escape some regexp characters if part of TAG
1312 TAG=$(echo "$TAG" | sed -e 's#\([\+\*\.]\)#\\\1#g')
1316 $CVS_COMMAND status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1323 if [ -n "$DEBUG" ]; then
1328 echo "Version: $PACKAGE_VERSION"
1329 echo "Release: $PACKAGE_RELEASE"
1332 if [ "$TAG_VERSION" = "yes" ]; then
1333 TAGVER=`make_tagver`
1334 echo "CVS tag: $TAGVER"
1336 if [ -n "$TAG" ]; then
1337 echo "CVS tag: $TAG"
1340 local OPTIONS="tag $CVS_FORCE"
1341 if [ -n "$CVSROOT" ]; then
1342 OPTIONS="-d $CVSROOT $OPTIONS"
1345 # if a tagname we are about to set already exists
1346 # and happens to be a branch (common case with AC-branch)
1347 # pass -B (allows -F to disturb branch tag)
1349 if [ "$TAG_VERSION" = "yes" ]; then
1352 is_tag_a_branch $_tag
1353 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1354 OPTIONS="$OPTIONS -B"
1359 for i in $TAG_FILES; do
1360 # don't tag files stored on distfiles
1361 [ -n "`src_md5 $i`" ] && continue
1362 local fp=`nourl "$i"`
1363 if [ -f "$fp" ]; then
1364 tag_files="$tag_files $fp"
1365 elif [ -n "GREEDSRC" ]; then
1366 get_greed_sources $i
1368 Exit_error err_no_source_in_repo $i
1372 if [ "$tag_files" ]; then
1373 if [ "$TAG_VERSION" = "yes" ]; then
1374 update_shell_title "tag sources: $TAGVER"
1375 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1376 $CVS_COMMAND $OPTIONS $TAGVER $tag_files || exit
1378 if [ -n "$TAG" ]; then
1379 update_shell_title "tag sources: $TAG"
1381 while [ "$tag_files" ]; do
1382 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1383 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1384 $CVS_COMMAND $OPTIONS $TAG $chunk || exit
1385 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1391 if [ "$TAG_VERSION" = "yes" ]; then
1392 update_shell_title "tag spec: $TAGVER"
1393 $CVS_COMMAND $OPTIONS $TAGVER $SPECFILE || exit
1395 if [ -n "$TAG" ]; then
1396 update_shell_title "tag spec: $TAG"
1397 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1403 echo "CVS branch tag: $TAG"
1408 if [ -n "$DEBUG" ]; then
1413 local OPTIONS="tag $CVS_FORCE -b"
1416 is_tag_a_branch $TAG
1417 if [ $? -eq 1 ]; then
1418 OPTIONS="$OPTIONS -B"
1421 if [ -n "$CVSROOT" ]; then
1422 OPTIONS="-d $CVSROOT $OPTIONS"
1426 for i in $TAG_FILES; do
1427 local fp=`nourl "$i"`
1428 if [ -f "$fp" ]; then
1429 tag_files="$tag_files $fp"
1430 elif [ -n "GREEDSRC" ]; then
1431 get_greed_sources $i
1433 Exit_error err_no_source_in_repo $i
1436 if [ "$tag_files" ]; then
1437 $CVS_COMMAND $OPTIONS $TAG $tag_files || exit
1441 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1445 # this function should exit early if package can't be built for this arch
1446 # this avoids unneccessary BR filling.
1449 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1451 if [ $ret -ne 0 ]; then
1463 s/^\(%define[ \t]\+_\?rel[ \t]\+\)$rel\$/\1$newrel/
1464 s/^\(Release:[ \t]\+\)$rel\$/\1$newrel/
1470 local ver="$2" subver=$ver
1471 local newver="$3" newsubver=$newver
1473 # try handling subver, everything that's not numeric-dotted in version
1474 if grep -Eq '%define\s+subver' $specfile; then
1475 subver=$(echo "$ver" | sed -re 's,^[0-9.]+,,')
1477 newsubver=$(echo "$newver" | sed -re 's,^[0-9.]+,,')
1478 newver=${newver%$newsubver}
1481 s/^\(%define[ \t]\+_\?ver[ \t]\+\)$ver\$/\1$newver/
1482 s/^\(%define[ \t]\+subver[ \t]\+\)$subver\$/\1$newsubver/
1483 s/^\(Version:[ \t]\+\)$ver\$/\1$newver/
1488 if [ -n "$TRY_UPGRADE" ]; then
1489 local TNOTIFY TNEWVER TOLDVER
1490 update_shell_title "build_package: try_upgrade"
1494 if [ "$UPGRADE_VERSION" ]; then
1495 TNEWVER=$UPGRADE_VERSION
1497 if [ -n "$FLOAT_VERSION" ]; then
1498 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
1500 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
1503 # pldnotify.awk does not set exit codes, but it has match for ERROR
1504 # in output which means so.
1505 if [[ "$TNOTIFY" = *ERROR* ]]; then
1510 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1513 if [ -n "$TNEWVER" ]; then
1514 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1515 echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
1516 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1517 cp -f $SPECFILE $SPECFILE.bak
1520 set_release $SPECFILE $PACKAGE_RELEASE 1
1521 set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
1523 if [ "$PACKAGE_VERSION" != "$TNEWVER" ]; then
1524 echo >&2 "Upgrading version failed, you need to update spec yourself"
1534 update_shell_title "build_package"
1535 if [ -n "$DEBUG" ]; then
1544 BUILD_SWITCH="-ba" ;;
1546 BUILD_SWITCH="-bb" ;;
1548 BUILD_SWITCH="-bs --nodeps" ;;
1550 BUILD_SWITCH="-bp --nodeps" ;;
1552 BUILD_SWITCH="-bc" ;;
1554 BUILD_SWITCH="-bi" ;;
1556 BUILD_SWITCH="-bl" ;;
1560 update_shell_title "build_package: $COMMAND"
1561 if [ -n "$LOGFILE" ]; then
1562 LOG=`eval echo $LOGFILE`
1563 if [ -d "$LOG" ]; then
1564 echo "Log file $LOG is a directory."
1565 echo "Parse error in the spec?"
1566 Exit_error err_build_fail
1568 if [ -n "$LASTLOG_FILE" ]; then
1569 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1571 RES_FILE=$(tempfile)
1573 (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
1574 RETVAL=`cat $RES_FILE`
1576 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1577 if [ "$RETVAL" -eq "0" ]; then
1584 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1587 if [ "$RETVAL" -ne "0" ]; then
1588 if [ -n "$TRY_UPGRADE" ]; then
1589 echo "\nUpgrade package to new version failed."
1590 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1591 echo "Restoring old spec file."
1592 mv -f $SPECFILE.bak $SPECFILE
1596 Exit_error err_build_fail
1602 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1605 install_required_packages() {
1610 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1613 /^%changelog/ { exit }
1615 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1616 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1617 gsub(/[ \t]+/, "_", bcond);
1619 }' $SPEC | LC_ALL=C sort -u
1623 # expand bconds from ~/.bcondrc
1624 # The file structure is like gentoo's package.use:
1627 # samba -mysql -pgsql
1628 # w32codec-installer license_agreement
1631 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1637 SN=${SPECFILE%%\.spec}
1639 local bcondrc=$HOME/.bcondrc
1640 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1642 local bcond_avail=$(find_spec_bcond $SPECFILE)
1644 while read pkg flags; do
1646 [[ "$pkg" == \#* ]] && continue
1648 # any package or current package?
1649 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1650 for flag in $flags; do
1651 local opt=${flag#[+-]}
1653 # use only flags which are in this package.
1654 if [[ $bcond_avail = *${opt}* ]]; then
1655 if [[ $flag = -* ]]; then
1656 if [[ $BCOND != *--with?${opt}* ]]; then
1657 BCOND="$BCOND --without $opt"
1660 if [[ $BCOND != *--without?${opt}* ]]; then
1661 BCOND="$BCOND --with $opt"
1668 update_shell_title "parse ~/.bcondrc: DONE!"
1671 set_bconds_values() {
1672 update_shell_title "set bcond values"
1674 AVAIL_BCONDS_WITHOUT=""
1675 AVAIL_BCONDS_WITH=""
1677 if grep -Eq '^# *_with' ${SPECFILE}; then
1678 echo >&2 "ERROR: This spec has old style bconds."
1682 if ! grep -q '^%bcond' ${SPECFILE}; then
1686 local bcond_avail=$(find_spec_bcond $SPECFILE)
1687 process_bcondrc "$SPECFILE"
1689 update_shell_title "parse bconds"
1692 for opt in $bcond_avail; do
1695 bcond=${opt#without_}
1697 *--without?${bcond}*)
1698 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1701 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1709 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1712 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1717 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1726 update_shell_title "run_sub_builder $package_name"
1728 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1729 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1730 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1731 # jakby nie bylo tego kawalka kodu.
1733 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1734 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1738 # kurwa. translate that ^^^^
1742 # Istnieje taki spec? ${package}.spec
1743 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1744 parent_spec_name=${package}.spec
1745 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1746 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1748 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1753 if [ "${parent_spec_name}" != "" ]; then
1754 spawn_sub_builder $parent_spec_name
1756 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1759 spawn_sub_builder() {
1761 update_shell_title "spawn_sub_builder $package_name"
1764 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1765 sub_builder_opts="${sub_builder_opts} -R"
1767 if [ "${REMOVE_BUILD_REQUIRES}" = "nice" ]; then
1768 sub_builder_opts="${sub_builder_opts} -RB"
1769 elif [ "${REMOVE_BUILD_REQUIRES}" = "force" ]; then
1770 sub_builder_opts="${sub_builder_opts} -FRB"
1772 if [ "${UPDATE_POLDEK_INDEXES}" = "yes" ]; then
1773 sub_builder_opts="${sub_builder_opts} -Upi"
1777 ./builder ${sub_builder_opts} "$@"
1780 remove_build_requires() {
1781 if [ "$INSTALLED_PACKAGES" != "" ]; then
1782 case "$REMOVE_BUILD_REQUIRES" in
1784 run_poldek --noask -ve $INSTALLED_PACKAGES
1787 run_poldek --ask -ve $INSTALLED_PACKAGES
1790 echo You may want to manually remove following BuildRequires fetched:
1791 echo $INSTALLED_PACKAGES
1792 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1799 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1800 if [ "$BCOND" ]; then
1802 echo "Building $SPECFILE with the following conditional flags:"
1806 echo "No conditional flags passed"
1809 echo "from available:"
1810 echo "--with :\t$AVAIL_BCONDS_WITH"
1811 echo "--without:\t$AVAIL_BCONDS_WITHOUT"
1816 display_branches() {
1817 if [ "$NOCVSSPEC" != "yes" ]; then
1818 echo -n "Available branches: "
1819 $CVS_COMMAND status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1823 # checks a given list of packages/files/provides agains current rpmdb.
1824 # outputs all dependencies which current rpmdb doesn't satisfy.
1825 # input can be either STDIN or parameters
1829 if [ $# -gt 0 ]; then
1835 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1838 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1840 # other deps (files)
1841 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1844 # checks if given package/files/provides exists in rpmdb.
1845 # input can be either stdin or parameters
1846 # returns packages which are present in the rpmdb
1850 if [ $# -gt 0 ]; then
1856 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1859 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1860 install_build_requires_rpmdeps() {
1861 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1862 # TODO: Conflicts list doesn't check versions
1863 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1864 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1866 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1867 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1868 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1871 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1872 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1873 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1874 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1876 if [ -n "$CNFL" ]; then
1877 update_shell_title "uninstall conflicting packages: $CNFL"
1878 echo "Trying to uninstall conflicting packages ($CNFL):"
1879 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1882 while [ "$DEPS" ]; do
1883 update_shell_title "install deps: $DEPS"
1884 echo "Trying to install dependencies ($DEPS):"
1885 local log=.${SPECFILE}_poldek.log
1886 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1887 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1890 if [ -n "$failed" ]; then
1891 for package in $failed; do
1892 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1901 fetch_build_requires()
1903 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1907 update_shell_title "fetch build requires"
1908 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1909 install_build_requires_rpmdeps
1913 # XXX is this ugliest code written in human history still needed?
1914 echo "All packages installed by fetch_build_requires() are written to:"
1915 echo "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1917 echo "If anything fails, you may get rid of them by executing:"
1918 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`"
1920 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1921 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)
1923 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)
1925 package=$(basename "$package_item"|sed -e "s/}$//g")
1926 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1929 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1930 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1931 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
1936 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1939 if `echo $COND_TST|grep -q 'without_'`; then
1940 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1941 if `echo $COND_TST|grep -q !`; then
1946 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1947 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1948 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1954 elif `echo $COND_TST|grep -q 'with_'`; then
1955 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1956 if `echo $COND_TST|grep -q !`; then
1961 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1962 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1963 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1969 RESULT="${COND_STATE}-${COND_ARGV}"
1971 "with-wout" | "wout-with" )
1974 "wout-wout" | "with-with" )
1978 echo "Action '$RESULT' was not defined for package '$package_item'"
1984 if [ "$GO" = "yes" ]; then
1985 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1986 echo "Testing if $package has subrequirements..."
1987 run_poldek -t -i $package --dumpn=".$package-req.txt"
1988 if [ -f ".$package-req.txt" ]; then
1989 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1991 if [ "$package_name" = "$package" ]; then
1992 echo "Installing BuildRequired package:\t$package_name"
1993 update_shell_title "Installing BuildRequired package: ${package_name}"
1994 install_required_packages $package
1996 echo "Installing (sub)Required package:\t$package_name"
1997 update_shell_title "Installing (sub)Required package: ${package_name}"
1998 install_required_packages $package_name
2002 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
2003 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
2006 echo "Attempting to run spawn sub - builder..."
2007 echo "Package installation failed:\t$package_name"
2008 run_sub_builder $package_name
2009 if [ $? -eq 0 ]; then
2010 install_required_packages $package_name
2013 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
2014 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
2017 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
2024 rm -f ".$package-req.txt"
2026 echo "Attempting to run spawn sub - builder..."
2027 echo "Package installation failed:\t$package"
2028 run_sub_builder $package
2029 if [ $? -eq 0 ]; then
2030 install_required_packages $package
2033 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
2034 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
2037 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
2043 echo "Package $package is already installed. BuildRequirement satisfied."
2047 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
2048 echo >&2 "Unable to install following packages and their dependencies:"
2049 for pkg in "$NOT_INSTALLED_PACKAGES"
2053 remove_build_requires
2059 local CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
2060 local TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
2061 local rpmdir=$(eval $RPM $RPMOPTS --eval '%{_rpmdir}')
2062 local buildir=$(eval $RPM $RPMOPTS --eval '%{_builddir}')
2063 local srpmdir=$(eval $RPM $RPMOPTS --eval '%{_srcrpmdir}')
2066 echo "Initializing rpm directories to $TOP_DIR from $CVSROOT"
2067 mkdir -p $TOP_DIR $rpmdir $buildir $srpmdir
2069 # need to checkout to tmp dir or we can't name our topdir
2070 tmp=$(TMPDIR= TEMPDIR= mktemp -p $TOP_DIR -d) || exit 1
2072 $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh,ci,civim}
2074 mv $tmp/packages/* $TOP_DIR
2079 echo "To checkout *all* .spec files (read-only):"
2080 echo "- run cvs co SPECS"
2082 echo "To checkout *all* packages:"
2083 echo "- run cvs up -dP in $TOP_DIR dir"
2086 echo "To commit with your developer account:"
2087 echo "- edit $TOP_DIR/CVS/Root"
2090 get_greed_sources() {
2091 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
2092 if [ -n "BE_VERBOSE" ]; then
2093 echo "Try greed download: $1 from: $CVSROOT"
2095 $CVS_COMMAND -d $CVSROOT get SOURCES/$1
2096 if [ $? != 0 ]; then
2097 Exit_error err_no_source_in_repo $1
2102 # remove entries from CVS/Entries
2103 cvs_entry_remove() {
2104 local cvsdir="$1"; shift
2105 if [ ! -d "$cvsdir" ]; then
2106 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
2110 for file in "$@"; do
2111 rm -f $cvsdir/CVS/Entries.new || return 1
2112 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
2113 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
2121 DONT_PRINT_REVISION="yes"
2125 # remove from CVS/Entries
2126 cvs_entry_remove $PACKAGE_DIR $SPECFILE $SOURCES $PATCHES
2128 # remove spec and sources
2129 $RPMBUILD --clean --rmsource --rmspec --nodeps --define "_specdir $PACKAGE_DIR" --define "_sourcedir $PACKAGE_DIR" $SPECFILE
2132 #---------------------------------------------
2140 while [ $# -gt 0 ]; do
2143 # NOTE: we should be fetcher specific, like fille WGET_OPTS, but
2144 # unfortunately $GETURI is already formed
2149 COMMAND="update_md5"
2154 COMMAND="update_md5"
2164 DEBUG="yes"; shift ;;
2166 COMMAND="version"; shift ;;
2168 COMMAND="short-version"; shift ;;
2170 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
2174 -b | -ba | --build )
2175 COMMAND="build"; shift ;;
2176 -bb | --build-binary )
2177 COMMAND="build-binary"; shift ;;
2179 COMMAND="build-build"; shift ;;
2181 COMMAND="build-install"; shift ;;
2183 COMMAND="build-list"; shift ;;
2184 -bp | --build-prep )
2185 COMMAND="build-prep"; shift ;;
2186 -bs | --build-source )
2187 COMMAND="build-source"; shift ;;
2189 COMMAND="branch"; shift; TAG="${1}"; shift;;
2191 CLEAN="--clean"; shift ;;
2193 CVS_FORCE="-F"; shift;;
2195 shift; CVSROOT="${1}"; shift ;;
2197 COMMAND="get"; shift ;;
2199 COMMAND="usage"; shift ;;
2201 PROTOCOL="ftp"; shift ;;
2203 PROTOCOL="http"; shift ;;
2205 RPMOPTS="${RPMOPTS} --define \"_smp_mflags -j$2\""
2209 RPMOPTS="${RPMOPTS} --define \"_smp_mflags $1\""
2213 shift; LOGFILE="${1}"; shift ;;
2215 shift; DEF_NICE_LEVEL=${1}; shift ;;
2216 -ske | --skip-existing-files)
2217 SKIP_EXISTING_FILES="yes"; shift ;;
2219 COMMAND="mr-proper"; shift ;;
2221 NOCVS="yes"; shift ;;
2222 -ncs | --no-cvs-specs )
2223 NOCVSSPEC="yes"; shift ;;
2224 -nd | --no-distfiles )
2225 NODIST="yes"; shift ;;
2226 -nm | --no-mirrors )
2227 NOMIRRORS="yes"; shift ;;
2229 NOURLS="yes"; shift ;;
2231 NOSRCS="yes"; shift ;;
2232 -ns0 | --no-source0 )
2233 NOSOURCE0="yes"; shift ;;
2243 -pm | --prefer-mirrors )
2250 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2252 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2253 --skip-patch | -sp )
2254 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : skiping patch${1}\""; shift ;;
2256 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2259 --with | --without )
2260 case $GROUP_BCONDS in
2264 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2265 while ! `echo ${1}|grep -qE '(^-|spec)'`
2267 BCOND="$BCOND $COND $1"
2271 if [[ "$2" = *,* ]]; then
2272 for a in $(echo "$2" | tr , ' '); do
2273 BCOND="$BCOND $1 $a"
2276 BCOND="$BCOND $1 $2"
2282 shift; TARGET="${1}"; shift ;;
2284 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2286 QUIET="--quiet"; shift ;;
2288 CVSDATE="${2}"; shift 2 ;;
2297 -R | --fetch-build-requires)
2298 FETCH_BUILD_REQUIRES="yes"
2299 NOT_INSTALLED_PACKAGES=
2301 -RB | --remove-build-requires)
2302 REMOVE_BUILD_REQUIRES="nice"
2304 -FRB | --force-remove-build-requires)
2305 REMOVE_BUILD_REQUIRES="force"
2307 -sc | --sources-cvs)
2308 COMMAND="list-sources-cvs"
2310 -sd | --source-distfiles)
2311 COMMAND="list-sources-distfiles"
2313 -sdp | --source-distfiles-paths)
2314 COMMAND="list-sources-distfiles-paths"
2316 -sf | --source-files)
2317 COMMAND="list-sources-files"
2319 -lsp | --source-paths)
2320 COMMAND="list-sources-local-paths"
2322 -su | --source-urls)
2323 COMMAND="list-sources-urls"
2325 -Tvs | --tag-version-stable )
2330 -Ts | --tag-stable )
2335 -Tv | --tag-version )
2340 -Tp | --tag-prefix )
2352 -ir | --integer-release-only )
2353 INTEGER_RELEASE="yes"
2356 COMMAND="update_md5"
2361 -Upi | --update-poldek-indexes )
2362 UPDATE_POLDEK_INDEXES="yes"
2365 COMMAND="init_rpm_dir"
2367 --use-greed-sources )
2370 -u | --try-upgrade )
2371 TRY_UPGRADE="1"; shift ;;
2373 shift; UPGRADE_VERSION="$1"; shift;;
2374 -un | --try-upgrade-with-float-version )
2375 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2377 BE_VERBOSE="1"; shift ;;
2382 if echo "${MACRO}" | grep -q '\W'; then
2383 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2387 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2392 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2396 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2399 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2400 COMMAND="show_bconds"
2404 COMMAND="show_bcond_args"
2407 --show-avail-bconds)
2408 COMMAND="show_avail_bconds"
2413 RPMOPTS="${RPMOPTS} --nodeps"
2416 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2419 Exit_error err_invalid_cmdline "$1"
2422 SPECFILE=${1%/}; shift
2423 # check if specname was passed as specname:cvstag
2424 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2425 CVSTAG="${SPECFILE##*:}"
2426 SPECFILE="${SPECFILE%%:*}"
2428 # always have SPECFILE ending with .spec extension
2429 SPECFILE=${SPECFILE%%.spec}.spec
2430 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2434 [ -d "$ASSUMED_NAME" ] && CVS_ENTRIES="$ASSUMED_NAME/CVS/Entries" || CVS_ENTRIES="CVS/Entries"
2435 if [ -f "$CVS_ENTRIES" ] && [ -z "$CVSTAG" ]; then
2436 CVSTAG=$(awk -vSPECFILE=$(basename $SPECFILE) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' ${CVS_ENTRIES})
2437 if [ "$CVSTAG" ]; then
2438 echo >&2 "builder: Sticky tag $CVSTAG active. Use -r TAGNAME to override."
2440 elif [ "$CVSTAG" = "HEAD" ]; then
2441 # assume -r HEAD is same as -A
2445 if [ "$CVSTAG" ]; then
2446 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2447 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2450 if [ -n "$DEBUG" ]; then
2455 if [ -n "$TARGET" ]; then
2458 TARGET_SWITCH="--target $TARGET" ;;
2460 TARGET_SWITCH="--target=$TARGET" ;;
2464 if [ "$SCHEDTOOL" != "no" ]; then
2465 NICE_COMMAND="$SCHEDTOOL"
2467 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2470 update_shell_title "$COMMAND"
2474 if [ -z "$SPECFILE" ]; then
2475 Exit_error err_no_spec_in_cmdl
2477 get_spec > /dev/null
2484 if [ -z "$SPECFILE" ]; then
2485 Exit_error err_no_spec_in_cmdl
2487 get_spec > /dev/null
2492 "show_avail_bconds")
2494 if [ -z "$SPECFILE" ]; then
2495 Exit_error err_no_spec_in_cmdl
2498 get_spec > /dev/null
2500 local bcond_avail=$(find_spec_bcond $SPECFILE)
2501 local opt bcond bconds
2502 for opt in $bcond_avail; do
2505 bcond=${opt#without_}
2506 bconds="$bconds $bcond"
2510 bconds="$bconds $bcond"
2513 echo >&2 "ERROR: unexpected '$opt' in show_avail_bconds"
2521 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2523 if [ -z "$SPECFILE" ]; then
2524 Exit_error err_no_spec_in_cmdl
2527 # display SMP make flags if set
2528 smp_mflags=$(rpm -E %{?_smp_mflags})
2529 if [ "$smp_mflags" ]; then
2530 echo "builder: SMP make flags are set to $smp_mflags"
2538 if [ "$COMMAND" != "build-source" ]; then
2541 fetch_build_requires
2542 if [ "$INTEGER_RELEASE" = "yes" ]; then
2543 echo "Checking release $PACKAGE_RELEASE..."
2544 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2545 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2549 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2550 if [ -n "$TEST_TAG" ]; then
2551 local TAGVER=`make_tagver`
2552 # escape some regexp characters if part of TAGVER
2553 TAGVER=$(echo "$TAGVER" | sed -e 's#\([\+\*\.]\)#\\\1#g')
2554 echo "Searching for tag $TAGVER..."
2555 TAGREL=$($CVS_COMMAND status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2556 if [ -n "$TAGREL" ]; then
2557 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2560 # - do not allow to build from HEAD when XX-branch exists
2561 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2562 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2563 TAG_BRANCH="${TREE_PREFIX}-branch"
2564 TAG_STATUS=$($CVS_COMMAND status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2565 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2566 Exit_error err_branch_exists "$TAG_STATUS"
2572 if [ -n "$NOSOURCE0" ] ; then
2573 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2578 get_files $SOURCES $PATCHES
2582 NODIST="yes" get_files $SOURCES $PATCHES
2583 update_md5 $SOURCES $PATCHES
2587 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2588 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2590 remove_build_requires
2594 if [ -z "$SPECFILE" ]; then
2595 Exit_error err_no_spec_in_cmdl
2600 # don't fetch sources from remote locations
2602 for file in $SOURCES; do
2603 [ -n "`src_md5 $file`" ] && continue
2604 new_SOURCES="$new_SOURCES $file"
2606 SOURCES="$new_SOURCES"
2607 get_files $SOURCES $PATCHES
2609 branch_files $TAG $SOURCES $PATCHES $ICONS
2613 if [ -z "$SPECFILE" ]; then
2614 Exit_error err_no_spec_in_cmdl
2617 ADD_PACKAGE_CVS=yes get_spec
2620 if [ -n "$NOSOURCE0" ] ; then
2621 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2623 get_files $SOURCES $PATCHES
2628 if [ -z "$SPECFILE" ]; then
2629 Exit_error err_no_spec_in_cmdl
2635 if [ -n "$NOSOURCE0" ] ; then
2636 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2638 get_files $SOURCES $PATCHES
2643 if [ -z "$SPECFILE" ]; then
2644 Exit_error err_no_spec_in_cmdl
2650 if [ -n "$NOSOURCE0" ] ; then
2651 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2653 update_md5 $SOURCES $PATCHES
2659 if [ -z "$SPECFILE" ]; then
2660 Exit_error err_no_spec_in_cmdl
2666 # don't fetch sources from remote locations
2668 for file in $SOURCES; do
2669 [ -n "`src_md5 $file`" ] && continue
2670 new_SOURCES="$new_SOURCES $file"
2672 SOURCES="$new_SOURCES"
2673 get_files $SOURCES $PATCHES
2675 tag_files $SOURCES $PATCHES $ICONS
2680 "list-sources-files" )
2683 DONT_PRINT_REVISION="yes"
2686 for SAP in $SOURCES $PATCHES; do
2687 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2690 "list-sources-urls" )
2693 DONT_PRINT_REVISION="yes"
2696 SAPS="$SOURCES $PATCHES"
2697 for SAP in $SAPS ; do
2701 "list-sources-local-paths" )
2704 DONT_PRINT_REVISION="yes"
2707 for SAP in $SOURCES $PATCHES; do
2708 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2711 "list-sources-distfiles-paths" )
2714 DONT_PRINT_REVISION="yes"
2717 for SAP in $SOURCES $PATCHES; do
2718 if [ -n "$(src_md5 "$SAP")" ]; then
2719 distfiles_path "$SAP"
2723 "list-sources-distfiles" )
2726 DONT_PRINT_REVISION="yes"
2729 for SAP in $SOURCES $PATCHES; do
2730 if [ -n "$(src_md5 "$SAP")" ]; then
2731 distfiles_url "$SAP"
2735 "list-sources-cvs" )
2738 DONT_PRINT_REVISION="yes"
2741 for SAP in $SOURCES $PATCHES; do
2742 if [ -z "$(src_md5 "$SAP")" ]; then
2743 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2757 echo "$VERSIONSTRING"
2760 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2761 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2765 # vi:syntax=sh:ts=4:sw=4:noet