rbutil: Use pattern replacement for SystemInfo build type.

Use pattern replacement for lookup instead of expanded values. Will
allow simplifying things later for better handling of different build
types.

Change-Id: Iaad67a6c8654d27c3206cf95a379acab169565bc
This commit is contained in:
Dominik Riebeling 2020-11-13 21:53:53 +01:00
parent 6b3b4df6f6
commit ad37655687
8 changed files with 94 additions and 75 deletions

View file

@ -95,17 +95,20 @@ QVariant ServerInfo::platformValue(enum ServerInfos info, QString platform)
if(value.toStringList().size() > 1)
value = value.toStringList().at(1);
else if(!version.isEmpty() && info == CurReleaseUrl)
value = SystemInfo::value(SystemInfo::ReleaseUrl).toString()
value = SystemInfo::value(SystemInfo::BuildUrl,
SystemInfo::BuildRelease).toString()
.replace("%MODEL%", platform)
.replace("%RELVERSION%", version);
else if(!version.isEmpty() && info == RelCandidateUrl)
value = SystemInfo::value(SystemInfo::CandidateUrl).toString()
value = SystemInfo::value(SystemInfo::BuildUrl,
SystemInfo::BuildCandidate).toString()
.replace("%MODEL%", platform)
.replace("%RELVERSION%", version);
}
break;
case CurDevelUrl:
value = SystemInfo::value(SystemInfo::BleedingUrl).toString()
value = SystemInfo::value(SystemInfo::BuildUrl,
SystemInfo::BuildCurrent).toString()
.replace("%MODEL%", platform);
break;
case ManualPdfUrl:

View file

@ -27,23 +27,18 @@ const static struct {
SystemInfo::SystemInfos info;
const char* name;
} SystemInfosList[] = {
{ SystemInfo::ManualUrl, "manual_url" },
{ SystemInfo::BleedingUrl, "bleeding_url" },
{ SystemInfo::BootloaderUrl, "bootloader_url" },
{ SystemInfo::BootloaderInfoUrl, "bootloader_info_url" },
{ SystemInfo::ReleaseFontUrl, "release_font_url" },
{ SystemInfo::DailyFontUrl, "daily_font_url" },
{ SystemInfo::DailyVoiceUrl, "daily_voice_url" },
{ SystemInfo::ReleaseVoiceUrl, "release_voice_url" },
{ SystemInfo::ManualUrl, ":build:/manual_url" },
{ SystemInfo::BuildUrl, ":build:/build_url" },
{ SystemInfo::FontUrl, ":build:/font_url" },
{ SystemInfo::VoiceUrl, ":build:/voice_url" },
{ SystemInfo::BootloaderUrl, "bootloader/download_url" },
{ SystemInfo::BootloaderInfoUrl, "bootloader/info_url" },
{ SystemInfo::DoomUrl, "doom_url" },
{ SystemInfo::Duke3DUrl, "duke3d_url" },
{ SystemInfo::PuzzFontsUrl, "puzzfonts_url" },
{ SystemInfo::QuakeUrl, "quake_url" },
{ SystemInfo::Wolf3DUrl, "wolf3d_url" },
{ SystemInfo::XWorldUrl, "xworld_url" },
{ SystemInfo::ReleaseUrl, "release_url" },
{ SystemInfo::CandidateUrl, "rc_url" },
{ SystemInfo::DailyUrl, "daily_url" },
{ SystemInfo::BuildInfoUrl, "build_info_url" },
{ SystemInfo::GenlangUrl, "genlang_url" },
{ SystemInfo::ThemesUrl, "themes_url" },
@ -84,7 +79,7 @@ void SystemInfo::ensureSystemInfoExists()
}
QVariant SystemInfo::value(enum SystemInfos info)
QVariant SystemInfo::value(enum SystemInfos info, BuildType type)
{
ensureSystemInfoExists();
@ -93,6 +88,20 @@ QVariant SystemInfo::value(enum SystemInfos info)
while(SystemInfosList[i].info != info)
i++;
QString s = SystemInfosList[i].name;
switch(type) {
case BuildDaily:
s.replace(":build:", "daily");
break;
case BuildCurrent:
s.replace(":build:", "development");
break;
case BuildCandidate:
s.replace(":build:", "release-candidate");
break;
case BuildRelease:
s.replace(":build:", "release");
break;
}
LOG_INFO() << "GET:" << s << systemInfos->value(s).toString();
return systemInfos->value(s);
}

