From 3cf85668d1d4e462e455df9dcddb3b988a1fa6ff Mon Sep 17 00:00:00 2001 From: Kirill Vainer Date: Tue, 11 Aug 2015 21:50:32 -0400 Subject: [PATCH] sdk installer: fix permissions issues on JRE and Blender executables --- .../src/org/mycompany/ConfigurationLogic.java | 17 ++++++++++ .../src/org/mycompany/ConfigurationLogic.java | 33 +++++++++++++++---- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/sdk/nbi/stub/ext/components/products/blender/src/org/mycompany/ConfigurationLogic.java b/sdk/nbi/stub/ext/components/products/blender/src/org/mycompany/ConfigurationLogic.java index be992b57b..d1616e459 100644 --- a/sdk/nbi/stub/ext/components/products/blender/src/org/mycompany/ConfigurationLogic.java +++ b/sdk/nbi/stub/ext/components/products/blender/src/org/mycompany/ConfigurationLogic.java @@ -1,8 +1,11 @@ package org.mycompany; +import java.io.File; import java.util.List; import org.netbeans.installer.product.Registry; +import org.netbeans.installer.product.components.Product; import org.netbeans.installer.product.components.ProductConfigurationLogic; +import org.netbeans.installer.utils.LogManager; import org.netbeans.installer.utils.helper.RemovalMode; import org.netbeans.installer.utils.exceptions.InitializationException; import org.netbeans.installer.utils.exceptions.InstallationException; @@ -35,6 +38,20 @@ public class ConfigurationLogic extends ProductConfigurationLogic { @Override public void install(Progress progress) throws InstallationException { + final Product product = getProduct(); + final File installLocation = product.getInstallationLocation(); + LogManager.log("Setting Blender files as executable"); + setExecutableFile(installLocation, "blender"); + setExecutableFile(installLocation, "blenderplayer"); + setExecutableFile(installLocation, "blender-softwaregl"); + } + private static void setExecutableFile(File parent, String path) { + File binFile = new File(parent, path); + try { + binFile.setExecutable(true, false); + } catch (Exception ex) { + ex.printStackTrace(); + } } @Override diff --git a/sdk/nbi/stub/ext/components/products/helloworld/src/org/mycompany/ConfigurationLogic.java b/sdk/nbi/stub/ext/components/products/helloworld/src/org/mycompany/ConfigurationLogic.java index 1b6e709a0..d6cd82a78 100644 --- a/sdk/nbi/stub/ext/components/products/helloworld/src/org/mycompany/ConfigurationLogic.java +++ b/sdk/nbi/stub/ext/components/products/helloworld/src/org/mycompany/ConfigurationLogic.java @@ -198,16 +198,37 @@ public class ConfigurationLogic extends ProductConfigurationLogic { throw new InstallationException("Cannot copy JDK",e); } // set permissions: - File binDir = new File(target, "bin"); - for (File file : binDir.listFiles()) { - try { - file.setExecutable(true); - } catch (Exception ex) { ex.printStackTrace(); } - } + // ADDED BY KIRILL: force correct permissions for JDK files + LogManager.log("Setting JDK files as executable"); + setExecutableContents(target, "bin"); + setExecutableContents(target, "db/bin"); + setExecutableContents(target, "jre/bin"); + setExecutableFile(target, "lib/jexec"); + setExecutableFile(target, "lib/amd64/libjawt.so"); + setExecutableFile(target, "lib/amd64/jli/libjli.so"); + setExecutableFile(target, "lib/visualvm/platform/lib/nbexec"); // to add uninstaller logic: SystemUtils.getNativeUtils().addUninstallerJVM(new LauncherResource(false, target)); } } + private static void setExecutableContents(File parent, String path) { + File binDir = new File(parent, path); + for (File file : binDir.listFiles()) { + try { + file.setExecutable(true, false); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + } + private static void setExecutableFile(File parent, String path) { + File binFile = new File(parent, path); + try { + binFile.setExecutable(true, false); + } catch (Exception ex) { + ex.printStackTrace(); + } + } @Override public void uninstall(Progress progress) throws UninstallationException {