mirror of https://github.com/odrling/Aegisub
simplify update system
This commit is contained in:
parent
5108535f52
commit
a68f670908
|
@ -46,8 +46,8 @@
|
||||||
<AegisubUseUpdateChecker>true</AegisubUseUpdateChecker>
|
<AegisubUseUpdateChecker>true</AegisubUseUpdateChecker>
|
||||||
<CsriLibraryName>vsfilter.lib</CsriLibraryName>
|
<CsriLibraryName>vsfilter.lib</CsriLibraryName>
|
||||||
<StartupLog>false</StartupLog>
|
<StartupLog>false</StartupLog>
|
||||||
<UpdateCheckerServer>updates.aegisub.org</UpdateCheckerServer>
|
<UpdateCheckerServer>mugen.karaokes.moe</UpdateCheckerServer>
|
||||||
<UpdateCheckerURL>/trunk</UpdateCheckerURL>
|
<UpdateCheckerURL>/downloads/aegisub-japan7</UpdateCheckerURL>
|
||||||
|
|
||||||
<VendorRoot>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\vendor))</VendorRoot>
|
<VendorRoot>$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)..\vendor))</VendorRoot>
|
||||||
<BoostPath>$(VendorRoot)\boost</BoostPath>
|
<BoostPath>$(VendorRoot)\boost</BoostPath>
|
||||||
|
|
|
@ -44,10 +44,13 @@ else
|
||||||
tagged_release=0
|
tagged_release=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
last_release=$(git describe --tags)
|
||||||
|
|
||||||
|
|
||||||
new_version_h="\
|
new_version_h="\
|
||||||
#define BUILD_GIT_VERSION_NUMBER ${git_revision}
|
#define BUILD_GIT_VERSION_NUMBER ${git_revision}
|
||||||
#define BUILD_GIT_VERSION_STRING \"${git_version_str}\"
|
#define BUILD_GIT_VERSION_STRING \"${git_version_str}\"
|
||||||
|
#define RELEASE_VERSION \"${last_release#v}\"
|
||||||
#define TAGGED_RELEASE ${tagged_release}
|
#define TAGGED_RELEASE ${tagged_release}
|
||||||
#define INSTALLER_VERSION \"${installer_version}\"
|
#define INSTALLER_VERSION \"${installer_version}\"
|
||||||
#define RESOURCE_BASE_VERSION ${resource_version}"
|
#define RESOURCE_BASE_VERSION ${resource_version}"
|
||||||
|
|
|
@ -523,16 +523,16 @@ AC_MSG_CHECKING([for update checker server])
|
||||||
AC_ARG_WITH(update-server,
|
AC_ARG_WITH(update-server,
|
||||||
AS_HELP_STRING([--with-update-server=HOSTNAME],
|
AS_HELP_STRING([--with-update-server=HOSTNAME],
|
||||||
[Server to use for the update checker
|
[Server to use for the update checker
|
||||||
[updates.aegisub.org]]))
|
[mugen.karaokes.moe]]))
|
||||||
AC_MSG_RESULT(${with_update_server:=updates.aegisub.org})
|
AC_MSG_RESULT(${with_update_server:=mugen.karaokes.moe})
|
||||||
AC_DEFINE_UNQUOTED([UPDATE_CHECKER_SERVER], ["$with_update_server"],
|
AC_DEFINE_UNQUOTED([UPDATE_CHECKER_SERVER], ["$with_update_server"],
|
||||||
[Server for the update checker])
|
[Server for the update checker])
|
||||||
|
|
||||||
AC_MSG_CHECKING([for update checker base URL])
|
AC_MSG_CHECKING([for update checker base URL])
|
||||||
AC_ARG_WITH(update-url,
|
AC_ARG_WITH(update-url,
|
||||||
AS_HELP_STRING([--with-update-url=HOSTNAME],
|
AS_HELP_STRING([--with-update-url=HOSTNAME],
|
||||||
[Base path to use for the update checker [/trunk]]))
|
[Base path to use for the update checker [/downloads/aegisub-japan7]]))
|
||||||
AC_MSG_RESULT(${with_update_url:=/trunk})
|
AC_MSG_RESULT(${with_update_url:=/downloads/aegisub-japan7})
|
||||||
AC_DEFINE_UNQUOTED([UPDATE_CHECKER_BASE_URL], ["$with_update_url"],
|
AC_DEFINE_UNQUOTED([UPDATE_CHECKER_BASE_URL], ["$with_update_url"],
|
||||||
[Base path for the update checker])
|
[Base path for the update checker])
|
||||||
|
|
||||||
|
|
|
@ -71,11 +71,59 @@ namespace {
|
||||||
std::mutex VersionCheckLock;
|
std::mutex VersionCheckLock;
|
||||||
|
|
||||||
struct AegisubUpdateDescription {
|
struct AegisubUpdateDescription {
|
||||||
std::string url;
|
int major;
|
||||||
std::string friendly_name;
|
int minor;
|
||||||
|
int patch;
|
||||||
|
std::string extra;
|
||||||
std::string description;
|
std::string description;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AegisubUpdateDescription ParseVersionString(std::string version_string) {
|
||||||
|
std::vector<std::string> maj_min;
|
||||||
|
std::vector<std::string> patch;
|
||||||
|
agi::Split(maj_min, version_string, '.');
|
||||||
|
agi::Split(patch, maj_min[2], '-');
|
||||||
|
|
||||||
|
std::string extra = "";
|
||||||
|
if (patch.size() > 1) {
|
||||||
|
extra = patch[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return AegisubUpdateDescription{
|
||||||
|
atoi(maj_min[0].c_str()),
|
||||||
|
atoi(maj_min[1].c_str()),
|
||||||
|
atoi(patch[0].c_str()),
|
||||||
|
extra,
|
||||||
|
""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsNewer(AegisubUpdateDescription update) {
|
||||||
|
AegisubUpdateDescription current = ParseVersionString(GetReleaseVersion());
|
||||||
|
|
||||||
|
if (update.major > current.major)
|
||||||
|
return true;
|
||||||
|
else if (update.major == current.major)
|
||||||
|
if (update.minor > current.minor)
|
||||||
|
return true;
|
||||||
|
else if (update.minor == current.minor)
|
||||||
|
if (update.patch > current.patch)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return update.extra.compare(current.extra) > 0;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string AegisubVersion(AegisubUpdateDescription update) {
|
||||||
|
std::ostringstream s;
|
||||||
|
s << update.major << "." << update.minor << "." << update.patch;
|
||||||
|
if (!update.extra.empty())
|
||||||
|
s << "-" << update.extra;
|
||||||
|
|
||||||
|
return s.str();
|
||||||
|
}
|
||||||
|
|
||||||
class VersionCheckerResultDialog final : public wxDialog {
|
class VersionCheckerResultDialog final : public wxDialog {
|
||||||
void OnCloseButton(wxCommandEvent &evt);
|
void OnCloseButton(wxCommandEvent &evt);
|
||||||
void OnRemindMeLater(wxCommandEvent &evt);
|
void OnRemindMeLater(wxCommandEvent &evt);
|
||||||
|
@ -84,12 +132,12 @@ class VersionCheckerResultDialog final : public wxDialog {
|
||||||
wxCheckBox *automatic_check_checkbox;
|
wxCheckBox *automatic_check_checkbox;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VersionCheckerResultDialog(wxString const& main_text, const std::vector<AegisubUpdateDescription> &updates);
|
VersionCheckerResultDialog(wxString const& main_text, const AegisubUpdateDescription update);
|
||||||
|
|
||||||
bool ShouldPreventAppExit() const override { return false; }
|
bool ShouldPreventAppExit() const override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
VersionCheckerResultDialog::VersionCheckerResultDialog(wxString const& main_text, const std::vector<AegisubUpdateDescription> &updates)
|
VersionCheckerResultDialog::VersionCheckerResultDialog(wxString const& main_text, const AegisubUpdateDescription update)
|
||||||
: wxDialog(nullptr, -1, _("Version Checker"))
|
: wxDialog(nullptr, -1, _("Version Checker"))
|
||||||
{
|
{
|
||||||
const int controls_width = 500;
|
const int controls_width = 500;
|
||||||
|
@ -100,10 +148,10 @@ VersionCheckerResultDialog::VersionCheckerResultDialog(wxString const& main_text
|
||||||
text->Wrap(controls_width);
|
text->Wrap(controls_width);
|
||||||
main_sizer->Add(text, 0, wxBOTTOM|wxEXPAND, 6);
|
main_sizer->Add(text, 0, wxBOTTOM|wxEXPAND, 6);
|
||||||
|
|
||||||
for (auto const& update : updates) {
|
main_sizer->Add(new wxStaticLine(this), 0, wxEXPAND|wxALL, 6);
|
||||||
main_sizer->Add(new wxStaticLine(this), 0, wxEXPAND|wxALL, 6);
|
|
||||||
|
|
||||||
text = new wxStaticText(this, -1, to_wx(update.friendly_name));
|
if (IsNewer(update)) {
|
||||||
|
text = new wxStaticText(this, -1, to_wx("Aegisub-Japan7"));
|
||||||
wxFont boldfont = text->GetFont();
|
wxFont boldfont = text->GetFont();
|
||||||
boldfont.SetWeight(wxFONTWEIGHT_BOLD);
|
boldfont.SetWeight(wxFONTWEIGHT_BOLD);
|
||||||
text->SetFont(boldfont);
|
text->SetFont(boldfont);
|
||||||
|
@ -112,21 +160,25 @@ VersionCheckerResultDialog::VersionCheckerResultDialog(wxString const& main_text
|
||||||
wxTextCtrl *descbox = new wxTextCtrl(this, -1, to_wx(update.description), wxDefaultPosition, wxSize(controls_width,60), wxTE_MULTILINE|wxTE_READONLY);
|
wxTextCtrl *descbox = new wxTextCtrl(this, -1, to_wx(update.description), wxDefaultPosition, wxSize(controls_width,60), wxTE_MULTILINE|wxTE_READONLY);
|
||||||
main_sizer->Add(descbox, 0, wxEXPAND|wxBOTTOM, 6);
|
main_sizer->Add(descbox, 0, wxEXPAND|wxBOTTOM, 6);
|
||||||
|
|
||||||
main_sizer->Add(new wxHyperlinkCtrl(this, -1, to_wx(update.url), to_wx(update.url)), 0, wxALIGN_LEFT|wxBOTTOM, 6);
|
std::ostringstream surl;
|
||||||
|
surl << "https://" << UPDATE_CHECKER_SERVER << UPDATE_CHECKER_BASE_URL << "/Aegisub-Japan7-x64-" << AegisubVersion(update) << ".exe";
|
||||||
|
std::string url = surl.str();
|
||||||
|
|
||||||
|
main_sizer->Add(new wxHyperlinkCtrl(this, -1, to_wx(url), to_wx(url)), 0, wxALIGN_LEFT|wxBOTTOM, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
automatic_check_checkbox = new wxCheckBox(this, -1, _("&Auto Check for Updates"));
|
automatic_check_checkbox = new wxCheckBox(this, -1, _("&Auto Check for Updates"));
|
||||||
automatic_check_checkbox->SetValue(OPT_GET("App/Auto/Check For Updates")->GetBool());
|
automatic_check_checkbox->SetValue(OPT_GET("App/Auto/Check For Updates")->GetBool());
|
||||||
|
|
||||||
wxButton *remind_later_button = nullptr;
|
wxButton *remind_later_button = nullptr;
|
||||||
if (updates.size() > 0)
|
if (IsNewer(update))
|
||||||
remind_later_button = new wxButton(this, wxID_NO, _("Remind me again in a &week"));
|
remind_later_button = new wxButton(this, wxID_NO, _("Remind me again in a &week"));
|
||||||
|
|
||||||
wxButton *close_button = new wxButton(this, wxID_OK, _("&Close"));
|
wxButton *close_button = new wxButton(this, wxID_OK, _("&Close"));
|
||||||
SetAffirmativeId(wxID_OK);
|
SetAffirmativeId(wxID_OK);
|
||||||
SetEscapeId(wxID_OK);
|
SetEscapeId(wxID_OK);
|
||||||
|
|
||||||
if (updates.size())
|
if (IsNewer(update))
|
||||||
main_sizer->Add(new wxStaticLine(this), 0, wxEXPAND|wxALL, 6);
|
main_sizer->Add(new wxStaticLine(this), 0, wxEXPAND|wxALL, 6);
|
||||||
main_sizer->Add(automatic_check_checkbox, 0, wxEXPAND|wxBOTTOM, 6);
|
main_sizer->Add(automatic_check_checkbox, 0, wxEXPAND|wxBOTTOM, 6);
|
||||||
|
|
||||||
|
@ -280,25 +332,19 @@ static wxString GetAegisubLanguage() {
|
||||||
return to_wx(OPT_GET("App/Language")->GetString());
|
return to_wx(OPT_GET("App/Language")->GetString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DoCheck(bool interactive) {
|
AegisubUpdateDescription GetLatestVersion() {
|
||||||
boost::asio::ip::tcp::iostream stream;
|
boost::asio::ip::tcp::iostream stream;
|
||||||
stream.connect(UPDATE_CHECKER_SERVER, "http");
|
stream.connect(UPDATE_CHECKER_SERVER, "http");
|
||||||
if (!stream)
|
if (!stream)
|
||||||
throw VersionCheckError(from_wx(_("Could not connect to updates server.")));
|
throw VersionCheckError(from_wx(_("Could not connect to updates server.")));
|
||||||
|
|
||||||
agi::format(stream,
|
agi::format(stream,
|
||||||
"GET %s?rev=%d&rel=%d&os=%s&lang=%s&aegilang=%s HTTP/1.0\r\n"
|
"GET %s/latest HTTP/1.1\r\n"
|
||||||
"User-Agent: Aegisub %s\r\n"
|
"User-Agent: Aegisub-Japan7\r\n"
|
||||||
"Host: %s\r\n"
|
"Host: %s\r\n"
|
||||||
"Accept: */*\r\n"
|
"Accept: */*\r\n"
|
||||||
"Connection: close\r\n\r\n"
|
"Connection: close\r\n\r\n"
|
||||||
, UPDATE_CHECKER_BASE_URL
|
, UPDATE_CHECKER_BASE_URL
|
||||||
, GetSVNRevision()
|
|
||||||
, (GetIsOfficialRelease() ? 1 : 0)
|
|
||||||
, GetOSShortName()
|
|
||||||
, GetSystemLanguage()
|
|
||||||
, GetAegisubLanguage()
|
|
||||||
, GetAegisubLongVersionString()
|
|
||||||
, UPDATE_CHECKER_SERVER);
|
, UPDATE_CHECKER_SERVER);
|
||||||
|
|
||||||
std::string http_version;
|
std::string http_version;
|
||||||
|
@ -316,36 +362,39 @@ void DoCheck(bool interactive) {
|
||||||
for (auto const& header : agi::line_iterator<std::string>(stream))
|
for (auto const& header : agi::line_iterator<std::string>(stream))
|
||||||
if (header.empty()) break;
|
if (header.empty()) break;
|
||||||
|
|
||||||
std::vector<AegisubUpdateDescription> results;
|
AegisubUpdateDescription version = AegisubUpdateDescription{0, 0, 0, "", ""};
|
||||||
|
std::ostringstream desc;
|
||||||
for (auto const& line : agi::line_iterator<std::string>(stream)) {
|
for (auto const& line : agi::line_iterator<std::string>(stream)) {
|
||||||
if (line.empty()) continue;
|
|
||||||
|
|
||||||
std::vector<std::string> parsed;
|
if (version.major == 0 && version.minor == 0 && version.minor == 0) {
|
||||||
agi::Split(parsed, line, '|');
|
version = ParseVersionString(line);
|
||||||
if (parsed.size() != 6) continue;
|
} else {
|
||||||
|
desc << line << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (atoi(parsed[1].c_str()) <= GetSVNRevision())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// 0 and 2 being things that never got used
|
|
||||||
results.push_back(AegisubUpdateDescription{
|
|
||||||
inline_string_decode(parsed[3]),
|
|
||||||
inline_string_decode(parsed[4]),
|
|
||||||
inline_string_decode(parsed[5])
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!results.empty() || interactive) {
|
if (version.major != 0 && version.minor != 0 && version.patch != 0) {
|
||||||
|
version.description = desc.str();
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw VersionCheckError(from_wx(_("Could not get update from updates server.")));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DoCheck(bool interactive) {
|
||||||
|
AegisubUpdateDescription update = GetLatestVersion();
|
||||||
|
|
||||||
|
if (IsNewer(update) || interactive) {
|
||||||
agi::dispatch::Main().Async([=]{
|
agi::dispatch::Main().Async([=]{
|
||||||
wxString text;
|
wxString text;
|
||||||
if (results.size() == 1)
|
if (IsNewer(update))
|
||||||
text = _("An update to Aegisub was found.");
|
text = _("An update to Aegisub was found.");
|
||||||
else if (results.size() > 1)
|
|
||||||
text = _("Several possible updates to Aegisub were found.");
|
|
||||||
else
|
else
|
||||||
text = _("There are no updates to Aegisub.");
|
text = _("There are no updates to Aegisub.");
|
||||||
|
|
||||||
new VersionCheckerResultDialog(text, results);
|
new VersionCheckerResultDialog(text, update);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,10 @@ const char *GetVersionNumber() {
|
||||||
return BUILD_GIT_VERSION_STRING;
|
return BUILD_GIT_VERSION_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *GetReleaseVersion() {
|
||||||
|
return RELEASE_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
int GetSVNRevision() {
|
int GetSVNRevision() {
|
||||||
#ifdef BUILD_GIT_VERSION_NUMBER
|
#ifdef BUILD_GIT_VERSION_NUMBER
|
||||||
return BUILD_GIT_VERSION_NUMBER;
|
return BUILD_GIT_VERSION_NUMBER;
|
||||||
|
|
|
@ -46,3 +46,5 @@ bool GetIsOfficialRelease();
|
||||||
const char *GetVersionNumber();
|
const char *GetVersionNumber();
|
||||||
/// Get SVN revision
|
/// Get SVN revision
|
||||||
int GetSVNRevision();
|
int GetSVNRevision();
|
||||||
|
/// Get Release Version
|
||||||
|
const char *GetReleaseVersion();
|
||||||
|
|
Loading…
Reference in New Issue