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)
25 # - does not respect NoSource: X, and tries to cvs up such files [ example: VirtualBox-bin.spec and its Source0 ]
27 # - ability to do ./builder -bb foo.spec foo2.spec foo3.spec
34 Build package utility from PLD Linux CVS repository
35 $VERSION (C) 1999-2009 Free Penguins".
37 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
56 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
60 # use rpm 4.4.6+ digest format instead of comments if non-zero
63 # user agent when fetching files
64 USER_AGENT="PLD/Builder($VERSION)"
66 # It can be used i.e. in log file naming.
67 # See LOGFILE example.
68 DATE=`date +%Y-%m-%d_%H-%M-%S`
70 # Example: LOGFILE='../log.$PACKAGE_NAME'
71 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
72 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
73 # Example: LOGFILE='$PACKAGE_NAME.$DATE.log'
74 # Yes, you can use variable name! Note _single_ quotes!
89 # create symlinks for tools in PACKAGE_DIR, see get_spec()
100 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
102 CVS_COMMAND=${CVS_COMMAND:-cvs}
105 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
106 CVS_SERVER="cvs.pld-linux.org"
111 DISTFILES_SERVER="://distfiles.pld-linux.org"
112 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
117 FAIL_IF_NO_SOURCES="yes"
119 # let get_files skip over files which are present to get those damn files fetched
120 SKIP_EXISTING_FILES="no"
123 # should the specfile be restored if upgrade failed?
124 REVERT_BROKEN_UPGRADE="yes"
126 if rpm --specsrpm 2>/dev/null; then
127 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
128 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
130 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
131 if [ -x /usr/bin/rpm-getdeps ]; then
132 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
134 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
139 # Here we load saved user environment used to
140 # predefine options set above, or passed to builder
142 # This one reads global system environment settings:
143 if [ -f ~/etc/builderrc ]; then
146 # And this one cascades settings using user personal
148 # Example of ~/.builderrc:
150 #UPDATE_POLDEK_INDEXES="yes"
151 #FETCH_BUILD_REQUIRES="yes"
152 #REMOVE_BUILD_REQUIRES="force"
154 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
158 if [ -n "$HOME_ETC" ]; then
159 USER_CFG="$HOME_ETC/.builderrc"
160 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
162 USER_CFG=~/.builderrc
163 BUILDER_MACROS=~/.builder-rpmmacros
166 [ -f "$USER_CFG" ] && . "$USER_CFG"
168 if [ "$SCHEDTOOL" = "auto" ]; then
169 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
170 SCHEDTOOL="schedtool -B -e"
176 if [ -n "$USE_PROZILLA" ]; then
177 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
180 elif [ -n "$USE_AXEL" ]; then
181 GETURI="axel -a $AXEL_OPTS"
185 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
186 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
187 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
188 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
190 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
191 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
197 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
206 # are we using cvs-nserver ?
209 $CVS_COMMAND --version 2>&1 | grep -q 'CVS-nserver'
210 [ $? -eq 0 ] && CVS_NSERVER=1
212 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
213 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
216 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
217 if [ -n "$LOGFILE" ]; then
218 LOG=`eval echo $LOGFILE`
219 if [ -n "$LASTLOG_FILE" ]; then
220 echo "LASTLOG=$LOG" > $LASTLOG_FILE
222 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
225 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
226 return `cat ${RES_FILE}`
231 #---------------------------------------------
235 if [ -n "$DEBUG" ]; then set -xv; fi
237 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
238 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
239 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
240 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
241 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
242 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
243 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
244 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
245 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
246 <package>[.spec][:cvstag]
248 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
249 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
250 -n5, --no-md5 - ignore md5 comments in spec
251 -D, --debug - enable builder script debugging mode,
252 -debug - produce rpm debug package (same as --opts -debug)
253 -V, --version - output builder version string
254 --short-version - output builder short version
255 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
256 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
258 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
259 only package from <package>.spec,
260 -bp, --build-prep - execute the %prep phase of <package>.spec,
261 -bc - execute the %build phase of <package>.spec,
262 -bi - execute the %install phase of <package>.spec
263 -bl - execute the %files phase of <package>.spec
264 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
266 --short-circuit - short-circuit build
267 -B, --branch - add branch
268 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
269 SPECS and \$RPM_BUILD_ROOT and CVS/Entries) after rpmbuild commands.
270 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
271 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
273 -cf, --cvs-force - use -F when tagging (useful when moving branches)
274 -d <cvsroot>, --cvsroot <cvsroot>
276 --define <macro> <value>
277 - define a macro <macro> with value <value>,
278 --alt_kernel <kernel>
279 - same as --define 'alt_kernel <kernel>'
280 --nodeps - rpm won't check any dependences
281 -g, --get - get <package>.spec and all related files from CVS repo
283 -h, --help - this message,
284 --http - use http instead of ftp,
285 -l <logfile>, --logtofile <logfile>
287 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
289 - don't check specs in CVS
290 -nd, --no-distfiles - don't download from distfiles
291 -nm, --no-mirrors - don't download from mirror, if source URL is given,
292 -nu, --no-urls - don't try to download from FTP/HTTP location,
293 -ns, --no-srcs - don't download Sources/Patches
294 -ns0, --no-source0 - don't download Source0
295 -nn, --no-net - don't download anything from the net
296 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
297 --no-init - don't initialize builder paths (SPECS and SOURCES)
299 --skip-existing-files - skip existing files in get_files
300 --opts <rpm opts> - additional options for rpm
301 -q, --quiet - be quiet,
302 --date yyyy-mm-dd - build package using resources from specified CVS date,
303 -r <cvstag>, --cvstag <cvstag>
304 - build package using resources from specified CVS tag,
305 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
306 -R, --fetch-build-requires
307 - fetch what is BuildRequired,
308 -RB, --remove-build-requires
309 - remove all you fetched with -R or --fetch-build-requires
310 remember, this option requires confirmation,
311 -FRB, --force-remove-build-requires
312 - remove all you fetched with -R or --fetch-build-requires
313 remember, this option works without confirmation,
314 -sd, --source-distfiles - list sources available from distfiles (intended for offline
315 operations; does not work when Icon field is present
316 but icon file is absent),
317 -sc, --source-cvs - list sources available from CVS
318 -sdp, --source-distfiles-paths - list sources available from distfiles -
319 paths relative to distfiles directory (intended for offline
320 operations; does not work when Icon field is present
321 but icon file is absent),
322 -sf, --source-files - list sources - bare filenames (intended for offline
323 operations; does not work when Icon field is present
324 but icon file is absent),
325 -sp, --source-paths - list sources - filenames with full local paths (intended for
326 offline operations; does not work when Icon field is present
327 but icon file is absent),
328 -su, --source-urls - list urls - urls to sources and patches
329 intended for copying urls with spec with lots of macros in urls
330 -T <cvstag> , --tag <cvstag>
331 - add cvs tag <cvstag> for files,
332 -Tvs, --tag-version-stable
333 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
335 - add cvs tag STABLE for files,
337 - add cvs tag NAME-VERSION-RELEASE for files,
338 -Tp, --tag-prefix <prefix>
339 - add <prefix> to NAME-VERSION-RELEASE tags,
340 -tt, --test-tag <prefix>
341 - fail if tag is already present,
342 -ir, --integer-release-only
343 - allow only integer and snapshot releases
344 -v, --verbose - be verbose,
345 -u, --try-upgrade - check version, and try to upgrade package
346 -un, --try-upgrade-with-float-version
347 - as above, but allow float version
349 - try download source from tag head if don't find it in
351 -U, --update - refetch sources, don't use distfiles, and update md5 comments
352 -Upi, --update-poldek-indexes
353 - refresh or make poldek package index files.
354 -np, --nopatch <patchnumber>
355 - don't apply <patchnumber>
356 --show-bconds - show available conditional builds, which can be used
357 - with --with and/or --without switches.
358 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
359 ./repackage.sh script. in other words, the output is
360 parseable by scripts.
361 --with/--without <feature>
362 - conditional build package depending on %_with_<feature>/
363 %_without_<feature> macro switch. You may now use
364 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
365 constructions. Set GROUP_BCONDS to yes to make use of it.
366 --target <platform>, --target=<platform>
367 - build for platform <platform>.
368 --init-rpm-dir - initialize ~/rpm directory structure
372 # change dependency to specname
374 # - perl(Package::Name) -> perl-Package-Name
378 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g};' -e 's/-\(devel\|static\)$//' )
382 update_shell_title() {
384 local len=${COLUMNS:-80}
385 local msg=$(echo "$*" | cut -c-$len)
387 if [ -n "$BE_VERBOSE" ]; then
388 echo >&2 "$(date +%s.%N) $*"
391 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
393 if [ -n "$PACKAGE_NAME" ]; then
394 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
399 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
400 msg=$(echo $msg | tr -d '\n\r')
403 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
406 echo >&2 -ne "\033]0;$msg\007"
412 # set TARGET from BuildArch: from SPECFILE
414 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
415 tmp=$(awk '/^BuildArch:/ { print $NF; exit }' $ASSUMED_NAME/$SPECFILE)
417 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
421 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
423 TARGET_SWITCH="--target=$TARGET" ;;
429 # runs rpm with minimal macroset
431 # we reset macros not to contain macros.build as all the %() macros are
432 # executed here, while none of them are actually needed.
433 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
434 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
436 # TODO: move these to /usr/lib/rpm/macros
437 cat > $BUILDER_MACROS <<'EOF'
438 %x8664 x86_64 amd64 ia32e
441 %requires_releq_kernel_up %{nil}
442 %requires_releq_kernel_smp %{nil}
443 %requires_releq_kernel %{nil}
444 %requires_releq() %{nil}
445 %pyrequires_eq() %{nil}
446 %requires_eq() %{nil}
447 %requires_eq_to() %{nil}
448 %releq_kernel_up ERROR
449 %releq_kernel_smp ERROR
454 %ruby_ver_requires_eq() %{nil}
455 %ruby_mod_ver_requires_eq() %{nil}
456 %__php_api_requires() %{nil}
457 %php_major_version ERROR
458 %php_api_version ERROR
459 %requires_xorg_xserver_extension %{nil}
460 %requires_xorg_xserver_xinput %{nil}
461 %requires_xorg_xserver_font %{nil}
462 %requires_xorg_xserver_videodrv %{nil}
464 %perl_vendorarch ERROR
465 %perl_vendorlib ERROR
466 # damn. need it here! - copied from /usr/lib/rpm/macros.build
467 %tmpdir %(echo "${TMPDIR:-/tmp}")
468 %patchset_source(f:b:) %(
469 base=%{-b*}%{!-b*:10000};
470 start=$(expr $base + %1);
471 end=$(expr $base + %{?2}%{!?2:%{1}});
472 # we need to call seq twice as it doesn't allow two formats
473 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
474 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
475 paste %{tmpdir}/__ps{1,2};
476 rm -f %{tmpdir}/__ps{1,2};
479 %add_etc_shells(p) %{p:<lua>}
480 %remove_etc_shells(p) %{p:<lua>}
481 %lua_add_etc_shells() %{nil}
482 %lua_remove_etc_shells() %{nil}
484 if [ "$NOINIT" = "yes" ] ; then
485 cat >> $BUILDER_MACROS <<'EOF'
490 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
494 if [ -n "$DEBUG" ]; then
499 if [ -x /usr/bin/rpm-specdump ]; then
500 update_shell_title "cache_rpm_dump using rpm-specdump command"
501 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
503 update_shell_title "cache_rpm_dump using rpmbuild command"
506 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
507 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
513 ARGS='--nodigest --nosignature --nobuild'
516 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
518 if [ $? -gt 0 ]; then
519 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
521 Exit_error err_build_fail
524 # make small dump cache
525 rpm_dump_cache=`echo "$rpm_dump" | awk '
526 $2 ~ /^SOURCEURL/ {print}
527 $2 ~ /^PATCHURL/ {print}
528 $2 ~ /^nosource/ {print}
529 $2 ~ /^PACKAGE_/ {print}
533 update_shell_title "cache_rpm_dump: OK!"
537 if [ -z "$rpm_dump_cache" ] ; then
538 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
540 echo "$rpm_dump_cache"
544 update_shell_title "get icons"
545 ICONS=$(awk '/^Icon:/ {print $2}' ${ASSUMED_NAME}/${SPECFILE})
546 if [ -z "$ICONS" ]; then
550 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
554 update_shell_title "parsing specfile"
555 if [ -n "$DEBUG" ]; then
560 # icons are needed for successful spec parse
566 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
567 FAIL_IF_NO_SOURCES="no"
570 if [ "$NOSRCS" != "yes" ]; then
571 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
572 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
573 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
576 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
577 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
578 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
580 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
581 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
584 if [ -n "$BE_VERBOSE" ]; then
585 echo "- Sources : `nourl $SOURCES`"
586 if [ -n "$PATCHES" ]; then
587 echo "- Patches : `nourl $PATCHES`"
589 echo "- Patches : *no patches needed*"
591 if [ -n "$ICONS" ]; then
592 echo "- Icon : `nourl $ICONS`"
594 echo "- Icon : *no package icon*"
596 echo "- Name : $PACKAGE_NAME"
597 echo "- Version : $PACKAGE_VERSION"
598 echo "- Release : $PACKAGE_RELEASE"
601 update_shell_title "parse_spec: OK!"
605 if [ -n "$DEBUG" ]; then
613 "err_no_spec_in_cmdl" )
614 remove_build_requires
615 echo >&2 "ERROR: spec file name not specified."
617 "err_invalid_cmdline" )
618 echo >&2 "ERROR: invalid command line arg ($2)."
620 "err_no_spec_in_repo" )
621 remove_build_requires
622 echo >&2 "Error: spec file not stored in CVS repo."
624 "err_no_source_in_repo" )
625 remove_build_requires
626 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
629 remove_build_requires
630 echo >&2 "Error: package build failed. (${2:-no more info})"
632 "err_no_package_data" )
633 remove_build_requires
634 echo >&2 "Error: couldn't get out package name/version/release from spec file."
637 remove_build_requires
638 echo >&2 "Tag ${2} already exists (spec release: ${3})."
641 remove_build_requires
642 echo >&2 "Release ${2} not integer and not a snapshot."
644 "err_branch_exists" )
645 remove_build_requires
646 echo >&2 "Tree branch already exists (${2})."
649 remove_build_requires
650 echo >&2 "Error: conditions reject building this spec (${2})."
653 echo >&2 "Unknown error."
658 if [ -n "$DEBUG" ]; then
663 if [ "$NOINIT" != "yes" ] ; then
664 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
665 REPO_DIR=$TOP_DIR/packages
666 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
677 update_shell_title "get_spec"
679 if [ -n "$DEBUG" ]; then
685 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
686 SPECFILE="$(basename $SPECFILE .spec).spec"
688 if [ "$NOCVSSPEC" != "yes" ]; then
690 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
691 echo "Warning: No CVS access defined - using local .spec file"
695 if [ -d "$ASSUMED_NAME" ]; then
696 cvsup "$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
698 cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
700 # remove Entries.Static -- so 'cvs up' would update all files in a repo
701 rm "$ASSUMED_NAME/CVS/Entries.Static"
702 cvsignore_df .cvsignore
704 # create symlinks for tools
705 if [ "$SYMLINK_TOOLS" != "no" ]; then
706 for a in dropin md5 adapter builder {relup,compile,repackage,rsync}.sh; do
707 [ -f $a ] || continue
708 ln -s ../$a $ASSUMED_NAME
715 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
716 Exit_error err_no_spec_in_repo
719 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
720 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
723 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
731 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
732 $CVS_COMMAND update mirrors >&2
736 local origin mirror name rest ol prefix
737 while read origin mirror name rest; do
738 # skip comments and empty lines
739 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
742 ol=$(echo -n "$origin" | wc -c)
743 prefix=$(echo -n "$url" | head -c $ol)
744 if [ "$prefix" = "$origin" ] ; then
745 suffix=$(echo "$url" | cut -b $((ol+1))-)
746 echo -n "$mirror$suffix"
753 # Warning: unpredictable results if same URL used twice
757 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
758 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
763 [ "$NO5" = "yes" ] && return
765 [ -z "$no" ] && return
769 if [ -f additional-md5sums ]; then
770 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
771 if [ -z "$spec_rev" ]; then
772 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
774 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
775 md5=$(grep -s -v '^#' additional-md5sums | \
776 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
777 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
778 grep -E '^[0-9a-f]{32}$')
781 if [ $(echo "$md5" | wc -l) != 1 ] ; then
782 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
784 echo "$md5" | tail -n 1
789 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
790 if [ -n "$source_md5" ]; then
793 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
794 if [ -n "$source_md5" ]; then
797 # we have empty SourceX-md5, but it is still possible
798 # that we have NoSourceX-md5 AND NoSource: X
799 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
800 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
808 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
812 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
815 distfiles_attic_url() {
816 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
822 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
826 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
827 [ -n "$size" -a "$size" -gt 0 ]
831 if [ "$CVSIGNORE_DF" != "yes" ]; then
834 cvsignore=${PACKAGE_DIR}/.cvsignore
836 # add only if not yet there
837 if ! awk -vf="$1" -vc=1 '$0 == f { c = 0 } END { exit c }' $cvsignore 2>/dev/null; then
838 echo "$1" >> $cvsignore
843 update_shell_title "cvsup"
846 if [ "$1" = "-c" ]; then
850 if [ -n "$CVSROOT" ]; then
851 OPTIONS="-d $CVSROOT $OPTIONS"
854 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
855 OPTIONS="$OPTIONS -A"
857 if [ -n "$CVSDATE" ]; then
858 OPTIONS="$OPTIONS -D $CVSDATE"
860 if [ -n "$CVSTAG" ]; then
861 OPTIONS="$OPTIONS -r $CVSTAG"
866 local retries_counter=0
868 update_shell_title "cvsup: $*"
870 update_shell_title "cvsup: $# files"
872 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
873 retries_counter=$(( $retries_counter + 1 ))
874 output=$(LC_ALL=C $CVS_COMMAND $OPTIONS "$@" 2>&1)
876 [ -n "$output" ] && echo "$output"
877 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
878 echo "Trying again [$*]... ($retries_counter)"
879 update_shell_title "cvsup: retry #$retries_counter"
886 update_shell_title "cvsup: done!"
890 # returns true if "$1" is ftp, http or https protocol url
893 ftp://*|http://*|https://*)
901 if [ $# -eq 0 ]; then
905 update_shell_title "update md5"
906 if [ -n "$DEBUG" ]; then
913 # pass 1: check files to be fetched
917 local fp=$(nourl "$i")
918 local srcno=$(src_no "$i")
919 if [ -n "$ADD5" ]; then
920 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
921 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
922 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
924 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE || continue
926 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
927 need_files="$need_files $i"
931 # pass 1a: get needed files
932 if [ "$need_files" ]; then
933 get_files $need_files
936 # pass 2: proceed with md5 adding or updating
938 local fp=$(nourl "$i")
939 local srcno=$(src_no "$i")
940 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE )
941 if [ -z "$md5" ]; then
942 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE )
944 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
945 local tag="# Source$srcno-md5:\t"
946 if [[ "$md5" == *NoSource* ]]; then
947 tag="# NoSource$srcno-md5:\t"
948 elif [ -n "$USEDIGEST" ]; then
949 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
951 md5=$(md5sum "$fp" | cut -f1 -d' ')
952 echo "Updating Source$srcno ($md5: $fp)."
954 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
955 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
957 $PACKAGE_DIR/$SPECFILE
963 [ "$NO5" = "yes" ] && return
965 update_shell_title "check md5"
968 if good_md5 "$i" && good_size "$i"; then
972 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
973 echo "or -5 to update md5 sums, if you're sure files are correct."
974 Exit_error err_no_source_in_repo $i
979 update_shell_title "get_files"
981 if [ -n "$DEBUG" ]; then
986 if [ $# -gt 0 ]; then
989 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
990 echo "Warning: No CVS access defined for SOURCES"
995 local get_files_cvs=""
999 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
1000 update_shell_title "$i"
1001 local fp=`nourl "$i"`
1002 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1007 local srcmd5=$(src_md5 "$i")
1009 # we know if source/patch is present in cvs/distfiles
1010 # - has md5 (in distfiles)
1011 # - in cvs... ideas?
1013 # CHECK: local file didn't exist or always cvs up (first) requested.
1014 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1015 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1016 echo "Warning: no URL given for $i"
1020 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1021 if good_md5 "$i" && good_size "$i"; then
1022 echo "$fp having proper md5sum already exists"
1026 # optionally prefer mirror over distfiles if there's mirror
1027 # TODO: build url list and then try each url from the list
1028 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1031 url=$(distfiles_url "$i")
1034 url_attic=$(distfiles_attic_url "$i")
1036 # is $url local file?
1037 if [[ "$url" = [./]* ]]; then
1038 update_shell_title "${GETLOCAL%% *}: $url"
1039 ${GETLOCAL} $url $target
1041 if [ -z "$NOMIRRORS" ]; then
1042 url=$(find_mirror "$url")
1046 # make shorter message for distfiles urls
1047 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1048 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1049 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1052 update_shell_title "${GETURI%% *}: $uri"
1053 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1054 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1055 update_shell_title "${GETURI2%% *}: $url"
1056 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1061 if [ ! -s "$target" ]; then
1063 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1064 update_shell_title "${GETLOCAL%% *}: $url_attic"
1065 ${GETLOCAL} $url_attic $target
1067 if [ -z "$NOMIRRORS" ]; then
1068 url_attic=$(find_mirror "$url_attic")
1070 update_shell_title "${GETURI%% *}: $url_attic"
1071 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1072 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1073 update_shell_title "${GETURI2%% *}: $url_attic"
1074 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1076 test -s "$target" || rm -f "$target"
1080 if [ -s "$target" ]; then
1081 cvsignore_df $target
1086 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1087 if [ $# -gt 1 ]; then
1088 get_files_cvs="$get_files_cvs $fp"
1089 update_shell_title "$fp (will cvs up later)"
1096 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1097 if [ -z "$NOMIRRORS" ]; then
1098 im=$(find_mirror "$i")
1102 update_shell_title "${GETURI%% *}: $im"
1103 ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
1104 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1105 update_shell_title "${GETURI2%% *}: $im"
1106 ${GETURI2} "$im" ${OUTFILEOPT} "$target"
1108 test -s "$target" || rm -f "$target"
1111 if [ "$cvsup" = 1 ]; then
1117 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1118 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1119 if [ -n "GREEDSRC" ]; then
1120 get_greed_sources $i
1122 Exit_error err_no_source_in_repo $i
1126 # we check md5 here just only to refetch immediately
1127 if good_md5 "$i" && good_size "$i"; then
1129 elif [ "$FROM_DISTFILES" = 1 ]; then
1130 # wrong md5 from distfiles: remove the file and try again
1132 echo "MD5 sum mismatch. Trying full fetch."
1135 update_shell_title "${GETURI%% *}: $url"
1136 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1137 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1138 update_shell_title "${GETURI2%% *}: $url"
1139 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1141 if [ ! -s "$target" ]; then
1143 update_shell_title "${GETURI%% *}: $url_attic"
1144 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1145 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1146 update_shell_title "${GETURI2%% *}: $url_attic"
1147 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1150 test -s "$target" || rm -f "$target"
1153 SHELL_TITLE_PREFIX=""
1155 if [ "$get_files_cvs" ]; then
1156 cvsup $get_files_cvs
1159 if [ "$CHMOD" = "yes" ]; then
1160 CHMOD_FILES=$(nourl "$@")
1161 if [ -n "$CHMOD_FILES" ]; then
1162 chmod $CHMOD_MODE $CHMOD_FILES
1169 if [ -n "$DEBUG" ]; then
1174 # Check whether first character of PACKAGE_NAME is legal for tag name
1175 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1179 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1180 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1182 # Remove #kernel.version_release from TAGVER because tagging sources
1183 # could occur with different kernel-headers than kernel-headers used at build time.
1184 # besides, %{_kernel_ver_str} is not expanded.
1186 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1187 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1193 # bool is_tag_a_branch(tag)
1195 # returns 1 if a tag is a branch set on SPECFILE
1197 if [ -n "$DEBUG" ]; then
1202 if [ $# -ne 1 ]; then
1209 $CVS_COMMAND status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1216 if [ -n "$DEBUG" ]; then
1221 echo "Version: $PACKAGE_VERSION"
1222 echo "Release: $PACKAGE_RELEASE"
1225 if [ "$TAG_VERSION" = "yes" ]; then
1226 TAGVER=`make_tagver`
1227 echo "CVS tag: $TAGVER"
1229 if [ -n "$TAG" ]; then
1230 echo "CVS tag: $TAG"
1233 local OPTIONS="tag $CVS_FORCE"
1234 if [ -n "$CVSROOT" ]; then
1235 OPTIONS="-d $CVSROOT $OPTIONS"
1238 # if a tagname we are about to set already exists
1239 # and happens to be a branch (common case with AC-branch)
1240 # pass -B (allows -F to disturb branch tag)
1242 if [ "$TAG_VERSION" = "yes" ]; then
1245 is_tag_a_branch $_tag
1246 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1247 OPTIONS="$OPTIONS -B"
1252 for i in $TAG_FILES; do
1253 # don't tag files stored on distfiles
1254 [ -n "`src_md5 $i`" ] && continue
1255 local fp=`nourl "$i"`
1256 if [ -f "$fp" ]; then
1257 tag_files="$tag_files $fp"
1258 elif [ -n "GREEDSRC" ]; then
1259 get_greed_sources $i
1261 Exit_error err_no_source_in_repo $i
1265 if [ "$tag_files" ]; then
1266 if [ "$TAG_VERSION" = "yes" ]; then
1267 update_shell_title "tag sources: $TAGVER"
1268 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1269 $CVS_COMMAND $OPTIONS $TAGVER $tag_files || exit
1271 if [ -n "$TAG" ]; then
1272 update_shell_title "tag sources: $TAG"
1274 while [ "$tag_files" ]; do
1275 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1276 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1277 $CVS_COMMAND $OPTIONS $TAG $chunk || exit
1278 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1284 if [ "$TAG_VERSION" = "yes" ]; then
1285 update_shell_title "tag spec: $TAGVER"
1286 $CVS_COMMAND $OPTIONS $TAGVER $SPECFILE || exit
1288 if [ -n "$TAG" ]; then
1289 update_shell_title "tag spec: $TAG"
1290 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1296 echo "CVS branch tag: $TAG"
1301 if [ -n "$DEBUG" ]; then
1306 local OPTIONS="tag $CVS_FORCE -b"
1309 is_tag_a_branch $TAG
1310 if [ $? -eq 1 ]; then
1311 OPTIONS="$OPTIONS -B"
1314 if [ -n "$CVSROOT" ]; then
1315 OPTIONS="-d $CVSROOT $OPTIONS"
1319 for i in $TAG_FILES; do
1320 local fp=`nourl "$i"`
1321 if [ -f "$fp" ]; then
1322 tag_files="$tag_files $fp"
1323 elif [ -n "GREEDSRC" ]; then
1324 get_greed_sources $i
1326 Exit_error err_no_source_in_repo $i
1329 if [ "$tag_files" ]; then
1330 $CVS_COMMAND $OPTIONS $TAG $tag_files || exit
1334 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1338 # this function should exit early if package can't be built for this arch
1339 # this avoids unneccessary BR filling.
1342 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1344 if [ $ret -ne 0 ]; then
1351 update_shell_title "build_package"
1352 if [ -n "$DEBUG" ]; then
1359 if [ -n "$TRY_UPGRADE" ]; then
1360 update_shell_title "build_package: try_upgrade"
1361 if [ -n "$FLOAT_VERSION" ]; then
1362 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1364 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1367 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1369 if [ -n "$TNEWVER" ]; then
1370 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1371 echo "New version found, updating spec file to version " $TNEWVER
1372 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1373 cp -f $SPECFILE $SPECFILE.bak
1376 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1377 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1379 NODIST="yes" get_files $SOURCES $PATCHES
1382 unset TOLDVER TNEWVER TNOTIFY
1389 BUILD_SWITCH="-ba" ;;
1391 BUILD_SWITCH="-bb" ;;
1393 BUILD_SWITCH="-bs --nodeps" ;;
1395 BUILD_SWITCH="-bp --nodeps" ;;
1397 BUILD_SWITCH="-bc" ;;
1399 BUILD_SWITCH="-bi" ;;
1401 BUILD_SWITCH="-bl" ;;
1405 update_shell_title "build_package: $COMMAND"
1406 if [ -n "$LOGFILE" ]; then
1407 LOG=`eval echo $LOGFILE`
1408 if [ -d "$LOG" ]; then
1409 echo "Log file $LOG is a directory."
1410 echo "Parse error in the spec?"
1411 Exit_error err_build_fail
1413 if [ -n "$LASTLOG_FILE" ]; then
1414 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1416 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1418 (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
1419 RETVAL=`cat $RES_FILE`
1421 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1422 if [ "$RETVAL" -eq "0" ]; then
1429 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1432 if [ "$RETVAL" -ne "0" ]; then
1433 if [ -n "$TRY_UPGRADE" ]; then
1434 echo "\n!!! Package with new version cannot be built automagically\n"
1435 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1436 mv -f $SPECFILE.bak $SPECFILE
1439 Exit_error err_build_fail
1445 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1448 install_required_packages() {
1453 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1456 /^%changelog/ { exit }
1458 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1459 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1460 gsub(/[ \t]+/, "_", bcond);
1462 }' $SPEC | LC_ALL=C sort -u
1466 # expand bconds from ~/.bcondrc
1467 # The file structure is like gentoo's package.use:
1470 # samba -mysql -pgsql
1471 # w32codec-installer license_agreement
1474 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1480 SN=${SPECFILE%%\.spec}
1482 local bcondrc=$HOME/.bcondrc
1483 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1485 local bcond_avail=$(find_spec_bcond $SPECFILE)
1487 while read pkg flags; do
1489 [[ "$pkg" == \#* ]] && continue
1491 # any package or current package?
1492 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1493 for flag in $flags; do
1494 local opt=${flag#[+-]}
1496 # use only flags which are in this package.
1497 if [[ $bcond_avail = *${opt}* ]]; then
1498 if [[ $flag = -* ]]; then
1499 if [[ $BCOND != *--with?${opt}* ]]; then
1500 BCOND="$BCOND --without $opt"
1503 if [[ $BCOND != *--without?${opt}* ]]; then
1504 BCOND="$BCOND --with $opt"
1511 update_shell_title "parse ~/.bcondrc: DONE!"
1514 set_bconds_values() {
1515 update_shell_title "set bcond values"
1517 AVAIL_BCONDS_WITHOUT=""
1518 AVAIL_BCONDS_WITH=""
1520 if egrep -q '^# *_with' ${SPECFILE}; then
1521 echo >&2 "ERROR: This spec has old style bconds."
1525 if ! grep -q '^%bcond' ${SPECFILE}; then
1529 local bcond_avail=$(find_spec_bcond $SPECFILE)
1530 process_bcondrc "$SPECFILE"
1532 update_shell_title "parse bconds"
1535 for opt in $bcond_avail; do
1538 bcond=${opt#without_}
1539 if [[ "$BCOND" = *--without?${bcond}* ]]; then
1540 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1542 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1547 if [[ "$BCOND" = *--with?${bcond}* ]]; then
1548 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1550 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1554 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1563 update_shell_title "run_sub_builder $package_name"
1565 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1566 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1567 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1568 # jakby nie bylo tego kawalka kodu.
1570 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1571 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1575 # kurwa. translate that ^^^^
1579 # Istnieje taki spec? ${package}.spec
1580 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1581 parent_spec_name=${package}.spec
1582 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1583 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1585 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1590 if [ "${parent_spec_name}" != "" ]; then
1591 spawn_sub_builder $parent_spec_name
1593 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1596 spawn_sub_builder() {
1598 update_shell_title "spawn_sub_builder $package_name"
1601 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1602 sub_builder_opts="${sub_builder_opts} -R"
1604 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1605 sub_builder_opts="${sub_builder_opts} -RB"
1606 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1607 sub_builder_opts="${sub_builder_opts} -FRB"
1609 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1610 sub_builder_opts="${sub_builder_opts} -Upi"
1614 ./builder ${sub_builder_opts} "$@"
1617 remove_build_requires() {
1618 if [ "$INSTALLED_PACKAGES" != "" ]; then
1619 case "$REMOVE_BUILD_REQUIRES" in
1621 run_poldek --noask -ve $INSTALLED_PACKAGES
1624 run_poldek --ask -ve $INSTALLED_PACKAGES
1627 echo You may want to manually remove following BuildRequires fetched:
1628 echo $INSTALLED_PACKAGES
1629 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1636 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1637 if [ "$BCOND" ]; then
1638 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1641 echo -ne "\nNo conditional flags passed"
1643 echo -ne "\n\nfrom available:\n"
1644 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1648 display_branches() {
1649 if [ "$NOCVSSPEC" != "yes" ]; then
1650 echo -ne "Available branches: "
1651 $CVS_COMMAND status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1655 # checks a given list of packages/files/provides agains current rpmdb.
1656 # outputs all dependencies which current rpmdb doesn't satisfy.
1657 # input can be either STDIN or parameters
1661 if [ $# -gt 0 ]; then
1667 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1670 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1672 # other deps (files)
1673 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1676 # checks if given package/files/provides exists in rpmdb.
1677 # input can be either stdin or parameters
1678 # returns packages which are present in the rpmdb
1682 if [ $# -gt 0 ]; then
1688 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1691 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1692 install_build_requires_rpmdeps() {
1693 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1694 # TODO: Conflicts list doesn't check versions
1695 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1696 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1698 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1699 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1700 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1703 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1704 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1705 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1706 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1708 if [ -n "$CNFL" ]; then
1709 update_shell_title "uninstall conflicting packages: $CNFL"
1710 echo "Trying to uninstall conflicting packages ($CNFL):"
1711 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1714 while [ "$DEPS" ]; do
1715 update_shell_title "install deps: $DEPS"
1716 echo "Trying to install dependencies ($DEPS):"
1717 local log=.${SPECFILE}_poldek.log
1718 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1719 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1722 if [ -n "$failed" ]; then
1723 for package in $failed; do
1724 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1733 fetch_build_requires()
1735 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1739 update_shell_title "fetch build requires"
1740 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1741 install_build_requires_rpmdeps
1745 # XXX is this ugliest code written in human history still needed?
1746 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1747 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1748 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1749 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1750 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1751 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)
1753 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)
1755 package=$(basename "$package_item"|sed -e "s/}$//g")
1756 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1759 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1760 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1761 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
1766 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1769 if `echo $COND_TST|grep -q 'without_'`; then
1770 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1771 if `echo $COND_TST|grep -q !`; then
1776 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1777 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1778 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1784 elif `echo $COND_TST|grep -q 'with_'`; then
1785 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1786 if `echo $COND_TST|grep -q !`; then
1791 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1792 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1793 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1799 RESULT="${COND_STATE}-${COND_ARGV}"
1801 "with-wout" | "wout-with" )
1804 "wout-wout" | "with-with" )
1808 echo "Action '$RESULT' was not defined for package '$package_item'"
1814 if [ "$GO" = "yes" ]; then
1815 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1816 echo "Testing if $package has subrequirements..."
1817 run_poldek -t -i $package --dumpn=".$package-req.txt"
1818 if [ -f ".$package-req.txt" ]; then
1819 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1821 if [ "$package_name" = "$package" ]; then
1822 echo -ne "Installing BuildRequired package:\t$package_name\n"
1823 update_shell_title "Installing BuildRequired package: ${package_name}"
1824 install_required_packages $package
1826 echo -ne "Installing (sub)Required package:\t$package_name\n"
1827 update_shell_title "Installing (sub)Required package: ${package_name}"
1828 install_required_packages $package_name
1832 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1833 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1836 echo "Attempting to run spawn sub - builder..."
1837 echo -ne "Package installation failed:\t$package_name\n"
1838 run_sub_builder $package_name
1839 if [ $? -eq 0 ]; then
1840 install_required_packages $package_name
1843 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1844 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1847 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1854 rm -f ".$package-req.txt"
1856 echo "Attempting to run spawn sub - builder..."
1857 echo -ne "Package installation failed:\t$package\n"
1858 run_sub_builder $package
1859 if [ $? -eq 0 ]; then
1860 install_required_packages $package
1863 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1864 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1867 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1873 echo "Package $package is already installed. BuildRequirement satisfied."
1877 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1878 echo >&2 "Unable to install following packages and their dependencies:"
1879 for pkg in "$NOT_INSTALLED_PACKAGES"
1883 remove_build_requires
1889 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1890 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1892 echo "Initialising rpm directories to $TOP_DIR from $CVSROOT"
1893 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1895 $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1899 echo "To checkout *all* .spec files (read-only):"
1900 echo "- run cvs co SPECS"
1902 echo "To checkout *all* packages:"
1903 echo "- run cvs up -dP in $TOP_DIR/packages dir"
1906 echo "To commit with your developer account:"
1907 echo "- edit $TOP_DIR/packages/CVS/Root"
1910 get_greed_sources() {
1911 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1912 if [ -n "BE_VERBOSE" ]; then
1913 echo "Try greed download: $1 from: $CVSROOT"
1915 $CVS_COMMAND -d $CVSROOT get SOURCES/$1
1916 if [ $? != 0 ]; then
1917 Exit_error err_no_source_in_repo $1
1922 # remove entries from CVS/Entries
1923 cvs_entry_remove() {
1924 local cvsdir="$1"; shift
1925 if [ ! -d "$cvsdir" ]; then
1926 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1930 for file in "$@"; do
1931 rm -f $cvsdir/CVS/Entries.new || return 1
1932 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1933 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1941 DONT_PRINT_REVISION="yes"
1945 # remove from CVS/Entries
1946 cvs_entry_remove $PACKAGE_DIR $SPECFILE $SOURCES $PATCHES
1948 # remove spec and sources
1949 $RPMBUILD --clean --rmsource --rmspec --nodeps --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1952 #---------------------------------------------
1960 while [ $# -gt 0 ]; do
1963 COMMAND="update_md5"
1968 COMMAND="update_md5"
1978 DEBUG="yes"; shift ;;
1980 COMMAND="version"; shift ;;
1982 COMMAND="short-version"; shift ;;
1984 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1985 -b | -ba | --build )
1986 COMMAND="build"; shift ;;
1987 -bb | --build-binary )
1988 COMMAND="build-binary"; shift ;;
1990 COMMAND="build-build"; shift ;;
1992 COMMAND="build-install"; shift ;;
1994 COMMAND="build-list"; shift ;;
1995 -bp | --build-prep )
1996 COMMAND="build-prep"; shift ;;
1997 -bs | --build-source )
1998 COMMAND="build-source"; shift ;;
2000 COMMAND="branch"; shift; TAG="${1}"; shift;;
2002 CLEAN="--clean --rmspec --rmsource"; shift ;;
2004 CVS_FORCE="-F"; shift;;
2006 shift; CVSROOT="${1}"; shift ;;
2008 COMMAND="get"; shift ;;
2010 COMMAND="usage"; shift ;;
2012 PROTOCOL="http"; shift ;;
2014 shift; LOGFILE="${1}"; shift ;;
2016 shift; DEF_NICE_LEVEL=${1}; shift ;;
2017 -ske | --skip-existing-files)
2018 SKIP_EXISTING_FILES="yes"; shift ;;
2020 COMMAND="mr-proper"; shift ;;
2022 NOCVS="yes"; shift ;;
2023 -ncs | --no-cvs-specs )
2024 NOCVSSPEC="yes"; shift ;;
2025 -nd | --no-distfiles )
2026 NODIST="yes"; shift ;;
2027 -nm | --no-mirrors )
2028 NOMIRRORS="yes"; shift ;;
2030 NOURLS="yes"; shift ;;
2032 NOSRCS="yes"; shift ;;
2033 -ns0 | --no-source0 )
2034 NOSOURCE0="yes"; shift ;;
2044 -pm | --prefer-mirrors )
2051 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2053 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2055 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2058 --with | --without )
2059 case $GROUP_BCONDS in
2063 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2064 while ! `echo ${1}|grep -qE '(^-|spec)'`
2066 BCOND="$BCOND $COND $1"
2070 if [[ "$2" = *,* ]]; then
2071 for a in $(echo "$2" | tr , ' '); do
2072 BCOND="$BCOND $1 $a"
2075 BCOND="$BCOND $1 $2"
2081 shift; TARGET="${1}"; shift ;;
2083 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2085 QUIET="--quiet"; shift ;;
2087 CVSDATE="${2}"; shift 2 ;;
2096 -R | --fetch-build-requires)
2097 FETCH_BUILD_REQUIRES="yes"
2098 NOT_INSTALLED_PACKAGES=
2100 -RB | --remove-build-requires)
2101 REMOVE_BUILD_REQUIRES="nice"
2103 -FRB | --force-remove-build-requires)
2104 REMOVE_BUILD_REQUIRES="force"
2106 -sc | --sources-cvs)
2107 COMMAND="list-sources-cvs"
2109 -sd | --sources-distfiles)
2110 COMMAND="list-sources-distfiles"
2112 -sdp | --sources-distfiles-paths)
2113 COMMAND="list-sources-distfiles-paths"
2115 -sf | --sources-files)
2116 COMMAND="list-sources-files"
2118 -sp | --sources-paths)
2119 COMMAND="list-sources-local-paths"
2121 -su | --sources-urls)
2122 COMMAND="list-sources-urls"
2124 -Tvs | --tag-version-stable )
2129 -Ts | --tag-stable )
2134 -Tv | --tag-version )
2139 -Tp | --tag-prefix )
2151 -ir | --integer-release-only )
2152 INTEGER_RELEASE="yes"
2155 COMMAND="update_md5"
2160 -Upi | --update-poldek-indexes )
2161 UPDATE_POLDEK_INDEXES="yes"
2164 COMMAND="init_rpm_dir"
2166 --use-greed-sources )
2169 -u | --try-upgrade )
2170 TRY_UPGRADE="1"; shift ;;
2171 -un | --try-upgrade-with-float-version )
2172 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2174 BE_VERBOSE="1"; shift ;;
2179 if echo "${MACRO}" | grep -q '\W'; then
2180 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2184 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2189 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2193 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2196 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2197 COMMAND="show_bconds"
2201 COMMAND="show_bcond_args"
2206 RPMOPTS="${RPMOPTS} --nodeps"
2209 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2212 Exit_error err_invalid_cmdline "$1"
2216 # check if specname was passed as specname:cvstag
2217 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2218 CVSTAG="${SPECFILE##*:}"
2219 SPECFILE="${SPECFILE%%:*}"
2221 # always have SPECFILE ending with .spec extension
2222 SPECFILE=${SPECFILE%%.spec}.spec
2223 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2227 [ -d "$ASSUMED_NAME" ] && CVS_ENTRIES="$ASSUMED_NAME/CVS/Entries" || CVS_ENTRIES="CVS/Entries"
2228 if [ -f "$CVS_ENTRIES" ] && [ -z "$CVSTAG" ]; then
2229 CVSTAG=$(awk -vSPECFILE=$(basename ${SPECFILE%.spec}.spec) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' ${CVS_ENTRIES})
2230 if [ "$CVSTAG" ]; then
2231 echo >&2 "builder: Sticky tag $CVSTAG active. Use -r TAGNAME to override."
2233 elif [ "$CVSTAG" = "HEAD" ]; then
2234 # assume -r HEAD is same as -A
2238 if [ "$CVSTAG" ]; then
2239 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2240 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2243 if [ -n "$DEBUG" ]; then
2248 if [ -n "$TARGET" ]; then
2251 TARGET_SWITCH="--target $TARGET" ;;
2253 TARGET_SWITCH="--target=$TARGET" ;;
2257 if [ "$SCHEDTOOL" != "no" ]; then
2258 NICE_COMMAND="$SCHEDTOOL"
2260 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2263 update_shell_title "$COMMAND"
2267 if [ -n "$SPECFILE" ]; then
2268 get_spec > /dev/null
2276 if [ -n "$SPECFILE" ]; then
2277 get_spec > /dev/null
2283 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2285 if [ -n "$SPECFILE" ]; then
2286 # display SMP make flags if set
2287 smp_mflags=$(rpm -E %{?_smp_mflags})
2288 if [ "$smp_mflags" ]; then
2289 echo >&2 "builder: SMP make flags are set to $smp_mflags"
2297 if [ "$COMMAND" != "build-source" ]; then
2300 fetch_build_requires
2301 if [ "$INTEGER_RELEASE" = "yes" ]; then
2302 echo "Checking release $PACKAGE_RELEASE..."
2303 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2304 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2308 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2309 if [ -n "$TEST_TAG" ]; then
2310 local TAGVER=`make_tagver`
2311 echo "Searching for tag $TAGVER..."
2312 TAGREL=$($CVS_COMMAND status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2313 if [ -n "$TAGREL" ]; then
2314 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2317 # - do not allow to build from HEAD when XX-branch exists
2318 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2319 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2320 TAG_BRANCH="${TREE_PREFIX}-branch"
2321 TAG_STATUS=$($CVS_COMMAND status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2322 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2323 Exit_error err_branch_exists "$TAG_STATUS"
2329 if [ -n "$NOSOURCE0" ] ; then
2330 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2332 get_files $SOURCES $PATCHES
2335 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2336 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2338 remove_build_requires
2340 Exit_error err_no_spec_in_cmdl
2345 if [ -n "$SPECFILE" ]; then
2348 # don't fetch sources from remote locations
2350 for file in $SOURCES; do
2351 [ -n "`src_md5 $file`" ] && continue
2352 new_SOURCES="$new_SOURCES $file"
2354 SOURCES="$new_SOURCES"
2355 get_files $SOURCES $PATCHES
2357 branch_files $TAG $SOURCES $PATCHES $ICONS
2359 Exit_error err_no_spec_in_cmdl
2364 if [ -n "$SPECFILE" ]; then
2368 if [ -n "$NOSOURCE0" ] ; then
2369 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2371 get_files $SOURCES $PATCHES
2374 Exit_error err_no_spec_in_cmdl
2379 if [ -n "$SPECFILE" ]; then
2383 if [ -n "$NOSOURCE0" ] ; then
2384 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2388 Exit_error err_no_spec_in_cmdl
2395 if [ -n "$SPECFILE" ]; then
2399 # don't fetch sources from remote locations
2401 for file in $SOURCES; do
2402 [ -n "`src_md5 $file`" ] && continue
2403 new_SOURCES="$new_SOURCES $file"
2405 SOURCES="$new_SOURCES"
2406 get_files $SOURCES $PATCHES
2408 tag_files $SOURCES $PATCHES $ICONS
2410 Exit_error err_no_spec_in_cmdl
2416 "list-sources-files" )
2419 DONT_PRINT_REVISION="yes"
2422 for SAP in $SOURCES $PATCHES; do
2423 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2426 "list-sources-urls" )
2429 DONT_PRINT_REVISION="yes"
2432 SAPS="$SOURCES $PATCHES"
2433 for SAP in $SAPS ; do
2437 "list-sources-local-paths" )
2440 DONT_PRINT_REVISION="yes"
2443 for SAP in $SOURCES $PATCHES; do
2444 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2447 "list-sources-distfiles-paths" )
2450 DONT_PRINT_REVISION="yes"
2453 for SAP in $SOURCES $PATCHES; do
2454 if [ -n "$(src_md5 "$SAP")" ]; then
2455 distfiles_path "$SAP"
2459 "list-sources-distfiles" )
2462 DONT_PRINT_REVISION="yes"
2465 for SAP in $SOURCES $PATCHES; do
2466 if [ -n "$(src_md5 "$SAP")" ]; then
2467 distfiles_url "$SAP"
2471 "list-sources-cvs" )
2474 DONT_PRINT_REVISION="yes"
2477 for SAP in $SOURCES $PATCHES; do
2478 if [ -z "$(src_md5 "$SAP")" ]; then
2479 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2493 echo "$VERSIONSTRING"
2496 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2497 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2501 # vi:syntax=sh:ts=4:sw=4:noet