3 # This program is free software, distributed under the terms of
4 # the GNU General Public License Version 2.
10 # 2 - no spec file name in cmdl parameters
11 # 3 - spec file not stored in repo
12 # 4 - some source, patch or icon files not stored in repo
13 # 5 - package build failed
14 # 6 - spec file with errors
15 # 7 - wrong source in /etc/poldek.conf
16 # 8 - Failed installing buildrequirements and subrequirements
17 # 9 - Requested tag already exist
18 # 10 - Refused to build fractional release
19 # 100 - Unknown error (should not happen)
22 # - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
23 # - when Icon: field is present, -5 and -a5 doesn't work
24 # - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
26 # - ability to do ./builder -bb foo.spec foo2.spec foo3.spec
33 Build package utility from PLD Linux CVS repository
34 $VERSION (C) 1999-2009 Free Penguins".
36 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
55 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
59 # use rpm 4.4.6+ digest format instead of comments if non-zero
62 # user agent when fetching files
63 USER_AGENT="PLD/Builder($VERSION)"
65 # It can be used i.e. in log file naming.
66 # See LOGFILE example.
67 DATE=`date +%Y-%m-%d_%H-%M-%S`
69 # Example: LOGFILE='../log.$PACKAGE_NAME'
70 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
71 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
72 # Example: LOGFILE='$PACKAGE_NAME.$DATE.log'
73 # Yes, you can use variable name! Note _single_ quotes!
88 # create symlinks for tools in PACKAGE_DIR, see get_spec()
99 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
101 CVS_COMMAND=${CVS_COMMAND:-cvs}
104 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
105 CVS_SERVER="cvs.pld-linux.org"
110 DISTFILES_SERVER="://distfiles.pld-linux.org"
111 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
116 FAIL_IF_NO_SOURCES="yes"
118 # let get_files skip over files which are present to get those damn files fetched
119 SKIP_EXISTING_FILES="no"
122 # should the specfile be restored if upgrade failed?
123 REVERT_BROKEN_UPGRADE="yes"
125 if rpm --specsrpm 2>/dev/null; then
126 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
127 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
129 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
130 if [ -x /usr/bin/rpm-getdeps ]; then
131 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
133 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
138 # Here we load saved user environment used to
139 # predefine options set above, or passed to builder
141 # This one reads global system environment settings:
142 if [ -f ~/etc/builderrc ]; then
145 # And this one cascades settings using user personal
147 # Example of ~/.builderrc:
149 #UPDATE_POLDEK_INDEXES="yes"
150 #FETCH_BUILD_REQUIRES="yes"
151 #REMOVE_BUILD_REQUIRES="force"
153 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
157 if [ -n "$HOME_ETC" ]; then
158 USER_CFG="$HOME_ETC/.builderrc"
159 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
161 USER_CFG=~/.builderrc
162 BUILDER_MACROS=~/.builder-rpmmacros
165 [ -f "$USER_CFG" ] && . "$USER_CFG"
167 if [ "$SCHEDTOOL" = "auto" ]; then
168 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
169 SCHEDTOOL="schedtool -B -e"
175 if [ -n "$USE_PROZILLA" ]; then
176 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
179 elif [ -n "$USE_AXEL" ]; then
180 GETURI="axel -a $AXEL_OPTS"
184 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
185 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
186 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
187 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
189 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
190 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
196 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
205 # are we using cvs-nserver ?
208 $CVS_COMMAND --version 2>&1 | grep -q 'CVS-nserver'
209 [ $? -eq 0 ] && CVS_NSERVER=1
211 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
212 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
215 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
216 if [ -n "$LOGFILE" ]; then
217 LOG=`eval echo $LOGFILE`
218 if [ -n "$LASTLOG_FILE" ]; then
219 echo "LASTLOG=$LOG" > $LASTLOG_FILE
221 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
224 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
225 return `cat ${RES_FILE}`
230 #---------------------------------------------
234 if [ -n "$DEBUG" ]; then set -xv; fi
236 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
237 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
238 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
239 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
240 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
241 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
242 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
243 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
244 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
245 <package>[.spec][:cvstag]
247 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
248 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
249 -n5, --no-md5 - ignore md5 comments in spec
250 -D, --debug - enable builder script debugging mode,
251 -debug - produce rpm debug package (same as --opts -debug)
252 -V, --version - output builder version string
253 --short-version - output builder short version
254 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
255 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
257 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
258 only package from <package>.spec,
259 -bp, --build-prep - execute the %prep phase of <package>.spec,
260 -bc - execute the %build phase of <package>.spec,
261 -bi - execute the %install phase of <package>.spec
262 -bl - execute the %files phase of <package>.spec
263 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
265 --short-circuit - short-circuit build
266 -B, --branch - add branch
267 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
268 SPECS and \$RPM_BUILD_ROOT and CVS/Entries) after rpmbuild commands.
269 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
270 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
272 -cf, --cvs-force - use -F when tagging (useful when moving branches)
273 -d <cvsroot>, --cvsroot <cvsroot>
275 --define <macro> <value>
276 - define a macro <macro> with value <value>,
277 --alt_kernel <kernel>
278 - same as --define 'alt_kernel <kernel>'
279 --nodeps - rpm won't check any dependences
280 -g, --get - get <package>.spec and all related files from CVS repo
282 -h, --help - this message,
283 --http - use http instead of ftp,
284 -l <logfile>, --logtofile <logfile>
286 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
288 - don't check specs in CVS
289 -nd, --no-distfiles - don't download from distfiles
290 -nm, --no-mirrors - don't download from mirror, if source URL is given,
291 -nu, --no-urls - don't try to download from FTP/HTTP location,
292 -ns, --no-srcs - don't download Sources/Patches
293 -ns0, --no-source0 - don't download Source0
294 -nn, --no-net - don't download anything from the net
295 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
296 --no-init - don't initialize builder paths (SPECS and SOURCES)
298 --skip-existing-files - skip existing files in get_files
299 --opts <rpm opts> - additional options for rpm
300 -q, --quiet - be quiet,
301 --date yyyy-mm-dd - build package using resources from specified CVS date,
302 -r <cvstag>, --cvstag <cvstag>
303 - build package using resources from specified CVS tag,
304 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
305 -R, --fetch-build-requires
306 - fetch what is BuildRequired,
307 -RB, --remove-build-requires
308 - remove all you fetched with -R or --fetch-build-requires
309 remember, this option requires confirmation,
310 -FRB, --force-remove-build-requires
311 - remove all you fetched with -R or --fetch-build-requires
312 remember, this option works without confirmation,
313 -sd, --source-distfiles - list sources available from distfiles (intended for offline
314 operations; does not work when Icon field is present
315 but icon file is absent),
316 -sc, --source-cvs - list sources available from CVS
317 -sdp, --source-distfiles-paths - list sources available from distfiles -
318 paths relative to distfiles directory (intended for offline
319 operations; does not work when Icon field is present
320 but icon file is absent),
321 -sf, --source-files - list sources - bare filenames (intended for offline
322 operations; does not work when Icon field is present
323 but icon file is absent),
324 -sp, --source-paths - list sources - filenames with full local paths (intended for
325 offline operations; does not work when Icon field is present
326 but icon file is absent),
327 -su, --source-urls - list urls - urls to sources and patches
328 intended for copying urls with spec with lots of macros in urls
329 -T <cvstag> , --tag <cvstag>
330 - add cvs tag <cvstag> for files,
331 -Tvs, --tag-version-stable
332 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
334 - add cvs tag STABLE for files,
336 - add cvs tag NAME-VERSION-RELEASE for files,
337 -Tp, --tag-prefix <prefix>
338 - add <prefix> to NAME-VERSION-RELEASE tags,
339 -tt, --test-tag <prefix>
340 - fail if tag is already present,
341 -ir, --integer-release-only
342 - allow only integer and snapshot releases
343 -v, --verbose - be verbose,
344 -u, --try-upgrade - check version, and try to upgrade package
345 -un, --try-upgrade-with-float-version
346 - as above, but allow float version
348 - try download source from tag head if don't find it in
350 -U, --update - refetch sources, don't use distfiles, and update md5 comments
351 -Upi, --update-poldek-indexes
352 - refresh or make poldek package index files.
353 -np, --nopatch <patchnumber>
354 - don't apply <patchnumber>
355 --show-bconds - show available conditional builds, which can be used
356 - with --with and/or --without switches.
357 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
358 ./repackage.sh script. in other words, the output is
359 parseable by scripts.
360 --with/--without <feature>
361 - conditional build package depending on %_with_<feature>/
362 %_without_<feature> macro switch. You may now use
363 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
364 constructions. Set GROUP_BCONDS to yes to make use of it.
365 --target <platform>, --target=<platform>
366 - build for platform <platform>.
367 --init-rpm-dir - initialize ~/rpm directory structure
371 # change dependency to specname
373 # - perl(Package::Name) -> perl-Package-Name
377 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g}')
381 update_shell_title() {
383 local len=${COLUMNS:-80}
384 local msg=$(echo "$*" | cut -c-$len)
386 if [ -n "$BE_VERBOSE" ]; then
387 echo >&2 "$(date +%s.%N) $*"
390 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
392 if [ -n "$PACKAGE_NAME" ]; then
393 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
398 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
399 msg=$(echo $msg | tr -d '\n\r')
402 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
405 echo >&2 -ne "\033]0;$msg\007"
411 # set TARGET from BuildArch: from SPECFILE
413 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
414 tmp=$(awk '/^BuildArch:/ { print $NF}' $ASSUMED_NAME/$SPECFILE)
416 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
420 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
422 TARGET_SWITCH="--target=$TARGET" ;;
428 # runs rpm with minimal macroset
430 # we reset macros not to contain macros.build as all the %() macros are
431 # executed here, while none of them are actually needed.
432 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
433 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
435 # TODO: move these to /usr/lib/rpm/macros
436 cat > $BUILDER_MACROS <<'EOF'
437 %x8664 x86_64 amd64 ia32e
440 %requires_releq_kernel_up %{nil}
441 %requires_releq_kernel_smp %{nil}
442 %requires_releq_kernel %{nil}
443 %requires_releq() %{nil}
444 %pyrequires_eq() %{nil}
445 %requires_eq() %{nil}
446 %requires_eq_to() %{nil}
447 %releq_kernel_up ERROR
448 %releq_kernel_smp ERROR
453 %ruby_ver_requires_eq() %{nil}
454 %ruby_mod_ver_requires_eq() %{nil}
455 %__php_api_requires() %{nil}
456 %php_major_version ERROR
457 %php_api_version ERROR
458 %requires_xorg_xserver_extension %{nil}
459 %requires_xorg_xserver_xinput %{nil}
460 %requires_xorg_xserver_font %{nil}
461 %requires_xorg_xserver_videodrv %{nil}
463 %perl_vendorarch ERROR
464 %perl_vendorlib ERROR
465 # damn. need it here! - copied from /usr/lib/rpm/macros.build
466 %tmpdir %(echo "${TMPDIR:-/tmp}")
467 %patchset_source(f:b:) %(
468 base=%{-b*}%{!-b*:10000};
469 start=$(expr $base + %1);
470 end=$(expr $base + %{?2}%{!?2:%{1}});
471 # we need to call seq twice as it doesn't allow two formats
472 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
473 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
474 paste %{tmpdir}/__ps{1,2};
475 rm -f %{tmpdir}/__ps{1,2};
478 %add_etc_shells(p) %{p:<lua>}
479 %remove_etc_shells(p) %{p:<lua>}
480 %lua_add_etc_shells() %{nil}
481 %lua_remove_etc_shells() %{nil}
483 if [ "$NOINIT" = "yes" ] ; then
484 cat >> $BUILDER_MACROS <<'EOF'
489 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
493 if [ -n "$DEBUG" ]; then
498 if [ -x /usr/bin/rpm-specdump ]; then
499 update_shell_title "cache_rpm_dump using rpm-specdump command"
500 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
502 update_shell_title "cache_rpm_dump using rpmbuild command"
505 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
506 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
512 ARGS='--nodigest --nosignature --nobuild'
515 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
517 if [ $? -gt 0 ]; then
518 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
520 Exit_error err_build_fail
523 # make small dump cache
524 rpm_dump_cache=`echo "$rpm_dump" | awk '
525 $2 ~ /^SOURCEURL/ {print}
526 $2 ~ /^PATCHURL/ {print}
527 $2 ~ /^nosource/ {print}
528 $2 ~ /^PACKAGE_/ {print}
532 update_shell_title "cache_rpm_dump: OK!"
536 if [ -z "$rpm_dump_cache" ] ; then
537 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
539 echo "$rpm_dump_cache"
543 update_shell_title "get icons"
544 ICONS=$(awk '/^Icon:/ {print $2}' ${ASSUMED_NAME}/${SPECFILE})
545 if [ -z "$ICONS" ]; then
549 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
553 update_shell_title "parsing specfile"
554 if [ -n "$DEBUG" ]; then
559 # icons are needed for successful spec parse
565 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
566 FAIL_IF_NO_SOURCES="no"
569 if [ "$NOSRCS" != "yes" ]; then
570 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
571 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
572 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
575 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
576 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
577 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
579 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
580 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
583 if [ -n "$BE_VERBOSE" ]; then
584 echo "- Sources : `nourl $SOURCES`"
585 if [ -n "$PATCHES" ]; then
586 echo "- Patches : `nourl $PATCHES`"
588 echo "- Patches : *no patches needed*"
590 if [ -n "$ICONS" ]; then
591 echo "- Icon : `nourl $ICONS`"
593 echo "- Icon : *no package icon*"
595 echo "- Name : $PACKAGE_NAME"
596 echo "- Version : $PACKAGE_VERSION"
597 echo "- Release : $PACKAGE_RELEASE"
600 update_shell_title "parse_spec: OK!"
604 if [ -n "$DEBUG" ]; then
612 "err_no_spec_in_cmdl" )
613 remove_build_requires
614 echo >&2 "ERROR: spec file name not specified."
616 "err_invalid_cmdline" )
617 echo >&2 "ERROR: invalid command line arg ($2)."
619 "err_no_spec_in_repo" )
620 remove_build_requires
621 echo >&2 "Error: spec file not stored in CVS repo."
623 "err_no_source_in_repo" )
624 remove_build_requires
625 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
628 remove_build_requires
629 echo >&2 "Error: package build failed. (${2:-no more info})"
631 "err_no_package_data" )
632 remove_build_requires
633 echo >&2 "Error: couldn't get out package name/version/release from spec file."
636 remove_build_requires
637 echo >&2 "Tag ${2} already exists (spec release: ${3})."
640 remove_build_requires
641 echo >&2 "Release ${2} not integer and not a snapshot."
643 "err_branch_exists" )
644 remove_build_requires
645 echo >&2 "Tree branch already exists (${2})."
648 remove_build_requires
649 echo >&2 "Error: conditions reject building this spec (${2})."
652 echo >&2 "Unknown error."
657 if [ -n "$DEBUG" ]; then
662 if [ "$NOINIT" != "yes" ] ; then
663 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
664 REPO_DIR=$TOP_DIR/packages
665 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
676 update_shell_title "get_spec"
678 if [ -n "$DEBUG" ]; then
684 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
685 SPECFILE="$(basename $SPECFILE .spec).spec"
687 if [ "$NOCVSSPEC" != "yes" ]; then
689 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
690 echo "Warning: No CVS access defined - using local .spec file"
694 if [ -d "$ASSUMED_NAME" ]; then
695 cvsup "$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
697 cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
699 # remove Entries.Static -- so 'cvs up' would update all files in a repo
700 rm "$ASSUMED_NAME/CVS/Entries.Static"
701 cvsignore_df .cvsignore
703 # create symlinks for tools
704 if [ "$SYMLINK_TOOLS" != "no" ]; then
705 for a in dropin md5 adapter builder {relup,compile,repackage,rsync}.sh; do
706 [ -f $a ] || continue
707 ln -s ../$a $ASSUMED_NAME
714 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
715 Exit_error err_no_spec_in_repo
718 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
719 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
722 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
730 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
731 $CVS_COMMAND update mirrors >&2
735 local origin mirror name rest ol prefix
736 while read origin mirror name rest; do
737 # skip comments and empty lines
738 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
741 ol=$(echo -n "$origin" | wc -c)
742 prefix=$(echo -n "$url" | head -c $ol)
743 if [ "$prefix" = "$origin" ] ; then
744 suffix=$(echo "$url" | cut -b $((ol+1))-)
745 echo -n "$mirror$suffix"
752 # Warning: unpredictable results if same URL used twice
756 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
757 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
762 [ "$NO5" = "yes" ] && return
764 [ -z "$no" ] && return
768 if [ -f additional-md5sums ]; then
769 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
770 if [ -z "$spec_rev" ]; then
771 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
773 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
774 md5=$(grep -s -v '^#' additional-md5sums | \
775 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
776 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
777 grep -E '^[0-9a-f]{32}$')
780 if [ $(echo "$md5" | wc -l) != 1 ] ; then
781 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
783 echo "$md5" | tail -n 1
788 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
789 if [ -n "$source_md5" ]; then
792 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
793 if [ -n "$source_md5" ]; then
796 # we have empty SourceX-md5, but it is still possible
797 # that we have NoSourceX-md5 AND NoSource: X
798 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
799 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
807 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
811 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
814 distfiles_attic_url() {
815 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
821 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
825 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
826 [ -n "$size" -a "$size" -gt 0 ]
830 if [ "$CVSIGNORE_DF" != "yes" ]; then
833 cvsignore=${PACKAGE_DIR}/.cvsignore
835 # add only if not yet there
836 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
837 echo "$1" >> $cvsignore
842 update_shell_title "cvsup"
845 if [ "$1" = "-c" ]; then
849 if [ -n "$CVSROOT" ]; then
850 OPTIONS="-d $CVSROOT $OPTIONS"
853 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
854 OPTIONS="$OPTIONS -A"
856 if [ -n "$CVSDATE" ]; then
857 OPTIONS="$OPTIONS -D $CVSDATE"
859 if [ -n "$CVSTAG" ]; then
860 OPTIONS="$OPTIONS -r $CVSTAG"
865 local retries_counter=0
867 update_shell_title "cvsup: $*"
869 update_shell_title "cvsup: $# files"
871 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
872 retries_counter=$(( $retries_counter + 1 ))
873 output=$(LC_ALL=C $CVS_COMMAND $OPTIONS "$@" 2>&1)
875 [ -n "$output" ] && echo "$output"
876 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
877 echo "Trying again [$*]... ($retries_counter)"
878 update_shell_title "cvsup: retry #$retries_counter"
885 update_shell_title "cvsup: done!"
889 # returns true if "$1" is ftp, http or https protocol url
892 ftp://*|http://*|https://*)
900 if [ $# -eq 0 ]; then
904 update_shell_title "update md5"
905 if [ -n "$DEBUG" ]; then
912 # pass 1: check files to be fetched
916 local fp=$(nourl "$i")
917 local srcno=$(src_no "$i")
918 if [ -n "$ADD5" ]; then
919 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
920 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
921 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
923 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
925 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
926 need_files="$need_files $i"
930 # pass 1a: get needed files
931 if [ "$need_files" ]; then
932 get_files $need_files
935 # pass 2: proceed with md5 adding or updating
937 local fp=$(nourl "$i")
938 local srcno=$(src_no "$i")
939 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
940 if [ -z "$md5" ]; then
941 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
943 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
944 local tag="# Source$srcno-md5:\t"
945 if [[ "$md5" == *NoSource* ]]; then
946 tag="# NoSource$srcno-md5:\t"
947 elif [ -n "$USEDIGEST" ]; then
948 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
950 md5=$(md5sum "$fp" | cut -f1 -d' ')
951 echo "Updating Source$srcno ($md5: $fp)."
953 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
954 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
956 $PACKAGE_DIR/$SPECFILE
962 [ "$NO5" = "yes" ] && return
964 update_shell_title "check md5"
967 if good_md5 "$i" && good_size "$i"; then
971 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
972 echo "or -5 to update md5 sums, if you're sure files are correct."
973 Exit_error err_no_source_in_repo $i
978 update_shell_title "get_files"
980 if [ -n "$DEBUG" ]; then
985 if [ $# -gt 0 ]; then
988 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
989 echo "Warning: No CVS access defined for SOURCES"
994 local get_files_cvs=""
998 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
999 update_shell_title "$i"
1000 local fp=`nourl "$i"`
1001 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1006 local srcmd5=$(src_md5 "$i")
1008 # we know if source/patch is present in cvs/distfiles
1009 # - has md5 (in distfiles)
1010 # - in cvs... ideas?
1012 # CHECK: local file didn't exist or always cvs up (first) requested.
1013 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1014 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1015 echo "Warning: no URL given for $i"
1018 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1019 if good_md5 "$i" && good_size "$i"; then
1020 echo "$fp having proper md5sum already exists"
1025 # optionally prefer mirror over distfiles if there's mirror
1026 # TODO: build url list and then try each url from the list
1027 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1030 url=$(distfiles_url "$i")
1033 url_attic=$(distfiles_attic_url "$i")
1035 # is $url local file?
1036 if [[ "$url" = [./]* ]]; then
1037 update_shell_title "${GETLOCAL%% *}: $url"
1038 ${GETLOCAL} $url $target
1040 if [ -z "$NOMIRRORS" ]; then
1041 url=$(find_mirror "$url")
1045 # make shorter message for distfiles urls
1046 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1047 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1048 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1051 update_shell_title "${GETURI%% *}: $uri"
1052 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1053 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1054 update_shell_title "${GETURI2%% *}: $url"
1055 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1060 if [ ! -s "$target" ]; then
1062 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1063 update_shell_title "${GETLOCAL%% *}: $url_attic"
1064 ${GETLOCAL} $url_attic $target
1066 if [ -z "$NOMIRRORS" ]; then
1067 url_attic=$(find_mirror "$url_attic")
1069 update_shell_title "${GETURI%% *}: $url_attic"
1070 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1071 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1072 update_shell_title "${GETURI2%% *}: $url_attic"
1073 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1078 if [ -s "$target" ]; then
1079 cvsignore_df $target
1084 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1085 if [ $# -gt 1 ]; then
1086 get_files_cvs="$get_files_cvs $fp"
1087 update_shell_title "$fp (will cvs up later)"
1094 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1095 if [ -z "$NOMIRRORS" ]; then
1096 im=$(find_mirror "$i")
1100 update_shell_title "${GETURI%% *}: $im"
1101 ${GETURI} "$im" || \
1102 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1103 update_shell_title "${GETURI2%% *}: $im"
1108 if [ "$cvsup" = 1 ]; then
1114 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1115 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1116 if [ -n "GREEDSRC" ]; then
1117 get_greed_sources $i
1119 Exit_error err_no_source_in_repo $i
1123 # we check md5 here just only to refetch immediately
1124 if good_md5 "$i" && good_size "$i"; then
1126 elif [ "$FROM_DISTFILES" = 1 ]; then
1127 # wrong md5 from distfiles: remove the file and try again
1129 echo "MD5 sum mismatch. Trying full fetch."
1132 update_shell_title "${GETURI%% *}: $url"
1133 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1134 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1135 update_shell_title "${GETURI2%% *}: $url"
1136 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1138 if [ ! -s "$target" ]; then
1140 update_shell_title "${GETURI%% *}: $url_attic"
1141 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1142 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1143 update_shell_title "${GETURI2%% *}: $url_attic"
1144 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1147 test -s "$target" || rm -f "$target"
1150 SHELL_TITLE_PREFIX=""
1152 if [ "$get_files_cvs" ]; then
1153 cvsup $get_files_cvs
1156 if [ "$CHMOD" = "yes" ]; then
1157 CHMOD_FILES=$(nourl "$@")
1158 if [ -n "$CHMOD_FILES" ]; then
1159 chmod $CHMOD_MODE $CHMOD_FILES
1166 if [ -n "$DEBUG" ]; then
1171 # Check whether first character of PACKAGE_NAME is legal for tag name
1172 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1176 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1177 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1179 # Remove #kernel.version_release from TAGVER because tagging sources
1180 # could occur with different kernel-headers than kernel-headers used at build time.
1181 # besides, %{_kernel_ver_str} is not expanded.
1183 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1184 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1190 # bool is_tag_a_branch(tag)
1192 # returns 1 if a tag is a branch set on SPECFILE
1194 if [ -n "$DEBUG" ]; then
1199 if [ $# -ne 1 ]; then
1206 $CVS_COMMAND status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1213 if [ -n "$DEBUG" ]; then
1218 echo "Version: $PACKAGE_VERSION"
1219 echo "Release: $PACKAGE_RELEASE"
1222 if [ "$TAG_VERSION" = "yes" ]; then
1223 TAGVER=`make_tagver`
1224 echo "CVS tag: $TAGVER"
1226 if [ -n "$TAG" ]; then
1227 echo "CVS tag: $TAG"
1230 local OPTIONS="tag $CVS_FORCE"
1231 if [ -n "$CVSROOT" ]; then
1232 OPTIONS="-d $CVSROOT $OPTIONS"
1235 # if a tagname we are about to set already exists
1236 # and happens to be a branch (common case with AC-branch)
1237 # pass -B (allows -F to disturb branch tag)
1239 if [ "$TAG_VERSION" = "yes" ]; then
1242 is_tag_a_branch $_tag
1243 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1244 OPTIONS="$OPTIONS -B"
1249 for i in $TAG_FILES; do
1250 # don't tag files stored on distfiles
1251 [ -n "`src_md5 $i`" ] && continue
1252 local fp=`nourl "$i"`
1253 if [ -f "$fp" ]; then
1254 tag_files="$tag_files $fp"
1255 elif [ -n "GREEDSRC" ]; then
1256 get_greed_sources $i
1258 Exit_error err_no_source_in_repo $i
1262 if [ "$tag_files" ]; then
1263 if [ "$TAG_VERSION" = "yes" ]; then
1264 update_shell_title "tag sources: $TAGVER"
1265 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1266 $CVS_COMMAND $OPTIONS $TAGVER $tag_files || exit
1268 if [ -n "$TAG" ]; then
1269 update_shell_title "tag sources: $TAG"
1271 while [ "$tag_files" ]; do
1272 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1273 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1274 $CVS_COMMAND $OPTIONS $TAG $chunk || exit
1275 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1281 if [ "$TAG_VERSION" = "yes" ]; then
1282 update_shell_title "tag spec: $TAGVER"
1283 $CVS_COMMAND $OPTIONS $TAGVER $SPECFILE || exit
1285 if [ -n "$TAG" ]; then
1286 update_shell_title "tag spec: $TAG"
1287 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1293 echo "CVS branch tag: $TAG"
1298 if [ -n "$DEBUG" ]; then
1303 local OPTIONS="tag $CVS_FORCE -b"
1306 is_tag_a_branch $TAG
1307 if [ $? -eq 1 ]; then
1308 OPTIONS="$OPTIONS -B"
1311 if [ -n "$CVSROOT" ]; then
1312 OPTIONS="-d $CVSROOT $OPTIONS"
1316 for i in $TAG_FILES; do
1317 local fp=`nourl "$i"`
1318 if [ -f "$fp" ]; then
1319 tag_files="$tag_files $fp"
1320 elif [ -n "GREEDSRC" ]; then
1321 get_greed_sources $i
1323 Exit_error err_no_source_in_repo $i
1326 if [ "$tag_files" ]; then
1327 $CVS_COMMAND $OPTIONS $TAG $tag_files || exit
1331 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1335 # this function should exit early if package can't be built for this arch
1336 # this avoids unneccessary BR filling.
1339 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1341 if [ $ret -ne 0 ]; then
1348 update_shell_title "build_package"
1349 if [ -n "$DEBUG" ]; then
1356 if [ -n "$TRY_UPGRADE" ]; then
1357 update_shell_title "build_package: try_upgrade"
1358 if [ -n "$FLOAT_VERSION" ]; then
1359 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1361 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1364 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1366 if [ -n "$TNEWVER" ]; then
1367 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1368 echo "New version found, updating spec file to version " $TNEWVER
1369 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1370 cp -f $SPECFILE $SPECFILE.bak
1373 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1374 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1376 NODIST="yes" get_files $SOURCES $PATCHES
1379 unset TOLDVER TNEWVER TNOTIFY
1386 BUILD_SWITCH="-ba" ;;
1388 BUILD_SWITCH="-bb" ;;
1390 BUILD_SWITCH="-bs --nodeps" ;;
1392 BUILD_SWITCH="-bp --nodeps" ;;
1394 BUILD_SWITCH="-bc" ;;
1396 BUILD_SWITCH="-bi" ;;
1398 BUILD_SWITCH="-bl" ;;
1402 update_shell_title "build_package: $COMMAND"
1403 if [ -n "$LOGFILE" ]; then
1404 LOG=`eval echo $LOGFILE`
1405 if [ -d "$LOG" ]; then
1406 echo "Log file $LOG is a directory."
1407 echo "Parse error in the spec?"
1408 Exit_error err_build_fail
1410 if [ -n "$LASTLOG_FILE" ]; then
1411 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1413 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1415 (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
1416 RETVAL=`cat $RES_FILE`
1418 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1419 if [ "$RETVAL" -eq "0" ]; then
1426 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1429 if [ "$RETVAL" -ne "0" ]; then
1430 if [ -n "$TRY_UPGRADE" ]; then
1431 echo "\n!!! Package with new version cannot be built automagically\n"
1432 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1433 mv -f $SPECFILE.bak $SPECFILE
1436 Exit_error err_build_fail
1442 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1445 install_required_packages() {
1450 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1453 /^%changelog/ { exit }
1455 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1456 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1457 gsub(/[ \t]+/, "_", bcond);
1459 }' $SPEC | LC_ALL=C sort -u
1463 # expand bconds from ~/.bcondrc
1464 # The file structure is like gentoo's package.use:
1467 # samba -mysql -pgsql
1468 # w32codec-installer license_agreement
1471 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1477 SN=${SPECFILE%%\.spec}
1479 local bcondrc=$HOME/.bcondrc
1480 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1482 local bcond_avail=$(find_spec_bcond $SPECFILE)
1484 while read pkg flags; do
1486 [[ "$pkg" == \#* ]] && continue
1488 # any package or current package?
1489 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1490 for flag in $flags; do
1491 local opt=${flag#[+-]}
1493 # use only flags which are in this package.
1494 if [[ $bcond_avail = *${opt}* ]]; then
1495 if [[ $flag = -* ]]; then
1496 if [[ $BCOND != *--with?${opt}* ]]; then
1497 BCOND="$BCOND --without $opt"
1500 if [[ $BCOND != *--without?${opt}* ]]; then
1501 BCOND="$BCOND --with $opt"
1508 update_shell_title "parse ~/.bcondrc: DONE!"
1511 set_bconds_values() {
1512 update_shell_title "set bcond values"
1514 AVAIL_BCONDS_WITHOUT=""
1515 AVAIL_BCONDS_WITH=""
1517 if egrep -q '^# *_with' ${SPECFILE}; then
1518 echo >&2 "ERROR: This spec has old style bconds."
1522 if ! grep -q '^%bcond' ${SPECFILE}; then
1526 local bcond_avail=$(find_spec_bcond $SPECFILE)
1527 process_bcondrc "$SPECFILE"
1529 update_shell_title "parse bconds"
1532 for opt in $bcond_avail; do
1535 bcond=${opt#without_}
1536 if [[ "$BCOND" = *--without?${bcond}* ]]; then
1537 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1539 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1544 if [[ "$BCOND" = *--with?${bcond}* ]]; then
1545 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1547 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1551 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1560 update_shell_title "run_sub_builder $package_name"
1562 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1563 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1564 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1565 # jakby nie bylo tego kawalka kodu.
1567 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1568 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1572 # kurwa. translate that ^^^^
1576 # Istnieje taki spec? ${package}.spec
1577 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1578 parent_spec_name=${package}.spec
1579 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1580 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1582 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1587 if [ "${parent_spec_name}" != "" ]; then
1588 spawn_sub_builder $parent_spec_name
1590 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1593 spawn_sub_builder() {
1595 update_shell_title "spawn_sub_builder $package_name"
1598 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1599 sub_builder_opts="${sub_builder_opts} -R"
1601 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1602 sub_builder_opts="${sub_builder_opts} -RB"
1603 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1604 sub_builder_opts="${sub_builder_opts} -FRB"
1606 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1607 sub_builder_opts="${sub_builder_opts} -Upi"
1611 ./builder ${sub_builder_opts} "$@"
1614 remove_build_requires() {
1615 if [ "$INSTALLED_PACKAGES" != "" ]; then
1616 case "$REMOVE_BUILD_REQUIRES" in
1618 run_poldek --noask -ve $INSTALLED_PACKAGES
1621 run_poldek --ask -ve $INSTALLED_PACKAGES
1624 echo You may want to manually remove following BuildRequires fetched:
1625 echo $INSTALLED_PACKAGES
1626 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1633 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1634 if [ "$BCOND" ]; then
1635 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1638 echo -ne "\nNo conditional flags passed"
1640 echo -ne "\n\nfrom available:\n"
1641 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1645 display_branches() {
1646 if [ "$NOCVSSPEC" != "yes" ]; then
1647 echo -ne "Available branches: "
1648 $CVS_COMMAND status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1652 # checks a given list of packages/files/provides agains current rpmdb.
1653 # outputs all dependencies which current rpmdb doesn't satisfy.
1654 # input can be either STDIN or parameters
1658 if [ $# -gt 0 ]; then
1664 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1667 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1669 # other deps (files)
1670 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1673 # checks if given package/files/provides exists in rpmdb.
1674 # input can be either stdin or parameters
1675 # returns packages which are present in the rpmdb
1679 if [ $# -gt 0 ]; then
1685 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1688 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1689 install_build_requires_rpmdeps() {
1690 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1691 # TODO: Conflicts list doesn't check versions
1692 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1693 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1695 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1696 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1697 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1700 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1701 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1702 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1703 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1705 if [ -n "$CNFL" ]; then
1706 update_shell_title "uninstall conflicting packages: $CNFL"
1707 echo "Trying to uninstall conflicting packages ($CNFL):"
1708 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1711 while [ "$DEPS" ]; do
1712 update_shell_title "install deps: $DEPS"
1713 echo "Trying to install dependencies ($DEPS):"
1714 local log=.${SPECFILE}_poldek.log
1715 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1716 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1719 if [ -n "$failed" ]; then
1720 for package in $failed; do
1721 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1730 fetch_build_requires()
1732 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1736 update_shell_title "fetch build requires"
1737 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1738 install_build_requires_rpmdeps
1742 # XXX is this ugliest code written in human history still needed?
1743 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1744 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1745 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1746 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1747 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1748 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)
1750 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)
1752 package=$(basename "$package_item"|sed -e "s/}$//g")
1753 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1756 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1757 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1758 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
1763 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1766 if `echo $COND_TST|grep -q 'without_'`; then
1767 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1768 if `echo $COND_TST|grep -q !`; then
1773 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1774 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1775 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1781 elif `echo $COND_TST|grep -q 'with_'`; then
1782 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1783 if `echo $COND_TST|grep -q !`; then
1788 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1789 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1790 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1796 RESULT="${COND_STATE}-${COND_ARGV}"
1798 "with-wout" | "wout-with" )
1801 "wout-wout" | "with-with" )
1805 echo "Action '$RESULT' was not defined for package '$package_item'"
1811 if [ "$GO" = "yes" ]; then
1812 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1813 echo "Testing if $package has subrequirements..."
1814 run_poldek -t -i $package --dumpn=".$package-req.txt"
1815 if [ -f ".$package-req.txt" ]; then
1816 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1818 if [ "$package_name" = "$package" ]; then
1819 echo -ne "Installing BuildRequired package:\t$package_name\n"
1820 update_shell_title "Installing BuildRequired package: ${package_name}"
1821 install_required_packages $package
1823 echo -ne "Installing (sub)Required package:\t$package_name\n"
1824 update_shell_title "Installing (sub)Required package: ${package_name}"
1825 install_required_packages $package_name
1829 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1830 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1833 echo "Attempting to run spawn sub - builder..."
1834 echo -ne "Package installation failed:\t$package_name\n"
1835 run_sub_builder $package_name
1836 if [ $? -eq 0 ]; then
1837 install_required_packages $package_name
1840 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1841 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1844 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1851 rm -f ".$package-req.txt"
1853 echo "Attempting to run spawn sub - builder..."
1854 echo -ne "Package installation failed:\t$package\n"
1855 run_sub_builder $package
1856 if [ $? -eq 0 ]; then
1857 install_required_packages $package
1860 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1861 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1864 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1870 echo "Package $package is already installed. BuildRequirement satisfied."
1874 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1875 echo >&2 "Unable to install following packages and their dependencies:"
1876 for pkg in "$NOT_INSTALLED_PACKAGES"
1880 remove_build_requires
1886 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1887 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1889 echo "Initialising rpm directories to $TOP_DIR from $CVSROOT"
1890 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1892 $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1896 echo "To checkout *all* .spec files (read-only):"
1897 echo "- run cvs co SPECS"
1899 echo "To checkout *all* packages:"
1900 echo "- run cvs up -d in $TOP_DIR/packages dir"
1903 echo "To commit with your developer account:"
1904 echo "- edit $TOP_DIR/packages/CVS/Root"
1907 get_greed_sources() {
1908 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1909 if [ -n "BE_VERBOSE" ]; then
1910 echo "Try greed download: $1 from: $CVSROOT"
1912 $CVS_COMMAND -d $CVSROOT get SOURCES/$1
1913 if [ $? != 0 ]; then
1914 Exit_error err_no_source_in_repo $1
1919 # remove entries from CVS/Entries
1920 cvs_entry_remove() {
1921 local cvsdir="$1"; shift
1922 if [ ! -d "$cvsdir" ]; then
1923 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1927 for file in "$@"; do
1928 rm -f $cvsdir/CVS/Entries.new || return 1
1929 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1930 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1938 DONT_PRINT_REVISION="yes"
1942 # remove from CVS/Entries
1943 cvs_entry_remove $PACKAGE_DIR $SPECFILE $SOURCES $PATCHES
1945 # remove spec and sources
1946 $RPMBUILD --clean --rmsource --rmspec --nodeps --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1949 #---------------------------------------------
1957 while [ $# -gt 0 ]; do
1960 COMMAND="update_md5"
1965 COMMAND="update_md5"
1975 DEBUG="yes"; shift ;;
1977 COMMAND="version"; shift ;;
1979 COMMAND="short-version"; shift ;;
1981 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1982 -b | -ba | --build )
1983 COMMAND="build"; shift ;;
1984 -bb | --build-binary )
1985 COMMAND="build-binary"; shift ;;
1987 COMMAND="build-build"; shift ;;
1989 COMMAND="build-install"; shift ;;
1991 COMMAND="build-list"; shift ;;
1992 -bp | --build-prep )
1993 COMMAND="build-prep"; shift ;;
1994 -bs | --build-source )
1995 COMMAND="build-source"; shift ;;
1997 COMMAND="branch"; shift; TAG="${1}"; shift;;
1999 CLEAN="--clean --rmspec --rmsource"; shift ;;
2001 CVS_FORCE="-F"; shift;;
2003 shift; CVSROOT="${1}"; shift ;;
2005 COMMAND="get"; shift ;;
2007 COMMAND="usage"; shift ;;
2009 PROTOCOL="http"; shift ;;
2011 shift; LOGFILE="${1}"; shift ;;
2013 shift; DEF_NICE_LEVEL=${1}; shift ;;
2014 -ske | --skip-existing-files)
2015 SKIP_EXISTING_FILES="yes"; shift ;;
2017 COMMAND="mr-proper"; shift ;;
2019 NOCVS="yes"; shift ;;
2020 -ncs | --no-cvs-specs )
2021 NOCVSSPEC="yes"; shift ;;
2022 -nd | --no-distfiles )
2023 NODIST="yes"; shift ;;
2024 -nm | --no-mirrors )
2025 NOMIRRORS="yes"; shift ;;
2027 NOURLS="yes"; shift ;;
2029 NOSRCS="yes"; shift ;;
2030 -ns0 | --no-source0 )
2031 NOSOURCE0="yes"; shift ;;
2041 -pm | --prefer-mirrors )
2048 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2050 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2052 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2055 --with | --without )
2056 case $GROUP_BCONDS in
2060 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2061 while ! `echo ${1}|grep -qE '(^-|spec)'`
2063 BCOND="$BCOND $COND $1"
2067 if [[ "$2" = *,* ]]; then
2068 for a in $(echo "$2" | tr , ' '); do
2069 BCOND="$BCOND $1 $a"
2072 BCOND="$BCOND $1 $2"
2078 shift; TARGET="${1}"; shift ;;
2080 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2082 QUIET="--quiet"; shift ;;
2084 CVSDATE="${2}"; shift 2 ;;
2093 -R | --fetch-build-requires)
2094 FETCH_BUILD_REQUIRES="yes"
2095 NOT_INSTALLED_PACKAGES=
2097 -RB | --remove-build-requires)
2098 REMOVE_BUILD_REQUIRES="nice"
2100 -FRB | --force-remove-build-requires)
2101 REMOVE_BUILD_REQUIRES="force"
2103 -sc | --sources-cvs)
2104 COMMAND="list-sources-cvs"
2106 -sd | --sources-distfiles)
2107 COMMAND="list-sources-distfiles"
2109 -sdp | --sources-distfiles-paths)
2110 COMMAND="list-sources-distfiles-paths"
2112 -sf | --sources-files)
2113 COMMAND="list-sources-files"
2115 -sp | --sources-paths)
2116 COMMAND="list-sources-local-paths"
2118 -su | --sources-urls)
2119 COMMAND="list-sources-urls"
2121 -Tvs | --tag-version-stable )
2126 -Ts | --tag-stable )
2131 -Tv | --tag-version )
2136 -Tp | --tag-prefix )
2148 -ir | --integer-release-only )
2149 INTEGER_RELEASE="yes"
2152 COMMAND="update_md5"
2157 -Upi | --update-poldek-indexes )
2158 UPDATE_POLDEK_INDEXES="yes"
2161 COMMAND="init_rpm_dir"
2163 --use-greed-sources )
2166 -u | --try-upgrade )
2167 TRY_UPGRADE="1"; shift ;;
2168 -un | --try-upgrade-with-float-version )
2169 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2171 BE_VERBOSE="1"; shift ;;
2176 if echo "${MACRO}" | grep -q '\W'; then
2177 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2181 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2186 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2190 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2193 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2194 COMMAND="show_bconds"
2198 COMMAND="show_bcond_args"
2203 RPMOPTS="${RPMOPTS} --nodeps"
2206 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2209 Exit_error err_invalid_cmdline "$1"
2213 # check if specname was passed as specname:cvstag
2214 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2215 CVSTAG="${SPECFILE##*:}"
2216 SPECFILE="${SPECFILE%%:*}"
2218 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2223 [ -d "$ASSUMED_NAME" ] && CVS_ENTRIES="$ASSUMED_NAME/CVS/Entries" || CVS_ENTRIES="CVS/Entries"
2224 if [ -f "$CVS_ENTRIES" ] && [ -z "$CVSTAG" ]; then
2225 CVSTAG=$(awk -vSPECFILE=$(basename ${SPECFILE%.spec}.spec) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' ${CVS_ENTRIES})
2226 if [ "$CVSTAG" ]; then
2227 echo >&2 "builder: Sticky tag $CVSTAG active. Use -r TAGNAME to override."
2229 elif [ "$CVSTAG" = "HEAD" ]; then
2230 # assume -r HEAD is same as -A
2234 if [ "$CVSTAG" ]; then
2235 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2236 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2239 if [ -n "$DEBUG" ]; then
2244 if [ -n "$TARGET" ]; then
2247 TARGET_SWITCH="--target $TARGET" ;;
2249 TARGET_SWITCH="--target=$TARGET" ;;
2253 if [ "$SCHEDTOOL" != "no" ]; then
2254 NICE_COMMAND="$SCHEDTOOL"
2256 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2259 update_shell_title "$COMMAND"
2263 if [ -n "$SPECFILE" ]; then
2264 get_spec > /dev/null
2272 if [ -n "$SPECFILE" ]; then
2273 get_spec > /dev/null
2279 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2281 if [ -n "$SPECFILE" ]; then
2282 # display SMP make flags if set
2283 smp_mflags=$(rpm -E %{?_smp_mflags})
2284 if [ "$smp_mflags" ]; then
2285 echo >&2 "builder: SMP make flags are set to $smp_mflags"
2293 if [ "$COMMAND" != "build-source" ]; then
2296 fetch_build_requires
2297 if [ "$INTEGER_RELEASE" = "yes" ]; then
2298 echo "Checking release $PACKAGE_RELEASE..."
2299 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2300 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2304 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2305 if [ -n "$TEST_TAG" ]; then
2306 local TAGVER=`make_tagver`
2307 echo "Searching for tag $TAGVER..."
2308 TAGREL=$($CVS_COMMAND status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2309 if [ -n "$TAGREL" ]; then
2310 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2313 # - do not allow to build from HEAD when XX-branch exists
2314 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2315 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2316 TAG_BRANCH="${TREE_PREFIX}-branch"
2317 TAG_STATUS=$($CVS_COMMAND status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2318 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2319 Exit_error err_branch_exists "$TAG_STATUS"
2325 if [ -n "$NOSOURCE0" ] ; then
2326 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2328 get_files $SOURCES $PATCHES
2331 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2332 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2334 remove_build_requires
2336 Exit_error err_no_spec_in_cmdl
2341 if [ -n "$SPECFILE" ]; then
2344 # don't fetch sources from remote locations
2346 for file in $SOURCES; do
2347 [ -n "`src_md5 $file`" ] && continue
2348 new_SOURCES="$new_SOURCES $file"
2350 SOURCES="$new_SOURCES"
2351 get_files $SOURCES $PATCHES
2353 branch_files $TAG $SOURCES $PATCHES $ICONS
2355 Exit_error err_no_spec_in_cmdl
2360 if [ -n "$SPECFILE" ]; then
2364 if [ -n "$NOSOURCE0" ] ; then
2365 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2367 get_files $SOURCES $PATCHES
2370 Exit_error err_no_spec_in_cmdl
2375 if [ -n "$SPECFILE" ]; then
2379 if [ -n "$NOSOURCE0" ] ; then
2380 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2384 Exit_error err_no_spec_in_cmdl
2391 if [ -n "$SPECFILE" ]; then
2395 # don't fetch sources from remote locations
2397 for file in $SOURCES; do
2398 [ -n "`src_md5 $file`" ] && continue
2399 new_SOURCES="$new_SOURCES $file"
2401 SOURCES="$new_SOURCES"
2402 get_files $SOURCES $PATCHES
2404 tag_files $SOURCES $PATCHES $ICONS
2406 Exit_error err_no_spec_in_cmdl
2412 "list-sources-files" )
2415 DONT_PRINT_REVISION="yes"
2418 for SAP in $SOURCES $PATCHES; do
2419 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2422 "list-sources-urls" )
2425 DONT_PRINT_REVISION="yes"
2428 SAPS="$SOURCES $PATCHES"
2429 for SAP in $SAPS ; do
2433 "list-sources-local-paths" )
2436 DONT_PRINT_REVISION="yes"
2439 for SAP in $SOURCES $PATCHES; do
2440 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2443 "list-sources-distfiles-paths" )
2446 DONT_PRINT_REVISION="yes"
2449 for SAP in $SOURCES $PATCHES; do
2450 if [ -n "$(src_md5 "$SAP")" ]; then
2451 distfiles_path "$SAP"
2455 "list-sources-distfiles" )
2458 DONT_PRINT_REVISION="yes"
2461 for SAP in $SOURCES $PATCHES; do
2462 if [ -n "$(src_md5 "$SAP")" ]; then
2463 distfiles_url "$SAP"
2467 "list-sources-cvs" )
2470 DONT_PRINT_REVISION="yes"
2473 for SAP in $SOURCES $PATCHES; do
2474 if [ -z "$(src_md5 "$SAP")" ]; then
2475 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2489 echo "$VERSIONSTRING"
2492 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2493 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2497 # vi:syntax=sh:ts=4:sw=4:noet