7 # 2 - no spec file name in cmdl parameters
8 # 3 - spec file not stored in repo
9 # 4 - some source, patch or icon files not stored in repo
10 # 5 - package build failed
11 # 6 - spec file with errors
12 # 7 - wrong source in /etc/poldek.conf
13 # 8 - Failed installing buildrequirements and subrequirements
14 # 9 - Requested tag already exist
15 # 10 - Refused to build fractional release
16 # 100 - Unknown error (should not happen)
19 # - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
20 # - when Icon: field is present, -5 and -a5 doesn't work
21 # - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
24 Build package utility from PLD Linux CVS repository
25 v0.15 (C) 1999-2006 Free Penguins".
26 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
45 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
48 # It can be used i.e. in log file naming.
49 # See LOGFILE example.
50 DATE=`date +%Y-%m-%d_%H-%M-%S`
52 # Example: LOGFILE='../log.$PACKAGE_NAME'
53 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
54 # Yes, you can use variable name! Note _single_ quotes!
77 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
78 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
83 CVS_SERVER="cvs.pld-linux.org"
84 DISTFILES_SERVER="://distfiles.pld-linux.org"
85 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
90 FAIL_IF_NO_SOURCES="yes"
92 # let get_files skip over files which are present to get those damn files fetched
93 SKIP_EXISTING_FILES="no"
95 if [ -x /usr/bin/rpm-getdeps ]; then
96 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
98 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
101 # Here we load saved user environment used to
102 # predefine options set above, or passed to builder
104 # This one reads global system environment settings:
105 if [ -f ~/etc/builderrc ]; then
108 # And this one cascades settings using user personal
110 # Example of ~/.builderrc:
112 #UPDATE_POLDEK_INDEXES="yes"
113 #FETCH_BUILD_REQUIRES="yes"
114 #REMOVE_BUILD_REQUIRES="force"
116 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
120 if [ -n "$HOME_ETC" ]; then
121 USER_CFG="$HOME_ETC/.builderrc"
123 USER_CFG=~/.builderrc
126 [ -f "$USER_CFG" ] && . "$USER_CFG"
128 if [ "$SCHEDTOOL" = "auto" ]; then
129 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
130 SCHEDTOOL="schedtool -B -e"
136 if [ -n "$USE_PROZILLA" ]; then
137 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
140 elif [ -n "$USE_AXEL" ]; then
141 GETURI="axel -a $AXEL_OPTS"
145 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
146 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
147 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
149 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
150 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
156 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
164 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
165 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
169 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
170 if [ -n "$LOGFILE" ]; then
171 LOG=`eval echo $LOGFILE`
172 if [ -n "$LASTLOG_FILE" ]; then
173 echo "LASTLOG=$LOG" > $LASTLOG_FILE
175 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
178 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
179 return `cat ${RES_FILE}`
184 #---------------------------------------------
189 if [ -n "$DEBUG" ]; then set -xv; fi
191 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
193 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
194 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
195 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
196 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
197 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
198 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
199 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
200 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
201 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec][:cvstag]
203 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
204 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
205 -n5, --no-md5 - ignore md5 comments in spec
206 -D, --debug - enable builder script debugging mode,
207 -debug - produce rpm debug package (same as --opts -debug)
208 -V, --version - output builder version
209 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
210 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
212 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
213 only package from <package>.spec,
214 -bp, --build-prep - execute the %prep phase of <package>.spec,
215 -bc - reserved (not implemented)
216 -bi reserved (not implemented)
217 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
219 --short-circuit - reserved (not implemented)
220 -B, --branch - add branch
221 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
222 SPECS and \$RPM_BUILD_ROOT),
223 -d <cvsroot>, --cvsroot <cvsroot>
225 --define <macro> <value>
226 - define a macro <macro> with value <value>,
227 --nodeps - rpm won't check any dependences
228 -g, --get - get <package>.spec and all related files from CVS repo
230 -h, --help - this message,
231 --http - use http instead of ftp,
232 -l <logfile>, --logtofile <logfile>
234 -m, --mr-proper - only remove all files related to spec file and all work
236 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
238 - don't check specs in CVS
239 -nd, --no-distfiles - don't download from distfiles
240 -nm, --no-mirrors - don't download from mirror, if source URL is given,
241 -nu, --no-urls - don't try to download from FTP/HTTP location,
242 -ns, --no-srcs - don't download Sources
243 -ns0, --no-source0 - don't download Source0
244 -nn, --no-net - don't download anything from the net
245 --no-init - don't initialize builder paths (SPECS and SOURCES)
247 --skip-existing-files - skip existing files in get_files
248 --opts <rpm opts> - additional options for rpm
249 -q, --quiet - be quiet,
250 --date yyyy-mm-dd - build package using resources from specified CVS date,
251 -r <cvstag>, --cvstag <cvstag>
252 - build package using resources from specified CVS tag,
253 -R, --fetch-build-requires
254 - fetch what is BuildRequired,
255 -RB, --remove-build-requires
256 - remove all you fetched with -R or --fetch-build-requires
257 remember, this option requires confirmation,
258 -FRB, --force-remove-build-requires
259 - remove all you fetched with -R or --fetch-build-requires
260 remember, this option works without confirmation,
261 -sd, --source-distfiles - list sources available from distfiles (intended for offline
262 operations; does not work when Icon field is present
263 but icon file is absent),
264 -sdp, --source-distfiles-paths - list sources available from distfiles -
265 paths relative to distfiles directory (intended for offline
266 operations; does not work when Icon field is present
267 but icon file is absent),
268 -sf, --source-files - list sources - bare filenames (intended for offline
269 operations; does not work when Icon field is present
270 but icon file is absent),
271 -sp, --source-paths - list sources - filenames with full local paths (intended for
272 offline operations; does not work when Icon field is present
273 but icon file is absent),
274 -su, --source-urls - list urls - urls to sources and patches
275 intended for copying urls with spec with lots of macros in urls
276 -T <cvstag> , --tag <cvstag>
277 - add cvs tag <cvstag> for files,
278 -Tvs, --tag-version-stable
279 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
280 -Tvn, --tag-version-nest
281 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
283 - add cvs tag STABLE for files,
285 - add cvs tag NEST for files,
287 - add cvs tag NAME-VERSION-RELEASE for files,
288 -Tp, --tag-prefix <prefix>
289 - add <prefix> to NAME-VERSION-RELEASE tags,
290 -tt, --test-tag <prefix>
291 - fail if tag is already present,
292 -ir, --integer-release-only
293 - allow only integer and snapshot releases
294 -v, --verbose - be verbose,
295 -u, --try-upgrade - check version, and try to upgrade package
296 -un, --try-upgrade-with-float-version
297 - as above, but allow float version
298 -U, --update - refetch sources, don't use distfiles, and update md5 comments
299 -Upi, --update-poldek-indexes
300 - refresh or make poldek package index files.
301 -np, --nopatch <patchnumber>
302 - don't apply <patchnumber>
303 --show-bconds - show available conditional builds, which can be used
304 - with --with and/or --without switches.
305 --with/--without <feature>
306 - conditional build package depending on %_with_<feature>/
307 %_without_<feature> macro switch. You may now use
308 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
309 constructions. Set GROUP_BCONDS to yes to make use of it.
310 --target <platform>, --target=<platform>
311 - build for platform <platform>.
312 --init-rpm-dir - initialize ~/rpm directory structure
316 update_shell_title() {
318 local len=${COLUMNS:-80}
319 local msg=$(echo "$*" | cut -c-$len)
321 if [ -n "$BE_VERBOSE" ]; then
322 echo >&2 "$(date +%s.%N) $*"
325 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
327 if [ -n "$PACKAGE_NAME" ]; then
328 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
333 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
334 msg="$(echo $msg | tr -d '\n\r')"
337 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
340 echo >&2 -ne "\033]0;$msg\007"
346 # set TARGET from BuildArch: from SPECFILE
348 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
349 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
354 TARGET_SWITCH="--target $TARGET" ;;
356 TARGET_SWITCH="--target=$TARGET" ;;
363 if [ -n "$DEBUG" ]; then
368 update_shell_title "cache_rpm_dump"
372 # we reset macros not to contain macros.build as all the %() macros are
373 # executed here, while none of them are actually needed.
374 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
375 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
376 macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.builder-rpmmacros:~/etc/.rpmmacros:~/.rpmmacros"
377 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
378 # FIXME: better ideas than .rpmrc?
379 printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .builder-rpmrc
380 # TODO: move these to /usr/lib/rpm/macros
381 cat > .builder-rpmmacros <<'EOF'
382 %requires_releq_kernel_up %{nil}
383 %requires_releq_kernel_smp %{nil}
384 %requires_releq() %{nil}
385 %pyrequires_eq() %{nil}
386 %requires_eq() %{nil}
387 %requires_eq_to() %{nil}
388 %releq_kernel_up ERROR
389 %releq_kernel_smp ERROR
393 %ruby_ver_requires_eq() %{nil}
394 %ruby_mod_ver_requires_eq() %{nil}
395 %__php_api_requires() %{nil}
396 %php_major_version ERROR
397 %php_api_version ERROR
405 ARGS='--nodigest --nosignature --nobuild'
408 if [ "$NOINIT" = "yes" ] ; then
409 cat >> .builder-rpmmacros <<'EOF'
414 $RPMBUILD --rcfile .builder-rpmrc $ARGS $ARGDIRS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
416 if [ $? -gt 0 ]; then
417 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
419 Exit_error err_build_fail;
422 # make small dump cache
423 rpm_dump_cache=`echo "$rpm_dump" | awk '
424 $2 ~ /^SOURCEURL/ {print}
425 $2 ~ /^PATCHURL/ {print}
426 $2 ~ /^nosource/ {print}
427 $2 ~ /^PACKAGE_/ {print}
430 update_shell_title "cache_rpm_dump: OK!"
434 if [ -z "$rpm_dump_cache" ] ; then
435 echo "internal error: cache_rpm_dump not called!" 1>&2
437 echo "$rpm_dump_cache"
442 update_shell_title "get icons"
443 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
444 if [ -z "$ICONS" ]; then
448 rpm_dump_cache="kalasaba" NODIST="yes" UPDATE5= get_files $ICONS
453 update_shell_title "parsing specfile"
454 if [ -n "$DEBUG" ]; then
459 # icons are needed for successful spec parse
465 if [ "$NOSRCS" != "yes" ]; then
466 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
469 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
470 FAIL_IF_NO_SOURCES="no"
473 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
474 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
475 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
476 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
477 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
479 if [ -n "$BE_VERBOSE" ]; then
480 echo "- Sources : `nourl $SOURCES`"
481 if [ -n "$PATCHES" ]; then
482 echo "- Patches : `nourl $PATCHES`"
484 echo "- Patches : *no patches needed*"
486 if [ -n "$ICONS" ]; then
487 echo "- Icon : `nourl $ICONS`"
489 echo "- Icon : *no package icon*"
491 echo "- Name : $PACKAGE_NAME"
492 echo "- Version : $PACKAGE_VERSION"
493 echo "- Release : $PACKAGE_RELEASE"
496 update_shell_title "parse_spec: OK!"
501 if [ -n "$DEBUG" ]; then
509 "err_no_spec_in_cmdl" )
510 remove_build_requires
511 echo "ERROR: spec file name not specified.";
513 "err_no_spec_in_repo" )
514 remove_build_requires
515 echo "Error: spec file not stored in CVS repo.";
517 "err_no_source_in_repo" )
518 remove_build_requires
519 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
522 remove_build_requires
523 echo "Error: package build failed. (${2:-no more info})";
525 "err_no_package_data" )
526 remove_build_requires
527 echo "Error: couldn't get out package name/version/release from spec file."
530 remove_build_requires
531 echo "Tag ${2} already exists (spec release: ${3}).";
534 remove_build_requires
535 echo "Release ${2} not integer and not a snapshot.";
537 "err_branch_exists" )
538 remove_build_requires
539 echo "Tree branch already exists (${2}).";
543 echo "Unknown error."
549 if [ -n "$DEBUG" ]; then
554 if [ "$NOINIT" != "yes" ] ; then
555 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
556 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
568 update_shell_title "get_spec"
570 if [ -n "$DEBUG" ]; then
576 if [ ! -f "$SPECFILE" ]; then
577 SPECFILE="`basename $SPECFILE .spec`.spec";
579 if [ "$NOCVSSPEC" != "yes" ]; then
581 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
582 echo "Warning: No CVS access defined - using local .spec file"
586 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
589 if [ ! -f "$SPECFILE" ]; then
590 Exit_error err_no_spec_in_repo;
593 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
594 chmod $CHMOD_MODE $SPECFILE
597 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
606 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
607 cvs update mirrors >&2
611 while read origin mirror name rest
613 ol=`echo -n "$origin"|wc -c`
614 prefix="`echo -n "$url" | head -c $ol`"
615 if [ "$prefix" = "$origin" ] ; then
616 suffix="`echo "$url"|cut -b $ol-`"
617 echo -n "$mirror$suffix"
628 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
629 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
635 [ X"$NO5" = X"yes" ] && return
637 [ -z "$no" ] && return
639 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
640 if [ -z "$spec_rev" ]; then
641 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
643 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
644 md5=$(grep -s -v '^#' additional-md5sums | \
645 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
646 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
647 grep -E '^[0-9a-f]{32}$')
648 if [ X"$md5" = X"" ] ; then
649 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
650 if [ ! -z "$source_md5" ] ; then
653 # we have empty SourceX-md5, but it is still possible
654 # that we have NoSourceX-md5 AND NoSource: X
655 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
656 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
661 if [ $(echo "$md5" | wc -l) != 1 ] ; then
662 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
664 echo "$md5" | tail -n 1
670 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
675 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
678 distfiles_attic_url ()
680 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
687 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
692 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
693 [ -n "$size" -a "$size" -gt 0 ]
698 if [ "$CVSIGNORE_DF" != "yes" ]; then
701 cvsignore=${SOURCE_DIR}/.cvsignore
702 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
703 echo "$1" >> $cvsignore
709 update_shell_title "cvsup"
711 if [ -n "$CVSROOT" ]; then
712 OPTIONS="-d $CVSROOT $OPTIONS"
715 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
716 OPTIONS="$OPTIONS -A"
718 if [ -n "$CVSDATE" ]; then
719 OPTIONS="$OPTIONS -D $CVSDATE"
721 if [ -n "$CVSTAG" ]; then
722 OPTIONS="$OPTIONS -r $CVSTAG"
727 local retries_counter=0
729 update_shell_title "cvsup: $*"
731 update_shell_title "cvsup: $# files"
733 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
734 retries_counter=$(( $retries_counter + 1 ))
735 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
737 [ -n "$output" ] && echo "$output"
738 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
739 echo "Trying again [$*]... ($retries_counter)"
740 update_shell_title "cvsup: retry #$retries_counter"
747 update_shell_title "cvsup: done!"
753 update_shell_title "get_files"
755 if [ -n "$DEBUG" ]; then
760 if [ $# -gt 0 ]; then
763 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
764 echo "Warning: No CVS access defined for SOURCES"
769 local get_files_cvs=""
773 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
774 update_shell_title "$i"
775 local fp=`nourl "$i"`
776 if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then
779 if [ -n "$UPDATE5" ]; then
780 if [ -n "$ADD5" ]; then
781 [ "$fp" = "$i" ] && continue
782 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
784 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
788 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
789 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
790 echo "Warning: no URL given for $i"
793 if [ -z "$NODIST" ] && [ -n "$(src_md5 "$i")" ]; then
794 if good_md5 "$i" && good_size "$i"; then
795 echo "$(nourl "$i") having proper md5sum already exists"
799 url=$(distfiles_url "$i")
800 url_attic=$(distfiles_attic_url "$i")
802 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
803 update_shell_title "${GETLOCAL%% *}: $url"
804 ${GETLOCAL} $url $target
806 if [ -z "$NOMIRRORS" ]; then
807 url="`find_mirror "$url"`"
809 update_shell_title "${GETURI%% *}: $url"
810 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
811 if [ "`echo $url | grep -E 'ftp://'`" ]; then
812 update_shell_title "${GETURI2%% *}: $url"
813 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
816 if ! test -s "$target"; then
818 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
819 update_shell_title "${GETLOCAL%% *}: $url_attic"
820 ${GETLOCAL} $url_attic $target
822 if [ -z "$NOMIRRORS" ]; then
823 url_attic="`find_mirror "$url_attic"`"
825 update_shell_title "${GETURI%% *}: $url_attic"
826 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
827 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
828 update_shell_title "${GETURI2%% *}: $url_attic"
829 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
833 if test -s "$target"; then
839 elif [ "$NOCVS" != "yes" -a -z "$(src_md5 "$i")" ]; then
840 if [ $# -gt 1 ]; then
841 get_files_cvs="$get_files_cvs $fp"
842 update_shell_title "$fp (will cvs up later)"
849 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
850 if [ -z "$NOMIRRORS" ]; then
851 im="`find_mirror "$i"`"
855 update_shell_title "${GETURI%% *}: $im"
857 if [ "`echo $im | grep -E 'ftp://'`" ]; then
858 update_shell_title "${GETURI2%% *}: $im"
863 if [ "$cvsup" = 1 ]; then
869 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
870 Exit_error err_no_source_in_repo $i;
871 elif [ -n "$UPDATE5" ] && \
872 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
873 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
874 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
876 echo "Updating source-$srcno md5."
877 md5=$(md5sum "$fp" | cut -f1 -d' ')
879 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
880 print "# Source'$srcno'-md5:\t'$md5'\n"
881 if /^Source'$srcno'\s*:\s+/;
886 if good_md5 "$i" && good_size "$i"; then
888 elif [ "$FROM_DISTFILES" = 1 ]; then
889 # wrong md5 from distfiles: remove the file and try again
891 echo "MD5 sum mismatch. Trying full fetch."
894 update_shell_title "${GETURI%% *}: $url"
895 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
896 if [ "`echo $url | grep -E 'ftp://'`" ]; then
897 update_shell_title "${GETURI2%% *}: $url"
898 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
900 if ! test -s "$target"; then
902 update_shell_title "${GETURI%% *}: $url_attic"
903 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
904 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
905 update_shell_title "${GETURI2%% *}: $url_attic"
906 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
909 test -s "$target" || rm -f "$target"
912 if good_md5 "$i" && good_size "$i" ; then
915 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
916 echo "or -5 to update md5 sums, if you're sure files are correct."
917 Exit_error err_no_source_in_repo $i
920 SHELL_TITLE_PREFIX=""
922 if [ "$get_files_cvs" ]; then
926 if [ "$CHMOD" = "yes" ]; then
927 CHMOD_FILES="`nourl "$@"`"
928 if [ -n "$CHMOD_FILES" ]; then
929 chmod $CHMOD_MODE $CHMOD_FILES
936 if [ -n "$DEBUG" ]; then
941 # Check whether first character of PACKAGE_NAME is legal for tag name
942 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
945 TAGVER=$TAG_PREFIX$PACKAGE_NAME-`echo $PACKAGE_VERSION | sed -e "s/\./\_/g" -e "s/@/#/g"`-`echo $PACKAGE_RELEASE | sed -e "s/\./\_/g" -e "s/@/#/g"`
946 # Remove #kernel.version_release from TAGVER because tagging sources
947 # could occur with different kernel-headers than kernel-headers used at build time.
948 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
956 if [ -n "$DEBUG" ]; then
961 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
962 echo "Version: $PACKAGE_VERSION"
963 echo "Release: $PACKAGE_RELEASE"
967 if [ "$TAG_VERSION" = "yes" ]; then
968 echo "CVS tag: $TAGVER"
970 if [ -n "$TAG" ]; then
975 if [ -n "$CVSROOT" ]; then
976 OPTIONS="-d $CVSROOT $OPTIONS"
982 # don't tag files stored on distfiles
983 [ -n "`src_md5 $i`" ] && continue
984 if [ -f "`nourl $i`" ]; then
985 if [ "$TAG_VERSION" = "yes" ]; then
986 cvs $OPTIONS $TAGVER `nourl $i`
988 if [ -n "$TAG" ]; then
989 cvs $OPTIONS $TAG `nourl $i`
992 Exit_error err_no_source_in_repo $i
997 if [ "$TAG_VERSION" = "yes" ]; then
998 cvs $OPTIONS $TAGVER $SPECFILE
1000 if [ -n "$TAG" ]; then
1001 cvs $OPTIONS $TAG $SPECFILE
1011 echo "CVS branch tag: $TAG"
1016 if [ -n "$DEBUG" ]; then
1021 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
1024 if [ -n "$CVSROOT" ]; then
1025 OPTIONS="-d $CVSROOT $OPTIONS"
1030 if [ -f `nourl $i` ]; then
1031 cvs $OPTIONS $TAG `nourl $i`
1033 Exit_error err_no_source_in_repo $i
1037 cvs $OPTIONS $TAG $SPECFILE
1047 update_shell_title "build_package"
1048 if [ -n "$DEBUG" ]; then
1055 if [ -n "$TRY_UPGRADE" ]; then
1056 update_shell_title "build_package: try_upgrade"
1057 if [ -n "$FLOAT_VERSION" ]; then
1058 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1060 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1063 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1065 if [ -n "$TNEWVER" ]; then
1066 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1067 echo "New version found, updating spec file to version " $TNEWVER
1068 cp -f $SPECFILE $SPECFILE.bak
1070 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1071 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1073 NODIST="yes" UPDATE5="yes" get_files $SOURCES $PATCHES;
1074 unset TOLDVER TNEWVER TNOTIFY
1081 BUILD_SWITCH="-ba" ;;
1083 BUILD_SWITCH="-bb" ;;
1085 BUILD_SWITCH="-bs --nodeps" ;;
1087 BUILD_SWITCH="-bp --nodeps" ;;
1090 update_shell_title "build_package: $COMMAND"
1091 if [ -n "$LOGFILE" ]; then
1092 LOG=`eval echo $LOGFILE`
1093 if [ -d "$LOG" ]; then
1094 echo "Log file $LOG is a directory."
1095 echo "Parse error in the spec?"
1096 Exit_error err_build_fail;
1098 if [ -n "$LASTLOG_FILE" ]; then
1099 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1101 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1102 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1103 RETVAL=`cat $RES_FILE`
1105 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1106 if [ "$RETVAL" -eq "0" ]; then
1113 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1116 if [ "$RETVAL" -ne "0" ]; then
1117 if [ -n "$TRY_UPGRADE" ]; then
1118 echo "\n!!! Package with new version cannot be built automagically\n"
1119 mv -f $SPECFILE.bak $SPECFILE
1121 Exit_error err_build_fail;
1128 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1131 install_required_packages()
1138 # taken from find-spec-bcond, but with just getting the list
1140 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1142 /^%changelog/ { exit }
1143 /_with(out)?_[_a-zA-Z0-9]+/{
1144 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1145 print substr($0, RSTART, RLENGTH);
1148 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1149 bcond = substr($0, RSTART +5 , RLENGTH -5);
1150 gsub(/[ \t]+/,"_",bcond);
1152 }' $SPEC | LC_ALL=C sort -u
1157 update_shell_title "set bcond values"
1159 AVAIL_BCONDS_WITHOUT=""
1160 AVAIL_BCONDS_WITH=""
1161 if `grep -q ^%bcond ${SPECFILE}`; then
1163 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1169 local bcond_avail=$(find_spec_bcond $SPECFILE)
1171 # expand bconds from ~/.bcondrc
1172 # The file structure is like gentoo's package.use:
1175 # samba -mysql -pgsql
1176 # w32codec-installer license_agreement
1179 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1180 SN=${SPECFILE%%\.spec}
1182 local bcondrc=$HOME/.bcondrc
1183 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1185 while read pkg flags; do
1187 [[ "$pkg" == \#* ]] && continue
1189 # any package or current package?
1190 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1191 for flag in $flags; do
1192 local opt=${flag#[+-]}
1194 # use only flags which are in this package.
1195 if [[ $bcond_avail = *${opt}* ]]; then
1196 if [[ $flag = -* ]]; then
1197 BCOND="$BCOND --without $opt"
1199 BCOND="$BCOND --with $opt"
1205 update_shell_title "parse ~/.bcondrc: DONE!"
1208 update_shell_title "parse bconds"
1209 case "${BCOND_VERSION}" in
1214 echo "Warning: This spec has old style bconds. Fix it || die."
1215 for opt in `echo "$bcond_avail" | grep ^_without_`
1217 AVAIL_BCOND_WITHOUT=${opt#_without_}
1218 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1219 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1221 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1225 for opt in `echo "$bcond_avail" | grep ^_with_`
1227 AVAIL_BCOND_WITH=${opt#_with_}
1228 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1229 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1231 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1236 local cond_type="" # with || without
1237 for opt in $bcond_avail; do
1246 AVAIL_BCOND_WITHOUT=${opt#_without_}
1247 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1248 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1250 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1254 AVAIL_BCOND_WITH=${opt#_with_}
1255 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1256 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1258 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1262 case "$cond_type" in
1265 AVAIL_BCOND_WITH="$opt"
1266 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1267 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1269 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1274 AVAIL_BCOND_WITHOUT="$opt"
1275 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1276 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1278 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1292 update_shell_title "run_sub_builder $package_name"
1294 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1295 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1296 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1297 # jakby nie bylo tego kawalka kodu.
1299 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1300 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1307 # Istnieje taki spec? ${package}.spec
1308 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1309 parent_spec_name=${package}.spec
1310 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1311 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1313 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1319 if [ "${parent_spec_name}" != "" ]; then
1320 spawn_sub_builder $parent_spec_name
1322 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1328 update_shell_title "spawn_sub_builder $package_name"
1331 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1332 sub_builder_opts="${sub_builder_opts} -R"
1334 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1335 sub_builder_opts="${sub_builder_opts} -RB"
1336 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1337 sub_builder_opts="${sub_builder_opts} -FRB"
1339 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1340 sub_builder_opts="${sub_builder_opts} -Upi"
1344 ./builder ${sub_builder_opts} "$@"
1347 remove_build_requires()
1349 if [ "$INSTALLED_PACKAGES" != "" ]; then
1350 case "$REMOVE_BUILD_REQUIRES" in
1352 run_poldek --noask -ve $INSTALLED_PACKAGES
1355 run_poldek --ask -ve $INSTALLED_PACKAGES
1358 echo You may want to manually remove following BuildRequires fetched:
1359 echo $INSTALLED_PACKAGES
1360 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1368 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1369 if [ "$BCOND" != "" ]; then
1370 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1373 echo -ne "\nNo conditional flags passed"
1375 echo -ne "\n\nfrom available:\n"
1376 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1382 if [ "$NOCVSSPEC" != "yes" ]; then
1383 echo -ne "Available branches: "
1384 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1388 # checks a given list of packages/files/provides agains current rpmdb.
1389 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1390 # input can be either STDIN or parameters
1395 if [ "$#" -gt 0 ]; then
1401 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1404 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1406 # other deps (files)
1407 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1410 # checks if given package/files/provides exists in rpmdb.
1411 # inout can be either stdin or parameters
1412 # returns packages wchi hare present in the rpmdb
1417 if [ "$#" -gt 0 ]; then
1423 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1426 fetch_build_requires()
1428 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1429 update_shell_title "fetch build requires"
1430 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1431 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1432 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1434 update_shell_title "poldek: update indexes"
1435 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1436 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1438 if [ -n "$CONF" ]; then
1439 update_shell_title "uninstall conflicting packages: $CONF"
1440 echo "Trying to uninstall conflicting packages ($CONF):"
1441 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1444 while [ "$DEPS" ]; do
1445 update_shell_title "install deps: $DEPS"
1446 echo "Trying to install dependencies ($DEPS):"
1447 local log=.${SPECFILE}_poldek.log
1448 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1449 failed=$(awk -F: '/^error:/{print $2}' $log)
1452 if [ -n "$failed" ]; then
1453 for package in $failed; do
1454 # FIXME: sanitise, deps could be not .spec files
1455 spawn_sub_builder -bb $package && ok="$ok $package"
1465 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1466 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1467 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1468 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1469 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1470 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`
1472 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`"
1474 package=`basename "$package_item"|sed -e "s/}$//g"`
1475 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1478 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1479 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1480 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
1485 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1488 if `echo $COND_TST|grep -q 'without_'`; then
1489 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1490 if `echo $COND_TST|grep -q !`; then
1495 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1496 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1497 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1503 elif `echo $COND_TST|grep -q 'with_'`; then
1504 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1505 if `echo $COND_TST|grep -q !`; then
1510 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1511 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1512 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1518 RESULT="${COND_STATE}-${COND_ARGV}"
1520 "with-wout" | "wout-with" )
1523 "wout-wout" | "with-with" )
1527 echo "Action '$RESULT' was not defined for package '$package_item'"
1533 if [ "$GO" = "yes" ]; then
1534 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1535 echo "Testing if $package has subrequirements..."
1536 run_poldek -t -i $package --dumpn=".$package-req.txt"
1537 if [ -f ".$package-req.txt" ]; then
1538 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1540 if [ "$package_name" = "$package" ]; then
1541 echo -ne "Installing BuildRequired package:\t$package_name\n"
1542 update_shell_title "Installing BuildRequired package: ${package_name}"
1543 install_required_packages $package;
1545 echo -ne "Installing (sub)Required package:\t$package_name\n"
1546 update_shell_title "Installing (sub)Required package: ${package_name}"
1547 install_required_packages $package_name;
1551 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1552 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1555 echo "Attempting to run spawn sub - builder..."
1556 echo -ne "Package installation failed:\t$package_name\n"
1557 run_sub_builder $package_name
1558 if [ $? -eq 0 ]; then
1559 install_required_packages $package_name;
1562 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1563 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1566 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1573 rm -f ".$package-req.txt"
1575 echo "Attempting to run spawn sub - builder..."
1576 echo -ne "Package installation failed:\t$package\n"
1577 run_sub_builder $package
1578 if [ $? -eq 0 ]; then
1579 install_required_packages $package;
1582 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1583 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1586 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1592 echo "Package $package is already installed. BuildRequirement satisfied."
1596 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1597 echo "Unable to install following packages and their dependencies:"
1598 for pkg in "$NOT_INSTALLED_PACKAGES"
1602 remove_build_requires
1610 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1611 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1613 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1615 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,repackage.sh}
1619 echo "To checkout *all* .spec files:"
1620 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1621 echo "- run cvs up in $SPECS_DIR dir"
1624 echo "To commit with your developer account:"
1625 echo "- edit $SPECS_DIR/CVS/Root"
1626 echo "- edit $SOURCE_DIR/CVS/Root"
1629 #---------------------------------------------
1632 if [ "$#" = 0 ]; then
1658 DEBUG="yes"; shift ;;
1660 COMMAND="version"; shift ;;
1662 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1663 -b | -ba | --build )
1664 COMMAND="build"; shift ;;
1665 -bb | --build-binary )
1666 COMMAND="build-binary"; shift ;;
1667 -bs | --build-source )
1668 COMMAND="build-source"; shift ;;
1669 -bp | --build-prep )
1670 COMMAND="build-prep"; shift ;;
1672 COMMAND="branch"; shift; TAG="${1}"; shift;;
1674 CLEAN="--clean --rmspec --rmsource"; shift ;;
1676 shift; CVSROOT="${1}"; shift ;;
1678 COMMAND="get"; shift ;;
1680 COMMAND="usage"; shift ;;
1682 PROTOCOL="http"; shift ;;
1684 shift; LOGFILE="${1}"; shift ;;
1686 shift; DEF_NICE_LEVEL=${1}; shift ;;
1687 -ske | --skip-existing-files)
1688 SKIP_EXISTING_FILES="yes"; shift ;;
1690 COMMAND="mr-proper"; shift ;;
1692 NOCVS="yes"; shift ;;
1693 -ncs | --no-cvs-specs )
1694 NOCVSSPEC="yes"; shift ;;
1695 -nd | --no-distfiles )
1696 NODIST="yes"; shift ;;
1697 -nm | --no-mirrors )
1698 NOMIRRORS="yes"; shift ;;
1700 NOURLS="yes"; shift ;;
1702 NOSRCS="yes"; shift ;;
1703 -ns0 | --no-source0 )
1704 NOSOURCE0="yes"; shift ;;
1718 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1720 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1721 --with | --without )
1722 case $GROUP_BCONDS in
1726 while ! `echo ${1}|grep -qE '(^-|spec)'`
1728 BCOND="$BCOND $COND $1"
1732 if [[ "$2" = *,* ]]; then
1733 for a in $(echo "$2" | tr , ' '); do
1734 BCOND="$BCOND $1 $a"
1737 BCOND="$BCOND $1 $2"
1743 shift; TARGET="${1}"; shift ;;
1745 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1747 QUIET="--quiet"; shift ;;
1749 CVSDATE="${2}"; shift 2 ;;
1751 shift; CVSTAG="${1}"; shift ;;
1752 -R | --fetch-build-requires)
1753 FETCH_BUILD_REQUIRES="yes"
1754 NOT_INSTALLED_PACKAGES=
1756 -RB | --remove-build-requires)
1757 REMOVE_BUILD_REQUIRES="nice"
1759 -FRB | --force-remove-build-requires)
1760 REMOVE_BUILD_REQUIRES="force"
1762 -sd | --sources-distfiles)
1763 COMMAND="list-sources-distfiles"
1765 -sdp | --sources-distfiles-paths)
1766 COMMAND="list-sources-distfiles-paths"
1768 -sf | --sources-files)
1769 COMMAND="list-sources-files"
1771 -sp | --sources-paths)
1772 COMMAND="list-sources-local-paths"
1774 -su | --sources-urls)
1775 COMMAND="list-sources-urls"
1777 -Tvs | --tag-version-stable )
1782 -Tvn | --tag-version-nest )
1787 -Ts | --tag-stable )
1797 -Tv | --tag-version )
1802 -Tp | --tag-prefix )
1814 -ir | --integer-release-only )
1815 INTEGER_RELEASE="yes"
1824 -Upi | --update-poldek-indexes )
1825 UPDATE_POLDEK_INDEXES="yes"
1828 COMMAND="init_rpm_dir";
1830 -u | --try-upgrade )
1831 TRY_UPGRADE="1"; shift ;;
1832 -un | --try-upgrade-with-float-version )
1833 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1835 BE_VERBOSE="1"; shift ;;
1841 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1843 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1849 RPMOPTS="${RPMOPTS} --nodeps"
1852 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift ;;
1855 # check if specname was passed as specname:cvstag
1856 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
1857 CVSTAG="${SPECFILE##*:}";
1858 SPECFILE="${SPECFILE%%:*}";
1864 if [ -n "$DEBUG" ]; then
1869 if [ -n "$TARGET" ]; then
1872 TARGET_SWITCH="--target $TARGET" ;;
1874 TARGET_SWITCH="--target=$TARGET" ;;
1878 if [ "$SCHEDTOOL" != "no" ]; then
1879 NICE_COMMAND="$SCHEDTOOL"
1881 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
1884 update_shell_title "$COMMAND"
1886 "build" | "build-binary" | "build-source" | "build-prep" )
1888 if [ -n "$SPECFILE" ]; then
1894 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1895 fetch_build_requires;
1896 if [ "$INTEGER_RELEASE" = "yes" ]; then
1897 echo "Checking release $PACKAGE_RELEASE..."
1898 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1899 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1903 if [ -n "$TEST_TAG" ]; then
1904 TAGVER=`make_tagver`
1905 echo "Searching for tag $TAGVER..."
1906 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1907 if [ -n "$TAGREL" ]; then
1908 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1911 # - do not allow to build from HEAD when XX-branch exists
1912 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1913 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1914 TAG_BRANCH="${TREE_PREFIX}-branch"
1915 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1916 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1917 Exit_error err_branch_exists "$TAG_STATUS"
1922 if [ -n "$NOSOURCE0" ] ; then
1923 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1925 get_files $SOURCES $PATCHES;
1927 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1928 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1930 remove_build_requires;
1932 Exit_error err_no_spec_in_cmdl;
1937 if [ -n "$SPECFILE" ]; then
1940 get_files $SOURCES $PATCHES;
1941 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1943 Exit_error err_no_spec_in_cmdl;
1948 if [ -n "$SPECFILE" ]; then
1952 if [ -n "$NOSOURCE0" ] ; then
1953 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1955 get_files $SOURCES $PATCHES
1957 Exit_error err_no_spec_in_cmdl;
1964 if [ -n "$SPECFILE" ]; then
1968 # don't fetch sources from remote locations
1970 for file in $SOURCES
1972 [ -n "`src_md5 $file`" ] && continue
1973 new_SOURCES="$new_SOURCES $file"
1975 SOURCES="$new_SOURCES"
1976 get_files $SOURCES $PATCHES;
1977 tag_files "$SOURCES $PATCHES $ICONS";
1979 Exit_error err_no_spec_in_cmdl;
1983 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1985 "list-sources-files" )
1988 DONT_PRINT_REVISION="yes"
1991 SAPS="$SOURCES $PATCHES"
1992 for SAP in $SAPS ; do
1993 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1996 "list-sources-urls" )
1999 DONT_PRINT_REVISION="yes"
2002 SAPS="$SOURCES $PATCHES"
2003 for SAP in $SAPS ; do
2007 "list-sources-local-paths" )
2010 DONT_PRINT_REVISION="yes"
2013 SAPS="$SOURCES $PATCHES"
2014 for SAP in $SAPS ; do
2015 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2018 "list-sources-distfiles-paths" )
2021 DONT_PRINT_REVISION="yes"
2024 SAPS="$SOURCES $PATCHES"
2025 for SAP in $SAPS ; do
2026 if [ -n "$(src_md5 "$SAP")" ]; then
2027 distfiles_path "$SAP"
2031 "list-sources-distfiles" )
2034 DONT_PRINT_REVISION="yes"
2037 SAPS="$SOURCES $PATCHES"
2038 for SAP in $SAPS ; do
2039 if [ -n "$(src_md5 "$SAP")" ]; then
2040 distfiles_url "$SAP"
2052 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2053 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2057 # vi:syntax=sh:ts=4:sw=4