View file

@ -34,15 +34,21 @@ class SystemInfo : public QObject
MapIncompatible,
};
enum BuildType {
BuildCurrent,
BuildDaily,
BuildRelease,
BuildCandidate
};
//! All system settings
enum SystemInfos {
BuildUrl,
FontUrl,
VoiceUrl,
ManualUrl,
BleedingUrl,
BootloaderUrl,
BootloaderInfoUrl,
DailyUrl,
DailyFontUrl,
DailyVoiceUrl,
DoomUrl,
Duke3DUrl,
QuakeUrl,
@ -50,9 +56,6 @@ class SystemInfo : public QObject
Wolf3DUrl,
XWorldUrl,
ReleaseUrl,
CandidateUrl,
ReleaseVoiceUrl,
ReleaseFontUrl,
BuildInfoUrl,
GenlangUrl,
ThemesUrl,
@ -92,7 +95,7 @@ class SystemInfo : public QObject
//! returns a map of usb-ids and their targets
static QMap<int, QStringList> usbIdMap(enum MapType type);
//! get a value from system settings
static QVariant value(enum SystemInfos info);
static QVariant value(enum SystemInfos info, BuildType type = BuildCurrent);
//! get a value from system settings for a named platform.
static QVariant platformValue(enum PlatformInfo info, QString platform = "");

View file

@ -428,10 +428,10 @@ void SelectiveInstallWidget::installFonts(void)
QString relversion = installInfo.release();
if(relversion.isEmpty()) {
// release is empty for non-release versions (i.e. daily / current)
fontsurl = SystemInfo::value(SystemInfo::DailyFontUrl).toString();
fontsurl = SystemInfo::value(SystemInfo::FontUrl, SystemInfo::BuildDaily).toString();
}
else {
fontsurl = SystemInfo::value(SystemInfo::ReleaseFontUrl).toString();
fontsurl = SystemInfo::value(SystemInfo::FontUrl, SystemInfo::BuildRelease).toString();
logversion = installInfo.release();
}
fontsurl.replace("%RELEASEVER%", relversion);

View file

@ -1,30 +1,13 @@
[general]
; builds
release_url=http://download.rockbox.org/release/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip
bleeding_url=http://build.rockbox.org/data/rockbox-%MODEL%.zip
rc_url=http://download.rockbox.org/release-candidate/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip
; voice files
release_voice_url=http://download.rockbox.org/release/%RELVERSION%/%MODEL%-%RELVERSION%-english.zip
; server information
build_info_url=http://download.rockbox.org/build-info
; genlang -- used to get list of strings (only really old builds)
genlang_url=http://www.rockbox.org/genlang/?lang=%LANG%&t=%TARGET%&rev=%REVISION%&f=%FEATURES%
; bootloader
bootloader_info_url=http://download.rockbox.org/bootloader/bootloaders-info
bootloader_url=http://download.rockbox.org/bootloader
; themes
themes_url=http://themes.rockbox.org/
themes_info_url=http://themes.rockbox.org/rbutilqt.php?target=%TARGET%&release=%RELEASE%&revision=%REVISION%&rbutilver=%RBUTILVER%
; server information
build_info_url=http://download.rockbox.org/build-info
; fonts
release_font_url=http://download.rockbox.org/release/%RELEASEVER%/rockbox-fonts-%RELEASEVER%.zip
daily_font_url=http://download.rockbox.org/daily/fonts/rockbox-fonts.zip
; other
manual_url=http://download.rockbox.org/manual/rockbox-%MODEL%%FORMAT%
doom_url=http://download.rockbox.org/useful/rockdoom.zip
duke3d_url=http://download.rockbox.org/useful/duke3d.zip
quake_url=http://download.rockbox.org/useful/quake.zip
@ -33,6 +16,35 @@ wolf3d_url=http://download.rockbox.org/useful/wolf3d.zip
xworld_url=http://download.rockbox.org/useful/xworld.zip
rbutil_url=http://download.rockbox.org/rbutil/
[bootloader]
info_url=http://download.rockbox.org/bootloader/bootloaders-info
download_url=http://download.rockbox.org/bootloader
[release]
build_url=https://download.rockbox.org/release/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip
voice_url=https://download.rockbox.org/release/%RELVERSION%/%MODEL%-%RELVERSION%-english.zip
font_url=https://download.rockbox.org/release/%RELEASEVER%/rockbox-fonts-%RELEASEVER%.zip
manual_url=https://download.rockbox.org/release/%RELEASEVER%/rockbox-%MODEL%%FORMAT%
[release-candidate]
build_url=https://download.rockbox.org/release-candidate/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip
voice_url=https://download.rockbox.org/release-candidate/%RELVERSION%/%MODEL%-%RELVERSION%-english.zip
font_url=https://download.rockbox.org/release-candidate/%RELEASEVER%/rockbox-fonts-%RELEASEVER%.zip
manual_url=https://download.rockbox.org/release-candidate/%RELEASEVER%/rockbox-%MODEL%%FORMAT%
[development]
build_url=http://build.rockbox.org/data/rockbox-%MODEL%.zip
voice_url=https://download.rockbox.org/release/%RELVERSION%/%MODEL%-%RELVERSION%-english.zip
font_url=https://download.rockbox.org/daily/fonts/rockbox-fonts.zip
; manual is only built daily, use that one instead.
manual_url=https://download.rockbox.org/daily/manual/rockbox-%MODEL%%FORMAT%
[daily]
build_url=https://download.rockbox.org/daily/%MODEL%/rockbox-%MODEL%.zip
voice_url=https://download.rockbox.org/daily/voices/%MODEL%-%VERSION%-%LANGUAGE%.zip
font_url=https://download.rockbox.org/daily/fonts/rockbox-fonts.zip
manual_url=https://download.rockbox.org/daily/manual/rockbox-%MODEL%%FORMAT%
; [platforms] is used to determine the order in the device tree.
; Only devices present in this section will get displayed!
[platforms]

View file

@ -483,7 +483,8 @@ void RbUtilQt::installVoice()
return;
}
else {
voiceurl = SystemInfo::value(SystemInfo::ReleaseVoiceUrl).toString();
voiceurl = SystemInfo::value(SystemInfo::VoiceUrl,
SystemInfo::BuildRelease).toString();
logversion = installInfo.release();
}
if(QMessageBox::question(this, tr("Confirm Installation"),

View file

@ -38,27 +38,22 @@ QVariant SystemInfo::platformValue(SystemInfo::PlatformInfo info, QString platfo
return QString();
}
QVariant SystemInfo::value(SystemInfo::SystemInfos info)
QVariant SystemInfo::value(SystemInfo::SystemInfos info, SystemInfo::BuildType type)
{
switch(info) {
case SystemInfo::ManualUrl:
return QString("https://unittest/manual/rockbox-%MODEL%%FORMAT%");
break;
case SystemInfo::BleedingUrl:
(void)info; // test is currently only using BuildUrl.
switch(type) {
case SystemInfo::BuildCurrent:
return QString("https://unittest/dev/rockbox-%MODEL%.zip");
break;
case SystemInfo::DailyUrl:
case SystemInfo::BuildDaily:
return QString("https://unittest/daily/rockbox-%MODEL%-%RELVERSION%.zip");
break;
case SystemInfo::ReleaseUrl:
case SystemInfo::BuildRelease:
return QString("https://unittest/release/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip");
break;
case SystemInfo::CandidateUrl:
case SystemInfo::BuildCandidate:
return QString("https://unittest/rc/%RELVERSION%/rockbox-%MODEL%-%RELVERSION%.zip");
break;
default:
return QString();
break;
}
return QString();
}
QStringList SystemInfo::platforms(SystemInfo::PlatformType type, QString variant)

View file

@ -93,10 +93,6 @@ const struct testvector testdata[] =
{ "iaudiox5.v", ServerInfo::BleedingRevision, "be1be79" },
{ "iaudiox5.v", ServerInfo::BleedingDate, "2020-11-14T10:57:23" },
{ "iaudiox5.v", ServerInfo::CurDevelUrl, "https://unittest/dev/rockbox-iaudiox5.zip" },
{ "iaudiox5.v", ServerInfo::ManualPdfUrl, "https://unittest/manual/rockbox-iaudiox5.pdf" },
{ "ipodmini2g", ServerInfo::ManualPdfUrl, "https://unittest/manual/rockbox-ipodmini1g.pdf" },
{ "iriverh100", ServerInfo::ManualHtmlUrl, "https://unittest/manual/rockbox-iriverh100/rockbox-build.html" },
{ "iriverh120", ServerInfo::ManualZipUrl, "https://unittest/manual/rockbox-iriverh100-html.zip" },
};