7 # 2 - no spec file name in cmdl parameters
8 # 3 - spec file not stored in repo
9 # 4 - some source, patch or icon files not stored in repo
10 # 5 - package build failed
11 # 6 - spec file with errors
12 # 7 - wrong source in /etc/poldek.conf
13 # 8 - Failed installing buildrequirements and subrequirements
14 # 9 - Requested tag already exist
15 # 10 - Refused to build fractional release
16 # 100 - Unknown error (should not happen)
19 # - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?)
20 # - when Icon: field is present, -5 and -a5 doesn't work
21 # - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice)
24 Build package utility from PLD Linux CVS repository
25 v0.16 (C) 1999-2006 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!
77 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
78 CVS_RETRIES=${MAX_CVS_RETRIES:-1000}
83 CVS_SERVER="cvs.pld-linux.org"
84 DISTFILES_SERVER="://distfiles.pld-linux.org"
85 ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org"
90 FAIL_IF_NO_SOURCES="yes"
92 # let get_files skip over files which are present to get those damn files fetched
93 SKIP_EXISTING_FILES="no"
95 if [ -x /usr/bin/rpm-getdeps ]; then
96 FETCH_BUILD_REQUIRES_RPMGETDEPS="yes"
98 FETCH_BUILD_REQUIRES_RPMGETDEPS="no"
101 # Here we load saved user environment used to
102 # predefine options set above, or passed to builder
104 # This one reads global system environment settings:
105 if [ -f ~/etc/builderrc ]; then
108 # And this one cascades settings using user personal
110 # Example of ~/.builderrc:
112 #UPDATE_POLDEK_INDEXES="yes"
113 #FETCH_BUILD_REQUIRES="yes"
114 #REMOVE_BUILD_REQUIRES="force"
116 #LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
120 if [ -n "$HOME_ETC" ]; then
121 USER_CFG="$HOME_ETC/.builderrc"
123 USER_CFG=~/.builderrc
126 [ -f "$USER_CFG" ] && . "$USER_CFG"
128 if [ "$SCHEDTOOL" = "auto" ]; then
129 if [ -x /usr/bin/schedtool ] && schedtool -B -e echo >/dev/null; then
130 SCHEDTOOL="schedtool -B -e"
136 if [ -n "$USE_PROZILLA" ]; then
137 GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS"
140 elif [ -n "$USE_AXEL" ]; then
141 GETURI="axel -a $AXEL_OPTS"
145 wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
146 wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
147 wget --help 2>&1 | grep -q -- ' --retry-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused"
149 GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS"
150 GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS"
156 if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
164 POLDEK_INDEX_DIR="`$RPM --eval %_rpmdir`/"
165 POLDEK_CMD="$SU_SUDO /usr/bin/poldek --noask"
169 RES_FILE=~/tmp/poldek-exit-status.$RANDOM
170 if [ -n "$LOGFILE" ]; then
171 LOG=`eval echo $LOGFILE`
172 if [ -n "$LASTLOG_FILE" ]; then
173 echo "LASTLOG=$LOG" > $LASTLOG_FILE
175 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE})|tee -a $LOG
178 (${NICE_COMMAND} ${POLDEK_CMD} `while test $# -gt 0; do echo "$1 ";shift;done` ; echo $? > ${RES_FILE}) 1>&2 >/dev/null
179 return `cat ${RES_FILE}`
184 #---------------------------------------------
189 if [ -n "$DEBUG" ]; then set -xv; fi
191 Usage: builder [-D|--debug] [-V|--version] [-a|--as_anon] [-b|-ba|--build]
193 [-bb|--build-binary] [-bs|--build-source] [-u|--try-upgrade]
194 [{-B|--branch} <branch>] [{-d|--cvsroot} <cvsroot>] [-g|--get]
195 [-h|--help] [--http] [{-l,--logtofile} <logfile>] [-m|--mr-proper]
196 [-q|--quiet] [--date <yyyy-mm-dd> [-r <cvstag>] [{-T--tag <cvstag>]
197 [-Tvs|--tag-version-stable] [-Ts|--tag-stable] [-Tv|--tag-version]
198 [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}]
199 [-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds]
200 [--with/--without <feature>] [--define <macro> <value>] <package>[.spec][:cvstag]
202 -5, --update-md5 - update md5 comments in spec, implies -nd -ncs
203 -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs
204 -n5, --no-md5 - ignore md5 comments in spec
205 -D, --debug - enable builder script debugging mode,
206 -debug - produce rpm debug package (same as --opts -debug)
207 -V, --version - output builder version
208 -a, --as_anon - get files via pserver as cvs@$CVS_SERVER,
209 -b, -ba, --build - get all files from CVS repo or HTTP/FTP and build package
211 -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary
212 only package from <package>.spec,
213 -bp, --build-prep - execute the %prep phase of <package>.spec,
214 -bc - reserved (not implemented)
215 -bi reserved (not implemented)
216 -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack
218 --short-circuit - reserved (not implemented)
219 -B, --branch - add branch
220 -c, --clean - clean all temporarily created files (in BUILD, SOURCES,
221 SPECS and \$RPM_BUILD_ROOT),
222 -d <cvsroot>, --cvsroot <cvsroot>
224 --define <macro> <value>
225 - define a macro <macro> with value <value>,
226 --nodeps - rpm won't check any dependences
227 -g, --get - get <package>.spec and all related files from CVS repo
229 -h, --help - this message,
230 --http - use http instead of ftp,
231 -l <logfile>, --logtofile <logfile>
233 -m, --mr-proper - only remove all files related to spec file and all work
235 -nc, --no-cvs - don't download sources from CVS, if source URL is given,
237 - don't check specs in CVS
238 -nd, --no-distfiles - don't download from distfiles
239 -nm, --no-mirrors - don't download from mirror, if source URL is given,
240 -nu, --no-urls - don't try to download from FTP/HTTP location,
241 -ns, --no-srcs - don't download Sources
242 -ns0, --no-source0 - don't download Source0
243 -nn, --no-net - don't download anything from the net
244 --no-init - don't initialize builder paths (SPECS and SOURCES)
246 --skip-existing-files - skip existing files in get_files
247 --opts <rpm opts> - additional options for rpm
248 -q, --quiet - be quiet,
249 --date yyyy-mm-dd - build package using resources from specified CVS date,
250 -r <cvstag>, --cvstag <cvstag>
251 - build package using resources from specified CVS tag,
252 -R, --fetch-build-requires
253 - fetch what is BuildRequired,
254 -RB, --remove-build-requires
255 - remove all you fetched with -R or --fetch-build-requires
256 remember, this option requires confirmation,
257 -FRB, --force-remove-build-requires
258 - remove all you fetched with -R or --fetch-build-requires
259 remember, this option works without confirmation,
260 -sd, --source-distfiles - list sources available from distfiles (intended for offline
261 operations; does not work when Icon field is present
262 but icon file is absent),
263 -sdp, --source-distfiles-paths - list sources available from distfiles -
264 paths relative to distfiles directory (intended for offline
265 operations; does not work when Icon field is present
266 but icon file is absent),
267 -sf, --source-files - list sources - bare filenames (intended for offline
268 operations; does not work when Icon field is present
269 but icon file is absent),
270 -sp, --source-paths - list sources - filenames with full local paths (intended for
271 offline operations; does not work when Icon field is present
272 but icon file is absent),
273 -su, --source-urls - list urls - urls to sources and patches
274 intended for copying urls with spec with lots of macros in urls
275 -T <cvstag> , --tag <cvstag>
276 - add cvs tag <cvstag> for files,
277 -Tvs, --tag-version-stable
278 - add cvs tags STABLE and NAME-VERSION-RELEASE for files,
280 - add cvs tag STABLE for files,
282 - add cvs tag NAME-VERSION-RELEASE for files,
283 -Tp, --tag-prefix <prefix>
284 - add <prefix> to NAME-VERSION-RELEASE tags,
285 -tt, --test-tag <prefix>
286 - fail if tag is already present,
287 -ir, --integer-release-only
288 - allow only integer and snapshot releases
289 -v, --verbose - be verbose,
290 -u, --try-upgrade - check version, and try to upgrade package
291 -un, --try-upgrade-with-float-version
292 - as above, but allow float version
293 -U, --update - refetch sources, don't use distfiles, and update md5 comments
294 -Upi, --update-poldek-indexes
295 - refresh or make poldek package index files.
296 -np, --nopatch <patchnumber>
297 - don't apply <patchnumber>
298 --show-bconds - show available conditional builds, which can be used
299 - with --with and/or --without switches.
300 --with/--without <feature>
301 - conditional build package depending on %_with_<feature>/
302 %_without_<feature> macro switch. You may now use
303 --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
304 constructions. Set GROUP_BCONDS to yes to make use of it.
305 --target <platform>, --target=<platform>
306 - build for platform <platform>.
307 --init-rpm-dir - initialize ~/rpm directory structure
311 update_shell_title() {
313 local len=${COLUMNS:-80}
314 local msg=$(echo "$*" | cut -c-$len)
316 if [ -n "$BE_VERBOSE" ]; then
317 echo >&2 "$(date +%s.%N) $*"
320 if [ "x$TITLECHANGE" == "xyes" -o "x$TITLECHANGE" == "x" ]; then
322 if [ -n "$PACKAGE_NAME" ]; then
323 pkg=${PACKAGE_NAME}-${PACKAGE_VERSION}-${PACKAGE_RELEASE}
328 msg="$pkg: ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg"
329 msg="$(echo $msg | tr -d '\n\r')"
332 echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007"
335 echo >&2 -ne "\033]0;$msg\007"
341 # set TARGET from BuildArch: from SPECFILE
343 if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then
344 tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE)
349 TARGET_SWITCH="--target $TARGET" ;;
351 TARGET_SWITCH="--target=$TARGET" ;;
358 if [ -n "$DEBUG" ]; then
363 update_shell_title "cache_rpm_dump"
367 # we reset macros not to contain macros.build as all the %() macros are
368 # executed here, while none of them are actually needed.
369 # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES.
370 # at the time of this writing macros.build + macros contained 70 "%(...)" macros.
371 macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.builder-rpmmacros:~/etc/.rpmmacros:~/.rpmmacros"
372 dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump'
373 # FIXME: better ideas than .rpmrc?
374 printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .builder-rpmrc
375 # TODO: move these to /usr/lib/rpm/macros
376 cat > .builder-rpmmacros <<'EOF'
377 %requires_releq_kernel_up %{nil}
378 %requires_releq_kernel_smp %{nil}
379 %requires_releq() %{nil}
380 %pyrequires_eq() %{nil}
381 %requires_eq() %{nil}
382 %requires_eq_to() %{nil}
383 %releq_kernel_up ERROR
384 %releq_kernel_smp ERROR
388 %ruby_ver_requires_eq() %{nil}
389 %ruby_mod_ver_requires_eq() %{nil}
390 %__php_api_requires() %{nil}
391 %php_major_version ERROR
392 %php_api_version ERROR
400 ARGS='--nodigest --nosignature --nobuild'
403 if [ "$NOINIT" = "yes" ] ; then
404 cat >> .builder-rpmmacros <<'EOF'
409 $RPMBUILD --rcfile .builder-rpmrc $ARGS $ARGDIRS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1
411 if [ $? -gt 0 ]; then
412 error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p')
414 Exit_error err_build_fail;
417 # make small dump cache
418 rpm_dump_cache=`echo "$rpm_dump" | awk '
419 $2 ~ /^SOURCEURL/ {print}
420 $2 ~ /^PATCHURL/ {print}
421 $2 ~ /^nosource/ {print}
422 $2 ~ /^PACKAGE_/ {print}
425 update_shell_title "cache_rpm_dump: OK!"
429 if [ -z "$rpm_dump_cache" ] ; then
430 echo "internal error: cache_rpm_dump not called!" 1>&2
432 echo "$rpm_dump_cache"
437 update_shell_title "get icons"
438 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
439 if [ -z "$ICONS" ]; then
443 rpm_dump_cache="kalasaba" NODIST="yes" UPDATE5= get_files $ICONS
448 update_shell_title "parsing specfile"
449 if [ -n "$DEBUG" ]; then
454 # icons are needed for successful spec parse
460 if [ "$NOSRCS" != "yes" ]; then
461 SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`"
464 if (rpm_dump | grep -qEi ":.*nosource.*1"); then
465 FAIL_IF_NO_SOURCES="no"
468 PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`"
469 ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`"
470 PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}')
471 PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}')
472 PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}')
474 if [ -n "$BE_VERBOSE" ]; then
475 echo "- Sources : `nourl $SOURCES`"
476 if [ -n "$PATCHES" ]; then
477 echo "- Patches : `nourl $PATCHES`"
479 echo "- Patches : *no patches needed*"
481 if [ -n "$ICONS" ]; then
482 echo "- Icon : `nourl $ICONS`"
484 echo "- Icon : *no package icon*"
486 echo "- Name : $PACKAGE_NAME"
487 echo "- Version : $PACKAGE_VERSION"
488 echo "- Release : $PACKAGE_RELEASE"
491 update_shell_title "parse_spec: OK!"
496 if [ -n "$DEBUG" ]; then
504 "err_no_spec_in_cmdl" )
505 remove_build_requires
506 echo "ERROR: spec file name not specified.";
508 "err_no_spec_in_repo" )
509 remove_build_requires
510 echo "Error: spec file not stored in CVS repo.";
512 "err_no_source_in_repo" )
513 remove_build_requires
514 echo "Error: some source, patch or icon files not stored in CVS repo. ($2)";
517 remove_build_requires
518 echo "Error: package build failed. (${2:-no more info})";
520 "err_no_package_data" )
521 remove_build_requires
522 echo "Error: couldn't get out package name/version/release from spec file."
525 remove_build_requires
526 echo "Tag ${2} already exists (spec release: ${3}).";
529 remove_build_requires
530 echo "Release ${2} not integer and not a snapshot.";
532 "err_branch_exists" )
533 remove_build_requires
534 echo "Tree branch already exists (${2}).";
538 echo "Unknown error."
544 if [ -n "$DEBUG" ]; then
549 if [ "$NOINIT" != "yes" ] ; then
550 SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`"
551 SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`"
563 update_shell_title "get_spec"
565 if [ -n "$DEBUG" ]; then
571 if [ ! -f "$SPECFILE" ]; then
572 SPECFILE="`basename $SPECFILE .spec`.spec";
574 if [ "$NOCVSSPEC" != "yes" ]; then
576 if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
577 echo "Warning: No CVS access defined - using local .spec file"
581 cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo
584 if [ ! -f "$SPECFILE" ]; then
585 Exit_error err_no_spec_in_repo;
588 if [ "$CHMOD" = "yes" -a -n "$SPECFILE" ]; then
589 chmod $CHMOD_MODE $SPECFILE
592 [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE
601 if [ ! -f "mirrors" -a "$NOCVSSPEC" != "yes" ] ; then
602 cvs update mirrors >&2
606 local origin mirror name rest ol prefix
607 while read origin mirror name rest; do
608 # skip comments and empty lines
609 if [ -z "$origin" ] || [[ $origin == \#* ]]; then
612 ol=`echo -n "$origin"|wc -c`
613 prefix="`echo -n "$url" | head -c $ol`"
614 if [ "$prefix" = "$origin" ] ; then
615 suffix="`echo "$url"|cut -b $((ol+1))-`"
616 echo -n "$mirror$suffix"
623 # Warning: unpredictable results if same URL used twice
628 grep "SOURCEURL[0-9]*[ ]*$1""[ ]*$" | \
629 sed -e 's/.*SOURCEURL\([0-9][0-9]*\).*/\1/' | \
635 [ "$NO5" = "yes" ] && return
637 [ -z "$no" ] && return
641 if [ -f additional-md5sums ]; then
642 local spec_rev=$(grep $SPECFILE CVS/Entries 2>/dev/null | sed -e s:/$SPECFILE/:: -e s:/.*::)
643 if [ -z "$spec_rev" ]; then
644 spec_rev="$(head -n 1 $SPECFILE | sed -e 's/.*\$Revision: \([0-9.]*\).*/\1/')"
646 local spec="$SPECFILE[0-9.,]*,$(echo $spec_rev | sed 's/\./\\./g')"
647 md5=$(grep -s -v '^#' additional-md5sums | \
648 grep -E "[ ]$(basename "$1")[ ]+${spec}([ ,]|\$)" | \
649 sed -e 's/^\([0-9a-f]\{32\}\).*/\1/' | \
650 grep -E '^[0-9a-f]{32}$')
653 if [ $(echo "$md5" | wc -l) != 1 ] ; then
654 echo "$SPECFILE: more then one entry in additional-md5sums for $1" 1>&2
656 echo "$md5" | tail -n 1
661 source_md5=`grep -i "#[ ]*Source$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
662 if [ -n "$source_md5" ]; then
665 # we have empty SourceX-md5, but it is still possible
666 # that we have NoSourceX-md5 AND NoSource: X
667 nosource_md5=`grep -i "#[ ]*NoSource$no-md5[ ]*:" $SPECFILE | sed -e 's/.*://'`
668 if [ -n "$nosource_md5" -a -n "`grep -i "^NoSource:[ ]*$no$" $SPECFILE`" ] ; then
676 echo "by-md5/$(src_md5 "$1" | sed -e 's|^\(.\)\(.\)|\1/\2/&|')/$(basename "$1")"
681 echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")"
684 distfiles_attic_url ()
686 echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")"
693 [ "$md5" = "$(md5sum $(nourl "$1") 2> /dev/null | sed -e 's/ .*//')" ]
698 size="$(find $(nourl "$1") -printf "%s" 2>/dev/null)"
699 [ -n "$size" -a "$size" -gt 0 ]
704 if [ "$CVSIGNORE_DF" != "yes" ]; then
707 cvsignore=${SOURCE_DIR}/.cvsignore
708 if ! grep -q "^$1\$" $cvsignore 2> /dev/null; then
709 echo "$1" >> $cvsignore
715 update_shell_title "cvsup"
717 if [ -n "$CVSROOT" ]; then
718 OPTIONS="-d $CVSROOT $OPTIONS"
721 if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then
722 OPTIONS="$OPTIONS -A"
724 if [ -n "$CVSDATE" ]; then
725 OPTIONS="$OPTIONS -D $CVSDATE"
727 if [ -n "$CVSTAG" ]; then
728 OPTIONS="$OPTIONS -r $CVSTAG"
733 local retries_counter=0
735 update_shell_title "cvsup: $*"
737 update_shell_title "cvsup: $# files"
739 while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do
740 retries_counter=$(( $retries_counter + 1 ))
741 output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1)
743 [ -n "$output" ] && echo "$output"
744 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
745 echo "Trying again [$*]... ($retries_counter)"
746 update_shell_title "cvsup: retry #$retries_counter"
753 update_shell_title "cvsup: done!"
759 if [ $# -eq 0 ]; then
763 update_shell_title "update md5"
764 if [ -n "$DEBUG" ]; then
771 # pass 1: check files to be fetched
775 local fp=$(nourl "$i")
776 local srcno=$(src_no "$i")
777 if [ -n "$UPDATE5" ]; then
778 if [ -n "$ADD5" ]; then
779 [ "$fp" = "$i" ] && continue # FIXME what is this check doing?
780 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue
782 grep -qiE '^#[ ]*Source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue
785 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
786 need_files="$need_files $i"
790 # pass 1a: get needed files
791 if [ "$need_files" ]; then
792 get_files $need_files
795 # pass 2: proceed with md5 adding or updating
797 local fp=$(nourl "$i")
798 local srcno=$(src_no "$i")
799 if [ -n "$UPDATE5" ] && \
800 ( ( [ -n "$ADD5" ] && echo $i | grep -q -E 'ftp://|http://|https://' && \
801 [ -z "$(grep -E -i '^NoSource[ ]*:[ ]*'$i'([ ]|$)' $SPECS_DIR/$SPECFILE)" ] ) || \
802 grep -q -i -E '^#[ ]*source'$srcno'-md5[ ]*:' $SPECS_DIR/$SPECFILE )
804 echo "Updating source-$srcno md5."
805 md5=$(md5sum "$fp" | cut -f1 -d' ')
807 print unless /^\s*#\s*Source'$srcno'-md5\s*:/i;
808 print "# Source'$srcno'-md5:\t'$md5'\n"
809 if /^Source'$srcno'\s*:\s+/;
818 update_shell_title "check md5"
821 if good_md5 "$i" && good_size "$i"; then
825 echo "MD5 sum mismatch or 0 size. Use -U to refetch sources,"
826 echo "or -5 to update md5 sums, if you're sure files are correct."
827 Exit_error err_no_source_in_repo $i
833 update_shell_title "get_files"
835 if [ -n "$DEBUG" ]; then
840 if [ $# -gt 0 ]; then
843 if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then
844 echo "Warning: No CVS access defined for SOURCES"
849 local get_files_cvs=""
853 SHELL_TITLE_PREFIX="get_files[$nc/$#]"
854 update_shell_title "$i"
855 local fp=`nourl "$i"`
856 if [ "$SKIP_EXISTING_FILES" = "yes" ] && [ -f "$fp" ]; then
861 local srcmd5=$(src_md5 "$i")
863 # we know if source/patch is present in cvs/distfiles
864 # - has md5 (in distfiles)
867 # CHECK: local file didn't exist or always cvs up (first) requested.
868 if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then
869 if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then
870 echo "Warning: no URL given for $i"
873 if [ -z "$NODIST" ] && [ -n "$srcmd5" ]; then
874 if good_md5 "$i" && good_size "$i"; then
875 echo "$fp having proper md5sum already exists"
879 url=$(distfiles_url "$i")
880 url_attic=$(distfiles_attic_url "$i")
882 # is $url local file?
883 if [[ "$url" = [./]* ]]; then
884 update_shell_title "${GETLOCAL%% *}: $url"
885 ${GETLOCAL} $url $target
887 if [ -z "$NOMIRRORS" ]; then
888 url="`find_mirror "$url"`"
890 update_shell_title "${GETURI%% *}: $url"
891 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
892 if [ "`echo $url | grep -E 'ftp://'`" ]; then
893 update_shell_title "${GETURI2%% *}: $url"
894 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
899 if [ ! -s "$target" ]; then
901 if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then
902 update_shell_title "${GETLOCAL%% *}: $url_attic"
903 ${GETLOCAL} $url_attic $target
905 if [ -z "$NOMIRRORS" ]; then
906 url_attic="`find_mirror "$url_attic"`"
908 update_shell_title "${GETURI%% *}: $url_attic"
909 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
910 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
911 update_shell_title "${GETURI2%% *}: $url_attic"
912 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
917 if [ -s "$target" ]; then
923 elif [ "$NOCVS" != "yes" -a -z "$srcmd5" ]; then
924 if [ $# -gt 1 ]; then
925 get_files_cvs="$get_files_cvs $fp"
926 update_shell_title "$fp (will cvs up later)"
933 if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then
934 if [ -z "$NOMIRRORS" ]; then
935 im="`find_mirror "$i"`"
939 update_shell_title "${GETURI%% *}: $im"
941 if [ "`echo $im | grep -E 'ftp://'`" ]; then
942 update_shell_title "${GETURI2%% *}: $im"
947 if [ "$cvsup" = 1 ]; then
953 # the md5 check must be moved elsewhere as if we've called from update_md5 the md5 is wrong.
954 if [ ! -f "$fp" -a "$FAIL_IF_NO_SOURCES" != "no" ]; then
955 Exit_error err_no_source_in_repo $i;
958 # we check md5 here just only to refetch immediately
959 if good_md5 "$i" && good_size "$i"; then
961 elif [ "$FROM_DISTFILES" = 1 ]; then
962 # wrong md5 from distfiles: remove the file and try again
964 echo "MD5 sum mismatch. Trying full fetch."
967 update_shell_title "${GETURI%% *}: $url"
968 ${GETURI} ${OUTFILEOPT} "$target" "$url" || \
969 if [ "`echo $url | grep -E 'ftp://'`" ]; then
970 update_shell_title "${GETURI2%% *}: $url"
971 ${GETURI2} ${OUTFILEOPT} "$target" "$url"
973 if [ ! -s "$target" ]; then
975 update_shell_title "${GETURI%% *}: $url_attic"
976 ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \
977 if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then
978 update_shell_title "${GETURI2%% *}: $url_attic"
979 ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic"
982 test -s "$target" || rm -f "$target"
985 SHELL_TITLE_PREFIX=""
987 if [ "$get_files_cvs" ]; then
991 if [ "$CHMOD" = "yes" ]; then
992 CHMOD_FILES="`nourl "$@"`"
993 if [ -n "$CHMOD_FILES" ]; then
994 chmod $CHMOD_MODE $CHMOD_FILES
1001 if [ -n "$DEBUG" ]; then
1006 # Check whether first character of PACKAGE_NAME is legal for tag name
1007 if [ -z "${PACKAGE_NAME##[_0-9]*}" -a -z "$TAG_PREFIX" ]; then
1010 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"`
1011 # Remove #kernel.version_release from TAGVER because tagging sources
1012 # could occur with different kernel-headers than kernel-headers used at build time.
1013 TAGVER=$(echo "$TAGVER" | sed -e 's/#.*//g')
1021 if [ -n "$DEBUG" ]; then
1026 echo "Version: $PACKAGE_VERSION"
1027 echo "Release: $PACKAGE_RELEASE"
1029 TAGVER=`make_tagver`
1031 if [ "$TAG_VERSION" = "yes" ]; then
1032 echo "CVS tag: $TAGVER"
1034 if [ -n "$TAG" ]; then
1035 echo "CVS tag: $TAG"
1038 local OPTIONS="tag -F"
1039 if [ -n "$CVSROOT" ]; then
1040 OPTIONS="-d $CVSROOT $OPTIONS"
1045 for i in $TAG_FILES; do
1046 # don't tag files stored on distfiles
1047 [ -n "`src_md5 $i`" ] && continue
1048 local fp=`nourl "$i"`
1049 if [ -f "$fp" ]; then
1050 tag_files="$tag_files $fp"
1052 Exit_error err_no_source_in_repo $i
1056 if [ "$tag_files" ]; then
1057 if [ "$TAG_VERSION" = "yes" ]; then
1058 update_shell_title "tag sources: $TAGVER"
1059 cvs $OPTIONS $TAGVER $tag_files
1061 if [ -n "$TAG" ]; then
1062 update_shell_title "tag sources: $TAG"
1063 cvs $OPTIONS $TAG $tag_files
1068 if [ "$TAG_VERSION" = "yes" ]; then
1069 update_shell_title "tag spec: $TAGVER"
1070 cvs $OPTIONS $TAGVER $SPECFILE
1072 if [ -n "$TAG" ]; then
1073 update_shell_title "tag spec: $TAG"
1074 cvs $OPTIONS $TAG $SPECFILE
1081 echo "CVS branch tag: $TAG"
1086 if [ -n "$DEBUG" ]; then
1091 if [ $# -gt 0 ]; then
1093 local OPTIONS="tag -b"
1094 if [ -n "$CVSROOT" ]; then
1095 OPTIONS="-d $CVSROOT $OPTIONS"
1099 for i in $TAG_FILES; do
1100 local fp=`nourl "$i"`
1101 if [ -f "$fp" ]; then
1102 tag_files="$tag_files $fp"
1104 Exit_error err_no_source_in_repo $i
1107 if [ "$tag_files" ]; then
1108 cvs $OPTIONS $TAG $tag_files
1112 cvs $OPTIONS $TAG $SPECFILE
1120 update_shell_title "build_package"
1121 if [ -n "$DEBUG" ]; then
1128 if [ -n "$TRY_UPGRADE" ]; then
1129 update_shell_title "build_package: try_upgrade"
1130 if [ -n "$FLOAT_VERSION" ]; then
1131 TNOTIFY=`./pldnotify.awk $SPECFILE -n` || exit 1
1133 TNOTIFY=`./pldnotify.awk $SPECFILE` || exit 1
1136 TNEWVER=`echo $TNOTIFY | awk '{ match($4,/\[NEW\]/); print $5 }'`
1138 if [ -n "$TNEWVER" ]; then
1139 TOLDVER=`echo $TNOTIFY | awk '{ print $3; }'`
1140 echo "New version found, updating spec file to version " $TNEWVER
1141 cp -f $SPECFILE $SPECFILE.bak
1143 eval "perl -pi -e 's/Version:\t"$TOLDVER"/Version:\t"$TNEWVER"/gs' $SPECFILE"
1144 eval "perl -pi -e 's/Release:\t[1-9]{0,4}/Release:\t0.1/' $SPECFILE"
1146 NODIST="yes" UPDATE5="yes" get_files $SOURCES $PATCHES;
1147 unset TOLDVER TNEWVER TNOTIFY
1154 BUILD_SWITCH="-ba" ;;
1156 BUILD_SWITCH="-bb" ;;
1158 BUILD_SWITCH="-bs --nodeps" ;;
1160 BUILD_SWITCH="-bp --nodeps" ;;
1163 update_shell_title "build_package: $COMMAND"
1164 if [ -n "$LOGFILE" ]; then
1165 LOG=`eval echo $LOGFILE`
1166 if [ -d "$LOG" ]; then
1167 echo "Log file $LOG is a directory."
1168 echo "Parse error in the spec?"
1169 Exit_error err_build_fail;
1171 if [ -n "$LASTLOG_FILE" ]; then
1172 echo "LASTLOG=$LOG" > $LASTLOG_FILE
1174 RES_FILE=~/tmp/$RPMBUILD-exit-status.$RANDOM
1175 (time eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE; echo $? > $RES_FILE) 2>&1 |tee $LOG
1176 RETVAL=`cat $RES_FILE`
1178 if [ -n "$LOGDIROK" ] && [ -n "$LOGDIRFAIL" ]; then
1179 if [ "$RETVAL" -eq "0" ]; then
1186 eval ${NICE_COMMAND} $RPMBUILD $BUILD_SWITCH -v $QUIET $CLEAN $RPMOPTS $RPMBUILDOPTS $BCOND $TARGET_SWITCH $SPECFILE
1189 if [ "$RETVAL" -ne "0" ]; then
1190 if [ -n "$TRY_UPGRADE" ]; then
1191 echo "\n!!! Package with new version cannot be built automagically\n"
1192 mv -f $SPECFILE.bak $SPECFILE
1194 Exit_error err_build_fail;
1201 echo "$@" | sed 's#\<\(ftp\|http\|https\|cvs\|svn\)://[^ ]*/##g'
1204 install_required_packages()
1211 # taken from find-spec-bcond, but with just getting the list
1213 # quick revert hint: '$RPMBUILD --bcond $SPEC'
1215 /^%changelog/ { exit }
1216 /_with(out)?_[_a-zA-Z0-9]+/{
1217 match($0, /_with(out)?_[_a-zA-Z0-9]+/);
1218 print substr($0, RSTART, RLENGTH);
1221 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
1222 bcond = substr($0, RSTART +5 , RLENGTH -5);
1223 gsub(/[ \t]+/,"_",bcond);
1225 }' $SPEC | LC_ALL=C sort -u
1230 update_shell_title "set bcond values"
1232 AVAIL_BCONDS_WITHOUT=""
1233 AVAIL_BCONDS_WITH=""
1234 if `grep -q ^%bcond ${SPECFILE}`; then
1236 elif `egrep -q ^#\ *_with ${SPECFILE}`; then
1242 local bcond_avail=$(find_spec_bcond $SPECFILE)
1244 # expand bconds from ~/.bcondrc
1245 # The file structure is like gentoo's package.use:
1248 # samba -mysql -pgsql
1249 # w32codec-installer license_agreement
1252 if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
1253 SN=${SPECFILE%%\.spec}
1255 local bcondrc=$HOME/.bcondrc
1256 [ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ] && bcondrc=$HOME_ETC/.bcondrc
1258 while read pkg flags; do
1260 [[ "$pkg" == \#* ]] && continue
1262 # any package or current package?
1263 if [ "$pkg" = "*" ] || [ "$pkg" = "$PACKAGE_NAME" ] || [ "$pkg" = "$SN" ]; then
1264 for flag in $flags; do
1265 local opt=${flag#[+-]}
1267 # use only flags which are in this package.
1268 if [[ $bcond_avail = *${opt}* ]]; then
1269 if [[ $flag = -* ]]; then
1270 BCOND="$BCOND --without $opt"
1272 BCOND="$BCOND --with $opt"
1278 update_shell_title "parse ~/.bcondrc: DONE!"
1281 update_shell_title "parse bconds"
1282 case "${BCOND_VERSION}" in
1287 echo "Warning: This spec has old style bconds. Fix it || die."
1288 for opt in `echo "$bcond_avail" | grep ^_without_`
1290 AVAIL_BCOND_WITHOUT=${opt#_without_}
1291 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1292 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1294 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1298 for opt in `echo "$bcond_avail" | grep ^_with_`
1300 AVAIL_BCOND_WITH=${opt#_with_}
1301 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1302 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1304 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1309 local cond_type="" # with || without
1310 for opt in $bcond_avail; do
1319 AVAIL_BCOND_WITHOUT=${opt#_without_}
1320 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1321 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1323 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1327 AVAIL_BCOND_WITH=${opt#_with_}
1328 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1329 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1331 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1335 case "$cond_type" in
1338 AVAIL_BCOND_WITH="$opt"
1339 if [[ "$BCOND" = *--with?${AVAIL_BCOND_WITH}* ]]; then
1340 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH <$AVAIL_BCOND_WITH>"
1342 AVAIL_BCONDS_WITH="$AVAIL_BCONDS_WITH $AVAIL_BCOND_WITH"
1347 AVAIL_BCOND_WITHOUT="$opt"
1348 if [[ "$BCOND" = *--without?${AVAIL_BCOND_WITHOUT}* ]]; then
1349 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT <$AVAIL_BCOND_WITHOUT>"
1351 AVAIL_BCONDS_WITHOUT="$AVAIL_BCONDS_WITHOUT $AVAIL_BCOND_WITHOUT"
1365 update_shell_title "run_sub_builder $package_name"
1367 # No i tutaj bym chcia³ zrobiæ sztuczn± inteligencjê, która spróbuje tego
1368 # pakieta zbudowaæ. Aktualnie niewiele dziala, bo generalnie nie widze do
1369 # konca algorytmu... Ale damy rade. :) Na razie po prostu sie wyjebie tak samo
1370 # jakby nie bylo tego kawalka kodu.
1372 # Update: Poprawi³em parê rzeczy i zaczê³o generowaæ pakiety spoza zadanej listy.
1373 # Jednym s³owem budowanie niespoldkowanych zale¿no¶ci dzia³a w paru przypadkach.
1380 # Istnieje taki spec? ${package}.spec
1381 if [ -f "${SPECS_DIR}/${package}.spec" ]; then
1382 parent_spec_name=${package}.spec
1383 elif [ -f "${SPECS_DIR}/`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec" ]; then
1384 parent_spec_name="`echo ${package_name} | sed -e s,-devel.*,,g -e s,-static,,g`.spec"
1386 for provides_line in `grep ^Provides:.*$package ${SPECS_DIR} -R`
1392 if [ "${parent_spec_name}" != "" ]; then
1393 spawn_sub_builder $parent_spec_name
1395 NOT_INSTALLED_PACKAGES="$NOT_INSTALLED_PACKAGES $package_name"
1401 update_shell_title "spawn_sub_builder $package_name"
1404 if [ "${FETCH_BUILD_REQUIRES}" == "yes" ]; then
1405 sub_builder_opts="${sub_builder_opts} -R"
1407 if [ "${REMOVE_BUILD_REQUIRES}" == "nice" ]; then
1408 sub_builder_opts="${sub_builder_opts} -RB"
1409 elif [ "${REMOVE_BUILD_REQUIRES}" == "force" ]; then
1410 sub_builder_opts="${sub_builder_opts} -FRB"
1412 if [ "${UPDATE_POLDEK_INDEXES}" == "yes" ]; then
1413 sub_builder_opts="${sub_builder_opts} -Upi"
1417 ./builder ${sub_builder_opts} "$@"
1420 remove_build_requires()
1422 if [ "$INSTALLED_PACKAGES" != "" ]; then
1423 case "$REMOVE_BUILD_REQUIRES" in
1425 run_poldek --noask -ve $INSTALLED_PACKAGES
1428 run_poldek --ask -ve $INSTALLED_PACKAGES
1431 echo You may want to manually remove following BuildRequires fetched:
1432 echo $INSTALLED_PACKAGES
1433 echo Try poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`
1441 if [ "$AVAIL_BCONDS_WITH" != "" ] || [ "$AVAIL_BCONDS_WITHOUT" != "" ]; then
1442 if [ "$BCOND" != "" ]; then
1443 echo -ne "\nBuilding $SPECFILE with the following conditional flags:\n"
1446 echo -ne "\nNo conditional flags passed"
1448 echo -ne "\n\nfrom available:\n"
1449 echo -ne "--with :\t$AVAIL_BCONDS_WITH\n--without:\t$AVAIL_BCONDS_WITHOUT\n\n"
1455 if [ "$NOCVSSPEC" != "yes" ]; then
1456 echo -ne "Available branches: "
1457 cvs status -v "${SPECFILE}" | awk '!/Sticky Tag:/ && /\(branch:/ { print $1 } ' | xargs
1461 # checks a given list of packages/files/provides agains current rpmdb.
1462 # outputs all dependencies whcih current rpmdb doesn't satisfy.
1463 # input can be either STDIN or parameters
1468 if [ "$#" -gt 0 ]; then
1474 DEPS=$(rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
1477 echo "$DEPS" | awk '/^no package provides/ { print $NF }'
1479 # other deps (files)
1480 echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
1483 # checks if given package/files/provides exists in rpmdb.
1484 # inout can be either stdin or parameters
1485 # returns packages wchi hare present in the rpmdb
1490 if [ "$#" -gt 0 ]; then
1496 rpm -q --whatprovides $DEPS 2>/dev/null | awk '!/no package provides/ { print }'
1499 fetch_build_requires()
1501 if [ "${FETCH_BUILD_REQUIRES}" = "yes" ]; then
1502 update_shell_title "fetch build requires"
1503 if [ "$FETCH_BUILD_REQUIRES_RPMGETDEPS" = "yes" ]; then
1504 local CONF=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\-/ { print $3 } ' | _rpm_cnfl_check | xargs)
1505 local DEPS=$(rpm-getdeps $BCOND $SPECFILE 2> /dev/null | awk '/^\+/ { print $3 } ' | _rpm_prov_check | xargs)
1507 update_shell_title "poldek: update indexes"
1508 if [ -n "$CONF" ] || [ -n "$DEPS" ]; then
1509 $SU_SUDO /usr/bin/poldek -q --update || $SU_SUDO /usr/bin/poldek -q --upa
1511 if [ -n "$CONF" ]; then
1512 update_shell_title "uninstall conflicting packages: $CONF"
1513 echo "Trying to uninstall conflicting packages ($CONF):"
1514 $SU_SUDO /usr/bin/poldek --noask --nofollow -ev $CONF
1517 while [ "$DEPS" ]; do
1518 update_shell_title "install deps: $DEPS"
1519 echo "Trying to install dependencies ($DEPS):"
1520 local log=.${SPECFILE}_poldek.log
1521 $SU_SUDO /usr/bin/poldek --caplookup -uGq $DEPS | tee $log
1522 failed=$(awk -F: '/^error:/{print $2}' $log)
1525 if [ -n "$failed" ]; then
1526 for package in $failed; do
1527 # FIXME: sanitise, deps could be not .spec files
1528 spawn_sub_builder -bb $package && ok="$ok $package"
1538 echo -ne "\nAll packages installed by fetch_build_requires() are written to:\n"
1539 echo -ne "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES\n"
1540 echo -ne "\nIf anything fails, you may get rid of them by executing:\n"
1541 echo "poldek -e \`cat `pwd`/.${SPECFILE}_INSTALLED_PACKAGES\`\n\n"
1542 echo > `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1543 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`
1545 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`"
1547 package=`basename "$package_item"|sed -e "s/}$//g"`
1548 COND_ARCH_TST="`cat $SPECFILE|grep -B1 BuildRequires|grep -B1 $package|grep ifarch|sed -e "s/^.*ifarch//g"`"
1551 COND_TST=`cat $SPECFILE|grep BuildRequires|grep "$package"`
1552 if `echo $COND_TST|grep -q '^BuildRequires:'`; then
1553 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
1558 COND_NAME=`echo $COND_TST|sed -e s,:BuildRequires:.*$,,g`
1561 if `echo $COND_TST|grep -q 'without_'`; then
1562 COND_NAME=`echo $COND_NAME|sed -e s,^.*without_,,g`
1563 if `echo $COND_TST|grep -q !`; then
1568 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1569 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1570 if [ -n "$COND_WITHOUT" ] || [ -z "$COND_WITH" ]; then
1576 elif `echo $COND_TST|grep -q 'with_'`; then
1577 COND_NAME=`echo $COND_NAME|sed -e s,^.*with_,,g`
1578 if `echo $COND_TST|grep -q !`; then
1583 COND_WITH=`echo $AVAIL_BCONDS_WITH|grep "<$COND_NAME>"`
1584 COND_WITHOUT=`echo $AVAIL_BCONDS_WITHOUT|grep "<$COND_NAME>"`
1585 if [ -n "$COND_WITH" ] || [ -z "$COND_WITHOUT" ]; then
1591 RESULT="${COND_STATE}-${COND_ARGV}"
1593 "with-wout" | "wout-with" )
1596 "wout-wout" | "with-with" )
1600 echo "Action '$RESULT' was not defined for package '$package_item'"
1606 if [ "$GO" = "yes" ]; then
1607 if [ "`rpm -q $package|sed -e "s/$package.*/$package/g"`" != "$package" ]; then
1608 echo "Testing if $package has subrequirements..."
1609 run_poldek -t -i $package --dumpn=".$package-req.txt"
1610 if [ -f ".$package-req.txt" ]; then
1611 for package_name in `cat ".$package-req.txt"|grep -v ^#`
1613 if [ "$package_name" = "$package" ]; then
1614 echo -ne "Installing BuildRequired package:\t$package_name\n"
1615 update_shell_title "Installing BuildRequired package: ${package_name}"
1616 install_required_packages $package;
1618 echo -ne "Installing (sub)Required package:\t$package_name\n"
1619 update_shell_title "Installing (sub)Required package: ${package_name}"
1620 install_required_packages $package_name;
1624 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1625 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1628 echo "Attempting to run spawn sub - builder..."
1629 echo -ne "Package installation failed:\t$package_name\n"
1630 run_sub_builder $package_name
1631 if [ $? -eq 0 ]; then
1632 install_required_packages $package_name;
1635 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1636 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1639 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1646 rm -f ".$package-req.txt"
1648 echo "Attempting to run spawn sub - builder..."
1649 echo -ne "Package installation failed:\t$package\n"
1650 run_sub_builder $package
1651 if [ $? -eq 0 ]; then
1652 install_required_packages $package;
1655 INSTALLED_PACKAGES="$package_name $INSTALLED_PACKAGES"
1656 echo $package_name >> `pwd`/.${SPECFILE}_INSTALLED_PACKAGES
1659 NOT_INSTALLED_PACKAGES="$package_name $NOT_INSTALLED_PACKAGES"
1665 echo "Package $package is already installed. BuildRequirement satisfied."
1669 if [ "$NOT_INSTALLED_PACKAGES" != "" ]; then
1670 echo "Unable to install following packages and their dependencies:"
1671 for pkg in "$NOT_INSTALLED_PACKAGES"
1675 remove_build_requires
1683 TOP_DIR="`eval $RPM $RPMOPTS --eval '%{_topdir}'`"
1684 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"
1686 mkdir -p $TOP_DIR/{RPMS,BUILD,SRPMS}
1688 cvs -d $CVSROOT co SOURCES/.cvsignore SPECS/{mirrors,adapter{,.awk},fetchsrc_request,builder,repackage.sh}
1692 echo "To checkout *all* .spec files:"
1693 echo "- remove $SPECS_DIR/CVS/Entries.Static"
1694 echo "- run cvs up in $SPECS_DIR dir"
1697 echo "To commit with your developer account:"
1698 echo "- edit $SPECS_DIR/CVS/Root"
1699 echo "- edit $SOURCE_DIR/CVS/Root"
1702 #---------------------------------------------
1705 if [ "$#" = 0 ]; then
1714 COMMAND="update_md5";
1720 COMMAND="update_md5";
1731 DEBUG="yes"; shift ;;
1733 COMMAND="version"; shift ;;
1735 CVSROOT=":pserver:cvs@$CVS_SERVER:/cvsroot"; shift ;;
1736 -b | -ba | --build )
1737 COMMAND="build"; shift ;;
1738 -bb | --build-binary )
1739 COMMAND="build-binary"; shift ;;
1740 -bs | --build-source )
1741 COMMAND="build-source"; shift ;;
1742 -bp | --build-prep )
1743 COMMAND="build-prep"; shift ;;
1745 COMMAND="branch"; shift; TAG="${1}"; shift;;
1747 CLEAN="--clean --rmspec --rmsource"; shift ;;
1749 shift; CVSROOT="${1}"; shift ;;
1751 COMMAND="get"; shift ;;
1753 COMMAND="usage"; shift ;;
1755 PROTOCOL="http"; shift ;;
1757 shift; LOGFILE="${1}"; shift ;;
1759 shift; DEF_NICE_LEVEL=${1}; shift ;;
1760 -ske | --skip-existing-files)
1761 SKIP_EXISTING_FILES="yes"; shift ;;
1763 COMMAND="mr-proper"; shift ;;
1765 NOCVS="yes"; shift ;;
1766 -ncs | --no-cvs-specs )
1767 NOCVSSPEC="yes"; shift ;;
1768 -nd | --no-distfiles )
1769 NODIST="yes"; shift ;;
1770 -nm | --no-mirrors )
1771 NOMIRRORS="yes"; shift ;;
1773 NOURLS="yes"; shift ;;
1775 NOSRCS="yes"; shift ;;
1776 -ns0 | --no-source0 )
1777 NOSOURCE0="yes"; shift ;;
1791 shift; RPMOPTS="$RPM_OPTS ${1}"; shift ;;
1793 shift; RPMOPTS="${RPMOPTS} --define \"patch${1} : ignoring patch${1}; exit 1; \""; shift ;;
1794 --with | --without )
1795 case $GROUP_BCONDS in
1799 while ! `echo ${1}|grep -qE '(^-|spec)'`
1801 BCOND="$BCOND $COND $1"
1805 if [[ "$2" = *,* ]]; then
1806 for a in $(echo "$2" | tr , ' '); do
1807 BCOND="$BCOND $1 $a"
1810 BCOND="$BCOND $1 $2"
1816 shift; TARGET="${1}"; shift ;;
1818 TARGET=$(echo "${1}" | sed 's/^--target=//'); shift ;;
1820 QUIET="--quiet"; shift ;;
1822 CVSDATE="${2}"; shift 2 ;;
1824 shift; CVSTAG="${1}"; shift ;;
1825 -R | --fetch-build-requires)
1826 FETCH_BUILD_REQUIRES="yes"
1827 NOT_INSTALLED_PACKAGES=
1829 -RB | --remove-build-requires)
1830 REMOVE_BUILD_REQUIRES="nice"
1832 -FRB | --force-remove-build-requires)
1833 REMOVE_BUILD_REQUIRES="force"
1835 -sd | --sources-distfiles)
1836 COMMAND="list-sources-distfiles"
1838 -sdp | --sources-distfiles-paths)
1839 COMMAND="list-sources-distfiles-paths"
1841 -sf | --sources-files)
1842 COMMAND="list-sources-files"
1844 -sp | --sources-paths)
1845 COMMAND="list-sources-local-paths"
1847 -su | --sources-urls)
1848 COMMAND="list-sources-urls"
1850 -Tvs | --tag-version-stable )
1855 -Ts | --tag-stable )
1860 -Tv | --tag-version )
1865 -Tp | --tag-prefix )
1877 -ir | --integer-release-only )
1878 INTEGER_RELEASE="yes"
1881 COMMAND="update_md5"
1887 -Upi | --update-poldek-indexes )
1888 UPDATE_POLDEK_INDEXES="yes"
1891 COMMAND="init_rpm_dir";
1893 -u | --try-upgrade )
1894 TRY_UPGRADE="1"; shift ;;
1895 -un | --try-upgrade-with-float-version )
1896 TRY_UPGRADE="1"; FLOAT_VERSION="1"; shift ;;
1898 BE_VERBOSE="1"; shift ;;
1904 RPMOPTS="${RPMOPTS} --define \"${MACRO} ${VALUE}\""
1906 --show-bconds | -show-bconds | -print-bconds | --print-bconds | -display-bconds | --display-bconds )
1912 RPMOPTS="${RPMOPTS} --nodeps"
1915 RPMBUILDOPTS="${RPMBUILDOPTS} -debug"; shift ;;
1918 # check if specname was passed as specname:cvstag
1919 if [ "${SPECFILE##*:}" != "${SPECFILE}" ]; then
1920 CVSTAG="${SPECFILE##*:}";
1921 SPECFILE="${SPECFILE%%:*}";
1927 if [ -n "$DEBUG" ]; then
1932 if [ -n "$TARGET" ]; then
1935 TARGET_SWITCH="--target $TARGET" ;;
1937 TARGET_SWITCH="--target=$TARGET" ;;
1941 if [ "$SCHEDTOOL" != "no" ]; then
1942 NICE_COMMAND="$SCHEDTOOL"
1944 NICE_COMMAND="nice -n ${DEF_NICE_LEVEL}"
1947 update_shell_title "$COMMAND"
1949 "build" | "build-binary" | "build-source" | "build-prep" )
1951 if [ -n "$SPECFILE" ]; then
1957 [ X"$SHOW_BCONDS" = X"yes" ] && exit 0
1958 fetch_build_requires;
1959 if [ "$INTEGER_RELEASE" = "yes" ]; then
1960 echo "Checking release $PACKAGE_RELEASE..."
1961 if echo $PACKAGE_RELEASE | grep -q '^[^.]*\.[^.]*$' 2>/dev/null ; then
1962 Exit_error err_fract_rel "$PACKAGE_RELEASE"
1966 if [ -n "$TEST_TAG" ]; then
1967 TAGVER=`make_tagver`
1968 echo "Searching for tag $TAGVER..."
1969 TAGREL=$(cvs status -v $SPECFILE | grep -E "^[[:space:]]*${TAGVER}[[[:space:]]" | sed -e 's#.*(revision: ##g' -e 's#).*##g')
1970 if [ -n "$TAGREL" ]; then
1971 Exit_error err_tag_exists "$TAGVER" "$TAGREL"
1974 # - do not allow to build from HEAD when XX-branch exists
1975 TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto-\([a-zA-Z]\+\)-.*#\1#g')
1976 if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
1977 TAG_BRANCH="${TREE_PREFIX}-branch"
1978 TAG_STATUS=$(cvs status -v $SPECFILE | grep -Ei "${TAG_BRANCH}.+(branch: [0-9.]+)")
1979 if [ -n "$TAG_STATUS" -a "$CVSTAG" = "HEAD" ]; then
1980 Exit_error err_branch_exists "$TAG_STATUS"
1985 if [ -n "$NOSOURCE0" ] ; then
1986 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
1988 get_files $SOURCES $PATCHES
1991 if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
1992 run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
1994 remove_build_requires;
1996 Exit_error err_no_spec_in_cmdl;
2001 if [ -n "$SPECFILE" ]; then
2004 get_files $SOURCES $PATCHES
2006 branch_files $TAG $SOURCES $PATCHES $ICONS
2008 Exit_error err_no_spec_in_cmdl;
2013 if [ -n "$SPECFILE" ]; then
2017 if [ -n "$NOSOURCE0" ] ; then
2018 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2020 get_files $SOURCES $PATCHES
2023 Exit_error err_no_spec_in_cmdl;
2028 if [ -n "$SPECFILE" ]; then
2032 if [ -n "$NOSOURCE0" ] ; then
2033 SOURCES=`echo $SOURCES | xargs | sed -e 's/[^ ]*//'`
2037 Exit_error err_no_spec_in_cmdl;
2044 if [ -n "$SPECFILE" ]; then
2048 # don't fetch sources from remote locations
2050 for file in $SOURCES; do
2051 [ -n "`src_md5 $file`" ] && continue
2052 new_SOURCES="$new_SOURCES $file"
2054 SOURCES="$new_SOURCES"
2055 get_files $SOURCES $PATCHES
2057 tag_files $SOURCES $PATCHES $ICONS
2059 Exit_error err_no_spec_in_cmdl;
2063 $RPM --clean --rmsource --rmspec --force --nodeps $SPECFILE
2065 "list-sources-files" )
2068 DONT_PRINT_REVISION="yes"
2071 for SAP in $SOURCES $PATCHES; do
2072 echo $SAP | awk '{gsub(/.*\//,"") ; print}'
2075 "list-sources-urls" )
2078 DONT_PRINT_REVISION="yes"
2081 SAPS="$SOURCES $PATCHES"
2082 for SAP in $SAPS ; do
2086 "list-sources-local-paths" )
2089 DONT_PRINT_REVISION="yes"
2092 for SAP in $SOURCES $PATCHES; do
2093 echo $SOURCE_DIR/$(echo $SAP | awk '{gsub(/.*\//,"") ; print }')
2096 "list-sources-distfiles-paths" )
2099 DONT_PRINT_REVISION="yes"
2102 for SAP in $SOURCES $PATCHES; do
2103 if [ -n "$(src_md5 "$SAP")" ]; then
2104 distfiles_path "$SAP"
2108 "list-sources-distfiles" )
2111 DONT_PRINT_REVISION="yes"
2114 for SAP in $SOURCES $PATCHES; do
2115 if [ -n "$(src_md5 "$SAP")" ]; then
2116 distfiles_url "$SAP"
2128 if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then
2129 rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"
2133 # vi:syntax=sh:ts=4:sw=4:noet