[opensuse-buildservice] [PATCH 2/2 for build] Add an option --cachedir
You can pull it from git://gitorious.org/~yyang/opensuse/yyang-build.git
From e80039b4eb60eea4ccf711d65937e9944459387b Mon Sep 17 00:00:00 2001 From: Yi Yang
Date: Fri, 26 Mar 2010 15:14:04 +0800 Subject: [PATCH] Add an option --cachedir to specify a cache dir for remote repos
By default, cache dir is /var/cache/build, every repo will have a subdirectory under it, this subdirectory name is md5sum of a remote repo url. --- build | 13 ++++++++++++- createrepomddeps | 3 ++- init_buildsystem | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/build b/build index 5a4a061..278d9ac 100755 --- a/build +++ b/build @@ -131,7 +131,7 @@ Known Parameters: repository NAME. The repo must be refreshed with zypp so package meta data is available locally. With emtpy NAME all enabled repositories are used. - url can specify a remote repo. + a url can specify a remote repo. --rpms path1:path2:... Specify path where to find the RPMs for the build system @@ -147,6 +147,13 @@ Known Parameters: --root rootdir Use 'rootdir' to setup chroot environment + --cachedir cachedir + Use 'cachedir' to cache remote repo's packages, the + default cache dir is /var/cache/build, every repo + given by --repository corresponds to a subdir named + as md5sum of its repo url, forx eaxmple: + /var/cache/build/3e8ea9b47808629414a0cebc33ea285e + --oldpackages oldpackagesdir Define a directory with a former build @@ -644,6 +651,10 @@ while test -n "$1"; do BUILD_ROOT="$ARG" shift ;; + *-cachedir) + CACHE_DIR="$ARG" + shift + ;; *-oldpackages) OLD_PACKAGES="$ARG" shift diff --git a/createrepomddeps b/createrepomddeps index 3b41b9f..a9a670d 100755 --- a/createrepomddeps +++ b/createrepomddeps @@ -409,7 +409,8 @@ for my $url (@ARGV) { } } elsif ($url =~ /^http:\/\/([^\/]*)\/?/) { my $repoid = md5_hex($url); - $dir = "/var/cache/build/$repoid/"; + my $cachedir=($::ENV{'CACHE_DIR'} || '/var/cache/build'); + $dir = "$cachedir/$repoid/"; getmetadata($url, $dir); $baseurl = $url; } else { diff --git a/init_buildsystem b/init_buildsystem index 48d39b1..d241ed1 100755 --- a/init_buildsystem +++ b/init_buildsystem @@ -293,7 +293,7 @@ function validate_cache_file { elif [ "${SRC#http://}" != "$SRC" ]; then repoid=$(echo -n $SRC | md5sum | cut -d" " -f 1) mkdir -p $CACHE_DIR/$repoid - set -- $BUILD_DIR/createrepomddeps "$SRC" + set -- env CACHE_DIR="$CACHE_DIR" $BUILD_DIR/createrepomddeps "$SRC" elif [ ! -e "$SRC" ]; then echo "*** $SRC does not exist" >&2 cleanup_and_exit 1 @@ -390,6 +390,9 @@ download_repo() local destfile=$cachedir/$name if [ ! -e "$destfile" ]; then echo "downloading $url to $cachedir... "; + if [ ! -e "$cachedir" ] ; then + mkdir -p "$cachedir" + fi $BUILD_DIR/download "$cachedir" "$url" || cleanup_and_exit 1 rpm -K "$destfile" > $destfile.v || { echo "rpm verify failed" >&2; rm -f "$destfile"; cleanup_and_exit 1; } if grep "NOT OK" $destfile.v; then -- 1.6.0.6 -- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
participants (1)
-
Yi Yang