Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to guess repo file name for a obs:// uri ( fixes #262 ) #268

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/commands/repos/add.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,23 @@ int AddRepoCmd::execute(Zypper &zypper, const std::vector<std::string> &position
report_too_few_arguments( zypper.out(), help() );
return( ZYPPER_EXIT_ERR_INVALID_ARGS );
case 1:
if( !isRepoFile( positionalArgs_r[0] ) )
if( isRepoFile( positionalArgs_r[0] ) )
{
zypper.out().error(_("If only one argument is used, it must be a URI pointing to a .repo file."));
ERR << "Not a repo file." << endl;
zypper.out().info( help() );
return ( ZYPPER_EXIT_ERR_INVALID_ARGS );
add_repo_from_file( zypper, positionalArgs_r[0], _commonProperties, _repoProperties, _disableCheck );
break;
}
else if ( positionalArgs_r[0].find("obs") == 0 ) {
bool withFilename = true;
Url url = make_obs_url( positionalArgs_r[0], zypper.config().obs_baseUrl, zypper.config().obs_platform, withFilename );
add_repo_from_file( zypper, repo::RepoVariablesUrlReplacer()(url).asCompleteString(), _commonProperties, _repoProperties, _disableCheck );
break;
}
else
{
add_repo_from_file( zypper, positionalArgs_r[0], _commonProperties, _repoProperties, _disableCheck );
break;
zypper.out().error(_("If only one argument is used, it must be a URI pointing to a .repo file or a OBS repository."));
ERR << "Not a repo file." << endl;
zypper.out().info( help() );
return ( ZYPPER_EXIT_ERR_INVALID_ARGS );
}
case 2:
Url url;
Expand Down
5 changes: 4 additions & 1 deletion src/utils/misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ namespace
} // namespace
///////////////////////////////////////////////////////////////////

Url make_obs_url( const std::string & obsuri, const Url & base_url, const std::string & default_platform )
Url make_obs_url( const std::string & obsuri, const Url & base_url, const std::string & default_platform , bool guessRepoFilename )
{
// obs-server ==> < base_url, default_platform >
static std::map<std::string, std::pair<Url,std::string>> wellKnownServers({
Expand Down Expand Up @@ -476,6 +476,9 @@ Url make_obs_url( const std::string & obsuri, const Url & base_url, const std::s
else
path /= platform;

if ( guessRepoFilename )
path /= what[1] + ".repo";

ret.setPathName( path.asString() );

return ret;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Url make_url( const std::string & url_s );
* Creates Url out of obs://project/platform URI with given base URL and default
* platform (used in case the platform is not specified in the URI).
*/
Url make_obs_url( const std::string & obsuri, const Url & base_url, const std::string & default_platform );
Url make_obs_url( const std::string & obsuri, const Url & base_url, const std::string & default_platform, bool guessRepoFilename = false );

/**
* Returns <code>true</code> if the string \a s contains a substring starting
Expand Down