From a3a5d83f298333201018d0001ef48d31897c374f Mon Sep 17 00:00:00 2001 From: Yi Yang Date: Fri, 9 Apr 2010 17:00:17 +0800 Subject: [PATCH] Can recognize more remote repo url and some cleanups --- build | 2 +- createrepomddeps | 3 ++- init_buildsystem | 16 ++++++---------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/build b/build index fd65285..6f27e85 100755 --- 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 diff --git a/createrepomddeps b/createrepomddeps index fb2f499..002275b 100755 --- a/createrepomddeps +++ b/createrepomddeps @@ -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; diff --git a/init_buildsystem b/init_buildsystem index 6abde32..d54f48f 100755 --- a/init_buildsystem +++ b/init_buildsystem @@ -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 -- 2.7.4