1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Projucer: Made the autoupdater obtain executable file permissions directly from the JUCE distribution zips

This commit is contained in:
Tom Poole 2019-11-15 16:59:28 +00:00
parent 5e2f53237e
commit 31e78da5dd
2 changed files with 17 additions and 25 deletions

View file

@ -445,13 +445,15 @@ private:
return r;
}
r = applyAutoUpdaterFile (unzipTarget);
#if JUCE_LINUX || JUCE_MAC
r = setFilePermissions (unzipTarget, zip);
if (r.failed())
{
unzipTarget.deleteRecursively();
return r;
}
#endif
if (targetFolder.exists())
{
@ -477,29 +479,24 @@ private:
return Result::ok();
}
Result applyAutoUpdaterFile (const File& root)
Result setFilePermissions (const File& root, const ZipFile& zip)
{
auto autoUpdaterFile = root.getChildFile (".autoupdater.xml");
constexpr uint32 executableFlag = (1 << 22);
if (autoUpdaterFile.existsAsFile())
for (int i = 0; i < zip.getNumEntries(); ++i)
{
#if JUCE_LINUX || JUCE_MAC
if (auto parent = parseXML (autoUpdaterFile))
auto* entry = zip.getEntry (i);
if ((entry->externalFileAttributes & executableFlag) != 0 && entry->filename.getLastCharacter() != '/')
{
if (auto* execElement = parent->getChildByName ("EXECUTABLE"))
{
forEachXmlChildElementWithTagName (*execElement, e, "FILE")
{
auto file = root.getChildFile (e->getAllSubText());
auto exeFile = root.getChildFile (entry->filename);
if (file.exists() && ! file.setExecutePermission (true))
return Result::fail ("Failed to set executable file permission for " + file.getFileName());
}
}
if (! exeFile.exists())
return Result::fail ("Failed to find executable file when setting permissions " + exeFile.getFileName());
if (! exeFile.setExecutePermission (true))
return Result::fail ("Failed to set executable file permission for " + exeFile.getFileName());
}
#endif
autoUpdaterFile.deleteFile();
}
return Result::ok();

View file

@ -515,7 +515,7 @@ static int getJuceVersion (const String& v)
+ getVersionElement (v, 0);
}
static int getBuiltJuceVersion()
static constexpr int getBuiltJuceVersion()
{
return JUCE_MAJOR_VERSION * 100000
+ JUCE_MINOR_VERSION * 1000
@ -524,11 +524,7 @@ static int getBuiltJuceVersion()
static bool isModuleNewerThanProjucer (const ModuleDescription& module)
{
if (module.getID().startsWith ("juce_")
&& getJuceVersion (module.getVersion()) > getBuiltJuceVersion())
return true;
return false;
return module.getID().startsWith ("juce_") && getJuceVersion (module.getVersion()) > getBuiltJuceVersion();
}
void Project::warnAboutOldProjucerVersion()
@ -537,7 +533,6 @@ void Project::warnAboutOldProjucerVersion()
{
if (isModuleNewerThanProjucer ({ juceModule.second }))
{
// Projucer is out of date!
if (ProjucerApplication::getApp().isRunningCommandLine)
std::cout << "WARNING! This version of the Projucer is out-of-date!" << std::endl;
else