changeset 4006:dce4c708d955

RT-27989 Linux DEB installer does not specify Installed-Size [mhowe] Contributed-by: Danno Ferrin <danno.ferrin@shemnon.com>
author mhowe
date Sun, 09 Jun 2013 22:28:27 -0700
parents 5b698983ad81
children 7fa0244ee54e
files deploy/packager/src/com/sun/javafx/tools/packager/bundlers/LinuxDebBundler.java deploy/packager/src/com/sun/javafx/tools/resource/linux/template.control
diffstat 2 files changed, 32 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/deploy/packager/src/com/sun/javafx/tools/packager/bundlers/LinuxDebBundler.java	Sun Jun 09 20:26:19 2013 -0700
+++ b/deploy/packager/src/com/sun/javafx/tools/packager/bundlers/LinuxDebBundler.java	Sun Jun 09 22:28:27 2013 -0700
@@ -36,6 +36,10 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Writer;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -277,6 +281,30 @@
             }
         }
     }
+    
+    private long getInstalledSizeKB() {
+        return getInstalledSizeKB(Paths.get(appImageRoot.toURI())) >> 10;
+    }
+
+    private long getInstalledSizeKB(Path dir) {
+        long count = 0;
+        try {
+            DirectoryStream<Path> stream = Files.newDirectoryStream(dir);
+            try {
+                for (Path p : stream) {
+                    if (Files.isRegularFile(p)) {
+                        count += Files.size(p);
+                    } else if (Files.isDirectory(p)) {
+                        count += getInstalledSizeKB(p);
+                    }
+                }
+            } finally {
+                stream.close();
+            }
+        } catch (IOException ignore) {
+        }
+        return count;
+    }    
 
     private boolean prepareProjectConfig() throws IOException {
         Map<String, String> data = new HashMap<String, String>();
@@ -301,7 +329,8 @@
                 params.licenseType != null ? params.licenseType : "unknown");
         data.put("APPLICATION_LICENSE_TEXT", getLicenseText());
         data.put("APPLICATION_ARCH", getArch());
-
+        data.put("APPLICATION_INSTALLED_SIZE", Long.toString(getInstalledSizeKB()));
+ 
         //prepare control file
         Writer w = new BufferedWriter(new FileWriter(getConfig_ControlFile()));
         String content = preprocessTextResource(
@@ -332,7 +361,7 @@
                 "DEB copyright file", DEFAULT_COPYRIGHT_TEMPLATE, data);
         w.write(content);
         w.close();
-
+        
         //prepare desktop shortcut
         w = new BufferedWriter(new FileWriter(getConfig_DesktopShortcutFile()));
         content = preprocessTextResource(
--- a/deploy/packager/src/com/sun/javafx/tools/resource/linux/template.control	Sun Jun 09 20:26:19 2013 -0700
+++ b/deploy/packager/src/com/sun/javafx/tools/resource/linux/template.control	Sun Jun 09 22:28:27 2013 -0700
@@ -6,4 +6,4 @@
 Architecture: APPLICATION_ARCH
 Provides: APPLICATION_NAME  
 Description: APPLICATION_SUMMARY
-
+Installed-Size: APPLICATION_INSTALLED_SIZE