initial support for /var/tmp/portage in tmpfs
authorRick Farina (Zero_Chaos) <zerochaos@gentoo.org>
Thu, 25 Oct 2012 03:20:36 +0000 (23:20 -0400)
committerRick Farina (Zero_Chaos) <zerochaos@gentoo.org>
Thu, 25 Oct 2012 03:20:36 +0000 (23:20 -0400)
recently a bug in ZFS completely preventing building on my host system,
due to this fact I hacked in this support to get around the issue.
Since building in tmpfs can speed things significantly I've added the
support properly and optionally. Hopefully others like this as much as
I do.
My motivation: https://bugs.gentoo.org/show_bug.cgi?id=411555
Thanks to jmbsvicetto and dol-sen for helping me read catalyst.

catalyst
files/catalyst.conf
modules/generic_stage_target.py

index 33e121fd115347720a05fb24d253cabe9d7b3798..483a6e53a3c5c1ea966b270911bdc58366969166 100755 (executable)
--- a/catalyst
+++ b/catalyst
@@ -165,6 +165,9 @@ def parse_config(myconfig):
                print "Envscript support enabled."
                conf_values["ENVSCRIPT"]=myconf["envscript"]
 
+       if myconf.has_key("var_tmpfs_portage"):
+               conf_values["var_tmpfs_portage"]=myconf["var_tmpfs_portage"];
+
 def import_modules():
        # import catalyst's own modules (i.e. catalyst_support and the arch modules)
        targetmap={}
index a5ef120c4d8ce40daea774639f07da9b0678d92e..49d2a15f5375709e2cec6021ccf19be2a8d5ee9a 100644 (file)
@@ -80,3 +80,9 @@ snapshot_cache="/var/tmp/catalyst/snapshot_cache"
 # storedir specifies where catalyst will store everything that it builds, and
 # also where it will put its temporary files and caches.
 storedir="/var/tmp/catalyst"
+
+# var_tmpfs_portage will mount a tmpfs for /var/tmp/portage so building takes place in RAM
+# this feature requires a pretty large tmpfs ({open,libre}office needs ~8GB to build)
+# WARNING: If you use too much RAM everything will fail horribly and it is not our fault.
+# set size of /var/tmp/portage tmpfs in gigabytes
+# var_tmpfs_portage=16
index eb5f4905e0292ef87a7cebc2e6568fa071c96790..ae7d97cd3818ec85b14c672310939d6477ffe707 100644 (file)
@@ -174,14 +174,14 @@ class generic_stage_target(generic_target):
 
                """ Setup our mount points """
                if self.settings.has_key("SNAPCACHE"):
-                       self.mounts=["/proc","/dev","/usr/portage","/usr/portage/distfiles"]
+                       self.mounts=["/proc","/dev","/usr/portage","/usr/portage/distfiles","/var/tmp/portage"]
                        self.mountmap={"/proc":"/proc","/dev":"/dev","/dev/pts":"/dev/pts",\
                                "/usr/portage":self.settings["snapshot_cache_path"]+"/portage",\
-                               "/usr/portage/distfiles":self.settings["distdir"]}
+                               "/usr/portage/distfiles":self.settings["distdir"],"/var/tmp/portage":"tmpfs"}
                else:
-                       self.mounts=["/proc","/dev","/usr/portage/distfiles"]
+                       self.mounts=["/proc","/dev","/usr/portage/distfiles","/var/tmp/portage"]
                        self.mountmap={"/proc":"/proc","/dev":"/dev","/dev/pts":"/dev/pts",\
-                               "/usr/portage/distfiles":self.settings["distdir"]}
+                               "/usr/portage/distfiles":self.settings["distdir"],"/var/tmp/portage":"tmpfs"}
                if os.uname()[0] == "Linux":
                        self.mounts.append("/dev/pts")
 
@@ -887,8 +887,14 @@ class generic_stage_target(generic_target):
                                        retval=os.system("mount_nullfs "+src+" "+\
                                                self.settings["chroot_path"]+x)
                        else:
-                               retval=os.system("mount --bind "+src+" "+\
-                                       self.settings["chroot_path"]+x)
+                               if src == "tmpfs":
+                                       if self.settings.has_key("var_tmpfs_portage"):
+                                               retval=os.system("mount -t tmpfs -o size="+\
+                                                       self.settings["var_tmpfs_portage"]+"G "+src+" "+\
+                                                       self.settings["chroot_path"]+x)
+                               else:
+                                       retval=os.system("mount --bind "+src+" "+\
+                                               self.settings["chroot_path"]+x)
                        if retval!=0:
                                self.unbind()
                                raise CatalystError,"Couldn't bind mount "+src