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 CVS repository
41 $VERSION (C) 1999-2010 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"
234 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
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] [-a|--as_anon] [-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] [--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 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
267 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
268 -n5, --no-md5 - ignore md5 comments in spec
269 -D, --debug - enable builder script debugging mode,
270 -debug - produce rpm debug package (same as --opts -debug)
271 -V, --version - output builder version string
272 --short-version - output builder short version
273 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
274 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
276 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
277 only package from <package>.spec,
278 -bp, --build-prep - execute the %prep phase of <package>.spec,
279 -bc - execute the %build phase of <package>.spec,
280 -bi - execute the %install phase of <package>.spec
281 -bl - execute the %files phase of <package>.spec
282 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
284 --short-circuit - short-circuit build
285 -B, --branch - add branch
286 -c, --clean - clean all temporarily created files (in BUILD\$RPM_BUILD_ROOT) after rpmbuild commands.
287 may be used with building process.
288 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
289 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
291 -cf, --cvs-force - use -F when tagging (useful when moving branches)
292 -d <cvsroot>, --cvsroot <cvsroot>
294 --define <macro> <value>
295 - define a macro <macro> with value <value>,
296 --alt_kernel <kernel>
297 - same as --define 'alt_kernel <kernel>'
298 --nodeps - rpm won't check any dependences
299 -g, --get - get <package>.spec and all related files from CVS repo
301 -h, --help - this message,
302 --http - use http instead of ftp,
303 -l <logfile>, --logtofile <logfile>
305 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
307 - don't check specs in CVS
308 -nd, --no-distfiles - don't download from distfiles
309 -nm, --no-mirrors - don't download from mirror, if source URL is given,
310 -nu, --no-urls - don't try to download from FTP/HTTP location,
311 -ns, --no-srcs - don't download Sources/Patches
312 -ns0, --no-source0 - don't download Source0
313 -nn, --no-net - don't download anything from the net
314 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
315 --no-init - don't initialize builder paths (SPECS and SOURCES)
317 --skip-existing-files - skip existing files in get_files
318 --opts <rpm opts> - additional options for rpm
319 -q, --quiet - be quiet,
320 --date yyyy-mm-dd - build package using resources from specified CVS date,
321 -r <cvstag>, --cvstag <cvstag>
322 - build package using resources from specified CVS tag,
323 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
324 -R, --fetch-build-requires
325 - fetch what is BuildRequired,
326 -RB, --remove-build-requires
327 - remove all you fetched with -R or --fetch-build-requires
328 remember, this option requires confirmation,
329 -FRB, --force-remove-build-requires
330 - remove all you fetched with -R or --fetch-build-requires
331 remember, this option works without confirmation,
332 -sd, --source-distfiles - list sources available from distfiles (intended for offline
333 operations; does not work when Icon field is present
334 but icon file is absent),
335 -sc, --source-cvs - list sources available from CVS
336 -sdp, --source-distfiles-paths - list sources available from distfiles -
337 paths relative to distfiles directory (intended for offline
338 operations; does not work when Icon field is present
339 but icon file is absent),
340 -sf, --source-files - list sources - bare filenames (intended for offline
341 operations; does not work when Icon field is present
342 but icon file is absent),
343 -sp, --source-paths - list sources - filenames with full local paths (intended for
344 offline operations; does not work when Icon field is present
345 but icon file is absent),
346 -su, --source-urls - list urls - urls to sources and patches
347 intended for copying urls with spec with lots of macros in urls
348 -T <cvstag> , --tag <cvstag>
349 - add cvs tag <cvstag> for files,
350 -Tvs, --tag-version-stable
351 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
353 - add cvs tag STABLE for files,
355 - add cvs tag NAME-VERSION-RELEASE for files,
356 -Tp, --tag-prefix <prefix>
357 - add <prefix> to NAME-VERSION-RELEASE tags,
358 -tt, --test-tag <prefix>
359 - fail if tag is already present,
360 -ir, --integer-release-only
361 - allow only integer and snapshot releases
362 -v, --verbose - be verbose,
363 -u, --try-upgrade - check version, and try to upgrade package
364 -un, --try-upgrade-with-float-version
365 - as above, but allow float version
367 - try download source from tag head if don't find it in
369 -U, --update - refetch sources, don't use distfiles, and update md5 comments
370 -Upi, --update-poldek-indexes
371 - refresh or make poldek package index files.
372 -np, --nopatch <patchnumber>
373 - don't apply <patchnumber>
374 --show-bconds - show available conditional builds, which can be used
375 - with --with and/or --without switches.
376 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
377 ./repackage.sh script. in other words, the output is
378 parseable by scripts.
379 --show-avail-bconds - show available bconds
380 --with/--without <feature>
381 - conditional build package depending on %_with_<feature>/
382 %_without_<feature> macro switch. You may now use
383 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
384 constructions. Set GROUP_BCONDS to yes to make use of it.
385 --target <platform>, --target=<platform>
386 - build for platform <platform>.
387 --init-rpm-dir - initialize ~/rpm directory structure
391 # change dependency to specname
393 # - perl(Package::Name) -> perl-Package-Name
397 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
401 update_shell_title() {
403 local len=${COLUMNS:-80}
404 local msg="$(echo "$*" | cut -c-$len)"
406 if [ -n "$BE_VERBOSE" ]; then
407 echo >&2 "$(date +%s.%N) $*"
410 if [ "x$TITLECHANGE" = "xyes" -o "x$TITLECHANGE" = "x" ]; then
412 if [ -n "$PACKAGE_NAME" ]; then
413 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
418 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
419 msg=$(echo $msg | tr -d '\n\r')
422 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
425 echo >&2 -ne "\033]0;$msg\007"
431 # set TARGET from BuildArch: from SPECFILE
433 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
434 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
436 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
440 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
442 TARGET_SWITCH="--target=$TARGET" ;;
448 # runs rpm with minimal macroset
450 # we reset macros not to contain macros.build as all the %() macros are
451 # executed here, while none of them are actually needed.
452 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
453 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
455 # TODO: move these to /usr/lib/rpm/macros
456 cat > $BUILDER_MACROS <<'EOF'
457 %x8664 x86_64 amd64 ia32e
460 %bootstrap_release() %{1}
461 %requires_releq_kernel_up(s:n:) %{nil}
462 %requires_releq_kernel_smp(s:n:) %{nil}
463 %requires_releq_kernel(s:n:) %{nil}
464 %requires_releq() %{nil}
465 %pyrequires_eq() %{nil}
466 %requires_eq() %{nil}
467 %requires_eq_to() %{nil}
468 %requires_ge() %{nil}
469 %releq_kernel_up(n:) ERROR
470 %releq_kernel_smp(n:) ERROR
471 %releq_kernel(n:) ERROR
475 %ruby_ver_requires_eq() %{nil}
476 %ruby_mod_ver_requires_eq() %{nil}
477 %__php_api_requires() %{nil}
478 %php_major_version ERROR
479 %php_api_version ERROR
480 %requires_xorg_xserver_extension %{nil}
481 %requires_xorg_xserver_xinput %{nil}
482 %requires_xorg_xserver_font %{nil}
483 %requires_xorg_xserver_videodrv %{nil}
485 %perl_vendorarch ERROR
486 %perl_vendorlib ERROR
487 # damn. need it here! - copied from /usr/lib/rpm/macros.build
488 %tmpdir %(echo "${TMPDIR:-/tmp}")
489 %patchset_source(f:b:) %(
490 base=%{-b*}%{!-b*:10000};
491 start=$(expr $base + %1);
492 end=$(expr $base + %{?2}%{!?2:%{1}});
493 # we need to call seq twice as it doesn't allow two formats
494 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
495 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
496 paste %{tmpdir}/__ps{1,2};
497 rm -f %{tmpdir}/__ps{1,2};
500 %add_etc_shells(p) %{p:<lua>}
501 %remove_etc_shells(p) %{p:<lua>}
502 %lua_add_etc_shells() %{nil}
503 %lua_remove_etc_shells() %{nil}
505 %buildrequires_jdk %{nil}
507 if [ "$NOINIT" = "yes" ] ; then
508 cat >> $BUILDER_MACROS <<'EOF'
513 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
517 if [ -n "$DEBUG" ]; then
522 if [ -x /usr/bin/rpm-specdump ]; then
523 update_shell_title "cache_rpm_dump using rpm-specdump command"
524 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
526 update_shell_title "cache_rpm_dump using rpmbuild command"
529 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
530 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
536 ARGS='--nodigest --nosignature --nobuild'
539 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
541 if [ $? -gt 0 ]; then
542 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
544 Exit_error err_build_fail
547 # make small dump cache
548 rpm_dump_cache=`echo "$rpm_dump" | awk '
549 $2 ~ /^SOURCEURL/ {print}
550 $2 ~ /^PATCHURL/ {print}
551 $2 ~ /^nosource/ {print}
552 $2 ~ /^PACKAGE_/ {print}
556 update_shell_title "cache_rpm_dump: OK!"
560 if [ -z "$rpm_dump_cache" ] ; then
561 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
563 echo "$rpm_dump_cache"
567 update_shell_title "get icons"
568 ICONS=$(awk '/^Icon:/ {print $2}' $PACKAGE_DIR/${SPECFILE})
569 if [ -z "$ICONS" ]; then
573 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
577 update_shell_title "parsing specfile"
578 if [ -n "$DEBUG" ]; then
583 # icons are needed for successful spec parse
589 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
590 FAIL_IF_NO_SOURCES="no"
593 if [ "$NOSRCS" != "yes" ]; then
594 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
595 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
596 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
599 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
600 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
601 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
603 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
604 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
607 if [ -n "$BE_VERBOSE" ]; then
608 echo "- Sources : `nourl $SOURCES`"
609 if [ -n "$PATCHES" ]; then
610 echo "- Patches : `nourl $PATCHES`"
612 echo "- Patches : *no patches needed*"
614 if [ -n "$ICONS" ]; then
615 echo "- Icon : `nourl $ICONS`"
617 echo "- Icon : *no package icon*"
619 echo "- Name : $PACKAGE_NAME"
620 echo "- Version : $PACKAGE_VERSION"
621 echo "- Release : $PACKAGE_RELEASE"
624 update_shell_title "parse_spec: OK!"
628 if [ -n "$DEBUG" ]; then
636 "err_no_spec_in_cmdl" )
637 remove_build_requires
638 echo >&2 "ERROR: spec file name not specified."
640 "err_invalid_cmdline" )
641 echo >&2 "ERROR: invalid command line arg ($2)."
643 "err_no_spec_in_repo" )
644 remove_build_requires
645 echo >&2 "Error: spec file not stored in CVS repo."
647 "err_no_source_in_repo" )
648 remove_build_requires
649 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
652 remove_build_requires
653 echo >&2 "Error: package build failed. (${2:-no more info})"
655 "err_no_package_data" )
656 remove_build_requires
657 echo >&2 "Error: couldn't get out package name/version/release from spec file."
660 remove_build_requires
661 echo >&2 "Tag ${2} already exists (spec release: ${3})."
664 remove_build_requires
665 echo >&2 "Release ${2} not integer and not a snapshot."
667 "err_branch_exists" )
668 remove_build_requires
669 echo >&2 "Tree branch already exists (${2})."
672 remove_build_requires
673 echo >&2 "Error: conditions reject building this spec (${2})."
676 echo >&2 "Unknown error."
681 if [ -n "$DEBUG" ]; then
686 if [ "$NOINIT" != "yes" ] ; then
687 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
689 local macros_ver=$(rpm -E %?rpm_build_macros)
690 if [ -z "$macros_ver" ]; then
691 REPO_DIR=$TOP_DIR/packages
692 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
694 if awk "BEGIN{exit($macros_ver>=$RPM_MACROS_VER)}"; then
695 echo >&2 "builder requires rpm-build-macros >= $RPM_MACROS_VER"
699 PACKAGE_DIR=$REPO_DIR/$ASSUMED_NAME
711 update_shell_title "get_spec"
713 if [ -n "$DEBUG" ]; then
719 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
721 SPECFILE=$(basename $SPECFILE)
723 if [ "$NOCVSSPEC" != "yes" ]; then
725 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
726 echo "Warning: No CVS access defined - using local .spec file"
730 if [ -d "$ASSUMED_NAME" ]; then
731 cvsup "$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
733 cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
735 # remove Entries.Static -- so 'cvs up' would update all files in a repo
736 rm "$ASSUMED_NAME/CVS/Entries.Static"
737 cvsignore_df .cvsignore
739 # create symlinks for tools
740 if [ "$SYMLINK_TOOLS" != "no" ]; then
741 for a in dropin md5 adapter builder {relup,compile,repackage,rsync,pearize}.sh pldnotify.awk; do
742 [ -f $a ] || continue
743 ln -s ../$a $ASSUMED_NAME
750 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
751 Exit_error err_no_spec_in_repo
754 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
755 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
758 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
766 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
767 $CVS_COMMAND update mirrors >&2
771 local origin mirror name rest ol prefix
772 while read origin mirror name rest; do
773 # skip comments and empty lines
774 if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then
777 ol=$(echo -n "$origin" | wc -c)
778 prefix=$(echo -n "$url" | head -c $ol)
779 if [ "$prefix" = "$origin" ] ; then
780 suffix=$(echo "$url" | cut -b $((ol+1))-)
781 echo -n "$mirror$suffix"
788 # Warning: unpredictable results if same URL used twice
792 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
793 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
798 [ "$NO5" = "yes" ] && return
800 [ -z "$no" ] && return
804 if [ -f additional-md5sums ]; then
805 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
806 if [ -z "$spec_rev" ]; then
807 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
809 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
810 md5=$(grep -s -v '^#' additional-md5sums | \
811 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
812 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
813 grep -E '^[0-9a-f]{32}$')
816 if [ $(echo "$md5" | wc -l) != 1 ] ; then
817 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
819 echo "$md5" | tail -n 1
824 source_md5=`grep -i "^#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
825 if [ -n "$source_md5" ]; then
828 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
829 if [ -n "$source_md5" ]; then
832 # we have empty SourceX-md5, but it is still possible
833 # that we have NoSourceX-md5 AND NoSource: X
834 nosource_md5=`grep -i "^#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
835 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
843 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
847 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
850 distfiles_attic_url() {
851 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
857 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
861 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
862 [ -n "$size" -a "$size" -gt 0 ]
866 if [ "$CVSIGNORE_DF" != "yes" ]; then
869 cvsignore=${PACKAGE_DIR}/.cvsignore
871 # add only if not yet there
872 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
873 echo "$1" >> $cvsignore
878 update_shell_title "cvsup"
881 if [ "$1" = "-c" ]; then
885 if [ -n "$CVSROOT" ]; then
886 OPTIONS="-d $CVSROOT $OPTIONS"
889 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
890 OPTIONS="$OPTIONS -A"
892 if [ -n "$CVSDATE" ]; then
893 OPTIONS="$OPTIONS -D $CVSDATE"
895 if [ -n "$CVSTAG" ]; then
896 OPTIONS="$OPTIONS -r $CVSTAG"
901 local retries_counter=0
903 update_shell_title "cvsup: $*"
905 update_shell_title "cvsup: $# files"
907 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
908 retries_counter=$(( $retries_counter + 1 ))
909 output=$(LC_ALL=C $CVS_COMMAND $OPTIONS "$@" 2>&1)
911 [ -n "$output" ] && echo "$output"
912 if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out|Unknown host)") && [ "$result" -ne "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; then
913 echo "Trying again [$*]... ($retries_counter)"
914 update_shell_title "cvsup: retry #$retries_counter"
921 update_shell_title "cvsup: done!"
925 # returns true if "$1" is ftp, http or https protocol url
928 ftp://*|http://*|https://*)
936 if [ $# -eq 0 ]; then
940 update_shell_title "update md5"
941 if [ -n "$DEBUG" ]; then
948 # pass 1: check files to be fetched
952 local fp=$(nourl "$i")
953 local srcno=$(src_no "$i")
954 if [ -n "$ADD5" ]; then
955 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
956 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
957 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
959 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
961 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
962 need_files="$need_files $i"
966 # pass 1a: get needed files
967 if [ "$need_files" ]; then
968 get_files $need_files
971 # pass 2: proceed with md5 adding or updating
973 local fp=$(nourl "$i")
974 local srcno=$(src_no "$i")
975 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
976 if [ -z "$md5" ]; then
977 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
979 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
980 local tag="# Source$srcno-md5:\t"
981 if [[ "$md5" == *NoSource* ]]; then
982 tag="# NoSource$srcno-md5:\t"
983 elif [ -n "$USEDIGEST" ]; then
984 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
986 md5=$(md5sum "$fp" | cut -f1 -d' ')
987 echo "Updating Source$srcno ($md5: $fp)."
989 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
990 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
992 $PACKAGE_DIR/$SPECFILE
999 [ "$NO5" = "yes" ] && return
1001 update_shell_title "check md5"
1005 if ! good_md5 "$i"; then
1006 echo -n "MD5 sum mismatch."
1009 if ! good_size "$i"; then
1010 echo -n "0 sized file."
1014 if [ $bad -eq 1 ]; then
1015 echo " Use -U to refetch sources,"
1016 echo "or -5 to update md5 sums, if you're sure files are correct."
1017 Exit_error err_no_source_in_repo $i
1023 update_shell_title "get_files"
1025 if [ -n "$DEBUG" ]; then
1030 if [ $# -gt 0 ]; then
1033 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
1034 echo "Warning: No CVS access defined for SOURCES"
1039 local get_files_cvs=""
1043 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1044 update_shell_title "$i"
1045 local fp=`nourl "$i"`
1046 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1051 local srcmd5=$(src_md5 "$i")
1053 # we know if source/patch is present in cvs/distfiles
1054 # - has md5 (in distfiles)
1055 # - in cvs... ideas?
1057 # CHECK: local file didn't exist or always cvs up (first) requested.
1058 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1059 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1060 echo "Warning: no URL given for $i"
1064 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1065 if good_md5 "$i" && good_size "$i"; then
1066 echo "$fp having proper md5sum already exists"
1070 # optionally prefer mirror over distfiles if there's mirror
1071 # TODO: build url list and then try each url from the list
1072 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1075 url=$(distfiles_url "$i")
1078 url_attic=$(distfiles_attic_url "$i")
1080 # is $url local file?
1081 if [[ "$url" = [./]* ]]; then
1082 update_shell_title "${GETLOCAL%% *}: $url"
1083 ${GETLOCAL} $url $target
1085 if [ -z "$NOMIRRORS" ]; then
1086 url=$(find_mirror "$url")
1090 # make shorter message for distfiles urls
1091 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1092 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1093 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1096 update_shell_title "${GETURI%% *}: $uri"
1097 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1098 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1099 update_shell_title "${GETURI2%% *}: $url"
1100 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1105 if [ ! -s "$target" ]; then
1107 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1108 update_shell_title "${GETLOCAL%% *}: $url_attic"
1109 ${GETLOCAL} $url_attic $target
1111 if [ -z "$NOMIRRORS" ]; then
1112 url_attic=$(find_mirror "$url_attic")
1114 update_shell_title "${GETURI%% *}: $url_attic"
1115 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1116 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1117 update_shell_title "${GETURI2%% *}: $url_attic"
1118 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1120 test -s "$target" || rm -f "$target"
1124 if [ -s "$target" ]; then
1125 cvsignore_df $target
1130 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1131 if [ $# -gt 1 ]; then
1132 get_files_cvs="$get_files_cvs $fp"
1133 update_shell_title "$fp (will cvs up later)"
1140 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1141 if [ -z "$NOMIRRORS" ]; then
1142 im=$(find_mirror "$i")
1146 update_shell_title "${GETURI%% *}: $im"
1147 ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
1148 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1149 update_shell_title "${GETURI2%% *}: $im"
1150 ${GETURI2} "$im" ${OUTFILEOPT} "$target"
1152 test -s "$target" || rm -f "$target"
1155 if [ "$cvsup" = 1 ]; then
1161 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1162 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1163 if [ -n "GREEDSRC" ]; then
1164 get_greed_sources $i
1166 Exit_error err_no_source_in_repo $i
1170 # we check md5 here just only to refetch immediately
1171 if good_md5 "$i" && good_size "$i"; then
1173 elif [ "$FROM_DISTFILES" = 1 ]; then
1174 # wrong md5 from distfiles: remove the file and try again
1176 echo "MD5 sum mismatch. Trying full fetch."
1179 update_shell_title "${GETURI%% *}: $url"
1180 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1181 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1182 update_shell_title "${GETURI2%% *}: $url"
1183 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1185 if [ ! -s "$target" ]; then
1187 update_shell_title "${GETURI%% *}: $url_attic"
1188 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1189 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1190 update_shell_title "${GETURI2%% *}: $url_attic"
1191 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1194 test -s "$target" || rm -f "$target"
1197 SHELL_TITLE_PREFIX=""
1199 if [ "$get_files_cvs" ]; then
1200 cvsup $get_files_cvs
1203 if [ "$CHMOD" = "yes" ]; then
1204 CHMOD_FILES=$(nourl "$@")
1205 if [ -n "$CHMOD_FILES" ]; then
1206 chmod $CHMOD_MODE $CHMOD_FILES
1213 if [ -n "$DEBUG" ]; then
1218 # Check whether first character of PACKAGE_NAME is legal for tag name
1219 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1223 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1224 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1226 # Remove #kernel.version_release from TAGVER because tagging sources
1227 # could occur with different kernel-headers than kernel-headers used at build time.
1228 # besides, %{_kernel_ver_str} is not expanded.
1230 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1231 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1237 # bool is_tag_a_branch(tag)
1239 # returns 1 if a tag is a branch set on SPECFILE
1241 if [ -n "$DEBUG" ]; then
1246 if [ $# -ne 1 ]; then
1253 $CVS_COMMAND status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1260 if [ -n "$DEBUG" ]; then
1265 echo "Version: $PACKAGE_VERSION"
1266 echo "Release: $PACKAGE_RELEASE"
1269 if [ "$TAG_VERSION" = "yes" ]; then
1270 TAGVER=`make_tagver`
1271 echo "CVS tag: $TAGVER"
1273 if [ -n "$TAG" ]; then
1274 echo "CVS tag: $TAG"
1277 local OPTIONS="tag $CVS_FORCE"
1278 if [ -n "$CVSROOT" ]; then
1279 OPTIONS="-d $CVSROOT $OPTIONS"
1282 # if a tagname we are about to set already exists
1283 # and happens to be a branch (common case with AC-branch)
1284 # pass -B (allows -F to disturb branch tag)
1286 if [ "$TAG_VERSION" = "yes" ]; then
1289 is_tag_a_branch $_tag
1290 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1291 OPTIONS="$OPTIONS -B"
1296 for i in $TAG_FILES; do
1297 # don't tag files stored on distfiles
1298 [ -n "`src_md5 $i`" ] && continue
1299 local fp=`nourl "$i"`
1300 if [ -f "$fp" ]; then
1301 tag_files="$tag_files $fp"
1302 elif [ -n "GREEDSRC" ]; then
1303 get_greed_sources $i
1305 Exit_error err_no_source_in_repo $i
1309 if [ "$tag_files" ]; then
1310 if [ "$TAG_VERSION" = "yes" ]; then
1311 update_shell_title "tag sources: $TAGVER"
1312 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1313 $CVS_COMMAND $OPTIONS $TAGVER $tag_files || exit
1315 if [ -n "$TAG" ]; then
1316 update_shell_title "tag sources: $TAG"
1318 while [ "$tag_files" ]; do
1319 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1320 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1321 $CVS_COMMAND $OPTIONS $TAG $chunk || exit
1322 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1328 if [ "$TAG_VERSION" = "yes" ]; then
1329 update_shell_title "tag spec: $TAGVER"
1330 $CVS_COMMAND $OPTIONS $TAGVER $SPECFILE || exit
1332 if [ -n "$TAG" ]; then
1333 update_shell_title "tag spec: $TAG"
1334 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1340 echo "CVS branch tag: $TAG"
1345 if [ -n "$DEBUG" ]; then
1350 local OPTIONS="tag $CVS_FORCE -b"
1353 is_tag_a_branch $TAG
1354 if [ $? -eq 1 ]; then
1355 OPTIONS="$OPTIONS -B"
1358 if [ -n "$CVSROOT" ]; then
1359 OPTIONS="-d $CVSROOT $OPTIONS"
1363 for i in $TAG_FILES; do
1364 local fp=`nourl "$i"`
1365 if [ -f "$fp" ]; then
1366 tag_files="$tag_files $fp"
1367 elif [ -n "GREEDSRC" ]; then
1368 get_greed_sources $i
1370 Exit_error err_no_source_in_repo $i
1373 if [ "$tag_files" ]; then
1374 $CVS_COMMAND $OPTIONS $TAG $tag_files || exit
1378 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1382 # this function should exit early if package can't be built for this arch
1383 # this avoids unneccessary BR filling.
1386 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1388 if [ $ret -ne 0 ]; then
1400 s/^\(%define[ \t]\+_\?rel[ \t]\+\)$rel\$/\1$newrel/
1401 s/^\(Release:[ \t]\+\)$rel\$/\1$newrel/
1410 s/^\(%define[ \t]\+_\?ver[ \t]\+\)$ver\$/\1$newver/
1411 s/^\(Version:[ \t]\+\)$ver\$/\1$newver/
1416 if [ -n "$TRY_UPGRADE" ]; then
1417 local TNOTIFY TNEWVER TOLDVER
1418 update_shell_title "build_package: try_upgrade"
1422 if [ -n "$FLOAT_VERSION" ]; then
1423 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE -n) || exit 1
1425 TNOTIFY=$($APPDIR/pldnotify.awk ${BE_VERBOSE:+-vDEBUG=1} $SPECFILE) || exit 1
1428 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1430 if [ -n "$TNEWVER" ]; then
1431 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1432 echo "New version found, updating spec file from $TOLDVER to version $TNEWVER"
1433 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1434 cp -f $SPECFILE $SPECFILE.bak
1437 set_release $SPECFILE $PACKAGE_RELEASE 1
1438 set_version $SPECFILE $PACKAGE_VERSION $TNEWVER
1447 update_shell_title "build_package"
1448 if [ -n "$DEBUG" ]; then
1457 BUILD_SWITCH="-ba" ;;
1459 BUILD_SWITCH="-bb" ;;
1461 BUILD_SWITCH="-bs --nodeps" ;;
1463 BUILD_SWITCH="-bp --nodeps" ;;
1465 BUILD_SWITCH="-bc" ;;
1467 BUILD_SWITCH="-bi" ;;
1469 BUILD_SWITCH="-bl" ;;
1473 update_shell_title "build_package: $COMMAND"
1474 if [ -n "$LOGFILE" ]; then
1475 LOG=`eval echo $LOGFILE`
1476 if [ -d "$LOG" ]; then
1477 echo "Log file $LOG is a directory."
1478 echo "Parse error in the spec?"
1479 Exit_error err_build_fail
1481 if [ -n "$LASTLOG_FILE" ]; then
1482 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1484 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1486 (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
1487 RETVAL=`cat $RES_FILE`
1489 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1490 if [ "$RETVAL" -eq "0" ]; then
1497 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1500 if [ "$RETVAL" -ne "0" ]; then
1501 if [ -n "$TRY_UPGRADE" ]; then
1502 echo "\nUpgrade package to new version failed."
1503 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1504 echo "Restoring old spec file."
1505 mv -f $SPECFILE.bak $SPECFILE
1509 Exit_error err_build_fail
1515 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1518 install_required_packages() {
1523 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1526 /^%changelog/ { exit }
1528 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1529 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1530 gsub(/[ \t]+/, "_", bcond);
1532 }' $SPEC | LC_ALL=C sort -u
1536 # expand bconds from ~/.bcondrc
1537 # The file structure is like gentoo's package.use:
1540 # samba -mysql -pgsql
1541 # w32codec-installer license_agreement
1544 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1550 SN=${SPECFILE%%\.spec}
1552 local bcondrc=$HOME/.bcondrc
1553 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1555 local bcond_avail=$(find_spec_bcond $SPECFILE)
1557 while read pkg flags; do
1559 [[ "$pkg" == \#* ]] && continue
1561 # any package or current package?
1562 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1563 for flag in $flags; do
1564 local opt=${flag#[+-]}
1566 # use only flags which are in this package.
1567 if [[ $bcond_avail = *${opt}* ]]; then
1568 if [[ $flag = -* ]]; then
1569 if [[ $BCOND != *--with?${opt}* ]]; then
1570 BCOND="$BCOND --without $opt"
1573 if [[ $BCOND != *--without?${opt}* ]]; then
1574 BCOND="$BCOND --with $opt"
1581 update_shell_title "parse ~/.bcondrc: DONE!"
1584 set_bconds_values() {
1585 update_shell_title "set bcond values"
1587 AVAIL_BCONDS_WITHOUT=""
1588 AVAIL_BCONDS_WITH=""
1590 if egrep -q '^# *_with' ${SPECFILE}; then
1591 echo >&2 "ERROR: This spec has old style bconds."
1595 if ! grep -q '^%bcond' ${SPECFILE}; then
1599 local bcond_avail=$(find_spec_bcond $SPECFILE)
1600 process_bcondrc "$SPECFILE"
1602 update_shell_title "parse bconds"
1605 for opt in $bcond_avail; do
1608 bcond=${opt#without_}
1610 *--without?${bcond}*)
1611 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1614 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1622 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1625 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1630 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1639 update_shell_title "run_sub_builder $package_name"
1641 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1642 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1643 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1644 # jakby nie bylo tego kawalka kodu.
1646 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1647 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1651 # kurwa. translate that ^^^^
1655 # Istnieje taki spec? ${package}.spec
1656 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1657 parent_spec_name=${package}.spec
1658 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1659 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1661 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1666 if [ "${parent_spec_name}" != "" ]; then
1667 spawn_sub_builder $parent_spec_name
1669 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1672 spawn_sub_builder() {
1674 update_shell_title "spawn_sub_builder $package_name"
1677 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1678 sub_builder_opts="${sub_builder_opts} -R"
1680 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1681 sub_builder_opts="${sub_builder_opts} -RB"
1682 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1683 sub_builder_opts="${sub_builder_opts} -FRB"
1685 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1686 sub_builder_opts="${sub_builder_opts} -Upi"
1690 ./builder ${sub_builder_opts} "$@"
1693 remove_build_requires() {
1694 if [ "$INSTALLED_PACKAGES" != "" ]; then
1695 case "$REMOVE_BUILD_REQUIRES" in
1697 run_poldek --noask -ve $INSTALLED_PACKAGES
1700 run_poldek --ask -ve $INSTALLED_PACKAGES
1703 echo You may want to manually remove following BuildRequires fetched:
1704 echo $INSTALLED_PACKAGES
1705 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1712 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1713 if [ "$BCOND" ]; then
1715 echo "Building $SPECFILE with the following conditional flags:"
1719 echo "No conditional flags passed"
1722 echo "from available:"
1723 echo "--with :\t$AVAIL_BCONDS_WITH"
1724 echo "--without:\t$AVAIL_BCONDS_WITHOUT"
1729 display_branches() {
1730 if [ "$NOCVSSPEC" != "yes" ]; then
1731 echo -n "Available branches: "
1732 $CVS_COMMAND status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1736 # checks a given list of packages/files/provides agains current rpmdb.
1737 # outputs all dependencies which current rpmdb doesn't satisfy.
1738 # input can be either STDIN or parameters
1742 if [ $# -gt 0 ]; then
1748 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1751 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1753 # other deps (files)
1754 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1757 # checks if given package/files/provides exists in rpmdb.
1758 # input can be either stdin or parameters
1759 # returns packages which are present in the rpmdb
1763 if [ $# -gt 0 ]; then
1769 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1772 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1773 install_build_requires_rpmdeps() {
1774 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1775 # TODO: Conflicts list doesn't check versions
1776 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1777 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1779 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1780 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1781 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1784 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1785 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1786 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1787 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1789 if [ -n "$CNFL" ]; then
1790 update_shell_title "uninstall conflicting packages: $CNFL"
1791 echo "Trying to uninstall conflicting packages ($CNFL):"
1792 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1795 while [ "$DEPS" ]; do
1796 update_shell_title "install deps: $DEPS"
1797 echo "Trying to install dependencies ($DEPS):"
1798 local log=.${SPECFILE}_poldek.log
1799 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1800 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1803 if [ -n "$failed" ]; then
1804 for package in $failed; do
1805 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1814 fetch_build_requires()
1816 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1820 update_shell_title "fetch build requires"
1821 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1822 install_build_requires_rpmdeps
1826 # XXX is this ugliest code written in human history still needed?
1827 echo "All packages installed by fetch_build_requires() are written to:"
1828 echo "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1830 echo "If anything fails, you may get rid of them by executing:"
1831 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`"
1833 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1834 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)
1836 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)
1838 package=$(basename "$package_item"|sed -e "s/}$//g")
1839 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1842 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1843 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1844 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
1849 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1852 if `echo $COND_TST|grep -q 'without_'`; then
1853 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1854 if `echo $COND_TST|grep -q !`; then
1859 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1860 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1861 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1867 elif `echo $COND_TST|grep -q 'with_'`; then
1868 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1869 if `echo $COND_TST|grep -q !`; then
1874 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1875 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1876 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1882 RESULT="${COND_STATE}-${COND_ARGV}"
1884 "with-wout" | "wout-with" )
1887 "wout-wout" | "with-with" )
1891 echo "Action '$RESULT' was not defined for package '$package_item'"
1897 if [ "$GO" = "yes" ]; then
1898 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1899 echo "Testing if $package has subrequirements..."
1900 run_poldek -t -i $package --dumpn=".$package-req.txt"
1901 if [ -f ".$package-req.txt" ]; then
1902 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1904 if [ "$package_name" = "$package" ]; then
1905 echo "Installing BuildRequired package:\t$package_name"
1906 update_shell_title "Installing BuildRequired package: ${package_name}"
1907 install_required_packages $package
1909 echo "Installing (sub)Required package:\t$package_name"
1910 update_shell_title "Installing (sub)Required package: ${package_name}"
1911 install_required_packages $package_name
1915 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1916 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1919 echo "Attempting to run spawn sub - builder..."
1920 echo "Package installation failed:\t$package_name"
1921 run_sub_builder $package_name
1922 if [ $? -eq 0 ]; then
1923 install_required_packages $package_name
1926 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1927 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1930 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1937 rm -f ".$package-req.txt"
1939 echo "Attempting to run spawn sub - builder..."
1940 echo "Package installation failed:\t$package"
1941 run_sub_builder $package
1942 if [ $? -eq 0 ]; then
1943 install_required_packages $package
1946 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1947 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1950 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1956 echo "Package $package is already installed. BuildRequirement satisfied."
1960 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1961 echo >&2 "Unable to install following packages and their dependencies:"
1962 for pkg in "$NOT_INSTALLED_PACKAGES"
1966 remove_build_requires
1972 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1973 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1975 echo "Initializing rpm directories to $TOP_DIR from $CVSROOT"
1976 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1978 $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1982 echo "To checkout *all* .spec files (read-only):"
1983 echo "- run cvs co SPECS"
1985 echo "To checkout *all* packages:"
1986 echo "- run cvs up -dP in $TOP_DIR/packages dir"
1989 echo "To commit with your developer account:"
1990 echo "- edit $TOP_DIR/packages/CVS/Root"
1993 get_greed_sources() {
1994 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1995 if [ -n "BE_VERBOSE" ]; then
1996 echo "Try greed download: $1 from: $CVSROOT"
1998 $CVS_COMMAND -d $CVSROOT get SOURCES/$1
1999 if [ $? != 0 ]; then
2000 Exit_error err_no_source_in_repo $1
2005 # remove entries from CVS/Entries
2006 cvs_entry_remove() {
2007 local cvsdir="$1"; shift
2008 if [ ! -d "$cvsdir" ]; then
2009 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
2013 for file in "$@"; do
2014 rm -f $cvsdir/CVS/Entries.new || return 1
2015 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
2016 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
2024 DONT_PRINT_REVISION="yes"
2028 # remove from CVS/Entries
2029 cvs_entry_remove $PACKAGE_DIR $SPECFILE $SOURCES $PATCHES
2031 # remove spec and sources
2032 $RPMBUILD --clean --rmsource --rmspec --nodeps --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
2035 #---------------------------------------------
2043 while [ $# -gt 0 ]; do
2046 COMMAND="update_md5"
2051 COMMAND="update_md5"
2061 DEBUG="yes"; shift ;;
2063 COMMAND="version"; shift ;;
2065 COMMAND="short-version"; shift ;;
2067 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
2068 -b | -ba | --build )
2069 COMMAND="build"; shift ;;
2070 -bb | --build-binary )
2071 COMMAND="build-binary"; shift ;;
2073 COMMAND="build-build"; shift ;;
2075 COMMAND="build-install"; shift ;;
2077 COMMAND="build-list"; shift ;;
2078 -bp | --build-prep )
2079 COMMAND="build-prep"; shift ;;
2080 -bs | --build-source )
2081 COMMAND="build-source"; shift ;;
2083 COMMAND="branch"; shift; TAG="${1}"; shift;;
2085 CLEAN="--clean"; shift ;;
2087 CVS_FORCE="-F"; shift;;
2089 shift; CVSROOT="${1}"; shift ;;
2091 COMMAND="get"; shift ;;
2093 COMMAND="usage"; shift ;;
2095 PROTOCOL="http"; shift ;;
2097 shift; LOGFILE="${1}"; shift ;;
2099 shift; DEF_NICE_LEVEL=${1}; shift ;;
2100 -ske | --skip-existing-files)
2101 SKIP_EXISTING_FILES="yes"; shift ;;
2103 COMMAND="mr-proper"; shift ;;
2105 NOCVS="yes"; shift ;;
2106 -ncs | --no-cvs-specs )
2107 NOCVSSPEC="yes"; shift ;;
2108 -nd | --no-distfiles )
2109 NODIST="yes"; shift ;;
2110 -nm | --no-mirrors )
2111 NOMIRRORS="yes"; shift ;;
2113 NOURLS="yes"; shift ;;
2115 NOSRCS="yes"; shift ;;
2116 -ns0 | --no-source0 )
2117 NOSOURCE0="yes"; shift ;;
2127 -pm | --prefer-mirrors )
2134 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2136 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2138 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2141 --with | --without )
2142 case $GROUP_BCONDS in
2146 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2147 while ! `echo ${1}|grep -qE '(^-|spec)'`
2149 BCOND="$BCOND $COND $1"
2153 if [[ "$2" = *,* ]]; then
2154 for a in $(echo "$2" | tr , ' '); do
2155 BCOND="$BCOND $1 $a"
2158 BCOND="$BCOND $1 $2"
2164 shift; TARGET="${1}"; shift ;;
2166 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2168 QUIET="--quiet"; shift ;;
2170 CVSDATE="${2}"; shift 2 ;;
2179 -R | --fetch-build-requires)
2180 FETCH_BUILD_REQUIRES="yes"
2181 NOT_INSTALLED_PACKAGES=
2183 -RB | --remove-build-requires)
2184 REMOVE_BUILD_REQUIRES="nice"
2186 -FRB | --force-remove-build-requires)
2187 REMOVE_BUILD_REQUIRES="force"
2189 -sc | --sources-cvs)
2190 COMMAND="list-sources-cvs"
2192 -sd | --sources-distfiles)
2193 COMMAND="list-sources-distfiles"
2195 -sdp | --sources-distfiles-paths)
2196 COMMAND="list-sources-distfiles-paths"
2198 -sf | --sources-files)
2199 COMMAND="list-sources-files"
2201 -sp | --sources-paths)
2202 COMMAND="list-sources-local-paths"
2204 -su | --sources-urls)
2205 COMMAND="list-sources-urls"
2207 -Tvs | --tag-version-stable )
2212 -Ts | --tag-stable )
2217 -Tv | --tag-version )
2222 -Tp | --tag-prefix )
2234 -ir | --integer-release-only )
2235 INTEGER_RELEASE="yes"
2238 COMMAND="update_md5"
2243 -Upi | --update-poldek-indexes )
2244 UPDATE_POLDEK_INDEXES="yes"
2247 COMMAND="init_rpm_dir"
2249 --use-greed-sources )
2252 -u | --try-upgrade )
2253 TRY_UPGRADE="1"; shift ;;
2254 -un | --try-upgrade-with-float-version )
2255 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2257 BE_VERBOSE="1"; shift ;;
2262 if echo "${MACRO}" | grep -q '\W'; then
2263 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2267 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2272 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2276 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2279 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2280 COMMAND="show_bconds"
2284 COMMAND="show_bcond_args"
2287 --show-avail-bconds)
2288 COMMAND="show_avail_bconds"
2293 RPMOPTS="${RPMOPTS} --nodeps"
2296 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2299 Exit_error err_invalid_cmdline "$1"
2303 # check if specname was passed as specname:cvstag
2304 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2305 CVSTAG="${SPECFILE##*:}"
2306 SPECFILE="${SPECFILE%%:*}"
2308 # always have SPECFILE ending with .spec extension
2309 SPECFILE=${SPECFILE%%.spec}.spec
2310 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2314 [ -d "$ASSUMED_NAME" ] && CVS_ENTRIES="$ASSUMED_NAME/CVS/Entries" || CVS_ENTRIES="CVS/Entries"
2315 if [ -f "$CVS_ENTRIES" ] && [ -z "$CVSTAG" ]; then
2316 CVSTAG=$(awk -vSPECFILE=$(basename $SPECFILE) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' ${CVS_ENTRIES})
2317 if [ "$CVSTAG" ]; then
2318 echo >&2 "builder: Sticky tag $CVSTAG active. Use -r TAGNAME to override."
2320 elif [ "$CVSTAG" = "HEAD" ]; then
2321 # assume -r HEAD is same as -A
2325 if [ "$CVSTAG" ]; then
2326 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2327 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2330 if [ -n "$DEBUG" ]; then
2335 if [ -n "$TARGET" ]; then
2338 TARGET_SWITCH="--target $TARGET" ;;
2340 TARGET_SWITCH="--target=$TARGET" ;;
2344 if [ "$SCHEDTOOL" != "no" ]; then
2345 NICE_COMMAND="$SCHEDTOOL"
2347 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2350 update_shell_title "$COMMAND"
2354 if [ -n "$SPECFILE" ]; then
2355 get_spec > /dev/null
2363 if [ -n "$SPECFILE" ]; then
2364 get_spec > /dev/null
2370 "show_avail_bconds")
2372 if [ -n "$SPECFILE" ]; then
2373 get_spec > /dev/null
2375 local bcond_avail=$(find_spec_bcond $SPECFILE)
2376 local opt bcond bconds
2377 for opt in $bcond_avail; do
2380 bcond=${opt#without_}
2381 bconds="$bconds $bcond"
2385 bconds="$bconds $bcond"
2388 echo >&2 "ERROR: unexpected '$opt' in show_avail_bconds"
2397 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2399 if [ -n "$SPECFILE" ]; then
2400 # display SMP make flags if set
2401 smp_mflags=$(rpm -E %{?_smp_mflags})
2402 if [ "$smp_mflags" ]; then
2403 echo "builder: SMP make flags are set to $smp_mflags"
2411 if [ "$COMMAND" != "build-source" ]; then
2414 fetch_build_requires
2415 if [ "$INTEGER_RELEASE" = "yes" ]; then
2416 echo "Checking release $PACKAGE_RELEASE..."
2417 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2418 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2422 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2423 if [ -n "$TEST_TAG" ]; then
2424 local TAGVER=`make_tagver`
2425 echo "Searching for tag $TAGVER..."
2426 TAGREL=$($CVS_COMMAND status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2427 if [ -n "$TAGREL" ]; then
2428 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2431 # - do not allow to build from HEAD when XX-branch exists
2432 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2433 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2434 TAG_BRANCH="${TREE_PREFIX}-branch"
2435 TAG_STATUS=$($CVS_COMMAND status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2436 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2437 Exit_error err_branch_exists "$TAG_STATUS"
2443 if [ -n "$NOSOURCE0" ] ; then
2444 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2449 get_files $SOURCES $PATCHES
2453 NODIST="yes" get_files $SOURCES $PATCHES
2458 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2459 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2461 remove_build_requires
2463 Exit_error err_no_spec_in_cmdl
2468 if [ -n "$SPECFILE" ]; then
2471 # don't fetch sources from remote locations
2473 for file in $SOURCES; do
2474 [ -n "`src_md5 $file`" ] && continue
2475 new_SOURCES="$new_SOURCES $file"
2477 SOURCES="$new_SOURCES"
2478 get_files $SOURCES $PATCHES
2480 branch_files $TAG $SOURCES $PATCHES $ICONS
2482 Exit_error err_no_spec_in_cmdl
2487 if [ -n "$SPECFILE" ]; then
2491 if [ -n "$NOSOURCE0" ] ; then
2492 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2494 get_files $SOURCES $PATCHES
2497 Exit_error err_no_spec_in_cmdl
2502 if [ -n "$SPECFILE" ]; then
2506 if [ -n "$NOSOURCE0" ] ; then
2507 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2511 Exit_error err_no_spec_in_cmdl
2518 if [ -n "$SPECFILE" ]; then
2522 # don't fetch sources from remote locations
2524 for file in $SOURCES; do
2525 [ -n "`src_md5 $file`" ] && continue
2526 new_SOURCES="$new_SOURCES $file"
2528 SOURCES="$new_SOURCES"
2529 get_files $SOURCES $PATCHES
2531 tag_files $SOURCES $PATCHES $ICONS
2533 Exit_error err_no_spec_in_cmdl
2539 "list-sources-files" )
2542 DONT_PRINT_REVISION="yes"
2545 for SAP in $SOURCES $PATCHES; do
2546 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2549 "list-sources-urls" )
2552 DONT_PRINT_REVISION="yes"
2555 SAPS="$SOURCES $PATCHES"
2556 for SAP in $SAPS ; do
2560 "list-sources-local-paths" )
2563 DONT_PRINT_REVISION="yes"
2566 for SAP in $SOURCES $PATCHES; do
2567 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2570 "list-sources-distfiles-paths" )
2573 DONT_PRINT_REVISION="yes"
2576 for SAP in $SOURCES $PATCHES; do
2577 if [ -n "$(src_md5 "$SAP")" ]; then
2578 distfiles_path "$SAP"
2582 "list-sources-distfiles" )
2585 DONT_PRINT_REVISION="yes"
2588 for SAP in $SOURCES $PATCHES; do
2589 if [ -n "$(src_md5 "$SAP")" ]; then
2590 distfiles_url "$SAP"
2594 "list-sources-cvs" )
2597 DONT_PRINT_REVISION="yes"
2600 for SAP in $SOURCES $PATCHES; do
2601 if [ -z "$(src_md5 "$SAP")" ]; then
2602 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2616 echo "$VERSIONSTRING"
2619 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2620 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2624 # vi:syntax=sh:ts=4:sw=4:noet