]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
- updating poldek indexes makes only sense when building binary rpms
[packages/rpm-build-tools.git] / builder.sh
index ffd83ef6bbdfe0d38d626317a8be3d015c45d532..12ed0c776ada9c7f378a25e87e57f36c526f2acb 100644 (file)
@@ -76,6 +76,9 @@ USER_AGENT="PLD/Builder($VERSION)"
 # See LOGFILE example.
 DATE=`date +%Y-%m-%d_%H-%M-%S`
 
+# target arch, can also be used for log file naming
+TARGET=$(rpm -E %{_target})
+
 # Example: LOGFILE='../log.$PACKAGE_NAME'
 # Example: LOGFILE='../LOGS/log.$PACKAGE_NAME.$DATE'
 # Example: LOGFILE='$PACKAGE_NAME/$PACKAGE_NAME.$DATE.log'
@@ -106,6 +109,11 @@ PACKAGE_VERSION=""
 PACKAGE_NAME=""
 ASSUMED_NAME=""
 PROTOCOL="http"
+
+# use lftp by default when available
+USE_LFTP=
+lftp --version > /dev/null 2>&1 && USE_LFTP=yes
+
 WGET_RETRIES=${MAX_WGET_RETRIES:-0}
 
 CVS_COMMAND=${CVS_COMMAND:-cvs}
@@ -144,6 +152,7 @@ else
        fi
 fi
 
+UPDATE_POLDEK_INDEXES_OPTS=""
 
 # Here we load saved user environment used to
 # predefine options set above, or passed to builder
@@ -157,6 +166,7 @@ fi
 # Example of ~/.builderrc:
 #
 #UPDATE_POLDEK_INDEXES="yes"
+#UPDATE_POLDEK_INDEXES_OPTS="--mo=nodiff"
 #FETCH_BUILD_REQUIRES="yes"
 #REMOVE_BUILD_REQUIRES="force"
 #GROUP_BCONDS="yes"
@@ -190,6 +200,10 @@ elif [ -n "$USE_AXEL" ]; then
        GETURI="axel -a $AXEL_OPTS"
        GETURI2="$GETURI"
        OUTFILEOPT="-o"
+elif [ -n "$USE_LFTP" ]; then
+       GETURI=download_lftp
+       GETURI2=$GETURI
+       OUTFILEOPT=""
 else
        wget --help 2>&1 | grep -q -- ' --no-check-certificate ' && WGET_OPTS="$WGET_OPTS --no-check-certificate"
        wget --help 2>&1 | grep -q -- ' --inet ' && WGET_OPTS="$WGET_OPTS --inet"
@@ -203,7 +217,7 @@ fi
 
 GETLOCAL="cp -a"
 
-if (rpm --version 2>&1 | grep -q '4.0.[0-2]'); then
+if rpm --version 2>&1 | grep -q '4.0.[0-2]'; then
        RPM="rpm"
        RPMBUILD="rpm"
 else
