AM_CXXFLAGS =
# gperf: -pg
-LDADD = -L$(top_srcdir)/zypp/.libs -L$(top_srcdir)/zypp2/.libs -lzypp -lzypp2 -lboost_regex -lxml2 -lz
+LDADD = -L$(top_srcdir)/zypp/.libs -L$(top_srcdir)/zypp2/.libs -lzypp -lzypp2 -lboost_regex -lxml2 -lz $(top_srcdir)/testsuite/src/utils/lib@PACKAGE@_testsuite_utils.la
## ##################################################
--- /dev/null
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <streambuf>
+
+#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
+#include "boost/filesystem/fstream.hpp" // ditto
+
+#include <boost/iostreams/device/file_descriptor.hpp>
+
+#include <zypp/base/Logger.h>
+#include <zypp/Locale.h>
+#include <zypp/ZYpp.h>
+#include <zypp/ZYppFactory.h>
+#include <zypp/TranslatedText.h>
+///////////////////////////////////////////////////////////////////
+
+#include <zypp/base/Logger.h>
+
+
+#include <map>
+#include <set>
+
+#include "zypp/CapFactory.h"
+#include "zypp/KeyRing.h"
+#include "zypp/Product.h"
+#include "zypp/Selection.h"
+#include "zypp/PublicKey.h"
+
+#include "zypp/ZYppFactory.h"
+
+#include "zypp/MediaSetAccess.h"
+#include "zypp2/source/yum/YUMSourceCacher.h"
+
+using namespace zypp::detail;
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::source;
+//using namespace DbXml;
+
+#define TestKind Selection
+
+int main()
+{
+ //MediaSetAccess ma( Url("cd:///"), Pathname("/"));
+ //MIL << "done 1" << std::endl;
+ //ChecksumFileChecker checker(CheckSum("sha1", "fa0abb22f703a3a41f7a39f0844b24daf572fd4c"));
+ //Pathname local = ma.provideFile("content", 1, checker);
+ //MIL << local << std::endl;
+ try
+ {
+ //zypp::source::yum::YUMSourceCacher cacher(Pathname("/"));
+ //cacher.cache( Url("dir:/space/tmp/factory-yum"), Pathname("/"));
+ ZYpp::Ptr z = getZYpp();
+ z->initializeTarget("/");
+
+ for (ResStore::resfilter_const_iterator it = z->target()->byKindBegin(ResTraits<TestKind>::kind); it != z->target()->byKindEnd(ResTraits<TestKind>::kind); ++it)
+ {
+ zypp::TestKind::constPtr res = asKind<const zypp::TestKind>( *it );
+ MIL << res->name() << " " << res->edition() << std::endl;
+ }
+
+ }
+ catch ( const Exception &e )
+ {
+ MIL << "Sorry, bye" << endl;
+ }
+}
+
+
--- /dev/null
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <streambuf>
+
+#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
+#include "boost/filesystem/fstream.hpp" // ditto
+
+#include <boost/iostreams/device/file_descriptor.hpp>
+
+#include <zypp/base/Logger.h>
+#include <zypp/Locale.h>
+#include <zypp/ZYpp.h>
+#include <zypp/ZYppFactory.h>
+#include <zypp/TranslatedText.h>
+///////////////////////////////////////////////////////////////////
+
+#include <zypp/base/Logger.h>
+
+
+#include <map>
+#include <set>
+
+#include "zypp/CapFactory.h"
+#include "zypp/KeyRing.h"
+#include "zypp/Product.h"
+#include "zypp/Selection.h"
+#include "zypp/PublicKey.h"
+
+#include "zypp/ZYppFactory.h"
+
+#include "zypp/MediaSetAccess.h"
+#include "zypp2/source/yum/YUMSourceCacher.h"
+
+using namespace zypp::detail;
+
+using namespace std;
+using namespace zypp;
+using namespace zypp::source;
+//using namespace DbXml;
+
+#define TestKind Selection
+
+int main()
+{
+ //MediaSetAccess ma( Url("cd:///"), Pathname("/"));
+ //MIL << "done 1" << std::endl;
+ //ChecksumFileChecker checker(CheckSum("sha1", "fa0abb22f703a3a41f7a39f0844b24daf572fd4c"));
+ //Pathname local = ma.provideFile("content", 1, checker);
+ //MIL << local << std::endl;
+ try
+ {
+ //zypp::source::yum::YUMSourceCacher cacher(Pathname("/"));
+ //cacher.cache( Url("dir:/space/tmp/factory-yum"), Pathname("/"));
+ ZYpp::Ptr z = getZYpp();
+ z->initializeTarget("/");
+
+ for (ResStore::resfilter_const_iterator it = z->target()->byKindBegin(ResTraits<TestKind>::kind); it != z->target()->byKindEnd(ResTraits<TestKind>::kind); ++it)
+ {
+ zypp::TestKind::constPtr res = asKind<const zypp::TestKind>( *it );
+ MIL << res->name() << " " << res->edition() << std::endl;
+ }
+
+ }
+ catch ( const Exception &e )
+ {
+ MIL << "Sorry, bye" << endl;
+ }
+}
+
+
#include "zypp/KeyRing.h"
#include "zypp/Product.h"
#include "zypp/Selection.h"
+#include "zypp/Package.h"
#include "zypp/PublicKey.h"
#include "zypp/ZYppFactory.h"
#include "zypp/MediaSetAccess.h"
+#include "zypp/SourceFactory.h"
#include "zypp2/source/yum/YUMSourceCacher.h"
+#include "testsuite/src/utils/TestUtils.h"
+
using namespace zypp::detail;
using namespace std;
int main()
{
- //MediaSetAccess ma( Url("cd:///"), Pathname("/"));
- //MIL << "done 1" << std::endl;
- //ChecksumFileChecker checker(CheckSum("sha1", "fa0abb22f703a3a41f7a39f0844b24daf572fd4c"));
- //Pathname local = ma.provideFile("content", 1, checker);
- //MIL << local << std::endl;
try
{
- //zypp::source::yum::YUMSourceCacher cacher(Pathname("/"));
- //cacher.cache( Url("dir:/space/tmp/factory-yum"), Pathname("/"));
ZYpp::Ptr z = getZYpp();
z->initializeTarget("/");
- for (ResStore::resfilter_const_iterator it = z->target()->byKindBegin(ResTraits<TestKind>::kind); it != z->target()->byKindEnd(ResTraits<TestKind>::kind); ++it)
+ //SourceManager_Ptr manager = SourceManager::sourceManager();
+
+ Source_Ref source = SourceFactory().createFrom( Url("dir:/space/rpms/duncan/vim/i386"), "/", "bleh", Pathname() );
+ ResStore store = source.resolvables();
+ //zypp::testsuite::utils::dump(store, true, true);
+
+ for (ResStore::const_iterator it = store.begin(); it != store.end(); ++it)
+ {
+ zypp::Package::Ptr res = asKind<zypp::Package>( *it );
+ MIL << res->name() << " " << res->edition() << " " << res->location() << std::endl;
+ }
+
+ /*for (ResStore::resfilter_const_iterator it = z->target()->byKindBegin(ResTraits<TestKind>::kind); it != z->target()->byKindEnd(ResTraits<TestKind>::kind); ++it)
{
zypp::TestKind::constPtr res = asKind<const zypp::TestKind>( *it );
MIL << res->name() << " " << res->edition() << std::endl;
- }
+ }*/
}
catch ( const Exception &e )
}
+
MIL << "Not SUSE tags source, trying next type" << endl;
}
-#warning Plaindir disabled in autoprobing
-#if 0
try
+ {
+ if ( ! ( ( url_r.getScheme() == "file") || ( url_r.getScheme() == "dir ") ) )
{
MIL << "Trying the Plaindir source" << endl;
Source_Ref::Impl_Ptr impl( base_source
- ? Impl::createBaseSourceImpl<PlaindirImpl>(id, path_r, alias_r, cache_dir_r)
- : Impl::createSourceImpl<PlaindirImpl>(id, path_r, alias_r, cache_dir_r) );
- MIL << "Found the Plaindir source" << endl;
-
+ ? Impl::createBaseSourceImpl<plaindir::PlaindirImpl>(id, path_r, alias_r, cache_dir_r, auto_refresh)
+ : Impl::createSourceImpl<plaindir::PlaindirImpl>(id, path_r, alias_r, cache_dir_r, auto_refresh) );
+ MIL << "Using the Plaindir source" << endl;
report->endProbe (url_r);
-
return Source_Ref(impl);
}
+ else
+ {
+ ZYPP_THROW(Exception("Url scheme " + url_r.getScheme() + " not compatible with plaindir sources. Only local paths supported"));
+ }
+ }
catch (const Exception & excpt_r)
{
ZYPP_CAUGHT(excpt_r);
MIL << "Not Plaindir source, trying next type" << endl;
}
-#endif
report->endProbe (url_r);
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
-/** \file zypp/source/plaindir/PlaindirImpl.cc
- *
-*/
+
#include <iostream>
#include "zypp/base/Logger.h"
#include "zypp/source/plaindir/PlaindirImpl.h"
using std::endl;
+using namespace std;
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace source
- { /////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- namespace plaindir
- { /////////////////////////////////////////////////////////////////
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PlaindirImpl::PlaindirImpl
- // METHOD TYPE : Ctor
- //
- PlaindirImpl::PlaindirImpl()
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PlaindirImpl::~PlaindirImpl
- // METHOD TYPE : Dtor
- //
- PlaindirImpl::~PlaindirImpl()
- {}
-
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : PlaindirImpl::~PlaindirImpl
- // METHOD TYPE : Dtor
- //
- void PlaindirImpl::factoryInit()
- {
- ZYPP_THROW( Exception( "Plaindir not implemented!" ) );
- }
+///////////////////////////////////////////////////////////////////
+namespace source
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+namespace plaindir
+{ /////////////////////////////////////////////////////////////////
+
+PlaindirImpl::PlaindirImpl()
+{
+
+}
+
+PlaindirImpl::~PlaindirImpl()
+{
+
+}
+
+
+void PlaindirImpl::factoryInit()
+{
+ if ( ! ( (url().getScheme() == "file") || (url().getScheme() == "dir") ) )
+ {
+ ZYPP_THROW( Exception( "Plaindir only supports local paths, scheme [" + url().getScheme() + "] is not local" ) );
+ }
+
+ Pathname thePath = Pathname(url().getPathName()) + path();
+ MIL << "Going to read dir " << thePath << std::endl;
+
+ extract_packages_from_directory( _store, thePath, selfSourceRef(), true );
+ MIL << "Plaindir source initialized." << std::endl;
+ MIL << " Url : " << url() << std::endl;
+ MIL << " Path : " << path() << std::endl;
+}
+
+int PlaindirImpl::extract_packages_from_directory (ResStore & store, const Pathname & path, Source_Ref source, bool recursive)
+{
+ Pathname filename;
+ PathInfo magic;
+ bool distro_magic, pkginfo_magic;
+
+ DBG << "extract_packages_from_directory(.., " << path << ", " << source.alias() << ", " << recursive << ")" << endl;
+
+ /*
+ Check for magic files that indicate how to treat the
+ directory. The files aren't read -- it is sufficient that
+ they exist.
+ */
+ magic = PathInfo( path + "/RC_SKIP" );
+ if (magic.isExist()) {
+ return 0;
+ }
+
+ magic = PathInfo( path + "/RC_RECURSIVE" );
+ if (magic.isExist())
+ recursive = true;
+
+ magic = PathInfo( path + "/RC_BY_DISTRO" );
+ distro_magic = magic.isExist();
+
+ pkginfo_magic = true;
+ magic = PathInfo( path + "/RC_IGNORE_PKGINFO" );
+ if (magic.isExist())
+ pkginfo_magic = false;
+
+
+ std::list<std::string> dircontent;
+ if (filesystem::readdir( dircontent, path, false) != 0) { // dont look for dot files
+ ERR << "readdir " << path << " failed" << endl;
+ return -1;
+ }
+
+ for (std::list<std::string>::const_iterator it = dircontent.begin(); it != dircontent.end(); ++it) {
+ Pathname file_path = path + *it;
+ PathInfo file_info( file_path );
+ if (recursive && file_info.isDir()) {
+
+ extract_packages_from_directory( store, file_path, source, recursive );
+
+ } else if (file_info.isFile()) {
+
+ string::size_type dotpos = it->find_last_of(".");
+ if (dotpos == string::npos)
+ continue;
+ if (string(*it, ++dotpos) != "rpm")
+ continue;
+ target::rpm::RpmHeader::constPtr header = target::rpm::RpmHeader::readPackage( file_path );
+ Package::Ptr package = target::rpm::RpmDb::makePackageFromHeader( header, NULL, file_path, source );
+
+ if (package != NULL) {
+ DBG << "Adding package " << *package << endl;
+ store.insert( package );
+ }
+ }
+ }
+ return 0;
+}
+
+
+
+
+
/////////////////////////////////////////////////////////////////
} // namespace plaindir
///////////////////////////////////////////////////////////////////
#include <iosfwd>
+#include <zypp/target/rpm/RpmHeader.h>
+#include <zypp/target/rpm/RpmDb.h>
+
#include "zypp/source/SourceImpl.h"
///////////////////////////////////////////////////////////////////
* \throw EXCEPTION on fail
*/
virtual void factoryInit();
+ int extract_packages_from_directory (ResStore & store, const Pathname & path, Source_Ref source, bool recursive);
};
///////////////////////////////////////////////////////////////////