return repo::RepoType::NONE;
}
- MediaSetAccess access(url);
- if ( access.doesFileExist("/repodata/repomd.xml") )
- return repo::RepoType::RPMMD;
- if ( access.doesFileExist("/content") )
- return repo::RepoType::YAST2;
-
- // if it is a local url of type dir
- if ( (! media::MediaManager::downloads(url)) && ( url.getScheme() == "dir" ) )
+ try
{
- Pathname path = Pathname(url.getPathName());
- if ( PathInfo(path).isDir() )
+ MediaSetAccess access(url);
+ if ( access.doesFileExist("/repodata/repomd.xml") )
+ return repo::RepoType::RPMMD;
+ if ( access.doesFileExist("/content") )
+ return repo::RepoType::YAST2;
+
+ // if it is a local url of type dir
+ if ( (! media::MediaManager::downloads(url)) && ( url.getScheme() == "dir" ) )
{
- // allow empty dirs for now
- return repo::RepoType::RPMPLAINDIR;
+ Pathname path = Pathname(url.getPathName());
+ if ( PathInfo(path).isDir() )
+ {
+ // allow empty dirs for now
+ return repo::RepoType::RPMPLAINDIR;
+ }
}
}
-
+ catch ( const media::MediaException &e )
+ {
+ ZYPP_THROW(RepoException("Error trying to read from " + url.asString()));
+ }
+ catch ( const Exception &e )
+ {
+ ZYPP_THROW(Exception("Unknown error reading from " + url.asString()));
+ }
+
return repo::RepoType::NONE;
}
ZYPP_THROW(RepoAlreadyExistsException(info.alias()));
}
+ RepoInfo tosave = info;
+
+ // check the first url for now
+ if ( ZConfig::instance().repo_add_probe() || ( tosave.type() == RepoType::NONE ) )
+ {
+ RepoType probedtype;
+ probedtype = probe(*tosave.baseUrlsBegin());
+ if ( tosave.baseUrlsSize() > 0 )
+ {
+ if ( probedtype == RepoType::NONE )
+ ZYPP_THROW(RepoUnknownTypeException());
+ else
+ tosave.setType(probedtype);
+ }
+ }
+
progress.set(50);
// assert the directory exists
filesystem::assert_dir(_pimpl->options.knownReposPath);
Pathname repofile = generate_non_existing_name(_pimpl->options.knownReposPath,
- generate_filename(info));
+ generate_filename(tosave));
// now we have a filename that does not exists
MIL << "Saving repo in " << repofile << endl;
ZYPP_THROW (Exception( "Can't open " + repofile.asString() ) );
}
- info.dumpRepoOn(file);
+ tosave.dumpRepoOn(file);
progress.toMax();
MIL << "done" << endl;
}
*
* \throws repo::RepoAlreadyExistsException If the repo clash some
* unique attribute like alias
- *
- * \throws RepoAlreadyExistsException
+ * \throws MediaException If the access to the url fails
+ * \throws ParseException If the file parsing fails
+ * \throws RepoUnknownType If repository type can't be determined
+ * \throws RepoException ON other repository related errors
+ * \throws Exception On other errors.
*/
void addRepository( const RepoInfo &info,
const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
* \throws RepoAlreadyExistsException
* \throws MediaException If the access to the url fails
* \throws ParseException If the file parsing fails
+ * \throws RepoUnknownType If repository type can't be determined
+ * \throws RepoException ON other repository related errors
* \throws Exception On other errors.
*/
void addRepositories( const Url &url,
{
public:
Impl()
+ : repo_add_probe(false)
{
MIL << "ZConfig singleton created." << endl;
Pathname confpath("/etc/zypp/zypp.conf");
{
cfg_cache_path = Pathname(value);
}
+ else if ( entry == "repo.add.probe" )
+ {
+ repo_add_probe = (value == "1");
+ }
}
}
Pathname cfg_cache_path;
Pathname cfg_known_repos_path;
+ bool repo_add_probe;
+
};
///////////////////////////////////////////////////////////////////
return s;
}
+ bool ZConfig::repo_add_probe() const
+ {
+ return _pimpl->repo_add_probe;
+ }
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////