]> git.pld-linux.org Git - packages/rpm-build-tools.git/commitdiff
builder: use multiple mirror file search locations
authorElan Ruusamäe <glen@delfi.ee>
Sun, 1 Nov 2015 19:11:55 +0000 (21:11 +0200)
committerElan Ruusamäe <glen@delfi.ee>
Sun, 1 Nov 2015 19:11:55 +0000 (21:11 +0200)
builder.sh

index 90e1b93eb434620b977749088bfd6c9938664dda..df16b001e04707e85086e06bbe6a486f376120d5 100755 (executable)
@@ -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
This page took 0.05601 seconds and 4 git commands to generate.