[lorax] Use xz when compressing the initrd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This makes the image a lot smaller.
---
 lorax.spec                 |    1 +
 src/pylorax/installtree.py |   13 +++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lorax.spec b/lorax.spec
index 7704f17..7da6643 100644
--- a/lorax.spec
+++ b/lorax.spec
@@ -26,6 +26,7 @@ Requires:       util-linux-ng
 Requires:       dosfstools
 Requires:       genisoimage
 Requires:       parted
+Requires:       pyliblzma
 
 %description
 Lorax is a tool for creating the anaconda install images.
diff --git a/src/pylorax/installtree.py b/src/pylorax/installtree.py
index 9883bba..d0a045d 100644
--- a/src/pylorax/installtree.py
+++ b/src/pylorax/installtree.py
@@ -26,6 +26,7 @@ import sys
 import os
 import shutil
 import gzip
+import lzma
 import re
 import glob
 import time
@@ -506,7 +507,7 @@ class LoraxInstallTree(BaseLoraxClass):
         dst = joinpaths(self.root, "sbin")
         shutil.copy2(src, dst)
 
-    def compress(self, initrd, kernel):
+    def compress(self, initrd, kernel, type="xz"):
         chdir = lambda: os.chdir(self.root)
         start = time.time()
 
@@ -521,9 +522,13 @@ class LoraxInstallTree(BaseLoraxClass):
                                 stdin=find.stdout, stdout=subprocess.PIPE,
                                 preexec_fn=chdir)
 
-        gzipped = gzip.open(initrd.fpath, "wb")
-        gzipped.write(cpio.stdout.read())
-        gzipped.close()
+        if type == "gzip":
+            compressed = gzip.open(initrd.fpath, "wb")
+        elif type == "xz":
+            compressed = lzma.LZMAFile(initrd.fpath, "w", options={"level":9})
+
+        compressed.write(cpio.stdout.read())
+        compressed.close()
 
         # move modules out of the tree again
         shutil.move(joinpaths(self.root, "modules", kernel.version),
-- 
1.7.3.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux