Mailinglist Archive: zypp-commit (233 mails)

< Previous Next >
[zypp-commit] <libzypp> master : Fix repository probing and building in presence of productdir. (bnc #553712)
  • From: Michael Andres <ma@xxxxxxx>
  • Date: Mon, 16 Nov 2009 15:35:37 +0100
  • Message-id: <E1NA3Wa-0002HI-4Z@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit 7dce3e150b619479264f1bed31fa25b4ff5ea363
Author: Michael Andres <ma@xxxxxxx>
Date: Mon Nov 16 15:35:37 2009 +0100

Fix repository probing and building in presence of productdir. (bnc #553712)
---
.../susetags/data/addon_in_subdir/updates/content | 1 +
.../data/addon_in_subdir/updates/license.tar.gz | Bin 0 -> 45 bytes
tests/zypp/RepoManager_test.cc | 10 ++-
zypp/RepoInfo.cc | 5 +-
zypp/RepoInfo.h | 12 ++-
zypp/RepoManager.cc | 94 ++++++++++---------
zypp/RepoManager.h | 10 ++-
7 files changed, 79 insertions(+), 53 deletions(-)

diff --git a/tests/repo/susetags/data/addon_in_subdir/updates/content
b/tests/repo/susetags/data/addon_in_subdir/updates/content
index debaa1d..cc17cac 100644
--- a/tests/repo/susetags/data/addon_in_subdir/updates/content
+++ b/tests/repo/susetags/data/addon_in_subdir/updates/content
@@ -16,3 +16,4 @@ VERSION 11.1
META SHA1 3d0cdf34257cc2c54929bf5414969142cad1d421 packages
META SHA1 2d68731ab2f3c86b81f7672798f871cf96b2d0fc packages.DU
META SHA1 07c36c760ed0c58b58d6d8fcfdd2717df02c4256 packages.en
+HASH SHA1 875e73cf2ee139203208c860fbfd7fa5cb291c7e license.tar.gz
\ No newline at end of file
diff --git a/tests/repo/susetags/data/addon_in_subdir/updates/license.tar.gz
b/tests/repo/susetags/data/addon_in_subdir/updates/license.tar.gz
new file mode 100644
index 0000000..5d513d1
Binary files /dev/null and
b/tests/repo/susetags/data/addon_in_subdir/updates/license.tar.gz differ
diff --git a/tests/zypp/RepoManager_test.cc b/tests/zypp/RepoManager_test.cc
index c4ded43..63400ac 100644
--- a/tests/zypp/RepoManager_test.cc
+++ b/tests/zypp/RepoManager_test.cc
@@ -51,10 +51,18 @@ BOOST_AUTO_TEST_CASE(refresh_addon_in_subdir)
info.setPath("/updates");
info.setType(RepoType::YAST2);
info.setAlias("boooh");
-
+
test.loadRepo(info);
+
+ // take care we actually got the data
+ Repository r( test.satpool().reposFind( "boooh" ) );
+ BOOST_REQUIRE( r );
+ BOOST_CHECK_EQUAL( r.solvablesSize(), 2 );
+ BOOST_CHECK_EQUAL( r.info().type(), repo::RepoType::YAST2 );
+ BOOST_CHECK( r.info().hasLicense() );
}

+
BOOST_AUTO_TEST_CASE(repomanager_test)
{
TmpDir tmpCachePath;
diff --git a/zypp/RepoInfo.cc b/zypp/RepoInfo.cc
index 29924d3..7f802a5 100644
--- a/zypp/RepoInfo.cc
+++ b/zypp/RepoInfo.cc
@@ -59,7 +59,7 @@ namespace zypp

public:
Pathname licenseTgz() const
- { return metadatapath.empty() ? Pathname() : metadatapath /
"license.tar.gz"; }
+ { return metadatapath.empty() ? Pathname() : metadatapath / path /
"license.tar.gz"; }


public:
@@ -276,6 +276,9 @@ namespace zypp
bool RepoInfo::hasLicense() const
{
Pathname licenseTgz( _pimpl->licenseTgz() );
+ SEC << licenseTgz << endl;
+ SEC << PathInfo(licenseTgz) << endl;
+
return ! licenseTgz.empty() && PathInfo(licenseTgz).isFile();
}

diff --git a/zypp/RepoInfo.h b/zypp/RepoInfo.h
index 2e97b86..37c4526 100644
--- a/zypp/RepoInfo.h
+++ b/zypp/RepoInfo.h
@@ -146,12 +146,14 @@ namespace zypp
* Pathname relative to the base Url where the product/repository
* is located
*
- * For medias containing more than one product, or repositories not
- * located at the root of the media it is important to
- * know the path of the media root relative to the product directory
- * so a media verifier can be set for that media.
+ * For media containing more than one product, or repositories not
+ * located at the root of the media it is important to know the path
+ * to the product directory relative to the media root. So a media
+ * verifier can be set for that media. You may also read it as
+ * <tt>baseUrl = url to mount</tt> and <tt>path = path on the
+ * mounted media</tt>.
*
- * It is not mandatory, and the default is /
+ * It is not mandatory, and the default is \c /.
*
* \note As a repository can have multiple Urls, the path is unique and
* the same for all Urls, so it is assumed all the Urls have the
diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc
index 9af471e..12a82c0 100644
--- a/zypp/RepoManager.cc
+++ b/zypp/RepoManager.cc
@@ -320,14 +320,14 @@ namespace zypp
}

/**
- * \short Calculates the raw metadata cache path for a repository, this is
- * inside the raw cache dir, plus the path where the metadata is.
+ * \short Calculates the raw product metadata path for a repository, this is
+ * inside the raw cache dir, plus an optional path where the metadata is.
*
* It should be different only for repositories that are not in the root of
* the media.
* for example /var/cache/zypp/alias/addondir
*/
- inline Pathname rawmetadata_path_for_repoinfo( const RepoManagerOptions
&opt, const RepoInfo &info )
+ inline Pathname rawproductdata_path_for_repoinfo( const RepoManagerOptions
&opt, const RepoInfo &info )
{
assert_alias(info);
return opt.repoRawCachePath / info.escaped_alias() / info.path();
@@ -543,7 +543,7 @@ namespace zypp
++it )
{
// set the metadata path for the repo
- Pathname metadata_path = rawmetadata_path_for_repoinfo(options, (*it));
+ Pathname metadata_path = rawcache_path_for_repoinfo(options, (*it));
(*it).setMetadataPath(metadata_path);

// set the downloaded packages path for the repo
@@ -626,7 +626,7 @@ namespace zypp

Pathname RepoManager::metadataPath( const RepoInfo &info ) const
{
- return rawmetadata_path_for_repoinfo(_pimpl->options, info );
+ return rawcache_path_for_repoinfo(_pimpl->options, info );
}

Pathname RepoManager::packagesPath( const RepoInfo &info ) const
@@ -638,8 +638,8 @@ namespace zypp

RepoStatus RepoManager::metadataStatus( const RepoInfo &info ) const
{
- Pathname rawpath = rawmetadata_path_for_repoinfo( _pimpl->options, info );
Pathname mediarootpath = rawcache_path_for_repoinfo( _pimpl->options, info
);
+ Pathname productdatapath = rawproductdata_path_for_repoinfo(
_pimpl->options, info );
RepoType repokind = info.type();
RepoStatus status;

@@ -647,7 +647,7 @@ namespace zypp
{
case RepoType::NONE_e:
// unknown, probe the local metadata
- repokind = probe(rawpath.asUrl());
+ repokind = probe( productdatapath.asUrl() );
break;
default:
break;
@@ -657,20 +657,20 @@ namespace zypp
{
case RepoType::RPMMD_e :
{
- status = RepoStatus( rawpath + "/repodata/repomd.xml");
+ status = RepoStatus( productdatapath + "/repodata/repomd.xml");
}
break;

case RepoType::YAST2_e :
{
- status = RepoStatus( rawpath + "/content") && (RepoStatus(
mediarootpath + "/media.1/media"));
+ status = RepoStatus( productdatapath + "/content") && (RepoStatus(
mediarootpath + "/media.1/media"));
}
break;

case RepoType::RPMPLAINDIR_e :
{
- if ( PathInfo(Pathname(rawpath + "/cookie")).isExist() )
- status = RepoStatus( rawpath + "/cookie");
+ if ( PathInfo(Pathname(productdatapath + "/cookie")).isExist() )
+ status = RepoStatus( /*productdatapath*/ + "/cookie");
}
break;

@@ -685,12 +685,12 @@ namespace zypp

void RepoManager::touchIndexFile(const RepoInfo & info)
{
- Pathname rawpath = rawmetadata_path_for_repoinfo( _pimpl->options, info );
+ Pathname productdatapath = rawproductdata_path_for_repoinfo(
_pimpl->options, info );

RepoType repokind = info.type();
if ( repokind.toEnum() == RepoType::NONE_e )
// unknown, probe the local metadata
- repokind = probe(rawpath.asUrl());
+ repokind = probe( productdatapath.asUrl() );
// if still unknown, just return
if (repokind == RepoType::NONE_e)
return;
@@ -699,15 +699,15 @@ namespace zypp
switch ( repokind.toEnum() )
{
case RepoType::RPMMD_e :
- p = Pathname(rawpath + "/repodata/repomd.xml");
+ p = Pathname(productdatapath + "/repodata/repomd.xml");
break;

case RepoType::YAST2_e :
- p = Pathname(rawpath + "/content");
+ p = Pathname(productdatapath + "/content");
break;

case RepoType::RPMPLAINDIR_e :
- p = Pathname(rawpath + "/cookie");
+ p = Pathname(productdatapath + "/cookie");
break;

case RepoType::NONE_e :
@@ -734,8 +734,8 @@ namespace zypp
MIL << "Going to try to check whether refresh is needed for " << url <<
endl;

// first check old (cached) metadata
- Pathname rawpath = rawmetadata_path_for_repoinfo( _pimpl->options, info
);
- filesystem::assert_dir(rawpath);
+ Pathname mediarootpath = rawcache_path_for_repoinfo( _pimpl->options,
info );
+ filesystem::assert_dir(mediarootpath);
oldstatus = metadataStatus(info);

if ( oldstatus.empty() )
@@ -775,16 +775,16 @@ namespace zypp
}
}

- // To test the new matadta create temp dir as sibling of rawpath
- filesystem::TmpDir tmpdir( filesystem::TmpDir::makeSibling( rawpath ) );
+ // To test the new matadta create temp dir as sibling of mediarootpath
+ filesystem::TmpDir tmpdir( filesystem::TmpDir::makeSibling(
mediarootpath ) );

repo::RepoType repokind = info.type();
// if the type is unknown, try probing.
switch ( repokind.toEnum() )
{
case RepoType::NONE_e:
- // unknown, probe it
- repokind = probe(url);
+ // unknown, probe it \todo respect productdir
+ repokind = probe( url, info.path() );
break;
default:
break;
@@ -894,7 +894,7 @@ namespace zypp
{
case RepoType::NONE_e:
// unknown, probe it
- repokind = probe(*it);
+ repokind = probe( *it, info.path() );

if (repokind.toEnum() != RepoType::NONE_e)
{
@@ -917,11 +917,11 @@ namespace zypp
break;
}

- Pathname rawpath = rawmetadata_path_for_repoinfo( _pimpl->options,
info );
- filesystem::assert_dir(rawpath);
+ Pathname mediarootpath = rawcache_path_for_repoinfo( _pimpl->options,
info );
+ filesystem::assert_dir(mediarootpath);

- // create temp dir as sibling of rawpath
- filesystem::TmpDir tmpdir( filesystem::TmpDir::makeSibling( rawpath )
);
+ // create temp dir as sibling of mediarootpath
+ filesystem::TmpDir tmpdir( filesystem::TmpDir::makeSibling(
mediarootpath ) );

if ( ( repokind.toEnum() == RepoType::RPMMD_e ) ||
( repokind.toEnum() == RepoType::YAST2_e ) )
@@ -944,7 +944,7 @@ namespace zypp
*/
for_( it, repoBegin(), repoEnd() )
{
- Pathname cachepath(rawmetadata_path_for_repoinfo( _pimpl->options,
*it ));
+ Pathname cachepath(rawcache_path_for_repoinfo( _pimpl->options,
*it ));
if ( PathInfo(cachepath).isExist() )
downloader_ptr->addCachePath(cachepath);
}
@@ -974,7 +974,7 @@ namespace zypp

// ok we have the metadata, now exchange
// the contents
- filesystem::exchange( tmpdir.path(), rawpath );
+ filesystem::exchange( tmpdir.path(), mediarootpath );

// we are done.
return;
@@ -1022,7 +1022,8 @@ namespace zypp
const ProgressData::ReceiverFnc & progressrcv )
{
assert_alias(info);
- Pathname rawpath = rawmetadata_path_for_repoinfo(_pimpl->options, info);
+ Pathname mediarootpath = rawcache_path_for_repoinfo( _pimpl->options, info
);
+ Pathname productdatapath = rawproductdata_path_for_repoinfo(
_pimpl->options, info );

filesystem::assert_dir(_pimpl->options.repoCachePath);
RepoStatus raw_metadata_status = metadataStatus(info);
@@ -1066,7 +1067,7 @@ namespace zypp
cleanCache(info);
}

- MIL << info.alias() << " building cache..." << endl;
+ MIL << info.alias() << " building cache..." << info.type() << endl;

Pathname base = solv_path_for_repoinfo( _pimpl->options, info);
filesystem::assert_dir(base);
@@ -1080,7 +1081,7 @@ namespace zypp
{
case RepoType::NONE_e:
// unknown, probe the local metadata
- repokind = probe(rawpath.asUrl());
+ repokind = probe( productdatapath.asUrl() );
break;
default:
break;
@@ -1114,7 +1115,7 @@ namespace zypp
cmd.push_back( forPlainDirs->getPathName().c_str() );
}
else
- cmd.push_back( rawpath.asString() );
+ cmd.push_back( productdatapath.asString() );

ExternalProgram prog( cmd, ExternalProgram::Stderr_To_Stdout );
std::string errdetail;
@@ -1152,15 +1153,18 @@ namespace zypp

////////////////////////////////////////////////////////////////////////////

- repo::RepoType RepoManager::probe( const Url &url ) const
+ repo::RepoType RepoManager::probe( const Url & url ) const
+ { return probe( url, Pathname() ); }
+
+ repo::RepoType RepoManager::probe( const Url & url, const Pathname & path )
const
{
- MIL << "going to probe the type of the repo " << endl;
+ MIL << "going to probe the repo type at " << url << " (" << path << ")" <<
endl;

- if ( url.getScheme() == "dir" && ! PathInfo( url.getPathName() ).isDir() )
+ if ( url.getScheme() == "dir" && ! PathInfo( url.getPathName()/path
).isDir() )
{
// Handle non existing local directory in advance, as
// MediaSetAccess does not support it.
- MIL << "Probed type NONE (not exists) at " << url << endl;
+ MIL << "Probed type NONE (not exists) at " << url << " (" << path << ")"
<< endl;
return repo::RepoType::NONE;
}

@@ -1178,9 +1182,9 @@ namespace zypp
MediaSetAccess access(url);
try
{
- if ( access.doesFileExist("/repodata/repomd.xml") )
+ if ( access.doesFileExist(path/"/repodata/repomd.xml") )
{
- MIL << "Probed type RPMMD at " << url << endl;
+ MIL << "Probed type RPMMD at " << url << " (" << path << ")" << endl;
return repo::RepoType::RPMMD;
}
}
@@ -1194,9 +1198,9 @@ namespace zypp

try
{
- if ( access.doesFileExist("/content") )
+ if ( access.doesFileExist(path/"/content") )
{
- MIL << "Probed type YAST2 at " << url << endl;
+ MIL << "Probed type YAST2 at " << url << " (" << path << ")" << endl;
return repo::RepoType::YAST2;
}
}
@@ -1212,10 +1216,10 @@ namespace zypp
if ( ! url.schemeIsDownloading() )
{
MediaMounter media( url );
- if ( PathInfo(media.getPathName()).isDir() )
+ if ( PathInfo(media.getPathName()/path).isDir() )
{
// allow empty dirs for now
- MIL << "Probed type RPMPLAINDIR at " << url << endl;
+ MIL << "Probed type RPMPLAINDIR at " << url << " (" << path << ")"
<< endl;
return repo::RepoType::RPMPLAINDIR;
}
}
@@ -1232,7 +1236,7 @@ namespace zypp
if (gotMediaException)
ZYPP_THROW(enew);

- MIL << "Probed type NONE at " << url << endl;
+ MIL << "Probed type NONE at " << url << " (" << path << ")" << endl;
return repo::RepoType::NONE;
}

@@ -1323,7 +1327,7 @@ namespace zypp
DBG << "unknown repository type, probing" << endl;

RepoType probedtype;
- probedtype = probe(*tosave.baseUrlsBegin());
+ probedtype = probe( *tosave.baseUrlsBegin(), info.path() );
if ( tosave.baseUrlsSize() > 0 )
{
if ( probedtype == RepoType::NONE )
diff --git a/zypp/RepoManager.h b/zypp/RepoManager.h
index 3196d38..2c96192 100644
--- a/zypp/RepoManager.h
+++ b/zypp/RepoManager.h
@@ -381,8 +381,16 @@ namespace zypp

/**
* \short Probe repo metadata type.
+ *
+ * The location to probe consists of the base \a url (you may think of it as
+ * a mountpoint) and the \a path to the repository on the mounted media
+ * (ususally \c / ).
+ */
+ repo::RepoType probe( const Url & url, const Pathname & path ) const;
+ /**
+ * \overload Using the default path \c "/".
*/
- repo::RepoType probe( const Url &url ) const;
+ repo::RepoType probe( const Url & url ) const;


/**
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages