X-Git-Url: https://git.tld-linux.org/?a=blobdiff_plain;f=builder.sh;h=056cdf4f660b79b2bce31762258dbf95362d19d2;hb=bbe9c10ae848838adafe5772aec8f8b9624c4432;hp=e7e8d3416db8a9d9244376a2b7212a70c4046928;hpb=52c6968e58d5dd2efc78b7758ad5349e41a49e20;p=packages%2Frpm-build-tools.git diff --git a/builder.sh b/builder.sh index e7e8d34..056cdf4 100755 --- a/builder.sh +++ b/builder.sh @@ -68,7 +68,7 @@ ALWAYS_CVSUP=${ALWAYS_CVSUP:-"yes"} USEDIGEST= # user agent when fetching files -USER_AGENT="PLD/Builder($VERSION)" +USER_AGENT="TLD/Builder($VERSION)" # It can be used i.e. in log file naming. # See LOGFILE example. @@ -86,7 +86,7 @@ LOGFILE='' # use teeboth Perl wrapper # temporary option to disable if broken -USE_TEEBOTH=yes +USE_TEEBOTH=no LOGDIR="" LOGDIROK="" @@ -119,19 +119,20 @@ PARALLEL_DOWNLOADS=10 WGET_RETRIES=${MAX_WGET_RETRIES:-0} +# rsync repository with git refs of packages +PKGREVS_URL="http://pkgrevs.tld-linux.org" + # TLD git/df config TLD_GIT_SERVER="git://git.tld-linux.org" -TLD_GIT_PUSH="git@git.tld-linux.org" +TLD_GIT_PUSH="git@git.tld-linux.org:7272" TLD_PACKAGES_DIR="packages" TLD_DISTFILES_SERVER="://df.tld-linux.org" -TLD_ATTICDISTFILES_SERVER="" # PLD git/df config PLD_GIT_SERVER="git://git.pld-linux.org" PLD_GIT_PUSH="git@git.pld-linux.org" PLD_PACKAGES_DIR="packages" PLD_DISTFILES_SERVER="://distfiles.pld-linux.org" -PLD_ATTICDISTFILES_SERVER="://attic-distfiles.pld-linux.org" CVS_FORCE="" CVSIGNORE_DF="yes" @@ -148,7 +149,6 @@ NEW_REPO="" RES_FILE="" DISTFILES_SERVER=${TLD_DISTFILES_SERVER} -ATTICDISTFILES_SERVER=${TLD_ATTICDISTFILES_SERVER} DEF_NICE_LEVEL=19 SCHEDTOOL="auto" @@ -317,6 +317,7 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ [{-Tp|--tag-prefix} ] [{-tt|--test-tag}] [-nu|--no-urls] [-v|--verbose] [--opts ] [--short-circuit] [--show-bconds] [--with/--without ] [--define ] +[--git-pld|--git-tld] [--pkgrev] [-lp] [.spec][:tag] -4 - force IPv4 when transferring files @@ -462,6 +463,9 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version] [ --git-pld - force use of PLD git and distfiles --git-tld - force use of TLD git and distfiles (note: it will fall back to PLD git/df if package doesn't exist in TLD git) +--pkgrev - save git revision of package being built into pkgrevs + (note: only official TLD source builders are allowed to do so) +-lp - list pkgrevs for specified package " } @@ -528,7 +532,7 @@ teeboth() { local efile rc logfile=$1; shift if [ "$logfile" ]; then efile=$(tempfile) - { "$@" 2>&1; echo $? > $efile; } | tee -a $logfile + { "$@" 2>&1; echo $? > $efile; } | tee $logfile rc=$(< $efile) rm -f $efile else @@ -835,8 +839,14 @@ Exit_error() { echo >&2 "Error: problem with remote (${2})" exit 13 ;; "err_no_checkut" ) - echo >&2 "Error: cannot checkout $2" + echo >&2 "Error: cannot checkout ${2}" exit 14 ;; + "err_pkgrev_set" ) + echo >&2 "Error: failed to set package revision for tag ${2}" + exit 15 ;; + "err_pkgrev_get" ) + echo >&2 "Error: failed to get package revision for tag ${2}" + exit 16 ;; "err_not_implemented" ) remove_build_requires echo >&2 "Error: functionality not yet imlemented" @@ -995,6 +1005,8 @@ get_spec() { fi if [ -n "$CVSTAG" ]; then + local _rev=$(get_pkgrev "$CVSTAG") + echo "$_rev" | grep -q -E "^ERROR$" || CVSTAG="$_rev" if git rev-parse --verify -q "$CVSTAG"; then git checkout "$CVSTAG" -- elif git rev-parse --verify -q "refs/remotes/${REMOTE_PLD}/$CVSTAG"; then @@ -1106,11 +1118,7 @@ distfiles_path() { } distfiles_url() { - echo "$PROTOCOL$DISTFILES_SERVER/distfiles/$(distfiles_path "$1")" -} - -distfiles_attic_url() { - echo "$PROTOCOL$ATTICDISTFILES_SERVER/distfiles/Attic/$(distfiles_path "$1")" + echo "$PROTOCOL$DISTFILES_SERVER/$(distfiles_path "$1")" } good_md5() { @@ -1284,7 +1292,6 @@ get_files() { url=$(distfiles_url "$i") fi - url_attic=$(distfiles_attic_url "$i") FROM_DISTFILES=1 # is $url local file? if [[ "$url" = [./]* ]]; then @@ -1293,9 +1300,8 @@ get_files() { else local uri=${url} # make shorter message for distfiles urls - if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]] || [[ "$uri" = ${PROTOCOL}${ATTICDISTFILES_SERVER}* ]]; then - uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/distfiles/by-md5/?/?/*/} - uri=${uri#${PROTOCOL}${ATTICDISTFILES_SERVER}/distfiles/by-md5/?/?/*/} + if [[ "$uri" = ${PROTOCOL}${DISTFILES_SERVER}* ]]; then + uri=${uri#${PROTOCOL}${DISTFILES_SERVER}/by-md5/?/?/*/} uri="df: $uri" fi update_shell_title "${GETURI%% *}: $uri" @@ -1306,23 +1312,6 @@ get_files() { fi fi - # is it empty file? - if [ ! -s "$target" ]; then - rm -f "$target" - if [ `echo $url_attic | grep -E '^(\.|/)'` ]; then - update_shell_title "${GETLOCAL%% *}: $url_attic" - ${GETLOCAL} $url_attic $target - else - update_shell_title "${GETURI%% *}: $url_attic" - ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \ - if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then - update_shell_title "${GETURI2%% *}: $url_attic" - ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic" - fi - test -s "$target" || rm -f "$target" - fi - fi - if [ -s "$target" ]; then cvsignore_df $target else @@ -1372,15 +1361,6 @@ get_files() { update_shell_title "${GETURI2%% *}: $url" ${GETURI2} ${OUTFILEOPT} "$target" "$url" fi - if [ ! -s "$target" ]; then - rm -f "$target" - update_shell_title "${GETURI%% *}: $url_attic" - ${GETURI} ${OUTFILEOPT} "$target" "$url_attic" || \ - if [ "`echo $url_attic | grep -E 'ftp://'`" ]; then - update_shell_title "${GETURI2%% *}: $url_attic" - ${GETURI2} ${OUTFILEOPT} "$target" "$url_attic" - fi - fi test -s "$target" || rm -f "$target" fi done @@ -1469,6 +1449,45 @@ tag_files() { fi } +get_pkgrev() { + [ -z "$1" ] && return 1 + local _tmp=$(mktemp /tmp/.builder-XXXX) + rm $_tmp 2>/dev/null + $GETURI $OUTFILEOPT $_tmp $PKGREVS_URL/get/$1 1>/dev/null 2>&1 || Exit_error err_pkgrev_get "$1" + local result=$(cat $_tmp) + rm $_tmp 2>/dev/null + echo -n "$result" +} + +set_pkgrev() { + local _tag + if [ "$TAG_VERSION" = "yes" ]; then + _tag=`make_tagver` + fi + if [ -n "$TAG" ]; then + _tag="$TAG" + fi + echo "Writing git revision for tag $_tag" + local _tmp=$(mktemp /tmp/.builder-XXXX) + rm $_tmp 2>/dev/null + local _rev=$(git rev-parse HEAD) + $GETURI $OUTFILEOPT $_tmp $PKGREVS_URL/set/$_rev/$_tag 1>/dev/null 2>&1 || Exit_error err_pkgrev_get "$1" + local result=$(cat $_tmp) + rm $_tmp 2>/dev/null + [ "$(get_pkgrev "$_tag")" = "$CVSTAG" ] && return 0 + echo "$result" | grep -q -E "^OK$" && return 0 + echo "$result" | grep -q -E "^EXISTS$" && Exit_error err_tag_exists "$_tag" + Exit_error err_pkgrev_set +} + +list_pkgrev() { + local _tmp=$(mktemp /tmp/.builder-XXXX) + rm $_tmp 2>/dev/null + $GETURI $OUTFILEOPT $_tmp $PKGREVS_URL/list/$PACKAGE_NAME 1>/dev/null 2>&1 + cat $_tmp + rm $_tmp 2>/dev/null +} + branch_files() { TAG=$1 echo "Git branch: $TAG" @@ -2431,7 +2450,6 @@ while [ $# -gt 0 ]; do GIT_PUSH=${PLD_GIT_PUSH} PACKAGES_DIR=${PLD_PACKAGES_DIR} DISTFILES_SERVER=${PLD_DISTFILES_SERVER} - ATTICDISTFILES_SERVER=${PLD_ATTICDISTFILES_SERVER} ;; --git-tld) shift @@ -2439,8 +2457,13 @@ while [ $# -gt 0 ]; do GIT_PUSH=${TLD_GIT_PUSH} PACKAGES_DIR=${TLD_PACKAGES_DIR} DISTFILES_SERVER=${TLD_DISTFILES_SERVER} - ATTICDISTFILES_SERVER=${TLD_ATTICDISTFILES_SERVER} ;; + --pkgrev) + COMMAND="set_pkgrev" + shift;; + -lp) + COMMAND="list_pkgrev" + shift;; -*) Exit_error err_invalid_cmdline "$1" ;; @@ -2459,12 +2482,11 @@ done # Check if given package exists in TLD git if ! git ls-remote --heads ${GIT_SERVER}/${PACKAGES_DIR}/${ASSUMED_NAME} 1>/dev/null 2>&1; then - # Nope, we don't have it in TLD, switch for PLD repositories + # Nope, we don't have it in TLD, switch to PLD repositories GIT_SERVER=${PLD_GIT_SERVER} GIT_PUSH=${PLD_GIT_PUSH} PACKAGES_DIR=${PLD_PACKAGES_DIR} DISTFILES_SERVER=${PLD_DISTFILES_SERVER} - ATTICDISTFILES_SERVER=${PLD_ATTICDISTFILES_SERVER} fi if [ "$CVSTAG" ]; then @@ -2578,7 +2600,8 @@ case "$COMMAND" in # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt if [ -n "$TEST_TAG" ]; then - local TAGVER=`make_tagver` + local TAGVER=` + make_tagver` tag_exist $TAGVER || [ $TAGVER = $CVSTAG ] || Exit_error err_tag_exists $TAGVER # check also tags created in CVS local TAGVER_CVS=$(echo $TAGVER | tr '[.@]' '[_#]') @@ -2783,6 +2806,26 @@ case "$COMMAND" in "version" ) echo "$VERSIONSTRING" ;; + "set_pkgrev" ) + init_builder + if [ -z "$SPECFILE" ]; then + Exit_error err_no_spec_in_cmdl + fi + get_spec > /dev/null + parse_spec + set_bconds_values + display_bconds + set_pkgrev + ;; + "list_pkgrev" ) + init_builder + if [ -z "$SPECFILE" ]; then + Exit_error err_no_spec_in_cmdl + fi + get_spec > /dev/null + parse_spec + list_pkgrev + ;; esac if [ -f "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES" -a "$REMOVE_BUILD_REQUIRES" != "" ]; then rm "`pwd`/.${SPECFILE}_INSTALLED_PACKAGES"