22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.jpackage.internal;
27
28 import java.io.*;
29 import java.nio.charset.StandardCharsets;
30 import java.nio.file.FileVisitResult;
31 import java.nio.file.Files;
32 import java.nio.file.Path;
33 import java.nio.file.SimpleFileVisitor;
34 import java.nio.file.attribute.BasicFileAttributes;
35
36 import java.nio.file.attribute.PosixFilePermission;
37 import java.nio.file.attribute.PosixFilePermissions;
38 import java.text.MessageFormat;
39 import java.util.*;
40 import java.util.regex.Pattern;
41 import java.util.stream.Stream;
42
43 import static jdk.jpackage.internal.StandardBundlerParam.*;
44 import static jdk.jpackage.internal.LinuxPackageBundler.I18N;
45
46 public class LinuxDebBundler extends LinuxPackageBundler {
47
48 // Debian rules for package naming are used here
49 // https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
50 //
51 // Package names must consist only of lower case letters (a-z),
52 // digits (0-9), plus (+) and minus (-) signs, and periods (.).
53 // They must be at least two characters long and
54 // must start with an alphanumeric character.
55 //
56 private static final Pattern DEB_PACKAGE_NAME_PATTERN =
57 Pattern.compile("^[a-z][a-z\\d\\+\\-\\.]+");
58
59 private static final BundlerParamInfo<String> PACKAGE_NAME =
60 new StandardBundlerParam<> (
61 Arguments.CLIOptions.LINUX_BUNDLE_NAME.getId(),
346 }
347
348 @Override
349 protected Map<String, String> createReplacementData(
350 Map<String, ? super Object> params) throws IOException {
351 Map<String, String> data = new HashMap<>();
352
353 data.put("APPLICATION_MAINTAINER", MAINTAINER.fetchFrom(params));
354 data.put("APPLICATION_SECTION", SECTION.fetchFrom(params));
355 data.put("APPLICATION_COPYRIGHT", COPYRIGHT.fetchFrom(params));
356 data.put("APPLICATION_LICENSE_TEXT", LICENSE_TEXT.fetchFrom(params));
357 data.put("APPLICATION_ARCH", getDebArch());
358 data.put("APPLICATION_INSTALLED_SIZE", Long.toString(
359 createMetaPackage(params).sourceApplicationLayout().sizeInBytes() >> 10));
360
361 return data;
362 }
363
364 private File getConfig_CopyrightFile(Map<String, ? super Object> params) {
365 PlatformPackage thePackage = createMetaPackage(params);
366 return thePackage.sourceRoot().resolve(Path.of("usr/share/doc",
367 thePackage.name(), "copyright")).toFile();
368 }
369
370 private File buildDeb(Map<String, ? super Object> params,
371 File outdir) throws IOException {
372 File outFile = new File(outdir,
373 FULL_PACKAGE_NAME.fetchFrom(params)+".deb");
374 Log.verbose(MessageFormat.format(I18N.getString(
375 "message.outputting-to-location"), outFile.getAbsolutePath()));
376
377 PlatformPackage thePackage = createMetaPackage(params);
378
379 // run dpkg
380 ProcessBuilder pb = new ProcessBuilder(
381 "fakeroot", TOOL_DPKG_DEB, "-b",
382 thePackage.sourceRoot().toString(),
383 outFile.getAbsolutePath());
384 IOUtils.exec(pb);
385
386 Log.verbose(MessageFormat.format(I18N.getString(
387 "message.output-to-location"), outFile.getAbsolutePath()));
|
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package jdk.jpackage.internal;
27
28 import java.io.*;
29 import java.nio.charset.StandardCharsets;
30 import java.nio.file.FileVisitResult;
31 import java.nio.file.Files;
32 import java.nio.file.Path;
33 import java.nio.file.SimpleFileVisitor;
34 import java.nio.file.attribute.BasicFileAttributes;
35
36 import java.nio.file.attribute.PosixFilePermission;
37 import java.nio.file.attribute.PosixFilePermissions;
38 import java.text.MessageFormat;
39 import java.util.*;
40 import java.util.regex.Pattern;
41 import java.util.stream.Stream;
42 import static jdk.jpackage.internal.LinuxAppBundler.LINUX_INSTALL_DIR;
43
44 import static jdk.jpackage.internal.StandardBundlerParam.*;
45 import static jdk.jpackage.internal.LinuxPackageBundler.I18N;
46
47 public class LinuxDebBundler extends LinuxPackageBundler {
48
49 // Debian rules for package naming are used here
50 // https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
51 //
52 // Package names must consist only of lower case letters (a-z),
53 // digits (0-9), plus (+) and minus (-) signs, and periods (.).
54 // They must be at least two characters long and
55 // must start with an alphanumeric character.
56 //
57 private static final Pattern DEB_PACKAGE_NAME_PATTERN =
58 Pattern.compile("^[a-z][a-z\\d\\+\\-\\.]+");
59
60 private static final BundlerParamInfo<String> PACKAGE_NAME =
61 new StandardBundlerParam<> (
62 Arguments.CLIOptions.LINUX_BUNDLE_NAME.getId(),
347 }
348
349 @Override
350 protected Map<String, String> createReplacementData(
351 Map<String, ? super Object> params) throws IOException {
352 Map<String, String> data = new HashMap<>();
353
354 data.put("APPLICATION_MAINTAINER", MAINTAINER.fetchFrom(params));
355 data.put("APPLICATION_SECTION", SECTION.fetchFrom(params));
356 data.put("APPLICATION_COPYRIGHT", COPYRIGHT.fetchFrom(params));
357 data.put("APPLICATION_LICENSE_TEXT", LICENSE_TEXT.fetchFrom(params));
358 data.put("APPLICATION_ARCH", getDebArch());
359 data.put("APPLICATION_INSTALLED_SIZE", Long.toString(
360 createMetaPackage(params).sourceApplicationLayout().sizeInBytes() >> 10));
361
362 return data;
363 }
364
365 private File getConfig_CopyrightFile(Map<String, ? super Object> params) {
366 PlatformPackage thePackage = createMetaPackage(params);
367 return thePackage.sourceRoot().resolve(Path.of(".",
368 LINUX_INSTALL_DIR.fetchFrom(params), PACKAGE_NAME.fetchFrom(
369 params), "share/doc/copyright")).toFile();
370 }
371
372 private File buildDeb(Map<String, ? super Object> params,
373 File outdir) throws IOException {
374 File outFile = new File(outdir,
375 FULL_PACKAGE_NAME.fetchFrom(params)+".deb");
376 Log.verbose(MessageFormat.format(I18N.getString(
377 "message.outputting-to-location"), outFile.getAbsolutePath()));
378
379 PlatformPackage thePackage = createMetaPackage(params);
380
381 // run dpkg
382 ProcessBuilder pb = new ProcessBuilder(
383 "fakeroot", TOOL_DPKG_DEB, "-b",
384 thePackage.sourceRoot().toString(),
385 outFile.getAbsolutePath());
386 IOUtils.exec(pb);
387
388 Log.verbose(MessageFormat.format(I18N.getString(
389 "message.output-to-location"), outFile.getAbsolutePath()));
|