rbutil: Move bootloader file check to base class.

Avoid constructing the bootloader file path in the caller. Pass filename
list and mountpoint separately so it can directly fall back to the
mountpoint.

Change some functions to use references instead of creating temporary
objects.

Change-Id: I09c9d755553a32de3d02a42a8ce1fcb94f831b2a
This commit is contained in:
Dominik Riebeling 2022-04-16 14:13:59 +02:00
parent 1af92e5ff8
commit 8c55ce62b9
4 changed files with 24 additions and 36 deletions

View file

@ -203,21 +203,28 @@ void BootloaderInstallBase::checkRemount()
//! @brief set list of possible bootloader files and pick the existing one.
//! @param sl list of possible bootloader files.
void BootloaderInstallBase::setBlFile(QStringList sl)
void BootloaderInstallBase::setBlFile(const QString& mountpoint, const QStringList& sl)
{
// figue which of the possible bootloader filenames is correct.
if(sl.size() == 0) {
m_blfile = mountpoint;
}
else {
for(int a = 0; a < sl.size(); a++) {
if(!Utils::resolvePathCase(sl.at(a)).isEmpty()) {
m_blfile = sl.at(a);
QString filename = mountpoint + sl.at(a);
if(!Utils::resolvePathCase(filename).isEmpty()) {
m_blfile = filename;
break;
}
}
// figue which of the possible bootloader filenames is correct.
if(m_blfile.isEmpty() && sl.size() > 0) {
m_blfile = sl.at(0);
m_blfile = mountpoint + sl.at(0);
}
}
}
bool BootloaderInstallBase::setOfFile(QString of, QStringList blfile)
bool BootloaderInstallBase::setOfFile(QString& of, const QStringList& blfile)
{
bool found = false;
ArchiveUtil *util = nullptr;

View file

@ -55,17 +55,17 @@ class BootloaderInstallBase : public QObject
bool backup(QString to);
//! set the different filenames and paths
void setBlFile(QStringList f);
void setBlFile(const QString& mountpoint, const QStringList& f);
void setBlUrl(QUrl u)
{ m_blurl = u; }
void setLogfile(QString f)
void setLogfile(const QString& f)
{ m_logfile = f; }
bool setOfFile(QString of, QStringList blfile);
bool setOfFile(QString& of, const QStringList& blfile);
//! returns a port Install Hint or empty if there is none
//! static and in the base class, so the installer classes dont need to
// be modified for new targets
static QString postinstallHints(QString model);
static QString postinstallHints(const QString& model);
protected slots:
void downloadBlFinish(QNetworkReply::NetworkError error);

View file

@ -308,17 +308,7 @@ void SelectiveInstallWidget::installBootloader(void)
// set bootloader filename. Do this now as installed() needs it.
QStringList blfile = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BootloaderFile).toStringList();
QStringList blfilepath;
for(int a = 0; a < blfile.size(); a++) {
blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
+ blfile.at(a));
}
// on devices without a bootloader file we use the mointpoint. The
// installer will use that to determine the correct device.
if(blfile.isEmpty()) {
blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString());
}
bl->setBlFile(blfilepath);
bl->setBlFile(RbSettings::value(RbSettings::Mountpoint).toString(), blfile);
QUrl url(PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderUrl).toString()
+ PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderName).toString());
bl->setBlUrl(url);

View file

@ -507,18 +507,9 @@ void RbUtilQt::uninstallBootloader(void)
logger->setFinished();
return;
}
QStringList blfile = PlayerBuildInfo::instance()->value(PlayerBuildInfo::BootloaderFile).toStringList();
QStringList blfilepath;
for(int a = 0; a < blfile.size(); a++) {
blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString()
+ blfile.at(a));
}
// on devices without a bootloader file we use the mointpoint. The
// installer will use that to determine the correct device.
if(blfile.isEmpty()) {
blfilepath.append(RbSettings::value(RbSettings::Mountpoint).toString());
}
bl->setBlFile(blfilepath);
QStringList blfile = PlayerBuildInfo::instance()->value(
PlayerBuildInfo::BootloaderFile).toStringList();
bl->setBlFile(RbSettings::value(RbSettings::Mountpoint).toString(), blfile);
bl->setLogfile(RbSettings::value(RbSettings::Mountpoint).toString()
+ "/.rockbox/rbutil.log");