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 V 0.13 (C) 1999-2005 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!
75 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
76 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
81 CVS_SERVER="cvs.pld-linux.org"
82 DISTFILES_SERVER="://distfiles.pld-linux.org"
83 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
87 FAIL_IF_NO_SOURCES="yes"
89 # let get_files skip over files which are present to get those damn files fetched
90 SKIP_EXISTING_FILES="no"
92 if [ -x /usr/bin/rpm-getdeps ]; then
93 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
95 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
98 # Here we load saved user environment used to
99 # predefine options set above, or passed to builder
101 # This one reads global system environment settings:
102 if [ -f ~/etc/builderrc ]; then
105 # And this one cascades settings using user personal
107 # Example of ~/.builderrc:
109 #UPDATE_POLDEK_INDEXES="yes"
110 #FETCH_BUILD_REQUIRES="yes"
111 #REMOVE_BUILD_REQUIRES="force"
113 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
116 if [ -n "$HOME_ETC" ]; then
117 USER_CFG="$HOME_ETC/.builderrc"
119 USER_CFG=~/.builderrc
122 [ -f "$USER_CFG" ] && . "$USER_CFG"
124 wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
126 if [ -n "$USE_PROZILLA" ]; then
127 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
130 elif [ -n "$USE_AXEL" ]; then
131 GETURI="axel -a $AXEL_OPTS"
135 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
136 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
138 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
139 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
145 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
153 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
154 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
158 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
159 if [ -n "$LOGFILE" ]; then
160 LOG=`eval echo $LOGFILE`
161 if [ -n "$LASTLOG_FILE" ]; then
162 echo "LASTLOG=$LOG" > $LASTLOG_FILE
164 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
167 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
168 return `cat ${RES_FILE}`
173 #---------------------------------------------
178 if [ -n "$DEBUG" ]; then set -xv; fi
180 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
182 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
183 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
184 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
185 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
186 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
187 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
188 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
189 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
190 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
192 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
193 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
194 -n5, --no-md5 - ignore md5 comments in spec
195 -D, --debug - enable builder script debugging mode,
196 -debug - produce rpm debug package (same as --opts -debug)
197 -V, --version - output builder version
198 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
199 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
201 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
202 only package from <package>.spec,
203 -bp, --build-prep - execute the %prep phase of <package>.spec,
204 -bc - reserved (not implemented)
205 -bi reserved (not implemented)
206 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
208 --short-circuit - reserved (not implemented)
209 -B, --branch - add branch
210 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
211 SPECS and \$RPM_BUILD_ROOT),
212 -d <cvsroot>, --cvsroot <cvsroot>
214 --define <macro> <value>
215 - define a macro <macro> with value <value>,
216 --nodeps - rpm won't check any dependences
217 -g, --get - get <package>.spec and all related files from CVS repo
219 -h, --help - this message,
220 --http - use http instead of ftp,
221 -l <logfile>, --logtofile <logfile>
223 -m, --mr-proper - only remove all files related to spec file and all work
225 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
227 - don't check specs in CVS
228 -nd, --no-distfiles - don't download from distfiles
229 -nm, --no-mirrors - don't download from mirror, if source URL is given,
230 -nu, --no-urls - don't try to download from FTP/HTTP location,
231 -ns, --no-srcs - don't download Sources
232 -ns0, --no-source0 - don't download Source0
233 -nn, --no-net - don't download anything from the net
235 --skip-existing-files - skip existing files in get_files
236 --opts <rpm opts> - additional options for rpm
237 -q, --quiet - be quiet,
238 --date yyyy-mm-dd - build package using resources from specified CVS date,
239 -r <cvstag>, --cvstag <cvstag>
240 - build package using resources from specified CVS tag,
241 -R, --fetch-build-requires
242 - fetch what is BuildRequired,
243 -RB, --remove-build-requires
244 - remove all you fetched with -R or --fetch-build-requires
245 remember, this option requires confirmation,
246 -FRB, --force-remove-build-requires
247 - remove all you fetched with -R or --fetch-build-requires
248 remember, this option works without confirmation,
249 -sf, --source-files - list sources - bare filenames (intended for offline
250 operations; does not work when Icon field is present
251 but icon file is absent),
252 -sp, --source-paths - list sources - filenames with full local paths (intended for
253 offline operations; does not work when Icon field is present
254 but icon file is absent),
255 -su, --source-urls - list urls - urls to sources and patches
256 intended for copying urls with spec with lots of macros in urls
257 -T <cvstag> , --tag <cvstag>
258 - add cvs tag <cvstag> for files,
259 -Tvs, --tag-version-stable
260 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
261 -Tvn, --tag-version-nest
262 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
264 - add cvs tag STABLE for files,
266 - add cvs tag NEST for files,
268 - add cvs tag NAME-VERSION-RELEASE for files,
269 -Tp, --tag-prefix <prefix>
270 - add <prefix> to NAME-VERSION-RELEASE tags,
271 -tt, --test-tag <prefix>
272 - fail if tag is already present,
273 -ir, --integer-release-only
274 - allow only integer and snapshot releases
275 -v, --verbose - be verbose,
276 -u, --try-upgrade - check version, and try to upgrade package
277 -un, --try-upgrade-with-float-version
278 - as above, but allow float version
279 -U, --update - refetch sources, don't use distfiles, and update md5 comments
280 -Upi, --update-poldek-indexes
281 - refresh or make poldek package index files.
282 -np, --nopatch <patchnumber>
283 - don't apply <patchnumber>
284 --show-bconds - show available conditional builds, which can be used
285 - with --with and/or --without switches.
286 --with/--without <feature>
287 - conditional build package depending on %_with_<feature>/
288 %_without_<feature> macro switch. You may now use
289 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
290 constructions. Set GROUP_BCONDS to yes to make use of it.
291 --target <platform>, --target=<platform>
292 - build for platform <platform>.
296 update_shell_title() {
298 local len=${COLUMNS:-80}
299 local msg=$(echo "$*" | cut -c-$len)
301 msg="builder[$SPECFILE] ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
304 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
307 echo >&2 -ne "\033]0;$msg\007"
312 # set TARGET from BuildArch: from SPECFILE
314 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
315 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
320 TARGET_SWITCH="--target $TARGET" ;;
322 TARGET_SWITCH="--target=$TARGET" ;;
329 if [ -n "$DEBUG" ]; then
337 rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
340 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
346 if [ -z "$rpm_dump_cache" ] ; then
347 echo "internal error: cache_rpm_dump not called!" 1>&2
349 echo "$rpm_dump_cache"
354 update_shell_title "parsing specfile"
355 if [ -n "$DEBUG" ]; then
364 if [ "$NOSRCS" != "yes" ]; then
365 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
367 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
368 FAIL_IF_NO_SOURCES="no"
371 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
372 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
373 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
374 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
375 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
377 # These variables may be unset after first cache_rpm_dump call
378 # (because of not-yet-retrieved icon file)
380 # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
381 # Exit_error err_no_package_data;
384 if [ -n "$BE_VERBOSE" ]; then
385 echo "- Sources : `nourl $SOURCES`"
386 if [ -n "$PATCHES" ]; then
387 echo "- Patches : `nourl $PATCHES`"
389 echo "- Patches : *no patches needed*"
391 if [ -n "$ICONS" ]; then
392 echo "- Icon : `nourl $ICONS`"
394 echo "- Icon : *no package icon*"
396 echo "- Name : $PACKAGE_NAME"
397 echo "- Version : $PACKAGE_VERSION"
398 echo "- Release : $PACKAGE_RELEASE"
404 if [ -n "$DEBUG" ]; then
412 "err_no_spec_in_cmdl" )
413 remove_build_requires
414 echo "ERROR: spec file name not specified.";
416 "err_no_spec_in_repo" )
417 remove_build_requires
418 echo "Error: spec file not stored in CVS repo.";
420 "err_no_source_in_repo" )
421 remove_build_requires
422 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
425 remove_build_requires
426 echo "Error: package build failed. (${2:-no more info})";
428 "err_no_package_data" )
429 remove_build_requires
430 echo "Error: couldn't get out package name/version/release from spec file."
433 remove_build_requires
434 echo "Tag ${2} already exists (spec release: ${3}).";
437 remove_build_requires
438 echo "Release ${2} not integer and not a snapshot.";
440 "err_branch_exists" )
441 remove_build_requires
442 echo "Tree branch already exists (${2}).";
446 echo "Unknown error."
452 if [ -n "$DEBUG" ]; then
457 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
458 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
466 update_shell_title "get_spec"
468 if [ -n "$DEBUG" ]; then
474 if [ \! -f "$SPECFILE" ]; then
475 SPECFILE="`basename $SPECFILE .spec`.spec";
477 if [ "$NOCVSSPEC" != "yes" ]; then
480 if [ -n "$CVSROOT" ]; then
481 OPTIONS="-d $CVSROOT $OPTIONS"
483 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
484 echo "warning: No cvs access defined - using local .spec file"
489 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
490 OPTIONS="$OPTIONS -A"
492 if [ -n "$CVSDATE" ]; then
493 OPTIONS="$OPTIONS -D $CVSDATE"
495 if [ -n "$CVSTAG" ]; then
496 OPTIONS="$OPTIONS -r $CVSTAG"
502 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
504 retries_counter=$(( $retries_counter + 1 ))
505 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
507 [ -n "$output" ] && echo "$output"
508 if [ "$result" -ne "0" ]; then
509 if (echo "$output" | grep -qE "(Cannot connect to|connect to .* failed|Connection reset by peer|Connection timed out|Unknown host)") && [ "$retries_counter" -le "$CVS_RETRIES" ]; then
510 echo "Trying again [$SPECFILE]... ($retries_counter)"
514 Exit_error err_no_spec_in_repo;
518 if [ ! -f "$SPECFILE" ]; then
519 Exit_error err_no_spec_in_repo;
522 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
523 chmod $CHMOD_MODE $SPECFILE
526 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
535 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
536 cvs update mirrors >&2
540 while read origin mirror name rest
542 ol=`echo -n "$origin"|wc -c`
543 prefix="`echo -n "$url" | head -c $ol`"
544 if [ "$prefix" = "$origin" ] ; then
545 suffix="`echo "$url"|cut -b $ol-`"
546 echo -n "$mirror$suffix"
557 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
558 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
564 [ X"$NO5" = X"yes" ] && return
566 [ -z "$no" ] && return
568 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
569 if [ -z "$spec_rev" ]; then
570 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
572 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
573 md5=$(grep -s -v '^#' additional-md5sums | \
574 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
575 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
576 grep -E '^[0-9a-f]{32}$')
577 if [ X"$md5" = X"" ] ; then
578 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
579 if [ ! -z "$source_md5" ] ; then
582 # we have empty SourceX-md5, but it is still possible
583 # that we have NoSourceX-md5 AND NoSource: X
584 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
585 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
590 if [ $(echo "$md5" | wc -l) != 1 ] ; then
591 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
593 echo "$md5" | tail -n 1
599 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
602 distfiles_attic_url ()
604 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
611 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
616 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
617 [ -n "$size" -a "$size" -gt 0 ]
622 if [ "$CVSIGNORE_DF" != "yes" ]; then
625 cvsignore=${SOURCE_DIR}/.cvsignore
626 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
627 echo "$1" >> $cvsignore
633 update_shell_title "cvsup"
635 if [ -n "$CVSROOT" ]; then
636 OPTIONS="-d $CVSROOT $OPTIONS"
638 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
639 echo "warning: No cvs access defined for SOURCES"
643 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
644 OPTIONS="$OPTIONS -A"
646 if [ -n "$CVSDATE" ]; then
647 OPTIONS="$OPTIONS -D $CVSDATE"
649 if [ -n "$CVSTAG" ]; then
650 OPTIONS="$OPTIONS -r $CVSTAG"
655 local retries_counter=0
656 update_shell_title "cvsup: $# files"
657 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
658 retries_counter=$(( $retries_counter + 1 ))
659 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
661 [ -n "$output" ] && echo "$output"
662 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
663 echo "Trying again [$*]... ($retries_counter)"
664 update_shell_title "cvsup: retry #$retries_counter"
671 update_shell_title "cvsup: done!"
677 update_shell_title "fetching sources"
679 if [ -n "$DEBUG" ]; then
684 if [ $# -gt 0 ]; then
687 local nf=$(echo "$GET_FILES" | wc -w)
689 local get_files_cvs=""
690 for i in $GET_FILES; do
692 SHELL_TITLE_PREFIX="get_files[$nc/$nf]"
693 update_shell_title "$i"
694 local fp=`nourl "$i"`
695 if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then
698 if [ -n "$UPDATE5" ]; then
699 if [ -n "$ADD5" ]; then
700 [ "$fp" = "$i" ] && continue
701 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
703 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
707 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
708 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
709 echo "Warning: no URL given for $i"
712 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
713 if good_md5 "$i" && good_size "$i"; then
714 echo "$(nourl "$i") having proper md5sum already exists"
718 url=$(distfiles_url "$i")
719 url_attic=$(distfiles_attic_url "$i")
721 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
722 update_shell_title "${GETLOCAL}: $url"
723 ${GETLOCAL} $url $target
725 if [ -z "$NOMIRRORS" ]; then
726 url="`find_mirror "$url"`"
728 update_shell_title "${GETURI}: $url"
729 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
730 if [ "`echo $url | grep -E 'ftp://'`" ]; then
731 update_shell_title "${GETURI2}: $url"
732 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
735 if ! test -s "$target"; then
737 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
738 update_shell_title "${GETLOCAL}: $url_attic"
739 ${GETLOCAL} $url_attic $target
741 if [ -z "$NOMIRRORS" ]; then
742 url_attic="`find_mirror "$url_attic"`"
744 update_shell_title "${GETURI}: $url_attic"
745 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
746 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
747 update_shell_title "${GETURI2}: $url_attic"
748 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
752 if test -s "$target"; then
758 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
759 get_files_cvs="$get_files_cvs $fp"
763 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
764 if [ -z "$NOMIRRORS" ]; then
765 im="`find_mirror "$i"`"
769 update_shell_title "${GETURI}: $im"
771 if [ "`echo $im | grep -E 'ftp://'`" ]; then
772 update_shell_title "${GETURI2}: $im"
779 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
780 Exit_error err_no_source_in_repo $i;
781 elif [ -n "$UPDATE5" ] && \
782 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
783 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
784 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
786 echo "Updating source-$srcno md5."
787 md5=$(md5sum "$fp" | cut -f1 -d' ')
789 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
790 print "# Source'$srcno'-md5:\t'$md5'\n"
791 if /^Source'$srcno'\s*:\s+/;
796 if good_md5 "$i" && good_size "$i"; then
798 elif [ "$FROM_DISTFILES" = 1 ]; then
799 # wrong md5 from distfiles: remove the file and try again
801 echo "MD5 sum mismatch. Trying full fetch."
804 update_shell_title "${GETURI}: $url"
805 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
806 if [ "`echo $url | grep -E 'ftp://'`" ]; then
807 update_shell_title "${GETURI2}: $url"
808 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
810 if ! test -s "$target"; then
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"
819 test -s "$target" || rm -f "$target"
822 if good_md5 "$i" && good_size "$i" ; then
825 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
826 echo "or -5 to update md5 sums, if you're sure files are correct."
827 Exit_error err_no_source_in_repo $i
830 SHELL_TITLE_PREFIX=""
832 if [ "$get_files_cvs" ]; then
836 if [ "$CHMOD" = "yes" ]; then
837 CHMOD_FILES="`nourl $GET_FILES`"
838 if [ -n "$CHMOD_FILES" ]; then
839 chmod $CHMOD_MODE $CHMOD_FILES
847 if [ -n "$DEBUG" ]; then
852 # Check whether first character of PACKAGE_NAME is legal for tag name
853 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
856 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"`
857 # Remove #kernel.version_release from TAGVER because tagging sources
858 # could occur with different kernel-headers than kernel-headers used at build time.
859 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
867 if [ -n "$DEBUG" ]; then
872 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
873 echo "Version: $PACKAGE_VERSION"
874 echo "Release: $PACKAGE_RELEASE"
878 if [ "$TAG_VERSION" = "yes" ]; then
879 echo "CVS tag: $TAGVER"
881 if [ -n "$TAG" ]; then
886 if [ -n "$CVSROOT" ]; then
887 OPTIONS="-d $CVSROOT $OPTIONS"
893 # don't tag files stored on distfiles
894 [ -n "`src_md5 $i`" ] && continue
895 if [ -f "`nourl $i`" ]; then
896 if [ "$TAG_VERSION" = "yes" ]; then
897 cvs $OPTIONS $TAGVER `nourl $i`
899 if [ -n "$TAG" ]; then
900 cvs $OPTIONS $TAG `nourl $i`
903 Exit_error err_no_source_in_repo $i
908 if [ "$TAG_VERSION" = "yes" ]; then
909 cvs $OPTIONS $TAGVER $SPECFILE
911 if [ -n "$TAG" ]; then
912 cvs $OPTIONS $TAG $SPECFILE
922 echo "CVS branch tag: $TAG"
927 if [ -n "$DEBUG" ]; then
932 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
935 if [ -n "$CVSROOT" ]; then
936 OPTIONS="-d $CVSROOT $OPTIONS"
941 if [ -f `nourl $i` ]; then
942 cvs $OPTIONS $TAG `nourl $i`
944 Exit_error err_no_source_in_repo $i
948 cvs $OPTIONS $TAG $SPECFILE
958 update_shell_title "build_package"
959 if [ -n "$DEBUG" ]; then
966 if [ -n "$TRY_UPGRADE" ]; then
967 update_shell_title "build_package: try_upgrade"
968 if [ -n "$FLOAT_VERSION" ]; then
969 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
971 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
974 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
976 if [ -n "$TNEWVER" ]; then
977 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
978 echo "New version found, updating spec file to version " $TNEWVER
979 cp -f $SPECFILE $SPECFILE.bak
981 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
982 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
984 if [ -n "$ICONS" ]; then
988 NODIST="yes" UPDATE5="yes" get_files "$SOURCES $PATCHES";
989 unset TOLDVER TNEWVER TNOTIFY
996 BUILD_SWITCH="-ba" ;;
998 BUILD_SWITCH="-bb" ;;
1000 BUILD_SWITCH="-bs --nodeps" ;;
1002 BUILD_SWITCH="-bp --nodeps" ;;
1005 update_shell_title "build_package: $COMMAND"
1006 if [ -n "$LOGFILE" ]; then
1007 LOG=`eval echo $LOGFILE`
1008 if [ -d "$LOG" ]; then
1009 echo "Log file $LOG is a directory."
1010 echo "Parse error in the spec?"
1011 Exit_error err_build_fail;
1013 if [ -n "$LASTLOG_FILE" ]; then
1014 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1016 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1017 (time eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1018 RETVAL=`cat $RES_FILE`
1020 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1021 if [ "$RETVAL" -eq "0" ]; then
1028 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
1031 if [ "$RETVAL" -ne "0" ]; then
1032 if [ -n "$TRY_UPGRADE" ]; then
1033 echo "\n!!! Package with new version cannot be build automagically\n"
1034 mv -f $SPECFILE.bak $SPECFILE
1036 Exit_error err_build_fail;
1043 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1046 install_required_packages()
1054 update_shell_title "set bcond values"
1056 AVAIL_BCONDS_WITHOUT=""
1057 AVAIL_BCONDS_WITH=""
1058 if `grep -q ^%bcond ${SPECFILE}`; then
1060 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1063 BCOND_VERSION="NONE"
1066 # expand bconds from ~/.bcondrc
1067 # The file structure is like gentoo's package.use:
1070 # samba -mysql -pgsql
1071 # w32codec-installer license_agreement
1074 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
1075 # This takes package name, first defined in spec.
1076 # so consider that when defining flags for package.
1077 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
1078 SN=${SPECFILE%%\.spec}
1079 AVAIL=`$RPMBUILD --bcond $SPECFILE`
1081 BCONDRC=$HOME/.bcondrc
1082 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
1084 while read pkg flags; do
1086 [[ "$pkg" == \#* ]] && continue
1088 # any package or current package?
1089 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ] || [ "$pkg" = "$SN" ]; then
1090 for flag in $flags; do
1093 # use only flags which are in this package.
1094 if [[ $AVAIL = *${opt}* ]]; then
1095 if [[ $flag = -* ]]; then
1096 BCOND="$BCOND --without $opt"
1098 BCOND="$BCOND --with $opt"
1106 case "${BCOND_VERSION}" in
1111 echo "Warning: This spec has old style bconds. Fix it || die."
1112 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1114 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1115 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1116 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1118 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1122 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1124 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1125 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1126 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1128 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1133 cond_type="" # with || without
1134 for opt in `$RPMBUILD --bcond $SPECFILE`
1144 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1145 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1146 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1148 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1152 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1153 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1154 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1156 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1160 case "$cond_type" in
1163 AVAIL_BCOND_WITH="$opt"
1164 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1165 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1167 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1172 AVAIL_BCOND_WITHOUT="$opt"
1173 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1174 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1176 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1190 update_shell_title "run_sub_builder $package_name"
1192 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1193 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1194 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1195 # jakby nie bylo tego kawalka kodu.
1197 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1198 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1205 # Istnieje taki spec? ${package}.spec
1206 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1207 parent_spec_name=${package}.spec
1208 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1209 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1211 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1217 if [ "${parent_spec_name}" != "" ]; then
1218 spawn_sub_builder $parent_spec_name
1220 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1226 update_shell_title "spawn_sub_builder $package_name"
1229 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1230 sub_builder_opts="${sub_builder_opts} -R"
1232 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1233 sub_builder_opts="${sub_builder_opts} -RB"
1234 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1235 sub_builder_opts="${sub_builder_opts} -FRB"
1237 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1238 sub_builder_opts="${sub_builder_opts} -Upi"
1242 ./builder ${sub_builder_opts} "$@"
1245 remove_build_requires()
1247 if [ "$INSTALLED_PACKAGES" != "" ]; then
1248 case "$REMOVE_BUILD_REQUIRES" in
1250 run_poldek --noask -ve $INSTALLED_PACKAGES
1253 run_poldek --ask -ve $INSTALLED_PACKAGES
1256 echo You may want to manually remove following BuildRequires fetched:
1257 echo $INSTALLED_PACKAGES
1258 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1266 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1267 if [ "$BCOND" != "" ]; then
1268 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1271 echo -ne "\nNo conditional flags passed"
1273 echo -ne "\n\nfrom available:\n"
1274 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1280 if [ "$NOCVSSPEC" != "yes" ]; then
1281 echo -ne "Available branches: "
1282 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1286 # checks a given list of packages/files/provides agains current rpmdb.
1287 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1288 # input can be either STDIN or parameters
1293 if [ "$#" -gt 0 ]; then
1299 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1302 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1304 # other deps (files)
1305 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1308 # checks if given package/files/provides exists in rpmdb.
1309 # inout can be either stdin or parameters
1310 # returns packages wchi hare present in the rpmdb
1315 if [ "$#" -gt 0 ]; then
1321 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1324 fetch_build_requires()
1326 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1327 update_shell_title "fetch build requires"
1328 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1329 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1330 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1332 update_shell_title "poldek: update indexes"
1333 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1334 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1336 if [ -n "$CONF" ]; then
1337 update_shell_title "uninstall conflicting packages: $CONF"
1338 echo "Trying to uninstall conflicting packages ($CONF):"
1339 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1342 while [ "$DEPS" ]; do
1343 update_shell_title "install deps: $DEPS"
1344 echo "Trying to install dependencies ($DEPS):"
1345 local log=.${SPECFILE}_poldek.log
1346 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1347 failed=$(awk -F: '/^error:/{print $2}' $log)
1350 if [ -n "$failed" ]; then
1351 for package in $failed; do
1352 # FIXME: sanitise, deps could be not .spec files
1353 spawn_sub_builder -bb $package && ok="$ok $package"
1363 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1364 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1365 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1366 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1367 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1368 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`
1370 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`"
1372 package=`basename "$package_item"|sed -e "s/}$//g"`
1373 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1376 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1377 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1378 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
1383 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1386 if `echo $COND_TST|grep -q 'without_'`; then
1387 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1388 if `echo $COND_TST|grep -q !`; then
1393 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1394 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1395 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1401 elif `echo $COND_TST|grep -q 'with_'`; then
1402 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1403 if `echo $COND_TST|grep -q !`; then
1408 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1409 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1410 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1416 RESULT="${COND_STATE}-${COND_ARGV}"
1418 "with-wout" | "wout-with" )
1421 "wout-wout" | "with-with" )
1425 echo "Action '$RESULT' was not defined for package '$package_item'"
1431 if [ "$GO" = "yes" ]; then
1432 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1433 echo "Testing if $package has subrequirements..."
1434 run_poldek -t -i $package --dumpn=".$package-req.txt"
1435 if [ -f ".$package-req.txt" ]; then
1436 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1438 if [ "$package_name" = "$package" ]; then
1439 echo -ne "Installing BuildRequired package:\t$package_name\n"
1440 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1441 install_required_packages $package;
1443 echo -ne "Installing (sub)Required package:\t$package_name\n"
1444 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1445 install_required_packages $package_name;
1449 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1450 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1453 echo "Attempting to run spawn sub - builder..."
1454 echo -ne "Package installation failed:\t$package_name\n"
1455 run_sub_builder $package_name
1456 if [ $? -eq 0 ]; then
1457 install_required_packages $package_name;
1460 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1461 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1464 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1471 rm -f ".$package-req.txt"
1473 echo "Attempting to run spawn sub - builder..."
1474 echo -ne "Package installation failed:\t$package\n"
1475 run_sub_builder $package
1476 if [ $? -eq 0 ]; then
1477 install_required_packages $package;
1480 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1481 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1484 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1490 echo "Package $package is already installed. BuildRequirement satisfied."
1494 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1495 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1496 echo "Unable to install following packages and their dependencies:"
1497 for pkg in "$NOT_INSTALLED_PACKAGES"
1501 remove_build_requires
1507 #---------------------------------------------
1510 if [ "$#" = 0 ]; then
1536 DEBUG="yes"; shift ;;
1538 COMMAND="version"; shift ;;
1540 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1541 -b | -ba | --build )
1542 COMMAND="build"; shift ;;
1543 -bb | --build-binary )
1544 COMMAND="build-binary"; shift ;;
1545 -bs | --build-source )
1546 COMMAND="build-source"; shift ;;
1547 -bp | --build-prep )
1548 COMMAND="build-prep"; shift ;;
1550 COMMAND="branch"; shift; TAG="${1}"; shift;;
1552 CLEAN="--clean --rmspec --rmsource"; shift ;;
1554 shift; CVSROOT="${1}"; shift ;;
1556 COMMAND="get"; shift ;;
1558 COMMAND="usage"; shift ;;
1560 PROTOCOL="http"; shift ;;
1562 shift; LOGFILE="${1}"; shift ;;
1564 shift; DEF_NICE_LEVEL=${1}; shift ;;
1565 -ske | --skip-existing-files)
1566 SKIP_EXISTING_FILES="yes"; shift ;;
1568 COMMAND="mr-proper"; shift ;;
1570 NOCVS="yes"; shift ;;
1571 -ncs | --no-cvs-specs )
1572 NOCVSSPEC="yes"; shift ;;
1573 -nd | --no-distfiles )
1574 NODIST="yes"; shift ;;
1575 -nm | --no-mirrors )
1576 NOMIRRORS="yes"; shift ;;
1578 NOURLS="yes"; shift ;;
1580 NOSRCS="yes"; shift ;;
1581 -ns0 | --no-source0 )
1582 NOSOURCE0="yes"; shift ;;
1593 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1595 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1596 --with | --without )
1597 case $GROUP_BCONDS in
1601 while ! `echo ${1}|grep -qE '(^-|spec)'`
1603 BCOND="$BCOND $COND $1"
1607 if [[ "$2" = *,* ]]; then
1608 for a in $(echo "$2" | tr , ' '); do
1609 BCOND="$BCOND $1 $a"
1612 BCOND="$BCOND $1 $2"
1618 shift; TARGET="${1}"; shift ;;
1620 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1622 QUIET="--quiet"; shift ;;
1624 CVSDATE="${2}"; shift 2 ;;
1626 shift; CVSTAG="${1}"; shift ;;
1627 -R | --fetch-build-requires)
1628 FETCH_BUILD_REQUIRES="yes"
1629 NOT_INSTALLED_PACKAGES=
1631 -RB | --remove-build-requires)
1632 REMOVE_BUILD_REQUIRES="nice"
1634 -FRB | --force-remove-build-requires)
1635 REMOVE_BUILD_REQUIRES="force"
1637 -sf | --sources-files)
1638 COMMAND="list-sources-files"
1640 -sp | --sources-paths)
1641 COMMAND="list-sources-local-paths"
1643 -su | --sources-urls)
1644 COMMAND="list-sources-urls"
1646 -Tvs | --tag-version-stable )
1651 -Tvn | --tag-version-nest )
1656 -Ts | --tag-stable )
1666 -Tv | --tag-version )
1671 -Tp | --tag-prefix )
1683 -ir | --integer-release-only )
1684 INTEGER_RELEASE="yes"
1693 -Upi | --update-poldek-indexes )
1694 UPDATE_POLDEK_INDEXES="yes"
1696 -u | --try-upgrade )
1697 TRY_UPGRADE="1"; shift ;;
1698 -un | --try-upgrade-with-float-version )
1699 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1701 BE_VERBOSE="1"; shift ;;
1707 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1709 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1715 RPMOPTS="${RPMOPTS} --nodeps"
1718 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1721 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1726 if [ -n "$DEBUG" ]; then
1731 if [ -n "$TARGET" ]; then
1734 TARGET_SWITCH="--target $TARGET" ;;
1736 TARGET_SWITCH="--target=$TARGET" ;;
1740 update_shell_title "$COMMAND"
1742 "build" | "build-binary" | "build-source" | "build-prep" )
1744 if [ -n "$SPECFILE" ]; then
1749 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1750 fetch_build_requires;
1752 if [ "$INTEGER_RELEASE" = "yes" ]; then
1753 echo "Checking release $PACKAGE_RELEASE..."
1754 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1755 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1759 if [ -n "$TEST_TAG" ]; then
1760 TAGVER=`make_tagver`
1761 echo "Searching for tag $TAGVER..."
1762 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1763 if [ -n "$TAGREL" ]; then
1764 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1767 # - do not allow to build from HEAD when XX-branch exists
1768 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1769 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1770 TAG_BRANCH="${TREE_PREFIX}-branch"
1771 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1772 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1773 Exit_error err_branch_exists "$TAG_STATUS"
1779 if [ -n "$ICONS" ]; then
1783 if [ -n "$NOSOURCE0" ] ; then
1784 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1786 get_files "$SOURCES $PATCHES";
1788 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1789 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1791 remove_build_requires;
1793 Exit_error err_no_spec_in_cmdl;
1798 if [ -n "$SPECFILE" ]; then
1801 if [ -n "$ICONS" ]; then
1805 get_files $SOURCES $PATCHES;
1806 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1808 Exit_error err_no_spec_in_cmdl;
1813 if [ -n "$SPECFILE" ]; then
1816 if [ -n "$ICONS" ]; then
1817 OLD_UPDATE5=$UPDATE5
1818 UPDATE5= get_files $ICONS
1819 UPDATE5=$OLD_UPDATE5
1822 if [ -n "$NOSOURCE0" ] ; then
1823 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1825 get_files $SOURCES $PATCHES
1827 Exit_error err_no_spec_in_cmdl;
1834 if [ -n "$SPECFILE" ]; then
1837 if [ -n "$ICONS" ]; then
1841 # don't fetch sources from remote locations
1843 for file in $SOURCES
1845 [ -n "`src_md5 $file`" ] && continue
1846 new_SOURCES="$new_SOURCES $file"
1848 SOURCES="$new_SOURCES"
1849 get_files $SOURCES $PATCHES;
1850 tag_files "$SOURCES $PATCHES $ICONS";
1852 Exit_error err_no_spec_in_cmdl;
1856 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1858 "list-sources-files" )
1861 DONT_PRINT_REVISION="yes"
1864 SAPS="$SOURCES $PATCHES"
1865 for SAP in $SAPS ; do
1866 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1869 "list-sources-urls" )
1872 DONT_PRINT_REVISION="yes"
1875 SAPS="$SOURCES $PATCHES"
1876 for SAP in $SAPS ; do
1880 "list-sources-local-paths" )
1883 DONT_PRINT_REVISION="yes"
1886 SAPS="$SOURCES $PATCHES"
1887 for SAP in $SAPS ; do
1888 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1896 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1897 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1901 # vi:syntax=sh:ts=4:sw=4