]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
add last known REVISION so adapter internals could work
[packages/rpm-build-tools.git] / builder.sh
index f0dadabd7c9123498189e63f8d63da74ba081112..3861956879a11e1ec7550c37d3ded2b9a14be10b 100755 (executable)
@@ -39,7 +39,7 @@ RCSID='$Id: builder,v 1.645 2011/02/13 17:54:10 glen Exp $' r=${RCSID#* * } rev=
 VERSION="v0.35/$rev"
 VERSIONSTRING="\
 Build package utility from PLD Linux Packages repository
-$VERSION (C) 1999-2011 Free Penguins".
+$VERSION (C) 1999-2012 Free Penguins".
 
 PATH="/bin:/usr/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
 
@@ -111,14 +111,15 @@ PROTOCOL="http"
 # use lftp by default when available
 USE_LFTP=
 lftp --version > /dev/null 2>&1 && USE_LFTP=yes
+PARALLEL_DOWNLOADS=10
 
 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
 
 CVS_FORCE=""
 CVSIGNORE_DF="yes"
 CVSTAG=""
-GIT_SERVER="git://carme.pld-linux.org"
-GIT_PUSH="draenog@carme.pld-linux.org"
+GIT_SERVER="git://git.pld-linux.org"
+GIT_PUSH="git@git.pld-linux.org"
 PACKAGES_DIR="packages"
 HEAD_DETACHED=""
 DEPTH=""
@@ -268,7 +269,7 @@ download_lftp() {
                set ssl:verify-certificate no;
                set net:max-retries $WGET_RETRIES;
                set http:user-agent \"$USER_AGENT\";
-               pget -n 10 -c \"$url\" -o \"$tmpfile\"
+               pget -n $PARALLEL_DOWNLOADS -c \"$url\" -o \"$tmpfile\"
        "
 
        retval=$?
@@ -343,6 +344,7 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version]  [
 -ns, --no-srcs      - don't download Sources/Patches
 -ns0, --no-source0  - don't download Source0
 -nn, --no-net       - don't download anything from the net
+-pN, -p N           - set PARALLEL_DOWNLOADS to N (default $PARALLEL_DOWNLOADS)
 -pm, --prefer-mirrors
                     - prefer mirrors (if any) over distfiles for SOURCES
 --no-init           - don't initialize builder paths (SPECS and SOURCES)
@@ -427,11 +429,11 @@ Usage: builder [--all-branches] [-D|--debug] [-V|--version] [--short-version]  [
 
 # create tempfile. as secure as possible
 tempfile() {
-       mktemp -t builder.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$
+       mktemp --tmpdir -t builder.$PACKAGE_NAME.XXXXXX || ${TMPDIR:-/tmp}/builder.$RANDOM.$$
 }
 
 tempdir() {
-       mktemp -d builder.XXXXXX
+       mktemp --tmpdir -d builder.$PACKAGE_NAME.XXXXXX
 }
 
 # inserts git log instead of %changelog
@@ -450,10 +452,10 @@ insert_gitlog() {
        # * 1265749244 +0000 Random Hacker <nikt@pld-linux.org> 9370900
        git rev-list -${log_entries:-20} HEAD | while read sha1; do
                local logfmt='%B%n'
-               git notes list $sha1 &> /dev/null && logfmt=%N
+               git notes list $sha1 > /dev/null 2>&1 && logfmt=%N
                git log -n 1 $sha1 --format=format:"* %ad %an <%ae> %h%n${logfmt}%n" --date=raw | sed '/^$/q'
        done > $gitlog
-       gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog > $speclog
+       LC_ALL=C gawk '/^\* /{printf("* %s %s\n", strftime("%a %b %d %Y", $2), substr($0, length($1)+length($2)+length($3)+4)); next}{print}' $gitlog > $speclog
        sed '/^%changelog/,$d' $SPECFILE | sed -e "\${
                        a%changelog
                        r $speclog
@@ -996,7 +998,7 @@ src_md5() {
                fi
        fi
 
-       source_md5=`grep -i "^#[        ]*$no-md5[      ]*:" $SPECFILE | sed -e 's/.*://'`
+       source_md5=$(grep -iE "^#[      ]*(No)?$no-md5[         ]*:" $SPECFILE | sed -e 's/.*://')
        if [ -n "$source_md5" ]; then
                echo $source_md5
        else
@@ -1316,6 +1318,17 @@ get_files() {
        fi
 }
 
+tag_exist() {
+       local _tag="$1"
+       echo "Searching for tag $_tag..."
+       if [ -n "$DEPTH" ]; then
+               local ref=`git ls-remote $REMOTE_PLD "refs/tags/$_tag"`
+               [ -n  "$ref" ] && echo "$ref" && Exit_error err_tag_exists "$_tag"
+       else
+               git show-ref "refs/tags/$_tag" && Exit_error err_tag_exists "$_tag"
+       fi
+}
+
 make_tagver() {
        if [ -n "$DEBUG" ]; then
                set -x
@@ -1328,16 +1341,16 @@ make_tagver() {
        fi
 
        # NOTE: CVS tags may must not contain the characters `$,.:;@'
-       TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE | tr '[.@]' '[_#]')
+       TAGVER=$(echo $TAG_PREFIX$PACKAGE_NAME-$PACKAGE_VERSION-$PACKAGE_RELEASE)
 
-       # Remove #kernel.version_release from TAGVER because tagging sources
+       # Remove @kernel.version_release from TAGVER because tagging sources
        # could occur with different kernel-headers than kernel-headers used at build time.
        # besides, %{_kernel_ver_str} is not expanded.
 
-       # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1#%{_kernel_ver_str}
+       # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1@%{_kernel_ver_str}
        # TAGVER=auto-ac-madwifi-ng-0-0_20070225_1
 
-       TAGVER=${TAGVER%#*}
+       TAGVER=${TAGVER%@*}
        echo -n "$TAGVER"
 }
 
@@ -2025,7 +2038,7 @@ init_rpm_dir() {
 
        cd "$TOP_DIR"
        if [ ! -e ../rpm-build-tools ]; then
-               git clone  ${GIT_SERVER}:${PACKAGES_DIR}/rpm-build-tools.git ../rpm-build-tools
+               git clone  ${GIT_SERVER}/${PACKAGES_DIR}/rpm-build-tools.git ../rpm-build-tools
        fi
        for a in adapter builder; do
                ln -s ../rpm-build-tools/${a}.sh $a
@@ -2126,6 +2139,14 @@ while [ $# -gt 0 ]; do
                        RPMOPTS="${RPMOPTS} --define \"_smp_mflags $1\""
                        shift
                        ;;
+               -p)
+                       PARALLEL_DOWNLOADS=$2
+                       shift 2
+                       ;;
+               -p[0-9])
+                       PARALLEL_DOWNLOADS=${1#-p}
+                       shift
+                       ;;
                -l | --logtofile )
                        shift; LOGFILE="${1}"; shift ;;
                -ni| --nice )
@@ -2220,7 +2241,7 @@ while [ $# -gt 0 ]; do
                -FRB | --force-remove-build-requires)
                        REMOVE_BUILD_REQUIRES="force"
                        shift ;;
-               -sc | --sources-cvs)
+               -sc | --source-cvs)
                        COMMAND="list-sources-cvs"
                        shift ;;
                -sd | --source-distfiles)
@@ -2456,13 +2477,9 @@ case "$COMMAND" in
                # ./builder -bs test.spec -r AC-branch -Tp auto-ac- -tt
                if [ -n "$TEST_TAG" ]; then
                        local TAGVER=`make_tagver`
-                       echo "Searching for tag $TAGVER..."
-                       if [ -n "$DEPTH" ]; then
-                               local ref=`git ls-remote $REMOTE_PLD "refs/tags/$TAGVER"`
-                               [ -n  "$ref" ] && echo "$ref" && Exit_error err_tag_exists "$TAGVER"
-                       else
-                               git show-ref "refs/tags/$TAGVER" && Exit_error err_tag_exists "$TAGVER"
-                       fi
+                       tag_exist $TAGVER
+                       # check also tags created in CVS
+                       tag_exist $(echo $TAGVER | tr '[.@]' '[_#]')
                        # - do not allow to build from HEAD when XX-branch exists
                        TREE_PREFIX=$(echo "$TAG_PREFIX" | sed -e 's#^auto/\([a-zA-Z]\+\)/.*#\1#g')
                        if [ "$TREE_PREFIX" != "$TAG_PREFIX" ]; then
@@ -2474,8 +2491,8 @@ case "$COMMAND" in
                                        cmd_branches="git show-ref"
                                        ref_prefix=refs/remotes/${REMOTE_PLD}
                                fi
-                               TAG_STATUS=$($cmd_branches | grep -i "${ref_prefix}/$TAG_BRANCH$")
-                               if [ -n "$TAG_STATUS" -a "$TAG_STATUS" != "$CVSTAG" ]; then
+                               TAG_STATUS=$($cmd_branches | grep -i "${ref_prefix}/$TAG_BRANCH$" | cut -c'-40')
+                               if [ -n "$TAG_STATUS" -a "$TAG_STATUS" != $(git rev-parse "$CVSTAG") ]; then
                                        Exit_error err_branch_exists "$TAG_STATUS"
                                fi
                        fi
This page took 0.035243 seconds and 4 git commands to generate.