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
20 # - tries to get new version from distfiles without new md5
21 # - after fetching new version doesn't update md5
22 # - doesn't get sources for specs with %include /usr/lib/rpm/macros.python
23 # when there's no rpm-pythonprov (rpm's fault, but it's ugly anyway)
24 # - as above with %include /usr/lib/rpm/macros.perl and no rpm-perlprov
25 # - when Icon: field is present, -5 and -a5 doesn't work
28 Build package utility from PLD CVS repository
29 V 0.11 (C) 1999-2004 Free Penguins".
30 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
48 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
51 # It can be used i.e. in log file naming.
52 # See LOGFILE example.
53 DATE=`date +%Y-%m-%d_%H-%M-%S`
55 # Example: LOGFILE='../log.$PACKAGE_NAME'
56 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
57 # Yes, you can use variable name! Note _single_ quotes!
79 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
80 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
85 CVS_SERVER="cvs.pld-linux.org"
86 DISTFILES_SERVER="://distfiles.pld-linux.org"
87 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
91 FAIL_IF_NO_SOURCES="yes"
93 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
94 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
96 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
97 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
100 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
108 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
110 POLDEK_CMD="/usr/bin/poldek --noask"
112 # Here we load saved user environment used to
113 # predefine options set above, or passed to builder
115 # This one reads global system environment settings:
116 if [ -f ~/etc/builderrc ]; then
119 # And this one cascades settings using user personal
121 # Example of ~/.builderrc:
123 #UPDATE_POLDEK_INDEXES="yes"
124 #FETCH_BUILD_REQUIRES="yes"
125 #REMOVE_BUILD_REQUIRES="force"
127 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
129 if [ -n "$HOME_ETC" ]; then
130 USER_CFG="$HOME_ETC/.builderrc"
132 USER_CFG=~/.builderrc
135 [ -f "$USER_CFG" ] && . "$USER_CFG"
139 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
140 if [ -n "$LOGFILE" ]; then
141 LOG=`eval echo $LOGFILE`
142 if [ -n "$LASTLOG_FILE" ]; then
143 echo "LASTLOG=$LOG" > $LASTLOG_FILE
145 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee $LOG
148 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
149 return `cat ${RES_FILE}`
154 # Example grep cvs /etc/poldek.conf:
155 # source = cvs /home/users/yoshi/rpm/RPMS/
156 if [ "$UPDATE_POLDEK_INDEXES" = "yes" ]; then
157 run_poldek -l -n ${POLDEK_SOURCE} 1>&2 > /dev/null
158 if [ ! "$?" == "0" ]; then
159 echo "Using improper source '${POLDEK_SOURCE}' in /etc/poldek.conf"
160 echo "Fix it and try to continue"
165 #---------------------------------------------
170 if [ -n "$DEBUG" ]; then set -xv; fi
172 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
174 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
175 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
176 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
177 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
178 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
179 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
180 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
181 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>]
182 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
184 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
185 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
186 -n5, --no-md5 - ignore md5 comments in spec
187 -D, --debug - enable script debugging mode,
188 -V, --version - output builder version
189 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
190 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
192 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
193 only package from <package>.spec,
194 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
196 -bp, --build-prep - execute the %prep phase of <package>.spec,
197 -B, --branch - add branch
198 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
199 SPECS and \$RPM_BUILD_ROOT),
200 -d <cvsroot>, --cvsroot <cvsroot>
202 --define <macro> <value>
203 - define a macro <macro> with value <value>,
204 --nodeps - rpm won't check any dependences
205 -g, --get - get <package>.spec and all related files from CVS repo
207 -h, --help - this message,
208 --http - use http instead of ftp,
209 -l <logfile>, --logtofile <logfile>
211 -m, --mr-proper - only remove all files related to spec file and all work
213 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
215 - don't check specs in CVS
216 -nd, --no-distfiles - don't download from distfiles
217 -nm, --no-mirrors - don't download from mirror, if source URL is given,
218 -nu, --no-urls - don't try to download from FTP/HTTP location,
219 -ns, --no-srcs - don't download Sources
220 -ns0, --no-source0 - don't download Source0
221 -nn, --no-net - don't download anything from the net
222 --opts <rpm opts> - additional options for rpm
223 -q, --quiet - be quiet,
224 --date yyyy-mm-dd - build package using resources from specified CVS date,
225 -r <cvstag>, --cvstag <cvstag>
226 - build package using resources from specified CVS tag,
227 -R, --fetch-build-requires
228 - fetch what is BuildRequired,
229 -RB, --remove-build-requires
230 - remove all you fetched with -R or --fetch-build-requires
231 remember, this option requires confirmation,
232 -FRB, --force-remove-build-requires
233 - remove all you fetched with -R or --fetch-build-requires
234 remember, this option works without confirmation,
235 -T <cvstag> , --tag <cvstag>
236 - add cvs tag <cvstag> for files,
237 -Tvs, --tag-version-stable
238 - add cvs tags STABLE and NAME-VERSION-RELESE for files,
239 -Tvn, --tag-version-nest
240 - add cvs tags NEST and NAME-VERSION-RELESE for files,
242 - add cvs tag STABLE for files,
244 - add cvs tag NEST for files,
246 - add cvs tag NAME-VERSION-RELESE for files,
247 -Tp, --tag-prefix <prefix>
248 - add <prefix> to NAME-VERSION-RELEASE tags,
249 -tt, --test-tag <prefix>
250 - fail if tag is already present,
251 -ir, --integer-release-only
252 - allow only integer and snapshot releases
253 -v, --verbose - be verbose,
254 -u, --try-upgrade - check version, and try to upgrade package
255 -un, --try-upgrade-with-float-version
256 - as above, but allow float version
257 -U, --update - refetch sources, don't use distfiles, and update md5 comments
258 -Upi, --update-poldek-indexes
259 - refresh or make poldek package index files.
260 --with/--without <feature>
261 - conditional build package depending on %_with_<feature>/
262 %_without_<feature> macro switch. You may now use
263 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
264 constructions. Set GROUP_BCONDS to yes to make use of it.
266 - build for platform <platform>.
271 if [ -n "$DEBUG" ]; then
278 rpm -bp --nodeps --define 'prep %dump' $BCOND $SPECFILE 2>&1
281 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1
287 if [ -z "$rpm_dump_cache" ] ; then
288 echo "internal error: cache_rpm_dump not called!" 1>&2
290 echo "$rpm_dump_cache"
295 if [ -n "$DEBUG" ]; then
304 if [ "$NOSRCS" != "yes" ]; then
305 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
307 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
308 FAIL_IF_NO_SOURCES="no"
311 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
312 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
313 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
314 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
315 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
317 if [ -n "$BE_VERBOSE" ]; then
318 echo "- Sources : `nourl $SOURCES`"
319 if [ -n "$PATCHES" ]; then
320 echo "- Patches : `nourl $PATCHES`"
322 echo "- Patches : *no patches needed*"
324 if [ -n "$ICONS" ]; then
325 echo "- Icon : `nourl $ICONS`"
327 echo "- Icon : *no package icon*"
329 echo "- Name : $PACKAGE_NAME"
330 echo "- Version : $PACKAGE_VERSION"
331 echo "- Release : $PACKAGE_RELEASE"
337 if [ -n "$DEBUG" ]; then
345 "err_no_spec_in_cmdl" )
346 remove_build_requires
347 echo "ERROR: spec file name not specified.";
349 "err_no_spec_in_repo" )
350 remove_build_requires
351 echo "Error: spec file not stored in CVS repo.";
353 "err_no_source_in_repo" )
354 remove_build_requires
355 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
358 remove_build_requires
359 echo "Error: package build failed. (${2:-no more info})";
362 remove_build_requires
363 echo "Tag ${2} already exists (spec release: ${3}).";
366 remove_build_requires
367 echo "Release ${2} not integer and not a snapshot.";
371 echo "Unknown error."
377 if [ -n "$DEBUG" ]; then
382 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
383 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
390 if [ -n "$DEBUG" ]; then
396 if [ \! -f "$SPECFILE" ]; then
397 SPECFILE="`basename $SPECFILE .spec`.spec";
399 if [ "$NOCVSSPEC" != "yes" ]; then
402 if [ -n "$CVSROOT" ]; then
403 OPTIONS="-d $CVSROOT $OPTIONS"
405 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
406 echo "warning: No cvs access defined - using local .spec file"
411 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
412 OPTIONS="$OPTIONS -A"
414 if [ -n "$CVSDATE" ]; then
415 OPTIONS="$OPTIONS -D $CVSDATE"
417 if [ -n "$CVSTAG" ]; then
418 OPTIONS="$OPTIONS -r $CVSTAG"
424 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
426 retries_counter=$(( $retries_counter + 1 ))
427 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
429 [ -n "$output" ] && echo "$output"
430 if [ "$result" -ne "0" ]; then
431 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
432 echo "Trying again [$SPECFILE]... ($retries_counter)"
436 Exit_error err_no_spec_in_repo;
440 if [ ! -f "$SPECFILE" ]; then
441 Exit_error err_no_spec_in_repo;
444 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
445 chmod $CHMOD_MODE $SPECFILE
448 grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
455 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
456 cvs update mirrors >&2
460 while read origin mirror name rest
462 ol=`echo -n "$origin"|wc -c`
463 prefix="`echo -n "$url" | head -c $ol`"
464 if [ "$prefix" = "$origin" ] ; then
465 suffix="`echo "$url"|cut -b $ol-`"
466 echo -n "$mirror$suffix"
477 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
478 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
484 [ X"$NO5" = X"yes" ] && return
486 [ -z "$no" ] && return
488 spec_rev=$(grep $SPECFILE CVS/Entries | sed -e s:/$SPECFILE/:: -e s:/.*::)
489 if [ -z "$spec_rev" ]; then
490 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
492 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
493 md5=$(grep -s -v '^#' additional-md5sums | \
494 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
495 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
496 grep -E '^[0-9a-f]{32}$')
497 if [ X"$md5" = X"" ] ; then
498 grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://' | xargs
500 if [ $(echo "$md5" | wc -l) != 1 ] ; then
501 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
503 echo "$md5" | tail -n 1
509 echo "$PROTOCOL$DISTFILES_SERVER/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
512 distfiles_attic_url ()
514 echo "$PROTOCOL$ATTICDISTFILES_SERVER/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
521 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
526 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
527 [ -n "$size" -a "$size" -gt 0 ]
532 if [ "$CVSIGNORE_DF" != "yes" ]; then
535 cvsignore=${SOURCE_DIR}/.cvsignore
536 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
537 echo "$1" >> $cvsignore
545 if [ -n "$DEBUG" ]; then
550 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
554 if [ -n "$CVSROOT" ]; then
555 OPTIONS="-d $CVSROOT $OPTIONS"
557 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
558 echo "warning: No cvs access defined for SOURCES"
562 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
563 OPTIONS="$OPTIONS -A"
565 if [ -n "$CVSDATE" ]; then
566 OPTIONS="$OPTIONS -D $CVSDATE"
568 if [ -n "$CVSTAG" ]; then
569 OPTIONS="$OPTIONS -r $CVSTAG"
574 if [ -n "$UPDATE5" ]; then
575 if [ -n "$ADD5" ]; then
576 [ `nourl $i` = "$i" ] && continue
577 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
579 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
583 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
584 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
585 echo "Warning: no URL given for $i"
588 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
589 if good_md5 "$i" && good_size "$i"; then
590 echo "$(nourl "$i") having proper md5sum already exists"
594 url=$(distfiles_url "$i")
595 url_attic=$(distfiles_attic_url "$i")
597 if [ `echo $url | grep -E '^(\.|/)'` ]; then
598 ${GETLOCAL} $url $target
600 if [ -z "$NOMIRRORS" ]; then
601 url="`find_mirror "$url"`"
603 ${GETURI} -O "$target" "$url" || \
604 if [ `echo $url | grep -E 'ftp://'` ]; then
605 ${GETURI2} -O "$target" "$url"
608 if ! test -s "$target"; then
610 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
611 ${GETLOCAL} $url_attic $target
613 if [ -z "$NOMIRRORS" ]; then
614 url_attic="`find_mirror "$url_attic"`"
616 ${GETURI} -O "$target" "$url_attic" || \
617 if [ `echo $url_attic | grep -E 'ftp://'` ]; then
618 ${GETURI2} -O "$target" "$url_attic"
622 if test -s "$target"; then
628 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
629 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
632 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
634 retries_counter=$(( $retries_counter + 1 ))
635 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
637 [ -n "$output" ] && echo "$output"
638 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
639 echo "Trying again [`nourl $i`]... ($retries_counter)"
648 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then
649 if [ -z "$NOMIRRORS" ]; then
650 im="`find_mirror "$i"`"
655 if [ `echo $im | grep -E 'ftp://'` ]; then
662 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
663 Exit_error err_no_source_in_repo $i;
664 elif [ -n "$UPDATE5" ] && \
665 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
666 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
667 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
669 echo "Updating source-$srcno md5."
670 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
672 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
673 print "# Source'$srcno'-md5:\t'$md5'\n"
674 if /^Source'$srcno'\s*:\s+/;
679 if good_md5 "$i" && good_size "$i"; then
681 elif [ "$FROM_DISTFILES" = 1 ]; then
682 # wrong md5 from distfiles: remove the file and try again
684 echo "MD5 sum mismatch. Trying full fetch."
687 ${GETURI} -O "$target" "$url" || \
688 if [ `echo $url | grep -E 'ftp://'` ]; then
689 ${GETURI2} -O "$target" "$url"
691 if ! test -s "$target"; then
693 ${GETURI} -O "$target" "$url_attic" || \
694 if [ `echo $url_attic | grep -E 'ftp://'` ]; then
695 ${GETURI2} -O "$target" "$url_attic"
698 test -s "$target" || rm -f "$target"
701 if good_md5 "$i" && good_size "$i" ; then
704 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
705 echo "or -5 to update md5 sums, if you're sure files are correct."
706 Exit_error err_no_source_in_repo $i
710 if [ "$CHMOD" = "yes" ]; then
711 CHMOD_FILES="`nourl $GET_FILES`"
712 if [ -n "$CHMOD_FILES" ]; then
713 chmod $CHMOD_MODE $CHMOD_FILES
721 # Check whether first character of PACKAGE_NAME is legal for tag name
722 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
725 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"`
726 # Remove #kernel.version_release from TAGVER because tagging sources
727 # could occur with different kernel-headers than kernel-headers used at build time.
728 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
736 if [ -n "$DEBUG" ]; then
741 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
742 echo "Version: $PACKAGE_VERSION"
743 echo "Release: $PACKAGE_RELEASE"
747 if [ "$TAG_VERSION" = "yes" ]; then
748 echo "CVS tag: $TAGVER"
750 if [ -n "$TAG" ]; then
755 if [ -n "$CVSROOT" ]; then
756 OPTIONS="-d $CVSROOT $OPTIONS"
762 # don't tag files stored on distfiles
763 [ -n "`src_md5 $i`" ] && continue
764 if [ -f "`nourl $i`" ]; then
765 if [ "$TAG_VERSION" = "yes" ]; then
766 cvs $OPTIONS $TAGVER `nourl $i`
768 if [ -n "$TAG" ]; then
769 cvs $OPTIONS $TAG `nourl $i`
772 Exit_error err_no_source_in_repo $i
777 if [ "$TAG_VERSION" = "yes" ]; then
778 cvs $OPTIONS $TAGVER $SPECFILE
780 if [ -n "$TAG" ]; then
781 cvs $OPTIONS $TAG $SPECFILE
791 echo "CVS branch tag: $TAG"
796 if [ -n "$DEBUG" ]; then
801 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
804 if [ -n "$CVSROOT" ]; then
805 OPTIONS="-d $CVSROOT $OPTIONS"
810 if [ -f `nourl $i` ]; then
811 cvs $OPTIONS $TAG `nourl $i`
813 Exit_error err_no_source_in_repo $i
817 cvs $OPTIONS $TAG $SPECFILE
827 if [ -n "$DEBUG" ]; then
834 if [ -n "$TRY_UPGRADE" ]; then
835 if [ -n "$FLOAT_VERSION" ]; then
836 TNOTIFY=`./pldnotify.awk $SPECFILE -n`
838 TNOTIFY=`./pldnotify.awk $SPECFILE`
841 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
843 if [ -n "$TNEWVER" ]; then
844 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
845 echo "New version found, updating spec file to version " $TNEWVER
846 cp -f $SPECFILE $SPECFILE.bak
848 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
849 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t1/' $SPECFILE"
851 get_files "$SOURCES $PATCHES";
852 unset TOLDVER TNEWVER TNOTIFY
857 if [ -n "$TARGET" ]; then
858 TARGET_SWITCH="--target $TARGET"
863 BUILD_SWITCH="-ba" ;;
865 BUILD_SWITCH="-bb" ;;
867 BUILD_SWITCH="-bs --nodeps" ;;
869 BUILD_SWITCH="-bp --nodeps" ;;
871 if [ -n "$LOGFILE" ]; then
872 LOG=`eval echo $LOGFILE`
873 if [ -d "$LOG" ]; then
874 echo "Log file $LOG is a directory."
875 echo "Parse error in the spec?"
876 Exit_error err_build_fail;
878 if [ -n "$LASTLOG_FILE" ]; then
879 echo "LASTLOG=$LOG" > $LASTLOG_FILE
881 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
882 (time nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH $TARGET_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
883 RETVAL=`cat $RES_FILE`
885 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
886 if [ "$RETVAL" -eq "0" ]; then
893 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH $TARGET_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $SPECFILE
896 if [ "$RETVAL" -ne "0" ]; then
897 if [ -n "$TRY_UPGRADE" ]; then
898 echo "\n!!! Package with new version cannot be build automagically\n"
899 mv -f $SPECFILE.bak $SPECFILE
901 Exit_error err_build_fail;
909 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
913 install_required_packages()
921 AVAIL_BCONDS_WITHOUT=""
923 if `grep -q ^%bcond ${SPECFILE}`; then
925 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
930 case "${BCOND_VERSION}" in
935 echo "Warning: This spec has old style bconds. Fix it || die."
936 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
938 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
939 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
940 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
942 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
946 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
948 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
949 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
950 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
952 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
957 cond_type="" # with || without
958 for opt in `$RPMBUILD --bcond $SPECFILE`
971 AVAIL_BCOND_WITH="$opt"
972 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
973 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
975 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
980 AVAIL_BCOND_WITHOUT="$opt"
981 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
982 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
984 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
998 echo -ne "Package installation failed:\t$package_name\n"
1000 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1001 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1002 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1003 # jakby nie bylo tego kawalka kodu.
1005 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1006 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1014 # Istnieje taki spec? ${package}.spec
1015 if [ -f "${SPECS_DIR}${package}.spec" ]; then
1016 parent_spec_name=${package}.spec
1017 elif [ -f "${SPECS_DIR}`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1018 parent_spec_name="`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1020 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1026 if [ "${parent_spec_name}" != "" ]; then
1028 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1029 sub_builder_opts="${sub_builder_opts} -R"
1031 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1032 sub_builder_opts="${sub_builder_opts} -RB"
1033 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1034 sub_builder_opts="${sub_builder_opts} -FRB"
1036 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1037 sub_builder_opts="${sub_builder_opts} -Upi"
1040 ./builder ${sub_builder_opts} ${parent_spec_name}
1042 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1045 remove_build_requires()
1047 if [ "$INSTALLED_PACKAGES" != "" ]; then
1048 case "$REMOVE_BUILD_REQUIRES" in
1050 run_poldek --noask -ve $INSTALLED_PACKAGES
1053 run_poldek --ask -ve $INSTALLED_PACKAGES
1056 echo You may want to manually remove following BuildRequires fetched:
1057 echo $INSTALLED_PACKAGES
1058 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1066 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1067 if [ "$BCOND" != "" ]; then
1068 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1071 echo -ne "\nNo conditional flags passed"
1073 echo -ne "\n\nfrom available:\n"
1074 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1078 fetch_build_requires()
1080 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1081 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1082 CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print "@" $3 } ' | xargs)
1083 DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print "@" $3 } ' | xargs)
1084 if [ -n "$CONF" -o -n "$DEPS" ]; then
1085 /usr/bin/poldek --update; /usr/bin/poldek --upa
1087 if [ -n "$CONF" ]; then
1088 echo "Trying to uninstall conflicting packages ($CONF):"
1089 /usr/bin/poldek --noask --nofollow -ev $CONF
1091 if [ -n "$DEPS" ]; then
1092 echo "Trying to install dependencies ($DEPS):"
1093 /usr/bin/poldek --caplookup -uGv $DEPS
1098 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1099 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1100 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1101 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1102 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1103 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,kgcc_package,gcc,g -e s,\),,g`
1105 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`"
1107 package=`basename "$package_item"|sed -e "s/}$//g"`
1108 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1111 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1112 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1113 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
1118 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1121 if `echo $COND_TST|grep -q 'without_'`; then
1122 COND_NAME=`echo $COND_NAME|sed -e s,^.*_without_,,g`
1123 if `echo $COND_TST|grep -q !`; then
1128 if `echo $AVAIL_BCONDS_WITHOUT|grep -q "<$COND_NAME>"`; then
1134 elif `echo $COND_TST|grep -q 'with_'`; then
1135 COND_NAME=`echo $COND_NAME|sed -e s,^.*_with_,,g`
1136 if `echo $COND_TST|grep -q !`; then
1141 if `echo $AVAIL_BCONDS_WITH|grep -q "<$COND_NAME>"`; then
1147 RESULT="${COND_STATE}-${COND_ARGV}"
1149 "with-wout" | "wout-with" )
1152 "wout-wout" | "with-with" )
1156 echo "Action '$RESULT' was not defined for package '$package_item'"
1162 if [ "$GO" = "yes" ]; then
1163 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1164 echo "Testing if $package has subrequirements..."
1165 run_poldek -t -i $package --dumpn=".$package-req.txt"
1166 if [ -f ".$package-req.txt" ]; then
1167 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1169 if [ "$package_name" = "$package" ]; then
1170 echo -ne "Installing BuildRequired package:\t$package_name\n"
1171 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1172 install_required_packages $package;
1174 echo -ne "Installing (sub)Required package:\t$package_name\n"
1175 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1176 install_required_packages $package_name;
1180 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1181 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1184 echo "Attempting to run spawn sub - builder..."
1185 run_sub_builder $package_name
1186 if [ $? -eq 0 ]; then
1187 install_required_packages $package_name;
1190 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1191 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1194 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1201 rm -f ".$package-req.txt"
1203 echo "Attempting to run spawn sub - builder..."
1204 run_sub_builder $package
1205 if [ $? -eq 0 ]; then
1206 install_required_packages $package;
1209 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1210 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1213 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1219 echo "Package $package is already installed. BuildRequirement satisfied."
1223 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1224 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1225 echo "Unable to install following packages and their dependencies:"
1226 for pkg in "$NOT_INSTALLED_PACKAGES"
1230 remove_build_requires
1236 #---------------------------------------------
1239 if [ "$#" = 0 ]; then
1265 DEBUG="yes"; shift ;;
1267 COMMAND="version"; shift ;;
1269 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1270 -b | -ba | --build )
1271 COMMAND="build"; shift ;;
1272 -bb | --build-binary )
1273 COMMAND="build-binary"; shift ;;
1274 -bs | --build-source )
1275 COMMAND="build-source"; shift ;;
1276 -bp | --build-prep )
1277 COMMAND="build-prep"; shift ;;
1279 COMMAND="branch"; shift; TAG="${1}"; shift;;
1281 CLEAN="--clean --rmspec --rmsource"; shift ;;
1283 shift; CVSROOT="${1}"; shift ;;
1285 COMMAND="get"; shift ;;
1287 COMMAND="usage"; shift ;;
1289 PROTOCOL="http"; shift ;;
1291 shift; LOGFILE="${1}"; shift ;;
1293 shift; DEF_NICE_LEVEL=${1}; shift ;;
1295 COMMAND="mr-proper"; shift ;;
1297 NOCVS="yes"; shift ;;
1298 -ncs | --no-cvs-specs )
1299 NOCVSSPEC="yes"; shift ;;
1300 -nd | --no-distfiles )
1301 NODIST="yes"; shift ;;
1302 -nm | --no-mirrors )
1303 NOMIRRORS="yes"; shift ;;
1305 NOURLS="yes"; shift ;;
1307 NOSRCS="yes"; shift ;;
1308 -ns0 | --no-source0 )
1309 NOSOURCE0="yes"; shift ;;
1319 shift; RPMOPTS="${1}"; shift ;;
1320 --with | --without )
1321 case $GROUP_BCONDS in
1325 while ! `echo ${1}|grep -qE '(^-|spec)'`
1327 BCOND="$BCOND $COND $1"
1331 BCOND="$BCOND $1 $2" ; shift 2 ;;
1335 shift; TARGET="${1}"; shift ;;
1337 QUIET="--quiet"; shift ;;
1339 CVSDATE="${2}"; shift 2 ;;
1341 shift; CVSTAG="${1}"; shift ;;
1342 -R | --fetch-build-requires)
1343 FETCH_BUILD_REQUIRES="yes"
1344 NOT_INSTALLED_PACKAGES=
1346 -RB | --remove-build-requires)
1347 REMOVE_BUILD_REQUIRES="nice"
1349 -FRB | --force-remove-build-requires)
1350 REMOVE_BUILD_REQUIRES="force"
1352 -Tvs | --tag-version-stable )
1357 -Tvn | --tag-version-nest )
1362 -Ts | --tag-stable )
1372 -Tv | --tag-version )
1377 -Tp | --tag-prefix )
1389 -ir | --integer-release-only )
1390 INTEGER_RELEASE="yes"
1399 -Upi | --update-poldek-indexes )
1400 UPDATE_POLDEK_INDEXES="yes"
1402 -u | --try-upgrade )
1403 TRY_UPGRADE="1"; shift ;;
1404 -un | --try-upgrade-with-float-version )
1405 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1407 BE_VERBOSE="1"; shift ;;
1413 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1417 RPMOPTS="${RPMOPTS} --nodeps"
1421 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1426 if [ -n "$DEBUG" ]; then
1432 "build" | "build-binary" | "build-source" | "build-prep" )
1434 if [ -n "$SPECFILE" ]; then
1438 fetch_build_requires;
1440 if [ "$INTEGER_RELEASE" = "yes" ]; then
1441 echo "Checking release $PACKAGE_RELEASE..."
1442 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1443 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1447 if [ -n "$TEST_TAG" ]; then
1448 TAGVER=`make_tagver`
1449 echo "Searching for tag $TAGVER..."
1450 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1451 if [ -n "$TAGREL" ]; then
1452 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1456 if [ -n "$ICONS" ]; then
1460 if [ -n "$NOSOURCE0" ] ; then
1461 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1463 get_files "$SOURCES $PATCHES";
1465 if [ "$UPDATE_POLDEK_INDEXES" = "yes" ]; then
1466 run_poldek --sn ${POLDEK_SOURCE} --mkidx="${POLDEK_INDEX_DIR}/packages.dir.gz"
1467 run_poldek --sn ${POLDEK_SOURCE} --up
1469 remove_build_requires;
1471 Exit_error err_no_spec_in_cmdl;
1476 if [ -n "$SPECFILE" ]; then
1479 if [ -n "$ICONS" ]; then
1483 get_files $SOURCES $PATCHES;
1484 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1486 Exit_error err_no_spec_in_cmdl;
1491 if [ -n "$SPECFILE" ]; then
1494 if [ -n "$ICONS" ]; then
1498 if [ -n "$NOSOURCE0" ] ; then
1499 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1501 get_files $SOURCES $PATCHES
1503 Exit_error err_no_spec_in_cmdl;
1510 if [ -n "$SPECFILE" ]; then
1513 if [ -n "$ICONS" ]; then
1517 # don't fetch sources from remote locations
1519 for file in $SOURCES
1521 [ -n "`src_md5 $file`" ] && continue
1522 new_SOURCES="$new_SOURCES $file"
1524 SOURCES="$new_SOURCES"
1525 get_files $SOURCES $PATCHES;
1526 tag_files "$SOURCES $PATCHES $ICONS";
1528 Exit_error err_no_spec_in_cmdl;
1532 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1539 test -f `pwd`/.${SPECFILE}_INSTALLED_PACKAGES && rm `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1542 # vi:syntax=sh:ts=3:sw=4