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
246 --skip-existing-files - skip existing files in get_files
247 --opts <rpm opts> - additional options for rpm
248 -q, --quiet - be quiet,
249 --date yyyy-mm-dd - build package using resources from specified CVS date,
250 -r <cvstag>, --cvstag <cvstag>
251 - build package using resources from specified CVS tag,
252 -R, --fetch-build-requires
253 - fetch what is BuildRequired,
254 -RB, --remove-build-requires
255 - remove all you fetched with -R or --fetch-build-requires
256 remember, this option requires confirmation,
257 -FRB, --force-remove-build-requires
258 - remove all you fetched with -R or --fetch-build-requires
259 remember, this option works without confirmation,
260 -sd, --source-distfiles - list sources available from distfiles (intended for offline
261 operations; does not work when Icon field is present
262 but icon file is absent),
263 -sdp, --source-distfiles-paths - list sources available from distfiles -
264 paths relative to distfiles directory (intended for offline
265 operations; does not work when Icon field is present
266 but icon file is absent),
267 -sf, --source-files - list sources - bare filenames (intended for offline
268 operations; does not work when Icon field is present
269 but icon file is absent),
270 -sp, --source-paths - list sources - filenames with full local paths (intended for
271 offline operations; does not work when Icon field is present
272 but icon file is absent),
273 -su, --source-urls - list urls - urls to sources and patches
274 intended for copying urls with spec with lots of macros in urls
275 -T <cvstag> , --tag <cvstag>
276 - add cvs tag <cvstag> for files,
277 -Tvs, --tag-version-stable
278 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
279 -Tvn, --tag-version-nest
280 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
282 - add cvs tag STABLE for files,
284 - add cvs tag NEST for files,
286 - add cvs tag NAME-VERSION-RELEASE for files,
287 -Tp, --tag-prefix <prefix>
288 - add <prefix> to NAME-VERSION-RELEASE tags,
289 -tt, --test-tag <prefix>
290 - fail if tag is already present,
291 -ir, --integer-release-only
292 - allow only integer and snapshot releases
293 -v, --verbose - be verbose,
294 -u, --try-upgrade - check version, and try to upgrade package
295 -un, --try-upgrade-with-float-version
296 - as above, but allow float version
297 -U, --update - refetch sources, don't use distfiles, and update md5 comments
298 -Upi, --update-poldek-indexes
299 - refresh or make poldek package index files.
300 -np, --nopatch <patchnumber>
301 - don't apply <patchnumber>
302 --show-bconds - show available conditional builds, which can be used
303 - with --with and/or --without switches.
304 --with/--without <feature>
305 - conditional build package depending on %_with_<feature>/
306 %_without_<feature> macro switch. You may now use
307 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
308 constructions. Set GROUP_BCONDS to yes to make use of it.
309 --target <platform>, --target=<platform>
310 - build for platform <platform>.
311 --init-rpm-dir - initialize ~/rpm directory structure
315 update_shell_title() {
317 local len=${COLUMNS:-80}
318 local msg=$(echo "$*" | cut -c-$len)
320 if [ -n "$BE_VERBOSE" ]; then
321 echo >&2 "$(date +%s.%N) $*"
324 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
326 if [ -n "$PACKAGE_NAME" ]; then
327 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
332 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
335 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
338 echo >&2 -ne "\033]0;$msg\007"
344 # set TARGET from BuildArch: from SPECFILE
346 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
347 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
352 TARGET_SWITCH="--target $TARGET" ;;
354 TARGET_SWITCH="--target=$TARGET" ;;
361 if [ -n "$DEBUG" ]; then
366 update_shell_title "cache_rpm_dump"
370 # we reset macros not to contain macros.build as all the %() macros are
371 # executed here, while none of them are actually needed.
372 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
373 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
374 macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.builder-rpmmacros:~/etc/.rpmmacros:~/.rpmmacros"
375 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
376 # FIXME: better ideas than .rpmrc?
377 printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .builder-rpmrc
378 # TODO: move these to /usr/lib/rpm/macros
379 cat > .builder-rpmmacros <<'EOF'
380 %requires_releq_kernel_up %{nil}
381 %requires_releq_kernel_smp %{nil}
382 %requires_releq() %{nil}
383 %pyrequires_eq() %{nil}
384 %requires_eq() %{nil}
385 %requires_eq_to() %{nil}
386 %releq_kernel_up ERROR
387 %releq_kernel_smp ERROR
391 %ruby_ver_requires_eq() %{nil}
392 %ruby_mod_ver_requires_eq() %{nil}
393 %__php_api_requires() %{nil}
394 %php_major_version ERROR
395 %php_api_version ERROR
403 ARGS='--nodigest --nosignature --nobuild'
406 $RPMBUILD --rcfile .builder-rpmrc $ARGS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
408 if [ $? -gt 0 ]; then
409 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
411 Exit_error err_build_fail;
414 # make small dump cache
415 rpm_dump_cache=`echo "$rpm_dump" | awk '
416 $2 ~ /^SOURCEURL/ {print}
417 $2 ~ /^PATCHURL/ {print}
418 $2 ~ /^nosource/ {print}
419 $2 ~ /^PACKAGE_/ {print}
422 update_shell_title "cache_rpm_dump: OK!"
426 if [ -z "$rpm_dump_cache" ] ; then
427 echo "internal error: cache_rpm_dump not called!" 1>&2
429 echo "$rpm_dump_cache"
434 update_shell_title "get icons"
435 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
436 if [ -z "$ICONS" ]; then
440 rpm_dump_cache="böö" NODIST="yes" UPDATE5= get_files $ICONS
445 update_shell_title "parsing specfile"
446 if [ -n "$DEBUG" ]; then
451 # icons are needed for successful spec parse
457 if [ "$NOSRCS" != "yes" ]; then
458 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
461 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
462 FAIL_IF_NO_SOURCES="no"
465 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
466 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
467 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
468 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
469 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
471 if [ -n "$BE_VERBOSE" ]; then
472 echo "- Sources : `nourl $SOURCES`"
473 if [ -n "$PATCHES" ]; then
474 echo "- Patches : `nourl $PATCHES`"
476 echo "- Patches : *no patches needed*"
478 if [ -n "$ICONS" ]; then
479 echo "- Icon : `nourl $ICONS`"
481 echo "- Icon : *no package icon*"
483 echo "- Name : $PACKAGE_NAME"
484 echo "- Version : $PACKAGE_VERSION"
485 echo "- Release : $PACKAGE_RELEASE"
488 update_shell_title "parse_spec: OK!"
493 if [ -n "$DEBUG" ]; then
501 "err_no_spec_in_cmdl" )
502 remove_build_requires
503 echo "ERROR: spec file name not specified.";
505 "err_no_spec_in_repo" )
506 remove_build_requires
507 echo "Error: spec file not stored in CVS repo.";
509 "err_no_source_in_repo" )
510 remove_build_requires
511 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
514 remove_build_requires
515 echo "Error: package build failed. (${2:-no more info})";
517 "err_no_package_data" )
518 remove_build_requires
519 echo "Error: couldn't get out package name/version/release from spec file."
522 remove_build_requires
523 echo "Tag ${2} already exists (spec release: ${3}).";
526 remove_build_requires
527 echo "Release ${2} not integer and not a snapshot.";
529 "err_branch_exists" )
530 remove_build_requires
531 echo "Tree branch already exists (${2}).";
535 echo "Unknown error."
541 if [ -n "$DEBUG" ]; then
546 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
547 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
555 update_shell_title "get_spec"
557 if [ -n "$DEBUG" ]; then
563 if [ ! -f "$SPECFILE" ]; then
564 SPECFILE="`basename $SPECFILE .spec`.spec";
566 if [ "$NOCVSSPEC" != "yes" ]; then
568 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
569 echo "Warning: No CVS access defined - using local .spec file"
573 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
576 if [ ! -f "$SPECFILE" ]; then
577 Exit_error err_no_spec_in_repo;
580 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
581 chmod $CHMOD_MODE $SPECFILE
584 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
593 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
594 cvs update mirrors >&2
598 while read origin mirror name rest
600 ol=`echo -n "$origin"|wc -c`
601 prefix="`echo -n "$url" | head -c $ol`"
602 if [ "$prefix" = "$origin" ] ; then
603 suffix="`echo "$url"|cut -b $ol-`"
604 echo -n "$mirror$suffix"
615 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
616 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
622 [ X"$NO5" = X"yes" ] && return
624 [ -z "$no" ] && return
626 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
627 if [ -z "$spec_rev" ]; then
628 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
630 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
631 md5=$(grep -s -v '^#' additional-md5sums | \
632 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
633 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
634 grep -E '^[0-9a-f]{32}$')
635 if [ X"$md5" = X"" ] ; then
636 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
637 if [ ! -z "$source_md5" ] ; then
640 # we have empty SourceX-md5, but it is still possible
641 # that we have NoSourceX-md5 AND NoSource: X
642 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
643 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
648 if [ $(echo "$md5" | wc -l) != 1 ] ; then
649 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
651 echo "$md5" | tail -n 1
657 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
662 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
665 distfiles_attic_url ()
667 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
674 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
679 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
680 [ -n "$size" -a "$size" -gt 0 ]
685 if [ "$CVSIGNORE_DF" != "yes" ]; then
688 cvsignore=${SOURCE_DIR}/.cvsignore
689 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
690 echo "$1" >> $cvsignore
696 update_shell_title "cvsup"
698 if [ -n "$CVSROOT" ]; then
699 OPTIONS="-d $CVSROOT $OPTIONS"
702 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
703 OPTIONS="$OPTIONS -A"
705 if [ -n "$CVSDATE" ]; then
706 OPTIONS="$OPTIONS -D $CVSDATE"
708 if [ -n "$CVSTAG" ]; then
709 OPTIONS="$OPTIONS -r $CVSTAG"
714 local retries_counter=0
716 update_shell_title "cvsup: $*"
718 update_shell_title "cvsup: $# files"
720 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
721 retries_counter=$(( $retries_counter + 1 ))
722 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
724 [ -n "$output" ] && echo "$output"
725 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
726 echo "Trying again [$*]... ($retries_counter)"
727 update_shell_title "cvsup: retry #$retries_counter"
734 update_shell_title "cvsup: done!"
740 update_shell_title "get_files"
742 if [ -n "$DEBUG" ]; then
747 if [ $# -gt 0 ]; then
750 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
751 echo "Warning: No CVS access defined for SOURCES"
756 local get_files_cvs=""
760 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
761 update_shell_title "$i"
762 local fp=`nourl "$i"`
763 if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then
766 if [ -n "$UPDATE5" ]; then
767 if [ -n "$ADD5" ]; then
768 [ "$fp" = "$i" ] && continue
769 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
771 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
775 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
776 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
777 echo "Warning: no URL given for $i"
780 if [ -z "$NODIST" ] && [ -n "$(src_md5 "$i")" ]; then
781 if good_md5 "$i" && good_size "$i"; then
782 echo "$(nourl "$i") having proper md5sum already exists"
786 url=$(distfiles_url "$i")
787 url_attic=$(distfiles_attic_url "$i")
789 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
790 update_shell_title "${GETLOCAL%% *}: $url"
791 ${GETLOCAL} $url $target
793 if [ -z "$NOMIRRORS" ]; then
794 url="`find_mirror "$url"`"
796 update_shell_title "${GETURI%% *}: $url"
797 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
798 if [ "`echo $url | grep -E 'ftp://'`" ]; then
799 update_shell_title "${GETURI2%% *}: $url"
800 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
803 if ! test -s "$target"; then
805 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
806 update_shell_title "${GETLOCAL%% *}: $url_attic"
807 ${GETLOCAL} $url_attic $target
809 if [ -z "$NOMIRRORS" ]; then
810 url_attic="`find_mirror "$url_attic"`"
812 update_shell_title "${GETURI%% *}: $url_attic"
813 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
814 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
815 update_shell_title "${GETURI2%% *}: $url_attic"
816 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
820 if test -s "$target"; then
826 elif [ "$NOCVS" != "yes" -a -z "$(src_md5 "$i")" ]; then
827 if [ $# -gt 1 ]; then
828 get_files_cvs="$get_files_cvs $fp"
829 update_shell_title "$fp (will cvs up later)"
836 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
837 if [ -z "$NOMIRRORS" ]; then
838 im="`find_mirror "$i"`"
842 update_shell_title "${GETURI%% *}: $im"
844 if [ "`echo $im | grep -E 'ftp://'`" ]; then
845 update_shell_title "${GETURI2%% *}: $im"
850 if [ "$cvsup" = 1 ]; then
856 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
857 Exit_error err_no_source_in_repo $i;
858 elif [ -n "$UPDATE5" ] && \
859 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
860 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
861 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
863 echo "Updating source-$srcno md5."
864 md5=$(md5sum "$fp" | cut -f1 -d' ')
866 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
867 print "# Source'$srcno'-md5:\t'$md5'\n"
868 if /^Source'$srcno'\s*:\s+/;
873 if good_md5 "$i" && good_size "$i"; then
875 elif [ "$FROM_DISTFILES" = 1 ]; then
876 # wrong md5 from distfiles: remove the file and try again
878 echo "MD5 sum mismatch. Trying full fetch."
881 update_shell_title "${GETURI%% *}: $url"
882 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
883 if [ "`echo $url | grep -E 'ftp://'`" ]; then
884 update_shell_title "${GETURI2%% *}: $url"
885 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
887 if ! test -s "$target"; then
889 update_shell_title "${GETURI%% *}: $url_attic"
890 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
891 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
892 update_shell_title "${GETURI2%% *}: $url_attic"
893 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
896 test -s "$target" || rm -f "$target"
899 if good_md5 "$i" && good_size "$i" ; then
902 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
903 echo "or -5 to update md5 sums, if you're sure files are correct."
904 Exit_error err_no_source_in_repo $i
907 SHELL_TITLE_PREFIX=""
909 if [ "$get_files_cvs" ]; then
913 if [ "$CHMOD" = "yes" ]; then
914 CHMOD_FILES="`nourl "$@"`"
915 if [ -n "$CHMOD_FILES" ]; then
916 chmod $CHMOD_MODE $CHMOD_FILES
924 if [ -n "$DEBUG" ]; then
929 # Check whether first character of PACKAGE_NAME is legal for tag name
930 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
933 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"`
934 # Remove #kernel.version_release from TAGVER because tagging sources
935 # could occur with different kernel-headers than kernel-headers used at build time.
936 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
944 if [ -n "$DEBUG" ]; then
949 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
950 echo "Version: $PACKAGE_VERSION"
951 echo "Release: $PACKAGE_RELEASE"
955 if [ "$TAG_VERSION" = "yes" ]; then
956 echo "CVS tag: $TAGVER"
958 if [ -n "$TAG" ]; then
963 if [ -n "$CVSROOT" ]; then
964 OPTIONS="-d $CVSROOT $OPTIONS"
970 # don't tag files stored on distfiles
971 [ -n "`src_md5 $i`" ] && continue
972 if [ -f "`nourl $i`" ]; then
973 if [ "$TAG_VERSION" = "yes" ]; then
974 cvs $OPTIONS $TAGVER `nourl $i`
976 if [ -n "$TAG" ]; then
977 cvs $OPTIONS $TAG `nourl $i`
980 Exit_error err_no_source_in_repo $i
985 if [ "$TAG_VERSION" = "yes" ]; then
986 cvs $OPTIONS $TAGVER $SPECFILE
988 if [ -n "$TAG" ]; then
989 cvs $OPTIONS $TAG $SPECFILE
999 echo "CVS branch tag: $TAG"
1004 if [ -n "$DEBUG" ]; then
1009 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
1012 if [ -n "$CVSROOT" ]; then
1013 OPTIONS="-d $CVSROOT $OPTIONS"
1018 if [ -f `nourl $i` ]; then
1019 cvs $OPTIONS $TAG `nourl $i`
1021 Exit_error err_no_source_in_repo $i
1025 cvs $OPTIONS $TAG $SPECFILE
1035 update_shell_title "build_package"
1036 if [ -n "$DEBUG" ]; then
1043 if [ -n "$TRY_UPGRADE" ]; then
1044 update_shell_title "build_package: try_upgrade"
1045 if [ -n "$FLOAT_VERSION" ]; then
1046 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1048 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1051 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1053 if [ -n "$TNEWVER" ]; then
1054 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1055 echo "New version found, updating spec file to version " $TNEWVER
1056 cp -f $SPECFILE $SPECFILE.bak
1058 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1059 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1061 NODIST="yes" UPDATE5="yes" get_files $SOURCES $PATCHES;
1062 unset TOLDVER TNEWVER TNOTIFY
1069 BUILD_SWITCH="-ba" ;;
1071 BUILD_SWITCH="-bb" ;;
1073 BUILD_SWITCH="-bs --nodeps" ;;
1075 BUILD_SWITCH="-bp --nodeps" ;;
1078 update_shell_title "build_package: $COMMAND"
1079 if [ -n "$LOGFILE" ]; then
1080 LOG=`eval echo $LOGFILE`
1081 if [ -d "$LOG" ]; then
1082 echo "Log file $LOG is a directory."
1083 echo "Parse error in the spec?"
1084 Exit_error err_build_fail;
1086 if [ -n "$LASTLOG_FILE" ]; then
1087 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1089 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1090 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1091 RETVAL=`cat $RES_FILE`
1093 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1094 if [ "$RETVAL" -eq "0" ]; then
1101 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1104 if [ "$RETVAL" -ne "0" ]; then
1105 if [ -n "$TRY_UPGRADE" ]; then
1106 echo "\n!!! Package with new version cannot be built automagically\n"
1107 mv -f $SPECFILE.bak $SPECFILE
1109 Exit_error err_build_fail;
1116 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1119 install_required_packages()
1126 # taken from find-spec-bcond, but with just getting the list
1128 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1130 /^%changelog/ { exit }
1131 /_with(out)?_[_a-zA-Z0-9]+/{
1132 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1133 print substr($0, RSTART, RLENGTH);
1136 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1137 bcond = substr($0, RSTART +5 , RLENGTH -5);
1138 gsub(/[ \t]+/,"_",bcond);
1140 }' $SPEC | LC_ALL=C sort -u
1145 update_shell_title "set bcond values"
1147 AVAIL_BCONDS_WITHOUT=""
1148 AVAIL_BCONDS_WITH=""
1149 if `grep -q ^%bcond ${SPECFILE}`; then
1151 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1157 local bcond_avail=$(find_spec_bcond $SPECFILE)
1159 # expand bconds from ~/.bcondrc
1160 # The file structure is like gentoo's package.use:
1163 # samba -mysql -pgsql
1164 # w32codec-installer license_agreement
1167 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1168 SN=${SPECFILE%%\.spec}
1170 local bcondrc=$HOME/.bcondrc
1171 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1173 while read pkg flags; do
1175 [[ "$pkg" == \#* ]] && continue
1177 # any package or current package?
1178 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1179 for flag in $flags; do
1180 local opt=${flag#[+-]}
1182 # use only flags which are in this package.
1183 if [[ $bcond_avail = *${opt}* ]]; then
1184 if [[ $flag = -* ]]; then
1185 BCOND="$BCOND --without $opt"
1187 BCOND="$BCOND --with $opt"
1193 update_shell_title "parse ~/.bcondrc: DONE!"
1196 update_shell_title "parse bconds"
1197 case "${BCOND_VERSION}" in
1202 echo "Warning: This spec has old style bconds. Fix it || die."
1203 for opt in `echo "$bcond_avail" | grep ^_without_`
1205 AVAIL_BCOND_WITHOUT=${opt#_without_}
1206 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1207 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1209 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1213 for opt in `echo "$bcond_avail" | grep ^_with_`
1215 AVAIL_BCOND_WITH=${opt#_with_}
1216 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1217 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1219 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1224 local cond_type="" # with || without
1225 for opt in $bcond_avail; do
1234 AVAIL_BCOND_WITHOUT=${opt#_without_}
1235 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1236 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1238 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1242 AVAIL_BCOND_WITH=${opt#_with_}
1243 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1244 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1246 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1250 case "$cond_type" in
1253 AVAIL_BCOND_WITH="$opt"
1254 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1255 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1257 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1262 AVAIL_BCOND_WITHOUT="$opt"
1263 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1264 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1266 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1280 update_shell_title "run_sub_builder $package_name"
1282 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1283 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1284 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1285 # jakby nie bylo tego kawalka kodu.
1287 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1288 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1295 # Istnieje taki spec? ${package}.spec
1296 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1297 parent_spec_name=${package}.spec
1298 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1299 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1301 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1307 if [ "${parent_spec_name}" != "" ]; then
1308 spawn_sub_builder $parent_spec_name
1310 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1316 update_shell_title "spawn_sub_builder $package_name"
1319 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1320 sub_builder_opts="${sub_builder_opts} -R"
1322 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1323 sub_builder_opts="${sub_builder_opts} -RB"
1324 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1325 sub_builder_opts="${sub_builder_opts} -FRB"
1327 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1328 sub_builder_opts="${sub_builder_opts} -Upi"
1332 ./builder ${sub_builder_opts} "$@"
1335 remove_build_requires()
1337 if [ "$INSTALLED_PACKAGES" != "" ]; then
1338 case "$REMOVE_BUILD_REQUIRES" in
1340 run_poldek --noask -ve $INSTALLED_PACKAGES
1343 run_poldek --ask -ve $INSTALLED_PACKAGES
1346 echo You may want to manually remove following BuildRequires fetched:
1347 echo $INSTALLED_PACKAGES
1348 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1356 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1357 if [ "$BCOND" != "" ]; then
1358 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1361 echo -ne "\nNo conditional flags passed"
1363 echo -ne "\n\nfrom available:\n"
1364 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1370 if [ "$NOCVSSPEC" != "yes" ]; then
1371 echo -ne "Available branches: "
1372 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1376 # checks a given list of packages/files/provides agains current rpmdb.
1377 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1378 # input can be either STDIN or parameters
1383 if [ "$#" -gt 0 ]; then
1389 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1392 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1394 # other deps (files)
1395 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1398 # checks if given package/files/provides exists in rpmdb.
1399 # inout can be either stdin or parameters
1400 # returns packages wchi hare present in the rpmdb
1405 if [ "$#" -gt 0 ]; then
1411 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1414 fetch_build_requires()
1416 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1417 update_shell_title "fetch build requires"
1418 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1419 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1420 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1422 update_shell_title "poldek: update indexes"
1423 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1424 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1426 if [ -n "$CONF" ]; then
1427 update_shell_title "uninstall conflicting packages: $CONF"
1428 echo "Trying to uninstall conflicting packages ($CONF):"
1429 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1432 while [ "$DEPS" ]; do
1433 update_shell_title "install deps: $DEPS"
1434 echo "Trying to install dependencies ($DEPS):"
1435 local log=.${SPECFILE}_poldek.log
1436 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1437 failed=$(awk -F: '/^error:/{print $2}' $log)
1440 if [ -n "$failed" ]; then
1441 for package in $failed; do
1442 # FIXME: sanitise, deps could be not .spec files
1443 spawn_sub_builder -bb $package && ok="$ok $package"
1453 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1454 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1455 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1456 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1457 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1458 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`
1460 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`"
1462 package=`basename "$package_item"|sed -e "s/}$//g"`
1463 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1466 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1467 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1468 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
1473 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1476 if `echo $COND_TST|grep -q 'without_'`; then
1477 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1478 if `echo $COND_TST|grep -q !`; then
1483 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1484 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1485 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1491 elif `echo $COND_TST|grep -q 'with_'`; then
1492 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1493 if `echo $COND_TST|grep -q !`; then
1498 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1499 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1500 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1506 RESULT="${COND_STATE}-${COND_ARGV}"
1508 "with-wout" | "wout-with" )
1511 "wout-wout" | "with-with" )
1515 echo "Action '$RESULT' was not defined for package '$package_item'"
1521 if [ "$GO" = "yes" ]; then
1522 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1523 echo "Testing if $package has subrequirements..."
1524 run_poldek -t -i $package --dumpn=".$package-req.txt"
1525 if [ -f ".$package-req.txt" ]; then
1526 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1528 if [ "$package_name" = "$package" ]; then
1529 echo -ne "Installing BuildRequired package:\t$package_name\n"
1530 update_shell_title "Installing BuildRequired package: ${package_name}"
1531 install_required_packages $package;
1533 echo -ne "Installing (sub)Required package:\t$package_name\n"
1534 update_shell_title "Installing (sub)Required package: ${package_name}"
1535 install_required_packages $package_name;
1539 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1540 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1543 echo "Attempting to run spawn sub - builder..."
1544 echo -ne "Package installation failed:\t$package_name\n"
1545 run_sub_builder $package_name
1546 if [ $? -eq 0 ]; then
1547 install_required_packages $package_name;
1550 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1551 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1554 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1561 rm -f ".$package-req.txt"
1563 echo "Attempting to run spawn sub - builder..."
1564 echo -ne "Package installation failed:\t$package\n"
1565 run_sub_builder $package
1566 if [ $? -eq 0 ]; then
1567 install_required_packages $package;
1570 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1571 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1574 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1580 echo "Package $package is already installed. BuildRequirement satisfied."
1584 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1585 echo "Unable to install following packages and their dependencies:"
1586 for pkg in "$NOT_INSTALLED_PACKAGES"
1590 remove_build_requires
1598 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1599 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1601 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1603 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,repackage.sh}
1607 echo "To checkout *all* .spec files:"
1608 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1609 echo "- run cvs up in $SPECS_DIR dir"
1612 echo "To commit with your developer account:"
1613 echo "- edit $SPECS_DIR/CVS/Root"
1614 echo "- edit $SOURCE_DIR/CVS/Root"
1617 #---------------------------------------------
1620 if [ "$#" = 0 ]; then
1646 DEBUG="yes"; shift ;;
1648 COMMAND="version"; shift ;;
1650 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1651 -b | -ba | --build )
1652 COMMAND="build"; shift ;;
1653 -bb | --build-binary )
1654 COMMAND="build-binary"; shift ;;
1655 -bs | --build-source )
1656 COMMAND="build-source"; shift ;;
1657 -bp | --build-prep )
1658 COMMAND="build-prep"; shift ;;
1660 COMMAND="branch"; shift; TAG="${1}"; shift;;
1662 CLEAN="--clean --rmspec --rmsource"; shift ;;
1664 shift; CVSROOT="${1}"; shift ;;
1666 COMMAND="get"; shift ;;
1668 COMMAND="usage"; shift ;;
1670 PROTOCOL="http"; shift ;;
1672 shift; LOGFILE="${1}"; shift ;;
1674 shift; DEF_NICE_LEVEL=${1}; shift ;;
1675 -ske | --skip-existing-files)
1676 SKIP_EXISTING_FILES="yes"; shift ;;
1678 COMMAND="mr-proper"; shift ;;
1680 NOCVS="yes"; shift ;;
1681 -ncs | --no-cvs-specs )
1682 NOCVSSPEC="yes"; shift ;;
1683 -nd | --no-distfiles )
1684 NODIST="yes"; shift ;;
1685 -nm | --no-mirrors )
1686 NOMIRRORS="yes"; shift ;;
1688 NOURLS="yes"; shift ;;
1690 NOSRCS="yes"; shift ;;
1691 -ns0 | --no-source0 )
1692 NOSOURCE0="yes"; shift ;;
1703 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1705 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1706 --with | --without )
1707 case $GROUP_BCONDS in
1711 while ! `echo ${1}|grep -qE '(^-|spec)'`
1713 BCOND="$BCOND $COND $1"
1717 if [[ "$2" = *,* ]]; then
1718 for a in $(echo "$2" | tr , ' '); do
1719 BCOND="$BCOND $1 $a"
1722 BCOND="$BCOND $1 $2"
1728 shift; TARGET="${1}"; shift ;;
1730 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1732 QUIET="--quiet"; shift ;;
1734 CVSDATE="${2}"; shift 2 ;;
1736 shift; CVSTAG="${1}"; shift ;;
1737 -R | --fetch-build-requires)
1738 FETCH_BUILD_REQUIRES="yes"
1739 NOT_INSTALLED_PACKAGES=
1741 -RB | --remove-build-requires)
1742 REMOVE_BUILD_REQUIRES="nice"
1744 -FRB | --force-remove-build-requires)
1745 REMOVE_BUILD_REQUIRES="force"
1747 -sd | --sources-distfiles)
1748 COMMAND="list-sources-distfiles"
1750 -sdp | --sources-distfiles-paths)
1751 COMMAND="list-sources-distfiles-paths"
1753 -sf | --sources-files)
1754 COMMAND="list-sources-files"
1756 -sp | --sources-paths)
1757 COMMAND="list-sources-local-paths"
1759 -su | --sources-urls)
1760 COMMAND="list-sources-urls"
1762 -Tvs | --tag-version-stable )
1767 -Tvn | --tag-version-nest )
1772 -Ts | --tag-stable )
1782 -Tv | --tag-version )
1787 -Tp | --tag-prefix )
1799 -ir | --integer-release-only )
1800 INTEGER_RELEASE="yes"
1809 -Upi | --update-poldek-indexes )
1810 UPDATE_POLDEK_INDEXES="yes"
1813 COMMAND="init_rpm_dir";
1815 -u | --try-upgrade )
1816 TRY_UPGRADE="1"; shift ;;
1817 -un | --try-upgrade-with-float-version )
1818 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1820 BE_VERBOSE="1"; shift ;;
1826 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1828 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1834 RPMOPTS="${RPMOPTS} --nodeps"
1837 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift ;;
1840 # check if specname was passed as specname:cvstag
1841 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
1842 CVSTAG="${SPECFILE##*:}";
1843 SPECFILE="${SPECFILE%%:*}";
1849 if [ -n "$DEBUG" ]; then
1854 if [ -n "$TARGET" ]; then
1857 TARGET_SWITCH="--target $TARGET" ;;
1859 TARGET_SWITCH="--target=$TARGET" ;;
1863 if [ "$SCHEDTOOL" != "no" ]; then
1864 NICE_COMMAND="$SCHEDTOOL"
1866 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
1869 update_shell_title "$COMMAND"
1871 "build" | "build-binary" | "build-source" | "build-prep" )
1873 if [ -n "$SPECFILE" ]; then
1879 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1880 fetch_build_requires;
1881 if [ "$INTEGER_RELEASE" = "yes" ]; then
1882 echo "Checking release $PACKAGE_RELEASE..."
1883 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1884 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1888 if [ -n "$TEST_TAG" ]; then
1889 TAGVER=`make_tagver`
1890 echo "Searching for tag $TAGVER..."
1891 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1892 if [ -n "$TAGREL" ]; then
1893 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1896 # - do not allow to build from HEAD when XX-branch exists
1897 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1898 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1899 TAG_BRANCH="${TREE_PREFIX}-branch"
1900 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1901 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1902 Exit_error err_branch_exists "$TAG_STATUS"
1908 if [ -n "$NOSOURCE0" ] ; then
1909 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1911 get_files $SOURCES $PATCHES;
1913 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1914 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1916 remove_build_requires;
1918 Exit_error err_no_spec_in_cmdl;
1923 if [ -n "$SPECFILE" ]; then
1926 get_files $SOURCES $PATCHES;
1927 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1929 Exit_error err_no_spec_in_cmdl;
1934 if [ -n "$SPECFILE" ]; then
1938 if [ -n "$NOSOURCE0" ] ; then
1939 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1941 get_files $SOURCES $PATCHES
1943 Exit_error err_no_spec_in_cmdl;
1950 if [ -n "$SPECFILE" ]; then
1954 # don't fetch sources from remote locations
1956 for file in $SOURCES
1958 [ -n "`src_md5 $file`" ] && continue
1959 new_SOURCES="$new_SOURCES $file"
1961 SOURCES="$new_SOURCES"
1962 get_files $SOURCES $PATCHES;
1963 tag_files "$SOURCES $PATCHES $ICONS";
1965 Exit_error err_no_spec_in_cmdl;
1969 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1971 "list-sources-files" )
1974 DONT_PRINT_REVISION="yes"
1977 SAPS="$SOURCES $PATCHES"
1978 for SAP in $SAPS ; do
1979 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1982 "list-sources-urls" )
1985 DONT_PRINT_REVISION="yes"
1988 SAPS="$SOURCES $PATCHES"
1989 for SAP in $SAPS ; do
1993 "list-sources-local-paths" )
1996 DONT_PRINT_REVISION="yes"
1999 SAPS="$SOURCES $PATCHES"
2000 for SAP in $SAPS ; do
2001 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2004 "list-sources-distfiles-paths" )
2007 DONT_PRINT_REVISION="yes"
2010 SAPS="$SOURCES $PATCHES"
2011 for SAP in $SAPS ; do
2012 if [ -n "$(src_md5 "$SAP")" ]; then
2013 distfiles_path "$SAP"
2017 "list-sources-distfiles" )
2020 DONT_PRINT_REVISION="yes"
2023 SAPS="$SOURCES $PATCHES"
2024 for SAP in $SAPS ; do
2025 if [ -n "$(src_md5 "$SAP")" ]; then
2026 distfiles_url "$SAP"
2038 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2039 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2043 # vi:syntax=sh:ts=4:sw=4