#include <zypp/Digest.h>
#include <zypp/Url.h>
+#include "zypper.h"
#include "zypper-callbacks.h"
#include "AliveCursor.h"
+#include "zypper-utils.h"
using zypp::media::MediaChangeReport;
using zypp::media::DownloadProgressReport;
struct MediaChangeReportReceiver : public zypp::callback::ReceiveReport<MediaChangeReport>
{
- virtual MediaChangeReport::Action requestMedia( Repository repo,
+ virtual MediaChangeReport::Action requestMedia( zypp::Url & url,
unsigned mediumNr,
MediaChangeReport::Error error,
const std::string & description )
{
- if (error == MediaChangeReport::WRONG)
+ if (is_changeable_media(url))
{
+ cerr << endl; // may be in the middle of RepoReport or ProgressReport
+ cerr << description << endl;
+
// TranslatorExplanation translate letters 'y' and 'n' to whathever is appropriate for your language.
// Try to check what answers does zypper accept (it always accepts y/n at least)
// You can also have a look at the regular expressions used to check the answer here:
// /usr/lib/locale/<your_locale>/LC_MESSAGES/SYS_LC_MESSAGES
std::string request = boost::str(boost::format(
_("Please insert media [%s] # %d and type 'y' to continue or 'n' to cancel the operation."))
- % repo.info().name() % mediumNr);
+ % gData.current_repo.name() % mediumNr);
if (read_bool_answer(request, false))
return MediaChangeReport::RETRY;
else
return MediaChangeReport::ABORT;
}
- else
- {
- cerr << description << endl;
- }
+
+ // not displaying the error for non-changeable media, it will be displayed
+ // where it is caught
}
};
return true;
}
+ // not used anywhere in libzypp 3.20.0
virtual DownloadProgressReport::Action problem( const zypp::Url & /*file*/, DownloadProgressReport::Error error, const std::string & description )
{
display_done ("download", cout_v);
return DownloadProgressReport::ABORT;
}
+ // used only to finish, errors will be reported in media change callback (libzypp 3.20.0)
virtual void finish( const zypp::Url & /*file*/, Error error, const std::string & konreason )
{
display_done ("download", cout_v);
- display_error (error, konreason);
+ // don't display errors here, they will be reported in media change callback
+ // display_error (error, konreason);
}
};
#include <zypp/target/store/PersistentStorage.h>
#include <zypp/base/IOStream.h>
-#include <zypp/media/MediaManager.h>
#include <zypp/RepoManager.h>
#include <zypp/RepoInfo.h>
static bool refresh_raw_metadata(const RepoInfo & repo, bool force_download)
{
+ gData.current_repo = repo;
+
+ // reset the gData.current_repo when going out of scope
+ struct Bye { ~Bye() { gData.current_repo = RepoInfo(); } } reset __attribute__ ((__unused__));
+
try
{
RepoManager manager;
for(RepoInfo::urls_const_iterator it = repo.baseUrlsBegin();
it != repo.baseUrlsEnd(); ++it)
{
- MediaManager mm; MediaAccessId id = mm.open(*it);
- is_cd = mm.isChangeable(id);
- mm.close(id);
+ is_cd = is_changeable_media(*it);
if (!is_cd)
break;
}
try
{
+ gData.current_repo = repo;
+
+ // reset the gData.current_repo when going out of scope
+ struct Bye { ~Bye() { gData.current_repo = RepoInfo(); } } reset __attribute__ ((__unused__));
+
manager.addRepository(repo);
}
catch (const RepoAlreadyExistsException & e)
ZYPP_CAUGHT(e);
report_problem(e,
_("Problem transferring repository data from specified URL:"),
- _("Please, check whether the specified URL is accessible."));
+ is_cd ? "" : _("Please, check whether the specified URL is accessible."));
ERR << "Problem transferring repository data from specified URL" << endl;
return ZYPPER_EXIT_ERR_ZYPP;
}
std::list<zypp::RepoInfo> repos;
int patches_count;
int security_patches_count;
- std::vector<std::string> packages_to_install;
+ std::vector<std::string> packages_to_install;
std::vector<std::string> packages_to_uninstall;
zypp::ResStore repo_resolvables;
zypp::ResStore target_resolvables;
+ zypp::RepoInfo current_repo;
/**
* Limit output to and above specified verbosity level.