Can recognize more remote repo url and some cleanups
authorYi Yang <yi.y.yang@intel.com>
Fri, 9 Apr 2010 09:00:17 +0000 (17:00 +0800)
committerLudwig Nussel <ludwig.nussel@suse.de>
Fri, 9 Apr 2010 11:25:56 +0000 (13:25 +0200)
build
createrepomddeps
init_buildsystem

diff --git a/build b/build
index fd65285..6f27e85 100755 (executable)
--- a/build
+++ b/build
@@ -879,7 +879,7 @@ while test -n "$1"; do
     esac
 done
 
-test -z "$CACHE_DIR" && CACHE_DIR=/var/cache/build
+test -n "$CACHE_DIR" ||  CACHE_DIR=/var/cache/build
 
 if test -n "$KILL" ; then
     test -z "$SRCDIR" || usage
index fb2f499..002275b 100755 (executable)
@@ -26,6 +26,7 @@ my $opt_dump;
 my $opt_old;
 my $opt_nosrc;
 my $opt_bc;
+my $cachedir = "/var/cache/build";
 
 my $old_seen = ();
 
@@ -363,6 +364,7 @@ GetOptions (
     "nosrc"   => \$opt_nosrc,
     "dump"   => \$opt_dump,
     "old"   => \$opt_old,
+    "cachedir=s"  => \$cachedir,
     ) or exit(1);
 
 $opt_bc = 1 unless ($opt_dump || $opt_old);
@@ -395,7 +397,6 @@ for my $url (@ARGV) {
     }
   } elsif ($url =~ /^http:\/\/([^\/]*)\/?/) {
     my $repoid = md5_hex($url);
-    my $cachedir = ($::ENV{'CACHE_DIR'} || '/var/cache/build');
     $dir = "$cachedir/$repoid/";
     getmetadata($url, $dir);
     $baseurl = $url;
index 6abde32..d54f48f 100755 (executable)
@@ -289,9 +289,9 @@ function validate_cache_file {
            test -z "$SRC" && SRC=`pwd`
            if [ "${SRC#zypp://}" != "$SRC" ]; then
                set -- $BUILD_DIR/createrepomddeps "$SRC"
-           elif [ "${SRC#http://}" != "$SRC" ]; then
+           elif [ "${SRC#http://}" != "$SRC" -o "${SRC#https://}" != "$SRC" -o "${SRC#ftp://}" != "$SRC" -o "${SRC#ftps://}" != "$SRC" ]; then
                mkdir -p "$(getcachedir "$SRC")"
-               set -- env CACHE_DIR="$CACHE_DIR" $BUILD_DIR/createrepomddeps "$SRC"
+                set -- $BUILD_DIR/createrepomddeps --cachedir="$CACHE_DIR" "$SRC"
            elif [ ! -e "$SRC" ]; then
                echo "*** $SRC does not exist" >&2
                cleanup_and_exit 1
@@ -355,7 +355,7 @@ downloadpkg()
        cachedir="/var/cache/zypp/packages/"
        SRC="$cachedir${url#zypp://}"
        mkdir -p "$(dirname $SRC)"
-    elif [ "${url:0:7}" == "http://" ] ; then
+    elif [ "${url:0:7}" == "http://" -o "${url:0:8}" == "https://" -o "${url:0:6}" == "ftp://" -o "${url:0:7}" == "ftps://" ] ; then
        cachedir="$(getcachedir "$url")"
        local name="$(basename "$url")"
        SRC="$cachedir/$name"
@@ -549,7 +549,7 @@ else
        if [ "${SRC#/}" = "$SRC" ]; then
            url="$SRC"
            case "$url" in
-               zypp://* | http://*)
+               zypp://* | http://* | https://* | ftp://* | ftps://*)
                    downloadpkg "$url"
                    ;;
                *)
@@ -558,12 +558,8 @@ else
                    ;;
            esac
        fi
-       if [ "${SRC:0:7}" == "http://" ] ; then
-           target_file=$(get_pkg_filename "$SRC")
-           ln -s "$target_file" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRC##*.}"
-       else
-           ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRC##*.}"
-       fi
+       # downloadpkg modified $SRC, so it has a right name for use
+       ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRC##*.}"
        PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PKG"
     done < $RPMLIST