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"
88 FAIL_IF_NO_SOURCES="yes"
90 # let get_files skip over files which are present to get those damn files fetched
91 SKIP_EXISTING_FILES="no"
93 if [ -x /usr/bin/rpm-getdeps ]; then
94 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
96 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
99 # Here we load saved user environment used to
100 # predefine options set above, or passed to builder
102 # This one reads global system environment settings:
103 if [ -f ~/etc/builderrc ]; then
106 # And this one cascades settings using user personal
108 # Example of ~/.builderrc:
110 #UPDATE_POLDEK_INDEXES="yes"
111 #FETCH_BUILD_REQUIRES="yes"
112 #REMOVE_BUILD_REQUIRES="force"
114 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
118 if [ -n "$HOME_ETC" ]; then
119 USER_CFG="$HOME_ETC/.builderrc"
121 USER_CFG=~/.builderrc
124 [ -f "$USER_CFG" ] && . "$USER_CFG"
126 wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
128 if [ -n "$USE_PROZILLA" ]; then
129 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
132 elif [ -n "$USE_AXEL" ]; then
133 GETURI="axel -a $AXEL_OPTS"
137 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
138 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
140 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
141 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
147 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
155 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
156 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
160 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
161 if [ -n "$LOGFILE" ]; then
162 LOG=`eval echo $LOGFILE`
163 if [ -n "$LASTLOG_FILE" ]; then
164 echo "LASTLOG=$LOG" > $LASTLOG_FILE
166 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
169 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
170 return `cat ${RES_FILE}`
175 #---------------------------------------------
180 if [ -n "$DEBUG" ]; then set -xv; fi
182 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
184 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
185 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
186 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
187 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
188 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
189 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
190 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
191 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
192 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec][:cvstag]
194 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
195 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
196 -n5, --no-md5 - ignore md5 comments in spec
197 -D, --debug - enable builder script debugging mode,
198 -debug - produce rpm debug package (same as --opts -debug)
199 -V, --version - output builder version
200 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
201 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
203 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
204 only package from <package>.spec,
205 -bp, --build-prep - execute the %prep phase of <package>.spec,
206 -bc - reserved (not implemented)
207 -bi reserved (not implemented)
208 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
210 --short-circuit - reserved (not implemented)
211 -B, --branch - add branch
212 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
213 SPECS and \$RPM_BUILD_ROOT),
214 -d <cvsroot>, --cvsroot <cvsroot>
216 --define <macro> <value>
217 - define a macro <macro> with value <value>,
218 --nodeps - rpm won't check any dependences
219 -g, --get - get <package>.spec and all related files from CVS repo
221 -h, --help - this message,
222 --http - use http instead of ftp,
223 -l <logfile>, --logtofile <logfile>
225 -m, --mr-proper - only remove all files related to spec file and all work
227 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
229 - don't check specs in CVS
230 -nd, --no-distfiles - don't download from distfiles
231 -nm, --no-mirrors - don't download from mirror, if source URL is given,
232 -nu, --no-urls - don't try to download from FTP/HTTP location,
233 -ns, --no-srcs - don't download Sources
234 -ns0, --no-source0 - don't download Source0
235 -nn, --no-net - don't download anything from the net
237 --skip-existing-files - skip existing files in get_files
238 --opts <rpm opts> - additional options for rpm
239 -q, --quiet - be quiet,
240 --date yyyy-mm-dd - build package using resources from specified CVS date,
241 -r <cvstag>, --cvstag <cvstag>
242 - build package using resources from specified CVS tag,
243 -R, --fetch-build-requires
244 - fetch what is BuildRequired,
245 -RB, --remove-build-requires
246 - remove all you fetched with -R or --fetch-build-requires
247 remember, this option requires confirmation,
248 -FRB, --force-remove-build-requires
249 - remove all you fetched with -R or --fetch-build-requires
250 remember, this option works without confirmation,
251 -sf, --source-files - list sources - bare filenames (intended for offline
252 operations; does not work when Icon field is present
253 but icon file is absent),
254 -sp, --source-paths - list sources - filenames with full local paths (intended for
255 offline operations; does not work when Icon field is present
256 but icon file is absent),
257 -su, --source-urls - list urls - urls to sources and patches
258 intended for copying urls with spec with lots of macros in urls
259 -T <cvstag> , --tag <cvstag>
260 - add cvs tag <cvstag> for files,
261 -Tvs, --tag-version-stable
262 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
263 -Tvn, --tag-version-nest
264 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
266 - add cvs tag STABLE for files,
268 - add cvs tag NEST for files,
270 - add cvs tag NAME-VERSION-RELEASE for files,
271 -Tp, --tag-prefix <prefix>
272 - add <prefix> to NAME-VERSION-RELEASE tags,
273 -tt, --test-tag <prefix>
274 - fail if tag is already present,
275 -ir, --integer-release-only
276 - allow only integer and snapshot releases
277 -v, --verbose - be verbose,
278 -u, --try-upgrade - check version, and try to upgrade package
279 -un, --try-upgrade-with-float-version
280 - as above, but allow float version
281 -U, --update - refetch sources, don't use distfiles, and update md5 comments
282 -Upi, --update-poldek-indexes
283 - refresh or make poldek package index files.
284 -np, --nopatch <patchnumber>
285 - don't apply <patchnumber>
286 --show-bconds - show available conditional builds, which can be used
287 - with --with and/or --without switches.
288 --with/--without <feature>
289 - conditional build package depending on %_with_<feature>/
290 %_without_<feature> macro switch. You may now use
291 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
292 constructions. Set GROUP_BCONDS to yes to make use of it.
293 --target <platform>, --target=<platform>
294 - build for platform <platform>.
295 --init-rpm-dir - initialize ~/rpm directory structure
299 update_shell_title() {
301 local len=${COLUMNS:-80}
302 local msg=$(echo "$*" | cut -c-$len)
304 if [ -n "$BE_VERBOSE" ]; then
305 echo >&2 "$(date +%s.%N) $*"
308 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
309 msg="${SPECFILE}: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
312 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
315 echo >&2 -ne "\033]0;$msg\007"
321 # set TARGET from BuildArch: from SPECFILE
323 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
324 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
329 TARGET_SWITCH="--target $TARGET" ;;
331 TARGET_SWITCH="--target=$TARGET" ;;
338 if [ -n "$DEBUG" ]; then
343 update_shell_title "cache_rpm_dump"
347 # we reset macros not to contain macros.build as all the %() macros are
348 # executed here, while none of them are actually needed.
349 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
350 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
351 macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.builder-rpmmacros:~/etc/.rpmmacros:~/.rpmmacros"
352 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
353 # FIXME: better ideas than .rpmrc?
354 printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .builder-rpmrc
355 # TODO: move these to /usr/lib/rpm/macros
356 cat > .builder-rpmmacros <<'EOF'
357 %requires_releq_kernel_up %{nil}
358 %requires_releq_kernel_smp %{nil}
359 %requires_releq() %{nil}
360 %pyrequires_eq() %{nil}
361 %requires_eq() %{nil}
362 %requires_eq_to() %{nil}
363 %releq_kernel_up ERROR
364 %releq_kernel_smp ERROR
368 %ruby_ver_requires_eq() %{nil}
369 %ruby_mod_ver_requires_eq() %{nil}
370 %__php_api_requires() %{nil}
371 %php_major_version ERROR
372 %php_api_version ERROR
380 ARGS='--nodigest --nosignature --nobuild'
383 $RPMBUILD --rcfile .builder-rpmrc $ARGS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
385 if [ $? -gt 0 ]; then
386 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
388 Exit_error err_build_fail;
391 # make small dump cache
392 rpm_dump_cache=`echo "$rpm_dump" | awk '
393 $2 ~ /^SOURCEURL/ {print}
394 $2 ~ /^PATCHURL/ {print}
395 $2 ~ /^nosource/ {print}
396 $2 ~ /^PACKAGE_/ {print}
399 update_shell_title "cache_rpm_dump: OK!"
403 if [ -z "$rpm_dump_cache" ] ; then
404 echo "internal error: cache_rpm_dump not called!" 1>&2
406 echo "$rpm_dump_cache"
411 update_shell_title "get icons"
412 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
413 if [ -z "$ICONS" ]; then
417 rpm_dump_cache="böö" NODIST="yes" UPDATE5= get_files $ICONS
422 update_shell_title "parsing specfile"
423 if [ -n "$DEBUG" ]; then
428 # icons are needed for successful spec parse
434 if [ "$NOSRCS" != "yes" ]; then
435 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
438 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
439 FAIL_IF_NO_SOURCES="no"
442 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
443 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
444 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
445 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
446 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
448 if [ -n "$BE_VERBOSE" ]; then
449 echo "- Sources : `nourl $SOURCES`"
450 if [ -n "$PATCHES" ]; then
451 echo "- Patches : `nourl $PATCHES`"
453 echo "- Patches : *no patches needed*"
455 if [ -n "$ICONS" ]; then
456 echo "- Icon : `nourl $ICONS`"
458 echo "- Icon : *no package icon*"
460 echo "- Name : $PACKAGE_NAME"
461 echo "- Version : $PACKAGE_VERSION"
462 echo "- Release : $PACKAGE_RELEASE"
465 update_shell_title "parse_spec: OK!"
470 if [ -n "$DEBUG" ]; then
478 "err_no_spec_in_cmdl" )
479 remove_build_requires
480 echo "ERROR: spec file name not specified.";
482 "err_no_spec_in_repo" )
483 remove_build_requires
484 echo "Error: spec file not stored in CVS repo.";
486 "err_no_source_in_repo" )
487 remove_build_requires
488 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
491 remove_build_requires
492 echo "Error: package build failed. (${2:-no more info})";
494 "err_no_package_data" )
495 remove_build_requires
496 echo "Error: couldn't get out package name/version/release from spec file."
499 remove_build_requires
500 echo "Tag ${2} already exists (spec release: ${3}).";
503 remove_build_requires
504 echo "Release ${2} not integer and not a snapshot.";
506 "err_branch_exists" )
507 remove_build_requires
508 echo "Tree branch already exists (${2}).";
512 echo "Unknown error."
518 if [ -n "$DEBUG" ]; then
523 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
524 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
532 update_shell_title "get_spec"
534 if [ -n "$DEBUG" ]; then
540 if [ ! -f "$SPECFILE" ]; then
541 SPECFILE="`basename $SPECFILE .spec`.spec";
543 if [ "$NOCVSSPEC" != "yes" ]; then
545 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
546 echo "Warning: No CVS access defined - using local .spec file"
550 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
553 if [ ! -f "$SPECFILE" ]; then
554 Exit_error err_no_spec_in_repo;
557 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
558 chmod $CHMOD_MODE $SPECFILE
561 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
570 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
571 cvs update mirrors >&2
575 while read origin mirror name rest
577 ol=`echo -n "$origin"|wc -c`
578 prefix="`echo -n "$url" | head -c $ol`"
579 if [ "$prefix" = "$origin" ] ; then
580 suffix="`echo "$url"|cut -b $ol-`"
581 echo -n "$mirror$suffix"
592 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
593 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
599 [ X"$NO5" = X"yes" ] && return
601 [ -z "$no" ] && return
603 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
604 if [ -z "$spec_rev" ]; then
605 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
607 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
608 md5=$(grep -s -v '^#' additional-md5sums | \
609 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
610 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
611 grep -E '^[0-9a-f]{32}$')
612 if [ X"$md5" = X"" ] ; then
613 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
614 if [ ! -z "$source_md5" ] ; then
617 # we have empty SourceX-md5, but it is still possible
618 # that we have NoSourceX-md5 AND NoSource: X
619 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
620 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
625 if [ $(echo "$md5" | wc -l) != 1 ] ; then
626 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
628 echo "$md5" | tail -n 1
634 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
637 distfiles_attic_url ()
639 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
646 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
651 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
652 [ -n "$size" -a "$size" -gt 0 ]
657 if [ "$CVSIGNORE_DF" != "yes" ]; then
660 cvsignore=${SOURCE_DIR}/.cvsignore
661 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
662 echo "$1" >> $cvsignore
668 update_shell_title "cvsup"
670 if [ -n "$CVSROOT" ]; then
671 OPTIONS="-d $CVSROOT $OPTIONS"
674 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
675 OPTIONS="$OPTIONS -A"
677 if [ -n "$CVSDATE" ]; then
678 OPTIONS="$OPTIONS -D $CVSDATE"
680 if [ -n "$CVSTAG" ]; then
681 OPTIONS="$OPTIONS -r $CVSTAG"
686 local retries_counter=0
688 update_shell_title "cvsup: $*"
690 update_shell_title "cvsup: $# files"
692 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
693 retries_counter=$(( $retries_counter + 1 ))
694 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
696 [ -n "$output" ] && echo "$output"
697 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
698 echo "Trying again [$*]... ($retries_counter)"
699 update_shell_title "cvsup: retry #$retries_counter"
706 update_shell_title "cvsup: done!"
712 update_shell_title "get_files"
714 if [ -n "$DEBUG" ]; then
719 if [ $# -gt 0 ]; then
722 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
723 echo "Warning: No CVS access defined for SOURCES"
728 local get_files_cvs=""
732 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
733 update_shell_title "$i"
734 local fp=`nourl "$i"`
735 if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then
738 if [ -n "$UPDATE5" ]; then
739 if [ -n "$ADD5" ]; then
740 [ "$fp" = "$i" ] && continue
741 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
743 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
747 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
748 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
749 echo "Warning: no URL given for $i"
752 if [ -z "$NODIST" ] && [ -n "$(src_md5 "$i")" ]; then
753 if good_md5 "$i" && good_size "$i"; then
754 echo "$(nourl "$i") having proper md5sum already exists"
758 url=$(distfiles_url "$i")
759 url_attic=$(distfiles_attic_url "$i")
761 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
762 update_shell_title "${GETLOCAL%% *}: $url"
763 ${GETLOCAL} $url $target
765 if [ -z "$NOMIRRORS" ]; then
766 url="`find_mirror "$url"`"
768 update_shell_title "${GETURI%% *}: $url"
769 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
770 if [ "`echo $url | grep -E 'ftp://'`" ]; then
771 update_shell_title "${GETURI2%% *}: $url"
772 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
775 if ! test -s "$target"; then
777 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
778 update_shell_title "${GETLOCAL%% *}: $url_attic"
779 ${GETLOCAL} $url_attic $target
781 if [ -z "$NOMIRRORS" ]; then
782 url_attic="`find_mirror "$url_attic"`"
784 update_shell_title "${GETURI%% *}: $url_attic"
785 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
786 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
787 update_shell_title "${GETURI2%% *}: $url_attic"
788 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
792 if test -s "$target"; then
798 elif [ "$NOCVS" != "yes" -a -z "$(src_md5 "$i")" ]; then
799 if [ $# -gt 1 ]; then
800 get_files_cvs="$get_files_cvs $fp"
801 update_shell_title "$fp (will cvs up later)"
808 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
809 if [ -z "$NOMIRRORS" ]; then
810 im="`find_mirror "$i"`"
814 update_shell_title "${GETURI%% *}: $im"
816 if [ "`echo $im | grep -E 'ftp://'`" ]; then
817 update_shell_title "${GETURI2%% *}: $im"
822 if [ "$cvsup" = 1 ]; then
828 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
829 Exit_error err_no_source_in_repo $i;
830 elif [ -n "$UPDATE5" ] && \
831 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
832 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
833 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
835 echo "Updating source-$srcno md5."
836 md5=$(md5sum "$fp" | cut -f1 -d' ')
838 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
839 print "# Source'$srcno'-md5:\t'$md5'\n"
840 if /^Source'$srcno'\s*:\s+/;
845 if good_md5 "$i" && good_size "$i"; then
847 elif [ "$FROM_DISTFILES" = 1 ]; then
848 # wrong md5 from distfiles: remove the file and try again
850 echo "MD5 sum mismatch. Trying full fetch."
853 update_shell_title "${GETURI%% *}: $url"
854 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
855 if [ "`echo $url | grep -E 'ftp://'`" ]; then
856 update_shell_title "${GETURI2%% *}: $url"
857 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
859 if ! test -s "$target"; then
861 update_shell_title "${GETURI%% *}: $url_attic"
862 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
863 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
864 update_shell_title "${GETURI2%% *}: $url_attic"
865 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
868 test -s "$target" || rm -f "$target"
871 if good_md5 "$i" && good_size "$i" ; then
874 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
875 echo "or -5 to update md5 sums, if you're sure files are correct."
876 Exit_error err_no_source_in_repo $i
879 SHELL_TITLE_PREFIX=""
881 if [ "$get_files_cvs" ]; then
885 if [ "$CHMOD" = "yes" ]; then
886 CHMOD_FILES="`nourl "$@"`"
887 if [ -n "$CHMOD_FILES" ]; then
888 chmod $CHMOD_MODE $CHMOD_FILES
896 if [ -n "$DEBUG" ]; then
901 # Check whether first character of PACKAGE_NAME is legal for tag name
902 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
905 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"`
906 # Remove #kernel.version_release from TAGVER because tagging sources
907 # could occur with different kernel-headers than kernel-headers used at build time.
908 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
916 if [ -n "$DEBUG" ]; then
921 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
922 echo "Version: $PACKAGE_VERSION"
923 echo "Release: $PACKAGE_RELEASE"
927 if [ "$TAG_VERSION" = "yes" ]; then
928 echo "CVS tag: $TAGVER"
930 if [ -n "$TAG" ]; then
935 if [ -n "$CVSROOT" ]; then
936 OPTIONS="-d $CVSROOT $OPTIONS"
942 # don't tag files stored on distfiles
943 [ -n "`src_md5 $i`" ] && continue
944 if [ -f "`nourl $i`" ]; then
945 if [ "$TAG_VERSION" = "yes" ]; then
946 cvs $OPTIONS $TAGVER `nourl $i`
948 if [ -n "$TAG" ]; then
949 cvs $OPTIONS $TAG `nourl $i`
952 Exit_error err_no_source_in_repo $i
957 if [ "$TAG_VERSION" = "yes" ]; then
958 cvs $OPTIONS $TAGVER $SPECFILE
960 if [ -n "$TAG" ]; then
961 cvs $OPTIONS $TAG $SPECFILE
971 echo "CVS branch tag: $TAG"
976 if [ -n "$DEBUG" ]; then
981 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
984 if [ -n "$CVSROOT" ]; then
985 OPTIONS="-d $CVSROOT $OPTIONS"
990 if [ -f `nourl $i` ]; then
991 cvs $OPTIONS $TAG `nourl $i`
993 Exit_error err_no_source_in_repo $i
997 cvs $OPTIONS $TAG $SPECFILE
1007 update_shell_title "build_package"
1008 if [ -n "$DEBUG" ]; then
1015 if [ -n "$TRY_UPGRADE" ]; then
1016 update_shell_title "build_package: try_upgrade"
1017 if [ -n "$FLOAT_VERSION" ]; then
1018 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1020 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1023 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1025 if [ -n "$TNEWVER" ]; then
1026 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1027 echo "New version found, updating spec file to version " $TNEWVER
1028 cp -f $SPECFILE $SPECFILE.bak
1030 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1031 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1033 NODIST="yes" UPDATE5="yes" get_files $SOURCES $PATCHES;
1034 unset TOLDVER TNEWVER TNOTIFY
1041 BUILD_SWITCH="-ba" ;;
1043 BUILD_SWITCH="-bb" ;;
1045 BUILD_SWITCH="-bs --nodeps" ;;
1047 BUILD_SWITCH="-bp --nodeps" ;;
1050 update_shell_title "build_package: $COMMAND"
1051 if [ -n "$LOGFILE" ]; then
1052 LOG=`eval echo $LOGFILE`
1053 if [ -d "$LOG" ]; then
1054 echo "Log file $LOG is a directory."
1055 echo "Parse error in the spec?"
1056 Exit_error err_build_fail;
1058 if [ -n "$LASTLOG_FILE" ]; then
1059 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1061 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1062 (time eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1063 RETVAL=`cat $RES_FILE`
1065 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1066 if [ "$RETVAL" -eq "0" ]; then
1073 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1076 if [ "$RETVAL" -ne "0" ]; then
1077 if [ -n "$TRY_UPGRADE" ]; then
1078 echo "\n!!! Package with new version cannot be built automagically\n"
1079 mv -f $SPECFILE.bak $SPECFILE
1081 Exit_error err_build_fail;
1088 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1091 install_required_packages()
1098 # taken from find-spec-bcond, but with just getting the list
1100 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1102 /^%changelog/ { exit }
1103 /_with(out)?_[_a-zA-Z0-9]+/{
1104 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1105 print substr($0, RSTART, RLENGTH);
1108 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1109 bcond = substr($0, RSTART +5 , RLENGTH -5);
1110 gsub(/[ \t]+/,"_",bcond);
1112 }' $SPEC | LC_ALL=C sort -u
1117 update_shell_title "set bcond values"
1119 AVAIL_BCONDS_WITHOUT=""
1120 AVAIL_BCONDS_WITH=""
1121 if `grep -q ^%bcond ${SPECFILE}`; then
1123 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1129 local bcond_avail=$(find_spec_bcond $SPECFILE)
1131 # expand bconds from ~/.bcondrc
1132 # The file structure is like gentoo's package.use:
1135 # samba -mysql -pgsql
1136 # w32codec-installer license_agreement
1139 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1140 SN=${SPECFILE%%\.spec}
1142 local bcondrc=$HOME/.bcondrc
1143 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1145 while read pkg flags; do
1147 [[ "$pkg" == \#* ]] && continue
1149 # any package or current package?
1150 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1151 for flag in $flags; do
1152 local opt=${flag#[+-]}
1154 # use only flags which are in this package.
1155 if [[ $bcond_avail = *${opt}* ]]; then
1156 if [[ $flag = -* ]]; then
1157 BCOND="$BCOND --without $opt"
1159 BCOND="$BCOND --with $opt"
1165 update_shell_title "parse ~/.bcondrc: DONE!"
1168 update_shell_title "parse bconds"
1169 case "${BCOND_VERSION}" in
1174 echo "Warning: This spec has old style bconds. Fix it || die."
1175 for opt in `echo "$bcond_avail" | grep ^_without_`
1177 AVAIL_BCOND_WITHOUT=${opt#_without_}
1178 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1179 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1181 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1185 for opt in `echo "$bcond_avail" | grep ^_with_`
1187 AVAIL_BCOND_WITH=${opt#_with_}
1188 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1189 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1191 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1196 local cond_type="" # with || without
1197 for opt in $bcond_avail; do
1206 AVAIL_BCOND_WITHOUT=${opt#_without_}
1207 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1208 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1210 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1214 AVAIL_BCOND_WITH=${opt#_with_}
1215 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1216 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1218 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1222 case "$cond_type" in
1225 AVAIL_BCOND_WITH="$opt"
1226 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1227 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1229 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1234 AVAIL_BCOND_WITHOUT="$opt"
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"
1252 update_shell_title "run_sub_builder $package_name"
1254 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1255 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1256 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1257 # jakby nie bylo tego kawalka kodu.
1259 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1260 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1267 # Istnieje taki spec? ${package}.spec
1268 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1269 parent_spec_name=${package}.spec
1270 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1271 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1273 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1279 if [ "${parent_spec_name}" != "" ]; then
1280 spawn_sub_builder $parent_spec_name
1282 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1288 update_shell_title "spawn_sub_builder $package_name"
1291 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1292 sub_builder_opts="${sub_builder_opts} -R"
1294 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1295 sub_builder_opts="${sub_builder_opts} -RB"
1296 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1297 sub_builder_opts="${sub_builder_opts} -FRB"
1299 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1300 sub_builder_opts="${sub_builder_opts} -Upi"
1304 ./builder ${sub_builder_opts} "$@"
1307 remove_build_requires()
1309 if [ "$INSTALLED_PACKAGES" != "" ]; then
1310 case "$REMOVE_BUILD_REQUIRES" in
1312 run_poldek --noask -ve $INSTALLED_PACKAGES
1315 run_poldek --ask -ve $INSTALLED_PACKAGES
1318 echo You may want to manually remove following BuildRequires fetched:
1319 echo $INSTALLED_PACKAGES
1320 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1328 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1329 if [ "$BCOND" != "" ]; then
1330 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1333 echo -ne "\nNo conditional flags passed"
1335 echo -ne "\n\nfrom available:\n"
1336 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1342 if [ "$NOCVSSPEC" != "yes" ]; then
1343 echo -ne "Available branches: "
1344 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1348 # checks a given list of packages/files/provides agains current rpmdb.
1349 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1350 # input can be either STDIN or parameters
1355 if [ "$#" -gt 0 ]; then
1361 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1364 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1366 # other deps (files)
1367 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1370 # checks if given package/files/provides exists in rpmdb.
1371 # inout can be either stdin or parameters
1372 # returns packages wchi hare present in the rpmdb
1377 if [ "$#" -gt 0 ]; then
1383 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1386 fetch_build_requires()
1388 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1389 update_shell_title "fetch build requires"
1390 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1391 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1392 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1394 update_shell_title "poldek: update indexes"
1395 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1396 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1398 if [ -n "$CONF" ]; then
1399 update_shell_title "uninstall conflicting packages: $CONF"
1400 echo "Trying to uninstall conflicting packages ($CONF):"
1401 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1404 while [ "$DEPS" ]; do
1405 update_shell_title "install deps: $DEPS"
1406 echo "Trying to install dependencies ($DEPS):"
1407 local log=.${SPECFILE}_poldek.log
1408 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1409 failed=$(awk -F: '/^error:/{print $2}' $log)
1412 if [ -n "$failed" ]; then
1413 for package in $failed; do
1414 # FIXME: sanitise, deps could be not .spec files
1415 spawn_sub_builder -bb $package && ok="$ok $package"
1425 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1426 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1427 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1428 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1429 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1430 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`
1432 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`"
1434 package=`basename "$package_item"|sed -e "s/}$//g"`
1435 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1438 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1439 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1440 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
1445 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1448 if `echo $COND_TST|grep -q 'without_'`; then
1449 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1450 if `echo $COND_TST|grep -q !`; then
1455 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1456 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1457 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1463 elif `echo $COND_TST|grep -q 'with_'`; then
1464 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1465 if `echo $COND_TST|grep -q !`; then
1470 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1471 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1472 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1478 RESULT="${COND_STATE}-${COND_ARGV}"
1480 "with-wout" | "wout-with" )
1483 "wout-wout" | "with-with" )
1487 echo "Action '$RESULT' was not defined for package '$package_item'"
1493 if [ "$GO" = "yes" ]; then
1494 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1495 echo "Testing if $package has subrequirements..."
1496 run_poldek -t -i $package --dumpn=".$package-req.txt"
1497 if [ -f ".$package-req.txt" ]; then
1498 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1500 if [ "$package_name" = "$package" ]; then
1501 echo -ne "Installing BuildRequired package:\t$package_name\n"
1502 update_shell_title "Installing BuildRequired package: ${package_name}"
1503 install_required_packages $package;
1505 echo -ne "Installing (sub)Required package:\t$package_name\n"
1506 update_shell_title "Installing (sub)Required package: ${package_name}"
1507 install_required_packages $package_name;
1511 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1512 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1515 echo "Attempting to run spawn sub - builder..."
1516 echo -ne "Package installation failed:\t$package_name\n"
1517 run_sub_builder $package_name
1518 if [ $? -eq 0 ]; then
1519 install_required_packages $package_name;
1522 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1523 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1526 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1533 rm -f ".$package-req.txt"
1535 echo "Attempting to run spawn sub - builder..."
1536 echo -ne "Package installation failed:\t$package\n"
1537 run_sub_builder $package
1538 if [ $? -eq 0 ]; then
1539 install_required_packages $package;
1542 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1543 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1546 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1552 echo "Package $package is already installed. BuildRequirement satisfied."
1556 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1557 echo "Unable to install following packages and their dependencies:"
1558 for pkg in "$NOT_INSTALLED_PACKAGES"
1562 remove_build_requires
1570 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1571 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1573 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1575 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,repackage.sh}
1579 echo "To checkout *all* .spec files:"
1580 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1581 echo "- run cvs up in $SPECS_DIR dir"
1584 echo "To commit with your developer account:"
1585 echo "- edit $SPECS_DIR/CVS/Root"
1586 echo "- edit $SOURCE_DIR/CVS/Root"
1589 #---------------------------------------------
1592 if [ "$#" = 0 ]; then
1618 DEBUG="yes"; shift ;;
1620 COMMAND="version"; shift ;;
1622 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1623 -b | -ba | --build )
1624 COMMAND="build"; shift ;;
1625 -bb | --build-binary )
1626 COMMAND="build-binary"; shift ;;
1627 -bs | --build-source )
1628 COMMAND="build-source"; shift ;;
1629 -bp | --build-prep )
1630 COMMAND="build-prep"; shift ;;
1632 COMMAND="branch"; shift; TAG="${1}"; shift;;
1634 CLEAN="--clean --rmspec --rmsource"; shift ;;
1636 shift; CVSROOT="${1}"; shift ;;
1638 COMMAND="get"; shift ;;
1640 COMMAND="usage"; shift ;;
1642 PROTOCOL="http"; shift ;;
1644 shift; LOGFILE="${1}"; shift ;;
1646 shift; DEF_NICE_LEVEL=${1}; shift ;;
1647 -ske | --skip-existing-files)
1648 SKIP_EXISTING_FILES="yes"; shift ;;
1650 COMMAND="mr-proper"; shift ;;
1652 NOCVS="yes"; shift ;;
1653 -ncs | --no-cvs-specs )
1654 NOCVSSPEC="yes"; shift ;;
1655 -nd | --no-distfiles )
1656 NODIST="yes"; shift ;;
1657 -nm | --no-mirrors )
1658 NOMIRRORS="yes"; shift ;;
1660 NOURLS="yes"; shift ;;
1662 NOSRCS="yes"; shift ;;
1663 -ns0 | --no-source0 )
1664 NOSOURCE0="yes"; shift ;;
1675 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1677 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1678 --with | --without )
1679 case $GROUP_BCONDS in
1683 while ! `echo ${1}|grep -qE '(^-|spec)'`
1685 BCOND="$BCOND $COND $1"
1689 if [[ "$2" = *,* ]]; then
1690 for a in $(echo "$2" | tr , ' '); do
1691 BCOND="$BCOND $1 $a"
1694 BCOND="$BCOND $1 $2"
1700 shift; TARGET="${1}"; shift ;;
1702 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1704 QUIET="--quiet"; shift ;;
1706 CVSDATE="${2}"; shift 2 ;;
1708 shift; CVSTAG="${1}"; shift ;;
1709 -R | --fetch-build-requires)
1710 FETCH_BUILD_REQUIRES="yes"
1711 NOT_INSTALLED_PACKAGES=
1713 -RB | --remove-build-requires)
1714 REMOVE_BUILD_REQUIRES="nice"
1716 -FRB | --force-remove-build-requires)
1717 REMOVE_BUILD_REQUIRES="force"
1719 -sf | --sources-files)
1720 COMMAND="list-sources-files"
1722 -sp | --sources-paths)
1723 COMMAND="list-sources-local-paths"
1725 -su | --sources-urls)
1726 COMMAND="list-sources-urls"
1728 -Tvs | --tag-version-stable )
1733 -Tvn | --tag-version-nest )
1738 -Ts | --tag-stable )
1748 -Tv | --tag-version )
1753 -Tp | --tag-prefix )
1765 -ir | --integer-release-only )
1766 INTEGER_RELEASE="yes"
1775 -Upi | --update-poldek-indexes )
1776 UPDATE_POLDEK_INDEXES="yes"
1779 COMMAND="init_rpm_dir";
1781 -u | --try-upgrade )
1782 TRY_UPGRADE="1"; shift ;;
1783 -un | --try-upgrade-with-float-version )
1784 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1786 BE_VERBOSE="1"; shift ;;
1792 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1794 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1800 RPMOPTS="${RPMOPTS} --nodeps"
1803 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift ;;
1806 # check if specname was passed as specname:cvstag
1807 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
1808 CVSTAG="${SPECFILE##*:}";
1809 SPECFILE="${SPECFILE%%:*}";
1815 if [ -n "$DEBUG" ]; then
1820 if [ -n "$TARGET" ]; then
1823 TARGET_SWITCH="--target $TARGET" ;;
1825 TARGET_SWITCH="--target=$TARGET" ;;
1829 update_shell_title "$COMMAND"
1831 "build" | "build-binary" | "build-source" | "build-prep" )
1833 if [ -n "$SPECFILE" ]; then
1839 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1840 fetch_build_requires;
1841 if [ "$INTEGER_RELEASE" = "yes" ]; then
1842 echo "Checking release $PACKAGE_RELEASE..."
1843 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1844 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1848 if [ -n "$TEST_TAG" ]; then
1849 TAGVER=`make_tagver`
1850 echo "Searching for tag $TAGVER..."
1851 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1852 if [ -n "$TAGREL" ]; then
1853 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1856 # - do not allow to build from HEAD when XX-branch exists
1857 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1858 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1859 TAG_BRANCH="${TREE_PREFIX}-branch"
1860 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1861 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1862 Exit_error err_branch_exists "$TAG_STATUS"
1868 if [ -n "$NOSOURCE0" ] ; then
1869 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1871 get_files $SOURCES $PATCHES;
1873 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1874 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1876 remove_build_requires;
1878 Exit_error err_no_spec_in_cmdl;
1883 if [ -n "$SPECFILE" ]; then
1886 get_files $SOURCES $PATCHES;
1887 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1889 Exit_error err_no_spec_in_cmdl;
1894 if [ -n "$SPECFILE" ]; then
1898 if [ -n "$NOSOURCE0" ] ; then
1899 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1901 get_files $SOURCES $PATCHES
1903 Exit_error err_no_spec_in_cmdl;
1910 if [ -n "$SPECFILE" ]; then
1914 # don't fetch sources from remote locations
1916 for file in $SOURCES
1918 [ -n "`src_md5 $file`" ] && continue
1919 new_SOURCES="$new_SOURCES $file"
1921 SOURCES="$new_SOURCES"
1922 get_files $SOURCES $PATCHES;
1923 tag_files "$SOURCES $PATCHES $ICONS";
1925 Exit_error err_no_spec_in_cmdl;
1929 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1931 "list-sources-files" )
1934 DONT_PRINT_REVISION="yes"
1937 SAPS="$SOURCES $PATCHES"
1938 for SAP in $SAPS ; do
1939 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1942 "list-sources-urls" )
1945 DONT_PRINT_REVISION="yes"
1948 SAPS="$SOURCES $PATCHES"
1949 for SAP in $SAPS ; do
1953 "list-sources-local-paths" )
1956 DONT_PRINT_REVISION="yes"
1959 SAPS="$SOURCES $PATCHES"
1960 for SAP in $SAPS ; do
1961 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1972 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1973 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1977 # vi:syntax=sh:ts=4:sw=4