Browse Source

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

tags/2021-05-28
Tom Poole 5 years ago
parent
commit
31e78da5dd
2 changed files with 18 additions and 26 deletions
  1. +16
    -19
      extras/Projucer/Source/Application/jucer_AutoUpdater.cpp
  2. +2
    -7
      extras/Projucer/Source/Project/jucer_Project.cpp

+ 16
- 19
extras/Projucer/Source/Application/jucer_AutoUpdater.cpp 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());
if (file.exists() && ! file.setExecutePermission (true))
return Result::fail ("Failed to set executable file permission for " + file.getFileName());
}
}
}
#endif
auto exeFile = root.getChildFile (entry->filename);
autoUpdaterFile.deleteFile();
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());
}
}
return Result::ok();


+ 2
- 7
extras/Projucer/Source/Project/jucer_Project.cpp 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


Loading…
Cancel
Save