Author: dmacvicar
Date: Fri Feb 15 13:58:44 2008
New Revision: 8717
URL: http://svn.opensuse.org/viewcvs/zypp?rev=8717&view=rev
Log:
- merge Stano's patch to keep downloaded rpms
Modified:
trunk/libzypp/zypp/Fetcher.cc
trunk/libzypp/zypp/RepoInfo.cc
trunk/libzypp/zypp/RepoInfo.h
trunk/libzypp/zypp/RepoManager.cc
trunk/libzypp/zypp/RepoManager.h
trunk/libzypp/zypp/ZConfig.cc
trunk/libzypp/zypp/ZConfig.h
trunk/libzypp/zypp/parser/RepoFileReader.cc
trunk/libzypp/zypp/repo/RepoProvideFile.cc
Modified: trunk/libzypp/zypp/Fetcher.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Fetcher.cc?rev=8717&r1=8716&r2=8717&view=diff
==============================================================================
--- trunk/libzypp/zypp/Fetcher.cc (original)
+++ trunk/libzypp/zypp/Fetcher.cc Fri Feb 15 13:58:44 2008
@@ -139,8 +139,13 @@
{
// does the current file exists in the current cache?
Pathname cached_file = *it_cache + (*it_res)->location.filename();
+
+ MIL << "Trying cached file: " << cached_file << endl;
+
if ( PathInfo( cached_file ).isExist() )
{
+ MIL << "File exist, testing checksum " << (*it_res)->location.checksum() << endl;
+
// check the checksum
if ( is_checksum( cached_file, (*it_res)->location.checksum() ) && (! (*it_res)->location.checksum().empty() ) )
{
@@ -151,16 +156,20 @@
// replicate the complete path in the target directory
Pathname dest_full_path = dest_dir + (*it_res)->location.filename();
- if ( assert_dir( dest_full_path.dirname() ) != 0 )
- ZYPP_THROW( Exception("Can't create " + dest_full_path.dirname().asString()));
+
+ if( dest_full_path != cached_file )
+ {
+ if ( assert_dir( dest_full_path.dirname() ) != 0 )
+ ZYPP_THROW( Exception("Can't create " + dest_full_path.dirname().asString()));
- if ( filesystem::copy(cached_file, dest_full_path ) != 0 )
- { //copy_file2dir
- //ZYPP_THROW(SourceIOException("Can't copy " + cached_file.asString() + " to " + destination.asString()));
- ERR << "Can't copy " << cached_file + " to " + dest_dir << endl;
- // try next cache
- continue;
- }
+ if ( filesystem::copy(cached_file, dest_full_path ) != 0 )
+ { //copy_file2dir
+ //ZYPP_THROW(SourceIOException("Can't copy " + cached_file.asString() + " to " + destination.asString()));
+ ERR << "Can't copy " << cached_file + " to " + dest_dir << endl;
+ // try next cache
+ continue;
+ }
+ }
got_from_cache = true;
break;
@@ -170,6 +179,8 @@
if ( ! got_from_cache )
{
+ MIL << "Not found in cache, downloading" << endl;
+
// try to get the file from the net
try
{
Modified: trunk/libzypp/zypp/RepoInfo.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoInfo.cc?rev=8717&r1=8716&r2=8717&view=diff
==============================================================================
--- trunk/libzypp/zypp/RepoInfo.cc (original)
+++ trunk/libzypp/zypp/RepoInfo.cc Fri Feb 15 13:58:44 2008
@@ -33,6 +33,7 @@
: enabled (false),
autorefresh(false),
gpgcheck(true),
+ keeppackages(false),
type(repo::RepoType::NONE_e)
{}
@@ -44,6 +45,7 @@
bool enabled;
bool autorefresh;
bool gpgcheck;
+ bool keeppackages;
Url gpgkey_url;
repo::RepoType type;
Url mirrorlist_url;
@@ -54,6 +56,7 @@
std::string name;
Pathname filepath;
Pathname metadatapath;
+ Pathname packagespath;
public:
private:
@@ -185,6 +188,18 @@
return *this;
}
+ RepoInfo & RepoInfo::setPackagesPath( const Pathname &path )
+ {
+ _pimpl->packagespath = path;
+ return *this;
+ }
+
+ RepoInfo & RepoInfo::setKeepPackages( bool keep )
+ {
+ _pimpl->keeppackages = keep;
+ return *this;
+ }
+
bool RepoInfo::enabled() const
{ return _pimpl->enabled; }
@@ -217,6 +232,9 @@
Pathname RepoInfo::metadataPath() const
{ return _pimpl->metadatapath; }
+ Pathname RepoInfo::packagesPath() const
+ { return _pimpl->packagespath; }
+
repo::RepoType RepoInfo::type() const
{ return _pimpl->type; }
@@ -264,6 +282,9 @@
bool RepoInfo::baseUrlsEmpty() const
{ return _pimpl->baseUrls.empty(); }
+ bool RepoInfo::keepPackages() const
+ { return _pimpl->keeppackages; }
+
std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
{
str << "--------------------------------------" << std::endl;
@@ -281,6 +302,7 @@
str << "- autorefresh : " << autorefresh() << std::endl;
str << "- gpgcheck : " << gpgCheck() << std::endl;
str << "- gpgkey : " << gpgKeyUrl() << std::endl;
+ str << "- keeppackages : " << keepPackages() << std::endl;
return str;
}
@@ -312,6 +334,8 @@
str << "gpgcheck=" << (gpgCheck() ? "1" : "0") << endl;
if ( ! (gpgKeyUrl().asString().empty()) )
str << "gpgkey=" <http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoInfo.h?rev=8717&r1=8716&r2=8717&view=diff
==============================================================================
--- trunk/libzypp/zypp/RepoInfo.h (original)
+++ trunk/libzypp/zypp/RepoInfo.h Fri Feb 15 13:58:44 2008
@@ -189,6 +189,11 @@
Pathname metadataPath() const;
/**
+ * \short Path where this repo packages are cached
+ */
+ Pathname packagesPath() const;
+
+ /**
* \short Whether to check or not this repository with gpg
*
* \note This is a just a hint to the application and can
@@ -209,6 +214,11 @@
Url gpgKeyUrl() const;
/**
+ * \short Whether to keep the packages downloaded from this repository will be kept in local cache
+ */
+ bool keepPackages() const;
+
+ /**
* Add a base url. \see baseUrls
* \param url The base url for the repository.
*
@@ -285,6 +295,13 @@
RepoInfo & setMetadataPath( const Pathname &path );
/**
+ * \short set the path where the local packages are stored
+ *
+ * \param path directory path
+ */
+ RepoInfo & setPackagesPath( const Pathname &path );
+
+ /**
* \short Whether to check or not this repository with gpg
*
* \param check true (check) or false (dont'check)
@@ -305,6 +322,17 @@
*
*/
RepoInfo & setGpgKeyUrl( const Url &gpgkey );
+
+ /**
+ * \short Set if the packaqes downloaded from this repository will be kept in local cache
+ *
+ * If the setting is true, all downloaded packages from this repository will be
+ * copied to the local raw cache.
+ *
+ * \param keep true (keep the downloaded packages) or false (delete them after installation)
+ *
+ */
+ RepoInfo & setKeepPackages( bool keep );
/**
* Write a human-readable representation of this RepoInfo object
Modified: trunk/libzypp/zypp/RepoManager.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.cc?rev=8717&r1=8716&r2=8717&view=diff
==============================================================================
--- trunk/libzypp/zypp/RepoManager.cc (original)
+++ trunk/libzypp/zypp/RepoManager.cc Fri Feb 15 13:58:44 2008
@@ -67,6 +67,7 @@
{
repoCachePath = ZConfig::instance().repoCachePath();
repoRawCachePath = ZConfig::instance().repoMetadataPath();
+ repoPackagesCachePath = ZConfig::instance().repoPackagesPath();
knownReposPath = ZConfig::instance().knownReposPath();
}
@@ -197,6 +198,15 @@
return opt.repoRawCachePath + info.alias();
}
+ /**
+ * \short Calculates the packages cache path for a repository
+ */
+ static Pathname packagescache_path_for_repoinfo( const RepoManagerOptions &opt, const RepoInfo &info )
+ {
+ assert_alias(info);
+ return opt.repoPackagesCachePath + info.alias();
+ }
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : RepoManager::Impl
@@ -277,6 +287,10 @@
// set the metadata path for the repo
Pathname metadata_path = rawcache_path_for_repoinfo(_pimpl->options, (*it));
(*it).setMetadataPath(metadata_path);
+
+ // set the downloaded packages path for the repo
+ Pathname packages_path = packagescache_path_for_repoinfo(_pimpl->options, (*it));
+ (*it).setPackagesPath(packages_path);
}
return repos;
}
@@ -599,10 +613,17 @@
// ok we have the metadata, now exchange
// the contents
- TmpDir oldmetadata( TmpDir::makeSibling( rawpath ) );
- filesystem::rename( rawpath, oldmetadata.path() );
+
+ // first, clean up the old rawcache metadata
+ // #FIXME
+ // now, move the new metadata in
+ // #FIXME
+
+ //TmpDir oldmetadata( TmpDir::makeSibling( rawpath ) );
+ //filesystem::rename( rawpath, oldmetadata.path() );
// move the just downloaded there
- filesystem::rename( tmpdir.path(), rawpath );
+ //filesystem::rename( tmpdir.path(), rawpath );
+
// we are done.
return;
}
Modified: trunk/libzypp/zypp/RepoManager.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/RepoManager.h?rev=8717&r1=8716&r2=8717&view=diff
==============================================================================
--- trunk/libzypp/zypp/RepoManager.h (original)
+++ trunk/libzypp/zypp/RepoManager.h Fri Feb 15 13:58:44 2008
@@ -52,6 +52,7 @@
Pathname repoCachePath;
Pathname repoRawCachePath;
+ Pathname repoPackagesCachePath;
Pathname knownReposPath;
};
Modified: trunk/libzypp/zypp/ZConfig.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.cc?rev=8717&r1=8716&r2=8717&view=diff
==============================================================================
--- trunk/libzypp/zypp/ZConfig.cc (original)
+++ trunk/libzypp/zypp/ZConfig.cc Fri Feb 15 13:58:44 2008
@@ -216,6 +216,10 @@
{
cfg_vendor_path = Pathname(value);
}
+ else if ( entry == "packagesdir" )
+ {
+ cfg_packages_path = Pathname(value);
+ }
}
}
}
@@ -249,6 +253,7 @@
Locale cfg_textLocale;
Pathname cfg_metadata_path;
+ Pathname cfg_packages_path;
Pathname cfg_cache_path;
Pathname cfg_known_repos_path;
Pathname cfg_vendor_path;
@@ -347,6 +352,12 @@
? Pathname("/var/cache/zypp/raw") : _pimpl->cfg_metadata_path );
}
+ Pathname ZConfig::repoPackagesPath() const
+ {
+ return ( _pimpl->cfg_packages_path.empty()
+ ? Pathname("/var/cache/zypp/packages") : _pimpl->cfg_packages_path );
+ }
+
Pathname ZConfig::repoCachePath() const
{
return ( _pimpl->cfg_cache_path.empty()
Modified: trunk/libzypp/zypp/ZConfig.h
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/ZConfig.h?rev=8717&r1=8716&r2=8717&view=diff
==============================================================================
--- trunk/libzypp/zypp/ZConfig.h (original)
+++ trunk/libzypp/zypp/ZConfig.h Fri Feb 15 13:58:44 2008
@@ -93,6 +93,11 @@
Pathname repoMetadataPath() const;
/**
+ * Path where the repo packages are downloaded and kept.
+ */
+ Pathname repoPackagesPath() const;
+
+ /**
* Path where the processed cache is kept
* (this is where zypp.db is located.
*/
Modified: trunk/libzypp/zypp/parser/RepoFileReader.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/parser/RepoFileReader.cc?rev=8717&r1=8716&r2=8717&view=diff
==============================================================================
--- trunk/libzypp/zypp/parser/RepoFileReader.cc (original)
+++ trunk/libzypp/zypp/parser/RepoFileReader.cc Fri Feb 15 13:58:44 2008
@@ -69,6 +69,8 @@
info.setGpgKeyUrl( Url(it->second) );
else if ( it->first == "gpgcheck" )
info.setGpgCheck( it->second == "1" );
+ else if ( it->first == "keeppackages" )
+ info.setKeepPackages( it->second == "1" );
else
ERR << "Unknown attribute " << it->second << " ignored" << endl;
}
Modified: trunk/libzypp/zypp/repo/RepoProvideFile.cc
URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/repo/RepoProvideFile.cc?rev=8717&r1=8716&r2=8717&view=diff
==============================================================================
--- trunk/libzypp/zypp/repo/RepoProvideFile.cc (original)
+++ trunk/libzypp/zypp/repo/RepoProvideFile.cc Fri Feb 15 13:58:44 2008
@@ -28,6 +28,7 @@
#include "zypp/repo/SUSEMediaVerifier.h"
#include "zypp/repo/RepoException.h"
#include "zypp/FileChecker.h"
+#include "zypp/Fetcher.h"
using std::endl;
using std::set;
@@ -214,7 +215,12 @@
repo_excpt.remember(RepoException(_("No url in repository.")));
ZYPP_THROW(repo_excpt);
}
+
+ Fetcher fetcher;
+ fetcher.addCachePath( info.packagesPath() );
+ MIL << "Added cache path " << info.packagesPath() << endl;
+
for ( RepoInfo::urls_const_iterator it = info.baseUrlsBegin();
it != info.baseUrlsEnd();
/* incremented in the loop */ )
@@ -227,11 +233,17 @@
<< "' from " << url << endl;
shared_ptr<MediaSetAccess> access = _impl->mediaAccessForUrl(url);
_impl->setVerifierForRepo(repo_r, access);
+
+ fetcher.enqueue( loc_r );
+
+ // FIXME: works for packages only
+ fetcher.start( info.packagesPath(), *access );
- ManagedFile ret( access->provideFile(loc_r) );
+ // reached if no exception has been thrown, so this is the correct file
+ ManagedFile ret( info.packagesPath() + loc_r.filename() );
std::string scheme( url.getScheme() );
- if ( scheme == "http" || scheme == "https" || scheme == "ftp" )
+ if ( !info.keepPackages() )
{
ret.setDispose( filesystem::unlink );
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org