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"
44 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
47 # It can be used i.e. in log file naming.
48 # See LOGFILE example.
49 DATE=`date +%Y-%m-%d_%H-%M-%S`
51 # Example: LOGFILE='../log.$PACKAGE_NAME'
52 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
53 # Yes, you can use variable name! Note _single_ quotes!
76 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
77 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
82 CVS_SERVER="cvs.pld-linux.org"
83 DISTFILES_SERVER="://distfiles.pld-linux.org"
84 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
89 FAIL_IF_NO_SOURCES="yes"
91 # let get_files skip over files which are present to get those damn files fetched
92 SKIP_EXISTING_FILES="no"
94 if [ -x /usr/bin/rpm-getdeps ]; then
95 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
97 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
100 # Here we load saved user environment used to
101 # predefine options set above, or passed to builder
103 # This one reads global system environment settings:
104 if [ -f ~/etc/builderrc ]; then
107 # And this one cascades settings using user personal
109 # Example of ~/.builderrc:
111 #UPDATE_POLDEK_INDEXES="yes"
112 #FETCH_BUILD_REQUIRES="yes"
113 #REMOVE_BUILD_REQUIRES="force"
115 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
119 if [ -n "$HOME_ETC" ]; then
120 USER_CFG="$HOME_ETC/.builderrc"
122 USER_CFG=~/.builderrc
125 [ -f "$USER_CFG" ] && . "$USER_CFG"
127 wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
129 if [ "$SCHEDTOOL" = "auto" ]; then
130 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
131 SCHEDTOOL="schedtool -B -e"
137 if [ -n "$USE_PROZILLA" ]; then
138 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
141 elif [ -n "$USE_AXEL" ]; then
142 GETURI="axel -a $AXEL_OPTS"
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 -ni, --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"
336 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
339 echo >&2 -ne "\033]0;$msg\007"
345 # set TARGET from BuildArch: from SPECFILE
347 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
348 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
353 TARGET_SWITCH="--target $TARGET" ;;
355 TARGET_SWITCH="--target=$TARGET" ;;
362 if [ -n "$DEBUG" ]; then
367 update_shell_title "cache_rpm_dump"
371 # we reset macros not to contain macros.build as all the %() macros are
372 # executed here, while none of them are actually needed.
373 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
374 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
375 macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.builder-rpmmacros:~/etc/.rpmmacros:~/.rpmmacros"
376 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
377 # FIXME: better ideas than .rpmrc?
378 printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .builder-rpmrc
379 # TODO: move these to /usr/lib/rpm/macros
380 cat > .builder-rpmmacros <<'EOF'
381 %requires_releq_kernel_up %{nil}
382 %requires_releq_kernel_smp %{nil}
383 %requires_releq() %{nil}
384 %pyrequires_eq() %{nil}
385 %requires_eq() %{nil}
386 %requires_eq_to() %{nil}
387 %releq_kernel_up ERROR
388 %releq_kernel_smp ERROR
392 %ruby_ver_requires_eq() %{nil}
393 %ruby_mod_ver_requires_eq() %{nil}
394 %__php_api_requires() %{nil}
395 %php_major_version ERROR
396 %php_api_version ERROR
404 ARGS='--nodigest --nosignature --nobuild'
407 $RPMBUILD --rcfile .builder-rpmrc $ARGS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
409 if [ $? -gt 0 ]; then
410 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
412 Exit_error err_build_fail;
415 # make small dump cache
416 rpm_dump_cache=`echo "$rpm_dump" | awk '
417 $2 ~ /^SOURCEURL/ {print}
418 $2 ~ /^PATCHURL/ {print}
419 $2 ~ /^nosource/ {print}
420 $2 ~ /^PACKAGE_/ {print}
423 update_shell_title "cache_rpm_dump: OK!"
427 if [ -z "$rpm_dump_cache" ] ; then
428 echo "internal error: cache_rpm_dump not called!" 1>&2
430 echo "$rpm_dump_cache"
435 update_shell_title "get icons"
436 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
437 if [ -z "$ICONS" ]; then
441 rpm_dump_cache="böö" "NODIST="yes" UPDATE5= get_files $ICONS
446 update_shell_title "parsing specfile"
447 if [ -n "$DEBUG" ]; then
452 # icons are needed for successful spec parse
458 if [ "$NOSRCS" != "yes" ]; then
459 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
462 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
463 FAIL_IF_NO_SOURCES="no"
466 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
467 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
468 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
469 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
470 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
472 if [ -n "$BE_VERBOSE" ]; then
473 echo "- Sources : `nourl $SOURCES`"
474 if [ -n "$PATCHES" ]; then
475 echo "- Patches : `nourl $PATCHES`"
477 echo "- Patches : *no patches needed*"
479 if [ -n "$ICONS" ]; then
480 echo "- Icon : `nourl $ICONS`"
482 echo "- Icon : *no package icon*"
484 echo "- Name : $PACKAGE_NAME"
485 echo "- Version : $PACKAGE_VERSION"
486 echo "- Release : $PACKAGE_RELEASE"
489 update_shell_title "parse_spec: OK!"
494 if [ -n "$DEBUG" ]; then
502 "err_no_spec_in_cmdl" )
503 remove_build_requires
504 echo "ERROR: spec file name not specified.";
506 "err_no_spec_in_repo" )
507 remove_build_requires
508 echo "Error: spec file not stored in CVS repo.";
510 "err_no_source_in_repo" )
511 remove_build_requires
512 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
515 remove_build_requires
516 echo "Error: package build failed. (${2:-no more info})";
518 "err_no_package_data" )
519 remove_build_requires
520 echo "Error: couldn't get out package name/version/release from spec file."
523 remove_build_requires
524 echo "Tag ${2} already exists (spec release: ${3}).";
527 remove_build_requires
528 echo "Release ${2} not integer and not a snapshot.";
530 "err_branch_exists" )
531 remove_build_requires
532 echo "Tree branch already exists (${2}).";
536 echo "Unknown error."
542 if [ -n "$DEBUG" ]; then
547 if [ "$NOINIT" != "yes" ] ; then
548 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
549 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
561 update_shell_title "get_spec"
563 if [ -n "$DEBUG" ]; then
569 if [ ! -f "$SPECFILE" ]; then
570 SPECFILE="`basename $SPECFILE .spec`.spec";
572 if [ "$NOCVSSPEC" != "yes" ]; then
574 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
575 echo "Warning: No CVS access defined - using local .spec file"
579 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
582 if [ ! -f "$SPECFILE" ]; then
583 Exit_error err_no_spec_in_repo;
586 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
587 chmod $CHMOD_MODE $SPECFILE
590 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
599 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
600 cvs update mirrors >&2
604 while read origin mirror name rest
606 ol=`echo -n "$origin"|wc -c`
607 prefix="`echo -n "$url" | head -c $ol`"
608 if [ "$prefix" = "$origin" ] ; then
609 suffix="`echo "$url"|cut -b $ol-`"
610 echo -n "$mirror$suffix"
621 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
622 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
628 [ X"$NO5" = X"yes" ] && return
630 [ -z "$no" ] && return
632 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
633 if [ -z "$spec_rev" ]; then
634 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
636 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
637 md5=$(grep -s -v '^#' additional-md5sums | \
638 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
639 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
640 grep -E '^[0-9a-f]{32}$')
641 if [ X"$md5" = X"" ] ; then
642 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
643 if [ ! -z "$source_md5" ] ; then
646 # we have empty SourceX-md5, but it is still possible
647 # that we have NoSourceX-md5 AND NoSource: X
648 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
649 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
654 if [ $(echo "$md5" | wc -l) != 1 ] ; then
655 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
657 echo "$md5" | tail -n 1
663 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
668 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
671 distfiles_attic_url ()
673 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
680 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
685 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
686 [ -n "$size" -a "$size" -gt 0 ]
691 if [ "$CVSIGNORE_DF" != "yes" ]; then
694 cvsignore=${SOURCE_DIR}/.cvsignore
695 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
696 echo "$1" >> $cvsignore
702 update_shell_title "cvsup"
704 if [ -n "$CVSROOT" ]; then
705 OPTIONS="-d $CVSROOT $OPTIONS"
708 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
709 OPTIONS="$OPTIONS -A"
711 if [ -n "$CVSDATE" ]; then
712 OPTIONS="$OPTIONS -D $CVSDATE"
714 if [ -n "$CVSTAG" ]; then
715 OPTIONS="$OPTIONS -r $CVSTAG"
720 local retries_counter=0
722 update_shell_title "cvsup: $*"
724 update_shell_title "cvsup: $# files"
726 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
727 retries_counter=$(( $retries_counter + 1 ))
728 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
730 [ -n "$output" ] && echo "$output"
731 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
732 echo "Trying again [$*]... ($retries_counter)"
733 update_shell_title "cvsup: retry #$retries_counter"
740 update_shell_title "cvsup: done!"
746 update_shell_title "get_files"
748 if [ -n "$DEBUG" ]; then
753 if [ $# -gt 0 ]; then
756 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
757 echo "Warning: No CVS access defined for SOURCES"
762 local get_files_cvs=""
766 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
767 update_shell_title "$i"
768 local fp=`nourl "$i"`
769 if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then
772 if [ -n "$UPDATE5" ]; then
773 if [ -n "$ADD5" ]; then
774 [ "$fp" = "$i" ] && continue
775 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
777 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
781 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
782 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
783 echo "Warning: no URL given for $i"
786 if [ -z "$NODIST" ] && [ -n "$(src_md5 "$i")" ]; then
787 if good_md5 "$i" && good_size "$i"; then
788 echo "$(nourl "$i") having proper md5sum already exists"
792 url=$(distfiles_url "$i")
793 url_attic=$(distfiles_attic_url "$i")
795 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
796 update_shell_title "${GETLOCAL%% *}: $url"
797 ${GETLOCAL} $url $target
799 if [ -z "$NOMIRRORS" ]; then
800 url="`find_mirror "$url"`"
802 update_shell_title "${GETURI%% *}: $url"
803 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
804 if [ "`echo $url | grep -E 'ftp://'`" ]; then
805 update_shell_title "${GETURI2%% *}: $url"
806 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
809 if ! test -s "$target"; then
811 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
812 update_shell_title "${GETLOCAL%% *}: $url_attic"
813 ${GETLOCAL} $url_attic $target
815 if [ -z "$NOMIRRORS" ]; then
816 url_attic="`find_mirror "$url_attic"`"
818 update_shell_title "${GETURI%% *}: $url_attic"
819 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
820 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
821 update_shell_title "${GETURI2%% *}: $url_attic"
822 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
826 if test -s "$target"; then
832 elif [ "$NOCVS" != "yes" -a -z "$(src_md5 "$i")" ]; then
833 if [ $# -gt 1 ]; then
834 get_files_cvs="$get_files_cvs $fp"
835 update_shell_title "$fp (will cvs up later)"
842 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
843 if [ -z "$NOMIRRORS" ]; then
844 im="`find_mirror "$i"`"
848 update_shell_title "${GETURI%% *}: $im"
850 if [ "`echo $im | grep -E 'ftp://'`" ]; then
851 update_shell_title "${GETURI2%% *}: $im"
856 if [ "$cvsup" = 1 ]; then
862 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
863 Exit_error err_no_source_in_repo $i;
864 elif [ -n "$UPDATE5" ] && \
865 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
866 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
867 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
869 echo "Updating source-$srcno md5."
870 md5=$(md5sum "$fp" | cut -f1 -d' ')
872 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
873 print "# Source'$srcno'-md5:\t'$md5'\n"
874 if /^Source'$srcno'\s*:\s+/;
879 if good_md5 "$i" && good_size "$i"; then
881 elif [ "$FROM_DISTFILES" = 1 ]; then
882 # wrong md5 from distfiles: remove the file and try again
884 echo "MD5 sum mismatch. Trying full fetch."
887 update_shell_title "${GETURI%% *}: $url"
888 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
889 if [ "`echo $url | grep -E 'ftp://'`" ]; then
890 update_shell_title "${GETURI2%% *}: $url"
891 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
893 if ! test -s "$target"; then
895 update_shell_title "${GETURI%% *}: $url_attic"
896 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
897 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
898 update_shell_title "${GETURI2%% *}: $url_attic"
899 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
902 test -s "$target" || rm -f "$target"
905 if good_md5 "$i" && good_size "$i" ; then
908 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
909 echo "or -5 to update md5 sums, if you're sure files are correct."
910 Exit_error err_no_source_in_repo $i
913 SHELL_TITLE_PREFIX=""
915 if [ "$get_files_cvs" ]; then
919 if [ "$CHMOD" = "yes" ]; then
920 CHMOD_FILES="`nourl "$@"`"
921 if [ -n "$CHMOD_FILES" ]; then
922 chmod $CHMOD_MODE $CHMOD_FILES
930 if [ -n "$DEBUG" ]; then
935 # Check whether first character of PACKAGE_NAME is legal for tag name
936 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
939 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"`
940 # Remove #kernel.version_release from TAGVER because tagging sources
941 # could occur with different kernel-headers than kernel-headers used at build time.
942 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
950 if [ -n "$DEBUG" ]; then
955 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
956 echo "Version: $PACKAGE_VERSION"
957 echo "Release: $PACKAGE_RELEASE"
961 if [ "$TAG_VERSION" = "yes" ]; then
962 echo "CVS tag: $TAGVER"
964 if [ -n "$TAG" ]; then
969 if [ -n "$CVSROOT" ]; then
970 OPTIONS="-d $CVSROOT $OPTIONS"
976 # don't tag files stored on distfiles
977 [ -n "`src_md5 $i`" ] && continue
978 if [ -f "`nourl $i`" ]; then
979 if [ "$TAG_VERSION" = "yes" ]; then
980 cvs $OPTIONS $TAGVER `nourl $i`
982 if [ -n "$TAG" ]; then
983 cvs $OPTIONS $TAG `nourl $i`
986 Exit_error err_no_source_in_repo $i
991 if [ "$TAG_VERSION" = "yes" ]; then
992 cvs $OPTIONS $TAGVER $SPECFILE
994 if [ -n "$TAG" ]; then
995 cvs $OPTIONS $TAG $SPECFILE
1005 echo "CVS branch tag: $TAG"
1010 if [ -n "$DEBUG" ]; then
1015 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
1018 if [ -n "$CVSROOT" ]; then
1019 OPTIONS="-d $CVSROOT $OPTIONS"
1024 if [ -f `nourl $i` ]; then
1025 cvs $OPTIONS $TAG `nourl $i`
1027 Exit_error err_no_source_in_repo $i
1031 cvs $OPTIONS $TAG $SPECFILE
1041 update_shell_title "build_package"
1042 if [ -n "$DEBUG" ]; then
1049 if [ -n "$TRY_UPGRADE" ]; then
1050 update_shell_title "build_package: try_upgrade"
1051 if [ -n "$FLOAT_VERSION" ]; then
1052 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1054 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1057 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1059 if [ -n "$TNEWVER" ]; then
1060 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1061 echo "New version found, updating spec file to version " $TNEWVER
1062 cp -f $SPECFILE $SPECFILE.bak
1064 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1065 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1067 NODIST="yes" UPDATE5="yes" get_files $SOURCES $PATCHES;
1068 unset TOLDVER TNEWVER TNOTIFY
1075 BUILD_SWITCH="-ba" ;;
1077 BUILD_SWITCH="-bb" ;;
1079 BUILD_SWITCH="-bs --nodeps" ;;
1081 BUILD_SWITCH="-bp --nodeps" ;;
1084 update_shell_title "build_package: $COMMAND"
1085 if [ -n "$LOGFILE" ]; then
1086 LOG=`eval echo $LOGFILE`
1087 if [ -d "$LOG" ]; then
1088 echo "Log file $LOG is a directory."
1089 echo "Parse error in the spec?"
1090 Exit_error err_build_fail;
1092 if [ -n "$LASTLOG_FILE" ]; then
1093 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1095 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1096 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1097 RETVAL=`cat $RES_FILE`
1099 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1100 if [ "$RETVAL" -eq "0" ]; then
1107 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1110 if [ "$RETVAL" -ne "0" ]; then
1111 if [ -n "$TRY_UPGRADE" ]; then
1112 echo "\n!!! Package with new version cannot be built automagically\n"
1113 mv -f $SPECFILE.bak $SPECFILE
1115 Exit_error err_build_fail;
1122 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1125 install_required_packages()
1132 # taken from find-spec-bcond, but with just getting the list
1134 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1136 /^%changelog/ { exit }
1137 /_with(out)?_[_a-zA-Z0-9]+/{
1138 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1139 print substr($0, RSTART, RLENGTH);
1142 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1143 bcond = substr($0, RSTART +5 , RLENGTH -5);
1144 gsub(/[ \t]+/,"_",bcond);
1146 }' $SPEC | LC_ALL=C sort -u
1151 update_shell_title "set bcond values"
1153 AVAIL_BCONDS_WITHOUT=""
1154 AVAIL_BCONDS_WITH=""
1155 if `grep -q ^%bcond ${SPECFILE}`; then
1157 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1163 local bcond_avail=$(find_spec_bcond $SPECFILE)
1165 # expand bconds from ~/.bcondrc
1166 # The file structure is like gentoo's package.use:
1169 # samba -mysql -pgsql
1170 # w32codec-installer license_agreement
1173 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1174 SN=${SPECFILE%%\.spec}
1176 local bcondrc=$HOME/.bcondrc
1177 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1179 while read pkg flags; do
1181 [[ "$pkg" == \#* ]] && continue
1183 # any package or current package?
1184 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1185 for flag in $flags; do
1186 local opt=${flag#[+-]}
1188 # use only flags which are in this package.
1189 if [[ $bcond_avail = *${opt}* ]]; then
1190 if [[ $flag = -* ]]; then
1191 BCOND="$BCOND --without $opt"
1193 BCOND="$BCOND --with $opt"
1199 update_shell_title "parse ~/.bcondrc: DONE!"
1202 update_shell_title "parse bconds"
1203 case "${BCOND_VERSION}" in
1208 echo "Warning: This spec has old style bconds. Fix it || die."
1209 for opt in `echo "$bcond_avail" | grep ^_without_`
1211 AVAIL_BCOND_WITHOUT=${opt#_without_}
1212 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1213 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1215 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1219 for opt in `echo "$bcond_avail" | grep ^_with_`
1221 AVAIL_BCOND_WITH=${opt#_with_}
1222 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1223 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1225 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1230 local cond_type="" # with || without
1231 for opt in $bcond_avail; do
1240 AVAIL_BCOND_WITHOUT=${opt#_without_}
1241 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1242 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1244 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1248 AVAIL_BCOND_WITH=${opt#_with_}
1249 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1250 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1252 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1256 case "$cond_type" in
1259 AVAIL_BCOND_WITH="$opt"
1260 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1261 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1263 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1268 AVAIL_BCOND_WITHOUT="$opt"
1269 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1270 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1272 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1286 update_shell_title "run_sub_builder $package_name"
1288 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1289 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1290 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1291 # jakby nie bylo tego kawalka kodu.
1293 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1294 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1301 # Istnieje taki spec? ${package}.spec
1302 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1303 parent_spec_name=${package}.spec
1304 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1305 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1307 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1313 if [ "${parent_spec_name}" != "" ]; then
1314 spawn_sub_builder $parent_spec_name
1316 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1322 update_shell_title "spawn_sub_builder $package_name"
1325 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1326 sub_builder_opts="${sub_builder_opts} -R"
1328 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1329 sub_builder_opts="${sub_builder_opts} -RB"
1330 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1331 sub_builder_opts="${sub_builder_opts} -FRB"
1333 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1334 sub_builder_opts="${sub_builder_opts} -Upi"
1338 ./builder ${sub_builder_opts} "$@"
1341 remove_build_requires()
1343 if [ "$INSTALLED_PACKAGES" != "" ]; then
1344 case "$REMOVE_BUILD_REQUIRES" in
1346 run_poldek --noask -ve $INSTALLED_PACKAGES
1349 run_poldek --ask -ve $INSTALLED_PACKAGES
1352 echo You may want to manually remove following BuildRequires fetched:
1353 echo $INSTALLED_PACKAGES
1354 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1362 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1363 if [ "$BCOND" != "" ]; then
1364 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1367 echo -ne "\nNo conditional flags passed"
1369 echo -ne "\n\nfrom available:\n"
1370 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1376 if [ "$NOCVSSPEC" != "yes" ]; then
1377 echo -ne "Available branches: "
1378 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1382 # checks a given list of packages/files/provides agains current rpmdb.
1383 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1384 # input can be either STDIN or parameters
1389 if [ "$#" -gt 0 ]; then
1395 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1398 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1400 # other deps (files)
1401 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1404 # checks if given package/files/provides exists in rpmdb.
1405 # inout can be either stdin or parameters
1406 # returns packages wchi hare present in the rpmdb
1411 if [ "$#" -gt 0 ]; then
1417 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1420 fetch_build_requires()
1422 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1423 update_shell_title "fetch build requires"
1424 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1425 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1426 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1428 update_shell_title "poldek: update indexes"
1429 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1430 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1432 if [ -n "$CONF" ]; then
1433 update_shell_title "uninstall conflicting packages: $CONF"
1434 echo "Trying to uninstall conflicting packages ($CONF):"
1435 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1438 while [ "$DEPS" ]; do
1439 update_shell_title "install deps: $DEPS"
1440 echo "Trying to install dependencies ($DEPS):"
1441 local log=.${SPECFILE}_poldek.log
1442 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1443 failed=$(awk -F: '/^error:/{print $2}' $log)
1446 if [ -n "$failed" ]; then
1447 for package in $failed; do
1448 # FIXME: sanitise, deps could be not .spec files
1449 spawn_sub_builder -bb $package && ok="$ok $package"
1459 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1460 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1461 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1462 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1463 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1464 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`
1466 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`"
1468 package=`basename "$package_item"|sed -e "s/}$//g"`
1469 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1472 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1473 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1474 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
1479 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1482 if `echo $COND_TST|grep -q 'without_'`; then
1483 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1484 if `echo $COND_TST|grep -q !`; then
1489 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1490 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1491 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1497 elif `echo $COND_TST|grep -q 'with_'`; then
1498 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1499 if `echo $COND_TST|grep -q !`; then
1504 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1505 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1506 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1512 RESULT="${COND_STATE}-${COND_ARGV}"
1514 "with-wout" | "wout-with" )
1517 "wout-wout" | "with-with" )
1521 echo "Action '$RESULT' was not defined for package '$package_item'"
1527 if [ "$GO" = "yes" ]; then
1528 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1529 echo "Testing if $package has subrequirements..."
1530 run_poldek -t -i $package --dumpn=".$package-req.txt"
1531 if [ -f ".$package-req.txt" ]; then
1532 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1534 if [ "$package_name" = "$package" ]; then
1535 echo -ne "Installing BuildRequired package:\t$package_name\n"
1536 update_shell_title "Installing BuildRequired package: ${package_name}"
1537 install_required_packages $package;
1539 echo -ne "Installing (sub)Required package:\t$package_name\n"
1540 update_shell_title "Installing (sub)Required package: ${package_name}"
1541 install_required_packages $package_name;
1545 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1546 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1549 echo "Attempting to run spawn sub - builder..."
1550 echo -ne "Package installation failed:\t$package_name\n"
1551 run_sub_builder $package_name
1552 if [ $? -eq 0 ]; then
1553 install_required_packages $package_name;
1556 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1557 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1560 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1567 rm -f ".$package-req.txt"
1569 echo "Attempting to run spawn sub - builder..."
1570 echo -ne "Package installation failed:\t$package\n"
1571 run_sub_builder $package
1572 if [ $? -eq 0 ]; then
1573 install_required_packages $package;
1576 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1577 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1580 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1586 echo "Package $package is already installed. BuildRequirement satisfied."
1590 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1591 echo "Unable to install following packages and their dependencies:"
1592 for pkg in "$NOT_INSTALLED_PACKAGES"
1596 remove_build_requires
1604 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1605 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1607 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1609 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,repackage.sh}
1613 echo "To checkout *all* .spec files:"
1614 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1615 echo "- run cvs up in $SPECS_DIR dir"
1618 echo "To commit with your developer account:"
1619 echo "- edit $SPECS_DIR/CVS/Root"
1620 echo "- edit $SOURCE_DIR/CVS/Root"
1623 #---------------------------------------------
1626 if [ "$#" = 0 ]; then
1652 DEBUG="yes"; shift ;;
1654 COMMAND="version"; shift ;;
1656 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1657 -b | -ba | --build )
1658 COMMAND="build"; shift ;;
1659 -bb | --build-binary )
1660 COMMAND="build-binary"; shift ;;
1661 -bs | --build-source )
1662 COMMAND="build-source"; shift ;;
1663 -bp | --build-prep )
1664 COMMAND="build-prep"; shift ;;
1666 COMMAND="branch"; shift; TAG="${1}"; shift;;
1668 CLEAN="--clean --rmspec --rmsource"; shift ;;
1670 shift; CVSROOT="${1}"; shift ;;
1672 COMMAND="get"; shift ;;
1674 COMMAND="usage"; shift ;;
1676 PROTOCOL="http"; shift ;;
1678 shift; LOGFILE="${1}"; shift ;;
1680 shift; DEF_NICE_LEVEL=${1}; shift ;;
1681 -ske | --skip-existing-files)
1682 SKIP_EXISTING_FILES="yes"; shift ;;
1684 COMMAND="mr-proper"; shift ;;
1686 NOCVS="yes"; shift ;;
1687 -ncs | --no-cvs-specs )
1688 NOCVSSPEC="yes"; shift ;;
1689 -nd | --no-distfiles )
1690 NODIST="yes"; shift ;;
1691 -nm | --no-mirrors )
1692 NOMIRRORS="yes"; shift ;;
1694 NOURLS="yes"; shift ;;
1696 NOSRCS="yes"; shift ;;
1697 -ns0 | --no-source0 )
1698 NOSOURCE0="yes"; shift ;;
1712 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1714 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1715 --with | --without )
1716 case $GROUP_BCONDS in
1720 while ! `echo ${1}|grep -qE '(^-|spec)'`
1722 BCOND="$BCOND $COND $1"
1726 if [[ "$2" = *,* ]]; then
1727 for a in $(echo "$2" | tr , ' '); do
1728 BCOND="$BCOND $1 $a"
1731 BCOND="$BCOND $1 $2"
1737 shift; TARGET="${1}"; shift ;;
1739 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1741 QUIET="--quiet"; shift ;;
1743 CVSDATE="${2}"; shift 2 ;;
1745 shift; CVSTAG="${1}"; shift ;;
1746 -R | --fetch-build-requires)
1747 FETCH_BUILD_REQUIRES="yes"
1748 NOT_INSTALLED_PACKAGES=
1750 -RB | --remove-build-requires)
1751 REMOVE_BUILD_REQUIRES="nice"
1753 -FRB | --force-remove-build-requires)
1754 REMOVE_BUILD_REQUIRES="force"
1756 -sd | --sources-distfiles)
1757 COMMAND="list-sources-distfiles"
1759 -sdp | --sources-distfiles-paths)
1760 COMMAND="list-sources-distfiles-paths"
1762 -sf | --sources-files)
1763 COMMAND="list-sources-files"
1765 -sp | --sources-paths)
1766 COMMAND="list-sources-local-paths"
1768 -su | --sources-urls)
1769 COMMAND="list-sources-urls"
1771 -Tvs | --tag-version-stable )
1776 -Tvn | --tag-version-nest )
1781 -Ts | --tag-stable )
1791 -Tv | --tag-version )
1796 -Tp | --tag-prefix )
1808 -ir | --integer-release-only )
1809 INTEGER_RELEASE="yes"
1818 -Upi | --update-poldek-indexes )
1819 UPDATE_POLDEK_INDEXES="yes"
1822 COMMAND="init_rpm_dir";
1824 -u | --try-upgrade )
1825 TRY_UPGRADE="1"; shift ;;
1826 -un | --try-upgrade-with-float-version )
1827 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1829 BE_VERBOSE="1"; shift ;;
1835 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1837 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1843 RPMOPTS="${RPMOPTS} --nodeps"
1846 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift ;;
1849 # check if specname was passed as specname:cvstag
1850 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
1851 CVSTAG="${SPECFILE##*:}";
1852 SPECFILE="${SPECFILE%%:*}";
1858 if [ -n "$DEBUG" ]; then
1863 if [ -n "$TARGET" ]; then
1866 TARGET_SWITCH="--target $TARGET" ;;
1868 TARGET_SWITCH="--target=$TARGET" ;;
1872 if [ "$SCHEDTOOL" != "no" ]; then
1873 NICE_COMMAND="$SCHEDTOOL"
1875 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
1878 update_shell_title "$COMMAND"
1880 "build" | "build-binary" | "build-source" | "build-prep" )
1882 if [ -n "$SPECFILE" ]; then
1888 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1889 fetch_build_requires;
1890 if [ "$INTEGER_RELEASE" = "yes" ]; then
1891 echo "Checking release $PACKAGE_RELEASE..."
1892 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1893 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1897 if [ -n "$TEST_TAG" ]; then
1898 TAGVER=`make_tagver`
1899 echo "Searching for tag $TAGVER..."
1900 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1901 if [ -n "$TAGREL" ]; then
1902 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1905 # - do not allow to build from HEAD when XX-branch exists
1906 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1907 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1908 TAG_BRANCH="${TREE_PREFIX}-branch"
1909 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1910 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1911 Exit_error err_branch_exists "$TAG_STATUS"
1917 if [ -n "$NOSOURCE0" ] ; then
1918 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1920 get_files $SOURCES $PATCHES;
1922 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1923 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1925 remove_build_requires;
1927 Exit_error err_no_spec_in_cmdl;
1932 if [ -n "$SPECFILE" ]; then
1935 get_files $SOURCES $PATCHES;
1936 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1938 Exit_error err_no_spec_in_cmdl;
1943 if [ -n "$SPECFILE" ]; then
1947 if [ -n "$NOSOURCE0" ] ; then
1948 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1950 get_files $SOURCES $PATCHES
1952 Exit_error err_no_spec_in_cmdl;
1959 if [ -n "$SPECFILE" ]; then
1963 # don't fetch sources from remote locations
1965 for file in $SOURCES
1967 [ -n "`src_md5 $file`" ] && continue
1968 new_SOURCES="$new_SOURCES $file"
1970 SOURCES="$new_SOURCES"
1971 get_files $SOURCES $PATCHES;
1972 tag_files "$SOURCES $PATCHES $ICONS";
1974 Exit_error err_no_spec_in_cmdl;
1978 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1980 "list-sources-files" )
1983 DONT_PRINT_REVISION="yes"
1986 SAPS="$SOURCES $PATCHES"
1987 for SAP in $SAPS ; do
1988 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1991 "list-sources-urls" )
1994 DONT_PRINT_REVISION="yes"
1997 SAPS="$SOURCES $PATCHES"
1998 for SAP in $SAPS ; do
2002 "list-sources-local-paths" )
2005 DONT_PRINT_REVISION="yes"
2008 SAPS="$SOURCES $PATCHES"
2009 for SAP in $SAPS ; do
2010 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2013 "list-sources-distfiles-paths" )
2016 DONT_PRINT_REVISION="yes"
2019 SAPS="$SOURCES $PATCHES"
2020 for SAP in $SAPS ; do
2021 if [ -n "$(src_md5 "$SAP")" ]; then
2022 distfiles_path "$SAP"
2026 "list-sources-distfiles" )
2029 DONT_PRINT_REVISION="yes"
2032 SAPS="$SOURCES $PATCHES"
2033 for SAP in $SAPS ; do
2034 if [ -n "$(src_md5 "$SAP")" ]; then
2035 distfiles_url "$SAP"
2047 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2048 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2052 # vi:syntax=sh:ts=4:sw=4