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

Fix unknown package handling in zypper install (fixes bsc#1127608) #266

Merged
merged 1 commit into from
Apr 18, 2019
Merged
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/installremove.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,25 @@ void InstallRemoveBase::fillSrOpts(SolverRequester::Options &sropts_r ) const
sropts_r.force_by_name = _selectByName;
}

int InstallRemoveBase::handleFeedback(Zypper &zypper, const SolverRequester &sr_r ) const
void InstallRemoveBase::handleFeedback(Zypper &zypper, const SolverRequester &sr_r, bool failOnCapNotFound ) const
{
sr_r.printFeedback( zypper.out() );

if ( !zypper.config().ignore_unknown
&& ( sr_r.hasFeedback( SolverRequester::Feedback::NOT_FOUND_NAME )
|| sr_r.hasFeedback( SolverRequester::Feedback::NOT_FOUND_CAP ) ) )
{
return ( ZYPPER_EXIT_INF_CAP_NOT_FOUND );
zypper.setExitCode( ZYPPER_EXIT_INF_CAP_NOT_FOUND );

//bsc#1127608 Only return with error if zypper is executed non interactively
//This was missed when migrating the install/remove commands,
//see commit f2e0f8638a32225ff084458a536eedc0f08ee549
if ( zypper.config().non_interactive && failOnCapNotFound )
ZYPP_THROW( ExitRequestException("name or capability not found") );

return;
}
return ZYPPER_EXIT_OK;
zypper.setExitCode( ZYPPER_EXIT_OK );
}


Expand Down Expand Up @@ -141,7 +149,7 @@ int RemoveCmd::execute(Zypper &zypper, const std::vector<std::string> &positiona

// bsc#980263: relax if removing packages
// only store exit code but continue with solving
zypper.setExitCode( handleFeedback( zypper, sr ) );
handleFeedback( zypper, sr, false );

Summary::ViewOptions opts = Summary::DEFAULT;
if ( _details )
Expand Down Expand Up @@ -274,9 +282,7 @@ int InstallCmd::execute( Zypper &zypper, const std::vector<std::string> &positio
PackageArgs rpm_args( rpms_files_caps );
sr.install( rpm_args );

code = handleFeedback( zypper, sr );
if ( code != ZYPPER_EXIT_OK )
return code;
handleFeedback( zypper, sr );

Summary::ViewOptions opts = Summary::DEFAULT;
if ( _details )
Expand Down
2 changes: 1 addition & 1 deletion src/commands/installremove.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class InstallRemoveBase : public ZypperBaseCommand
using ZypperBaseCommand::ZypperBaseCommand;
protected:
void fillSrOpts (SolverRequester::Options &sropts_r ) const;
int handleFeedback (Zypper &zypper, const SolverRequester &sr_r) const;
void handleFeedback(Zypper &zypper, const SolverRequester &sr_r, bool failOnCapNotFound = true ) const;

std::set<zypp::ResKind> _kinds;

Expand Down