3 # This program is free software, distributed under the terms of
4 # the GNU General Public License Version 2.
10 # 2 - no spec file name in cmdl parameters
11 # 3 - spec file not stored in repo
12 # 4 - some source, patch or icon files not stored in repo
13 # 5 - package build failed
14 # 6 - spec file with errors
15 # 7 - wrong source in /etc/poldek.conf
16 # 8 - Failed installing buildrequirements and subrequirements
17 # 9 - Requested tag already exist
18 # 10 - Refused to build fractional release
19 # 100 - Unknown error (should not happen)
22 # - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
23 # - when Icon: field is present, -5 and -a5 doesn't work
24 # - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
26 # - ability to do ./builder -bb foo.spec foo2.spec foo3.spec
33 Build package utility from PLD Linux CVS repository
34 $VERSION (C) 1999-2009 Free Penguins".
36 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
55 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
59 # use rpm 4.4.6+ digest format instead of comments if non-zero
62 # user agent when fetching files
63 USER_AGENT="PLD/Builder($VERSION)"
65 # It can be used i.e. in log file naming.
66 # See LOGFILE example.
67 DATE=`date +%Y-%m-%d_%H-%M-%S`
69 # Example: LOGFILE='../log.$PACKAGE_NAME'
70 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
71 # Yes, you can use variable name! Note _single_ quotes!
95 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
97 CVS_COMMAND=${CVS_COMMAND:-cvs}
100 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
101 CVS_SERVER="cvs.pld-linux.org"
106 DISTFILES_SERVER="://distfiles.pld-linux.org"
107 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
112 FAIL_IF_NO_SOURCES="yes"
114 # let get_files skip over files which are present to get those damn files fetched
115 SKIP_EXISTING_FILES="no"
118 # should the specfile be restored if upgrade failed?
119 REVERT_BROKEN_UPGRADE="yes"
121 if rpm --specsrpm 2>/dev/null; then
122 FETCH_BUILD_REQUIRES_RPMSPECSRPM="yes"
123 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
125 FETCH_BUILD_REQUIRES_RPMSPECSRPM="no"
126 if [ -x /usr/bin/rpm-getdeps ]; then
127 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
129 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
134 # Here we load saved user environment used to
135 # predefine options set above, or passed to builder
137 # This one reads global system environment settings:
138 if [ -f ~/etc/builderrc ]; then
141 # And this one cascades settings using user personal
143 # Example of ~/.builderrc:
145 #UPDATE_POLDEK_INDEXES="yes"
146 #FETCH_BUILD_REQUIRES="yes"
147 #REMOVE_BUILD_REQUIRES="force"
149 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
153 if [ -n "$HOME_ETC" ]; then
154 USER_CFG="$HOME_ETC/.builderrc"
155 BUILDER_MACROS="$HOME_ETC/.builder-rpmmacros"
157 USER_CFG=~/.builderrc
158 BUILDER_MACROS=~/.builder-rpmmacros
161 [ -f "$USER_CFG" ] && . "$USER_CFG"
163 if [ "$SCHEDTOOL" = "auto" ]; then
164 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
165 SCHEDTOOL="schedtool -B -e"
171 if [ -n "$USE_PROZILLA" ]; then
172 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
175 elif [ -n "$USE_AXEL" ]; then
176 GETURI="axel -a $AXEL_OPTS"
180 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
181 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
182 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
183 WGET_OPTS="$WGET_OPTS --user-agent=$USER_AGENT"
185 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
186 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
192 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
201 # are we using cvs-nserver ?
204 $CVS_COMMAND --version 2>&1 | grep -q 'CVS-nserver'
205 [ $? -eq 0 ] && CVS_NSERVER=1
207 POLDEK_INDEX_DIR="$($RPM --eval %_rpmdir)/"
208 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 #---------------------------------------------
230 if [ -n "$DEBUG" ]; then set -xv; fi
232 Usage: builder [-D|--debug] [-V|--version] [--short-version] [-a|--as_anon] [-b|-ba|--build]
233 [-bb|--build-binary] [-bs|--build-source] [-bc] [-bi] [-bl] [-u|--try-upgrade]
234 [{-cf|--cvs-force}] [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>]
235 [-g|--get] [-h|--help] [--http] [{-l|--logtofile} <logfile>] [-m|--mr-proper]
236 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T|--tag <cvstag>]
237 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
238 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] [--use-greed-sources]
239 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--short-circuit]
240 [--show-bconds] [--with/--without <feature>] [--define <macro> <value>]
241 <package>[.spec][:cvstag]
243 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
244 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
245 -n5, --no-md5 - ignore md5 comments in spec
246 -D, --debug - enable builder script debugging mode,
247 -debug - produce rpm debug package (same as --opts -debug)
248 -V, --version - output builder version string
249 --short-version - output builder short version
250 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
251 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
253 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
254 only package from <package>.spec,
255 -bp, --build-prep - execute the %prep phase of <package>.spec,
256 -bc - execute the %build phase of <package>.spec,
257 -bi - execute the %install phase of <package>.spec
258 -bl - execute the %files phase of <package>.spec
259 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
261 --short-circuit - short-circuit build
262 -B, --branch - add branch
263 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
264 SPECS and \$RPM_BUILD_ROOT and CVS/Entries) after rpmbuild commands.
265 -m, --mr-proper - clean all temporarily created files (in BUILD, SOURCES,
266 SPECS and \$RPM_BUILD_ROOT and CVS/Entries). Doesn't run
268 -cf, --cvs-force - use -F when tagging (useful when moving branches)
269 -d <cvsroot>, --cvsroot <cvsroot>
271 --define <macro> <value>
272 - define a macro <macro> with value <value>,
273 --alt_kernel <kernel>
274 - same as --define 'alt_kernel <kernel>'
275 --nodeps - rpm won't check any dependences
276 -g, --get - get <package>.spec and all related files from CVS repo
278 -h, --help - this message,
279 --http - use http instead of ftp,
280 -l <logfile>, --logtofile <logfile>
282 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
284 - don't check specs in CVS
285 -nd, --no-distfiles - don't download from distfiles
286 -nm, --no-mirrors - don't download from mirror, if source URL is given,
287 -nu, --no-urls - don't try to download from FTP/HTTP location,
288 -ns, --no-srcs - don't download Sources
289 -ns0, --no-source0 - don't download Source0
290 -nn, --no-net - don't download anything from the net
291 -pm, --prefer-mirrors - prefer mirrors (if any) over distfiles for SOURCES
292 --no-init - don't initialize builder paths (SPECS and SOURCES)
294 --skip-existing-files - skip existing files in get_files
295 --opts <rpm opts> - additional options for rpm
296 -q, --quiet - be quiet,
297 --date yyyy-mm-dd - build package using resources from specified CVS date,
298 -r <cvstag>, --cvstag <cvstag>
299 - build package using resources from specified CVS tag,
300 -A - build package using CVS resources as any sticky tags/date/kopts being reset.
301 -R, --fetch-build-requires
302 - fetch what is BuildRequired,
303 -RB, --remove-build-requires
304 - remove all you fetched with -R or --fetch-build-requires
305 remember, this option requires confirmation,
306 -FRB, --force-remove-build-requires
307 - remove all you fetched with -R or --fetch-build-requires
308 remember, this option works without confirmation,
309 -sd, --source-distfiles - list sources available from distfiles (intended for offline
310 operations; does not work when Icon field is present
311 but icon file is absent),
312 -sc, --source-cvs - list sources available from CVS
313 -sdp, --source-distfiles-paths - list sources available from distfiles -
314 paths relative to distfiles directory (intended for offline
315 operations; does not work when Icon field is present
316 but icon file is absent),
317 -sf, --source-files - list sources - bare filenames (intended for offline
318 operations; does not work when Icon field is present
319 but icon file is absent),
320 -sp, --source-paths - list sources - filenames with full local paths (intended for
321 offline operations; does not work when Icon field is present
322 but icon file is absent),
323 -su, --source-urls - list urls - urls to sources and patches
324 intended for copying urls with spec with lots of macros in urls
325 -T <cvstag> , --tag <cvstag>
326 - add cvs tag <cvstag> for files,
327 -Tvs, --tag-version-stable
328 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
330 - add cvs tag STABLE for files,
332 - add cvs tag NAME-VERSION-RELEASE for files,
333 -Tp, --tag-prefix <prefix>
334 - add <prefix> to NAME-VERSION-RELEASE tags,
335 -tt, --test-tag <prefix>
336 - fail if tag is already present,
337 -ir, --integer-release-only
338 - allow only integer and snapshot releases
339 -v, --verbose - be verbose,
340 -u, --try-upgrade - check version, and try to upgrade package
341 -un, --try-upgrade-with-float-version
342 - as above, but allow float version
344 - try download source from tag head if don't find it in
346 -U, --update - refetch sources, don't use distfiles, and update md5 comments
347 -Upi, --update-poldek-indexes
348 - refresh or make poldek package index files.
349 -np, --nopatch <patchnumber>
350 - don't apply <patchnumber>
351 --show-bconds - show available conditional builds, which can be used
352 - with --with and/or --without switches.
353 --show-bcond-args - show active bconds, from ~/.bcondrc. this is used by
354 ./repackage.sh script. in other words, the output is
355 parseable by scripts.
356 --with/--without <feature>
357 - conditional build package depending on %_with_<feature>/
358 %_without_<feature> macro switch. You may now use
359 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
360 constructions. Set GROUP_BCONDS to yes to make use of it.
361 --target <platform>, --target=<platform>
362 - build for platform <platform>.
363 --init-rpm-dir - initialize ~/rpm directory structure
367 # change dependency to specname
369 # - perl(Package::Name) -> perl-Package-Name
373 package=$(echo "$package" | sed -e '/perl(.*)/{s,perl(\(.*\)),perl-\1,;s,::,-,g}')
377 update_shell_title() {
379 local len=${COLUMNS:-80}
380 local msg=$(echo "$*" | cut -c-$len)
382 if [ -n "$BE_VERBOSE" ]; then
383 echo >&2 "$(date +%s.%N) $*"
386 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
388 if [ -n "$PACKAGE_NAME" ]; then
389 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
394 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
395 msg=$(echo $msg | tr -d '\n\r')
398 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
401 echo >&2 -ne "\033]0;$msg\007"
407 # set TARGET from BuildArch: from SPECFILE
409 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
410 tmp=$(awk '/^BuildArch:/ { print $NF}' $ASSUMED_NAME/$SPECFILE)
412 target_platform=$(rpm -E '%{_target_vendor}-%{_target_os}%{?_gnu}')
416 TARGET_SWITCH="--target ${TARGET}-${target_platform}" ;;
418 TARGET_SWITCH="--target=$TARGET" ;;
424 # runs rpm with minimal macroset
426 # we reset macros not to contain macros.build as all the %() macros are
427 # executed here, while none of them are actually needed.
428 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
429 safe_macrofiles=$(rpm $TARGET_SWITCH --showrc | awk -F: '/^macrofiles/ { gsub(/^macrofiles[ \t]+:/, "", $0); gsub(/:.*macros.build:/, ":", $0); print $0 } ')
431 # TODO: move these to /usr/lib/rpm/macros
432 cat > $BUILDER_MACROS <<'EOF'
433 %x8664 x86_64 amd64 ia32e
436 %requires_releq_kernel_up %{nil}
437 %requires_releq_kernel_smp %{nil}
438 %requires_releq_kernel %{nil}
439 %requires_releq() %{nil}
440 %pyrequires_eq() %{nil}
441 %requires_eq() %{nil}
442 %requires_eq_to() %{nil}
443 %releq_kernel_up ERROR
444 %releq_kernel_smp ERROR
449 %ruby_ver_requires_eq() %{nil}
450 %ruby_mod_ver_requires_eq() %{nil}
451 %__php_api_requires() %{nil}
452 %php_major_version ERROR
453 %php_api_version ERROR
454 %requires_xorg_xserver_extension %{nil}
455 %requires_xorg_xserver_xinput %{nil}
456 %requires_xorg_xserver_font %{nil}
457 %requires_xorg_xserver_videodrv %{nil}
459 %perl_vendorarch ERROR
460 %perl_vendorlib ERROR
461 # damn. need it here! - copied from /usr/lib/rpm/macros.build
462 %tmpdir %(echo "${TMPDIR:-/tmp}")
463 %patchset_source(f:b:) %(
464 base=%{-b*}%{!-b*:10000};
465 start=$(expr $base + %1);
466 end=$(expr $base + %{?2}%{!?2:%{1}});
467 # we need to call seq twice as it doesn't allow two formats
468 seq -f 'Patch%g:' $start $end > %{tmpdir}/__ps1;
469 seq -f '%{-f*}' %1 %{?2}%{!?2:%{1}} > %{tmpdir}/__ps2;
470 paste %{tmpdir}/__ps{1,2};
471 rm -f %{tmpdir}/__ps{1,2};
474 %add_etc_shells(p) %{p:<lua>}
475 %remove_etc_shells(p) %{p:<lua>}
476 %lua_add_etc_shells() %{nil}
477 %lua_remove_etc_shells() %{nil}
479 if [ "$NOINIT" = "yes" ] ; then
480 cat >> $BUILDER_MACROS <<'EOF'
485 eval $RPMBUILD $TARGET_SWITCH --macros "$safe_macrofiles:$BUILDER_MACROS" $QUIET $RPMOPTS $RPMBUILDOPTS $BCOND $* 2>&1
489 if [ -n "$DEBUG" ]; then
494 if [ -x /usr/bin/rpm-specdump ]; then
495 update_shell_title "cache_rpm_dump using rpm-specdump command"
496 rpm_dump_cache=$(rpm-specdump $TARGET_SWITCH $BCOND $SPECFILE)
498 update_shell_title "cache_rpm_dump using rpmbuild command"
501 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
502 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
508 ARGS='--nodigest --nosignature --nobuild'
511 minirpm $ARGS --define "'prep $dump'" --nodeps $SPECFILE
513 if [ $? -gt 0 ]; then
514 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
516 Exit_error err_build_fail
519 # make small dump cache
520 rpm_dump_cache=`echo "$rpm_dump" | awk '
521 $2 ~ /^SOURCEURL/ {print}
522 $2 ~ /^PATCHURL/ {print}
523 $2 ~ /^nosource/ {print}
524 $2 ~ /^PACKAGE_/ {print}
528 update_shell_title "cache_rpm_dump: OK!"
532 if [ -z "$rpm_dump_cache" ] ; then
533 echo >&2 "internal error: cache_rpm_dump not called! (missing %prep?)"
535 echo "$rpm_dump_cache"
539 update_shell_title "get icons"
540 ICONS=$(awk '/^Icon:/ {print $2}' ${ASSUMED_NAME}/${SPECFILE})
541 if [ -z "$ICONS" ]; then
545 rpm_dump_cache="kalasaba" NODIST="yes" get_files $ICONS
549 update_shell_title "parsing specfile"
550 if [ -n "$DEBUG" ]; then
555 # icons are needed for successful spec parse
561 if [ "$NOSRCS" != "yes" ]; then
562 SOURCES=$(rpm_dump | awk '$2 ~ /^SOURCEURL[0-9]+/ {print substr($2, length("SOURCEURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
565 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
566 FAIL_IF_NO_SOURCES="no"
569 PATCHES=$(rpm_dump | awk '$2 ~ /^PATCHURL[0-9]+/ {print substr($2, length("PATCHURL") + 1), $3}' | LC_ALL=C sort -n | awk '{print $2}')
570 ICONS=$(awk '/^Icon:/ {print $2}' ${SPECFILE})
571 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3; exit}')
572 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3; exit}')
573 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3; exit}')
575 if [ "$PACKAGE_NAME" != "$ASSUMED_NAME" ]; then
576 echo >&2 "WARNING! Spec name ($ASSUMED_NAME) does not agree with package name ($PACKAGE_NAME)"
579 if [ -n "$BE_VERBOSE" ]; then
580 echo "- Sources : `nourl $SOURCES`"
581 if [ -n "$PATCHES" ]; then
582 echo "- Patches : `nourl $PATCHES`"
584 echo "- Patches : *no patches needed*"
586 if [ -n "$ICONS" ]; then
587 echo "- Icon : `nourl $ICONS`"
589 echo "- Icon : *no package icon*"
591 echo "- Name : $PACKAGE_NAME"
592 echo "- Version : $PACKAGE_VERSION"
593 echo "- Release : $PACKAGE_RELEASE"
596 update_shell_title "parse_spec: OK!"
600 if [ -n "$DEBUG" ]; then
608 "err_no_spec_in_cmdl" )
609 remove_build_requires
610 echo >&2 "ERROR: spec file name not specified."
612 "err_invalid_cmdline" )
613 echo >&2 "ERROR: invalid command line arg ($2)."
615 "err_no_spec_in_repo" )
616 remove_build_requires
617 echo >&2 "Error: spec file not stored in CVS repo."
619 "err_no_source_in_repo" )
620 remove_build_requires
621 echo >&2 "Error: some source, patch or icon files not stored in CVS repo. ($2)"
624 remove_build_requires
625 echo >&2 "Error: package build failed. (${2:-no more info})"
627 "err_no_package_data" )
628 remove_build_requires
629 echo >&2 "Error: couldn't get out package name/version/release from spec file."
632 remove_build_requires
633 echo >&2 "Tag ${2} already exists (spec release: ${3})."
636 remove_build_requires
637 echo >&2 "Release ${2} not integer and not a snapshot."
639 "err_branch_exists" )
640 remove_build_requires
641 echo >&2 "Tree branch already exists (${2})."
644 remove_build_requires
645 echo >&2 "Error: conditions reject building this spec (${2})."
648 echo >&2 "Unknown error."
653 if [ -n "$DEBUG" ]; then
658 if [ "$NOINIT" != "yes" ] ; then
659 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
660 REPO_DIR=$TOP_DIR/packages
661 PACKAGE_DIR=$TOP_DIR/packages/$ASSUMED_NAME
672 update_shell_title "get_spec"
674 if [ -n "$DEBUG" ]; then
680 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
681 SPECFILE="$(basename $SPECFILE .spec).spec"
683 if [ "$NOCVSSPEC" != "yes" ]; then
685 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
686 echo "Warning: No CVS access defined - using local .spec file"
690 if [ -d "$ASSUMED_NAME" ]; then
691 cvsup "$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
693 cvsup -c -d $ASSUMED_NAME "packages/$ASSUMED_NAME/$SPECFILE" || Exit_error err_no_spec_in_repo
695 # remove Entries.Static -- so 'cvs up' would update all files in a repo
696 rm "$ASSUMED_NAME/CVS/Entries.Static"
698 # create symlinks for tools
699 if [ "$SYMLINK_TOOLS" != "no" ]; then
700 for a in dropin md5 adapter builder {relup,compile,repackage}.sh; do
701 [ -f $a ] || continue
702 ln -s ../$a $ASSUMED_NAME
709 if [ ! -f "$ASSUMED_NAME/$SPECFILE" ]; then
710 Exit_error err_no_spec_in_repo
713 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
714 chmod $CHMOD_MODE $ASSUMED_NAME/$SPECFILE
717 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $ASSUMED_NAME/$SPECFILE
725 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
726 $CVS_COMMAND update mirrors >&2
730 local origin mirror name rest ol prefix
731 while read origin mirror name rest; do
732 # skip comments and empty lines
733 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
736 ol=$(echo -n "$origin" | wc -c)
737 prefix=$(echo -n "$url" | head -c $ol)
738 if [ "$prefix" = "$origin" ] ; then
739 suffix=$(echo "$url" | cut -b $((ol+1))-)
740 echo -n "$mirror$suffix"
747 # Warning: unpredictable results if same URL used twice
751 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
752 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
757 [ "$NO5" = "yes" ] && return
759 [ -z "$no" ] && return
763 if [ -f additional-md5sums ]; then
764 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
765 if [ -z "$spec_rev" ]; then
766 spec_rev=$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')
768 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
769 md5=$(grep -s -v '^#' additional-md5sums | \
770 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
771 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
772 grep -E '^[0-9a-f]{32}$')
775 if [ $(echo "$md5" | wc -l) != 1 ] ; then
776 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
778 echo "$md5" | tail -n 1
783 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
784 if [ -n "$source_md5" ]; then
787 source_md5=`grep -i "BuildRequires:[ ]*digest(%SOURCE$no)[ ]*=" $SPECFILE | sed -e 's/.*=//'`
788 if [ -n "$source_md5" ]; then
791 # we have empty SourceX-md5, but it is still possible
792 # that we have NoSourceX-md5 AND NoSource: X
793 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
794 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
802 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
806 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
809 distfiles_attic_url() {
810 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
816 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
820 size=$(find $(nourl "$1") -printf "%s" 2>/dev/null)
821 [ -n "$size" -a "$size" -gt 0 ]
825 if [ "$CVSIGNORE_DF" != "yes" ]; then
828 cvsignore=${PACKAGE_DIR}/.cvsignore
829 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
830 echo "$1" >> $cvsignore
835 update_shell_title "cvsup"
838 if [ "$1" = "-c" ]; then
842 if [ -n "$CVSROOT" ]; then
843 OPTIONS="-d $CVSROOT $OPTIONS"
846 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
847 OPTIONS="$OPTIONS -A"
849 if [ -n "$CVSDATE" ]; then
850 OPTIONS="$OPTIONS -D $CVSDATE"
852 if [ -n "$CVSTAG" ]; then
853 OPTIONS="$OPTIONS -r $CVSTAG"
858 local retries_counter=0
860 update_shell_title "cvsup: $*"
862 update_shell_title "cvsup: $# files"
864 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
865 retries_counter=$(( $retries_counter + 1 ))
866 output=$(LC_ALL=C $CVS_COMMAND $OPTIONS "$@" 2>&1)
868 [ -n "$output" ] && echo "$output"
869 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
870 echo "Trying again [$*]... ($retries_counter)"
871 update_shell_title "cvsup: retry #$retries_counter"
878 update_shell_title "cvsup: done!"
882 # returns true if "$1" is ftp, http or https protocol url
885 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[ ]*:' $PACKAGE_DIR/$SPECFILE && continue
914 grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_DIR/$SPECFILE && continue
916 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $PACKAGE_DIR/$SPECFILE || grep -qiE '^BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_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[ ]*:' $PACKAGE_DIR/$SPECFILE )
933 if [ -z "$md5" ]; then
934 md5=$(grep -iE '^[ ]*BuildRequires:[ ]*digest[(]%SOURCE'$srcno'[)][ ]*=' $PACKAGE_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+/;
949 $PACKAGE_DIR/$SPECFILE
955 [ "$NO5" = "yes" ] && return
957 update_shell_title "check md5"
960 if good_md5 "$i" && good_size "$i"; then
964 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
965 echo "or -5 to update md5 sums, if you're sure files are correct."
966 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_COMMAND status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
1206 if [ -n "$DEBUG" ]; then
1211 echo "Version: $PACKAGE_VERSION"
1212 echo "Release: $PACKAGE_RELEASE"
1215 if [ "$TAG_VERSION" = "yes" ]; then
1216 TAGVER=`make_tagver`
1217 echo "CVS tag: $TAGVER"
1219 if [ -n "$TAG" ]; then
1220 echo "CVS tag: $TAG"
1223 local OPTIONS="tag $CVS_FORCE"
1224 if [ -n "$CVSROOT" ]; then
1225 OPTIONS="-d $CVSROOT $OPTIONS"
1228 # if a tagname we are about to set already exists
1229 # and happens to be a branch (common case with AC-branch)
1230 # pass -B (allows -F to disturb branch tag)
1232 if [ "$TAG_VERSION" = "yes" ]; then
1235 is_tag_a_branch $_tag
1236 if [ $? -eq 0 -a $CVS_NSERVER -eq 0 ]; then
1237 OPTIONS="$OPTIONS -B"
1242 for i in $TAG_FILES; do
1243 # don't tag files stored on distfiles
1244 [ -n "`src_md5 $i`" ] && continue
1245 local fp=`nourl "$i"`
1246 if [ -f "$fp" ]; then
1247 tag_files="$tag_files $fp"
1248 elif [ -n "GREEDSRC" ]; then
1249 get_greed_sources $i
1251 Exit_error err_no_source_in_repo $i
1255 if [ "$tag_files" ]; then
1256 if [ "$TAG_VERSION" = "yes" ]; then
1257 update_shell_title "tag sources: $TAGVER"
1258 printf "Tagging %d files\n" $(echo $tag_files | wc -w)
1259 $CVS_COMMAND $OPTIONS $TAGVER $tag_files || exit
1261 if [ -n "$TAG" ]; then
1262 update_shell_title "tag sources: $TAG"
1264 while [ "$tag_files" ]; do
1265 local chunk=$(echo $tag_files | tr ' ' '\n' | head -n 100)
1266 printf "Tagging %d files\n" $(echo $chunk | wc -w)
1267 $CVS_COMMAND $OPTIONS $TAG $chunk || exit
1268 tag_files=$(echo $tag_files | tr ' ' '\n' | tail +101)
1274 if [ "$TAG_VERSION" = "yes" ]; then
1275 update_shell_title "tag spec: $TAGVER"
1276 $CVS_COMMAND $OPTIONS $TAGVER $SPECFILE || exit
1278 if [ -n "$TAG" ]; then
1279 update_shell_title "tag spec: $TAG"
1280 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1286 echo "CVS branch tag: $TAG"
1291 if [ -n "$DEBUG" ]; then
1296 local OPTIONS="tag $CVS_FORCE -b"
1299 is_tag_a_branch $TAG
1300 if [ $? -eq 1 ]; then
1301 OPTIONS="$OPTIONS -B"
1304 if [ -n "$CVSROOT" ]; then
1305 OPTIONS="-d $CVSROOT $OPTIONS"
1309 for i in $TAG_FILES; do
1310 local fp=`nourl "$i"`
1311 if [ -f "$fp" ]; then
1312 tag_files="$tag_files $fp"
1313 elif [ -n "GREEDSRC" ]; then
1314 get_greed_sources $i
1316 Exit_error err_no_source_in_repo $i
1319 if [ "$tag_files" ]; then
1320 $CVS_COMMAND $OPTIONS $TAG $tag_files || exit
1324 $CVS_COMMAND $OPTIONS $TAG $SPECFILE || exit
1328 # this function should exit early if package can't be built for this arch
1329 # this avoids unneccessary BR filling.
1332 out=$(minirpm --short-circuit -bp --define "'prep exit 0'" --nodeps $SPECFILE 2>&1)
1334 if [ $ret -ne 0 ]; then
1341 update_shell_title "build_package"
1342 if [ -n "$DEBUG" ]; then
1349 if [ -n "$TRY_UPGRADE" ]; then
1350 update_shell_title "build_package: try_upgrade"
1351 if [ -n "$FLOAT_VERSION" ]; then
1352 TNOTIFY=$(./pldnotify.awk $SPECFILE -n) || exit 1
1354 TNOTIFY=$(./pldnotify.awk $SPECFILE) || exit 1
1357 TNEWVER=$(echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }')
1359 if [ -n "$TNEWVER" ]; then
1360 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1361 echo "New version found, updating spec file to version " $TNEWVER
1362 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1363 cp -f $SPECFILE $SPECFILE.bak
1366 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1367 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1369 NODIST="yes" get_files $SOURCES $PATCHES
1372 unset TOLDVER TNEWVER TNOTIFY
1379 BUILD_SWITCH="-ba" ;;
1381 BUILD_SWITCH="-bb" ;;
1383 BUILD_SWITCH="-bs --nodeps" ;;
1385 BUILD_SWITCH="-bp --nodeps" ;;
1387 BUILD_SWITCH="-bc" ;;
1389 BUILD_SWITCH="-bi" ;;
1391 BUILD_SWITCH="-bl" ;;
1395 update_shell_title "build_package: $COMMAND"
1396 if [ -n "$LOGFILE" ]; then
1397 LOG=`eval echo $LOGFILE`
1398 if [ -d "$LOG" ]; then
1399 echo "Log file $LOG is a directory."
1400 echo "Parse error in the spec?"
1401 Exit_error err_build_fail
1403 if [ -n "$LASTLOG_FILE" ]; then
1404 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1406 RES_FILE=$(mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM)
1408 (time eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1409 RETVAL=`cat $RES_FILE`
1411 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1412 if [ "$RETVAL" -eq "0" ]; then
1419 eval ${NICE_COMMAND} $RPMBUILD $TARGET_SWITCH $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1422 if [ "$RETVAL" -ne "0" ]; then
1423 if [ -n "$TRY_UPGRADE" ]; then
1424 echo "\n!!! Package with new version cannot be built automagically\n"
1425 if [ "$REVERT_BROKEN_UPGRADE" = "yes" ]; then
1426 mv -f $SPECFILE.bak $SPECFILE
1429 Exit_error err_build_fail
1435 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1438 install_required_packages() {
1443 find_spec_bcond() { # originally from /usr/lib/rpm/find-spec-bcond
1446 /^%changelog/ { exit }
1448 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1449 bcond = substr($0, RSTART + 6, RLENGTH - 6);
1450 gsub(/[ \t]+/, "_", bcond);
1452 }' $SPEC | LC_ALL=C sort -u
1456 # expand bconds from ~/.bcondrc
1457 # The file structure is like gentoo's package.use:
1460 # samba -mysql -pgsql
1461 # w32codec-installer license_agreement
1464 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1470 SN=${SPECFILE%%\.spec}
1472 local bcondrc=$HOME/.bcondrc
1473 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1475 local bcond_avail=$(find_spec_bcond $SPECFILE)
1477 while read pkg flags; do
1479 [[ "$pkg" == \#* ]] && continue
1481 # any package or current package?
1482 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1483 for flag in $flags; do
1484 local opt=${flag#[+-]}
1486 # use only flags which are in this package.
1487 if [[ $bcond_avail = *${opt}* ]]; then
1488 if [[ $flag = -* ]]; then
1489 if [[ $BCOND != *--with?${opt}* ]]; then
1490 BCOND="$BCOND --without $opt"
1493 if [[ $BCOND != *--without?${opt}* ]]; then
1494 BCOND="$BCOND --with $opt"
1501 update_shell_title "parse ~/.bcondrc: DONE!"
1504 set_bconds_values() {
1505 update_shell_title "set bcond values"
1507 AVAIL_BCONDS_WITHOUT=""
1508 AVAIL_BCONDS_WITH=""
1510 if egrep -q '^# *_with' ${SPECFILE}; then
1511 echo >&2 "ERROR: This spec has old style bconds."
1515 if ! grep -q '^%bcond' ${SPECFILE}; then
1519 local bcond_avail=$(find_spec_bcond $SPECFILE)
1520 process_bcondrc "$SPECFILE"
1522 update_shell_title "parse bconds"
1525 for opt in $bcond_avail; do
1528 bcond=${opt#without_}
1529 if [[ "$BCOND" = *--without?${bcond}* ]]; then
1530 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$bcond>"
1532 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $bcond"
1537 if [[ "$BCOND" = *--with?${bcond}* ]]; then
1538 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$bcond>"
1540 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $bcond"
1544 echo >&2 "ERROR: unexpected '$opt' in set_bconds_values"
1553 update_shell_title "run_sub_builder $package_name"
1555 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1556 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1557 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1558 # jakby nie bylo tego kawalka kodu.
1560 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1561 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1565 # kurwa. translate that ^^^^
1569 # Istnieje taki spec? ${package}.spec
1570 if [ -f "${PACKAGE_DIR}/${package}.spec" ]; then
1571 parent_spec_name=${package}.spec
1572 elif [ -f "${PACKAGE_DIR}/$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec" ]; then
1573 parent_spec_name="$(echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g).spec"
1575 for provides_line in $(grep -r ^Provides:.*$package ${PACKAGE_DIR}); do
1580 if [ "${parent_spec_name}" != "" ]; then
1581 spawn_sub_builder $parent_spec_name
1583 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1586 spawn_sub_builder() {
1588 update_shell_title "spawn_sub_builder $package_name"
1591 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1592 sub_builder_opts="${sub_builder_opts} -R"
1594 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1595 sub_builder_opts="${sub_builder_opts} -RB"
1596 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1597 sub_builder_opts="${sub_builder_opts} -FRB"
1599 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1600 sub_builder_opts="${sub_builder_opts} -Upi"
1604 ./builder ${sub_builder_opts} "$@"
1607 remove_build_requires() {
1608 if [ "$INSTALLED_PACKAGES" != "" ]; then
1609 case "$REMOVE_BUILD_REQUIRES" in
1611 run_poldek --noask -ve $INSTALLED_PACKAGES
1614 run_poldek --ask -ve $INSTALLED_PACKAGES
1617 echo You may want to manually remove following BuildRequires fetched:
1618 echo $INSTALLED_PACKAGES
1619 echo "Try poldek -e \`cat $(pwd)/.${SPECFILE}_INSTALLED_PACKAGES\`"
1626 if [ "$AVAIL_BCONDS_WITH" -o "$AVAIL_BCONDS_WITHOUT" ]; then
1627 if [ "$BCOND" ]; then
1628 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1631 echo -ne "\nNo conditional flags passed"
1633 echo -ne "\n\nfrom available:\n"
1634 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1638 display_branches() {
1639 if [ "$NOCVSSPEC" != "yes" ]; then
1640 echo -ne "Available branches: "
1641 $CVS_COMMAND status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1645 # checks a given list of packages/files/provides agains current rpmdb.
1646 # outputs all dependencies which current rpmdb doesn't satisfy.
1647 # input can be either STDIN or parameters
1651 if [ $# -gt 0 ]; then
1657 DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1660 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1662 # other deps (files)
1663 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1666 # checks if given package/files/provides exists in rpmdb.
1667 # input can be either stdin or parameters
1668 # returns packages which are present in the rpmdb
1672 if [ $# -gt 0 ]; then
1678 LANG=C rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1681 # install deps via information from 'rpm-getdeps' or 'rpm --specsrpm'
1682 install_build_requires_rpmdeps() {
1683 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1684 # TODO: Conflicts list doesn't check versions
1685 local CNFL=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1686 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1688 if [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1689 local CNFL=$(rpm -q --specsrpm --conflicts $BCOND $SPECFILE | awk '{print $1}' | _rpm_cnfl_check | xargs)
1690 local DEPS=$(rpm -q --specsrpm --requires $BCOND $SPECFILE | awk '{print $1}' | _rpm_prov_check | xargs)
1693 if [ -n "$CNFL" ] || [ -n "$DEPS" ]; then
1694 echo "fetch BuildRequires: install [$DEPS]; remove [$CNFL]"
1695 update_shell_title "poldek: install [$DEPS]; remove [$CNFL]"
1696 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1698 if [ -n "$CNFL" ]; then
1699 update_shell_title "uninstall conflicting packages: $CNFL"
1700 echo "Trying to uninstall conflicting packages ($CNFL):"
1701 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CNFL
1704 while [ "$DEPS" ]; do
1705 update_shell_title "install deps: $DEPS"
1706 echo "Trying to install dependencies ($DEPS):"
1707 local log=.${SPECFILE}_poldek.log
1708 LANG=C $SU_SUDO /usr/bin/poldek --noask --caplookup -uGqQ $DEPS | tee $log
1709 failed=$(awk '/^error:/{a=$2; sub(/^error: /, "", a); sub(/:$/, "", a); print a}' $log)
1712 if [ -n "$failed" ]; then
1713 for package in $failed; do
1714 spawn_sub_builder -bb $(depspecname $package) && ok="$ok $package"
1723 fetch_build_requires()
1725 if [ "${FETCH_BUILD_REQUIRES}" != "yes" ]; then
1729 update_shell_title "fetch build requires"
1730 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ] || [ "$FETCH_BUILD_REQUIRES_RPMSPECSRPM" = "yes" ]; then
1731 install_build_requires_rpmdeps
1735 # XXX is this ugliest code written in human history still needed?
1736 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1737 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1738 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1739 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1740 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1741 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)
1743 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)
1745 package=$(basename "$package_item"|sed -e "s/}$//g")
1746 COND_ARCH_TST=$(cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g")
1749 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1750 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1751 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
1756 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1759 if `echo $COND_TST|grep -q 'without_'`; then
1760 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1761 if `echo $COND_TST|grep -q !`; then
1766 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1767 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1768 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1774 elif `echo $COND_TST|grep -q 'with_'`; then
1775 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1776 if `echo $COND_TST|grep -q !`; then
1781 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1782 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1783 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1789 RESULT="${COND_STATE}-${COND_ARGV}"
1791 "with-wout" | "wout-with" )
1794 "wout-wout" | "with-with" )
1798 echo "Action '$RESULT' was not defined for package '$package_item'"
1804 if [ "$GO" = "yes" ]; then
1805 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1806 echo "Testing if $package has subrequirements..."
1807 run_poldek -t -i $package --dumpn=".$package-req.txt"
1808 if [ -f ".$package-req.txt" ]; then
1809 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1811 if [ "$package_name" = "$package" ]; then
1812 echo -ne "Installing BuildRequired package:\t$package_name\n"
1813 update_shell_title "Installing BuildRequired package: ${package_name}"
1814 install_required_packages $package
1816 echo -ne "Installing (sub)Required package:\t$package_name\n"
1817 update_shell_title "Installing (sub)Required package: ${package_name}"
1818 install_required_packages $package_name
1822 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1823 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1826 echo "Attempting to run spawn sub - builder..."
1827 echo -ne "Package installation failed:\t$package_name\n"
1828 run_sub_builder $package_name
1829 if [ $? -eq 0 ]; then
1830 install_required_packages $package_name
1833 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1834 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1837 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1844 rm -f ".$package-req.txt"
1846 echo "Attempting to run spawn sub - builder..."
1847 echo -ne "Package installation failed:\t$package\n"
1848 run_sub_builder $package
1849 if [ $? -eq 0 ]; then
1850 install_required_packages $package
1853 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1854 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1857 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1863 echo "Package $package is already installed. BuildRequirement satisfied."
1867 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1868 echo >&2 "Unable to install following packages and their dependencies:"
1869 for pkg in "$NOT_INSTALLED_PACKAGES"
1873 remove_build_requires
1879 TOP_DIR=$(eval $RPM $RPMOPTS --eval '%{_topdir}')
1880 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1882 echo "Initialising rpm directories to $TOP_DIR from $CVSROOT"
1883 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1885 $CVS_COMMAND -d $CVSROOT co packages/{.cvsignore,rpm.groups,dropin,mirrors,md5,adapter{,.awk},fetchsrc_request,builder,{relup,compile,repackage}.sh}
1889 echo "To checkout *all* .spec files (read-only):"
1890 echo "- run cvs co SPECS"
1892 echo "To checkout *all* packages:"
1893 echo "- run cvs up in $TOP_DIR/packages dir"
1896 echo "To commit with your developer account:"
1897 echo "- edit $TOP_DIR/packages/CVS/Root"
1900 get_greed_sources() {
1901 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1902 if [ -n "BE_VERBOSE" ]; then
1903 echo "Try greed download: $1 from: $CVSROOT"
1905 $CVS_COMMAND -d $CVSROOT get SOURCES/$1
1906 if [ $? != 0 ]; then
1907 Exit_error err_no_source_in_repo $1
1912 # remove entries from CVS/Entries
1913 cvs_entry_remove() {
1914 local cvsdir="$1"; shift
1915 if [ ! -d "$cvsdir" ]; then
1916 echo >&2 "cvs_entry_remove: $cvsdir is not a directory"
1920 for file in "$@"; do
1921 rm -f $cvsdir/CVS/Entries.new || return 1
1922 awk -ve="${file##*/}" -F/ '$2 != e {print}' $cvsdir/CVS/Entries > $cvsdir/CVS/Entries.new || return 1
1923 mv -f $cvsdir/CVS/Entries.new $cvsdir/CVS/Entries || return 1
1931 DONT_PRINT_REVISION="yes"
1935 # remove from CVS/Entries
1936 cvs_entry_remove $PACKAGE_DIR $SPECFILE $SOURCES $PATCHES
1938 # remove spec and sources
1939 $RPMBUILD --clean --rmsource --rmspec --nodeps --define \'_specdir $PACKAGE_DIR\' --define \'_sourcedir $PACKAGE_DIR\' $SPECFILE
1942 #---------------------------------------------
1950 while [ $# -gt 0 ]; do
1953 COMMAND="update_md5"
1958 COMMAND="update_md5"
1968 DEBUG="yes"; shift ;;
1970 COMMAND="version"; shift ;;
1972 COMMAND="short-version"; shift ;;
1974 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1975 -b | -ba | --build )
1976 COMMAND="build"; shift ;;
1977 -bb | --build-binary )
1978 COMMAND="build-binary"; shift ;;
1980 COMMAND="build-build"; shift ;;
1982 COMMAND="build-install"; shift ;;
1984 COMMAND="build-list"; shift ;;
1985 -bp | --build-prep )
1986 COMMAND="build-prep"; shift ;;
1987 -bs | --build-source )
1988 COMMAND="build-source"; shift ;;
1990 COMMAND="branch"; shift; TAG="${1}"; shift;;
1992 CLEAN="--clean --rmspec --rmsource"; shift ;;
1994 CVS_FORCE="-F"; shift;;
1996 shift; CVSROOT="${1}"; shift ;;
1998 COMMAND="get"; shift ;;
2000 COMMAND="usage"; shift ;;
2002 PROTOCOL="http"; shift ;;
2004 shift; LOGFILE="${1}"; shift ;;
2006 shift; DEF_NICE_LEVEL=${1}; shift ;;
2007 -ske | --skip-existing-files)
2008 SKIP_EXISTING_FILES="yes"; shift ;;
2010 COMMAND="mr-proper"; shift ;;
2012 NOCVS="yes"; shift ;;
2013 -ncs | --no-cvs-specs )
2014 NOCVSSPEC="yes"; shift ;;
2015 -nd | --no-distfiles )
2016 NODIST="yes"; shift ;;
2017 -nm | --no-mirrors )
2018 NOMIRRORS="yes"; shift ;;
2020 NOURLS="yes"; shift ;;
2022 NOSRCS="yes"; shift ;;
2023 -ns0 | --no-source0 )
2024 NOSOURCE0="yes"; shift ;;
2034 -pm | --prefer-mirrors )
2041 shift; RPMOPTS="${RPMOPTS} ${1}"; shift ;;
2043 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
2045 RPMOPTS="${RPMOPTS} --define \"_topdir $2\""
2048 --with | --without )
2049 case $GROUP_BCONDS in
2053 # XXX: broken: ./builder -bb ucspi-tcp.spec --without mysql
2054 while ! `echo ${1}|grep -qE '(^-|spec)'`
2056 BCOND="$BCOND $COND $1"
2060 if [[ "$2" = *,* ]]; then
2061 for a in $(echo "$2" | tr , ' '); do
2062 BCOND="$BCOND $1 $a"
2065 BCOND="$BCOND $1 $2"
2071 shift; TARGET="${1}"; shift ;;
2073 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
2075 QUIET="--quiet"; shift ;;
2077 CVSDATE="${2}"; shift 2 ;;
2086 -R | --fetch-build-requires)
2087 FETCH_BUILD_REQUIRES="yes"
2088 NOT_INSTALLED_PACKAGES=
2090 -RB | --remove-build-requires)
2091 REMOVE_BUILD_REQUIRES="nice"
2093 -FRB | --force-remove-build-requires)
2094 REMOVE_BUILD_REQUIRES="force"
2096 -sc | --sources-cvs)
2097 COMMAND="list-sources-cvs"
2099 -sd | --sources-distfiles)
2100 COMMAND="list-sources-distfiles"
2102 -sdp | --sources-distfiles-paths)
2103 COMMAND="list-sources-distfiles-paths"
2105 -sf | --sources-files)
2106 COMMAND="list-sources-files"
2108 -sp | --sources-paths)
2109 COMMAND="list-sources-local-paths"
2111 -su | --sources-urls)
2112 COMMAND="list-sources-urls"
2114 -Tvs | --tag-version-stable )
2119 -Ts | --tag-stable )
2124 -Tv | --tag-version )
2129 -Tp | --tag-prefix )
2141 -ir | --integer-release-only )
2142 INTEGER_RELEASE="yes"
2145 COMMAND="update_md5"
2150 -Upi | --update-poldek-indexes )
2151 UPDATE_POLDEK_INDEXES="yes"
2154 COMMAND="init_rpm_dir"
2156 --use-greed-sources )
2159 -u | --try-upgrade )
2160 TRY_UPGRADE="1"; shift ;;
2161 -un | --try-upgrade-with-float-version )
2162 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
2164 BE_VERBOSE="1"; shift ;;
2169 if echo "${MACRO}" | grep -q '\W'; then
2170 RPMOPTS="${RPMOPTS} --define \"${MACRO}\""
2174 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
2179 RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
2183 RPMBUILDOPTS="${RPMBUILDOPTS} --short-circuit"
2186 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
2187 COMMAND="show_bconds"
2191 COMMAND="show_bcond_args"
2196 RPMOPTS="${RPMOPTS} --nodeps"
2199 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift
2202 Exit_error err_invalid_cmdline "$1"
2206 # check if specname was passed as specname:cvstag
2207 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
2208 CVSTAG="${SPECFILE##*:}"
2209 SPECFILE="${SPECFILE%%:*}"
2211 ASSUMED_NAME=$(basename ${SPECFILE%%.spec})
2216 if [ -f CVS/Entries ] && [ -z "$CVSTAG" ]; then
2217 CVSTAG=$(awk -vSPECFILE=$(basename ${SPECFILE%.spec}.spec) -F/ '$2 == SPECFILE && $6 ~ /^T/{print substr($6, 2)}' CVS/Entries)
2218 if [ "$CVSTAG" ]; then
2219 echo >&2 "builder: Sticky tag $CVSTAG active. Use -r TAGNAME to override."
2221 elif [ "$CVSTAG" = "HEAD" ]; then
2222 # assume -r HEAD is same as -A
2226 if [ "$CVSTAG" ]; then
2227 # pass $CVSTAG used by builder to rpmbuild too, so specs could use it
2228 RPMOPTS="$RPMOPTS --define \"_cvstag $CVSTAG\""
2231 if [ -n "$DEBUG" ]; then
2236 if [ -n "$TARGET" ]; then
2239 TARGET_SWITCH="--target $TARGET" ;;
2241 TARGET_SWITCH="--target=$TARGET" ;;
2245 if [ "$SCHEDTOOL" != "no" ]; then
2246 NICE_COMMAND="$SCHEDTOOL"
2248 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
2251 update_shell_title "$COMMAND"
2255 if [ -n "$SPECFILE" ]; then
2256 get_spec > /dev/null
2264 if [ -n "$SPECFILE" ]; then
2265 get_spec > /dev/null
2271 "build" | "build-binary" | "build-source" | "build-prep" | "build-build" | "build-install" | "build-list")
2273 if [ -n "$SPECFILE" ]; then
2274 # display SMP make flags if set
2275 smp_mflags=$(rpm -E %{?_smp_mflags})
2276 if [ "$smp_mflags" ]; then
2277 echo >&2 "builder: SMP make flags are set to $smp_mflags"
2285 if [ "$COMMAND" != "build-source" ]; then
2288 fetch_build_requires
2289 if [ "$INTEGER_RELEASE" = "yes" ]; then
2290 echo "Checking release $PACKAGE_RELEASE..."
2291 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
2292 Exit_error err_fract_rel "$PACKAGE_RELEASE"
2296 # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
2297 if [ -n "$TEST_TAG" ]; then
2298 local TAGVER=`make_tagver`
2299 echo "Searching for tag $TAGVER..."
2300 TAGREL=$($CVS_COMMAND status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
2301 if [ -n "$TAGREL" ]; then
2302 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
2305 # - do not allow to build from HEAD when XX-branch exists
2306 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
2307 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
2308 TAG_BRANCH="${TREE_PREFIX}-branch"
2309 TAG_STATUS=$($CVS_COMMAND status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
2310 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
2311 Exit_error err_branch_exists "$TAG_STATUS"
2317 if [ -n "$NOSOURCE0" ] ; then
2318 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2320 get_files $SOURCES $PATCHES
2323 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
2324 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
2326 remove_build_requires
2328 Exit_error err_no_spec_in_cmdl
2333 if [ -n "$SPECFILE" ]; then
2336 # don't fetch sources from remote locations
2338 for file in $SOURCES; do
2339 [ -n "`src_md5 $file`" ] && continue
2340 new_SOURCES="$new_SOURCES $file"
2342 SOURCES="$new_SOURCES"
2343 get_files $SOURCES $PATCHES
2345 branch_files $TAG $SOURCES $PATCHES $ICONS
2347 Exit_error err_no_spec_in_cmdl
2352 if [ -n "$SPECFILE" ]; then
2356 if [ -n "$NOSOURCE0" ] ; then
2357 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2359 get_files $SOURCES $PATCHES
2362 Exit_error err_no_spec_in_cmdl
2367 if [ -n "$SPECFILE" ]; then
2371 if [ -n "$NOSOURCE0" ] ; then
2372 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2376 Exit_error err_no_spec_in_cmdl
2383 if [ -n "$SPECFILE" ]; then
2387 # don't fetch sources from remote locations
2389 for file in $SOURCES; do
2390 [ -n "`src_md5 $file`" ] && continue
2391 new_SOURCES="$new_SOURCES $file"
2393 SOURCES="$new_SOURCES"
2394 get_files $SOURCES $PATCHES
2396 tag_files $SOURCES $PATCHES $ICONS
2398 Exit_error err_no_spec_in_cmdl
2404 "list-sources-files" )
2407 DONT_PRINT_REVISION="yes"
2410 for SAP in $SOURCES $PATCHES; do
2411 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2414 "list-sources-urls" )
2417 DONT_PRINT_REVISION="yes"
2420 SAPS="$SOURCES $PATCHES"
2421 for SAP in $SAPS ; do
2425 "list-sources-local-paths" )
2428 DONT_PRINT_REVISION="yes"
2431 for SAP in $SOURCES $PATCHES; do
2432 echo $PACKAGE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2435 "list-sources-distfiles-paths" )
2438 DONT_PRINT_REVISION="yes"
2441 for SAP in $SOURCES $PATCHES; do
2442 if [ -n "$(src_md5 "$SAP")" ]; then
2443 distfiles_path "$SAP"
2447 "list-sources-distfiles" )
2450 DONT_PRINT_REVISION="yes"
2453 for SAP in $SOURCES $PATCHES; do
2454 if [ -n "$(src_md5 "$SAP")" ]; then
2455 distfiles_url "$SAP"
2459 "list-sources-cvs" )
2462 DONT_PRINT_REVISION="yes"
2465 for SAP in $SOURCES $PATCHES; do
2466 if [ -z "$(src_md5 "$SAP")" ]; then
2467 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2481 echo "$VERSIONSTRING"
2484 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2485 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2489 # vi:syntax=sh:ts=4:sw=4:noet