src/share/classes/org/openjdk/jigsaw/cli/Packager.java

Print this page

        

@@ -123,10 +123,13 @@
 
     private File natlibs;
     private File natcmds;
     private File config_dir;
 
+    // default architecture is any
+    private ModuleArchitecture modArch = ModuleArchitecture.ANY;
+
     // Installed size
     private Integer installedSize = null;
 
     // Platform boot module
     private static final String BOOT_MODULE = "jdk.base";

@@ -168,11 +171,11 @@
                                            + outputfilename + " for "
                                            + modulename);
                     outputfile = new File(destination, outputfilename);
                     ModuleFileWriter writer
                         = new ModuleFileWriter(outputfile, (fast || jigsawDevMode));
-                    writer.writeModule(classes, natlibs, natcmds, config_dir);
+                    writer.writeModule(classes, natlibs, natcmds, config_dir, modArch);
                 }
                 catch (IOException x) {
                     if (outputfile != null && !outputfile.delete()) {
                         Throwable t
                             = new IOException(outputfile +

@@ -326,11 +329,11 @@
                 control.format("Package: %s%n"
                                + "Version: %s%n"
                                + "Section: misc%n"
                                + "Priority: optional%n"
                                + "Architecture: "
-                               + System.getProperty("os.arch") + "%n",
+                               + System.getProperty("os.arch") + "%n", // ## update to use archOpt
                                info.id().name(),
                                translateVersion(info.id().version().toString()));
 
                 // If either maintainer name or e-mail is declared as parameter, use it
                 if (null != maintainer_name || null != maintainer_email) {

@@ -589,11 +592,11 @@
                 cleanup();
             }
         }
     }
 
-    private static Map<String,Class<? extends Command<SimpleLibrary>>> commands
+    private static final Map<String,Class<? extends Command<SimpleLibrary>>> commands
         = new HashMap<>();
 
     static {
         commands.put("deb", Deb.class);
         commands.put("jmod", Jmod.class);

@@ -734,10 +737,20 @@
         OptionSpec<File> config
             = (parser.accepts("config", "Directory with configuration")
                .withRequiredArg()
                .describedAs("dir")
                .ofType(File.class));
+        OptionSpec<String> osOpt
+            = (parser.accepts("os", "Target Operating System of the module")
+               .withRequiredArg()
+               .describedAs("os")
+               .ofType(String.class));
+        OptionSpec<String> archOpt
+            = (parser.accepts("arch", "Target Architecture of the module")
+               .withRequiredArg()
+               .describedAs("arch")
+               .ofType(String.class));
 
         if (args.length == 0) {
             usage();
             return;
         }

@@ -805,10 +818,12 @@
         }
         if (opts.has(config)) {
             config_dir = opts.valueOf(config);
             checkPathArgument(config_dir, "Config");
         }
+        modArch = ModuleArchitecture.create(opts.valueOf(osOpt),
+                                            opts.valueOf(archOpt));
         if (opts.has(isize))
             installedSize = opts.valueOf(isize);
 
         if (cmd == Deb.class)
             (new Deb()).run(null, opts);

@@ -822,13 +837,13 @@
      * @param path to check
      * @param type of path being checked
      *
      * @throws Command.Exception if path doesn't exist
      */
-    private static final void checkIfPathExists(File path, String type)
-        throws Command.Exception {
-
+    private static void checkIfPathExists(File path, String type)
+        throws Command.Exception
+    {
         if (!path.exists())
             throw new Command.Exception("%s path doesn't exist: %s",
                                         type, path);
     }
 

@@ -838,13 +853,13 @@
      * @param path to check
      * @param type of path being checked
      *
      * @throws Command.Exception if path isn't readable
      */
-    private static final void checkIfPathIsReadable(File path, String type)
-        throws Command.Exception {
-
+    private static void checkIfPathIsReadable(File path, String type)
+        throws Command.Exception
+    {
         if (!path.canRead())
             throw new Command.Exception("%s path isn't readable: %s",
                                         type, path);
     }
 

@@ -854,13 +869,13 @@
      * @param path to check
      * @param type of path being checked
      *
      * @throws Command.Exception if path is not a directory
      */
-    private static final void checkIfPathIsDirectory(File path, String type)
-        throws Command.Exception {
-
+    private static void checkIfPathIsDirectory(File path, String type)
+        throws Command.Exception
+    {
         if (!path.isDirectory())
             throw new Command.Exception("%s path is not a directory: %s",
                                         type, path);
     }
 

@@ -870,13 +885,13 @@
      * @param path to check
      * @param type of path being checked
      *
      * @throws Command.Exception if path is not a directory
      */
-    private static final void checkPathArgument(File path, String type)
-        throws Command.Exception {
-
+    private static void checkPathArgument(File path, String type)
+        throws Command.Exception
+    {
         checkIfPathExists(path, type);
         checkIfPathIsReadable(path, type);
         checkIfPathIsDirectory(path, type);
     }