Issue 1623 (#1624)

* Fixing issue #1623 (Package installation with '-y' from command line does not work for URL or file)

* Another bugfix: package installation with -y from file structure did not work as 'grain.xml' is not added to grain URL

---------

Co-authored-by: Matthias Koefferlein <matthias@klayout.de>
This commit is contained in:
Matthias Köfferlein 2024-02-12 16:58:09 +01:00 committed by GitHub
parent cc7622b6b4
commit b799391ec9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 29 additions and 8 deletions

View File

@ -179,6 +179,10 @@ SaltController::install_packages (const std::vector<std::string> &packages, bool
{
lay::SaltDownloadManager manager;
// This method is used for command-line installation ignoring the package index.
// Hence we have to download package information here:
manager.set_always_download_package_information (true);
lay::Salt salt_mine;
if (! m_salt_mine_url.empty ()) {
tl::log << tl::to_string (tr ("Downloading package repository from %1").arg (tl::to_qstring (m_salt_mine_url)));

View File

@ -166,7 +166,7 @@ ConfirmationDialog::finish ()
SaltDownloadManager::SaltDownloadManager ()
{
// .. nothing yet ..
m_always_download_package_information = false;
}
void
@ -344,7 +344,7 @@ SaltDownloadManager::fetch_missing (const lay::Salt &salt, const lay::Salt &salt
}
if (! p->downloaded && salt_mine.download_package_information ()) {
if (! p->downloaded && (m_always_download_package_information || salt_mine.download_package_information ())) {
// If requested, download package information to complete information from index or dependencies
if (tl::verbosity() >= 10) {
@ -362,7 +362,7 @@ SaltDownloadManager::fetch_missing (const lay::Salt &salt, const lay::Salt &salt
if (! p->downloaded) {
if (p->name.empty ()) {
throw tl::Exception (tl::to_string (tr ("No name given package from '%s' (from dependencies or command line installation request)")), p->url);
throw tl::Exception (tl::to_string (tr ("No name given for package from '%s' (from dependencies or command line installation request)")), p->url);
}
if (tl::verbosity() >= 10) {

View File

@ -103,6 +103,22 @@ public:
*/
SaltDownloadManager ();
/**
* @brief Gets a flag indicating whether to always download package information
*/
bool always_download_package_information () const
{
return m_always_download_package_information;
}
/**
* @brief Sets a flag indicating whether to always download package information
*/
void set_always_download_package_information (bool f)
{
m_always_download_package_information = f;
}
/**
* @brief Registers an URL (with version) for download in the given target directory
*
@ -176,6 +192,7 @@ private:
};
std::vector<Descriptor> m_registry;
bool m_always_download_package_information;
bool needs_iteration ();
void fetch_missing (const lay::Salt &salt, const lay::Salt &salt_mine, tl::AbsoluteProgress &progress);

View File

@ -487,7 +487,7 @@ SaltGrain::load (tl::InputStream &p)
void
SaltGrain::save () const
{
save (tl::to_string (QDir (tl::to_qstring (path ())).filePath (tl::to_qstring (grain_filename))));
save (tl::to_string (QDir (tl::to_qstring (path ())).filePath (tl::to_qstring (SaltGrain::spec_file ()))));
}
void
@ -503,7 +503,7 @@ SaltGrain::from_path (const std::string &path)
QDir dir (tl::to_qstring (path));
SaltGrain g;
g.load (tl::to_string (dir.filePath (tl::to_qstring (grain_filename))));
g.load (tl::to_string (dir.filePath (tl::to_qstring (SaltGrain::spec_file ()))));
g.set_path (tl::to_string (dir.absolutePath ()));
return g;
}
@ -552,7 +552,7 @@ SaltGrain::stream_from_url (std::string &generic_url, double timeout, tl::InputH
} else {
return new tl::InputStream (url);
return new tl::InputStream (url + "/" + SaltGrain::spec_file ());
}
}
@ -576,10 +576,10 @@ SaltGrain::is_grain (const std::string &path)
if (path[0] != ':') {
QDir dir (tl::to_qstring (path));
QString gf = dir.filePath (tl::to_qstring (grain_filename));
QString gf = dir.filePath (tl::to_qstring (SaltGrain::spec_file ()));
return QFileInfo (gf).exists ();
} else {
return QResource (tl::to_qstring (path + "/" + grain_filename)).isValid ();
return QResource (tl::to_qstring (path + "/" + SaltGrain::spec_file ())).isValid ();
}
}