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 wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
130 if [ "$SCHEDTOOL" = "auto" ]; then
131 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
132 SCHEDTOOL="schedtool -B -e"
138 if [ -n "$USE_PROZILLA" ]; then
139 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
142 elif [ -n "$USE_AXEL" ]; then
143 GETURI="axel -a $AXEL_OPTS"
147 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
148 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
150 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
151 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
157 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
165 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
166 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
170 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
171 if [ -n "$LOGFILE" ]; then
172 LOG=`eval echo $LOGFILE`
173 if [ -n "$LASTLOG_FILE" ]; then
174 echo "LASTLOG=$LOG" > $LASTLOG_FILE
176 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
179 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
180 return `cat ${RES_FILE}`
185 #---------------------------------------------
190 if [ -n "$DEBUG" ]; then set -xv; fi
192 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
194 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
195 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
196 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
197 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
198 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
199 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
200 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
201 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
202 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec][:cvstag]
204 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
205 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
206 -n5, --no-md5 - ignore md5 comments in spec
207 -D, --debug - enable builder script debugging mode,
208 -debug - produce rpm debug package (same as --opts -debug)
209 -V, --version - output builder version
210 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
211 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
213 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
214 only package from <package>.spec,
215 -bp, --build-prep - execute the %prep phase of <package>.spec,
216 -bc - reserved (not implemented)
217 -bi reserved (not implemented)
218 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
220 --short-circuit - reserved (not implemented)
221 -B, --branch - add branch
222 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
223 SPECS and \$RPM_BUILD_ROOT),
224 -d <cvsroot>, --cvsroot <cvsroot>
226 --define <macro> <value>
227 - define a macro <macro> with value <value>,
228 --nodeps - rpm won't check any dependences
229 -g, --get - get <package>.spec and all related files from CVS repo
231 -h, --help - this message,
232 --http - use http instead of ftp,
233 -l <logfile>, --logtofile <logfile>
235 -m, --mr-proper - only remove all files related to spec file and all work
237 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
239 - don't check specs in CVS
240 -nd, --no-distfiles - don't download from distfiles
241 -nm, --no-mirrors - don't download from mirror, if source URL is given,
242 -nu, --no-urls - don't try to download from FTP/HTTP location,
243 -ns, --no-srcs - don't download Sources
244 -ns0, --no-source0 - don't download Source0
245 -nn, --no-net - don't download anything from the net
246 -ni, --no-init - don't initialize builder paths (SPECS and SOURCES)
248 --skip-existing-files - skip existing files in get_files
249 --opts <rpm opts> - additional options for rpm
250 -q, --quiet - be quiet,
251 --date yyyy-mm-dd - build package using resources from specified CVS date,
252 -r <cvstag>, --cvstag <cvstag>
253 - build package using resources from specified CVS tag,
254 -R, --fetch-build-requires
255 - fetch what is BuildRequired,
256 -RB, --remove-build-requires
257 - remove all you fetched with -R or --fetch-build-requires
258 remember, this option requires confirmation,
259 -FRB, --force-remove-build-requires
260 - remove all you fetched with -R or --fetch-build-requires
261 remember, this option works without confirmation,
262 -sd, --source-distfiles - list sources available from distfiles (intended for offline
263 operations; does not work when Icon field is present
264 but icon file is absent),
265 -sdp, --source-distfiles-paths - list sources available from distfiles -
266 paths relative to distfiles directory (intended for offline
267 operations; does not work when Icon field is present
268 but icon file is absent),
269 -sf, --source-files - list sources - bare filenames (intended for offline
270 operations; does not work when Icon field is present
271 but icon file is absent),
272 -sp, --source-paths - list sources - filenames with full local paths (intended for
273 offline operations; does not work when Icon field is present
274 but icon file is absent),
275 -su, --source-urls - list urls - urls to sources and patches
276 intended for copying urls with spec with lots of macros in urls
277 -T <cvstag> , --tag <cvstag>
278 - add cvs tag <cvstag> for files,
279 -Tvs, --tag-version-stable
280 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
281 -Tvn, --tag-version-nest
282 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
284 - add cvs tag STABLE for files,
286 - add cvs tag NEST for files,
288 - add cvs tag NAME-VERSION-RELEASE for files,
289 -Tp, --tag-prefix <prefix>
290 - add <prefix> to NAME-VERSION-RELEASE tags,
291 -tt, --test-tag <prefix>
292 - fail if tag is already present,
293 -ir, --integer-release-only
294 - allow only integer and snapshot releases
295 -v, --verbose - be verbose,
296 -u, --try-upgrade - check version, and try to upgrade package
297 -un, --try-upgrade-with-float-version
298 - as above, but allow float version
299 -U, --update - refetch sources, don't use distfiles, and update md5 comments
300 -Upi, --update-poldek-indexes
301 - refresh or make poldek package index files.
302 -np, --nopatch <patchnumber>
303 - don't apply <patchnumber>
304 --show-bconds - show available conditional builds, which can be used
305 - with --with and/or --without switches.
306 --with/--without <feature>
307 - conditional build package depending on %_with_<feature>/
308 %_without_<feature> macro switch. You may now use
309 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
310 constructions. Set GROUP_BCONDS to yes to make use of it.
311 --target <platform>, --target=<platform>
312 - build for platform <platform>.
313 --init-rpm-dir - initialize ~/rpm directory structure
317 update_shell_title() {
319 local len=${COLUMNS:-80}
320 local msg=$(echo "$*" | cut -c-$len)
322 if [ -n "$BE_VERBOSE" ]; then
323 echo >&2 "$(date +%s.%N) $*"
326 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
328 if [ -n "$PACKAGE_NAME" ]; then
329 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
334 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
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 $RPMBUILD --rcfile .builder-rpmrc $ARGS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
410 if [ $? -gt 0 ]; then
411 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
413 Exit_error err_build_fail;
416 # make small dump cache
417 rpm_dump_cache=`echo "$rpm_dump" | awk '
418 $2 ~ /^SOURCEURL/ {print}
419 $2 ~ /^PATCHURL/ {print}
420 $2 ~ /^nosource/ {print}
421 $2 ~ /^PACKAGE_/ {print}
424 update_shell_title "cache_rpm_dump: OK!"
428 if [ -z "$rpm_dump_cache" ] ; then
429 echo "internal error: cache_rpm_dump not called!" 1>&2
431 echo "$rpm_dump_cache"
436 update_shell_title "get icons"
437 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
438 if [ -z "$ICONS" ]; then
442 rpm_dump_cache="böö" NODIST="yes" UPDATE5= get_files $ICONS
447 update_shell_title "parsing specfile"
448 if [ -n "$DEBUG" ]; then
453 # icons are needed for successful spec parse
459 if [ "$NOSRCS" != "yes" ]; then
460 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
463 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
464 FAIL_IF_NO_SOURCES="no"
467 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
468 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
469 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
470 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
471 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
473 if [ -n "$BE_VERBOSE" ]; then
474 echo "- Sources : `nourl $SOURCES`"
475 if [ -n "$PATCHES" ]; then
476 echo "- Patches : `nourl $PATCHES`"
478 echo "- Patches : *no patches needed*"
480 if [ -n "$ICONS" ]; then
481 echo "- Icon : `nourl $ICONS`"
483 echo "- Icon : *no package icon*"
485 echo "- Name : $PACKAGE_NAME"
486 echo "- Version : $PACKAGE_VERSION"
487 echo "- Release : $PACKAGE_RELEASE"
490 update_shell_title "parse_spec: OK!"
495 if [ -n "$DEBUG" ]; then
503 "err_no_spec_in_cmdl" )
504 remove_build_requires
505 echo "ERROR: spec file name not specified.";
507 "err_no_spec_in_repo" )
508 remove_build_requires
509 echo "Error: spec file not stored in CVS repo.";
511 "err_no_source_in_repo" )
512 remove_build_requires
513 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
516 remove_build_requires
517 echo "Error: package build failed. (${2:-no more info})";
519 "err_no_package_data" )
520 remove_build_requires
521 echo "Error: couldn't get out package name/version/release from spec file."
524 remove_build_requires
525 echo "Tag ${2} already exists (spec release: ${3}).";
528 remove_build_requires
529 echo "Release ${2} not integer and not a snapshot.";
531 "err_branch_exists" )
532 remove_build_requires
533 echo "Tree branch already exists (${2}).";
537 echo "Unknown error."
543 if [ -n "$DEBUG" ]; then
548 if [ "$NOINIT" != "yes" ] ; then
549 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
550 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
562 update_shell_title "get_spec"
564 if [ -n "$DEBUG" ]; then
570 if [ ! -f "$SPECFILE" ]; then
571 SPECFILE="`basename $SPECFILE .spec`.spec";
573 if [ "$NOCVSSPEC" != "yes" ]; then
575 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
576 echo "Warning: No CVS access defined - using local .spec file"
580 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
583 if [ ! -f "$SPECFILE" ]; then
584 Exit_error err_no_spec_in_repo;
587 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
588 chmod $CHMOD_MODE $SPECFILE
591 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
600 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
601 cvs update mirrors >&2
605 while read origin mirror name rest
607 ol=`echo -n "$origin"|wc -c`
608 prefix="`echo -n "$url" | head -c $ol`"
609 if [ "$prefix" = "$origin" ] ; then
610 suffix="`echo "$url"|cut -b $ol-`"
611 echo -n "$mirror$suffix"
622 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
623 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
629 [ X"$NO5" = X"yes" ] && return
631 [ -z "$no" ] && return
633 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
634 if [ -z "$spec_rev" ]; then
635 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
637 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
638 md5=$(grep -s -v '^#' additional-md5sums | \
639 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
640 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
641 grep -E '^[0-9a-f]{32}$')
642 if [ X"$md5" = X"" ] ; then
643 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
644 if [ ! -z "$source_md5" ] ; then
647 # we have empty SourceX-md5, but it is still possible
648 # that we have NoSourceX-md5 AND NoSource: X
649 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
650 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
655 if [ $(echo "$md5" | wc -l) != 1 ] ; then
656 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
658 echo "$md5" | tail -n 1
664 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
669 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
672 distfiles_attic_url ()
674 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
681 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
686 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
687 [ -n "$size" -a "$size" -gt 0 ]
692 if [ "$CVSIGNORE_DF" != "yes" ]; then
695 cvsignore=${SOURCE_DIR}/.cvsignore
696 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
697 echo "$1" >> $cvsignore
703 update_shell_title "cvsup"
705 if [ -n "$CVSROOT" ]; then
706 OPTIONS="-d $CVSROOT $OPTIONS"
709 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
710 OPTIONS="$OPTIONS -A"
712 if [ -n "$CVSDATE" ]; then
713 OPTIONS="$OPTIONS -D $CVSDATE"
715 if [ -n "$CVSTAG" ]; then
716 OPTIONS="$OPTIONS -r $CVSTAG"
721 local retries_counter=0
723 update_shell_title "cvsup: $*"
725 update_shell_title "cvsup: $# files"
727 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
728 retries_counter=$(( $retries_counter + 1 ))
729 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
731 [ -n "$output" ] && echo "$output"
732 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
733 echo "Trying again [$*]... ($retries_counter)"
734 update_shell_title "cvsup: retry #$retries_counter"
741 update_shell_title "cvsup: done!"
747 update_shell_title "get_files"
749 if [ -n "$DEBUG" ]; then
754 if [ $# -gt 0 ]; then
757 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
758 echo "Warning: No CVS access defined for SOURCES"
763 local get_files_cvs=""
767 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
768 update_shell_title "$i"
769 local fp=`nourl "$i"`
770 if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then
773 if [ -n "$UPDATE5" ]; then
774 if [ -n "$ADD5" ]; then
775 [ "$fp" = "$i" ] && continue
776 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
778 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
782 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
783 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
784 echo "Warning: no URL given for $i"
787 if [ -z "$NODIST" ] && [ -n "$(src_md5 "$i")" ]; then
788 if good_md5 "$i" && good_size "$i"; then
789 echo "$(nourl "$i") having proper md5sum already exists"
793 url=$(distfiles_url "$i")
794 url_attic=$(distfiles_attic_url "$i")
796 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
797 update_shell_title "${GETLOCAL%% *}: $url"
798 ${GETLOCAL} $url $target
800 if [ -z "$NOMIRRORS" ]; then
801 url="`find_mirror "$url"`"
803 update_shell_title "${GETURI%% *}: $url"
804 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
805 if [ "`echo $url | grep -E 'ftp://'`" ]; then
806 update_shell_title "${GETURI2%% *}: $url"
807 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
810 if ! test -s "$target"; then
812 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
813 update_shell_title "${GETLOCAL%% *}: $url_attic"
814 ${GETLOCAL} $url_attic $target
816 if [ -z "$NOMIRRORS" ]; then
817 url_attic="`find_mirror "$url_attic"`"
819 update_shell_title "${GETURI%% *}: $url_attic"
820 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
821 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
822 update_shell_title "${GETURI2%% *}: $url_attic"
823 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
827 if test -s "$target"; then
833 elif [ "$NOCVS" != "yes" -a -z "$(src_md5 "$i")" ]; then
834 if [ $# -gt 1 ]; then
835 get_files_cvs="$get_files_cvs $fp"
836 update_shell_title "$fp (will cvs up later)"
843 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
844 if [ -z "$NOMIRRORS" ]; then
845 im="`find_mirror "$i"`"
849 update_shell_title "${GETURI%% *}: $im"
851 if [ "`echo $im | grep -E 'ftp://'`" ]; then
852 update_shell_title "${GETURI2%% *}: $im"
857 if [ "$cvsup" = 1 ]; then
863 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
864 Exit_error err_no_source_in_repo $i;
865 elif [ -n "$UPDATE5" ] && \
866 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
867 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
868 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
870 echo "Updating source-$srcno md5."
871 md5=$(md5sum "$fp" | cut -f1 -d' ')
873 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
874 print "# Source'$srcno'-md5:\t'$md5'\n"
875 if /^Source'$srcno'\s*:\s+/;
880 if good_md5 "$i" && good_size "$i"; then
882 elif [ "$FROM_DISTFILES" = 1 ]; then
883 # wrong md5 from distfiles: remove the file and try again
885 echo "MD5 sum mismatch. Trying full fetch."
888 update_shell_title "${GETURI%% *}: $url"
889 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
890 if [ "`echo $url | grep -E 'ftp://'`" ]; then
891 update_shell_title "${GETURI2%% *}: $url"
892 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
894 if ! test -s "$target"; then
896 update_shell_title "${GETURI%% *}: $url_attic"
897 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
898 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
899 update_shell_title "${GETURI2%% *}: $url_attic"
900 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
903 test -s "$target" || rm -f "$target"
906 if good_md5 "$i" && good_size "$i" ; then
909 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
910 echo "or -5 to update md5 sums, if you're sure files are correct."
911 Exit_error err_no_source_in_repo $i
914 SHELL_TITLE_PREFIX=""
916 if [ "$get_files_cvs" ]; then
920 if [ "$CHMOD" = "yes" ]; then
921 CHMOD_FILES="`nourl "$@"`"
922 if [ -n "$CHMOD_FILES" ]; then
923 chmod $CHMOD_MODE $CHMOD_FILES
931 if [ -n "$DEBUG" ]; then
936 # Check whether first character of PACKAGE_NAME is legal for tag name
937 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
940 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"`
941 # Remove #kernel.version_release from TAGVER because tagging sources
942 # could occur with different kernel-headers than kernel-headers used at build time.
943 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
951 if [ -n "$DEBUG" ]; then
956 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
957 echo "Version: $PACKAGE_VERSION"
958 echo "Release: $PACKAGE_RELEASE"
962 if [ "$TAG_VERSION" = "yes" ]; then
963 echo "CVS tag: $TAGVER"
965 if [ -n "$TAG" ]; then
970 if [ -n "$CVSROOT" ]; then
971 OPTIONS="-d $CVSROOT $OPTIONS"
977 # don't tag files stored on distfiles
978 [ -n "`src_md5 $i`" ] && continue
979 if [ -f "`nourl $i`" ]; then
980 if [ "$TAG_VERSION" = "yes" ]; then
981 cvs $OPTIONS $TAGVER `nourl $i`
983 if [ -n "$TAG" ]; then
984 cvs $OPTIONS $TAG `nourl $i`
987 Exit_error err_no_source_in_repo $i
992 if [ "$TAG_VERSION" = "yes" ]; then
993 cvs $OPTIONS $TAGVER $SPECFILE
995 if [ -n "$TAG" ]; then
996 cvs $OPTIONS $TAG $SPECFILE
1006 echo "CVS branch tag: $TAG"
1011 if [ -n "$DEBUG" ]; then
1016 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
1019 if [ -n "$CVSROOT" ]; then
1020 OPTIONS="-d $CVSROOT $OPTIONS"
1025 if [ -f `nourl $i` ]; then
1026 cvs $OPTIONS $TAG `nourl $i`
1028 Exit_error err_no_source_in_repo $i
1032 cvs $OPTIONS $TAG $SPECFILE
1042 update_shell_title "build_package"
1043 if [ -n "$DEBUG" ]; then
1050 if [ -n "$TRY_UPGRADE" ]; then
1051 update_shell_title "build_package: try_upgrade"
1052 if [ -n "$FLOAT_VERSION" ]; then
1053 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1055 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1058 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1060 if [ -n "$TNEWVER" ]; then
1061 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1062 echo "New version found, updating spec file to version " $TNEWVER
1063 cp -f $SPECFILE $SPECFILE.bak
1065 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1066 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1068 NODIST="yes" UPDATE5="yes" get_files $SOURCES $PATCHES;
1069 unset TOLDVER TNEWVER TNOTIFY
1076 BUILD_SWITCH="-ba" ;;
1078 BUILD_SWITCH="-bb" ;;
1080 BUILD_SWITCH="-bs --nodeps" ;;
1082 BUILD_SWITCH="-bp --nodeps" ;;
1085 update_shell_title "build_package: $COMMAND"
1086 if [ -n "$LOGFILE" ]; then
1087 LOG=`eval echo $LOGFILE`
1088 if [ -d "$LOG" ]; then
1089 echo "Log file $LOG is a directory."
1090 echo "Parse error in the spec?"
1091 Exit_error err_build_fail;
1093 if [ -n "$LASTLOG_FILE" ]; then
1094 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1096 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1097 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1098 RETVAL=`cat $RES_FILE`
1100 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1101 if [ "$RETVAL" -eq "0" ]; then
1108 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1111 if [ "$RETVAL" -ne "0" ]; then
1112 if [ -n "$TRY_UPGRADE" ]; then
1113 echo "\n!!! Package with new version cannot be built automagically\n"
1114 mv -f $SPECFILE.bak $SPECFILE
1116 Exit_error err_build_fail;
1123 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1126 install_required_packages()
1133 # taken from find-spec-bcond, but with just getting the list
1135 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1137 /^%changelog/ { exit }
1138 /_with(out)?_[_a-zA-Z0-9]+/{
1139 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1140 print substr($0, RSTART, RLENGTH);
1143 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1144 bcond = substr($0, RSTART +5 , RLENGTH -5);
1145 gsub(/[ \t]+/,"_",bcond);
1147 }' $SPEC | LC_ALL=C sort -u
1152 update_shell_title "set bcond values"
1154 AVAIL_BCONDS_WITHOUT=""
1155 AVAIL_BCONDS_WITH=""
1156 if `grep -q ^%bcond ${SPECFILE}`; then
1158 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1164 local bcond_avail=$(find_spec_bcond $SPECFILE)
1166 # expand bconds from ~/.bcondrc
1167 # The file structure is like gentoo's package.use:
1170 # samba -mysql -pgsql
1171 # w32codec-installer license_agreement
1174 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1175 SN=${SPECFILE%%\.spec}
1177 local bcondrc=$HOME/.bcondrc
1178 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1180 while read pkg flags; do
1182 [[ "$pkg" == \#* ]] && continue
1184 # any package or current package?
1185 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1186 for flag in $flags; do
1187 local opt=${flag#[+-]}
1189 # use only flags which are in this package.
1190 if [[ $bcond_avail = *${opt}* ]]; then
1191 if [[ $flag = -* ]]; then
1192 BCOND="$BCOND --without $opt"
1194 BCOND="$BCOND --with $opt"
1200 update_shell_title "parse ~/.bcondrc: DONE!"
1203 update_shell_title "parse bconds"
1204 case "${BCOND_VERSION}" in
1209 echo "Warning: This spec has old style bconds. Fix it || die."
1210 for opt in `echo "$bcond_avail" | grep ^_without_`
1212 AVAIL_BCOND_WITHOUT=${opt#_without_}
1213 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1214 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1216 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1220 for opt in `echo "$bcond_avail" | grep ^_with_`
1222 AVAIL_BCOND_WITH=${opt#_with_}
1223 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1224 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1226 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1231 local cond_type="" # with || without
1232 for opt in $bcond_avail; do
1241 AVAIL_BCOND_WITHOUT=${opt#_without_}
1242 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1243 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1245 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1249 AVAIL_BCOND_WITH=${opt#_with_}
1250 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1251 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1253 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1257 case "$cond_type" in
1260 AVAIL_BCOND_WITH="$opt"
1261 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1262 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1264 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1269 AVAIL_BCOND_WITHOUT="$opt"
1270 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1271 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1273 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1287 update_shell_title "run_sub_builder $package_name"
1289 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1290 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1291 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1292 # jakby nie bylo tego kawalka kodu.
1294 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1295 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1302 # Istnieje taki spec? ${package}.spec
1303 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1304 parent_spec_name=${package}.spec
1305 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1306 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1308 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1314 if [ "${parent_spec_name}" != "" ]; then
1315 spawn_sub_builder $parent_spec_name
1317 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1323 update_shell_title "spawn_sub_builder $package_name"
1326 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1327 sub_builder_opts="${sub_builder_opts} -R"
1329 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1330 sub_builder_opts="${sub_builder_opts} -RB"
1331 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1332 sub_builder_opts="${sub_builder_opts} -FRB"
1334 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1335 sub_builder_opts="${sub_builder_opts} -Upi"
1339 ./builder ${sub_builder_opts} "$@"
1342 remove_build_requires()
1344 if [ "$INSTALLED_PACKAGES" != "" ]; then
1345 case "$REMOVE_BUILD_REQUIRES" in
1347 run_poldek --noask -ve $INSTALLED_PACKAGES
1350 run_poldek --ask -ve $INSTALLED_PACKAGES
1353 echo You may want to manually remove following BuildRequires fetched:
1354 echo $INSTALLED_PACKAGES
1355 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1363 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1364 if [ "$BCOND" != "" ]; then
1365 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1368 echo -ne "\nNo conditional flags passed"
1370 echo -ne "\n\nfrom available:\n"
1371 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1377 if [ "$NOCVSSPEC" != "yes" ]; then
1378 echo -ne "Available branches: "
1379 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1383 # checks a given list of packages/files/provides agains current rpmdb.
1384 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1385 # input can be either STDIN or parameters
1390 if [ "$#" -gt 0 ]; then
1396 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1399 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1401 # other deps (files)
1402 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1405 # checks if given package/files/provides exists in rpmdb.
1406 # inout can be either stdin or parameters
1407 # returns packages wchi hare present in the rpmdb
1412 if [ "$#" -gt 0 ]; then
1418 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1421 fetch_build_requires()
1423 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1424 update_shell_title "fetch build requires"
1425 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1426 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1427 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1429 update_shell_title "poldek: update indexes"
1430 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1431 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1433 if [ -n "$CONF" ]; then
1434 update_shell_title "uninstall conflicting packages: $CONF"
1435 echo "Trying to uninstall conflicting packages ($CONF):"
1436 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1439 while [ "$DEPS" ]; do
1440 update_shell_title "install deps: $DEPS"
1441 echo "Trying to install dependencies ($DEPS):"
1442 local log=.${SPECFILE}_poldek.log
1443 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1444 failed=$(awk -F: '/^error:/{print $2}' $log)
1447 if [ -n "$failed" ]; then
1448 for package in $failed; do
1449 # FIXME: sanitise, deps could be not .spec files
1450 spawn_sub_builder -bb $package && ok="$ok $package"
1460 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1461 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1462 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1463 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1464 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1465 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`
1467 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`"
1469 package=`basename "$package_item"|sed -e "s/}$//g"`
1470 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1473 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1474 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1475 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
1480 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1483 if `echo $COND_TST|grep -q 'without_'`; then
1484 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1485 if `echo $COND_TST|grep -q !`; then
1490 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1491 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1492 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1498 elif `echo $COND_TST|grep -q 'with_'`; then
1499 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1500 if `echo $COND_TST|grep -q !`; then
1505 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1506 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1507 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1513 RESULT="${COND_STATE}-${COND_ARGV}"
1515 "with-wout" | "wout-with" )
1518 "wout-wout" | "with-with" )
1522 echo "Action '$RESULT' was not defined for package '$package_item'"
1528 if [ "$GO" = "yes" ]; then
1529 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1530 echo "Testing if $package has subrequirements..."
1531 run_poldek -t -i $package --dumpn=".$package-req.txt"
1532 if [ -f ".$package-req.txt" ]; then
1533 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1535 if [ "$package_name" = "$package" ]; then
1536 echo -ne "Installing BuildRequired package:\t$package_name\n"
1537 update_shell_title "Installing BuildRequired package: ${package_name}"
1538 install_required_packages $package;
1540 echo -ne "Installing (sub)Required package:\t$package_name\n"
1541 update_shell_title "Installing (sub)Required package: ${package_name}"
1542 install_required_packages $package_name;
1546 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1547 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1550 echo "Attempting to run spawn sub - builder..."
1551 echo -ne "Package installation failed:\t$package_name\n"
1552 run_sub_builder $package_name
1553 if [ $? -eq 0 ]; then
1554 install_required_packages $package_name;
1557 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1558 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1561 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1568 rm -f ".$package-req.txt"
1570 echo "Attempting to run spawn sub - builder..."
1571 echo -ne "Package installation failed:\t$package\n"
1572 run_sub_builder $package
1573 if [ $? -eq 0 ]; then
1574 install_required_packages $package;
1577 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1578 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1581 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1587 echo "Package $package is already installed. BuildRequirement satisfied."
1591 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1592 echo "Unable to install following packages and their dependencies:"
1593 for pkg in "$NOT_INSTALLED_PACKAGES"
1597 remove_build_requires
1605 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1606 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1608 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1610 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,repackage.sh}
1614 echo "To checkout *all* .spec files:"
1615 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1616 echo "- run cvs up in $SPECS_DIR dir"
1619 echo "To commit with your developer account:"
1620 echo "- edit $SPECS_DIR/CVS/Root"
1621 echo "- edit $SOURCE_DIR/CVS/Root"
1624 #---------------------------------------------
1627 if [ "$#" = 0 ]; then
1653 DEBUG="yes"; shift ;;
1655 COMMAND="version"; shift ;;
1657 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1658 -b | -ba | --build )
1659 COMMAND="build"; shift ;;
1660 -bb | --build-binary )
1661 COMMAND="build-binary"; shift ;;
1662 -bs | --build-source )
1663 COMMAND="build-source"; shift ;;
1664 -bp | --build-prep )
1665 COMMAND="build-prep"; shift ;;
1667 COMMAND="branch"; shift; TAG="${1}"; shift;;
1669 CLEAN="--clean --rmspec --rmsource"; shift ;;
1671 shift; CVSROOT="${1}"; shift ;;
1673 COMMAND="get"; shift ;;
1675 COMMAND="usage"; shift ;;
1677 PROTOCOL="http"; shift ;;
1679 shift; LOGFILE="${1}"; shift ;;
1681 shift; DEF_NICE_LEVEL=${1}; shift ;;
1682 -ske | --skip-existing-files)
1683 SKIP_EXISTING_FILES="yes"; shift ;;
1685 COMMAND="mr-proper"; shift ;;
1687 NOCVS="yes"; shift ;;
1688 -ncs | --no-cvs-specs )
1689 NOCVSSPEC="yes"; shift ;;
1690 -nd | --no-distfiles )
1691 NODIST="yes"; shift ;;
1692 -nm | --no-mirrors )
1693 NOMIRRORS="yes"; shift ;;
1695 NOURLS="yes"; shift ;;
1697 NOSRCS="yes"; shift ;;
1698 -ns0 | --no-source0 )
1699 NOSOURCE0="yes"; shift ;;
1713 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1715 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1716 --with | --without )
1717 case $GROUP_BCONDS in
1721 while ! `echo ${1}|grep -qE '(^-|spec)'`
1723 BCOND="$BCOND $COND $1"
1727 if [[ "$2" = *,* ]]; then
1728 for a in $(echo "$2" | tr , ' '); do
1729 BCOND="$BCOND $1 $a"
1732 BCOND="$BCOND $1 $2"
1738 shift; TARGET="${1}"; shift ;;
1740 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1742 QUIET="--quiet"; shift ;;
1744 CVSDATE="${2}"; shift 2 ;;
1746 shift; CVSTAG="${1}"; shift ;;
1747 -R | --fetch-build-requires)
1748 FETCH_BUILD_REQUIRES="yes"
1749 NOT_INSTALLED_PACKAGES=
1751 -RB | --remove-build-requires)
1752 REMOVE_BUILD_REQUIRES="nice"
1754 -FRB | --force-remove-build-requires)
1755 REMOVE_BUILD_REQUIRES="force"
1757 -sd | --sources-distfiles)
1758 COMMAND="list-sources-distfiles"
1760 -sdp | --sources-distfiles-paths)
1761 COMMAND="list-sources-distfiles-paths"
1763 -sf | --sources-files)
1764 COMMAND="list-sources-files"
1766 -sp | --sources-paths)
1767 COMMAND="list-sources-local-paths"
1769 -su | --sources-urls)
1770 COMMAND="list-sources-urls"
1772 -Tvs | --tag-version-stable )
1777 -Tvn | --tag-version-nest )
1782 -Ts | --tag-stable )
1792 -Tv | --tag-version )
1797 -Tp | --tag-prefix )
1809 -ir | --integer-release-only )
1810 INTEGER_RELEASE="yes"
1819 -Upi | --update-poldek-indexes )
1820 UPDATE_POLDEK_INDEXES="yes"
1823 COMMAND="init_rpm_dir";
1825 -u | --try-upgrade )
1826 TRY_UPGRADE="1"; shift ;;
1827 -un | --try-upgrade-with-float-version )
1828 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1830 BE_VERBOSE="1"; shift ;;
1836 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1838 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1844 RPMOPTS="${RPMOPTS} --nodeps"
1847 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift ;;
1850 # check if specname was passed as specname:cvstag
1851 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
1852 CVSTAG="${SPECFILE##*:}";
1853 SPECFILE="${SPECFILE%%:*}";
1859 if [ -n "$DEBUG" ]; then
1864 if [ -n "$TARGET" ]; then
1867 TARGET_SWITCH="--target $TARGET" ;;
1869 TARGET_SWITCH="--target=$TARGET" ;;
1873 if [ "$SCHEDTOOL" != "no" ]; then
1874 NICE_COMMAND="$SCHEDTOOL"
1876 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
1879 update_shell_title "$COMMAND"
1881 "build" | "build-binary" | "build-source" | "build-prep" )
1883 if [ -n "$SPECFILE" ]; then
1889 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1890 fetch_build_requires;
1891 if [ "$INTEGER_RELEASE" = "yes" ]; then
1892 echo "Checking release $PACKAGE_RELEASE..."
1893 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1894 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1898 if [ -n "$TEST_TAG" ]; then
1899 TAGVER=`make_tagver`
1900 echo "Searching for tag $TAGVER..."
1901 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1902 if [ -n "$TAGREL" ]; then
1903 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1906 # - do not allow to build from HEAD when XX-branch exists
1907 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1908 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1909 TAG_BRANCH="${TREE_PREFIX}-branch"
1910 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1911 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1912 Exit_error err_branch_exists "$TAG_STATUS"
1918 if [ -n "$NOSOURCE0" ] ; then
1919 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1921 get_files $SOURCES $PATCHES;
1923 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1924 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1926 remove_build_requires;
1928 Exit_error err_no_spec_in_cmdl;
1933 if [ -n "$SPECFILE" ]; then
1936 get_files $SOURCES $PATCHES;
1937 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1939 Exit_error err_no_spec_in_cmdl;
1944 if [ -n "$SPECFILE" ]; then
1948 if [ -n "$NOSOURCE0" ] ; then
1949 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1951 get_files $SOURCES $PATCHES
1953 Exit_error err_no_spec_in_cmdl;
1960 if [ -n "$SPECFILE" ]; then
1964 # don't fetch sources from remote locations
1966 for file in $SOURCES
1968 [ -n "`src_md5 $file`" ] && continue
1969 new_SOURCES="$new_SOURCES $file"
1971 SOURCES="$new_SOURCES"
1972 get_files $SOURCES $PATCHES;
1973 tag_files "$SOURCES $PATCHES $ICONS";
1975 Exit_error err_no_spec_in_cmdl;
1979 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1981 "list-sources-files" )
1984 DONT_PRINT_REVISION="yes"
1987 SAPS="$SOURCES $PATCHES"
1988 for SAP in $SAPS ; do
1989 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1992 "list-sources-urls" )
1995 DONT_PRINT_REVISION="yes"
1998 SAPS="$SOURCES $PATCHES"
1999 for SAP in $SAPS ; do
2003 "list-sources-local-paths" )
2006 DONT_PRINT_REVISION="yes"
2009 SAPS="$SOURCES $PATCHES"
2010 for SAP in $SAPS ; do
2011 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2014 "list-sources-distfiles-paths" )
2017 DONT_PRINT_REVISION="yes"
2020 SAPS="$SOURCES $PATCHES"
2021 for SAP in $SAPS ; do
2022 if [ -n "$(src_md5 "$SAP")" ]; then
2023 distfiles_path "$SAP"
2027 "list-sources-distfiles" )
2030 DONT_PRINT_REVISION="yes"
2033 SAPS="$SOURCES $PATCHES"
2034 for SAP in $SAPS ; do
2035 if [ -n "$(src_md5 "$SAP")" ]; then
2036 distfiles_url "$SAP"
2048 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2049 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2053 # vi:syntax=sh:ts=4:sw=4