]> git.pld-linux.org Git - packages/rpm-build-tools.git/blobdiff - builder.sh
builder: xtitle check stderr, so it would work in capture blocks too
[packages/rpm-build-tools.git] / builder.sh
index 4e3748fc86a04a1e9c9c8bb03cc2fb2d8bd59424..840a3699afe082a238d4e9c1bc65f8d33b91a6a4 100755 (executable)
@@ -463,7 +463,7 @@ tempdir() {
 }
 
 # inserts git log instead of %changelog
-# outputs name of modified file created by tempfile
+# @output directory containing modified specfile
 insert_gitlog() {
        local SPECFILE=$1 specdir=$(tempdir) gitlog=$(tempfile) speclog=$(tempfile)
 
@@ -554,7 +554,7 @@ depspecname() {
 }
 
 update_shell_title() {
-       [ -t 1 ] || return
+       [ -t 2 ] || return
        local len=${COLUMNS:-80}
        local msg="$(echo "$*" | cut -c-$len)"
 
@@ -656,7 +656,7 @@ minirpm() {
 %remove_etc_shells(p) %{p:<lua>}
 %lua_add_etc_shells()  %{nil}
 %lua_remove_etc_shells() %{nil}
-%required_jdk %{nil}
+%required_jdk jdk
 %buildrequires_jdk %{nil}
 %pear_package_print_optionalpackages %{nil}
 EOF
@@ -1033,15 +1033,22 @@ get_spec() {
        set_spec_target
 }
 
+# find mirrors in this order. first match wins:
+# - package dir (~/rpm/packages/foo)
+# - repository dir (~/rpm/packages)
+# - tools dir dir (~/rpm/packages/rpm-build-tools)
 find_mirror() {
-       cd "$REPO_DIR"
        local url="$1"
-       if [ ! -f "mirrors"  ] ; then
-               ln -s ../rpm-build-tools/mirrors .
-       fi
 
-       IFS="|"
+       update_shell_title "find_mirror[$url][$REPO_DIR]"
+
+       # NOTE: as while loop runs in subshell,
+       # we use exit 2 to indicate  that the match was found
+       # otherwise we end up outputing mirror url and origin url.
+
        local origin mirror name rest ol prefix
+       IFS="|"
+       cat "$PACKAGE_DIR/mirrors" "$REPO_DIR/mirrors" "$REPO_DIR/../rpm-build-tools/mirrors" /dev/null 2>/dev/null | \
        while read origin mirror name rest; do
                # skip comments and empty lines
                if [ -z "$origin" ] || [ "${origin#\#}" != "$origin" ]; then
@@ -1052,10 +1059,9 @@ find_mirror() {
                if [ "$prefix" = "$origin" ] ; then
                        suffix=$(echo "$url" | cut -b $((ol+1))-)
                        echo -n "$mirror$suffix"
-                       return 0
+                       exit 2
                fi
-       done < mirrors
-       echo "$url"
+       done && echo "$url"
 }
 
 # Warning: unpredictable results if same URL used twice
@@ -1828,7 +1834,7 @@ run_sub_builder() {
 # this requires following sudo rules:
 # - poldek --noask --caplookup -uG
 poldek_install() {
-       LANG=C $POLDEK_CMD --noask --caplookup -uG "$@"
+       LANG=C $POLDEK_CMD --noask --caplookup --uniq -uG "$@"
 }
 
 # install packages
@@ -1928,21 +1934,21 @@ display_branches() {
 # outputs all dependencies which current rpmdb doesn't satisfy.
 # input can be either STDIN or parameters
 _rpm_prov_check() {
-       local DEPS
+       local deps out
 
        if [ $# -gt 0 ]; then
-               DEPS="$@"
+               deps="$@"
        else
-               DEPS=$(cat)
+               deps=$(cat)
        fi
 
-       DEPS=$(LANG=C rpm -q --whatprovides $DEPS 2>&1 | awk '/^(error:|no package provides)/ { print }')
+       out=$(LC_ALL=C rpm -q --whatprovides $deps 2>&1)
 
        # packages
-       echo "$DEPS" | awk '/^no package provides/ { print $NF }'
+       echo "$out" | awk '/^no package provides/ { print $NF }'
 
        # other deps (files)
-       echo "$DEPS" | awk -F: '/^error:.*No such file/{o = $2; gsub("^ file ", "", o); print o}'
+       echo "$out" | sed -rne 's/file (.*): No such file or directory/\1/p'
 }
 
 # checks if given package/files/provides exists in rpmdb.
@@ -1974,12 +1980,12 @@ install_build_requires_rpmdeps() {
        fi
 
        if [ -n "$CNFL" ]; then
-               echo "Uninstall conflicting packages ($CNFL):"
+               echo "Uninstall conflicting packages: $CNFL"
                uninstall_packages $CNFL
        fi
 
        if [ -n "$DEPS" ]; then
-               echo "Install dependencies ($DEPS):"
+               echo "Install dependencies: $DEPS"
                install_packages $DEPS
        fi
 }
@@ -2052,6 +2058,11 @@ if [ $# = 0 ]; then
        exit 1
 fi
 
+# stuff global $BUILDER_OPTS from env as args
+if [ "$BUILDER_OPTS" ]; then
+       set -- "$BUILDER_OPTS" "$@"
+fi
+
 while [ $# -gt 0 ]; do
        case "${1}" in
                -4|-6)
@@ -2310,7 +2321,7 @@ while [ $# -gt 0 ]; do
                        ;;
                --alt_kernel)
                        shift
-                       RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\""
+                       RPMOPTS="${RPMOPTS} --define \"alt_kernel $1\" --define \"build_kernels $1\""
                        shift
                        ;;
                --short-circuit)
This page took 0.116812 seconds and 4 git commands to generate.