@@ -249,6 +263,27 @@ run_poldek() {
 #---------------------------------------------
 # functions
 
+download_lftp() {
+       local outfile=$1 url=$2 retval tmpfile
+       # TODO: use mktemp
+       tmpfile=$outfile.tmp
+       lftp -c "
+               $([ "$DEBUG" = "yes" ] && echo "debug 5;")
+               set ssl:verify-certificate no;
+               set net:max-retries $WGET_RETRIES;
+               set http:user-agent \"$USER_AGENT\";
+               pget -n 10 -c \"$url\" -o \"$tmpfile\"
+       "
+
+       retval=$?
+       if [ $retval -eq 0 ]; then
+               mv -f "$tmpfile" "$outfile"
+       else
+               rm -f "$tmpfile"
+       fi
+       return $retval
+}
+
 usage() {
        if [ -n "$DEBUG" ]; then set -xv; fi
        echo "\
@@ -331,7 +366,7 @@ Usage: builder [-D|--debug] [-V|--version] [--short-version] [--as_anon] [-a|--a
 -sd, --source-distfiles - list sources available from distfiles (intended for offline
                       operations; does not work when Icon field is present
                       but icon file is absent),
--sc, --source-cvs - list sources available from CVS
+-sc, --source-cvs   - list sources available from CVS
 -sdp, --source-distfiles-paths - list sources available from distfiles -
                       paths relative to distfiles directory (intended for offline
                       operations; does not work when Icon field is present
@@ -360,7 +395,7 @@ Usage: builder [-D|--debug] [-V|--version] [--short-version] [--as_anon] [-a|--a
 -u, --try-upgrade   - check version, and try to upgrade package
 -un, --try-upgrade-with-float-version
                     - as above, but allow float version
-                                       php-pear-Services_Digg/
+                      php-pear-Services_Digg/
 --upgrade-version   - upgrade to specified version in try-upgrade
 --use-greed-sources
                     - try download source from tag head if don't find it in
@@ -383,8 +418,8 @@ Usage: builder [-D|--debug] [-V|--version] [--short-version] [--as_anon] [-a|--a
                       --with feat1 feat2 feat3 --without feat4 feat5 --with feat6
                       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
+                    - build for platform <platform>.
+--init-rpm-dir      - initialize ~/rpm directory structure
 "
 }
 
@@ -594,7 +629,7 @@ parse_spec() {
        cd $PACKAGE_DIR
        cache_rpm_dump
 
-       if (rpm_dump | grep -qEi ":.*nosource.*1"); then
+       if rpm_dump | grep -qEi ":.*nosource.*1"; then
                FAIL_IF_NO_SOURCES="no"
        fi
 
@@ -734,7 +769,7 @@ get_spec() {
 
        if [ "$NOCVSSPEC" != "yes" ]; then
                if [ ! -s CVS/Root -a "$NOCVSSPEC" != "yes" ]; then
-                       echo "Warning: No CVS access defined - using local .spec file"
+                       echo "Warning: No CVS access defined in $(pwd)- using local .spec file"
                        NOCVSSPEC="yes"
                fi
 
@@ -1034,7 +1069,7 @@ update_md5() {
                if [ -n "$ADD5" ] && is_url $i || [ -n "$md5" ]; then
                        local tag="# $srcno-md5:\t"
                        if [[ "$md5" == *NoSource* ]]; then
-                               tag="# NoSource$srcno-md5:\t"
+                               tag="# No$srcno-md5:\t"
                        elif [ -n "$USEDIGEST" ]; then
                                tag="BuildRequires:\tdigest(%SOURCE$srcno) = "
                        fi
@@ -1199,10 +1234,10 @@ get_files() {
                                                im="$i"
                                        fi
                                        update_shell_title "${GETURI%% *}: $im"
-                                       ${GETURI} "$im" ${OUTFILEOPT} "$target" || \
+                                       ${GETURI} ${OUTFILEOPT} "$target" "$im" || \
                                        if [ "`echo $im | grep -E 'ftp://'`" ]; then
                                                update_shell_title "${GETURI2%% *}: $im"
-                                               ${GETURI2} "$im" ${OUTFILEOPT} "$target"
+                                               ${GETURI2} ${OUTFILEOPT} "$target" "$im"
                                        fi
                                        test -s "$target" || rm -f "$target"
                                fi
@@ -1302,13 +1337,13 @@ is_tag_a_branch() {
                return 0;
        fi
 
-       TAG=$1
+       local _TAG=$1
        # escape some regexp characters if part of TAG
-       TAG=$(echo "$TAG" | sed -e 's#\([\+\*\.]\)#\\\1#g')
+       _TAG=$(echo "$_TAG" | sed -e 's#\([\+\*\.]\)#\\\1#g')
 
 
        cd "$PACKAGE_DIR"
-       $CVS_COMMAND status -v $SPECFILE | grep -Eiq "${TAG}.+(branch: [0-9.]+)"
+       $CVS_COMMAND status -v $SPECFILE | grep -Eiq "${_TAG}.+(branch: [0-9.]+)"
        return $?
 }
 
@@ -1623,7 +1658,7 @@ process_bcondrc() {
        # w32codec-installer license_agreement
        # php +mysqli
        # ---
-       if ([ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ])); then
+       if [ -f $HOME/.bcondrc ] || ([ -n $HOME_ETC ] && [ -f $HOME_ETC/.bcondrc ]); then
                :
        else
                return
@@ -2581,8 +2616,8 @@ case "$COMMAND" in
                                ;;
                esac
                build_package
-               if [ "$UPDATE_POLDEK_INDEXES" = "yes" -a "$COMMAND" != "build-prep" ]; then
-                       run_poldek --sdir="${POLDEK_INDEX_DIR}" --mkidxz
+               if [ "$UPDATE_POLDEK_INDEXES" = "yes" ] && [ "$COMMAND" = "build" -o "$COMMAND" = "build-binary" ]; then
+                       run_poldek --sdir="${POLDEK_INDEX_DIR}" ${UPDATE_POLDEK_INDEXES_OPTS} --mkidxz
                fi
                remove_build_requires
                ;;
This page took 0.03659 seconds and 4 git commands to generate.