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() {
290 local msg="builder[$SPECFILE] $*"
293 echo -ne "\033]1;$msg\007\033]2;$msg\007"
296 echo -ne "\033]0;$msg\007"
301 # set TARGET from BuildArch: from SPECFILE
303 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
304 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
309 TARGET_SWITCH="--target $TARGET" ;;
311 TARGET_SWITCH="--target=$TARGET" ;;
318 if [ -n "$DEBUG" ]; then
326 rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
329 rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1
335 if [ -z "$rpm_dump_cache" ] ; then
336 echo "internal error: cache_rpm_dump not called!" 1>&2
338 echo "$rpm_dump_cache"
343 update_shell_title "parse_spec"
344 if [ -n "$DEBUG" ]; then
353 if [ "$NOSRCS" != "yes" ]; then
354 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
356 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
357 FAIL_IF_NO_SOURCES="no"
360 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
361 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
362 PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
363 PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`"
364 PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`"
366 # These variables may be unset after first cache_rpm_dump call
367 # (because of not-yet-retrieved icon file)
369 # if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then
370 # Exit_error err_no_package_data;
373 if [ -n "$BE_VERBOSE" ]; then
374 echo "- Sources : `nourl $SOURCES`"
375 if [ -n "$PATCHES" ]; then
376 echo "- Patches : `nourl $PATCHES`"
378 echo "- Patches : *no patches needed*"
380 if [ -n "$ICONS" ]; then
381 echo "- Icon : `nourl $ICONS`"
383 echo "- Icon : *no package icon*"
385 echo "- Name : $PACKAGE_NAME"
386 echo "- Version : $PACKAGE_VERSION"
387 echo "- Release : $PACKAGE_RELEASE"
393 if [ -n "$DEBUG" ]; then
401 "err_no_spec_in_cmdl" )
402 remove_build_requires
403 echo "ERROR: spec file name not specified.";
405 "err_no_spec_in_repo" )
406 remove_build_requires
407 echo "Error: spec file not stored in CVS repo.";
409 "err_no_source_in_repo" )
410 remove_build_requires
411 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
414 remove_build_requires
415 echo "Error: package build failed. (${2:-no more info})";
417 "err_no_package_data" )
418 remove_build_requires
419 echo "Error: couldn't get out package name/version/release from spec file."
422 remove_build_requires
423 echo "Tag ${2} already exists (spec release: ${3}).";
426 remove_build_requires
427 echo "Release ${2} not integer and not a snapshot.";
429 "err_branch_exists" )
430 remove_build_requires
431 echo "Tree branch already exists (${2}).";
435 echo "Unknown error."
441 if [ -n "$DEBUG" ]; then
446 SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`"
447 SPECS_DIR="`$RPM --eval '%{_specdir}'`"
455 update_shell_title "get_spec"
457 if [ -n "$DEBUG" ]; then
463 if [ \! -f "$SPECFILE" ]; then
464 SPECFILE="`basename $SPECFILE .spec`.spec";
466 if [ "$NOCVSSPEC" != "yes" ]; then
469 if [ -n "$CVSROOT" ]; then
470 OPTIONS="-d $CVSROOT $OPTIONS"
472 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
473 echo "warning: No cvs access defined - using local .spec file"
478 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
479 OPTIONS="$OPTIONS -A"
481 if [ -n "$CVSDATE" ]; then
482 OPTIONS="$OPTIONS -D $CVSDATE"
484 if [ -n "$CVSTAG" ]; then
485 OPTIONS="$OPTIONS -r $CVSTAG"
491 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
493 retries_counter=$(( $retries_counter + 1 ))
494 output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1)
496 [ -n "$output" ] && echo "$output"
497 if [ "$result" -ne "0" ]; then
498 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
499 echo "Trying again [$SPECFILE]... ($retries_counter)"
503 Exit_error err_no_spec_in_repo;
507 if [ ! -f "$SPECFILE" ]; then
508 Exit_error err_no_spec_in_repo;
511 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
512 chmod $CHMOD_MODE $SPECFILE
515 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
524 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
525 cvs update mirrors >&2
529 while read origin mirror name rest
531 ol=`echo -n "$origin"|wc -c`
532 prefix="`echo -n "$url" | head -c $ol`"
533 if [ "$prefix" = "$origin" ] ; then
534 suffix="`echo "$url"|cut -b $ol-`"
535 echo -n "$mirror$suffix"
546 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
547 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
553 [ X"$NO5" = X"yes" ] && return
555 [ -z "$no" ] && return
557 spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
558 if [ -z "$spec_rev" ]; then
559 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
561 spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
562 md5=$(grep -s -v '^#' additional-md5sums | \
563 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
564 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
565 grep -E '^[0-9a-f]{32}$')
566 if [ X"$md5" = X"" ] ; then
567 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
568 if [ ! -z "$source_md5" ] ; then
571 # we have empty SourceX-md5, but it is still possible
572 # that we have NoSourceX-md5 AND NoSource: X
573 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
574 if [ ! -z "$nosource_md5" -a ! X"`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" = X"" ] ; then
579 if [ $(echo "$md5" | wc -l) != 1 ] ; then
580 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
582 echo "$md5" | tail -n 1
588 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
591 distfiles_attic_url ()
593 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
600 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
605 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
606 [ -n "$size" -a "$size" -gt 0 ]
611 if [ "$CVSIGNORE_DF" != "yes" ]; then
614 cvsignore=${SOURCE_DIR}/.cvsignore
615 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
616 echo "$1" >> $cvsignore
623 update_shell_title "get_files"
625 if [ -n "$DEBUG" ]; then
630 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
634 if [ -n "$CVSROOT" ]; then
635 OPTIONS="-d $CVSROOT $OPTIONS"
637 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
638 echo "warning: No cvs access defined for SOURCES"
642 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
643 OPTIONS="$OPTIONS -A"
645 if [ -n "$CVSDATE" ]; then
646 OPTIONS="$OPTIONS -D $CVSDATE"
648 if [ -n "$CVSTAG" ]; then
649 OPTIONS="$OPTIONS -r $CVSTAG"
654 if [ -n "$UPDATE5" ]; then
655 if [ -n "$ADD5" ]; then
656 [ `nourl $i` = "$i" ] && continue
657 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
659 grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
663 if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then
664 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
665 echo "Warning: no URL given for $i"
668 if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then
669 if good_md5 "$i" && good_size "$i"; then
670 echo "$(nourl "$i") having proper md5sum already exists"
674 url=$(distfiles_url "$i")
675 url_attic=$(distfiles_attic_url "$i")
677 if [ "`echo $url | grep -E '^(\.|/)'`" ]; then
678 update_shell_title "get_files: $url"
679 ${GETLOCAL} $url $target
681 if [ -z "$NOMIRRORS" ]; then
682 url="`find_mirror "$url"`"
684 update_shell_title "get_files: $url"
685 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
686 if [ "`echo $url | grep -E 'ftp://'`" ]; then
687 update_shell_title "get_files: $url"
688 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
691 if ! test -s "$target"; then
693 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
694 update_shell_title "get_files: $url_attic"
695 ${GETLOCAL} $url_attic $target
697 if [ -z "$NOMIRRORS" ]; then
698 url_attic="`find_mirror "$url_attic"`"
700 update_shell_title "get_files: $url_attic"
701 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
702 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
703 update_shell_title "get_files: $url_attic"
704 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
708 if test -s "$target"; then
714 elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then
715 # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred
718 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]
720 retries_counter=$(( $retries_counter + 1 ))
721 output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1)
723 [ -n "$output" ] && echo "$output"
724 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
725 echo "Trying again [`nourl $i`]... ($retries_counter)"
734 if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
735 if [ -z "$NOMIRRORS" ]; then
736 im="`find_mirror "$i"`"
740 update_shell_title "get_files: $im"
742 if [ "`echo $im | grep -E 'ftp://'`" ]; then
743 update_shell_title "get_files: $im"
750 if [ ! -f "`nourl $i`" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
751 Exit_error err_no_source_in_repo $i;
752 elif [ -n "$UPDATE5" ] && \
753 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
754 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
755 grep -q -i -E '^#[ ]*source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
757 echo "Updating source-$srcno md5."
758 md5=$(md5sum `nourl $i` | cut -f1 -d' ')
760 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
761 print "# Source'$srcno'-md5:\t'$md5'\n"
762 if /^Source'$srcno'\s*:\s+/;
767 if good_md5 "$i" && good_size "$i"; then
769 elif [ "$FROM_DISTFILES" = 1 ]; then
770 # wrong md5 from distfiles: remove the file and try again
772 echo "MD5 sum mismatch. Trying full fetch."
775 update_shell_title "get_files: $url"
776 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
777 if [ "`echo $url | grep -E 'ftp://'`" ]; then
778 update_shell_title "get_files: $url"
779 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
781 if ! test -s "$target"; then
783 update_shell_title "get_files: $url_attic"
784 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
785 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
786 update_shell_title "get_files: $url_attic"
787 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
790 test -s "$target" || rm -f "$target"
793 if good_md5 "$i" && good_size "$i" ; then
796 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
797 echo "or -5 to update md5 sums, if you're sure files are correct."
798 Exit_error err_no_source_in_repo $i
802 if [ "$CHMOD" = "yes" ]; then
803 CHMOD_FILES="`nourl $GET_FILES`"
804 if [ -n "$CHMOD_FILES" ]; then
805 chmod $CHMOD_MODE $CHMOD_FILES
814 if [ -n "$DEBUG" ]; then
819 # Check whether first character of PACKAGE_NAME is legal for tag name
820 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
823 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"`
824 # Remove #kernel.version_release from TAGVER because tagging sources
825 # could occur with different kernel-headers than kernel-headers used at build time.
826 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
834 if [ -n "$DEBUG" ]; then
839 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
840 echo "Version: $PACKAGE_VERSION"
841 echo "Release: $PACKAGE_RELEASE"
845 if [ "$TAG_VERSION" = "yes" ]; then
846 echo "CVS tag: $TAGVER"
848 if [ -n "$TAG" ]; then
853 if [ -n "$CVSROOT" ]; then
854 OPTIONS="-d $CVSROOT $OPTIONS"
860 # don't tag files stored on distfiles
861 [ -n "`src_md5 $i`" ] && continue
862 if [ -f "`nourl $i`" ]; then
863 if [ "$TAG_VERSION" = "yes" ]; then
864 cvs $OPTIONS $TAGVER `nourl $i`
866 if [ -n "$TAG" ]; then
867 cvs $OPTIONS $TAG `nourl $i`
870 Exit_error err_no_source_in_repo $i
875 if [ "$TAG_VERSION" = "yes" ]; then
876 cvs $OPTIONS $TAGVER $SPECFILE
878 if [ -n "$TAG" ]; then
879 cvs $OPTIONS $TAG $SPECFILE
889 echo "CVS branch tag: $TAG"
894 if [ -n "$DEBUG" ]; then
899 if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then
902 if [ -n "$CVSROOT" ]; then
903 OPTIONS="-d $CVSROOT $OPTIONS"
908 if [ -f `nourl $i` ]; then
909 cvs $OPTIONS $TAG `nourl $i`
911 Exit_error err_no_source_in_repo $i
915 cvs $OPTIONS $TAG $SPECFILE
925 update_shell_title "build_package"
926 if [ -n "$DEBUG" ]; then
933 if [ -n "$TRY_UPGRADE" ]; then
934 update_shell_title "build_package: try_upgrade"
935 if [ -n "$FLOAT_VERSION" ]; then
936 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
938 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
941 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
943 if [ -n "$TNEWVER" ]; then
944 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
945 echo "New version found, updating spec file to version " $TNEWVER
946 cp -f $SPECFILE $SPECFILE.bak
948 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
949 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
951 if [ -n "$ICONS" ]; then
955 NODIST="yes" UPDATE5="yes" get_files "$SOURCES $PATCHES";
956 unset TOLDVER TNEWVER TNOTIFY
963 BUILD_SWITCH="-ba" ;;
965 BUILD_SWITCH="-bb" ;;
967 BUILD_SWITCH="-bs --nodeps" ;;
969 BUILD_SWITCH="-bp --nodeps" ;;
972 update_shell_title "build_package: $COMMAND"
973 if [ -n "$LOGFILE" ]; then
974 LOG=`eval echo $LOGFILE`
975 if [ -d "$LOG" ]; then
976 echo "Log file $LOG is a directory."
977 echo "Parse error in the spec?"
978 Exit_error err_build_fail;
980 if [ -n "$LASTLOG_FILE" ]; then
981 echo "LASTLOG=$LOG" > $LASTLOG_FILE
983 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
984 (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
985 RETVAL=`cat $RES_FILE`
987 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
988 if [ "$RETVAL" -eq "0" ]; then
995 eval nice -n ${DEF_NICE_LEVEL} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $BCOND $TARGET_SWITCH $SPECFILE
998 if [ "$RETVAL" -ne "0" ]; then
999 if [ -n "$TRY_UPGRADE" ]; then
1000 echo "\n!!! Package with new version cannot be build automagically\n"
1001 mv -f $SPECFILE.bak $SPECFILE
1003 Exit_error err_build_fail;
1010 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1013 install_required_packages()
1021 update_shell_title "set_bconds_values"
1023 AVAIL_BCONDS_WITHOUT=""
1024 AVAIL_BCONDS_WITH=""
1025 if `grep -q ^%bcond ${SPECFILE}`; then
1027 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1030 BCOND_VERSION="NONE"
1033 # expand bconds from ~/.bcondrc
1034 # The file structure is like gentoo's package.use:
1037 # samba -mysql -pgsql
1038 # w32codec-installer license_agreement
1041 if [ "${BCOND_VERSION}" != "NONE" ] && ( [ -f $HOME/.bcondrc ] || ( [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] ) ) ; then
1042 # This takes package name, first defined in spec.
1043 # so consider that when defining flags for package.
1044 PN=`$RPM -q --qf '%{NAME}\n' --specfile $SPECFILE | head -n 1`
1045 SN=${SPECFILE%%\.spec}
1046 AVAIL=`$RPMBUILD --bcond $SPECFILE`
1048 BCONDRC=$HOME/.bcondrc
1049 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && BCONDRC=$HOME_ETC/.bcondrc
1051 while read pkg flags; do
1053 [[ "$pkg" == \#* ]] && continue
1055 # any package or current package?
1056 if [ "$pkg" = "*" ] || [ "$pkg" = "$PN" ] || [ "$pkg" = "$SN" ]; then
1057 for flag in $flags; do
1060 # use only flags which are in this package.
1061 if [[ $AVAIL = *${opt}* ]]; then
1062 if [[ $flag = -* ]]; then
1063 BCOND="$BCOND --without $opt"
1065 BCOND="$BCOND --with $opt"
1073 case "${BCOND_VERSION}" in
1078 echo "Warning: This spec has old style bconds. Fix it || die."
1079 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_without_`
1081 AVAIL_BCOND_WITHOUT=`echo $opt|sed -e "s/^_without_//g"`
1082 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1083 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1085 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1089 for opt in `$RPMBUILD --bcond $SPECFILE |grep ^_with_`
1091 AVAIL_BCOND_WITH=`echo $opt|sed -e "s/^_with_//g"`
1092 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1093 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1095 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1100 cond_type="" # with || without
1101 for opt in `$RPMBUILD --bcond $SPECFILE`
1111 AVAIL_BCOND_WITHOUT="`echo $opt | sed 's/^_without_//g'`"
1112 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1113 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1115 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1119 AVAIL_BCOND_WITH="`echo $opt | sed 's/^_with_//g'`"
1120 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1121 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1123 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1127 case "$cond_type" in
1130 AVAIL_BCOND_WITH="$opt"
1131 if `echo $BCOND|grep -q -- "--with $AVAIL_BCOND_WITH"`;then
1132 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1134 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1139 AVAIL_BCOND_WITHOUT="$opt"
1140 if `echo $BCOND|grep -q -- "--without $AVAIL_BCOND_WITHOUT"`;then
1141 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1143 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1157 echo -ne "Package installation failed:\t$package_name\n"
1159 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1160 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1161 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1162 # jakby nie bylo tego kawalka kodu.
1164 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1165 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1172 # Istnieje taki spec? ${package}.spec
1173 if [ -f "${SPECS_DIR}${package}.spec" ]; then
1174 parent_spec_name=${package}.spec
1175 elif [ -f "${SPECS_DIR}`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1176 parent_spec_name="`echo ${package_name}|sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1178 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1184 if [ "${parent_spec_name}" != "" ]; then
1186 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1187 sub_builder_opts="${sub_builder_opts} -R"
1189 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1190 sub_builder_opts="${sub_builder_opts} -RB"
1191 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1192 sub_builder_opts="${sub_builder_opts} -FRB"
1194 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1195 sub_builder_opts="${sub_builder_opts} -Upi"
1198 ./builder ${sub_builder_opts} ${parent_spec_name}
1200 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1203 remove_build_requires()
1205 if [ "$INSTALLED_PACKAGES" != "" ]; then
1206 case "$REMOVE_BUILD_REQUIRES" in
1208 run_poldek --noask -ve $INSTALLED_PACKAGES
1211 run_poldek --ask -ve $INSTALLED_PACKAGES
1214 echo You may want to manually remove following BuildRequires fetched:
1215 echo $INSTALLED_PACKAGES
1216 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1224 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1225 if [ "$BCOND" != "" ]; then
1226 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1229 echo -ne "\nNo conditional flags passed"
1231 echo -ne "\n\nfrom available:\n"
1232 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1238 if [ "$NOCVSSPEC" != "yes" ]; then
1239 echo -ne "Available branches: "
1240 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1244 # checks a given list of packages/files/provides agains current rpmdb.
1245 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1246 # input can be either STDIN or parameters
1251 if [ "$#" -gt 0 ]; then
1257 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1260 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1262 # other deps (files)
1263 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1266 # checks if given package/files/provides exists in rpmdb.
1267 # inout can be either stdin or parameters
1268 # returns packages wchi hare present in the rpmdb
1273 if [ "$#" -gt 0 ]; then
1279 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1282 fetch_build_requires()
1284 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1285 update_shell_title "fetch_build_requires"
1286 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1287 CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1288 DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1290 update_shell_title "fetch_build_requires: update indexes"
1291 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1292 $SU_SUDO /usr/bin/poldek --update || $SU_SUDO /usr/bin/poldek --upa
1294 if [ -n "$CONF" ]; then
1295 update_shell_title "fetch_build_requires: uninstall conflicting packages"
1296 echo "Trying to uninstall conflicting packages ($CONF):"
1297 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1299 if [ -n "$DEPS" ]; then
1300 update_shell_title "fetch_build_requires: install deps ($DEPS)"
1301 echo "Trying to install dependencies ($DEPS):"
1302 $SU_SUDO /usr/bin/poldek --caplookup -uGv $DEPS
1307 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1308 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1309 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1310 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1311 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1312 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`
1314 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`"
1316 package=`basename "$package_item"|sed -e "s/}$//g"`
1317 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1320 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1321 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1322 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
1327 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1330 if `echo $COND_TST|grep -q 'without_'`; then
1331 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1332 if `echo $COND_TST|grep -q !`; then
1337 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1338 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1339 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1345 elif `echo $COND_TST|grep -q 'with_'`; then
1346 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1347 if `echo $COND_TST|grep -q !`; then
1352 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1353 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1354 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1360 RESULT="${COND_STATE}-${COND_ARGV}"
1362 "with-wout" | "wout-with" )
1365 "wout-wout" | "with-with" )
1369 echo "Action '$RESULT' was not defined for package '$package_item'"
1375 if [ "$GO" = "yes" ]; then
1376 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1377 echo "Testing if $package has subrequirements..."
1378 run_poldek -t -i $package --dumpn=".$package-req.txt"
1379 if [ -f ".$package-req.txt" ]; then
1380 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1382 if [ "$package_name" = "$package" ]; then
1383 echo -ne "Installing BuildRequired package:\t$package_name\n"
1384 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing BuildRequired package: ${package_name}\007"`
1385 install_required_packages $package;
1387 echo -ne "Installing (sub)Required package:\t$package_name\n"
1388 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}: Installing (sub)Required package: ${package_name}\007"`
1389 install_required_packages $package_name;
1393 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1394 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1397 echo "Attempting to run spawn sub - builder..."
1398 run_sub_builder $package_name
1399 if [ $? -eq 0 ]; then
1400 install_required_packages $package_name;
1403 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1404 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1407 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1414 rm -f ".$package-req.txt"
1416 echo "Attempting to run spawn sub - builder..."
1417 run_sub_builder $package
1418 if [ $? -eq 0 ]; then
1419 install_required_packages $package;
1422 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1423 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1426 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1432 echo "Package $package is already installed. BuildRequirement satisfied."
1436 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1437 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1438 echo "Unable to install following packages and their dependencies:"
1439 for pkg in "$NOT_INSTALLED_PACKAGES"
1443 remove_build_requires
1451 # vim like diff colourization, glen@pld-linux.org
1453 s,
\e,
\e[44m^[
\e[49m,g;
1454 s,
\a,
\e[44m^G
\e[49m,g;
1455 s,^\(Index:\|diff\|---\|+++\) .*$,
\e[32m&,;
1459 s,
\r,
\e[44m^M
\e[49m,g;
1461 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1
\e[41m\2
\e[49m,g;
1469 # diff2hunks orignally by dig
1475 for my $filename (@ARGV) {
1478 open $fh, "<", $filename or die "$filename: open for reading: $!";
1482 for my $i (0 ... $#lines) {
1483 next unless $lines[$i] =~ m/^\@\@ /;
1484 if ($i >= 2 and $lines[$i - 2] =~ m/^--- / and $lines[$i - 1] =~ m/^\+\+\+ /) {
1485 @curheader = @lines[$i - 2 ... $i - 1];
1487 next unless @curheader;
1489 while ($j < @lines and $lines[$j] !~ m/^\@\@ /) {$j++}
1491 if $j >= 3 and $j < @lines
1492 and $lines[$j - 2] =~ m/^--- /
1493 and $lines[$j - 1] =~ m/^\+\+\+ /;
1495 $j-- until $lines[$j] =~ m/^[ @+-]/;
1496 my $hunkfilename = $filename;
1497 $hunkfilename =~ s/((\.(pat(ch)?|diff?))?)$/"-".sprintf("%03i",$counter++).$1/ei;
1499 open $ofh, ">", $hunkfilename or die "$hunkfilename: open for writing: $!";
1500 print $ofh @curheader, @lines[$i ... $j];
1511 tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/adapter-XXXXXX) || exit
1512 awk -f adapter.awk $SPECFILE > $tmpdir/$SPECFILE || exit
1514 if [ "`diff --brief $SPECFILE $tmpdir/$SPECFILE`" ] ; then
1515 diff -u $SPECFILE $tmpdir/$SPECFILE > $tmpdir/$SPECFILE.diff
1517 diffcol $tmpdir/$SPECFILE.diff | less -r
1519 echo -n "Accept? (Yes, No, Confirm)? "
1523 mv -f $tmpdir/$SPECFILE $SPECFILE
1524 echo "Ok, adapterized."
1527 [cC]) # confirm each chunk
1528 diff2hunks $tmpdir/$SPECFILE.diff
1529 for t in $(ls $tmpdir/$SPECFILE-*.diff); do
1530 diffcol $t | less -r
1531 echo -n "Accept? (Yes, [N]o)? "
1548 cat $tmpdir/$SPECFILE.diff
1551 echo "The SPEC is perfect ;)"
1557 #---------------------------------------------
1560 if [ "$#" = 0 ]; then
1574 --adapter | --adapterize )
1575 COMMAND="adapterize";
1592 DEBUG="yes"; shift ;;
1594 COMMAND="version"; shift ;;
1596 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1597 -b | -ba | --build )
1598 COMMAND="build"; shift ;;
1599 -bb | --build-binary )
1600 COMMAND="build-binary"; shift ;;
1601 -bs | --build-source )
1602 COMMAND="build-source"; shift ;;
1603 -bp | --build-prep )
1604 COMMAND="build-prep"; shift ;;
1606 COMMAND="branch"; shift; TAG="${1}"; shift;;
1608 CLEAN="--clean --rmspec --rmsource"; shift ;;
1610 shift; CVSROOT="${1}"; shift ;;
1612 COMMAND="get"; shift ;;
1614 COMMAND="usage"; shift ;;
1616 PROTOCOL="http"; shift ;;
1618 shift; LOGFILE="${1}"; shift ;;
1620 shift; DEF_NICE_LEVEL=${1}; shift ;;
1622 COMMAND="mr-proper"; shift ;;
1624 NOCVS="yes"; shift ;;
1625 -ncs | --no-cvs-specs )
1626 NOCVSSPEC="yes"; shift ;;
1627 -nd | --no-distfiles )
1628 NODIST="yes"; shift ;;
1629 -nm | --no-mirrors )
1630 NOMIRRORS="yes"; shift ;;
1632 NOURLS="yes"; shift ;;
1634 NOSRCS="yes"; shift ;;
1635 -ns0 | --no-source0 )
1636 NOSOURCE0="yes"; shift ;;
1646 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1648 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} echo ignoring patch${1} \""; shift ;;
1649 --with | --without )
1650 case $GROUP_BCONDS in
1654 while ! `echo ${1}|grep -qE '(^-|spec)'`
1656 BCOND="$BCOND $COND $1"
1660 if [[ "$2" = *,* ]]; then
1661 for a in $(echo "$2" | tr , ' '); do
1662 BCOND="$BCOND $1 $a"
1665 BCOND="$BCOND $1 $2"
1671 shift; TARGET="${1}"; shift ;;
1673 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1675 QUIET="--quiet"; shift ;;
1677 CVSDATE="${2}"; shift 2 ;;
1679 shift; CVSTAG="${1}"; shift ;;
1680 -R | --fetch-build-requires)
1681 FETCH_BUILD_REQUIRES="yes"
1682 NOT_INSTALLED_PACKAGES=
1684 -RB | --remove-build-requires)
1685 REMOVE_BUILD_REQUIRES="nice"
1687 -FRB | --force-remove-build-requires)
1688 REMOVE_BUILD_REQUIRES="force"
1690 -sf | --sources-files)
1691 COMMAND="list-sources-files"
1693 -sp | --sources-paths)
1694 COMMAND="list-sources-local-paths"
1696 -Tvs | --tag-version-stable )
1701 -Tvn | --tag-version-nest )
1706 -Ts | --tag-stable )
1716 -Tv | --tag-version )
1721 -Tp | --tag-prefix )
1733 -ir | --integer-release-only )
1734 INTEGER_RELEASE="yes"
1743 -Upi | --update-poldek-indexes )
1744 UPDATE_POLDEK_INDEXES="yes"
1746 -u | --try-upgrade )
1747 TRY_UPGRADE="1"; shift ;;
1748 -un | --try-upgrade-with-float-version )
1749 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1751 BE_VERBOSE="1"; shift ;;
1757 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1759 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1765 RPMOPTS="${RPMOPTS} --nodeps"
1768 RPMOPTS="${RPMOPTS} -debug"; shift ;;
1771 export PROMPT_COMMAND=`echo -ne "\033]0;${SPECFILE}\007"`
1776 if [ -n "$DEBUG" ]; then
1781 if [ -n "$TARGET" ]; then
1784 TARGET_SWITCH="--target $TARGET" ;;
1786 TARGET_SWITCH="--target=$TARGET" ;;
1790 update_shell_title "$COMMAND"
1792 "build" | "build-binary" | "build-source" | "build-prep" )
1794 if [ -n "$SPECFILE" ]; then
1799 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1800 fetch_build_requires;
1802 if [ "$INTEGER_RELEASE" = "yes" ]; then
1803 echo "Checking release $PACKAGE_RELEASE..."
1804 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1805 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1809 if [ -n "$TEST_TAG" ]; then
1810 TAGVER=`make_tagver`
1811 echo "Searching for tag $TAGVER..."
1812 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1813 if [ -n "$TAGREL" ]; then
1814 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1817 # - do not allow to build from HEAD when XX-branch exists
1818 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1819 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1820 TAG_BRANCH="${TREE_PREFIX}-branch"
1821 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1822 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1823 Exit_error err_branch_exists "$TAG_STATUS"
1829 if [ -n "$ICONS" ]; then
1833 if [ -n "$NOSOURCE0" ] ; then
1834 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1836 get_files "$SOURCES $PATCHES";
1838 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1839 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1841 remove_build_requires;
1843 Exit_error err_no_spec_in_cmdl;
1848 if [ -n "$SPECFILE" ]; then
1851 if [ -n "$ICONS" ]; then
1855 get_files $SOURCES $PATCHES;
1856 branch_files $TAG "$SOURCES $PATCHES $ICONS";
1858 Exit_error err_no_spec_in_cmdl;
1863 if [ -n "$SPECFILE" ]; then
1866 if [ -n "$ICONS" ]; then
1867 OLD_UPDATE5=$UPDATE5
1868 UPDATE5= get_files $ICONS
1869 UPDATE5=$OLD_UPDATE5
1872 if [ -n "$NOSOURCE0" ] ; then
1873 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1875 get_files $SOURCES $PATCHES
1877 Exit_error err_no_spec_in_cmdl;
1884 if [ -n "$SPECFILE" ]; then
1887 if [ -n "$ICONS" ]; then
1891 # don't fetch sources from remote locations
1893 for file in $SOURCES
1895 [ -n "`src_md5 $file`" ] && continue
1896 new_SOURCES="$new_SOURCES $file"
1898 SOURCES="$new_SOURCES"
1899 get_files $SOURCES $PATCHES;
1900 tag_files "$SOURCES $PATCHES $ICONS";
1902 Exit_error err_no_spec_in_cmdl;
1906 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
1908 "list-sources-files" )
1911 DONT_PRINT_REVISION="yes"
1914 SAPS="$SOURCES $PATCHES"
1915 for SAP in $SAPS ; do
1916 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
1919 "list-sources-local-paths" )
1922 DONT_PRINT_REVISION="yes"
1925 SAPS="$SOURCES $PATCHES"
1926 for SAP in $SAPS ; do
1927 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
1938 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
1939 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
1943 # vi:syntax=sh:ts=3:sw=4