68 dir = dir.substring(0, dir.length()-1); 69 } 70 return dir; 71 } 72 return "/opt"; 73 }, 74 (s, p) -> s 75 ); 76 77 static final BundlerParamInfo<String> LINUX_PACKAGE_DEPENDENCIES = 78 new StandardBundlerParam<>( 79 Arguments.CLIOptions.LINUX_PACKAGE_DEPENDENCIES.getId(), 80 String.class, 81 params -> { 82 return ""; 83 }, 84 (s, p) -> s 85 ); 86 87 @Override 88 public boolean validate(Map<String, ? super Object> p) 89 throws UnsupportedPlatformException, ConfigException { 90 try { 91 if (p == null) throw new ConfigException( 92 I18N.getString("error.parameters-null"), 93 I18N.getString("error.parameters-null.advice")); 94 95 return doValidate(p); 96 } catch (RuntimeException re) { 97 if (re.getCause() instanceof ConfigException) { 98 throw (ConfigException) re.getCause(); 99 } else { 100 throw new ConfigException(re); 101 } 102 } 103 } 104 105 private boolean doValidate(Map<String, ? super Object> p) 106 throws UnsupportedPlatformException, ConfigException { 107 if (Platform.getPlatform() != Platform.LINUX) { 108 throw new UnsupportedPlatformException(); 109 } 110 111 imageBundleValidation(p); 112 113 return true; 114 } 115 116 // it is static for the sake of sharing with "installer" bundlers 117 // that may skip calls to validate/bundle in this class! 118 static File getRootDir(File outDir, Map<String, ? super Object> p) { 119 return new File(outDir, APP_NAME.fetchFrom(p)); 120 } 121 122 static String getLauncherCfgName(Map<String, ? super Object> p) { 123 return "app/" + APP_NAME.fetchFrom(p) +".cfg"; 124 } 125 126 File doBundle(Map<String, ? super Object> p, File outputDirectory, 127 boolean dependentTask) throws PackagerException { 128 if (StandardBundlerParam.isRuntimeInstaller(p)) { 129 return PREDEFINED_RUNTIME_IMAGE.fetchFrom(p); 130 } else { 131 return doAppBundle(p, outputDirectory, dependentTask); 132 } 133 } 134 135 private File doAppBundle(Map<String, ? super Object> p, 136 File outputDirectory, boolean dependentTask) throws PackagerException { 137 try { 138 File rootDirectory = createRoot(p, outputDirectory, dependentTask, 139 APP_NAME.fetchFrom(p)); 140 AbstractAppImageBuilder appBuilder = new LinuxAppImageBuilder(p, 141 outputDirectory.toPath()); 142 if (PREDEFINED_RUNTIME_IMAGE.fetchFrom(p) == null ) { 143 JLinkBundlerHelper.execute(p, appBuilder); 144 } else { 145 StandardBundlerParam.copyPredefinedRuntimeImage(p, appBuilder); 146 } 147 return rootDirectory; 148 } catch (PackagerException pe) { 149 throw pe; 150 } catch (Exception ex) { 151 Log.verbose(ex); 152 throw new PackagerException(ex); 153 } 154 } 155 156 @Override 157 public String getName() { 158 return I18N.getString("app.bundler.name"); 159 } 160 161 @Override 162 public String getDescription() { 163 return I18N.getString("app.bundler.description"); 164 } 165 | 68 dir = dir.substring(0, dir.length()-1); 69 } 70 return dir; 71 } 72 return "/opt"; 73 }, 74 (s, p) -> s 75 ); 76 77 static final BundlerParamInfo<String> LINUX_PACKAGE_DEPENDENCIES = 78 new StandardBundlerParam<>( 79 Arguments.CLIOptions.LINUX_PACKAGE_DEPENDENCIES.getId(), 80 String.class, 81 params -> { 82 return ""; 83 }, 84 (s, p) -> s 85 ); 86 87 @Override 88 public boolean validate(Map<String, ? super Object> params) 89 throws UnsupportedPlatformException, ConfigException { 90 try { 91 if (params == null) throw new ConfigException( 92 I18N.getString("error.parameters-null"), 93 I18N.getString("error.parameters-null.advice")); 94 95 return doValidate(params); 96 } catch (RuntimeException re) { 97 if (re.getCause() instanceof ConfigException) { 98 throw (ConfigException) re.getCause(); 99 } else { 100 throw new ConfigException(re); 101 } 102 } 103 } 104 105 private boolean doValidate(Map<String, ? super Object> params) 106 throws UnsupportedPlatformException, ConfigException { 107 if (Platform.getPlatform() != Platform.LINUX) { 108 throw new UnsupportedPlatformException(); 109 } 110 111 imageBundleValidation(params); 112 113 return true; 114 } 115 116 // it is static for the sake of sharing with "installer" bundlers 117 // that may skip calls to validate/bundle in this class! 118 static File getRootDir(File outDir, Map<String, ? super Object> params) { 119 return new File(outDir, APP_NAME.fetchFrom(params)); 120 } 121 122 static String getLauncherCfgName(Map<String, ? super Object> params) { 123 return "app/" + APP_NAME.fetchFrom(params) +".cfg"; 124 } 125 126 File doBundle(Map<String, ? super Object> params, File outputDirectory, 127 boolean dependentTask) throws PackagerException { 128 if (StandardBundlerParam.isRuntimeInstaller(params)) { 129 return PREDEFINED_RUNTIME_IMAGE.fetchFrom(params); 130 } else { 131 return doAppBundle(params, outputDirectory, dependentTask); 132 } 133 } 134 135 private File doAppBundle(Map<String, ? super Object> params, 136 File outputDirectory, boolean dependentTask) throws PackagerException { 137 try { 138 File rootDirectory = createRoot(params, outputDirectory, 139 dependentTask, APP_NAME.fetchFrom(params)); 140 AbstractAppImageBuilder appBuilder = new LinuxAppImageBuilder( 141 params, outputDirectory.toPath()); 142 if (PREDEFINED_RUNTIME_IMAGE.fetchFrom(params) == null ) { 143 JLinkBundlerHelper.execute(params, appBuilder); 144 } else { 145 StandardBundlerParam.copyPredefinedRuntimeImage( 146 params, appBuilder); 147 } 148 return rootDirectory; 149 } catch (PackagerException pe) { 150 throw pe; 151 } catch (Exception ex) { 152 Log.verbose(ex); 153 throw new PackagerException(ex); 154 } 155 } 156 157 @Override 158 public String getName() { 159 return I18N.getString("app.bundler.name"); 160 } 161 162 @Override 163 public String getDescription() { 164 return I18N.getString("app.bundler.description"); 165 } 166 |