equal
deleted
inserted
replaced
24 */ |
24 */ |
25 |
25 |
26 package jdk.jpackage.internal; |
26 package jdk.jpackage.internal; |
27 |
27 |
28 import java.io.*; |
28 import java.io.*; |
29 import java.nio.file.Files; |
|
30 import java.nio.file.Path; |
29 import java.nio.file.Path; |
31 import java.text.MessageFormat; |
30 import java.text.MessageFormat; |
32 import java.util.*; |
31 import java.util.*; |
33 import java.util.regex.Matcher; |
32 import java.util.regex.Matcher; |
34 import java.util.regex.Pattern; |
33 import java.util.regex.Pattern; |
35 import java.util.stream.Collectors; |
34 import java.util.stream.Collectors; |
36 |
35 |
37 import static jdk.jpackage.internal.StandardBundlerParam.*; |
36 import static jdk.jpackage.internal.StandardBundlerParam.*; |
38 import static jdk.jpackage.internal.LinuxAppBundler.LINUX_INSTALL_DIR; |
37 import static jdk.jpackage.internal.LinuxAppBundler.LINUX_INSTALL_DIR; |
|
38 import static jdk.jpackage.internal.OverridableResource.createResource; |
39 |
39 |
40 /** |
40 /** |
41 * There are two command line options to configure license information for RPM |
41 * There are two command line options to configure license information for RPM |
42 * packaging: --linux-rpm-license-type and --license-file. Value of |
42 * packaging: --linux-rpm-license-type and --license-file. Value of |
43 * --linux-rpm-license-type command line option configures "License:" section |
43 * --linux-rpm-license-type command line option configures "License:" section |
144 PackagerException, IOException { |
144 PackagerException, IOException { |
145 |
145 |
146 Path specFile = specFile(params); |
146 Path specFile = specFile(params); |
147 |
147 |
148 // prepare spec file |
148 // prepare spec file |
149 Files.createDirectories(specFile.getParent()); |
149 createResource(DEFAULT_SPEC_TEMPLATE, params) |
150 try (Writer w = Files.newBufferedWriter(specFile)) { |
150 .setCategory(I18N.getString("resource.rpm-spec-file")) |
151 String content = preprocessTextResource( |
151 .setSubstitutionData(replacementData) |
152 specFile.getFileName().toString(), |
152 .saveToFile(specFile); |
153 I18N.getString("resource.rpm-spec-file"), |
|
154 DEFAULT_SPEC_TEMPLATE, replacementData, |
|
155 VERBOSE.fetchFrom(params), |
|
156 RESOURCE_DIR.fetchFrom(params)); |
|
157 w.write(content); |
|
158 } |
|
159 |
153 |
160 return buildRPM(params, outputParentDir); |
154 return buildRPM(params, outputParentDir); |
161 } |
155 } |
162 |
156 |
163 @Override |
157 @Override |
169 params), PACKAGE_NAME.fetchFrom(params)).toString()); |
163 params), PACKAGE_NAME.fetchFrom(params)).toString()); |
170 data.put("APPLICATION_SUMMARY", APP_NAME.fetchFrom(params)); |
164 data.put("APPLICATION_SUMMARY", APP_NAME.fetchFrom(params)); |
171 data.put("APPLICATION_LICENSE_TYPE", LICENSE_TYPE.fetchFrom(params)); |
165 data.put("APPLICATION_LICENSE_TYPE", LICENSE_TYPE.fetchFrom(params)); |
172 |
166 |
173 String licenseFile = LICENSE_FILE.fetchFrom(params); |
167 String licenseFile = LICENSE_FILE.fetchFrom(params); |
174 if (licenseFile == null) { |
168 if (licenseFile != null) { |
175 licenseFile = ""; |
|
176 } else { |
|
177 licenseFile = Path.of(licenseFile).toAbsolutePath().normalize().toString(); |
169 licenseFile = Path.of(licenseFile).toAbsolutePath().normalize().toString(); |
178 } |
170 } |
179 data.put("APPLICATION_LICENSE_FILE", licenseFile); |
171 data.put("APPLICATION_LICENSE_FILE", licenseFile); |
180 data.put("APPLICATION_GROUP", Optional.ofNullable( |
172 data.put("APPLICATION_GROUP", GROUP.fetchFrom(params)); |
181 GROUP.fetchFrom(params)).orElse("")); |
|
182 |
173 |
183 return data; |
174 return data; |
184 } |
175 } |
185 |
176 |
186 @Override |
177 @Override |