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!
95 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
96 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
102 CVS_SERVER="cvs.pld-linux.org"
103 DISTFILES_SERVER="://distfiles.pld-linux.org"
104 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
109 FAIL_IF_NO_SOURCES="yes"
111 # let get_files skip over files which are present to get those damn files fetched
112 SKIP_EXISTING_FILES="no"
115 # should the specfile be restored if upgrade failed?
116 REVERT_BROKEN_UPGRADE="yes"
118 if rpm --specsrpm 2>/dev/null; then
119 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
120 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
122 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
123 if [ -x /usr/bin/rpm-getdeps ]; then
124 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
126 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
131 # Here we load saved user environment used to
132 # predefine options set above, or passed to builder
134 # This one reads global system environment settings:
135 if [ -f ~/etc/builderrc ]; then
138 # And this one cascades settings using user personal
140 # Example of ~/.builderrc:
142 #UPDATE_POLDEK_INDEXES="yes"
143 #FETCH_BUILD_REQUIRES="yes"
144 #REMOVE_BUILD_REQUIRES="force"
146 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
150 if [ -n "$HOME_ETC" ]; then
151 USER_CFG="$HOME_ETC/.builderrc"
152 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
154 USER_CFG=~/.builderrc
155 BUILDER_MACROS=~/.builder-rpmmacros
158 [ -f "$USER_CFG" ] && . "$USER_CFG"
160 if [ "$SCHEDTOOL" = "auto" ]; then
161 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
162 SCHEDTOOL="schedtool -B -e"
168 if [ -n "$USE_PROZILLA" ]; then
169 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
172 elif [ -n "$USE_AXEL" ]; then
173 GETURI="axel -a $AXEL_OPTS"
177 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
178 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
179 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
180 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
182 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
183 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
189 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
198 # are we using cvs-nserver ?
201 cvs --version 2>&1 | grep -q 'CVS-nserver'
202 [ $? -eq 0 ] && CVS_NSERVER=1
204 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
205 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
209 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
210 if [ -n "$LOGFILE" ]; then
211 LOG=`eval echo $LOGFILE`
212 if [ -n "$LASTLOG_FILE" ]; then
213 echo "LASTLOG=$LOG" > $LASTLOG_FILE
215 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
218 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
219 return `cat ${RES_FILE}`
224 #---------------------------------------------
229 if [ -n "$DEBUG" ]; then set -xv; fi
231 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
232 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
233 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
234 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
235 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
236 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
237 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
238 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
239 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
240 <package>[.spec][:cvstag]
242 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
243 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
244 -n5, --no-md5 - ignore md5 comments in spec
245 -D, --debug - enable builder script debugging mode,
246 -debug - produce rpm debug package (same as --opts -debug)
247 -V, --version - output builder version string
248 --short-version - output builder short version
249 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
250 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
252 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
253 only package from <package>.spec,
254 -bp, --build-prep - execute the %prep phase of <package>.spec,
255 -bc - execute the %build phase of <package>.spec,
256 -bi - execute the %install phase of <package>.spec
257 -bl - execute the %files phase of <package>.spec
258 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
260 --short-circuit - short-circuit build
261 -B, --branch - add branch
262 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
263 SPECS and \$RPM_BUILD_ROOT and CVS/Entries) after rpmbuild commands.
264 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
265 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
267 -cf, --cvs-force - use -F when tagging (useful when moving branches)
268 -d <cvsroot>, --cvsroot <cvsroot>
270 --define <macro> <value>
271 - define a macro <macro> with value <value>,
272 --alt_kernel <kernel>
273 - same as --define 'alt_kernel <kernel>'
274 --nodeps - rpm won't check any dependences
275 -g, --get - get <package>.spec and all related files from CVS repo
277 -h, --help - this message,
278 --http - use http instead of ftp,
279 -l <logfile>, --logtofile <logfile>
281 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
283 - don't check specs in CVS
284 -nd, --no-distfiles - don't download from distfiles
285 -nm, --no-mirrors - don't download from mirror, if source URL is given,
286 -nu, --no-urls - don't try to download from FTP/HTTP location,
287 -ns, --no-srcs - don't download Sources
288 -ns0, --no-source0 - don't download Source0
289 -nn, --no-net - don't download anything from the net
290 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
291 --no-init - don't initialize builder paths (SPECS and SOURCES)
293 --skip-existing-files - skip existing files in get_files
294 --opts <rpm opts> - additional options for rpm
295 -q, --quiet - be quiet,
296 --date yyyy-mm-dd - build package using resources from specified CVS date,
297 -r <cvstag>, --cvstag <cvstag>
298 - build package using resources from specified CVS tag,
299 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
300 -R, --fetch-build-requires
301 - fetch what is BuildRequired,
302 -RB, --remove-build-requires
303 - remove all you fetched with -R or --fetch-build-requires
304 remember, this option requires confirmation,
305 -FRB, --force-remove-build-requires
306 - remove all you fetched with -R or --fetch-build-requires
307 remember, this option works without confirmation,
308 -sd, --source-distfiles - list sources available from distfiles (intended for offline
309 operations; does not work when Icon field is present
310 but icon file is absent),
311 -sc, --source-cvs - list sources available from CVS
312 -sdp, --source-distfiles-paths - list sources available from distfiles -
313 paths relative to distfiles directory (intended for offline
314 operations; does not work when Icon field is present
315 but icon file is absent),
316 -sf, --source-files - list sources - bare filenames (intended for offline
317 operations; does not work when Icon field is present
318 but icon file is absent),
319 -sp, --source-paths - list sources - filenames with full local paths (intended for
320 offline operations; does not work when Icon field is present
321 but icon file is absent),
322 -su, --source-urls - list urls - urls to sources and patches
323 intended for copying urls with spec with lots of macros in urls
324 -T <cvstag> , --tag <cvstag>
325 - add cvs tag <cvstag> for files,
326 -Tvs, --tag-version-stable
327 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
329 - add cvs tag STABLE for files,
331 - add cvs tag NAME-VERSION-RELEASE for files,
332 -Tp, --tag-prefix <prefix>
333 - add <prefix> to NAME-VERSION-RELEASE tags,
334 -tt, --test-tag <prefix>
335 - fail if tag is already present,
336 -ir, --integer-release-only
337 - allow only integer and snapshot releases
338 -v, --verbose - be verbose,
339 -u, --try-upgrade - check version, and try to upgrade package
340 -un, --try-upgrade-with-float-version
341 - as above, but allow float version
343 - try download source from tag head if don't find it in
345 -U, --update - refetch sources, don't use distfiles, and update md5 comments
346 -Upi, --update-poldek-indexes
347 - refresh or make poldek package index files.
348 -np, --nopatch <patchnumber>
349 - don't apply <patchnumber>
350 --show-bconds - show available conditional builds, which can be used
351 - with --with and/or --without switches.
352 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
353 ./repackage.sh script. in other words, the output is
354 parseable by scripts.
355 --with/--without <feature>
356 - conditional build package depending on %_with_<feature>/
357 %_without_<feature> macro switch. You may now use
358 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
359 constructions. Set GROUP_BCONDS to yes to make use of it.
360 --target <platform>, --target=<platform>
361 - build for platform <platform>.
362 --init-rpm-dir - initialize ~/rpm directory structure
366 # change dependency to specname
368 # - perl(Package::Name) -> perl-Package-Name
372 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g}')
376 update_shell_title() {
378 local len=${COLUMNS:-80}
379 local msg=$(echo "$*" | cut -c-$len)
381 if [ -n "$BE_VERBOSE" ]; then
382 echo >&2 "$(date +%s.%N) $*"
385 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
387 if [ -n "$PACKAGE_NAME" ]; then
388 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
393 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
394 msg=$(echo $msg | tr -d '\n\r')
397 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
400 echo >&2 -ne "\033]0;$msg\007"
406 # set TARGET from BuildArch: from SPECFILE
408 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
409 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
411 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
415 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
417 TARGET_SWITCH="--target=$TARGET" ;;
423 # runs rpm with minimal macroset
425 # we reset macros not to contain macros.build as all the %() macros are
426 # executed here, while none of them are actually needed.
427 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
428 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
430 # TODO: move these to /usr/lib/rpm/macros
431 cat > $BUILDER_MACROS <<'EOF'
432 %x8664 x86_64 amd64 ia32e
435 %requires_releq_kernel_up %{nil}
436 %requires_releq_kernel_smp %{nil}
437 %requires_releq_kernel %{nil}
438 %requires_releq() %{nil}
439 %pyrequires_eq() %{nil}
440 %requires_eq() %{nil}
441 %requires_eq_to() %{nil}
442 %releq_kernel_up ERROR
443 %releq_kernel_smp ERROR
448 %ruby_ver_requires_eq() %{nil}
449 %ruby_mod_ver_requires_eq() %{nil}
450 %__php_api_requires() %{nil}
451 %php_major_version ERROR
452 %php_api_version ERROR
453 %requires_xorg_xserver_extension %{nil}
454 %requires_xorg_xserver_xinput %{nil}
455 %requires_xorg_xserver_font %{nil}
456 %requires_xorg_xserver_videodrv %{nil}
458 %perl_vendorarch ERROR
459 %perl_vendorlib ERROR
460 # damn. need it here! - copied from /usr/lib/rpm/macros.build
461 %tmpdir %(echo "${TMPDIR:-/tmp}")
462 %patchset_source(f:b:) %(
463 base=%{-b*}%{!-b*:10000};
464 start=$(expr $base + %1);
465 end=$(expr $base + %{?2}%{!?2:%{1}});
466 # we need to call seq twice as it doesn't allow two formats
467 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
468 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
469 paste %{tmpdir}/__ps{1,2};
470 rm -f %{tmpdir}/__ps{1,2};
473 %add_etc_shells(p) %{p:<lua>}
474 %remove_etc_shells(p) %{p:<lua>}
475 %lua_add_etc_shells() %{nil}
476 %lua_remove_etc_shells() %{nil}
478 if [ "$NOINIT" = "yes" ] ; then
479 cat >> $BUILDER_MACROS <<'EOF'
484 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
488 if [ -n "$DEBUG" ]; then
493 if [ -x /usr/bin/rpm-specdump ]; then
494 update_shell_title "cache_rpm_dump using rpm-specdump command"
495 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
497 update_shell_title "cache_rpm_dump using rpmbuild command"
500 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
501 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
507 ARGS='--nodigest --nosignature --nobuild'
510 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
512 if [ $? -gt 0 ]; then
513 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
515 Exit_error err_build_fail
518 # make small dump cache
519 rpm_dump_cache=`echo "$rpm_dump" | awk '
520 $2 ~ /^SOURCEURL/ {print}
521 $2 ~ /^PATCHURL/ {print}
522 $2 ~ /^nosource/ {print}
523 $2 ~ /^PACKAGE_/ {print}
527 update_shell_title "cache_rpm_dump: OK!"
531 if [ -z "$rpm_dump_cache" ] ; then
532 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
534 echo "$rpm_dump_cache"
539 update_shell_title "get icons"
540 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
541 if [ -z "$ICONS" ]; then
545 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
550 update_shell_title "parsing specfile"
551 if [ -n "$DEBUG" ]; then
556 # icons are needed for successful spec parse
562 if [ "$NOSRCS" != "yes" ]; then
563 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
566 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
567 FAIL_IF_NO_SOURCES="no"
570 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
571 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
572 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
573 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
574 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
576 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
577 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
580 if [ -n "$BE_VERBOSE" ]; then
581 echo "- Sources : `nourl $SOURCES`"
582 if [ -n "$PATCHES" ]; then
583 echo "- Patches : `nourl $PATCHES`"
585 echo "- Patches : *no patches needed*"
587 if [ -n "$ICONS" ]; then
588 echo "- Icon : `nourl $ICONS`"
590 echo "- Icon : *no package icon*"
592 echo "- Name : $PACKAGE_NAME"
593 echo "- Version : $PACKAGE_VERSION"
594 echo "- Release : $PACKAGE_RELEASE"
597 update_shell_title "parse_spec: OK!"
602 if [ -n "$DEBUG" ]; then
610 "err_no_spec_in_cmdl" )
611 remove_build_requires
612 echo >&2 "ERROR: spec file name not specified."
614 "err_invalid_cmdline" )
615 echo >&2 "ERROR: invalid command line arg ($2)."
617 "err_no_spec_in_repo" )
618 remove_build_requires
619 echo >&2 "Error: spec file not stored in CVS repo."
621 "err_no_source_in_repo" )
622 remove_build_requires
623 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
626 remove_build_requires
627 echo >&2 "Error: package build failed. (${2:-no more info})"
629 "err_no_package_data" )
630 remove_build_requires
631 echo >&2 "Error: couldn't get out package name/version/release from spec file."
634 remove_build_requires
635 echo >&2 "Tag ${2} already exists (spec release: ${3})."
638 remove_build_requires
639 echo >&2 "Release ${2} not integer and not a snapshot."
641 "err_branch_exists" )
642 remove_build_requires
643 echo >&2 "Tree branch already exists (${2})."
646 remove_build_requires
647 echo >&2 "Error: conditions reject building this spec (${2})."
650 echo >&2 "Unknown error."
656 if [ -n "$DEBUG" ]; then
661 if [ "$NOINIT" != "yes" ] ; then
663 if [ "$ASSUMED_NAME" ]; then
664 extra="--define 'name $ASSUMED_NAME'"
666 SOURCE_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_sourcedir}')
667 SPEC_DIR=$(eval $RPM $RPMOPTS $extra --eval '%{_specdir}')
679 update_shell_title "get_spec"
681 if [ -n "$DEBUG" ]; then
687 if [ ! -f "$SPECFILE" ]; then
688 SPECFILE="$(basename $SPECFILE .spec).spec"
690 if [ "$NOCVSSPEC" != "yes" ]; then
692 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
693 echo "Warning: No CVS access defined - using local .spec file"
697 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
700 if [ ! -f "$SPECFILE" ]; then
701 Exit_error err_no_spec_in_repo
704 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
705 chmod $CHMOD_MODE $SPECFILE
708 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
717 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
718 cvs update mirrors >&2
722 local origin mirror name rest ol prefix
723 while read origin mirror name rest; do
724 # skip comments and empty lines
725 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
728 ol=$(echo -n "$origin" | wc -c)
729 prefix=$(echo -n "$url" | head -c $ol)
730 if [ "$prefix" = "$origin" ] ; then
731 suffix=$(echo "$url" | cut -b $((ol+1))-)
732 echo -n "$mirror$suffix"
739 # Warning: unpredictable results if same URL used twice
744 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
745 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
751 [ "$NO5" = "yes" ] && return
753 [ -z "$no" ] && return
757 if [ -f additional-md5sums ]; then
758 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
759 if [ -z "$spec_rev" ]; then
760 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
762 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
763 md5=$(grep -s -v '^#' additional-md5sums | \
764 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
765 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
766 grep -E '^[0-9a-f]{32}$')
769 if [ $(echo "$md5" | wc -l) != 1 ] ; then
770 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
772 echo "$md5" | tail -n 1
777 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
778 if [ -n "$source_md5" ]; then
781 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
782 if [ -n "$source_md5" ]; then
785 # we have empty SourceX-md5, but it is still possible
786 # that we have NoSourceX-md5 AND NoSource: X
787 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
788 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
797 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
802 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
805 distfiles_attic_url ()
807 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
814 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
819 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
820 [ -n "$size" -a "$size" -gt 0 ]
825 if [ "$CVSIGNORE_DF" != "yes" ]; then
828 cvsignore=${SOURCE_DIR}/.cvsignore
829 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
830 echo "$1" >> $cvsignore
836 update_shell_title "cvsup"
838 if [ -n "$CVSROOT" ]; then
839 OPTIONS="-d $CVSROOT $OPTIONS"
842 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
843 OPTIONS="$OPTIONS -A"
845 if [ -n "$CVSDATE" ]; then
846 OPTIONS="$OPTIONS -D $CVSDATE"
848 if [ -n "$CVSTAG" ]; then
849 OPTIONS="$OPTIONS -r $CVSTAG"
854 local retries_counter=0
856 update_shell_title "cvsup: $*"
858 update_shell_title "cvsup: $# files"
860 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
861 retries_counter=$(( $retries_counter + 1 ))
862 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
864 [ -n "$output" ] && echo "$output"
865 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
866 echo "Trying again [$*]... ($retries_counter)"
867 update_shell_title "cvsup: retry #$retries_counter"
874 update_shell_title "cvsup: done!"
878 # returns true if "$1" is ftp, http or https protocol url
882 ftp://*|http://*|https://*)
891 if [ $# -eq 0 ]; then
895 update_shell_title "update md5"
896 if [ -n "$DEBUG" ]; then
903 # pass 1: check files to be fetched
907 local fp=$(nourl "$i")
908 local srcno=$(src_no "$i")
909 if [ -n "$ADD5" ]; then
910 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
911 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE && continue
912 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE && continue
914 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE || continue
916 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
917 need_files="$need_files $i"
921 # pass 1a: get needed files
922 if [ "$need_files" ]; then
923 get_files $need_files
926 # pass 2: proceed with md5 adding or updating
928 local fp=$(nourl "$i")
929 local srcno=$(src_no "$i")
930 local md5=$(grep -iE '^#[ ]*(No)?Source'$srcno'-md5[ ]*:' $SPEC_DIR/$SPECFILE )
931 if [ -z "$md5" ]; then
932 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $SPEC_DIR/$SPECFILE )
934 if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
935 local tag="# Source$srcno-md5:\t"
936 if [[ "$md5" == *NoSource* ]]; then
937 tag="# NoSource$srcno-md5:\t"
938 elif [ -n "$USEDIGEST" ]; then
939 tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
941 md5=$(md5sum "$fp" | cut -f1 -d' ')
942 echo "Updating Source$srcno ($md5: $fp)."
944 print unless (/^\s*#\s*(No)?Source'$srcno'-md5\s*:/i or /^\s*BuildRequires:\s*digest\(%SOURCE'$srcno'\)/i);
945 print "'"$tag$md5"'\n" if /^Source'$srcno'\s*:\s+/;
954 [ "$NO5" = "yes" ] && return
956 update_shell_title "check md5"
959 if good_md5 "$i" && good_size "$i"; then
963 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
964 echo "or -5 to update md5 sums, if you're sure files are correct."
965 Exit_error err_no_source_in_repo $i
971 update_shell_title "get_files"
973 if [ -n "$DEBUG" ]; then
978 if [ $# -gt 0 ]; then
981 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
982 echo "Warning: No CVS access defined for SOURCES"
987 local get_files_cvs=""
991 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
992 update_shell_title "$i"
993 local fp=`nourl "$i"`
994 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
999 local srcmd5=$(src_md5 "$i")
1001 # we know if source/patch is present in cvs/distfiles
1002 # - has md5 (in distfiles)
1003 # - in cvs... ideas?
1005 # CHECK: local file didn't exist or always cvs up (first) requested.
1006 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
1007 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
1008 echo "Warning: no URL given for $i"
1011 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
1012 if good_md5 "$i" && good_size "$i"; then
1013 echo "$fp having proper md5sum already exists"
1018 # optionally prefer mirror over distfiles if there's mirror
1019 # TODO: build url list and then try each url from the list
1020 if [ -n "$PREFMIRRORS" ] && [ -z "$NOMIRRORS" ] && im=$(find_mirror "$i") && [ "$im" != "$i" ]; then
1023 url=$(distfiles_url "$i")
1026 url_attic=$(distfiles_attic_url "$i")
1028 # is $url local file?
1029 if [[ "$url" = [./]* ]]; then
1030 update_shell_title "${GETLOCAL%% *}: $url"
1031 ${GETLOCAL} $url $target
1033 if [ -z "$NOMIRRORS" ]; then
1034 url=$(find_mirror "$url")
1038 # make shorter message for distfiles urls
1039 if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then
1040 uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1041 uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/}
1044 update_shell_title "${GETURI%% *}: $uri"
1045 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1046 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1047 update_shell_title "${GETURI2%% *}: $url"
1048 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1053 if [ ! -s "$target" ]; then
1055 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
1056 update_shell_title "${GETLOCAL%% *}: $url_attic"
1057 ${GETLOCAL} $url_attic $target
1059 if [ -z "$NOMIRRORS" ]; then
1060 url_attic=$(find_mirror "$url_attic")
1062 update_shell_title "${GETURI%% *}: $url_attic"
1063 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1064 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1065 update_shell_title "${GETURI2%% *}: $url_attic"
1066 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1071 if [ -s "$target" ]; then
1072 cvsignore_df $target
1077 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
1078 if [ $# -gt 1 ]; then
1079 get_files_cvs="$get_files_cvs $fp"
1080 update_shell_title "$fp (will cvs up later)"
1087 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
1088 if [ -z "$NOMIRRORS" ]; then
1089 im=$(find_mirror "$i")
1093 update_shell_title "${GETURI%% *}: $im"
1094 ${GETURI} "$im" || \
1095 if [ "`echo $im | grep -E 'ftp://'`" ]; then
1096 update_shell_title "${GETURI2%% *}: $im"
1101 if [ "$cvsup" = 1 ]; then
1107 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
1108 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
1109 if [ -n "GREEDSRC" ]; then
1110 get_greed_sources $i
1112 Exit_error err_no_source_in_repo $i
1116 # we check md5 here just only to refetch immediately
1117 if good_md5 "$i" && good_size "$i"; then
1119 elif [ "$FROM_DISTFILES" = 1 ]; then
1120 # wrong md5 from distfiles: remove the file and try again
1122 echo "MD5 sum mismatch. Trying full fetch."
1125 update_shell_title "${GETURI%% *}: $url"
1126 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
1127 if [ "`echo $url | grep -E 'ftp://'`" ]; then
1128 update_shell_title "${GETURI2%% *}: $url"
1129 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
1131 if [ ! -s "$target" ]; then
1133 update_shell_title "${GETURI%% *}: $url_attic"
1134 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
1135 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
1136 update_shell_title "${GETURI2%% *}: $url_attic"
1137 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
1140 test -s "$target" || rm -f "$target"
1143 SHELL_TITLE_PREFIX=""
1145 if [ "$get_files_cvs" ]; then
1146 cvsup $get_files_cvs
1149 if [ "$CHMOD" = "yes" ]; then
1150 CHMOD_FILES=$(nourl "$@")
1151 if [ -n "$CHMOD_FILES" ]; then
1152 chmod $CHMOD_MODE $CHMOD_FILES
1159 if [ -n "$DEBUG" ]; then
1164 # Check whether first character of PACKAGE_NAME is legal for tag name
1165 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1169 # NOTE: CVS tags may must not contain the characters `$,.:;@'
1170 TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
1172 # Remove #kernel.version_release from TAGVER because tagging sources
1173 # could occur with different kernel-headers than kernel-headers used at build time.
1174 # besides, %{_kernel_ver_str} is not expanded.
1176 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
1177 # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
1183 # bool is_tag_a_branch(tag)
1185 # returns 1 if a tag is a branch set on SPECFILE
1187 if [ -n "$DEBUG" ]; then
1192 if [ $# -ne 1 ]; then
1199 cvs status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1207 if [ -n "$DEBUG" ]; then
1212 echo "Version: $PACKAGE_VERSION"
1213 echo "Release: $PACKAGE_RELEASE"
1216 if [ "$TAG_VERSION" = "yes" ]; then
1217 TAGVER=`make_tagver`
1218 echo "CVS tag: $TAGVER"
1220 if [ -n "$TAG" ]; then
1221 echo "CVS tag: $TAG"
1224 local OPTIONS="tag $CVS_FORCE"
1225 if [ -n "$CVSROOT" ]; then
1226 OPTIONS="-d $CVSROOT $OPTIONS"
1229 # if a tagname we are about to set already exists
1230 # and happens to be a branch (common case with AC-branch)
1231 # pass -B (allows -F to disturb branch tag)
1233 if [ "$TAG_VERSION" = "yes" ]; then
1236 is_tag_a_branch $_tag
1237 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1238 OPTIONS="$OPTIONS -B"
1243 for i in $TAG_FILES; do
1244 # don't tag files stored on distfiles
1245 [ -n "`src_md5 $i`" ] && continue
1246 local fp=`nourl "$i"`
1247 if [ -f "$fp" ]; then
1248 tag_files="$tag_files $fp"
1249 elif [ -n "GREEDSRC" ]; then
1250 get_greed_sources $i
1252 Exit_error err_no_source_in_repo $i
1256 if [ "$tag_files" ]; then
1257 if [ "$TAG_VERSION" = "yes" ]; then
1258 update_shell_title "tag sources: $TAGVER"
1259 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1260 cvs $OPTIONS $TAGVER $tag_files || exit
1262 if [ -n "$TAG" ]; then
1263 update_shell_title "tag sources: $TAG"
1265 while [ "$tag_files" ]; do
1266 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1267 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1268 cvs $OPTIONS $TAG $chunk || exit
1269 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1275 if [ "$TAG_VERSION" = "yes" ]; then
1276 update_shell_title "tag spec: $TAGVER"
1277 cvs $OPTIONS $TAGVER $SPECFILE || exit
1279 if [ -n "$TAG" ]; then
1280 update_shell_title "tag spec: $TAG"
1281 cvs $OPTIONS $TAG $SPECFILE || exit
1288 echo "CVS branch tag: $TAG"
1293 if [ -n "$DEBUG" ]; then
1298 local OPTIONS="tag $CVS_FORCE -b"
1301 is_tag_a_branch $TAG
1302 if [ $? -eq 1 ]; then
1303 OPTIONS="$OPTIONS -B"
1306 if [ -n "$CVSROOT" ]; then
1307 OPTIONS="-d $CVSROOT $OPTIONS"
1311 for i in $TAG_FILES; do
1312 local fp=`nourl "$i"`
1313 if [ -f "$fp" ]; then
1314 tag_files="$tag_files $fp"
1315 elif [ -n "GREEDSRC" ]; then
1316 get_greed_sources $i
1318 Exit_error err_no_source_in_repo $i
1321 if [ "$tag_files" ]; then
1322 cvs $OPTIONS $TAG $tag_files || exit
1326 cvs $OPTIONS $TAG $SPECFILE || exit
1330 # this function should exit early if package can't be built for this arch
1331 # this avoids unneccessary BR filling.
1334 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1336 if [ $ret -ne 0 ]; then
1345 update_shell_title "build_package"
1346 if [ -n "$DEBUG" ]; then
1353 if [ -n "$TRY_UPGRADE" ]; then
1354 update_shell_title "build_package: try_upgrade"
1355 if [ -n "$FLOAT_VERSION" ]; then
1356 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1358 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1361 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1363 if [ -n "$TNEWVER" ]; then
1364 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1365 echo "New version found, updating spec file to version " $TNEWVER
1366 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1367 cp -f $SPECFILE $SPECFILE.bak
1370 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1371 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1373 NODIST="yes" get_files $SOURCES $PATCHES
1376 unset TOLDVER TNEWVER TNOTIFY
1383 BUILD_SWITCH="-ba" ;;
1385 BUILD_SWITCH="-bb" ;;
1387 BUILD_SWITCH="-bs --nodeps" ;;
1389 BUILD_SWITCH="-bp --nodeps" ;;
1391 BUILD_SWITCH="-bc" ;;
1393 BUILD_SWITCH="-bi" ;;
1395 BUILD_SWITCH="-bl" ;;
1399 update_shell_title "build_package: $COMMAND"
1400 if [ -n "$LOGFILE" ]; then
1401 LOG=`eval echo $LOGFILE`
1402 if [ -d "$LOG" ]; then
1403 echo "Log file $LOG is a directory."
1404 echo "Parse error in the spec?"
1405 Exit_error err_build_fail
1407 if [ -n "$LASTLOG_FILE" ]; then
1408 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1410 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1412 (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1413 RETVAL=`cat $RES_FILE`
1415 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1416 if [ "$RETVAL" -eq "0" ]; then
1423 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $SPECFILE
1426 if [ "$RETVAL" -ne "0" ]; then
1427 if [ -n "$TRY_UPGRADE" ]; then
1428 echo "\n!!! Package with new version cannot be built automagically\n"
1429 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1430 mv -f $SPECFILE.bak $SPECFILE
1433 Exit_error err_build_fail
1440 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1443 install_required_packages()
1450 # taken from find-spec-bcond, but with just getting the list
1453 /^%changelog/ { exit }
1454 /_with(out)?_[_a-zA-Z0-9]+/{
1455 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1456 print substr($0, RSTART, RLENGTH);
1459 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1460 bcond = substr($0, RSTART +5 , RLENGTH -5);
1461 gsub(/[ \t]+/,"_",bcond);
1463 }' $SPEC | LC_ALL=C sort -u
1467 # expand bconds from ~/.bcondrc
1468 # The file structure is like gentoo's package.use:
1471 # samba -mysql -pgsql
1472 # w32codec-installer license_agreement
1475 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1481 SN=${SPECFILE%%\.spec}
1483 local bcondrc=$HOME/.bcondrc
1484 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1486 local bcond_avail=$(find_spec_bcond $SPECFILE)
1488 while read pkg flags; do
1490 [[ "$pkg" == \#* ]] && continue
1492 # any package or current package?
1493 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1494 for flag in $flags; do
1495 local opt=${flag#[+-]}
1497 # use only flags which are in this package.
1498 if [[ $bcond_avail = *${opt}* ]]; then
1499 if [[ $flag = -* ]]; then
1500 if [[ $BCOND != *--with?${opt}* ]]; then
1501 BCOND="$BCOND --without $opt"
1504 if [[ $BCOND != *--without?${opt}* ]]; then
1505 BCOND="$BCOND --with $opt"
1512 update_shell_title "parse ~/.bcondrc: DONE!"
1517 update_shell_title "set bcond values"
1519 AVAIL_BCONDS_WITHOUT=""
1520 AVAIL_BCONDS_WITH=""
1521 if `grep -q ^%bcond ${SPECFILE}`; then
1523 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1529 local bcond_avail=$(find_spec_bcond $SPECFILE)
1530 process_bcondrc "$SPECFILE"
1532 update_shell_title "parse bconds"
1533 case "${BCOND_VERSION}" in
1538 echo "Warning: This spec has old style bconds. Fix it || die."
1539 for opt in `echo "$bcond_avail" | grep ^_without_`
1541 AVAIL_BCOND_WITHOUT=${opt#_without_}
1542 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1543 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1545 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1549 for opt in `echo "$bcond_avail" | grep ^_with_`
1551 AVAIL_BCOND_WITH=${opt#_with_}
1552 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1553 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1555 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1560 local cond_type="" # with || without
1561 for opt in $bcond_avail; do
1570 AVAIL_BCOND_WITHOUT=${opt#_without_}
1571 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1572 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1574 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1578 AVAIL_BCOND_WITH=${opt#_with_}
1579 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1580 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1582 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1586 case "$cond_type" in
1589 AVAIL_BCOND_WITH="$opt"
1590 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1591 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1593 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1598 AVAIL_BCOND_WITHOUT="$opt"
1599 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1600 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1602 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1616 update_shell_title "run_sub_builder $package_name"
1618 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1619 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1620 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1621 # jakby nie bylo tego kawalka kodu.
1623 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1624 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1628 # kurwa. translate that ^^^^
1632 # Istnieje taki spec? ${package}.spec
1633 if [ -f "${SPEC_DIR}/${package}.spec" ]; then
1634 parent_spec_name=${package}.spec
1635 elif [ -f "${SPEC_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1636 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1638 for provides_line in $(grep -r ^Provides:.*$package ${SPEC_DIR}); do
1643 if [ "${parent_spec_name}" != "" ]; then
1644 spawn_sub_builder $parent_spec_name
1646 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1652 update_shell_title "spawn_sub_builder $package_name"
1655 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1656 sub_builder_opts="${sub_builder_opts} -R"
1658 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1659 sub_builder_opts="${sub_builder_opts} -RB"
1660 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1661 sub_builder_opts="${sub_builder_opts} -FRB"
1663 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1664 sub_builder_opts="${sub_builder_opts} -Upi"
1668 ./builder ${sub_builder_opts} "$@"
1671 remove_build_requires()
1673 if [ "$INSTALLED_PACKAGES" != "" ]; then
1674 case "$REMOVE_BUILD_REQUIRES" in
1676 run_poldek --noask -ve $INSTALLED_PACKAGES
1679 run_poldek --ask -ve $INSTALLED_PACKAGES
1682 echo You may want to manually remove following BuildRequires fetched:
1683 echo $INSTALLED_PACKAGES
1684 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1692 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1693 if [ "$BCOND" != "" ]; then
1694 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1697 echo -ne "\nNo conditional flags passed"
1699 echo -ne "\n\nfrom available:\n"
1700 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1706 if [ "$NOCVSSPEC" != "yes" ]; then
1707 echo -ne "Available branches: "
1708 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1712 # checks a given list of packages/files/provides agains current rpmdb.
1713 # outputs all dependencies which current rpmdb doesn't satisfy.
1714 # input can be either STDIN or parameters
1719 if [ $# -gt 0 ]; then
1725 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1728 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1730 # other deps (files)
1731 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1734 # checks if given package/files/provides exists in rpmdb.
1735 # input can be either stdin or parameters
1736 # returns packages which are present in the rpmdb
1741 if [ $# -gt 0 ]; then
1747 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1750 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1751 install_build_requires_rpmdeps() {
1752 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1753 # TODO: Conflicts list doesn't check versions
1754 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1755 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1757 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1758 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1759 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1762 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1763 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1764 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1765 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1767 if [ -n "$CNFL" ]; then
1768 update_shell_title "uninstall conflicting packages: $CNFL"
1769 echo "Trying to uninstall conflicting packages ($CNFL):"
1770 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1773 while [ "$DEPS" ]; do
1774 update_shell_title "install deps: $DEPS"
1775 echo "Trying to install dependencies ($DEPS):"
1776 local log=.${SPECFILE}_poldek.log
1777 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1778 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1781 if [ -n "$failed" ]; then
1782 for package in $failed; do
1783 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1792 fetch_build_requires()
1794 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1798 update_shell_title "fetch build requires"
1799 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1800 install_build_requires_rpmdeps
1804 # XXX is this ugliest code written in human history still needed?
1805 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1806 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1807 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1808 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1809 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1810 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)
1812 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)
1814 package=$(basename "$package_item"|sed -e "s/}$//g")
1815 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1818 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1819 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1820 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
1825 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1828 if `echo $COND_TST|grep -q 'without_'`; then
1829 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1830 if `echo $COND_TST|grep -q !`; then
1835 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1836 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1837 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1843 elif `echo $COND_TST|grep -q 'with_'`; then
1844 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1845 if `echo $COND_TST|grep -q !`; then
1850 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1851 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1852 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1858 RESULT="${COND_STATE}-${COND_ARGV}"
1860 "with-wout" | "wout-with" )
1863 "wout-wout" | "with-with" )
1867 echo "Action '$RESULT' was not defined for package '$package_item'"
1873 if [ "$GO" = "yes" ]; then
1874 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1875 echo "Testing if $package has subrequirements..."
1876 run_poldek -t -i $package --dumpn=".$package-req.txt"
1877 if [ -f ".$package-req.txt" ]; then
1878 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1880 if [ "$package_name" = "$package" ]; then
1881 echo -ne "Installing BuildRequired package:\t$package_name\n"
1882 update_shell_title "Installing BuildRequired package: ${package_name}"
1883 install_required_packages $package
1885 echo -ne "Installing (sub)Required package:\t$package_name\n"
1886 update_shell_title "Installing (sub)Required package: ${package_name}"
1887 install_required_packages $package_name
1891 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1892 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1895 echo "Attempting to run spawn sub - builder..."
1896 echo -ne "Package installation failed:\t$package_name\n"
1897 run_sub_builder $package_name
1898 if [ $? -eq 0 ]; then
1899 install_required_packages $package_name
1902 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1903 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1906 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1913 rm -f ".$package-req.txt"
1915 echo "Attempting to run spawn sub - builder..."
1916 echo -ne "Package installation failed:\t$package\n"
1917 run_sub_builder $package
1918 if [ $? -eq 0 ]; then
1919 install_required_packages $package
1922 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1923 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1926 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1932 echo "Package $package is already installed. BuildRequirement satisfied."
1936 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1937 echo >&2 "Unable to install following packages and their dependencies:"
1938 for pkg in "$NOT_INSTALLED_PACKAGES"
1942 remove_build_requires
1948 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1949 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1951 echo "Initialising rpm directories to $TOP_DIR from $CVSROOT"
1952 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1954 cvs -d $CVSROOT co SOURCES/{.cvsignore,dropin} SPECS/{mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1958 echo "To checkout *all* .spec files:"
1959 echo "- remove $SPEC_DIR/CVS/Entries.Static"
1960 echo "- run cvs up in $SPEC_DIR dir"
1963 echo "To commit with your developer account:"
1964 echo "- edit $SPEC_DIR/CVS/Root"
1965 echo "- edit $SOURCE_DIR/CVS/Root"
1968 get_greed_sources() {
1969 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1970 if [ -n "BE_VERBOSE" ]; then
1971 echo "Try greed download: $1 from: $CVSROOT"
1973 cvs -d $CVSROOT get SOURCES/$1
1974 if [ $? != 0 ]; then
1975 Exit_error err_no_source_in_repo $1
1980 # remove entries from CVS/Entries
1981 cvs_entry_remove() {
1982 local cvsdir="$1"; shift
1983 if [ ! -d "$cvsdir" ]; then
1984 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1988 for file in "$@"; do
1989 rm -f $cvsdir/CVS/Entries.new || return 1
1990 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1991 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1999 DONT_PRINT_REVISION="yes"
2003 # remove from CVS/Entries
2004 cvs_entry_remove $SPEC_DIR $SPECFILE
2005 cvs_entry_remove $SOURCE_DIR $SOURCES $PATCHES
2007 # remove spec and sources
2008 $RPMBUILD --clean --rmsource --rmspec --nodeps $SPECFILE
2011 #---------------------------------------------
2019 while [ $# -gt 0 ]; do
2022 COMMAND="update_md5"
2027 COMMAND="update_md5"
2037 DEBUG="yes"; shift ;;
2039 COMMAND="version"; shift ;;
2041 COMMAND="short-version"; shift ;;
2043 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
2044 -b | -ba | --build )
2045 COMMAND="build"; shift ;;
2046 -bb | --build-binary )
2047 COMMAND="build-binary"; shift ;;
2049 COMMAND="build-build"; shift ;;
2051 COMMAND="build-install"; shift ;;
2053 COMMAND="build-list"; shift ;;
2054 -bp | --build-prep )
2055 COMMAND="build-prep"; shift ;;
2056 -bs | --build-source )
2057 COMMAND="build-source"; shift ;;
2059 COMMAND="branch"; shift; TAG="${1}"; shift;;
2061 CLEAN="--clean --rmspec --rmsource"; shift ;;
2063 CVS_FORCE="-F"; shift;;
2065 shift; CVSROOT="${1}"; shift ;;
2067 COMMAND="get"; shift ;;
2069 COMMAND="usage"; shift ;;
2071 PROTOCOL="http"; shift ;;
2073 shift; LOGFILE="${1}"; shift ;;
2075 shift; DEF_NICE_LEVEL=${1}; shift ;;
2076 -ske | --skip-existing-files)
2077 SKIP_EXISTING_FILES="yes"; shift ;;
2079 COMMAND="mr-proper"; shift ;;
2081 NOCVS="yes"; shift ;;
2082 -ncs | --no-cvs-specs )
2083 NOCVSSPEC="yes"; shift ;;
2084 -nd | --no-distfiles )
2085 NODIST="yes"; shift ;;
2086 -nm | --no-mirrors )
2087 NOMIRRORS="yes"; shift ;;
2089 NOURLS="yes"; shift ;;
2091 NOSRCS="yes"; shift ;;
2092 -ns0 | --no-source0 )
2093 NOSOURCE0="yes"; shift ;;
2103 -pm | --prefer-mirrors )
2110 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2112 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2114 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2117 --with | --without )
2118 case $GROUP_BCONDS in
2122 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2123 while ! `echo ${1}|grep -qE '(^-|spec)'`
2125 BCOND="$BCOND $COND $1"
2129 if [[ "$2" = *,* ]]; then
2130 for a in $(echo "$2" | tr , ' '); do
2131 BCOND="$BCOND $1 $a"
2134 BCOND="$BCOND $1 $2"
2140 shift; TARGET="${1}"; shift ;;
2142 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2144 QUIET="--quiet"; shift ;;
2146 CVSDATE="${2}"; shift 2 ;;
2155 -R | --fetch-build-requires)
2156 FETCH_BUILD_REQUIRES="yes"
2157 NOT_INSTALLED_PACKAGES=
2159 -RB | --remove-build-requires)
2160 REMOVE_BUILD_REQUIRES="nice"
2162 -FRB | --force-remove-build-requires)
2163 REMOVE_BUILD_REQUIRES="force"
2165 -sc | --sources-cvs)
2166 COMMAND="list-sources-cvs"
2168 -sd | --sources-distfiles)
2169 COMMAND="list-sources-distfiles"
2171 -sdp | --sources-distfiles-paths)
2172 COMMAND="list-sources-distfiles-paths"
2174 -sf | --sources-files)
2175 COMMAND="list-sources-files"
2177 -sp | --sources-paths)
2178 COMMAND="list-sources-local-paths"
2180 -su | --sources-urls)
2181 COMMAND="list-sources-urls"
2183 -Tvs | --tag-version-stable )
2188 -Ts | --tag-stable )
2193 -Tv | --tag-version )
2198 -Tp | --tag-prefix )
2210 -ir | --integer-release-only )
2211 INTEGER_RELEASE="yes"
2214 COMMAND="update_md5"
2219 -Upi | --update-poldek-indexes )
2220 UPDATE_POLDEK_INDEXES="yes"
2223 COMMAND="init_rpm_dir"
2225 --use-greed-sources )
2228 -u | --try-upgrade )
2229 TRY_UPGRADE="1"; shift ;;
2230 -un | --try-upgrade-with-float-version )
2231 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2233 BE_VERBOSE="1"; shift ;;
2238 if echo "${MACRO}" | grep -q '\W'; then
2239 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2243 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2248 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2252 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2255 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2256 COMMAND="show_bconds"
2260 COMMAND="show_bcond_args"
2265 RPMOPTS="${RPMOPTS} --nodeps"
2268 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2271 Exit_error err_invalid_cmdline "$1"
2275 # check if specname was passed as specname:cvstag
2276 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2277 CVSTAG="${SPECFILE##*:}"
2278 SPECFILE="${SPECFILE%%:*}"
2280 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2285 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2286 CVSTAG=$(awk -vSPECFILE=$(basename ${SPECFILE%.spec}.spec) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2287 if [ "$CVSTAG" ]; then
2288 echo >&2 "builder: Stick tag $CVSTAG active. Use -r TAGNAME to override."
2290 elif [ "$CVSTAG" = "HEAD" ]; then
2291 # assume -r HEAD is same as -A
2295 if [ "$CVSTAG" ]; then
2296 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2297 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2300 if [ -n "$DEBUG" ]; then
2305 if [ -n "$TARGET" ]; then
2308 TARGET_SWITCH="--target $TARGET" ;;
2310 TARGET_SWITCH="--target=$TARGET" ;;
2314 if [ "$SCHEDTOOL" != "no" ]; then
2315 NICE_COMMAND="$SCHEDTOOL"
2317 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2320 update_shell_title "$COMMAND"
2324 if [ -n "$SPECFILE" ]; then
2325 get_spec > /dev/null
2333 if [ -n "$SPECFILE" ]; then
2334 get_spec > /dev/null
2340 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2342 if [ -n "$SPECFILE" ]; then
2348 if [ "$COMMAND" != "build-source" ]; then
2351 fetch_build_requires
2352 if [ "$INTEGER_RELEASE" = "yes" ]; then
2353 echo "Checking release $PACKAGE_RELEASE..."
2354 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2355 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2359 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2360 if [ -n "$TEST_TAG" ]; then
2361 local TAGVER=`make_tagver`
2362 echo "Searching for tag $TAGVER..."
2363 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2364 if [ -n "$TAGREL" ]; then
2365 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2368 # - do not allow to build from HEAD when XX-branch exists
2369 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2370 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2371 TAG_BRANCH="${TREE_PREFIX}-branch"
2372 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2373 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2374 Exit_error err_branch_exists "$TAG_STATUS"
2380 if [ -n "$NOSOURCE0" ] ; then
2381 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2383 get_files $SOURCES $PATCHES
2386 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2387 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2389 remove_build_requires
2391 Exit_error err_no_spec_in_cmdl
2396 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 branch_files $TAG $SOURCES $PATCHES $ICONS
2410 Exit_error err_no_spec_in_cmdl
2415 if [ -n "$SPECFILE" ]; then
2419 if [ -n "$NOSOURCE0" ] ; then
2420 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2422 get_files $SOURCES $PATCHES
2425 Exit_error err_no_spec_in_cmdl
2430 if [ -n "$SPECFILE" ]; then
2434 if [ -n "$NOSOURCE0" ] ; then
2435 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2439 Exit_error err_no_spec_in_cmdl
2446 if [ -n "$SPECFILE" ]; then
2450 # don't fetch sources from remote locations
2452 for file in $SOURCES; do
2453 [ -n "`src_md5 $file`" ] && continue
2454 new_SOURCES="$new_SOURCES $file"
2456 SOURCES="$new_SOURCES"
2457 get_files $SOURCES $PATCHES
2459 tag_files $SOURCES $PATCHES $ICONS
2461 Exit_error err_no_spec_in_cmdl
2467 "list-sources-files" )
2470 DONT_PRINT_REVISION="yes"
2473 for SAP in $SOURCES $PATCHES; do
2474 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2477 "list-sources-urls" )
2480 DONT_PRINT_REVISION="yes"
2483 SAPS="$SOURCES $PATCHES"
2484 for SAP in $SAPS ; do
2488 "list-sources-local-paths" )
2491 DONT_PRINT_REVISION="yes"
2494 for SAP in $SOURCES $PATCHES; do
2495 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2498 "list-sources-distfiles-paths" )
2501 DONT_PRINT_REVISION="yes"
2504 for SAP in $SOURCES $PATCHES; do
2505 if [ -n "$(src_md5 "$SAP")" ]; then
2506 distfiles_path "$SAP"
2510 "list-sources-distfiles" )
2513 DONT_PRINT_REVISION="yes"
2516 for SAP in $SOURCES $PATCHES; do
2517 if [ -n "$(src_md5 "$SAP")" ]; then
2518 distfiles_url "$SAP"
2522 "list-sources-cvs" )
2525 DONT_PRINT_REVISION="yes"
2528 for SAP in $SOURCES $PATCHES; do
2529 if [ -z "$(src_md5 "$SAP")" ]; then
2530 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2544 echo "$VERSIONSTRING"
2547 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2548 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2552 # vi:syntax=sh:ts=4:sw=4:noet