зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1854868: Remove the use of update-settings.ini on macOS and query the accepted MAR channels from the macOS Framework instead. r=bytesized
Differential Revision: https://phabricator.services.mozilla.com/D189488
This commit is contained in:
Родитель
26ab0df735
Коммит
530dbf112d
|
@ -145,8 +145,11 @@
|
|||
#endif
|
||||
@RESPATH@/application.ini
|
||||
#ifdef MOZ_UPDATER
|
||||
# update-settings.ini has been removed on macOS.
|
||||
#ifndef XP_MACOSX
|
||||
@RESPATH@/update-settings.ini
|
||||
#endif
|
||||
#endif
|
||||
@RESPATH@/platform.ini
|
||||
#ifndef MOZ_FOLD_LIBS
|
||||
@BINPATH@/@DLL_PREFIX@mozsqlite3@DLL_SUFFIX@
|
||||
|
|
|
@ -78,3 +78,8 @@
|
|||
@DIR_RESOURCES@defaults/pref/channel-prefs.js
|
||||
@DIR_RESOURCES@defaults/pref/
|
||||
#endif
|
||||
|
||||
# update-settings.ini has been removed on macOS.
|
||||
#ifdef XP_MACOSX
|
||||
@DIR_RESOURCES@update-settings.ini
|
||||
#endif
|
||||
|
|
|
@ -107,7 +107,10 @@ if CONFIG["MOZ_APP_BASENAME"]:
|
|||
)
|
||||
|
||||
FINAL_TARGET_FILES += ["!application.ini"]
|
||||
if CONFIG["MOZ_WIDGET_TOOLKIT"] != "android" and CONFIG["MOZ_UPDATER"]:
|
||||
if (
|
||||
CONFIG["MOZ_WIDGET_TOOLKIT"] not in ("android", "cocoa")
|
||||
and CONFIG["MOZ_UPDATER"]
|
||||
):
|
||||
FINAL_TARGET_PP_FILES += ["update-settings.ini"]
|
||||
|
||||
GeneratedFile(
|
||||
|
|
|
@ -38,16 +38,6 @@ class AutoFILE {
|
|||
FILE* fp_;
|
||||
};
|
||||
|
||||
class AutoCharArray {
|
||||
public:
|
||||
explicit AutoCharArray(size_t len) { ptr_ = new char[len]; }
|
||||
~AutoCharArray() { delete[] ptr_; }
|
||||
operator char*() { return ptr_; }
|
||||
|
||||
private:
|
||||
char* ptr_;
|
||||
};
|
||||
|
||||
static const char kNL[] = "\r\n";
|
||||
static const char kEquals[] = "=";
|
||||
static const char kWhitespace[] = " \t";
|
||||
|
@ -153,7 +143,8 @@ int ReadStrings(const NS_tchar* path, const char* keyList,
|
|||
}
|
||||
|
||||
size_t flen = size_t(len);
|
||||
AutoCharArray fileContents(flen + 1);
|
||||
|
||||
char* fileContents = new char[flen + 1];
|
||||
if (!fileContents) {
|
||||
return READ_STRINGS_MEM_ERROR;
|
||||
}
|
||||
|
@ -170,12 +161,53 @@ int ReadStrings(const NS_tchar* path, const char* keyList,
|
|||
|
||||
fileContents[flen] = '\0';
|
||||
|
||||
char* buffer = fileContents;
|
||||
int result = ReadStringsFromBuffer(fileContents, keyList, numStrings, results,
|
||||
section);
|
||||
delete[] fileContents;
|
||||
return result;
|
||||
}
|
||||
|
||||
// A wrapper function to read strings for the updater.
|
||||
// Added for compatibility with the original code.
|
||||
int ReadStrings(const NS_tchar* path, StringTable* results) {
|
||||
const unsigned int kNumStrings = 2;
|
||||
const char* kUpdaterKeys = "Title\0Info\0";
|
||||
mozilla::UniquePtr<char[]> updater_strings[kNumStrings];
|
||||
|
||||
int result = ReadStrings(path, kUpdaterKeys, kNumStrings, updater_strings);
|
||||
|
||||
if (result == OK) {
|
||||
results->title.swap(updater_strings[0]);
|
||||
results->info.swap(updater_strings[1]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* A very basic parser for updater.ini taken mostly from nsINIParser.cpp
|
||||
* that can be used by standalone apps.
|
||||
*
|
||||
* @param stringBuffer The string buffer to parse
|
||||
* @param keyList List of zero-delimited keys ending with two zero
|
||||
* characters
|
||||
* @param numStrings Number of strings to read into results buffer - must be
|
||||
* equal to the number of keys
|
||||
* @param results Array of strings. Array's length must be equal to
|
||||
* numStrings. Each string will be populated with the value
|
||||
* corresponding to the key with the same index in keyList.
|
||||
* @param section Optional name of the section to read; defaults to
|
||||
* "Strings"
|
||||
*/
|
||||
int ReadStringsFromBuffer(char* stringBuffer, const char* keyList,
|
||||
unsigned int numStrings,
|
||||
mozilla::UniquePtr<char[]>* results,
|
||||
const char* section) {
|
||||
bool inStringsSection = false;
|
||||
|
||||
unsigned int read = 0;
|
||||
|
||||
while (char* token = NS_strtok(kNL, &buffer)) {
|
||||
while (char* token = NS_strtok(kNL, &stringBuffer)) {
|
||||
if (token[0] == '#' || token[0] == ';') { // it's a comment
|
||||
continue;
|
||||
}
|
||||
|
@ -233,23 +265,6 @@ int ReadStrings(const NS_tchar* path, const char* keyList,
|
|||
return (read == numStrings) ? OK : PARSE_ERROR;
|
||||
}
|
||||
|
||||
// A wrapper function to read strings for the updater.
|
||||
// Added for compatibility with the original code.
|
||||
int ReadStrings(const NS_tchar* path, StringTable* results) {
|
||||
const unsigned int kNumStrings = 2;
|
||||
const char* kUpdaterKeys = "Title\0Info\0";
|
||||
mozilla::UniquePtr<char[]> updater_strings[kNumStrings];
|
||||
|
||||
int result = ReadStrings(path, kUpdaterKeys, kNumStrings, updater_strings);
|
||||
|
||||
if (result == OK) {
|
||||
results->title.swap(updater_strings[0]);
|
||||
results->info.swap(updater_strings[1]);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
IniReader::IniReader(const NS_tchar* iniPath,
|
||||
const char* section /* = nullptr */) {
|
||||
if (iniPath) {
|
||||
|
|
|
@ -37,6 +37,15 @@ int ReadStrings(const NS_tchar* path, const char* keyList,
|
|||
unsigned int numStrings, mozilla::UniquePtr<char[]>* results,
|
||||
const char* section = nullptr);
|
||||
|
||||
/**
|
||||
* This function reads in localized strings corresponding to the keys from a
|
||||
* given string buffer.
|
||||
*/
|
||||
int ReadStringsFromBuffer(char* stringBuffer, const char* keyList,
|
||||
unsigned int numStrings,
|
||||
mozilla::UniquePtr<char[]>* results,
|
||||
const char* section = nullptr);
|
||||
|
||||
/**
|
||||
* This class is meant to be a slightly cleaner interface into the ReadStrings
|
||||
* function.
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "updatecommon.h"
|
||||
#ifdef XP_MACOSX
|
||||
# include "UpdateSettingsUtil.h"
|
||||
# include "updaterfileutils_osx.h"
|
||||
#endif // XP_MACOSX
|
||||
|
||||
|
@ -2659,23 +2660,38 @@ static void WaitForServiceFinishThread(void* param) {
|
|||
#endif
|
||||
|
||||
#ifdef MOZ_VERIFY_MAR_SIGNATURE
|
||||
# ifndef XP_MACOSX
|
||||
/**
|
||||
* This function reads in the ACCEPTED_MAR_CHANNEL_IDS from update-settings.ini
|
||||
*
|
||||
* @param path The path to the ini file that is to be read
|
||||
* @param results A pointer to the location to store the read strings
|
||||
* @param aPath The path to the ini file that is to be read
|
||||
* @param aResults A pointer to the location to store the read strings
|
||||
* @return OK on success
|
||||
*/
|
||||
static int ReadMARChannelIDs(const NS_tchar* path,
|
||||
MARChannelStringTable* results) {
|
||||
static int ReadMARChannelIDsFromPath(const NS_tchar* aPath,
|
||||
MARChannelStringTable* aResults) {
|
||||
const unsigned int kNumStrings = 1;
|
||||
const char* kUpdaterKeys = "ACCEPTED_MAR_CHANNEL_IDS\0";
|
||||
int result = ReadStrings(path, kUpdaterKeys, kNumStrings,
|
||||
&results->MARChannelID, "Settings");
|
||||
|
||||
return result;
|
||||
return ReadStrings(aPath, kUpdaterKeys, kNumStrings, &aResults->MARChannelID,
|
||||
"Settings");
|
||||
}
|
||||
#endif
|
||||
# else // XP_MACOSX
|
||||
/**
|
||||
* This function reads in the ACCEPTED_MAR_CHANNEL_IDS from a string buffer.
|
||||
*
|
||||
* @param aChannels A string buffer containing the MAR channel(s).
|
||||
* @param aResults A pointer to the location to store the read strings.
|
||||
* @return OK on success
|
||||
*/
|
||||
static int ReadMARChannelIDsFromBuffer(char* aChannels,
|
||||
MARChannelStringTable* aResults) {
|
||||
const unsigned int kNumStrings = 1;
|
||||
const char* kUpdaterKeys = "ACCEPTED_MAR_CHANNEL_IDS\0";
|
||||
return ReadStringsFromBuffer(aChannels, kUpdaterKeys, kNumStrings,
|
||||
&aResults->MARChannelID, "Settings");
|
||||
}
|
||||
# endif // XP_MACOSX
|
||||
#endif // MOZ_VERIFY_MAR_SIGNATURE
|
||||
|
||||
static int GetUpdateFileName(NS_tchar* fileName, int maxChars) {
|
||||
NS_tsnprintf(fileName, maxChars, NS_T("%s/update.mar"), gPatchDirPath);
|
||||
|
@ -2700,17 +2716,22 @@ static void UpdateThreadFunc(void* param) {
|
|||
}
|
||||
|
||||
if (rv == OK) {
|
||||
MARChannelStringTable MARStrings;
|
||||
# ifndef XP_MACOSX
|
||||
NS_tchar updateSettingsPath[MAXPATHLEN];
|
||||
NS_tsnprintf(updateSettingsPath,
|
||||
sizeof(updateSettingsPath) / sizeof(updateSettingsPath[0]),
|
||||
# ifdef XP_MACOSX
|
||||
NS_T("%s/Contents/Resources/update-settings.ini"),
|
||||
NS_T("%s/update-settings.ini"), gInstallDirPath);
|
||||
rv = ReadMARChannelIDsFromPath(updateSettingsPath, &MARStrings);
|
||||
# else
|
||||
NS_T("%s/update-settings.ini"),
|
||||
if (auto marChannels =
|
||||
UpdateSettingsUtil::GetAcceptedMARChannelsValue()) {
|
||||
rv = ReadMARChannelIDsFromBuffer(marChannels->data(), &MARStrings);
|
||||
} else {
|
||||
rv = UPDATE_SETTINGS_FILE_CHANNEL;
|
||||
}
|
||||
# endif
|
||||
gInstallDirPath);
|
||||
MARChannelStringTable MARStrings;
|
||||
if (ReadMARChannelIDs(updateSettingsPath, &MARStrings) != OK) {
|
||||
if (rv != OK) {
|
||||
rv = UPDATE_SETTINGS_FILE_CHANNEL;
|
||||
} else {
|
||||
rv = gArchiveReader.VerifyProductInformation(
|
||||
|
|
Загрузка…
Ссылка в новой задаче