From 4fc99aed1c6ba4d262f7d0c70f07cdd3413c18df Mon Sep 17 00:00:00 2001 From: "Rick Farina (Zero_Chaos)" Date: Wed, 24 Oct 2012 23:20:36 -0400 Subject: [PATCH] initial support for /var/tmp/portage in tmpfs 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 | 3 +++ files/catalyst.conf | 6 ++++++ modules/generic_stage_target.py | 18 ++++++++++++------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/catalyst b/catalyst index 33e121fd..483a6e53 100755 --- 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={} diff --git a/files/catalyst.conf b/files/catalyst.conf index a5ef120c..49d2a15f 100644 --- a/files/catalyst.conf +++ b/files/catalyst.conf @@ -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 diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py index eb5f4905..ae7d97cd 100644 --- a/modules/generic_stage_target.py +++ b/modules/generic_stage_target.py @@ -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 -- 2.26.2