author | herrick |
Wed, 16 Oct 2019 09:57:23 -0400 | |
branch | JDK-8200758-branch |
changeset 58647 | 2c43b89b1679 |
parent 58417 | 67ffaf3a2b75 |
child 58696 | 61c44899b4eb |
permissions | -rw-r--r-- |
57038 | 1 |
/* |
57106
ea870b9ce89a
8216492: Update copyright of all new jpackage fils to 2019
kcr
parents:
57103
diff
changeset
|
2 |
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
57038 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
57039 | 26 |
package jdk.jpackage.internal; |
57038 | 27 |
|
28 |
import java.io.*; |
|
57807
4a15115716ea
8215381: Investigate if current implementation of --license-file is correct for Debian packages
herrick
parents:
57790
diff
changeset
|
29 |
import java.nio.charset.StandardCharsets; |
57808 | 30 |
import java.nio.file.FileVisitResult; |
57038 | 31 |
import java.nio.file.Files; |
57807
4a15115716ea
8215381: Investigate if current implementation of --license-file is correct for Debian packages
herrick
parents:
57790
diff
changeset
|
32 |
import java.nio.file.Path; |
57808 | 33 |
import java.nio.file.SimpleFileVisitor; |
34 |
import java.nio.file.attribute.BasicFileAttributes; |
|
35 |
||
57038 | 36 |
import java.nio.file.attribute.PosixFilePermission; |
37 |
import java.nio.file.attribute.PosixFilePermissions; |
|
38 |
import java.text.MessageFormat; |
|
39 |
import java.util.*; |
|
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
40 |
import java.util.regex.Matcher; |
57038 | 41 |
import java.util.regex.Pattern; |
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
42 |
import java.util.stream.Collectors; |
57807
4a15115716ea
8215381: Investigate if current implementation of --license-file is correct for Debian packages
herrick
parents:
57790
diff
changeset
|
43 |
import java.util.stream.Stream; |
58303
88453b906981
8231279 : Change install location for copyright file for Debian package
herrick
parents:
58301
diff
changeset
|
44 |
import static jdk.jpackage.internal.LinuxAppBundler.LINUX_INSTALL_DIR; |
58647
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58417
diff
changeset
|
45 |
import static jdk.jpackage.internal.OverridableResource.createResource; |
57038 | 46 |
|
57039 | 47 |
import static jdk.jpackage.internal.StandardBundlerParam.*; |
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
48 |
|
57038 | 49 |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
50 |
public class LinuxDebBundler extends LinuxPackageBundler { |
57038 | 51 |
|
52 |
// Debian rules for package naming are used here |
|
53 |
// https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source |
|
54 |
// |
|
55 |
// Package names must consist only of lower case letters (a-z), |
|
56 |
// digits (0-9), plus (+) and minus (-) signs, and periods (.). |
|
57 |
// They must be at least two characters long and |
|
58 |
// must start with an alphanumeric character. |
|
59 |
// |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
60 |
private static final Pattern DEB_PACKAGE_NAME_PATTERN = |
57038 | 61 |
Pattern.compile("^[a-z][a-z\\d\\+\\-\\.]+"); |
62 |
||
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
63 |
private static final BundlerParamInfo<String> PACKAGE_NAME = |
57038 | 64 |
new StandardBundlerParam<> ( |
65 |
Arguments.CLIOptions.LINUX_BUNDLE_NAME.getId(), |
|
66 |
String.class, |
|
67 |
params -> { |
|
68 |
String nm = APP_NAME.fetchFrom(params); |
|
69 |
||
70 |
if (nm == null) return null; |
|
71 |
||
72 |
// make sure to lower case and spaces/underscores become dashes |
|
73 |
nm = nm.toLowerCase().replaceAll("[ _]", "-"); |
|
74 |
return nm; |
|
75 |
}, |
|
76 |
(s, p) -> { |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
77 |
if (!DEB_PACKAGE_NAME_PATTERN.matcher(s).matches()) { |
57038 | 78 |
throw new IllegalArgumentException(new ConfigException( |
79 |
MessageFormat.format(I18N.getString( |
|
80 |
"error.invalid-value-for-package-name"), s), |
|
81 |
I18N.getString( |
|
82 |
"error.invalid-value-for-package-name.advice"))); |
|
83 |
} |
|
84 |
||
85 |
return s; |
|
86 |
}); |
|
87 |
||
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
88 |
private final static String TOOL_DPKG_DEB = "dpkg-deb"; |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
89 |
private final static String TOOL_DPKG = "dpkg"; |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
90 |
private final static String TOOL_FAKEROOT = "fakeroot"; |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
91 |
|
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
92 |
private final static String DEB_ARCH; |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
93 |
static { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
94 |
String debArch; |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
95 |
try { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
96 |
debArch = Executor.of(TOOL_DPKG, "--print-architecture").saveOutput( |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
97 |
true).executeExpectSuccess().getOutput().get(0); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
98 |
} catch (IOException ex) { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
99 |
debArch = null; |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
100 |
} |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
101 |
DEB_ARCH = debArch; |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
102 |
} |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
103 |
|
57910
28412b313c6b
8228660: .deb files generated by jpackage don't follow naming convention
herrick
parents:
57908
diff
changeset
|
104 |
private static final BundlerParamInfo<String> FULL_PACKAGE_NAME = |
28412b313c6b
8228660: .deb files generated by jpackage don't follow naming convention
herrick
parents:
57908
diff
changeset
|
105 |
new StandardBundlerParam<>( |
28412b313c6b
8228660: .deb files generated by jpackage don't follow naming convention
herrick
parents:
57908
diff
changeset
|
106 |
"linux.deb.fullPackageName", String.class, params -> { |
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
107 |
return PACKAGE_NAME.fetchFrom(params) |
57910
28412b313c6b
8228660: .deb files generated by jpackage don't follow naming convention
herrick
parents:
57908
diff
changeset
|
108 |
+ "_" + VERSION.fetchFrom(params) |
28412b313c6b
8228660: .deb files generated by jpackage don't follow naming convention
herrick
parents:
57908
diff
changeset
|
109 |
+ "-" + RELEASE.fetchFrom(params) |
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
110 |
+ "_" + DEB_ARCH; |
57910
28412b313c6b
8228660: .deb files generated by jpackage don't follow naming convention
herrick
parents:
57908
diff
changeset
|
111 |
}, (s, p) -> s); |
57038 | 112 |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
113 |
private static final BundlerParamInfo<String> EMAIL = |
57038 | 114 |
new StandardBundlerParam<> ( |
57255
f686bda3b831
8215574: Investigate and document usage of --category, --copyright, --vendor and --description
herrick
parents:
57150
diff
changeset
|
115 |
Arguments.CLIOptions.LINUX_DEB_MAINTAINER.getId(), |
57038 | 116 |
String.class, |
117 |
params -> "Unknown", |
|
118 |
(s, p) -> s); |
|
119 |
||
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
120 |
private static final BundlerParamInfo<String> MAINTAINER = |
57038 | 121 |
new StandardBundlerParam<> ( |
57255
f686bda3b831
8215574: Investigate and document usage of --category, --copyright, --vendor and --description
herrick
parents:
57150
diff
changeset
|
122 |
BundleParams.PARAM_MAINTAINER, |
57038 | 123 |
String.class, |
124 |
params -> VENDOR.fetchFrom(params) + " <" |
|
125 |
+ EMAIL.fetchFrom(params) + ">", |
|
126 |
(s, p) -> s); |
|
127 |
||
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
128 |
private static final BundlerParamInfo<String> SECTION = |
57790 | 129 |
new StandardBundlerParam<>( |
130 |
Arguments.CLIOptions.LINUX_CATEGORY.getId(), |
|
131 |
String.class, |
|
132 |
params -> "misc", |
|
133 |
(s, p) -> s); |
|
57807
4a15115716ea
8215381: Investigate if current implementation of --license-file is correct for Debian packages
herrick
parents:
57790
diff
changeset
|
134 |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
135 |
private static final BundlerParamInfo<String> LICENSE_TEXT = |
57038 | 136 |
new StandardBundlerParam<> ( |
137 |
"linux.deb.licenseText", |
|
138 |
String.class, |
|
139 |
params -> { |
|
140 |
try { |
|
57080 | 141 |
String licenseFile = LICENSE_FILE.fetchFrom(params); |
142 |
if (licenseFile != null) { |
|
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
143 |
return Files.lines(Path.of(licenseFile), |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
144 |
StandardCharsets.UTF_8).collect( |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
145 |
Collectors.joining("\n")); |
57038 | 146 |
} |
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
147 |
} catch (IOException e) { |
57140 | 148 |
Log.verbose(e); |
57038 | 149 |
} |
150 |
return "Unknown"; |
|
151 |
}, |
|
152 |
(s, p) -> s); |
|
153 |
||
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
154 |
public LinuxDebBundler() { |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
155 |
super(PACKAGE_NAME); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
156 |
} |
57038 | 157 |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
158 |
@Override |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
159 |
public void doValidate(Map<String, ? super Object> params) |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
160 |
throws ConfigException { |
57038 | 161 |
|
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
162 |
// Show warning if license file is missing |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
163 |
if (LICENSE_FILE.fetchFrom(params) == null) { |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
164 |
Log.verbose(I18N.getString("message.debs-like-licenses")); |
57038 | 165 |
} |
166 |
} |
|
167 |
||
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
168 |
@Override |
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
169 |
protected List<ToolValidator> getToolValidators( |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
170 |
Map<String, ? super Object> params) { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
171 |
return Stream.of(TOOL_DPKG_DEB, TOOL_DPKG, TOOL_FAKEROOT).map( |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
172 |
ToolValidator::new).collect(Collectors.toList()); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
173 |
} |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
174 |
|
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
175 |
@Override |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
176 |
protected File buildPackageBundle( |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
177 |
Map<String, String> replacementData, |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
178 |
Map<String, ? super Object> params, File outputParentDir) throws |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
179 |
PackagerException, IOException { |
57038 | 180 |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
181 |
prepareProjectConfig(replacementData, params); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
182 |
adjustPermissionsRecursive(createMetaPackage(params).sourceRoot().toFile()); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
183 |
return buildDeb(params, outputParentDir); |
57038 | 184 |
} |
185 |
||
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
186 |
private static final Pattern PACKAGE_NAME_REGEX = Pattern.compile("^(^\\S+):"); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
187 |
|
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
188 |
@Override |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
189 |
protected void initLibProvidersLookup( |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
190 |
Map<String, ? super Object> params, |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
191 |
LibProvidersLookup libProvidersLookup) { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
192 |
|
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
193 |
// |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
194 |
// `dpkg -S` command does glob pattern lookup. If not the absolute path |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
195 |
// to the file is specified it might return mltiple package names. |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
196 |
// Even for full paths multiple package names can be returned as |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
197 |
// it is OK for multiple packages to provide the same file. `/opt` |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
198 |
// directory is such an example. So we have to deal with multiple |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
199 |
// packages per file situation. |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
200 |
// |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
201 |
// E.g.: `dpkg -S libc.so.6` command reports three packages: |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
202 |
// libc6-x32: /libx32/libc.so.6 |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
203 |
// libc6:amd64: /lib/x86_64-linux-gnu/libc.so.6 |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
204 |
// libc6-i386: /lib32/libc.so.6 |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
205 |
// `:amd64` is architecture suffix and can (should) be dropped. |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
206 |
// Still need to decide what package to choose from three. |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
207 |
// libc6-x32 and libc6-i386 both depend on libc6: |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
208 |
// $ dpkg -s libc6-x32 |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
209 |
// Package: libc6-x32 |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
210 |
// Status: install ok installed |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
211 |
// Priority: optional |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
212 |
// Section: libs |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
213 |
// Installed-Size: 10840 |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
214 |
// Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
215 |
// Architecture: amd64 |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
216 |
// Source: glibc |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
217 |
// Version: 2.23-0ubuntu10 |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
218 |
// Depends: libc6 (= 2.23-0ubuntu10) |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
219 |
// |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
220 |
// We can dive into tracking dependencies, but this would be overly |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
221 |
// complicated. |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
222 |
// |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
223 |
// For simplicity lets consider the following rules: |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
224 |
// 1. If there is one item in `dpkg -S` output, accept it. |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
225 |
// 2. If there are multiple items in `dpkg -S` output and there is at |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
226 |
// least one item with the default arch suffix (DEB_ARCH), |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
227 |
// accept only these items. |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
228 |
// 3. If there are multiple items in `dpkg -S` output and there are |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
229 |
// no with the default arch suffix (DEB_ARCH), accept all items. |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
230 |
// So lets use this heuristics: don't accept packages for whom |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
231 |
// `dpkg -p` command fails. |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
232 |
// 4. Arch suffix should be stripped from accepted package names. |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
233 |
// |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
234 |
|
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
235 |
libProvidersLookup.setPackageLookup(file -> { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
236 |
Set<String> archPackages = new HashSet<>(); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
237 |
Set<String> otherPackages = new HashSet<>(); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
238 |
|
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
239 |
Executor.of(TOOL_DPKG, "-S", file.toString()) |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
240 |
.saveOutput(true).executeExpectSuccess() |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
241 |
.getOutput().forEach(line -> { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
242 |
Matcher matcher = PACKAGE_NAME_REGEX.matcher(line); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
243 |
if (matcher.find()) { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
244 |
String name = matcher.group(1); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
245 |
if (name.endsWith(":" + DEB_ARCH)) { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
246 |
// Strip arch suffix |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
247 |
name = name.substring(0, |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
248 |
name.length() - (DEB_ARCH.length() + 1)); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
249 |
archPackages.add(name); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
250 |
} else { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
251 |
otherPackages.add(name); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
252 |
} |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
253 |
} |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
254 |
}); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
255 |
|
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
256 |
if (!archPackages.isEmpty()) { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
257 |
return archPackages.stream(); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
258 |
} |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
259 |
return otherPackages.stream(); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
260 |
}); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
261 |
} |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
262 |
|
57038 | 263 |
/* |
264 |
* set permissions with a string like "rwxr-xr-x" |
|
265 |
* |
|
266 |
* This cannot be directly backport to 22u which is built with 1.6 |
|
267 |
*/ |
|
268 |
private void setPermissions(File file, String permissions) { |
|
269 |
Set<PosixFilePermission> filePermissions = |
|
270 |
PosixFilePermissions.fromString(permissions); |
|
271 |
try { |
|
272 |
if (file.exists()) { |
|
273 |
Files.setPosixFilePermissions(file.toPath(), filePermissions); |
|
274 |
} |
|
275 |
} catch (IOException ex) { |
|
57392 | 276 |
Log.error(ex.getMessage()); |
277 |
Log.verbose(ex); |
|
57038 | 278 |
} |
279 |
||
280 |
} |
|
281 |
||
58114
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
282 |
public static boolean isDebian() { |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
283 |
// we are just going to run "dpkg -s coreutils" and assume Debian |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
284 |
// or deritive if no error is returned. |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
285 |
try { |
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
286 |
Executor.of(TOOL_DPKG, "-s", "coreutils").executeExpectSuccess(); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
287 |
return true; |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
288 |
} catch (IOException e) { |
58114
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
289 |
// just fall thru |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
290 |
} |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
291 |
return false; |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
292 |
} |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
293 |
|
57808 | 294 |
private void adjustPermissionsRecursive(File dir) throws IOException { |
295 |
Files.walkFileTree(dir.toPath(), new SimpleFileVisitor<Path>() { |
|
296 |
@Override |
|
297 |
public FileVisitResult visitFile(Path file, |
|
298 |
BasicFileAttributes attrs) |
|
299 |
throws IOException { |
|
300 |
if (file.endsWith(".so") || !Files.isExecutable(file)) { |
|
301 |
setPermissions(file.toFile(), "rw-r--r--"); |
|
302 |
} else if (Files.isExecutable(file)) { |
|
303 |
setPermissions(file.toFile(), "rwxr-xr-x"); |
|
304 |
} |
|
305 |
return FileVisitResult.CONTINUE; |
|
306 |
} |
|
307 |
||
308 |
@Override |
|
309 |
public FileVisitResult postVisitDirectory(Path dir, IOException e) |
|
310 |
throws IOException { |
|
311 |
if (e == null) { |
|
312 |
setPermissions(dir.toFile(), "rwxr-xr-x"); |
|
313 |
return FileVisitResult.CONTINUE; |
|
314 |
} else { |
|
315 |
// directory iteration failed |
|
316 |
throw e; |
|
317 |
} |
|
318 |
} |
|
319 |
}); |
|
320 |
} |
|
321 |
||
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
322 |
private class DebianFile { |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
323 |
|
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
324 |
DebianFile(Path dstFilePath, String comment) { |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
325 |
this.dstFilePath = dstFilePath; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
326 |
this.comment = comment; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
327 |
} |
57038 | 328 |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
329 |
DebianFile setExecutable() { |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
330 |
permissions = "rwxr-xr-x"; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
331 |
return this; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
332 |
} |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
333 |
|
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
334 |
void create(Map<String, String> data, Map<String, ? super Object> params) |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
335 |
throws IOException { |
58647
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58417
diff
changeset
|
336 |
createResource("template." + dstFilePath.getFileName().toString(), |
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58417
diff
changeset
|
337 |
params) |
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58417
diff
changeset
|
338 |
.setCategory(I18N.getString(comment)) |
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58417
diff
changeset
|
339 |
.setSubstitutionData(data) |
2c43b89b1679
8231862: Decouple DesktopIntegration and LinuxPackageBundler classes
herrick
parents:
58417
diff
changeset
|
340 |
.saveToFile(dstFilePath); |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
341 |
if (permissions != null) { |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
342 |
setPermissions(dstFilePath.toFile(), permissions); |
57038 | 343 |
} |
344 |
} |
|
345 |
||
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
346 |
private final Path dstFilePath; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
347 |
private final String comment; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
348 |
private String permissions; |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
349 |
} |
57038 | 350 |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
351 |
private void prepareProjectConfig(Map<String, String> data, |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
352 |
Map<String, ? super Object> params) throws IOException { |
57038 | 353 |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
354 |
Path configDir = createMetaPackage(params).sourceRoot().resolve("DEBIAN"); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
355 |
List<DebianFile> debianFiles = new ArrayList<>(); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
356 |
debianFiles.add(new DebianFile( |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
357 |
configDir.resolve("control"), |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
358 |
"resource.deb-control-file")); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
359 |
debianFiles.add(new DebianFile( |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
360 |
configDir.resolve("preinst"), |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
361 |
"resource.deb-preinstall-script").setExecutable()); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
362 |
debianFiles.add(new DebianFile( |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
363 |
configDir.resolve("prerm"), |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
364 |
"resource.deb-prerm-script").setExecutable()); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
365 |
debianFiles.add(new DebianFile( |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
366 |
configDir.resolve("postinst"), |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
367 |
"resource.deb-postinstall-script").setExecutable()); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
368 |
debianFiles.add(new DebianFile( |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
369 |
configDir.resolve("postrm"), |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
370 |
"resource.deb-postrm-script").setExecutable()); |
58304 | 371 |
debianFiles.add(new DebianFile( |
372 |
getConfig_CopyrightFile(params).toPath(), |
|
373 |
"resource.copyright-file")); |
|
57038 | 374 |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
375 |
for (DebianFile debianFile : debianFiles) { |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
376 |
debianFile.create(data, params); |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
377 |
} |
57038 | 378 |
} |
379 |
||
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
380 |
@Override |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
381 |
protected Map<String, String> createReplacementData( |
57543
bcd1ab268a7d
8222778: Packaging Tool (JEP 343) on Linux/AArch64
dchuyko
parents:
57438
diff
changeset
|
382 |
Map<String, ? super Object> params) throws IOException { |
57038 | 383 |
Map<String, String> data = new HashMap<>(); |
384 |
||
385 |
data.put("APPLICATION_MAINTAINER", MAINTAINER.fetchFrom(params)); |
|
57790 | 386 |
data.put("APPLICATION_SECTION", SECTION.fetchFrom(params)); |
57038 | 387 |
data.put("APPLICATION_COPYRIGHT", COPYRIGHT.fetchFrom(params)); |
388 |
data.put("APPLICATION_LICENSE_TEXT", LICENSE_TEXT.fetchFrom(params)); |
|
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
389 |
data.put("APPLICATION_ARCH", DEB_ARCH); |
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
390 |
data.put("APPLICATION_INSTALLED_SIZE", Long.toString( |
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
391 |
createMetaPackage(params).sourceApplicationLayout().sizeInBytes() >> 10)); |
57038 | 392 |
|
393 |
return data; |
|
394 |
} |
|
395 |
||
396 |
private File getConfig_CopyrightFile(Map<String, ? super Object> params) { |
|
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
397 |
PlatformPackage thePackage = createMetaPackage(params); |
58303
88453b906981
8231279 : Change install location for copyright file for Debian package
herrick
parents:
58301
diff
changeset
|
398 |
return thePackage.sourceRoot().resolve(Path.of(".", |
88453b906981
8231279 : Change install location for copyright file for Debian package
herrick
parents:
58301
diff
changeset
|
399 |
LINUX_INSTALL_DIR.fetchFrom(params), PACKAGE_NAME.fetchFrom( |
88453b906981
8231279 : Change install location for copyright file for Debian package
herrick
parents:
58301
diff
changeset
|
400 |
params), "share/doc/copyright")).toFile(); |
57808 | 401 |
} |
402 |
||
57038 | 403 |
private File buildDeb(Map<String, ? super Object> params, |
404 |
File outdir) throws IOException { |
|
405 |
File outFile = new File(outdir, |
|
406 |
FULL_PACKAGE_NAME.fetchFrom(params)+".deb"); |
|
407 |
Log.verbose(MessageFormat.format(I18N.getString( |
|
408 |
"message.outputting-to-location"), outFile.getAbsolutePath())); |
|
409 |
||
58301
e0efb29609bd
8225249 : LinuxDebBundler and LinuxRpmBundler should share more code
herrick
parents:
58116
diff
changeset
|
410 |
PlatformPackage thePackage = createMetaPackage(params); |
57038 | 411 |
|
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
412 |
List<String> cmdline = new ArrayList<>(); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
413 |
cmdline.addAll(List.of(TOOL_FAKEROOT, TOOL_DPKG_DEB)); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
414 |
if (Log.isVerbose()) { |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
415 |
cmdline.add("--verbose"); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
416 |
} |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
417 |
cmdline.addAll(List.of("-b", thePackage.sourceRoot().toString(), |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
418 |
outFile.getAbsolutePath())); |
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
419 |
|
57038 | 420 |
// run dpkg |
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
421 |
Executor.of(cmdline.toArray(String[]::new)).executeExpectSuccess(); |
57038 | 422 |
|
423 |
Log.verbose(MessageFormat.format(I18N.getString( |
|
424 |
"message.output-to-location"), outFile.getAbsolutePath())); |
|
425 |
||
426 |
return outFile; |
|
427 |
} |
|
428 |
||
429 |
@Override |
|
430 |
public String getName() { |
|
57059 | 431 |
return I18N.getString("deb.bundler.name"); |
57038 | 432 |
} |
433 |
||
434 |
@Override |
|
435 |
public String getID() { |
|
436 |
return "deb"; |
|
437 |
} |
|
438 |
||
439 |
@Override |
|
57150 | 440 |
public boolean supported(boolean runtimeInstaller) { |
58417
67ffaf3a2b75
8231280: Linux packages produced by jpackage should have correct dependencies
herrick
parents:
58304
diff
changeset
|
441 |
return Platform.isLinux() && (new ToolValidator(TOOL_DPKG_DEB).validate() == null); |
57038 | 442 |
} |
443 |
||
58114
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
444 |
@Override |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
445 |
public boolean isDefault() { |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
446 |
return isDebian(); |
42df7de58e39
8230519: jpackage "--package-type" values and default
herrick
parents:
57910
diff
changeset
|
447 |
} |
57038 | 448 |
} |