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"
45 ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"}
48 # It can be used i.e. in log file naming.
49 # See LOGFILE example.
50 DATE=`date +%Y-%m-%d_%H-%M-%S`
52 # Example: LOGFILE='../log.$PACKAGE_NAME'
53 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
54 # 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 if [ -x /usr/bin/rpm-getdeps ]; then
91 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
93 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
96 # Here we load saved user environment used to
97 # predefine options set above, or passed to builder
99 # This one reads global system environment settings:
100 if [ -f ~/etc/builderrc ]; then
103 # And this one cascades settings using user personal
105 # Example of ~/.builderrc:
107 #UPDATE_POLDEK_INDEXES="yes"
108 #FETCH_BUILD_REQUIRES="yes"
109 #REMOVE_BUILD_REQUIRES="force"
111 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
114 if [ -n "$HOME_ETC" ]; then
115 USER_CFG="$HOME_ETC/.builderrc"
117 USER_CFG=~/.builderrc
120 [ -f "$USER_CFG" ] && . "$USER_CFG"
122 wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
124 if [ -n "$USE_PROZILLA" ]; then
125 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
128 elif [ -n "$USE_AXEL" ]; then
129 GETURI="axel -a $AXEL_OPTS"
133 wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet"
134 wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
136 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
137 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
143 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
151 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
152 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
156 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
157 if [ -n "$LOGFILE" ]; then
158 LOG=`eval echo $LOGFILE`
159 if [ -n "$LASTLOG_FILE" ]; then
160 echo "LASTLOG=$LOG" > $LASTLOG_FILE
162 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
165 (nice -n ${DEF_NICE_LEVEL} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
166 return `cat ${RES_FILE}`
171 #---------------------------------------------
176 if [ -n "$DEBUG" ]; then set -xv; fi
178 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
180 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
181 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
182 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
183 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
184 [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest]
185 [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version]
186 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
187 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
188 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec]
190 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
191 --adapter[ize] - run adapter.awk on SPECFILE
192 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
193 -n5, --no-md5 - ignore md5 comments in spec
194 -D, --debug - enable builder script debugging mode,
195 -debug - produce rpm debug package (same as --opts -debug)
196 -V, --version - output builder version
197 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
198 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
200 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
201 only package from <package>.spec,
202 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
204 -bp, --build-prep - execute the %prep phase of <package>.spec,
205 -B, --branch - add branch
206 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
207 SPECS and \$RPM_BUILD_ROOT),
208 -d <cvsroot>, --cvsroot <cvsroot>
210 --define <macro> <value>
211 - define a macro <macro> with value <value>,
212 --nodeps - rpm won't check any dependences
213 -g, --get - get <package>.spec and all related files from CVS repo
215 -h, --help - this message,
216 --http - use http instead of ftp,
217 -l <logfile>, --logtofile <logfile>
219 -m, --mr-proper - only remove all files related to spec file and all work
221 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
223 - don't check specs in CVS
224 -nd, --no-distfiles - don't download from distfiles
225 -nm, --no-mirrors - don't download from mirror, if source URL is given,
226 -nu, --no-urls - don't try to download from FTP/HTTP location,
227 -ns, --no-srcs - don't download Sources
228 -ns0, --no-source0 - don't download Source0
229 -nn, --no-net - don't download anything from the net
230 --opts <rpm opts> - additional options for rpm
231 -q, --quiet - be quiet,
232 --date yyyy-mm-dd - build package using resources from specified CVS date,
233 -r <cvstag>, --cvstag <cvstag>
234 - build package using resources from specified CVS tag,
235 -R, --fetch-build-requires
236 - fetch what is BuildRequired,
237 -RB, --remove-build-requires
238 - remove all you fetched with -R or --fetch-build-requires
239 remember, this option requires confirmation,
240 -FRB, --force-remove-build-requires
241 - remove all you fetched with -R or --fetch-build-requires
242 remember, this option works without confirmation,
243 -sf, --source-files - list sources - bare filenames (intended for offline
244 operations; does not work when Icon field is present
245 but icon file is absent),
246 -sp, --source-paths - list sources - filenames with full local paths (intended for
247 offline operations; does not work when Icon field is present
248 but icon file is absent),
249 -T <cvstag> , --tag <cvstag>
250 - add cvs tag <cvstag> for files,
251 -Tvs, --tag-version-stable
252 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
253 -Tvn, --tag-version-nest
254 - add cvs tags NEST and NAME-VERSION-RELEASE for files,
256 - add cvs tag STABLE for files,
258 - add cvs tag NEST for files,
260 - add cvs tag NAME-VERSION-RELEASE for files,
261 -Tp, --tag-prefix <prefix>
262 - add <prefix> to NAME-VERSION-RELEASE tags,
263 -tt, --test-tag <prefix>
264 - fail if tag is already present,
265 -ir, --integer-release-only
266 - allow only integer and snapshot releases
267 -v, --verbose - be verbose,
268 -u, --try-upgrade - check version, and try to upgrade package
269 -un, --try-upgrade-with-float-version
270 - as above, but allow float version
271 -U, --update - refetch sources, don't use distfiles, and update md5 comments
272 -Upi, --update-poldek-indexes
273 - refresh or make poldek package index files.
274 -np, --nopatch <patchnumber>
275 - don't apply <patchnumber>
276 --show-bconds - show available conditional builds, which can be used
277 - with --with and/or --without switches.
278 --with/--without <feature>
279 - conditional build package depending on %_with_<feature>/
280 %_without_<feature> macro switch. You may now use
281 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
282 constructions. Set GROUP_BCONDS to yes to make use of it.
283 --target <platform>, --target=<platform>
284 - build for platform <platform>.
288 update_shell_title() {
289 local msg="builder[$SPECFILE] $*"
292 echo -ne "\033]1;$msg\007\033]2;$msg\007"
295 echo -ne "\033]0;$msg\007"
300 # set TARGET from BuildArch: from SPECFILE
302 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
303 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
308 TARGET_SWITCH="--target $TARGET" ;;
310 TARGET_SWITCH="--target=$TARGET" ;;
317 if [ -n "$DEBUG" ]; then
325 rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
328 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
334 if [ -z "$rpm_dump_cache" ] ; then
335 echo "internal error: cache_rpm_dump not called!" 1>&2
337 echo "$rpm_dump_cache"
342 update_shell_title "parse_spec"
343 if [ -n "$DEBUG" ]; then
352 if [ "$NOSRCS" != "yes" ]; then
353 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
355 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
356 FAIL_IF_NO_SOURCES="no"
359 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
360 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
361 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
362 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
363 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
365 # These variables may be unset after first cache_rpm_dump call
366 # (because of not-yet-retrieved icon file)
368 # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
369 # Exit_error err_no_package_data;
372 if [ -n "$BE_VERBOSE" ]; then
373 echo "- Sources : `nourl $SOURCES`"
374 if [ -n "$PATCHES" ]; then
375 echo "- Patches : `nourl $PATCHES`"
377 echo "- Patches : *no patches needed*"
379 if [ -n "$ICONS" ]; then
380 echo "- Icon : `nourl $ICONS`"
382 echo "- Icon : *no package icon*"
384 echo "- Name : $PACKAGE_NAME"
385 echo "- Version : $PACKAGE_VERSION"
386 echo "- Release : $PACKAGE_RELEASE"
392 if [ -n "$DEBUG" ]; then
400 "err_no_spec_in_cmdl" )
401 remove_build_requires
402 echo "ERROR: spec file name not specified.";
404 "err_no_spec_in_repo" )
405 remove_build_requires
406 echo "Error: spec file not stored in CVS repo.";
408 "err_no_source_in_repo" )
409 remove_build_requires
410 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
413 remove_build_requires
414 echo "Error: package build failed. (${2:-no more info})";
416 "err_no_package_data" )
417 remove_build_requires
418 echo "Error: couldn't get out package name/version/release from spec file."
421 remove_build_requires
422 echo "Tag ${2} already exists (spec release: ${3}).";
425 remove_build_requires
426 echo "Release ${2} not integer and not a snapshot.";
428 "err_branch_exists" )
429 remove_build_requires
430 echo "Tree branch already exists (${2}).";
434 echo "Unknown error."
440 if [ -n "$DEBUG" ]; then
445 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
446 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
454 update_shell_title "get_spec"
456 if [ -n "$DEBUG" ]; then
462 if [ \! -f "$SPECFILE" ]; then
463 SPECFILE="`basename $SPECFILE .spec`.spec";
465 if [ "$NOCVSSPEC" != "yes" ]; then
468 if [ -n "$CVSROOT" ]; then
469 OPTIONS="-d $CVSROOT $OPTIONS"
471 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
472 echo "warning: No cvs access defined - using local .spec file"
477 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
478 OPTIONS="$OPTIONS -A"
480 if [ -n "$CVSDATE" ]; then
481 OPTIONS="$OPTIONS -D $CVSDATE"
483 if [ -n "$CVSTAG" ]; then
484 OPTIONS="$OPTIONS -r $CVSTAG"
490 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
492 retries_counter=$(( $retries_counter + 1 ))
493 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
495 [ -n "$output" ] && echo "$output"
496 if [ "$result" -ne "0" ]; then
497 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
498 echo "Trying again [$SPECFILE]... ($retries_counter)"
502 Exit_error err_no_spec_in_repo;
506 if [ ! -f "$SPECFILE" ]; then
507 Exit_error err_no_spec_in_repo;
510 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
511 chmod $CHMOD_MODE $SPECFILE
514 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
523 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
524 cvs update mirrors >&2
528 while read origin mirror name rest
530 ol=`echo -n "$origin"|wc -c`
531 prefix="`echo -n "$url" | head -c $ol`"
532 if [ "$prefix" = "$origin" ] ; then
533 suffix="`echo "$url"|cut -b $ol-`"
534 echo -n "$mirror$suffix"
545 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
546 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
552 [ X"$NO5" = X"yes" ] && return
554 [ -z "$no" ] && return
556 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
557 if [ -z "$spec_rev" ]; then
558 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
560 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
561 md5=$(grep -s -v '^#' additional-md5sums | \
562 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
563 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
564 grep -E '^[0-9a-f]{32}$')
565 if [ X"$md5" = X"" ] ; then
566 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
567 if [ ! -z "$source_md5" ] ; then
570 # we have empty SourceX-md5, but it is still possible
571 # that we have NoSourceX-md5 AND NoSource: X
572 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
573 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
578 if [ $(echo "$md5" | wc -l) != 1 ] ; then
579 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
581 echo "$md5" | tail -n 1
587 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
590 distfiles_attic_url ()
592 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
599 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
604 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
605 [ -n "$size" -a "$size" -gt 0 ]
610 if [ "$CVSIGNORE_DF" != "yes" ]; then
613 cvsignore=${SOURCE_DIR}/.cvsignore
614 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
615 echo "$1" >> $cvsignore
622 update_shell_title "get_files"
624 if [ -n "$DEBUG" ]; then
629 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
633 if [ -n "$CVSROOT" ]; then
634 OPTIONS="-d $CVSROOT $OPTIONS"
636 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
637 echo "warning: No cvs access defined for SOURCES"
641 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
642 OPTIONS="$OPTIONS -A"
644 if [ -n "$CVSDATE" ]; then
645 OPTIONS="$OPTIONS -D $CVSDATE"
647 if [ -n "$CVSTAG" ]; then
648 OPTIONS="$OPTIONS -r $CVSTAG"
653 if [ -n "$UPDATE5" ]; then
654 if [ -n "$ADD5" ]; then
655 [ `nourl $i` = "$i" ] && continue
656 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
658 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
662 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
663 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
664 echo "Warning: no URL given for $i"
667 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
668 if good_md5 "$i" && good_size "$i"; then
669 echo "$(nourl "$i") having proper md5sum already exists"
673 url=$(distfiles_url "$i")
674 url_attic=$(distfiles_attic_url "$i")
676 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
677 update_shell_title "get_files: $url"
678 ${GETLOCAL} $url $target
680 if [ -z "$NOMIRRORS" ]; then
681 url="`find_mirror "$url"`"
683 update_shell_title "get_files: $url"
684 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
685 if [ "`echo $url | grep -E 'ftp://'`" ]; then
686 update_shell_title "get_files: $url"
687 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
690 if ! test -s "$target"; then
692 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
693 update_shell_title "get_files: $url_attic"
694 ${GETLOCAL} $url_attic $target
696 if [ -z "$NOMIRRORS" ]; then
697 url_attic="`find_mirror "$url_attic"`"
699 update_shell_title "get_files: $url_attic"
700 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
701 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
702 update_shell_title "get_files: $url_attic"
703 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
707 if test -s "$target"; then
713 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
714 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
717 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
719 retries_counter=$(( $retries_counter + 1 ))
720 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
722 [ -n "$output" ] && echo "$output"
723 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
724 echo "Trying again [`nourl $i`]... ($retries_counter)"
733 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
734 if [ -z "$NOMIRRORS" ]; then
735 im="`find_mirror "$i"`"
739 update_shell_title "get_files: $im"
741 if [ "`echo $im | grep -E 'ftp://'`" ]; then
742 update_shell_title "get_files: $im"
749 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
750 Exit_error err_no_source_in_repo $i;
751 elif [ -n "$UPDATE5" ] && \
752 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
753 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
754 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
756 echo "Updating source-$srcno md5."
757 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
759 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
760 print "# Source'$srcno'-md5:\t'$md5'\n"
761 if /^Source'$srcno'\s*:\s+/;
766 if good_md5 "$i" && good_size "$i"; then
768 elif [ "$FROM_DISTFILES" = 1 ]; then
769 # wrong md5 from distfiles: remove the file and try again
771 echo "MD5 sum mismatch. Trying full fetch."
774 update_shell_title "get_files: $url"
775 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
776 if [ "`echo $url | grep -E 'ftp://'`" ]; then
777 update_shell_title "get_files: $url"
778 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
780 if ! test -s "$target"; then
782 update_shell_title "get_files: $url_attic"
783 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
784 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
785 update_shell_title "get_files: $url_attic"
786 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
789 test -s "$target" || rm -f "$target"
792 if good_md5 "$i" && good_size "$i" ; then
795 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
796 echo "or -5 to update md5 sums, if you're sure files are correct."
797 Exit_error err_no_source_in_repo $i
801 if [ "$CHMOD" = "yes" ]; then
802 CHMOD_FILES="`nourl $GET_FILES`"
803 if [ -n "$CHMOD_FILES" ]; then
804 chmod $CHMOD_MODE $CHMOD_FILES
813 if [ -n "$DEBUG" ]; then
818 # Check whether first character of PACKAGE_NAME is legal for tag name
819 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
822 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"`
823 # Remove #kernel.version_release from TAGVER because tagging sources
824 # could occur with different kernel-headers than kernel-headers used at build time.
825 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
833 if [ -n "$DEBUG" ]; then
838 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
839 echo "Version: $PACKAGE_VERSION"
840 echo "Release: $PACKAGE_RELEASE"
844 if [ "$TAG_VERSION" = "yes" ]; then
845 echo "CVS tag: $TAGVER"
847 if [ -n "$TAG" ]; then
852 if [ -n "$CVSROOT" ]; then
853 OPTIONS="-d $CVSROOT $OPTIONS"
859 # don't tag files stored on distfiles
860 [ -n "`src_md5 $i`" ] && continue
861 if [ -f "`nourl $i`" ]; then
862 if [ "$TAG_VERSION" = "yes" ]; then
863 cvs $OPTIONS $TAGVER `nourl $i`
865 if [ -n "$TAG" ]; then
866 cvs $OPTIONS $TAG `nourl $i`
869 Exit_error err_no_source_in_repo $i
874 if [ "$TAG_VERSION" = "yes" ]; then
875 cvs $OPTIONS $TAGVER $SPECFILE
877 if [ -n "$TAG" ]; then
878 cvs $OPTIONS $TAG $SPECFILE
888 echo "CVS branch tag: $TAG"
893 if [ -n "$DEBUG" ]; then
898 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
901 if [ -n "$CVSROOT" ]; then
902 OPTIONS="-d $CVSROOT $OPTIONS"
907 if [ -f `nourl $i` ]; then
908 cvs $OPTIONS $TAG `nourl $i`
910 Exit_error err_no_source_in_repo $i
914 cvs $OPTIONS $TAG $SPECFILE
924 update_shell_title "build_package"
925 if [ -n "$DEBUG" ]; then
932 if [ -n "$TRY_UPGRADE" ]; then
933 update_shell_title "build_package: try_upgrade"
934 if [ -n "$FLOAT_VERSION" ]; then
935 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
937 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
940 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
942 if [ -n "$TNEWVER" ]; then
943 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
944 echo "New version found, updating spec file to version " $TNEWVER
945 cp -f $SPECFILE $SPECFILE.bak
947 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
948 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
950 if [ -n "$ICONS" ]; then
954 NODIST="yes" UPDATE5="yes" get_files "$SOURCES $PATCHES";
955 unset TOLDVER TNEWVER TNOTIFY
962 BUILD_SWITCH="-ba" ;;
964 BUILD_SWITCH="-bb" ;;
966 BUILD_SWITCH="-bs --nodeps" ;;
968 BUILD_SWITCH="-bp --nodeps" ;;
971 update_shell_title "build_package: $COMMAND"
972 if [ -n "$LOGFILE" ]; then
973 LOG=`eval echo $LOGFILE`
974 if [ -d "$LOG" ]; then
975 echo "Log file $LOG is a directory."
976 echo "Parse error in the spec?"
977 Exit_error err_build_fail;
979 if [ -n "$LASTLOG_FILE" ]; then
980 echo "LASTLOG=$LOG" > $LASTLOG_FILE
982 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
983 (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
984 RETVAL=`cat $RES_FILE`
986 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
987 if [ "$RETVAL" -eq "0" ]; then
994 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
997 if [ "$RETVAL" -ne "0" ]; then
998 if [ -n "$TRY_UPGRADE" ]; then
999 echo "\n!!! Package with new version cannot be build automagically\n"
1000 mv -f $SPECFILE.bak $SPECFILE
1002 Exit_error err_build_fail;
1009 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1012 install_required_packages()
1020 update_shell_title "set_bconds_values"
1022 AVAIL_BCONDS_WITHOUT=""
1023 AVAIL_BCONDS_WITH=""
1024 if `grep -q ^%bcond ${SPECFILE}`; then
1026 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1029 BCOND_VERSION="NONE"
1032 # expand bconds from ~/.bcondrc
1033 # The file structure is like gentoo's package.use:
1036 # samba -mysql -pgsql
1037 # w32codec-installer license_agreement
1040 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
1041 # This takes package name, first defined in spec.
1042 # so consider that when defining flags for package.
1043 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
1044 SN=${SPECFILE%%\.spec}
1045 AVAIL=`$RPMBUILD --bcond $SPECFILE`
1047 BCONDRC=$HOME/.bcondrc
1048 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
1050 while read pkg flags; do
1052 [[ "$pkg" == \#* ]] && continue
1054 # any package or current package?
1055 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ] || [ "$pkg" = "$SN" ]; then
1056 for flag in $flags; do
1059 # use only flags which are in this package.
1060 if [[ $AVAIL = *${opt}* ]]; then
1061 if [[ $flag = -* ]]; then
1062 BCOND="$BCOND --without $opt"
1064 BCOND="$BCOND --with $opt"
1072 case "${BCOND_VERSION}" in
1077 echo "Warning: This spec has old style bconds. Fix it || die."
1078 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1080 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1081 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1082 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1084 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1088 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1090 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1091 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1092 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1094 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1099 cond_type="" # with || without
1100 for opt in `$RPMBUILD --bcond $SPECFILE`
1110 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1111 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1112 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1114 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1118 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1119 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1120 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1122 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1126 case "$cond_type" in
1129 AVAIL_BCOND_WITH="$opt"
1130 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1131 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1133 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1138 AVAIL_BCOND_WITHOUT="$opt"
1139 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1140 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1142 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1156 echo -ne "Package installation failed:\t$package_name\n"
1158 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1159 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1160 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1161 # jakby nie bylo tego kawalka kodu.
1163 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1164 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1171 # Istnieje taki spec? ${package}.spec
1172 if [ -f "${SPECS_DIR}${package}.spec" ]; then
1173 parent_spec_name=${package}.spec
1174 elif [ -f "${SPECS_DIR}`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1175 parent_spec_name="`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1177 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1183 if [ "${parent_spec_name}" != "" ]; then
1185 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1186 sub_builder_opts="${sub_builder_opts} -R"
1188 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1189 sub_builder_opts="${sub_builder_opts} -RB"
1190 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1191 sub_builder_opts="${sub_builder_opts} -FRB"
1193 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1194 sub_builder_opts="${sub_builder_opts} -Upi"
1197 ./builder ${sub_builder_opts} ${parent_spec_name}
1199 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1202 remove_build_requires()
1204 if [ "$INSTALLED_PACKAGES" != "" ]; then
1205 case "$REMOVE_BUILD_REQUIRES" in
1207 run_poldek --noask -ve $INSTALLED_PACKAGES
1210 run_poldek --ask -ve $INSTALLED_PACKAGES
1213 echo You may want to manually remove following BuildRequires fetched:
1214 echo $INSTALLED_PACKAGES
1215 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1223 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1224 if [ "$BCOND" != "" ]; then
1225 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1228 echo -ne "\nNo conditional flags passed"
1230 echo -ne "\n\nfrom available:\n"
1231 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1237 if [ "$NOCVSSPEC" != "yes" ]; then
1238 echo -ne "Available branches: "
1239 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1243 # checks a given list of packages/files/provides agains current rpmdb.
1244 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1245 # input can be either STDIN or parameters
1250 if [ "$#" -gt 0 ]; then
1256 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1259 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1261 # other deps (files)
1262 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1265 # checks if given package/files/provides exists in rpmdb.
1266 # inout can be either stdin or parameters
1267 # returns packages wchi hare present in the rpmdb
1272 if [ "$#" -gt 0 ]; then
1278 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1281 fetch_build_requires()
1283 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1284 update_shell_title "fetch_build_requires"
1285 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1286 CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1287 DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1289 update_shell_title "fetch_build_requires: update indexes"
1290 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1291 $SU_SUDO /usr/bin/poldek --update || $SU_SUDO /usr/bin/poldek --upa
1293 if [ -n "$CONF" ]; then
1294 update_shell_title "fetch_build_requires: uninstall conflicting packages"
1295 echo "Trying to uninstall conflicting packages ($CONF):"
1296 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1298 if [ -n "$DEPS" ]; then
1299 update_shell_title "fetch_build_requires: install deps ($DEPS)"
1300 echo "Trying to install dependencies ($DEPS):"
1301 $SU_SUDO /usr/bin/poldek --caplookup -uGv $DEPS
1306 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1307 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1308 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1309 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1310 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1311 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`
1313 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`"
1315 package=`basename "$package_item"|sed -e "s/}$//g"`
1316 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1319 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1320 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1321 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
1326 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1329 if `echo $COND_TST|grep -q 'without_'`; then
1330 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1331 if `echo $COND_TST|grep -q !`; then
1336 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1337 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1338 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1344 elif `echo $COND_TST|grep -q 'with_'`; then
1345 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1346 if `echo $COND_TST|grep -q !`; then
1351 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1352 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1353 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1359 RESULT="${COND_STATE}-${COND_ARGV}"
1361 "with-wout" | "wout-with" )
1364 "wout-wout" | "with-with" )
1368 echo "Action '$RESULT' was not defined for package '$package_item'"
1374 if [ "$GO" = "yes" ]; then
1375 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1376 echo "Testing if $package has subrequirements..."
1377 run_poldek -t -i $package --dumpn=".$package-req.txt"
1378 if [ -f ".$package-req.txt" ]; then
1379 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1381 if [ "$package_name" = "$package" ]; then
1382 echo -ne "Installing BuildRequired package:\t$package_name\n"
1383 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1384 install_required_packages $package;
1386 echo -ne "Installing (sub)Required package:\t$package_name\n"
1387 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1388 install_required_packages $package_name;
1392 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1393 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1396 echo "Attempting to run spawn sub - builder..."
1397 run_sub_builder $package_name
1398 if [ $? -eq 0 ]; then
1399 install_required_packages $package_name;
1402 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1403 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1406 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1413 rm -f ".$package-req.txt"
1415 echo "Attempting to run spawn sub - builder..."
1416 run_sub_builder $package
1417 if [ $? -eq 0 ]; then
1418 install_required_packages $package;
1421 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1422 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1425 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1431 echo "Package $package is already installed. BuildRequirement satisfied."
1435 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1436 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1437 echo "Unable to install following packages and their dependencies:"
1438 for pkg in "$NOT_INSTALLED_PACKAGES"
1442 remove_build_requires
1450 # vim like diff colourization, glen@pld-linux.org
1452 s,
\e,
\e[44m^[
\e[49m,g;
1453 s,
\a,
\e[44m^G
\e[49m,g;
1454 s,^\(Index:\|diff\|---\|+++\) .*$,
\e[32m&,;
1458 s,
\r,
\e[44m^M
\e[49m,g;
1460 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1
\e[41m\2
\e[49m,g;
1469 tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/adapter-XXXXXX) || exit
1470 awk -f adapter.awk $SPECFILE > $tmpdir/$SPECFILE || exit
1472 if [ "`diff --brief $SPECFILE $tmpdir/$SPECFILE`" ] ; then
1473 diff -u $SPECFILE $tmpdir/$SPECFILE > $tmpdir/$SPECFILE.diff
1475 diffcol $tmpdir/$SPECFILE.diff | less -r
1477 echo -n "Accept? [yn] "
1481 mv -f $tmpdir/$SPECFILE $SPECFILE
1482 echo "Ok, adapterized."
1492 cat $tmpdir/$SPECFILE.diff
1495 echo "The SPEC is perfect ;)"
1501 #---------------------------------------------
1504 if [ "$#" = 0 ]; then
1518 --adapter | --adapterize )
1519 COMMAND="adapterize";
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 ;;
1566 COMMAND="mr-proper"; shift ;;
1568 NOCVS="yes"; shift ;;
1569 -ncs | --no-cvs-specs )
1570 NOCVSSPEC="yes"; shift ;;
1571 -nd | --no-distfiles )
1572 NODIST="yes"; shift ;;
1573 -nm | --no-mirrors )
1574 NOMIRRORS="yes"; shift ;;
1576 NOURLS="yes"; shift ;;
1578 NOSRCS="yes"; shift ;;
1579 -ns0 | --no-source0 )
1580 NOSOURCE0="yes"; shift ;;
1590 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1592 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} echo ignoring patch${1} \""; shift ;;
1593 --with | --without )
1594 case $GROUP_BCONDS in
1598 while ! `echo ${1}|grep -qE '(^-|spec)'`
1600 BCOND="$BCOND $COND $1"
1604 if [[ "$2" = *,* ]]; then
1605 for a in $(echo "$2" | tr , ' '); do
1606 BCOND="$BCOND $1 $a"
1609 BCOND="$BCOND $1 $2"
1615 shift; TARGET="${1}"; shift ;;
1617 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1619 QUIET="--quiet"; shift ;;
1621 CVSDATE="${2}"; shift 2 ;;
1623 shift; CVSTAG="${1}"; shift ;;
1624 -R | --fetch-build-requires)
1625 FETCH_BUILD_REQUIRES="yes"
1626 NOT_INSTALLED_PACKAGES=
1628 -RB | --remove-build-requires)
1629 REMOVE_BUILD_REQUIRES="nice"
1631 -FRB | --force-remove-build-requires)
1632 REMOVE_BUILD_REQUIRES="force"
1634 -sf | --sources-files)
1635 COMMAND="list-sources-files"
1637 -sp | --sources-paths)
1638 COMMAND="list-sources-local-paths"
1640 -Tvs | --tag-version-stable )
1645 -Tvn | --tag-version-nest )
1650 -Ts | --tag-stable )
1660 -Tv | --tag-version )
1665 -Tp | --tag-prefix )
1677 -ir | --integer-release-only )
1678 INTEGER_RELEASE="yes"
1687 -Upi | --update-poldek-indexes )
1688 UPDATE_POLDEK_INDEXES="yes"
1690 -u | --try-upgrade )
1691 TRY_UPGRADE="1"; shift ;;
1692 -un | --try-upgrade-with-float-version )
1693 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1695 BE_VERBOSE="1"; shift ;;
1701 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1703 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1709 RPMOPTS="${RPMOPTS} --nodeps"
1712 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1715 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1720 if [ -n "$DEBUG" ]; then
1725 if [ -n "$TARGET" ]; then
1728 TARGET_SWITCH="--target $TARGET" ;;
1730 TARGET_SWITCH="--target=$TARGET" ;;
1734 update_shell_title "$COMMAND"
1736 "build" | "build-binary" | "build-source" | "build-prep" )
1738 if [ -n "$SPECFILE" ]; then
1743 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1744 fetch_build_requires;
1746 if [ "$INTEGER_RELEASE" = "yes" ]; then
1747 echo "Checking release $PACKAGE_RELEASE..."
1748 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1749 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1753 if [ -n "$TEST_TAG" ]; then
1754 TAGVER=`make_tagver`
1755 echo "Searching for tag $TAGVER..."
1756 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1757 if [ -n "$TAGREL" ]; then
1758 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1761 # - do not allow to build from HEAD when XX-branch exists
1762 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1763 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1764 TAG_BRANCH="${TREE_PREFIX}-branch"
1765 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1766 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1767 Exit_error err_branch_exists "$TAG_STATUS"
1773 if [ -n "$ICONS" ]; then
1777 if [ -n "$NOSOURCE0" ] ; then
1778 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1780 get_files "$SOURCES $PATCHES";
1782 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1783 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1785 remove_build_requires;
1787 Exit_error err_no_spec_in_cmdl;
1792 if [ -n "$SPECFILE" ]; then
1795 if [ -n "$ICONS" ]; then
1799 get_files $SOURCES $PATCHES;
1800 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1802 Exit_error err_no_spec_in_cmdl;
1807 if [ -n "$SPECFILE" ]; then
1810 if [ -n "$ICONS" ]; then
1811 OLD_UPDATE5=$UPDATE5
1812 UPDATE5= get_files $ICONS
1813 UPDATE5=$OLD_UPDATE5
1816 if [ -n "$NOSOURCE0" ] ; then
1817 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1819 get_files $SOURCES $PATCHES
1821 Exit_error err_no_spec_in_cmdl;
1828 if [ -n "$SPECFILE" ]; then
1831 if [ -n "$ICONS" ]; then
1835 # don't fetch sources from remote locations
1837 for file in $SOURCES
1839 [ -n "`src_md5 $file`" ] && continue
1840 new_SOURCES="$new_SOURCES $file"
1842 SOURCES="$new_SOURCES"
1843 get_files $SOURCES $PATCHES;
1844 tag_files "$SOURCES $PATCHES $ICONS";
1846 Exit_error err_no_spec_in_cmdl;
1850 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1852 "list-sources-files" )
1855 DONT_PRINT_REVISION="yes"
1858 SAPS="$SOURCES $PATCHES"
1859 for SAP in $SAPS ; do
1860 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1863 "list-sources-local-paths" )
1866 DONT_PRINT_REVISION="yes"
1869 SAPS="$SOURCES $PATCHES"
1870 for SAP in $SAPS ; do
1871 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1882 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1883 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1887 # vi:syntax=sh:ts=3:sw=4