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-2008 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 # Yes, you can use variable name! Note _single_ quotes!
94 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
96 CVS_COMMAND=${CVS_COMMAND:-cvs}
99 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
100 CVS_SERVER="cvs.pld-linux.org"
105 DISTFILES_SERVER="://distfiles.pld-linux.org"
106 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
111 FAIL_IF_NO_SOURCES="yes"
113 # let get_files skip over files which are present to get those damn files fetched
114 SKIP_EXISTING_FILES="no"
117 # should the specfile be restored if upgrade failed?
118 REVERT_BROKEN_UPGRADE="yes"
120 if rpm --specsrpm 2>/dev/null; then
121 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
122 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
124 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
125 if [ -x /usr/bin/rpm-getdeps ]; then
126 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
128 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
133 # Here we load saved user environment used to
134 # predefine options set above, or passed to builder
136 # This one reads global system environment settings:
137 if [ -f ~/etc/builderrc ]; then
140 # And this one cascades settings using user personal
142 # Example of ~/.builderrc:
144 #UPDATE_POLDEK_INDEXES="yes"
145 #FETCH_BUILD_REQUIRES="yes"
146 #REMOVE_BUILD_REQUIRES="force"
148 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
152 if [ -n "$HOME_ETC" ]; then
153 USER_CFG="$HOME_ETC/.builderrc"
154 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
156 USER_CFG=~/.builderrc
157 BUILDER_MACROS=~/.builder-rpmmacros
160 [ -f "$USER_CFG" ] && . "$USER_CFG"
162 if [ "$SCHEDTOOL" = "auto" ]; then
163 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
164 SCHEDTOOL="schedtool -B -e"
170 if [ -n "$USE_PROZILLA" ]; then
171 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
174 elif [ -n "$USE_AXEL" ]; then
175 GETURI="axel -a $AXEL_OPTS"
179 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
180 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
181 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
182 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
184 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
185 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
191 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
200 # are we using cvs-nserver ?
203 $CVS_COMMAND --version 2>&1 | grep -q 'CVS-nserver'
204 [ $? -eq 0 ] && CVS_NSERVER=1
206 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
207 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
211 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
212 if [ -n "$LOGFILE" ]; then
213 LOG=`eval echo $LOGFILE`
214 if [ -n "$LASTLOG_FILE" ]; then
215 echo "LASTLOG=$LOG" > $LASTLOG_FILE
217 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
220 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
221 return `cat ${RES_FILE}`
226 #---------------------------------------------
231 if [ -n "$DEBUG" ]; then set -xv; fi
233 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
234 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
235 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
236 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
237 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
238 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
239 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
240 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
241 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
242 <package>[.spec][:cvstag]
244 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
245 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
246 -n5, --no-md5 - ignore md5 comments in spec
247 -D, --debug - enable builder script debugging mode,
248 -debug - produce rpm debug package (same as --opts -debug)
249 -V, --version - output builder version string
250 --short-version - output builder short version
251 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
252 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
254 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
255 only package from <package>.spec,
256 -bp, --build-prep - execute the %prep phase of <package>.spec,
257 -bc - execute the %build phase of <package>.spec,
258 -bi - execute the %install phase of <package>.spec
259 -bl - execute the %files phase of <package>.spec
260 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
262 --short-circuit - short-circuit build
263 -B, --branch - add branch
264 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
265 SPECS and \$RPM_BUILD_ROOT and CVS/Entries) after rpmbuild commands.
266 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
267 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
269 -cf, --cvs-force - use -F when tagging (useful when moving branches)
270 -d <cvsroot>, --cvsroot <cvsroot>
272 --define <macro> <value>
273 - define a macro <macro> with value <value>,
274 --alt_kernel <kernel>
275 - same as --define 'alt_kernel <kernel>'
276 --nodeps - rpm won't check any dependences
277 -g, --get - get <package>.spec and all related files from CVS repo
279 -h, --help - this message,
280 --http - use http instead of ftp,
281 -l <logfile>, --logtofile <logfile>
283 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
285 - don't check specs in CVS
286 -nd, --no-distfiles - don't download from distfiles
287 -nm, --no-mirrors - don't download from mirror, if source URL is given,
288 -nu, --no-urls - don't try to download from FTP/HTTP location,
289 -ns, --no-srcs - don't download Sources
290 -ns0, --no-source0 - don't download Source0
291 -nn, --no-net - don't download anything from the net
292 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
293 --no-init - don't initialize builder paths (SPECS and SOURCES)
295 --skip-existing-files - skip existing files in get_files
296 --opts <rpm opts> - additional options for rpm
297 -q, --quiet - be quiet,
298 --date yyyy-mm-dd - build package using resources from specified CVS date,
299 -r <cvstag>, --cvstag <cvstag>
300 - build package using resources from specified CVS tag,
301 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
302 -R, --fetch-build-requires
303 - fetch what is BuildRequired,
304 -RB, --remove-build-requires
305 - remove all you fetched with -R or --fetch-build-requires
306 remember, this option requires confirmation,
307 -FRB, --force-remove-build-requires
308 - remove all you fetched with -R or --fetch-build-requires
309 remember, this option works without confirmation,
310 -sd, --source-distfiles - list sources available from distfiles (intended for offline
311 operations; does not work when Icon field is present
312 but icon file is absent),
313 -sc, --source-cvs - list sources available from CVS
314 -sdp, --source-distfiles-paths - list sources available from distfiles -
315 paths relative to distfiles directory (intended for offline
316 operations; does not work when Icon field is present
317 but icon file is absent),
318 -sf, --source-files - list sources - bare filenames (intended for offline
319 operations; does not work when Icon field is present
320 but icon file is absent),
321 -sp, --source-paths - list sources - filenames with full local paths (intended for
322 offline operations; does not work when Icon field is present
323 but icon file is absent),
324 -su, --source-urls - list urls - urls to sources and patches
325 intended for copying urls with spec with lots of macros in urls
326 -T <cvstag> , --tag <cvstag>
327 - add cvs tag <cvstag> for files,
328 -Tvs, --tag-version-stable
329 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
331 - add cvs tag STABLE for files,
333 - add cvs tag NAME-VERSION-RELEASE for files,
334 -Tp, --tag-prefix <prefix>
335 - add <prefix> to NAME-VERSION-RELEASE tags,
336 -tt, --test-tag <prefix>
337 - fail if tag is already present,
338 -ir, --integer-release-only
339 - allow only integer and snapshot releases
340 -v, --verbose - be verbose,
341 -u, --try-upgrade - check version, and try to upgrade package
342 -un, --try-upgrade-with-float-version
343 - as above, but allow float version
345 - try download source from tag head if don't find it in
347 -U, --update - refetch sources, don't use distfiles, and update md5 comments
348 -Upi, --update-poldek-indexes
349 - refresh or make poldek package index files.
350 -np, --nopatch <patchnumber>
351 - don't apply <patchnumber>
352 --show-bconds - show available conditional builds, which can be used
353 - with --with and/or --without switches.
354 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
355 ./repackage.sh script. in other words, the output is
356 parseable by scripts.
357 --with/--without <feature>
358 - conditional build package depending on %_with_<feature>/
359 %_without_<feature> macro switch. You may now use
360 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
361 constructions. Set GROUP_BCONDS to yes to make use of it.
362 --target <platform>, --target=<platform>
363 - build for platform <platform>.
364 --init-rpm-dir - initialize ~/rpm directory structure
368 # change dependency to specname
370 # - perl(Package::Name) -> perl-Package-Name
374 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g}')
378 update_shell_title() {
380 local len=${COLUMNS:-80}
381 local msg=$(echo "$*" | cut -c-$len)
383 if [ -n "$BE_VERBOSE" ]; then
384 echo >&2 "$(date +%s.%N) $*"
387 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
389 if [ -n "$PACKAGE_NAME" ]; then
390 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
395 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
396 msg=$(echo $msg | tr -d '\n\r')
399 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
402 echo >&2 -ne "\033]0;$msg\007"
408 # set TARGET from BuildArch: from SPECFILE
410 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
411 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
413 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
417 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
419 TARGET_SWITCH="--target=$TARGET" ;;
425 # runs rpm with minimal macroset
427 # we reset macros not to contain macros.build as all the %() macros are
428 # executed here, while none of them are actually needed.
429 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
430 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
432 # TODO: move these to /usr/lib/rpm/macros
433 cat > $BUILDER_MACROS <<'EOF'
434 %x8664 x86_64 amd64 ia32e
437 %requires_releq_kernel_up %{nil}
438 %requires_releq_kernel_smp %{nil}
439 %requires_releq_kernel %{nil}
440 %requires_releq() %{nil}
441 %pyrequires_eq() %{nil}
442 %requires_eq() %{nil}
443 %requires_eq_to() %{nil}
444 %releq_kernel_up ERROR
445 %releq_kernel_smp ERROR
450 %ruby_ver_requires_eq() %{nil}
451 %ruby_mod_ver_requires_eq() %{nil}
452 %__php_api_requires() %{nil}
453 %php_major_version ERROR
454 %php_api_version ERROR
455 %requires_xorg_xserver_extension %{nil}
456 %requires_xorg_xserver_xinput %{nil}
457 %requires_xorg_xserver_font %{nil}
458 %requires_xorg_xserver_videodrv %{nil}
460 %perl_vendorarch ERROR
461 %perl_vendorlib ERROR
462 # damn. need it here! - copied from /usr/lib/rpm/macros.build
463 %tmpdir %(echo "${TMPDIR:-/tmp}")
464 %patchset_source(f:b:) %(
465 base=%{-b*}%{!-b*:10000};
466 start=$(expr $base + %1);
467 end=$(expr $base + %{?2}%{!?2:%{1}});
468 # we need to call seq twice as it doesn't allow two formats
469 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
470 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
471 paste %{tmpdir}/__ps{1,2};
472 rm -f %{tmpdir}/__ps{1,2};
475 %add_etc_shells(p) %{p:<lua>}
476 %remove_etc_shells(p) %{p:<lua>}
477 %lua_add_etc_shells() %{nil}
478 %lua_remove_etc_shells() %{nil}
480 if [ "$NOINIT" = "yes" ] ; then
481 cat >> $BUILDER_MACROS <<'EOF'
486 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
490 if [ -n "$DEBUG" ]; then
495 if [ -x /usr/bin/rpm-specdump ]; then
496 update_shell_title "cache_rpm_dump using rpm-specdump command"
497 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
499 update_shell_title "cache_rpm_dump using rpmbuild command"
502 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
503 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
509 ARGS='--nodigest --nosignature --nobuild'
512 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
514 if [ $? -gt 0 ]; then
515 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
517 Exit_error err_build_fail
520 # make small dump cache
521 rpm_dump_cache=`echo "$rpm_dump" | awk '
522 $2 ~ /^SOURCEURL/ {print}
523 $2 ~ /^PATCHURL/ {print}
524 $2 ~ /^nosource/ {print}
525 $2 ~ /^PACKAGE_/ {print}
529 update_shell_title "cache_rpm_dump: OK!"
533 if [ -z "$rpm_dump_cache" ] ; then
534 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
536 echo "$rpm_dump_cache"
541 update_shell_title "get icons"
542 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
543 if [ -z "$ICONS" ]; then
547 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
552 update_shell_title "parsing specfile"
553 if [ -n "$DEBUG" ]; then
558 # icons are needed for successful spec parse
564 if [ "$NOSRCS" != "yes" ]; then
565 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
568 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
569 FAIL_IF_NO_SOURCES="no"
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})
574 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
575 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
576 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
578 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
579 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
582 if [ -n "$BE_VERBOSE" ]; then
583 echo "- Sources : `nourl $SOURCES`"
584 if [ -n "$PATCHES" ]; then
585 echo "- Patches : `nourl $PATCHES`"
587 echo "- Patches : *no patches needed*"
589 if [ -n "$ICONS" ]; then
590 echo "- Icon : `nourl $ICONS`"
592 echo "- Icon : *no package icon*"
594 echo "- Name : $PACKAGE_NAME"
595 echo "- Version : $PACKAGE_VERSION"
596 echo "- Release : $PACKAGE_RELEASE"
599 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."
658 if [ -n "$DEBUG" ]; then
663 if [ "$NOINIT" != "yes" ] ; then
665 if [ "$ASSUMED_NAME" ]; then
666 extra="--define 'name $ASSUMED_NAME'"
668 SOURCE_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_sourcedir}')
669 SPEC_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_specdir}')
681 update_shell_title "get_spec"
683 if [ -n "$DEBUG" ]; then
689 if [ ! -f "$SPECFILE" ]; then
690 SPECFILE="$(basename $SPECFILE .spec).spec"
692 if [ "$NOCVSSPEC" != "yes" ]; then
694 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
695 echo "Warning: No CVS access defined - using local .spec file"
699 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
702 if [ ! -f "$SPECFILE" ]; then
703 Exit_error err_no_spec_in_repo
706 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
707 chmod $CHMOD_MODE $SPECFILE
710 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
719 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
720 $CVS_COMMAND update mirrors >&2
724 local origin mirror name rest ol prefix
725 while read origin mirror name rest; do
726 # skip comments and empty lines
727 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
730 ol=$(echo -n "$origin" | wc -c)
731 prefix=$(echo -n "$url" | head -c $ol)
732 if [ "$prefix" = "$origin" ] ; then
733 suffix=$(echo "$url" | cut -b $((ol+1))-)
734 echo -n "$mirror$suffix"
741 # Warning: unpredictable results if same URL used twice
746 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
747 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
753 [ "$NO5" = "yes" ] && return
755 [ -z "$no" ] && return
759 if [ -f additional-md5sums ]; then
760 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
761 if [ -z "$spec_rev" ]; then
762 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
764 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
765 md5=$(grep -s -v '^#' additional-md5sums | \
766 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
767 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
768 grep -E '^[0-9a-f]{32}$')
771 if [ $(echo "$md5" | wc -l) != 1 ] ; then
772 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
774 echo "$md5" | tail -n 1
779 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
780 if [ -n "$source_md5" ]; then
783 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
784 if [ -n "$source_md5" ]; then
787 # we have empty SourceX-md5, but it is still possible
788 # that we have NoSourceX-md5 AND NoSource: X
789 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
790 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
799 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
804 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
807 distfiles_attic_url ()
809 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
816 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
821 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
822 [ -n "$size" -a "$size" -gt 0 ]
827 if [ "$CVSIGNORE_DF" != "yes" ]; then
830 cvsignore=${SOURCE_DIR}/.cvsignore
831 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
832 echo "$1" >> $cvsignore
838 update_shell_title "cvsup"
840 if [ -n "$CVSROOT" ]; then
841 OPTIONS="-d $CVSROOT $OPTIONS"
844 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
845 OPTIONS="$OPTIONS -A"
847 if [ -n "$CVSDATE" ]; then
848 OPTIONS="$OPTIONS -D $CVSDATE"
850 if [ -n "$CVSTAG" ]; then
851 OPTIONS="$OPTIONS -r $CVSTAG"
856 local retries_counter=0
858 update_shell_title "cvsup: $*"
860 update_shell_title "cvsup: $# files"
862 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
863 retries_counter=$(( $retries_counter + 1 ))
864 output=$(LC_ALL=C $CVS_COMMAND $OPTIONS "$@" 2>&1)
866 [ -n "$output" ] && echo "$output"
867 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
868 echo "Trying again [$*]... ($retries_counter)"
869 update_shell_title "cvsup: retry #$retries_counter"
876 update_shell_title "cvsup: done!"
880 # returns true if "$1" is ftp, http or https protocol url
884 ftp://*|http://*|https://*)
893 if [ $# -eq 0 ]; then
897 update_shell_title "update md5"
898 if [ -n "$DEBUG" ]; then
905 # pass 1: check files to be fetched
909 local fp=$(nourl "$i")
910 local srcno=$(src_no "$i")
911 if [ -n "$ADD5" ]; then
912 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
913 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE && continue
914 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE && continue
916 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE || continue
918 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
919 need_files="$need_files $i"
923 # pass 1a: get needed files
924 if [ "$need_files" ]; then
925 get_files $need_files
928 # pass 2: proceed with md5 adding or updating
930 local fp=$(nourl "$i")
931 local srcno=$(src_no "$i")
932 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE )
933 if [ -z "$md5" ]; then
934 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE )
936 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
937 local tag="# Source$srcno-md5:\t"
938 if [[ "$md5" == *NoSource* ]]; then
939 tag="# NoSource$srcno-md5:\t"
940 elif [ -n "$USEDIGEST" ]; then
941 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
943 md5=$(md5sum "$fp" | cut -f1 -d' ')
944 echo "Updating Source$srcno ($md5: $fp)."
946 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
947 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
956 [ "$NO5" = "yes" ] && return
958 update_shell_title "check md5"
961 if good_md5 "$i" && good_size "$i"; then
965 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
966 echo "or -5 to update md5 sums, if you're sure files are correct."
967 Exit_error err_no_source_in_repo $i
973 update_shell_title "get_files"
975 if [ -n "$DEBUG" ]; then
980 if [ $# -gt 0 ]; then
983 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
984 echo "Warning: No CVS access defined for SOURCES"
989 local get_files_cvs=""
993 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
994 update_shell_title "$i"
995 local fp=`nourl "$i"`
996 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
1001 local srcmd5=$(src_md5 "$i")
1003 # we know if source/patch is present in cvs/distfiles
1004 # - has md5 (in distfiles)
1005 # - in cvs... ideas?
1007 # CHECK: local file didn't exist or always cvs up (first) requested.
1008 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1009 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1010 echo "Warning: no URL given for $i"
1013 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1014 if good_md5 "$i" && good_size "$i"; then
1015 echo "$fp having proper md5sum already exists"
1020 # optionally prefer mirror over distfiles if there's mirror
1021 # TODO: build url list and then try each url from the list
1022 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1025 url=$(distfiles_url "$i")
1028 url_attic=$(distfiles_attic_url "$i")
1030 # is $url local file?
1031 if [[ "$url" = [./]* ]]; then
1032 update_shell_title "${GETLOCAL%% *}: $url"
1033 ${GETLOCAL} $url $target
1035 if [ -z "$NOMIRRORS" ]; then
1036 url=$(find_mirror "$url")
1040 # make shorter message for distfiles urls
1041 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1042 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1043 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1046 update_shell_title "${GETURI%% *}: $uri"
1047 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1048 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1049 update_shell_title "${GETURI2%% *}: $url"
1050 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1055 if [ ! -s "$target" ]; then
1057 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1058 update_shell_title "${GETLOCAL%% *}: $url_attic"
1059 ${GETLOCAL} $url_attic $target
1061 if [ -z "$NOMIRRORS" ]; then
1062 url_attic=$(find_mirror "$url_attic")
1064 update_shell_title "${GETURI%% *}: $url_attic"
1065 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1066 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1067 update_shell_title "${GETURI2%% *}: $url_attic"
1068 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1073 if [ -s "$target" ]; then
1074 cvsignore_df $target
1079 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1080 if [ $# -gt 1 ]; then
1081 get_files_cvs="$get_files_cvs $fp"
1082 update_shell_title "$fp (will cvs up later)"
1089 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1090 if [ -z "$NOMIRRORS" ]; then
1091 im=$(find_mirror "$i")
1095 update_shell_title "${GETURI%% *}: $im"
1096 ${GETURI} "$im" || \
1097 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1098 update_shell_title "${GETURI2%% *}: $im"
1103 if [ "$cvsup" = 1 ]; then
1109 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1110 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1111 if [ -n "GREEDSRC" ]; then
1112 get_greed_sources $i
1114 Exit_error err_no_source_in_repo $i
1118 # we check md5 here just only to refetch immediately
1119 if good_md5 "$i" && good_size "$i"; then
1121 elif [ "$FROM_DISTFILES" = 1 ]; then
1122 # wrong md5 from distfiles: remove the file and try again
1124 echo "MD5 sum mismatch. Trying full fetch."
1127 update_shell_title "${GETURI%% *}: $url"
1128 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1129 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1130 update_shell_title "${GETURI2%% *}: $url"
1131 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1133 if [ ! -s "$target" ]; then
1135 update_shell_title "${GETURI%% *}: $url_attic"
1136 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1137 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1138 update_shell_title "${GETURI2%% *}: $url_attic"
1139 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1142 test -s "$target" || rm -f "$target"
1145 SHELL_TITLE_PREFIX=""
1147 if [ "$get_files_cvs" ]; then
1148 cvsup $get_files_cvs
1151 if [ "$CHMOD" = "yes" ]; then
1152 CHMOD_FILES=$(nourl "$@")
1153 if [ -n "$CHMOD_FILES" ]; then
1154 chmod $CHMOD_MODE $CHMOD_FILES
1161 if [ -n "$DEBUG" ]; then
1166 # Check whether first character of PACKAGE_NAME is legal for tag name
1167 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1171 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1172 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1174 # Remove #kernel.version_release from TAGVER because tagging sources
1175 # could occur with different kernel-headers than kernel-headers used at build time.
1176 # besides, %{_kernel_ver_str} is not expanded.
1178 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1179 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1185 # bool is_tag_a_branch(tag)
1187 # returns 1 if a tag is a branch set on SPECFILE
1189 if [ -n "$DEBUG" ]; then
1194 if [ $# -ne 1 ]; then
1201 $CVS_COMMAND status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1209 if [ -n "$DEBUG" ]; then
1214 echo "Version: $PACKAGE_VERSION"
1215 echo "Release: $PACKAGE_RELEASE"
1218 if [ "$TAG_VERSION" = "yes" ]; then
1219 TAGVER=`make_tagver`
1220 echo "CVS tag: $TAGVER"
1222 if [ -n "$TAG" ]; then
1223 echo "CVS tag: $TAG"
1226 local OPTIONS="tag $CVS_FORCE"
1227 if [ -n "$CVSROOT" ]; then
1228 OPTIONS="-d $CVSROOT $OPTIONS"
1231 # if a tagname we are about to set already exists
1232 # and happens to be a branch (common case with AC-branch)
1233 # pass -B (allows -F to disturb branch tag)
1235 if [ "$TAG_VERSION" = "yes" ]; then
1238 is_tag_a_branch $_tag
1239 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1240 OPTIONS="$OPTIONS -B"
1245 for i in $TAG_FILES; do
1246 # don't tag files stored on distfiles
1247 [ -n "`src_md5 $i`" ] && continue
1248 local fp=`nourl "$i"`
1249 if [ -f "$fp" ]; then
1250 tag_files="$tag_files $fp"
1251 elif [ -n "GREEDSRC" ]; then
1252 get_greed_sources $i
1254 Exit_error err_no_source_in_repo $i
1258 if [ "$tag_files" ]; then
1259 if [ "$TAG_VERSION" = "yes" ]; then
1260 update_shell_title "tag sources: $TAGVER"
1261 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1262 $CVS_COMMAND $OPTIONS $TAGVER $tag_files || exit
1264 if [ -n "$TAG" ]; then
1265 update_shell_title "tag sources: $TAG"
1267 while [ "$tag_files" ]; do
1268 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1269 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1270 $CVS_COMMAND $OPTIONS $TAG $chunk || exit
1271 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1277 if [ "$TAG_VERSION" = "yes" ]; then
1278 update_shell_title "tag spec: $TAGVER"
1279 $CVS_COMMAND $OPTIONS $TAGVER $SPECFILE || exit
1281 if [ -n "$TAG" ]; then
1282 update_shell_title "tag spec: $TAG"
1283 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1290 echo "CVS branch tag: $TAG"
1295 if [ -n "$DEBUG" ]; then
1300 local OPTIONS="tag $CVS_FORCE -b"
1303 is_tag_a_branch $TAG
1304 if [ $? -eq 1 ]; then
1305 OPTIONS="$OPTIONS -B"
1308 if [ -n "$CVSROOT" ]; then
1309 OPTIONS="-d $CVSROOT $OPTIONS"
1313 for i in $TAG_FILES; do
1314 local fp=`nourl "$i"`
1315 if [ -f "$fp" ]; then
1316 tag_files="$tag_files $fp"
1317 elif [ -n "GREEDSRC" ]; then
1318 get_greed_sources $i
1320 Exit_error err_no_source_in_repo $i
1323 if [ "$tag_files" ]; then
1324 $CVS_COMMAND $OPTIONS $TAG $tag_files || exit
1328 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1332 # this function should exit early if package can't be built for this arch
1333 # this avoids unneccessary BR filling.
1336 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1338 if [ $ret -ne 0 ]; then
1347 update_shell_title "build_package"
1348 if [ -n "$DEBUG" ]; then
1355 if [ -n "$TRY_UPGRADE" ]; then
1356 update_shell_title "build_package: try_upgrade"
1357 if [ -n "$FLOAT_VERSION" ]; then
1358 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1360 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1363 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1365 if [ -n "$TNEWVER" ]; then
1366 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1367 echo "New version found, updating spec file to version " $TNEWVER
1368 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1369 cp -f $SPECFILE $SPECFILE.bak
1372 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1373 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1375 NODIST="yes" get_files $SOURCES $PATCHES
1378 unset TOLDVER TNEWVER TNOTIFY
1385 BUILD_SWITCH="-ba" ;;
1387 BUILD_SWITCH="-bb" ;;
1389 BUILD_SWITCH="-bs --nodeps" ;;
1391 BUILD_SWITCH="-bp --nodeps" ;;
1393 BUILD_SWITCH="-bc" ;;
1395 BUILD_SWITCH="-bi" ;;
1397 BUILD_SWITCH="-bl" ;;
1401 update_shell_title "build_package: $COMMAND"
1402 if [ -n "$LOGFILE" ]; then
1403 LOG=`eval echo $LOGFILE`
1404 if [ -d "$LOG" ]; then
1405 echo "Log file $LOG is a directory."
1406 echo "Parse error in the spec?"
1407 Exit_error err_build_fail
1409 if [ -n "$LASTLOG_FILE" ]; then
1410 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1412 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1414 (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1415 RETVAL=`cat $RES_FILE`
1417 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1418 if [ "$RETVAL" -eq "0" ]; then
1425 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $SPECFILE
1428 if [ "$RETVAL" -ne "0" ]; then
1429 if [ -n "$TRY_UPGRADE" ]; then
1430 echo "\n!!! Package with new version cannot be built automagically\n"
1431 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1432 mv -f $SPECFILE.bak $SPECFILE
1435 Exit_error err_build_fail
1442 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1445 install_required_packages()
1452 # taken from find-spec-bcond, but with just getting the list
1455 /^%changelog/ { exit }
1456 /_with(out)?_[_a-zA-Z0-9]+/{
1457 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1458 print substr($0, RSTART, RLENGTH);
1461 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1462 bcond = substr($0, RSTART +5 , RLENGTH -5);
1463 gsub(/[ \t]+/,"_",bcond);
1465 }' $SPEC | LC_ALL=C sort -u
1469 # expand bconds from ~/.bcondrc
1470 # The file structure is like gentoo's package.use:
1473 # samba -mysql -pgsql
1474 # w32codec-installer license_agreement
1477 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1483 SN=${SPECFILE%%\.spec}
1485 local bcondrc=$HOME/.bcondrc
1486 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1488 local bcond_avail=$(find_spec_bcond $SPECFILE)
1490 while read pkg flags; do
1492 [[ "$pkg" == \#* ]] && continue
1494 # any package or current package?
1495 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1496 for flag in $flags; do
1497 local opt=${flag#[+-]}
1499 # use only flags which are in this package.
1500 if [[ $bcond_avail = *${opt}* ]]; then
1501 if [[ $flag = -* ]]; then
1502 if [[ $BCOND != *--with?${opt}* ]]; then
1503 BCOND="$BCOND --without $opt"
1506 if [[ $BCOND != *--without?${opt}* ]]; then
1507 BCOND="$BCOND --with $opt"
1514 update_shell_title "parse ~/.bcondrc: DONE!"
1519 update_shell_title "set bcond values"
1521 AVAIL_BCONDS_WITHOUT=""
1522 AVAIL_BCONDS_WITH=""
1523 if `grep -q ^%bcond ${SPECFILE}`; then
1525 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1531 local bcond_avail=$(find_spec_bcond $SPECFILE)
1532 process_bcondrc "$SPECFILE"
1534 update_shell_title "parse bconds"
1535 case "${BCOND_VERSION}" in
1540 echo "Warning: This spec has old style bconds. Fix it || die."
1541 for opt in `echo "$bcond_avail" | grep ^_without_`
1543 AVAIL_BCOND_WITHOUT=${opt#_without_}
1544 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1545 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1547 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1551 for opt in `echo "$bcond_avail" | grep ^_with_`
1553 AVAIL_BCOND_WITH=${opt#_with_}
1554 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1555 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1557 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1562 local cond_type="" # with || without
1563 for opt in $bcond_avail; do
1572 AVAIL_BCOND_WITHOUT=${opt#_without_}
1573 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1574 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1576 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1580 AVAIL_BCOND_WITH=${opt#_with_}
1581 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1582 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1584 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1588 case "$cond_type" in
1591 AVAIL_BCOND_WITH="$opt"
1592 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1593 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1595 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1600 AVAIL_BCOND_WITHOUT="$opt"
1601 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1602 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1604 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1618 update_shell_title "run_sub_builder $package_name"
1620 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1621 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1622 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1623 # jakby nie bylo tego kawalka kodu.
1625 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1626 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1630 # kurwa. translate that ^^^^
1634 # Istnieje taki spec? ${package}.spec
1635 if [ -f "${SPEC_DIR}/${package}.spec" ]; then
1636 parent_spec_name=${package}.spec
1637 elif [ -f "${SPEC_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1638 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1640 for provides_line in $(grep -r ^Provides:.*$package ${SPEC_DIR}); do
1645 if [ "${parent_spec_name}" != "" ]; then
1646 spawn_sub_builder $parent_spec_name
1648 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1654 update_shell_title "spawn_sub_builder $package_name"
1657 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1658 sub_builder_opts="${sub_builder_opts} -R"
1660 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1661 sub_builder_opts="${sub_builder_opts} -RB"
1662 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1663 sub_builder_opts="${sub_builder_opts} -FRB"
1665 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1666 sub_builder_opts="${sub_builder_opts} -Upi"
1670 ./builder ${sub_builder_opts} "$@"
1673 remove_build_requires()
1675 if [ "$INSTALLED_PACKAGES" != "" ]; then
1676 case "$REMOVE_BUILD_REQUIRES" in
1678 run_poldek --noask -ve $INSTALLED_PACKAGES
1681 run_poldek --ask -ve $INSTALLED_PACKAGES
1684 echo You may want to manually remove following BuildRequires fetched:
1685 echo $INSTALLED_PACKAGES
1686 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1694 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1695 if [ "$BCOND" != "" ]; then
1696 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1699 echo -ne "\nNo conditional flags passed"
1701 echo -ne "\n\nfrom available:\n"
1702 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1708 if [ "$NOCVSSPEC" != "yes" ]; then
1709 echo -ne "Available branches: "
1710 $CVS_COMMAND status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1714 # checks a given list of packages/files/provides agains current rpmdb.
1715 # outputs all dependencies which current rpmdb doesn't satisfy.
1716 # input can be either STDIN or parameters
1721 if [ $# -gt 0 ]; then
1727 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1730 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1732 # other deps (files)
1733 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1736 # checks if given package/files/provides exists in rpmdb.
1737 # input can be either stdin or parameters
1738 # returns packages which are present in the rpmdb
1743 if [ $# -gt 0 ]; then
1749 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1752 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1753 install_build_requires_rpmdeps() {
1754 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1755 # TODO: Conflicts list doesn't check versions
1756 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1757 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1759 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1760 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1761 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1764 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1765 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1766 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1767 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1769 if [ -n "$CNFL" ]; then
1770 update_shell_title "uninstall conflicting packages: $CNFL"
1771 echo "Trying to uninstall conflicting packages ($CNFL):"
1772 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1775 while [ "$DEPS" ]; do
1776 update_shell_title "install deps: $DEPS"
1777 echo "Trying to install dependencies ($DEPS):"
1778 local log=.${SPECFILE}_poldek.log
1779 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1780 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1783 if [ -n "$failed" ]; then
1784 for package in $failed; do
1785 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1794 fetch_build_requires()
1796 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1800 update_shell_title "fetch build requires"
1801 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1802 install_build_requires_rpmdeps
1806 # XXX is this ugliest code written in human history still needed?
1807 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1808 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1809 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1810 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1811 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1812 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)
1814 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)
1816 package=$(basename "$package_item"|sed -e "s/}$//g")
1817 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1820 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1821 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1822 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
1827 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1830 if `echo $COND_TST|grep -q 'without_'`; then
1831 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1832 if `echo $COND_TST|grep -q !`; then
1837 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1838 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1839 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1845 elif `echo $COND_TST|grep -q 'with_'`; then
1846 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1847 if `echo $COND_TST|grep -q !`; then
1852 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1853 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1854 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1860 RESULT="${COND_STATE}-${COND_ARGV}"
1862 "with-wout" | "wout-with" )
1865 "wout-wout" | "with-with" )
1869 echo "Action '$RESULT' was not defined for package '$package_item'"
1875 if [ "$GO" = "yes" ]; then
1876 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1877 echo "Testing if $package has subrequirements..."
1878 run_poldek -t -i $package --dumpn=".$package-req.txt"
1879 if [ -f ".$package-req.txt" ]; then
1880 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1882 if [ "$package_name" = "$package" ]; then
1883 echo -ne "Installing BuildRequired package:\t$package_name\n"
1884 update_shell_title "Installing BuildRequired package: ${package_name}"
1885 install_required_packages $package
1887 echo -ne "Installing (sub)Required package:\t$package_name\n"
1888 update_shell_title "Installing (sub)Required package: ${package_name}"
1889 install_required_packages $package_name
1893 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1894 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1897 echo "Attempting to run spawn sub - builder..."
1898 echo -ne "Package installation failed:\t$package_name\n"
1899 run_sub_builder $package_name
1900 if [ $? -eq 0 ]; then
1901 install_required_packages $package_name
1904 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1905 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1908 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1915 rm -f ".$package-req.txt"
1917 echo "Attempting to run spawn sub - builder..."
1918 echo -ne "Package installation failed:\t$package\n"
1919 run_sub_builder $package
1920 if [ $? -eq 0 ]; then
1921 install_required_packages $package
1924 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1925 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1928 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1934 echo "Package $package is already installed. BuildRequirement satisfied."
1938 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1939 echo >&2 "Unable to install following packages and their dependencies:"
1940 for pkg in "$NOT_INSTALLED_PACKAGES"
1944 remove_build_requires
1950 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1951 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1953 echo "Initialising rpm directories to $TOP_DIR from $CVSROOT"
1954 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1956 $CVS_COMMAND -d $CVSROOT co SOURCES/{.cvsignore,dropin} SPECS/{mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1960 echo "To checkout *all* .spec files:"
1961 echo "- remove $SPEC_DIR/CVS/Entries.Static"
1962 echo "- run cvs up in $SPEC_DIR dir"
1965 echo "To commit with your developer account:"
1966 echo "- edit $SPEC_DIR/CVS/Root"
1967 echo "- edit $SOURCE_DIR/CVS/Root"
1970 get_greed_sources() {
1971 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1972 if [ -n "BE_VERBOSE" ]; then
1973 echo "Try greed download: $1 from: $CVSROOT"
1975 $CVS_COMMAND -d $CVSROOT get SOURCES/$1
1976 if [ $? != 0 ]; then
1977 Exit_error err_no_source_in_repo $1
1982 # remove entries from CVS/Entries
1983 cvs_entry_remove() {
1984 local cvsdir="$1"; shift
1985 if [ ! -d "$cvsdir" ]; then
1986 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1990 for file in "$@"; do
1991 rm -f $cvsdir/CVS/Entries.new || return 1
1992 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1993 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
2001 DONT_PRINT_REVISION="yes"
2005 # remove from CVS/Entries
2006 cvs_entry_remove $SPEC_DIR $SPECFILE
2007 cvs_entry_remove $SOURCE_DIR $SOURCES $PATCHES
2009 # remove spec and sources
2010 $RPMBUILD --clean --rmsource --rmspec --nodeps $SPECFILE
2013 #---------------------------------------------
2021 while [ $# -gt 0 ]; do
2024 COMMAND="update_md5"
2029 COMMAND="update_md5"
2039 DEBUG="yes"; shift ;;
2041 COMMAND="version"; shift ;;
2043 COMMAND="short-version"; shift ;;
2045 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
2046 -b | -ba | --build )
2047 COMMAND="build"; shift ;;
2048 -bb | --build-binary )
2049 COMMAND="build-binary"; shift ;;
2051 COMMAND="build-build"; shift ;;
2053 COMMAND="build-install"; shift ;;
2055 COMMAND="build-list"; shift ;;
2056 -bp | --build-prep )
2057 COMMAND="build-prep"; shift ;;
2058 -bs | --build-source )
2059 COMMAND="build-source"; shift ;;
2061 COMMAND="branch"; shift; TAG="${1}"; shift;;
2063 CLEAN="--clean --rmspec --rmsource"; shift ;;
2065 CVS_FORCE="-F"; shift;;
2067 shift; CVSROOT="${1}"; shift ;;
2069 COMMAND="get"; shift ;;
2071 COMMAND="usage"; shift ;;
2073 PROTOCOL="http"; shift ;;
2075 shift; LOGFILE="${1}"; shift ;;
2077 shift; DEF_NICE_LEVEL=${1}; shift ;;
2078 -ske | --skip-existing-files)
2079 SKIP_EXISTING_FILES="yes"; shift ;;
2081 COMMAND="mr-proper"; shift ;;
2083 NOCVS="yes"; shift ;;
2084 -ncs | --no-cvs-specs )
2085 NOCVSSPEC="yes"; shift ;;
2086 -nd | --no-distfiles )
2087 NODIST="yes"; shift ;;
2088 -nm | --no-mirrors )
2089 NOMIRRORS="yes"; shift ;;
2091 NOURLS="yes"; shift ;;
2093 NOSRCS="yes"; shift ;;
2094 -ns0 | --no-source0 )
2095 NOSOURCE0="yes"; shift ;;
2105 -pm | --prefer-mirrors )
2112 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2114 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2116 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2119 --with | --without )
2120 case $GROUP_BCONDS in
2124 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2125 while ! `echo ${1}|grep -qE '(^-|spec)'`
2127 BCOND="$BCOND $COND $1"
2131 if [[ "$2" = *,* ]]; then
2132 for a in $(echo "$2" | tr , ' '); do
2133 BCOND="$BCOND $1 $a"
2136 BCOND="$BCOND $1 $2"
2142 shift; TARGET="${1}"; shift ;;
2144 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2146 QUIET="--quiet"; shift ;;
2148 CVSDATE="${2}"; shift 2 ;;
2157 -R | --fetch-build-requires)
2158 FETCH_BUILD_REQUIRES="yes"
2159 NOT_INSTALLED_PACKAGES=
2161 -RB | --remove-build-requires)
2162 REMOVE_BUILD_REQUIRES="nice"
2164 -FRB | --force-remove-build-requires)
2165 REMOVE_BUILD_REQUIRES="force"
2167 -sc | --sources-cvs)
2168 COMMAND="list-sources-cvs"
2170 -sd | --sources-distfiles)
2171 COMMAND="list-sources-distfiles"
2173 -sdp | --sources-distfiles-paths)
2174 COMMAND="list-sources-distfiles-paths"
2176 -sf | --sources-files)
2177 COMMAND="list-sources-files"
2179 -sp | --sources-paths)
2180 COMMAND="list-sources-local-paths"
2182 -su | --sources-urls)
2183 COMMAND="list-sources-urls"
2185 -Tvs | --tag-version-stable )
2190 -Ts | --tag-stable )
2195 -Tv | --tag-version )
2200 -Tp | --tag-prefix )
2212 -ir | --integer-release-only )
2213 INTEGER_RELEASE="yes"
2216 COMMAND="update_md5"
2221 -Upi | --update-poldek-indexes )
2222 UPDATE_POLDEK_INDEXES="yes"
2225 COMMAND="init_rpm_dir"
2227 --use-greed-sources )
2230 -u | --try-upgrade )
2231 TRY_UPGRADE="1"; shift ;;
2232 -un | --try-upgrade-with-float-version )
2233 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2235 BE_VERBOSE="1"; shift ;;
2240 if echo "${MACRO}" | grep -q '\W'; then
2241 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2245 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2250 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2254 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2257 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2258 COMMAND="show_bconds"
2262 COMMAND="show_bcond_args"
2267 RPMOPTS="${RPMOPTS} --nodeps"
2270 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2273 Exit_error err_invalid_cmdline "$1"
2277 # check if specname was passed as specname:cvstag
2278 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2279 CVSTAG="${SPECFILE##*:}"
2280 SPECFILE="${SPECFILE%%:*}"
2282 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2287 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2288 CVSTAG=$(awk -vSPECFILE=$(basename ${SPECFILE%.spec}.spec) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2289 if [ "$CVSTAG" ]; then
2290 echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
2292 elif [ "$CVSTAG" = "HEAD" ]; then
2293 # assume -r HEAD is same as -A
2297 if [ "$CVSTAG" ]; then
2298 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2299 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2302 if [ -n "$DEBUG" ]; then
2307 if [ -n "$TARGET" ]; then
2310 TARGET_SWITCH="--target $TARGET" ;;
2312 TARGET_SWITCH="--target=$TARGET" ;;
2316 if [ "$SCHEDTOOL" != "no" ]; then
2317 NICE_COMMAND="$SCHEDTOOL"
2319 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2322 update_shell_title "$COMMAND"
2326 if [ -n "$SPECFILE" ]; then
2327 get_spec > /dev/null
2335 if [ -n "$SPECFILE" ]; then
2336 get_spec > /dev/null
2342 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2344 if [ -n "$SPECFILE" ]; then
2350 if [ "$COMMAND" != "build-source" ]; then
2353 fetch_build_requires
2354 if [ "$INTEGER_RELEASE" = "yes" ]; then
2355 echo "Checking release $PACKAGE_RELEASE..."
2356 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2357 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2361 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2362 if [ -n "$TEST_TAG" ]; then
2363 local TAGVER=`make_tagver`
2364 echo "Searching for tag $TAGVER..."
2365 TAGREL=$($CVS_COMMAND status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2366 if [ -n "$TAGREL" ]; then
2367 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2370 # - do not allow to build from HEAD when XX-branch exists
2371 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2372 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2373 TAG_BRANCH="${TREE_PREFIX}-branch"
2374 TAG_STATUS=$($CVS_COMMAND status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2375 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2376 Exit_error err_branch_exists "$TAG_STATUS"
2382 if [ -n "$NOSOURCE0" ] ; then
2383 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2385 get_files $SOURCES $PATCHES
2388 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2389 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2391 remove_build_requires
2393 Exit_error err_no_spec_in_cmdl
2398 if [ -n "$SPECFILE" ]; then
2401 # don't fetch sources from remote locations
2403 for file in $SOURCES; do
2404 [ -n "`src_md5 $file`" ] && continue
2405 new_SOURCES="$new_SOURCES $file"
2407 SOURCES="$new_SOURCES"
2408 get_files $SOURCES $PATCHES
2410 branch_files $TAG $SOURCES $PATCHES $ICONS
2412 Exit_error err_no_spec_in_cmdl
2417 if [ -n "$SPECFILE" ]; then
2421 if [ -n "$NOSOURCE0" ] ; then
2422 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2424 get_files $SOURCES $PATCHES
2427 Exit_error err_no_spec_in_cmdl
2432 if [ -n "$SPECFILE" ]; then
2436 if [ -n "$NOSOURCE0" ] ; then
2437 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2441 Exit_error err_no_spec_in_cmdl
2448 if [ -n "$SPECFILE" ]; then
2452 # don't fetch sources from remote locations
2454 for file in $SOURCES; do
2455 [ -n "`src_md5 $file`" ] && continue
2456 new_SOURCES="$new_SOURCES $file"
2458 SOURCES="$new_SOURCES"
2459 get_files $SOURCES $PATCHES
2461 tag_files $SOURCES $PATCHES $ICONS
2463 Exit_error err_no_spec_in_cmdl
2469 "list-sources-files" )
2472 DONT_PRINT_REVISION="yes"
2475 for SAP in $SOURCES $PATCHES; do
2476 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2479 "list-sources-urls" )
2482 DONT_PRINT_REVISION="yes"
2485 SAPS="$SOURCES $PATCHES"
2486 for SAP in $SAPS ; do
2490 "list-sources-local-paths" )
2493 DONT_PRINT_REVISION="yes"
2496 for SAP in $SOURCES $PATCHES; do
2497 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2500 "list-sources-distfiles-paths" )
2503 DONT_PRINT_REVISION="yes"
2506 for SAP in $SOURCES $PATCHES; do
2507 if [ -n "$(src_md5 "$SAP")" ]; then
2508 distfiles_path "$SAP"
2512 "list-sources-distfiles" )
2515 DONT_PRINT_REVISION="yes"
2518 for SAP in $SOURCES $PATCHES; do
2519 if [ -n "$(src_md5 "$SAP")" ]; then
2520 distfiles_url "$SAP"
2524 "list-sources-cvs" )
2527 DONT_PRINT_REVISION="yes"
2530 for SAP in $SOURCES $PATCHES; do
2531 if [ -z "$(src_md5 "$SAP")" ]; then
2532 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2546 echo "$VERSIONSTRING"
2549 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2550 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2554 # vi:syntax=sh:ts=4:sw=4:noet