Author: glen Date: Sun Feb 5 17:20:24 2006 GMT Module: SOURCES Tag: HEAD ---- Log message: - v0.14 from SPECS (r1.405)
---- Files affected: SOURCES: builder (1.12 -> 1.13) ---- Diffs: ================================================================ Index: SOURCES/builder diff -u SOURCES/builder:1.12 SOURCES/builder:1.13 --- SOURCES/builder:1.12 Tue Aug 23 21:39:34 2005 +++ SOURCES/builder Sun Feb 5 18:20:19 2006 @@ -16,17 +16,13 @@ # 100 - Unknown error (should not happen) # Notes (todo): -# - builder -u fetches current version first -# - tries to get new version from distfiles without new md5 -# - after fetching new version doesn't update md5 -# - doesn't get sources for specs with %include /usr/lib/rpm/macros.python -# when there's no rpm-pythonprov (rpm's fault, but it's ugly anyway) -# - as above with %include /usr/lib/rpm/macros.perl and no rpm-perlprov +# - builder -u fetches current version first (well that's okay, how you compare versions if you have no old spec?) # - when Icon: field is present, -5 and -a5 doesn't work +# - builder -R skips installing BR if spec is not present before builder invocation (need to run builder twice) VERSION="\ -Build package utility from PLD CVS repository -V 0.12 (C) 1999-2005 Free Penguins". +Build package utility from PLD Linux CVS repository +v0.14 (C) 1999-2006 Free Penguins". PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin" COMMAND="build" @@ -45,7 +41,6 @@ UPDATE5="" ADD5="" NO5="" -ADAPTERIZE="" ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"} CVSROOT="" @@ -91,6 +86,9 @@ FAIL_IF_NO_SOURCES="yes" +# let get_files skip over files which are present to get those damn files fetched +SKIP_EXISTING_FILES="no" + if [ -x /usr/bin/rpm-getdeps ]; then FETCH_BUILD_REQUIRES_RPMGETDEPS="yes" else @@ -123,6 +121,8 @@ [ -f "$USER_CFG" ] && . "$USER_CFG" +wget --help 2>&1 | grep -q ' \-\-no-check\-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate" + if [ -n "$USE_PROZILLA" ]; then GETURI="proz --no-getch -r -P ./ -t$WGET_RETRIES $PROZILLA_OPTS" GETURI2="$GETURI" @@ -134,7 +134,7 @@ else wget --help 2>&1 | grep -q ' \-\-inet ' && WGET_OPTS="$WGET_OPTS --inet" wget --help 2>&1 | grep -q ' \-\-retry\-connrefused ' && WGET_OPTS="$WGET_OPTS --retry-connrefused" - + GETURI="wget --passive-ftp -c -nd -t$WGET_RETRIES $WGET_OPTS" GETURI2="wget -c -nd -t$WGET_RETRIES $WGET_OPTS" OUTFILEOPT="-O" @@ -186,11 +186,10 @@ [-Tvs|--tag-version-stable] [-Tvn|--tag-version-nest] [-Ts|--tag-stable] [-Tn|--tag-nest] [-Tv|--tag-version] [{-Tp|--tag-prefix} <prefix>] [{-tt|--test-tag}] -[-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] -[--with/--without <feature>] [--define <macro> <value>] <package>[.spec] +[-nu|--no-urls] [-v|--verbose] [--opts <rpm opts>] [--show-bconds] +[--with/--without <feature>] [--define <macro> <value>] <package>[.spec][:cvstag] -5, --update-md5 - update md5 comments in spec, implies -nd -ncs ---adapter[ize] - run adapter.awk on SPECFILE -a5, --add-md5 - add md5 comments to URL sources, implies -nc -nd -ncs -n5, --no-md5 - ignore md5 comments in spec -D, --debug - enable builder script debugging mode, @@ -201,9 +200,12 @@ from <package>.spec, -bb, --build-binary - get all files from CVS repo or HTTP/FTP and build binary only package from <package>.spec, +-bp, --build-prep - execute the %prep phase of <package>.spec, +-bc - reserved (not implemented) +-bi reserved (not implemented) -bs, --build-source - get all files from CVS repo or HTTP/FTP and only pack them into src.rpm, --bp, --build-prep - execute the %prep phase of <package>.spec, +--short-circuit - reserved (not implemented) -B, --branch - add branch -c, --clean - clean all temporarily created files (in BUILD, SOURCES, SPECS and \$RPM_BUILD_ROOT), @@ -229,6 +231,8 @@ -ns, --no-srcs - don't download Sources -ns0, --no-source0 - don't download Source0 -nn, --no-net - don't download anything from the net +-ske, +--skip-existing-files - skip existing files in get_files --opts <rpm opts> - additional options for rpm -q, --quiet - be quiet, --date yyyy-mm-dd - build package using resources from specified CVS date, @@ -248,6 +252,8 @@ -sp, --source-paths - list sources - filenames with full local paths (intended for offline operations; does not work when Icon field is present but icon file is absent), +-su, --source-urls - list urls - urls to sources and patches + intended for copying urls with spec with lots of macros in urls -T <cvstag> , --tag <cvstag> - add cvs tag <cvstag> for files, -Tvs, --tag-version-stable @@ -273,6 +279,10 @@ -U, --update - refetch sources, don't use distfiles, and update md5 comments -Upi, --update-poldek-indexes - refresh or make poldek package index files. +-np, --nopatch <patchnumber> + - don't apply <patchnumber> +--show-bconds - show available conditional builds, which can be used + - with --with and/or --without switches. --with/--without <feature> - conditional build package depending on %_with_<feature>/ %_without_<feature> macro switch. You may now use @@ -280,23 +290,109 @@ constructions. Set GROUP_BCONDS to yes to make use of it. --target <platform>, --target=<platform> - build for platform <platform>. +--init-rpm-dir - initialize ~/rpm directory structure " } +update_shell_title() { + [ -t 1 ] || return + local len=${COLUMNS:-80} + local msg=$(echo "$*" | cut -c-$len) + + if [ -n "$BE_VERBOSE" ]; then + echo >&2 "$(date +%s.%N) $*" + fi + + msg="builder[$SPECFILE] ${SHELL_TITLE_PREFIX:+$SHELL_TITLE_PREFIX }$msg" + case "$TERM" in + cygwin|xterm*) + echo >&2 -ne "\033]1;$msg\007\033]2;$msg\007" + ;; + screen*) + echo >&2 -ne "\033]0;$msg\007" + ;; + esac +} + +# set TARGET from BuildArch: from SPECFILE +set_spec_target() { + if [ -n "$SPECFILE" ] && [ -z "$TARGET" ]; then + tmp=$(awk '/^BuildArch:/ { print $NF}' $SPECFILE) + if [ "$tmp" ]; then + TARGET="$tmp" + case "$RPMBUILD" in + "rpmbuild") + TARGET_SWITCH="--target $TARGET" ;; + "rpm") + TARGET_SWITCH="--target=$TARGET" ;; + esac + fi + fi +} + cache_rpm_dump () { if [ -n "$DEBUG" ]; then set -x; set -v; fi -rpm_dump_cache=` + + update_shell_title "cache_rpm_dump" + local rpm_dump + rpm_dump=` + + # we reset macros not to contain macros.build as all the %() macros are + # executed here, while none of them are actually needed. + # what we need from dump is NAME, VERSION, RELEASE and PATCHES/SOURCES. + # at the time of this writing macros.build + macros contained 70 "%(...)" macros. + macrofiles="/usr/lib/rpm/macros:$SPECS_DIR/.rpmmacros:~/etc/.rpmmacros:~/.rpmmacros" + dump='%{echo:dummy: PACKAGE_NAME %{name} }%dump' + # FIXME: better ideas than .rpmrc? + printf 'include:/usr/lib/rpm/rpmrc\nmacrofiles:%s\n' $macrofiles > .rpmrc +# TODO: move these to /usr/lib/rpm/macros + cat > .rpmmacros <<'EOF' +%requires_releq_kernel_up %{nil} +%requires_releq_kernel_smp %{nil} +%requires_releq() %{nil} +%pyrequires_eq() %{nil} +%requires_eq() %{nil} +%requires_eq_to() %{nil} +%releq_kernel_up ERROR +%releq_kernel_smp ERROR +%kgcc_package ERROR +%_fontsdir ERROR +%ruby_version ERROR +%ruby_ver_requires_eq() %{nil} +%ruby_mod_ver_requires_eq() %{nil} +%__php_api_requires() %{nil} +%php_major_version ERROR +%php_api_version ERROR +%py_ver ERROR +EOF case "$RPMBUILD" in - rpm ) - rpm -bp --nodeps --define 'prep %dump' $BCOND $TARGET_SWITCH $SPECFILE 2>&1 - ;; - rpmbuild ) - rpmbuild --nodigest --nosignature --define 'prep %dump' $BCOND $SPECFILE 2>&1 - ;; - esac` + rpm) + ARGS='-bp' + ;; + rpmbuild) + ARGS='--nodigest --nosignature --nobuild' + ;; + esac + $RPMBUILD --rcfile .rpmrc $ARGS --nodeps --define "prep $dump" $BCOND $TARGET_SWITCH $SPECFILE 2>&1 + ` + if [ $? -gt 0 ]; then + error=$(echo "$rpm_dump" | sed -ne '/^error:/,$p') + echo "$error" >&2 + Exit_error err_build_fail; + fi + + # make small dump cache + rpm_dump_cache=`echo "$rpm_dump" | awk ' + $2 ~ /^SOURCEURL/ {print} + $2 ~ /^PATCHURL/ {print} + $2 ~ /^nosource/ {print} + $2 ~ /^PACKAGE_/ {print} + '` + + update_shell_title "cache_rpm_dump: OK!" } rpm_dump () { @@ -306,36 +402,44 @@ echo "$rpm_dump_cache" } +get_icons() +{ + update_shell_title "get icons" + ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`" + if [ -z "$ICONS" ]; then + return + fi + + rpm_dump_cache="böö" NODIST="yes" UPDATE5= get_files $ICONS +} + parse_spec() { + update_shell_title "parsing specfile" if [ -n "$DEBUG" ]; then set -x; set -v; fi - cd $SPECS_DIR + # icons are needed for successful spec parse + get_icons; + cd $SPECS_DIR cache_rpm_dump if [ "$NOSRCS" != "yes" ]; then SOURCES="`rpm_dump | awk '/SOURCEURL[0-9]+/ {print $3}'`" fi + if (rpm_dump | grep -qEi ":.*nosource.*1"); then FAIL_IF_NO_SOURCES="no" fi PATCHES="`rpm_dump | awk '/PATCHURL[0-9]+/ {print $3}'`" ICONS="`awk '/^Icon:/ {print $2}' ${SPECFILE}`" - PACKAGE_NAME="`$RPM -q --qf '%{NAME}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`" - PACKAGE_VERSION="`$RPM -q --qf '%{VERSION}\n' --specfile ${SPECFILE} 2> /dev/null| head -n 1`" - PACKAGE_RELEASE="`$RPM -q --qf '%{RELEASE}\n' --specfile ${SPECFILE} 2> /dev/null | head -n 1`" - -# These variables may be unset after first cache_rpm_dump call -# (because of not-yet-retrieved icon file) -# -# if [ -z "$PACKAGE_NAME" -o -z "$PACKAGE_VERSION" -o -z "$PACKAGE_RELEASE" ]; then -# Exit_error err_no_package_data; -# fi + PACKAGE_NAME=$(rpm_dump | awk '$2 == "PACKAGE_NAME" { print $3}') + PACKAGE_VERSION=$(rpm_dump | awk '$2 == "PACKAGE_VERSION" { print $3}') + PACKAGE_RELEASE=$(rpm_dump | awk '$2 == "PACKAGE_RELEASE" { print $3}') if [ -n "$BE_VERBOSE" ]; then echo "- Sources : `nourl $SOURCES`" @@ -353,6 +457,8 @@ echo "- Version : $PACKAGE_VERSION" echo "- Release : $PACKAGE_RELEASE" fi + + update_shell_title "parse_spec: OK!" } Exit_error() @@ -393,6 +499,10 @@ remove_build_requires echo "Release ${2} not integer and not a snapshot."; exit 10 ;; + "err_branch_exists" ) + remove_build_requires + echo "Tree branch already exists (${2})."; + exit 11 ;; esac echo "Unknown error." @@ -406,64 +516,36 @@ set -v; fi - SOURCE_DIR="`$RPM --eval '%{_sourcedir}'`" - SPECS_DIR="`$RPM --eval '%{_specdir}'`" + SOURCE_DIR="`eval $RPM $RPMOPTS --eval '%{_sourcedir}'`" + SPECS_DIR="`eval $RPM $RPMOPTS --eval '%{_specdir}'`" __PWD="`pwd`" } get_spec() { + + update_shell_title "get_spec" + if [ -n "$DEBUG" ]; then set -x; set -v; fi cd "$SPECS_DIR" - if [ \! -f "$SPECFILE" ]; then + if [ ! -f "$SPECFILE" ]; then SPECFILE="`basename $SPECFILE .spec`.spec"; fi if [ "$NOCVSSPEC" != "yes" ]; then - OPTIONS="up " - if [ -n "$CVSROOT" ]; then - OPTIONS="-d $CVSROOT $OPTIONS" - else - if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then - echo "warning: No cvs access defined - using local .spec file" - NOCVSSPEC="yes" - fi - fi - - if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then - OPTIONS="$OPTIONS -A" - else - if [ -n "$CVSDATE" ]; then - OPTIONS="$OPTIONS -D $CVSDATE" - fi - if [ -n "$CVSTAG" ]; then - OPTIONS="$OPTIONS -r $CVSTAG" - fi + if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then + echo "Warning: No CVS access defined - using local .spec file" + NOCVSSPEC="yes" fi - result=1 - retries_counter=0 - while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ] - do - retries_counter=$(( $retries_counter + 1 )) - output=$(LC_ALL=C cvs $OPTIONS $SPECFILE 2>&1) - result=$? - [ -n "$output" ] && echo "$output" - if [ "$result" -ne "0" ]; then - 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 - echo "Trying again [$SPECFILE]... ($retries_counter)" - sleep 2 - continue - fi - Exit_error err_no_spec_in_repo; - fi - done + cvsup "$SPECFILE" || Exit_error err_no_spec_in_repo fi + if [ ! -f "$SPECFILE" ]; then Exit_error err_no_spec_in_repo; fi @@ -473,6 +555,8 @@ fi unset OPTIONS [ -n "$DONT_PRINT_REVISION" ] || grep -E -m 1 "^#.*Revision:.*Date" $SPECFILE + + set_spec_target } find_mirror() @@ -575,83 +659,128 @@ fi } +cvsup() +{ + update_shell_title "cvsup" + local OPTIONS="up " + if [ -n "$CVSROOT" ]; then + OPTIONS="-d $CVSROOT $OPTIONS" + fi + + if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then + OPTIONS="$OPTIONS -A" + else + if [ -n "$CVSDATE" ]; then + OPTIONS="$OPTIONS -D $CVSDATE" + fi + if [ -n "$CVSTAG" ]; then + OPTIONS="$OPTIONS -r $CVSTAG" + fi + fi + + local result=1 + local retries_counter=0 + if [ $# = 1 ]; then + update_shell_title "cvsup: $*" + else + update_shell_title "cvsup: $# files" + fi + while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ]; do + retries_counter=$(( $retries_counter + 1 )) + output=$(LC_ALL=C cvs $OPTIONS "$@" 2>&1) + result=$? + [ -n "$output" ] && echo "$output" + 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 + echo "Trying again [$*]... ($retries_counter)" + update_shell_title "cvsup: retry #$retries_counter" + sleep 2 + continue + else + break + fi + done + update_shell_title "cvsup: done!" + return $result +} + get_files() { - GET_FILES="$@" + update_shell_title "get_files" if [ -n "$DEBUG" ]; then set -x; set -v; fi - if [ -n "$1$2$3$4$5$6$7$8$9${10}" ]; then + if [ $# -gt 0 ]; then cd "$SOURCE_DIR" - OPTIONS="up " - if [ -n "$CVSROOT" ]; then - OPTIONS="-d $CVSROOT $OPTIONS" - else - if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then - echo "warning: No cvs access defined for SOURCES" - NOCVS="yes" - fi + if [ ! -s CVS/Root -a "$NOCVS" != "yes" ]; then + echo "Warning: No CVS access defined for SOURCES" + NOCVS="yes" fi - if [ -z "$CVSDATE" -a -z "$CVSTAG" ]; then - OPTIONS="$OPTIONS -A" - else - if [ -n "$CVSDATE" ]; then - OPTIONS="$OPTIONS -D $CVSDATE" - fi - if [ -n "$CVSTAG" ]; then - OPTIONS="$OPTIONS -r $CVSTAG" + + local nc=0 + local get_files_cvs="" + for i in "$@"; do + nc=$((nc + 1)) + local cvsup=0 + SHELL_TITLE_PREFIX="get_files[$nc/$#]" + update_shell_title "$i" + local fp=`nourl "$i"` + if [ -f "$fp" ] && [ "$SKIP_EXISTING_FILES" = "yes" ]; then + continue fi - fi - for i in $GET_FILES - do if [ -n "$UPDATE5" ]; then if [ -n "$ADD5" ]; then - [ `nourl $i` = "$i" ] && continue + [ "$fp" = "$i" ] && continue grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE && continue else grep -qiE '^#[ ]*Source'$(src_no $i)'-md5[ ]*:' $SPECS_DIR/$SPECFILE || continue fi fi FROM_DISTFILES=0 - if [ ! -f `nourl $i` ] || [ $ALWAYS_CVSUP = "yes" ]; then + if [ ! -f "$fp" ] || [ $ALWAYS_CVSUP = "yes" ]; then if echo $i | grep -vE '(http|ftp|https|cvs|svn)://' | grep -qE '\.(gz|bz2)$']; then echo "Warning: no URL given for $i" fi - if [ -n "$(src_md5 "$i")" ] && [ -z "$NODIST" ]; then + if [ -z "$NODIST" ] && [ -n "$(src_md5 "$i")" ]; then if good_md5 "$i" && good_size "$i"; then echo "$(nourl "$i") having proper md5sum already exists" continue fi - target=$(nourl "$i") + target="$fp" url=$(distfiles_url "$i") url_attic=$(distfiles_attic_url "$i") FROM_DISTFILES=1 - if [ `echo $url | grep -E '^(\.|/)'` ]; then + if [ "`echo $url | grep -E '^(\.|/)'`" ]; then + update_shell_title "${GETLOCAL%% *}: $url" ${GETLOCAL} $url $target else if [ -z "$NOMIRRORS" ]; then url="`find_mirror "$url"`" fi + update_shell_title "${GETURI%% *}: $url" ${GETURI} ${OUTFILEOPT} "$target" "$url" || \ - if [ `echo $url | grep -E 'ftp://'` ]; then + if [ "`echo $url | grep -E 'ftp://'`" ]; then + update_shell_title "${GETURI2%% *}: $url" ${GETURI2} ${OUTFILEOPT} "$target" "$url" fi fi if ! test -s "$target"; then rm -f "$target" if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then + update_shell_title "${GETLOCAL%% *}: $url_attic" ${GETLOCAL} $url_attic $target else if [ -z "$NOMIRRORS" ]; then url_attic="`find_mirror "$url_attic"`" fi + update_shell_title "${GETURI%% *}: $url_attic" ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \ - if [ `echo $url_attic | grep -E 'ftp://'` ]; then + if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then + update_shell_title "${GETURI2%% *}: $url_attic" ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic" fi fi @@ -662,41 +791,37 @@ rm -f "$target" FROM_DISTFILES=0 fi - elif [ -z "$(src_md5 "$i")" -a "$NOCVS" != "yes" ]; then - # ( echo $i | grep -qvE '(ftp|http|https)://' ); -- if CVS should be used, but URLs preferred - result=1 - retries_counter=0 - while [ "$result" != "0" -a "$retries_counter" -le "$CVS_RETRIES" ] - do - retries_counter=$(( $retries_counter + 1 )) - output=$(LC_ALL=C cvs $OPTIONS `nourl $i` 2>&1) - result=$? - [ -n "$output" ] && echo "$output" - 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 - echo "Trying again [`nourl $i`]... ($retries_counter)" - sleep 2 - continue - else - break - fi - done + elif [ "$NOCVS" != "yes" -a -z "$(src_md5 "$i")" ]; then + if [ $# -gt 1 ]; then + get_files_cvs="$get_files_cvs $fp" + update_shell_title "$fp (will cvs up later)" + cvsup=1 + else + cvsup $fp + fi fi - if [ -z "$NOURLS" ] && [ ! -f "`nourl $i`" -o -n "$UPDATE" ] && [ `echo $i | grep -E 'ftp://|http://|https://'` ]; then + if [ -z "$NOURLS" ] && [ ! -f "$fp" -o -n "$UPDATE" ] && [ "`echo $i | grep -E 'ftp://|http://|https://'`" ]; then if [ -z "$NOMIRRORS" ]; then im="`find_mirror "$i"`" else im="$i" fi + update_shell_title "${GETURI%% *}: $im" ${GETURI} "$im" || \ <<Diff was trimmed, longer than 597 lines>> ---- CVS-web: http://cvs.pld-linux.org/SOURCES/builder?r1=1.12&r2=1.13&f=u _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit