Author: dmacvicar Date: Fri Jun 22 17:52:24 2007 New Revision: 5834 URL: http://svn.opensuse.org/viewcvs/zypp?rev=5834&view=rev Log: support plaindir rpms Modified: branches/REFACTORING-10_3/libzypp/zypp/RepoManager.cc branches/REFACTORING-10_3/libzypp/zypp/parser/plaindir/RepoParser.cc branches/REFACTORING-10_3/libzypp/zypp/parser/plaindir/RepoParser.h Modified: branches/REFACTORING-10_3/libzypp/zypp/RepoManager.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/RepoManager.cc?rev=5834&r1=5833&r2=5834&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/RepoManager.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/RepoManager.cc Fri Jun 22 17:52:24 2007 @@ -31,7 +31,7 @@ #include "zypp/parser/RepoFileReader.h" #include "zypp/repo/yum/Downloader.h" #include "zypp/parser/yum/RepoParser.h" - +#include "zypp/parser/plaindir/RepoParser.h" #include "zypp/repo/susetags/Downloader.h" #include "zypp/parser/susetags/RepoParser.h" @@ -281,6 +281,11 @@ { status = RepoStatus( rawpath + "/content"); } + case RepoType::RPMPLAINDIR_e : + { + if ( PathInfo(Pathname(rawpath + "/cookie")).isExist() ) + status = RepoStatus( rawpath + "/content"); + } break; default: ZYPP_THROW(RepoUnknownTypeException()); @@ -377,6 +382,39 @@ return; // no error } + case RepoType::RPMPLAINDIR_e : + { + RepoStatus newstatus = parser::plaindir::dirStatus(url.getPathName()); + bool refresh = false; + if ( oldstatus.checksum() == newstatus.checksum() ) + { + MIL << "repo has not changed" << endl; + if ( policy == RefreshForced ) + { + MIL << "refresh set to forced" << endl; + refresh = true; + } + } + else + { + refresh = true; + } + + if ( refresh ) + { + std::ofstream file(( tmpdir.path() + "/cookie").c_str()); + if (!file) { + ZYPP_THROW (Exception( "Can't open " + tmpdir.path().asString() + "/cookie" ) ); + } + file << url << endl; + file << newstatus.checksum() << endl; + + file.close(); + } + else + return; + // no error + } break; default: ZYPP_THROW(RepoUnknownTypeException()); @@ -475,6 +513,15 @@ parser.parse(rawpath); // no error } + case RepoType::RPMPLAINDIR_e : + { + InputStream is(rawpath + "cookie"); + string buffer; + getline( is.stream(), buffer); + Url url(buffer); + parser::plaindir::RepoParser parser(id, store); + parser.parse(url.getPathName()); + } break; default: ZYPP_THROW(RepoUnknownTypeException()); @@ -498,10 +545,15 @@ if ( access.doesFileExist("/content") ) return repo::RepoType::YAST2; - // if it is a local url - if ( ! media::MediaManager::downloads(url) ) + // if it is a local url of type dir + if ( (! media::MediaManager::downloads(url)) && ( url.getScheme() == "dir" ) ) { - + Pathname path = Pathname(url.getPathName()); + if ( PathInfo(path).isDir() ) + { + // allow empty dirs for now + return repo::RepoType::RPMPLAINDIR; + } } return repo::RepoType("UNKNOWN"); Modified: branches/REFACTORING-10_3/libzypp/zypp/parser/plaindir/RepoParser.cc URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/parser/plaindir/RepoParser.cc?rev=5834&r1=5833&r2=5834&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/parser/plaindir/RepoParser.cc (original) +++ branches/REFACTORING-10_3/libzypp/zypp/parser/plaindir/RepoParser.cc Fri Jun 22 17:52:24 2007 @@ -35,6 +35,40 @@ namespace plaindir { ///////////////////////////////////////////////////////////////// +static time_t recursive_timestamp( const Pathname &dir ) +{ + time_t max = PathInfo(dir).mtime(); + std::liststd::string dircontent; + if (filesystem::readdir( dircontent, dir, false) != 0) + { // dont look for dot files + ERR << "readdir " << dir << " failed" << endl; + return 0; + } + + for (std::liststd::string::const_iterator it = dircontent.begin(); + it != dircontent.end(); + ++it) + { + Pathname dir_path = dir + *it; + if ( PathInfo(dir_path).isDir()) + { + time_t val = recursive_timestamp(dir_path); + if ( val > max ) + max = val; + } + } + return max; +} + +RepoStatus dirStatus( const Pathname &dir ) +{ + RepoStatus status; + time_t t = recursive_timestamp(dir); + status.setTimestamp(Date(t)); + status.setChecksum(str::numstring(t)); + return status; +} + data::Package_Ptr makePackageDataFromHeader( const RpmHeader::constPtr header, set<string> * filerequires, const Pathname & location, data::RecordId &repoid ) Modified: branches/REFACTORING-10_3/libzypp/zypp/parser/plaindir/RepoParser.h URL: http://svn.opensuse.org/viewcvs/zypp/branches/REFACTORING-10_3/libzypp/zypp/parser/plaindir/RepoParser.h?rev=5834&r1=5833&r2=5834&view=diff ============================================================================== --- branches/REFACTORING-10_3/libzypp/zypp/parser/plaindir/RepoParser.h (original) +++ branches/REFACTORING-10_3/libzypp/zypp/parser/plaindir/RepoParser.h Fri Jun 22 17:52:24 2007 @@ -19,6 +19,7 @@ #include "zypp/data/ResolvableDataConsumer.h" #include "zypp/ProgressData.h" +#include "zypp/RepoStatus.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -30,6 +31,11 @@ namespace plaindir { ///////////////////////////////////////////////////////////////// + /** + * \short Gives a cookie for a dir + */ + RepoStatus dirStatus( const Pathname &dir ); + /** Plaindir metadata parser. */ class RepoParser : private base::NonCopyable -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org