< prev index next >

src/jdk.jpackage/linux/classes/jdk/jpackage/internal/LinuxDebBundler.java

Print this page




 390         try {
 391             if (file.exists()) {
 392                 Files.setPosixFilePermissions(file.toPath(), filePermissions);
 393             }
 394         } catch (IOException ex) {
 395             Log.error(ex.getMessage());
 396             Log.verbose(ex);
 397         }
 398 
 399     }
 400 
 401     private static String getDebArch() throws IOException {
 402         try (var baos = new ByteArrayOutputStream();
 403                 var ps = new PrintStream(baos)) {
 404             var pb = new ProcessBuilder(TOOL_DPKG, "--print-architecture");
 405             IOUtils.exec(pb, false, ps);
 406             return baos.toString().split("\n", 2)[0];
 407         }
 408     }
 409 













 410     private long getInstalledSizeKB(Map<String, ? super Object> params) {
 411         return getInstalledSizeKB(APP_IMAGE_ROOT.fetchFrom(params)) >> 10;
 412     }
 413 
 414     private long getInstalledSizeKB(File dir) {
 415         long count = 0;
 416         File[] children = dir.listFiles();
 417         if (children != null) {
 418             for (File file : children) {
 419                 if (file.isFile()) {
 420                     count += file.length();
 421                 }
 422                 else if (file.isDirectory()) {
 423                     count += getInstalledSizeKB(file);
 424                 }
 425             }
 426         }
 427         return count;
 428     }
 429 


 922             if (testTool(TOOL_DPKG_DEB, "1")) {
 923                 return true;
 924             }
 925         }
 926         return false;
 927     }
 928 
 929     public int getSquareSizeOfImage(File f) {
 930         try {
 931             BufferedImage bi = ImageIO.read(f);
 932             if (bi.getWidth() == bi.getHeight()) {
 933                 return bi.getWidth();
 934             } else {
 935                 return 0;
 936             }
 937         } catch (Exception e) {
 938             Log.verbose(e);
 939             return 0;
 940         }
 941     }






 942 }


 390         try {
 391             if (file.exists()) {
 392                 Files.setPosixFilePermissions(file.toPath(), filePermissions);
 393             }
 394         } catch (IOException ex) {
 395             Log.error(ex.getMessage());
 396             Log.verbose(ex);
 397         }
 398 
 399     }
 400 
 401     private static String getDebArch() throws IOException {
 402         try (var baos = new ByteArrayOutputStream();
 403                 var ps = new PrintStream(baos)) {
 404             var pb = new ProcessBuilder(TOOL_DPKG, "--print-architecture");
 405             IOUtils.exec(pb, false, ps);
 406             return baos.toString().split("\n", 2)[0];
 407         }
 408     }
 409 
 410     public static boolean isDebian() {
 411         // we are just going to run "dpkg -s coreutils" ans assume Debian
 412         // or deritive if no error is returned.
 413         var pb = new ProcessBuilder(TOOL_DPKG, "-s", "coreutils");
 414         try {
 415             int ret = pb.start().waitFor();
 416             return (ret == 0);
 417         } catch (IOException | InterruptedException e) {
 418             // just fall thru
 419         }
 420         return false;
 421     }
 422 
 423     private long getInstalledSizeKB(Map<String, ? super Object> params) {
 424         return getInstalledSizeKB(APP_IMAGE_ROOT.fetchFrom(params)) >> 10;
 425     }
 426 
 427     private long getInstalledSizeKB(File dir) {
 428         long count = 0;
 429         File[] children = dir.listFiles();
 430         if (children != null) {
 431             for (File file : children) {
 432                 if (file.isFile()) {
 433                     count += file.length();
 434                 }
 435                 else if (file.isDirectory()) {
 436                     count += getInstalledSizeKB(file);
 437                 }
 438             }
 439         }
 440         return count;
 441     }
 442 


 935             if (testTool(TOOL_DPKG_DEB, "1")) {
 936                 return true;
 937             }
 938         }
 939         return false;
 940     }
 941 
 942     public int getSquareSizeOfImage(File f) {
 943         try {
 944             BufferedImage bi = ImageIO.read(f);
 945             if (bi.getWidth() == bi.getHeight()) {
 946                 return bi.getWidth();
 947             } else {
 948                 return 0;
 949             }
 950         } catch (Exception e) {
 951             Log.verbose(e);
 952             return 0;
 953         }
 954     }
 955 
 956     @Override
 957     public boolean isDefault() {
 958         return isDebian();
 959     }
 960 
 961 }
< prev index next >