From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C5D49139695 for ; Thu, 9 Mar 2017 10:02:41 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 241E921C07D; Thu, 9 Mar 2017 10:02:36 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E2EE021C07D for ; Thu, 9 Mar 2017 10:02:35 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DB3CD341687 for ; Thu, 9 Mar 2017 10:02:34 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 55E666211 for ; Thu, 9 Mar 2017 10:02:33 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1489053580.2ca4770bb462f54229a2c84e47d2c7d78794a4c0.dolsen@gentoo> Subject: [gentoo-commits] proj/catalyst:pending commit in: catalyst/base/, etc/, catalyst/ X-VCS-Repository: proj/catalyst X-VCS-Files: catalyst/base/stagebase.py catalyst/defaults.py etc/catalyst.conf X-VCS-Directories: catalyst/base/ etc/ catalyst/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 2ca4770bb462f54229a2c84e47d2c7d78794a4c0 X-VCS-Branch: pending Date: Thu, 9 Mar 2017 10:02:33 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 5ce7092a-2973-4c88-afcc-f639b8cb18f8 X-Archives-Hash: 84d700f1ba37a4f0f1955127a42871b5 commit: 2ca4770bb462f54229a2c84e47d2c7d78794a4c0 Author: Brian Dolbec gentoo org> AuthorDate: Thu Mar 9 09:14:04 2017 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 9 09:59:40 2017 +0000 URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=2ca4770b base/stagebase.py: Seperate out the writing of the make.conf file By sepaerating out the writing of the make.conf file, it keeps all code to do so in one place. I also fixed the code to correctly set the target chroot directories for PORTDIR, DISTDIR, PKGDIR and PORTDIR_OVERLAY. The same code also re-writes make.conf toggling any PORTDIR_OVERLAY setting during the clean() run. Add target_distdir and target_pkgdir settings to defaults and catalyst.conf. This allows for more flexibility between host and target settings. They can be individually configured this way. Update target an source mounts from the configured settings. catalyst/base/stagebase.py | 194 ++++++++++++++++++++++++--------------------- catalyst/defaults.py | 2 + etc/catalyst.conf | 2 + 3 files changed, 106 insertions(+), 92 deletions(-) diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py index 677e19d..31efdf6 100644 --- a/catalyst/base/stagebase.py +++ b/catalyst/base/stagebase.py @@ -225,8 +225,13 @@ class StageBase(TargetBase, ClearBase, GenBase): self.mounts = ["proc", "dev", "portdir", "distdir", "port_tmpdir"] # initialize our source mounts self.mountmap = SOURCE_MOUNT_DEFAULTS.copy() - # update them from settings + # update these from settings + self.mountmap["portdir"] = self.settings["portdir"] self.mountmap["distdir"] = self.settings["distdir"] + self.target_mounts["portdir"] = normpath(self.settings["repo_basedir"] + + "/" + self.settings["repo_name"]) + self.target_mounts["distdir"] = self.settings["target_distdir"] + self.target_mounts["packagedir"] = self.settings["target_pkgdir"] if "snapcache" not in self.settings["options"]: self.mounts.remove("portdir") self.mountmap["portdir"] = None @@ -1070,96 +1075,106 @@ class StageBase(TargetBase, ClearBase, GenBase): if os.path.exists(hosts_file): os.rename(hosts_file, hosts_file + '.catalyst') shutil.copy('/etc/hosts', hosts_file) + # write out the make.conf + try: + self.write_make_conf(setup=True) + except OSError as e: + raise CatalystError('Could not write %s: %s' % ( + normpath(self.settings["chroot_path"] + + self.settings["make_conf"]), e)) + self.resume.enable("chroot_setup") - # Modify and write out make.conf (for the chroot) - makepath = normpath(self.settings["chroot_path"] + - self.settings["make_conf"]) - clear_path(makepath) - myf = open(makepath, "w") - myf.write("# These settings were set by the catalyst build script " - "that automatically\n# built this stage.\n") - myf.write("# Please consult " - "/usr/share/portage/config/make.conf.example " - "for a more\n# detailed example.\n") - - for flags in ["CFLAGS", "CXXFLAGS", "FCFLAGS", "FFLAGS", "LDFLAGS", - "ASFLAGS"]: - if not flags in self.settings: - continue - if flags in ["LDFLAGS", "ASFLAGS"]: - myf.write("# %s is unsupported. USE AT YOUR OWN RISK!\n" - % flags) - if (flags is not "CFLAGS" and - self.settings[flags] == self.settings["CFLAGS"]): - myf.write('%s="${CFLAGS}"\n' % flags) - elif isinstance(self.settings[flags], list): - myf.write('%s="%s"\n' - % (flags, ' '.join(self.settings[flags]))) - else: - myf.write('%s="%s"\n' - % (flags, self.settings[flags])) - - if "CBUILD" in self.settings: - myf.write("# This should not be changed unless you know exactly" - " what you are doing. You\n# should probably be " - "using a different stage, instead.\n") - myf.write('CBUILD="' + self.settings["CBUILD"] + '"\n') - - if "CHOST" in self.settings: - myf.write("# WARNING: Changing your CHOST is not something " - "that should be done lightly.\n# Please consult " - "https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable " - "before changing.\n") - myf.write('CHOST="' + self.settings["CHOST"] + '"\n') - - # Figure out what our USE vars are for building - myusevars = [] - if "HOSTUSE" in self.settings: - myusevars.extend(self.settings["HOSTUSE"]) - - if "use" in self.settings: - myusevars.extend(self.settings["use"]) - - if myusevars: - myf.write("# These are the USE and USE_EXPAND flags that were " - "used for\n# building in addition to what is provided " - "by the profile.\n") - myusevars = sorted(set(myusevars)) - myf.write('USE="' + ' '.join(myusevars) + '"\n') - if '-*' in myusevars: - log.warning( - 'The use of -* in %s/use will cause portage to ignore\n' - 'package.use in the profile and portage_confdir.\n' - "You've been warned!", self.settings['spec_prefix']) - - myuseexpandvars = {} - if "HOSTUSEEXPAND" in self.settings: - for hostuseexpand in self.settings["HOSTUSEEXPAND"]: - myuseexpandvars.update( - {hostuseexpand:self.settings["HOSTUSEEXPAND"][hostuseexpand]}) - - if myuseexpandvars: - for hostuseexpand in myuseexpandvars: - myf.write(hostuseexpand + '="' + - ' '.join(myuseexpandvars[hostuseexpand]) + '"\n') - - myf.write('PORTDIR="%s"\n' % self.settings['portdir']) - myf.write('DISTDIR="%s"\n' % self.settings['distdir']) - myf.write('PKGDIR="%s"\n' % self.settings['packagedir']) - + def write_make_conf(self, setup=True): + # Modify and write out make.conf (for the chroot) + makepath = normpath(self.settings["chroot_path"] + + self.settings["make_conf"]) + clear_path(makepath) + myf = open(makepath, "w") + myf.write("# These settings were set by the catalyst build script " + "that automatically\n# built this stage.\n") + myf.write("# Please consult " + "/usr/share/portage/config/make.conf.example " + "for a more\n# detailed example.\n") + + for flags in ["CFLAGS", "CXXFLAGS", "FCFLAGS", "FFLAGS", "LDFLAGS", + "ASFLAGS"]: + if not flags in self.settings: + continue + if flags in ["LDFLAGS", "ASFLAGS"]: + myf.write("# %s is unsupported. USE AT YOUR OWN RISK!\n" + % flags) + if (flags is not "CFLAGS" and + self.settings[flags] == self.settings["CFLAGS"]): + myf.write('%s="${CFLAGS}"\n' % flags) + elif isinstance(self.settings[flags], list): + myf.write('%s="%s"\n' + % (flags, ' '.join(self.settings[flags]))) + else: + myf.write('%s="%s"\n' + % (flags, self.settings[flags])) + + if "CBUILD" in self.settings: + myf.write("# This should not be changed unless you know exactly" + " what you are doing. You\n# should probably be " + "using a different stage, instead.\n") + myf.write('CBUILD="' + self.settings["CBUILD"] + '"\n') + + if "CHOST" in self.settings: + myf.write("# WARNING: Changing your CHOST is not something " + "that should be done lightly.\n# Please consult " + "https://wiki.gentoo.org/wiki/Changing_the_CHOST_variable " + "before changing.\n") + myf.write('CHOST="' + self.settings["CHOST"] + '"\n') + + # Figure out what our USE vars are for building + myusevars = [] + if "HOSTUSE" in self.settings: + myusevars.extend(self.settings["HOSTUSE"]) + + if "use" in self.settings: + myusevars.extend(self.settings["use"]) + + if myusevars: + myf.write("# These are the USE and USE_EXPAND flags that were " + "used for\n# building in addition to what is provided " + "by the profile.\n") + myusevars = sorted(set(myusevars)) + myf.write('USE="' + ' '.join(myusevars) + '"\n') + if '-*' in myusevars: + log.warning( + 'The use of -* in %s/use will cause portage to ignore\n' + 'package.use in the profile and portage_confdir.\n' + "You've been warned!", self.settings['spec_prefix']) + + myuseexpandvars = {} + if "HOSTUSEEXPAND" in self.settings: + for hostuseexpand in self.settings["HOSTUSEEXPAND"]: + myuseexpandvars.update( + {hostuseexpand:self.settings["HOSTUSEEXPAND"][hostuseexpand]}) + + if myuseexpandvars: + for hostuseexpand in myuseexpandvars: + myf.write(hostuseexpand + '="' + + ' '.join(myuseexpandvars[hostuseexpand]) + '"\n') + # write out a shipable version + target_portdir = normpath(self.settings["repo_basedir"] + "/" + + self.settings["repo_name"]) + + myf.write('PORTDIR="%s"\n' % target_portdir) + myf.write('DISTDIR="%s"\n' % self.settings['target_distdir']) + myf.write('PKGDIR="%s"\n' % self.settings['target_pkgdir']) + if setup: # Setup the portage overlay if "portage_overlay" in self.settings: myf.write('PORTDIR_OVERLAY="%s"\n' % self.settings["local_overlay"]) - # Set default locale for system responses. #478382 - myf.write( - '\n' - '# This sets the language of build output to English.\n' - '# Please keep this setting intact when reporting bugs.\n' - 'LC_MESSAGES=C\n') - - myf.close() - self.resume.enable("chroot_setup") + # Set default locale for system responses. #478382 + myf.write( + '\n' + '# This sets the language of build output to English.\n' + '# Please keep this setting intact when reporting bugs.\n' + 'LC_MESSAGES=C\n') + myf.close() def fsscript(self): if "autoresume" in self.settings["options"] \ @@ -1202,12 +1217,7 @@ class StageBase(TargetBase, ClearBase, GenBase): make_conf = self.settings['chroot_path'] + self.settings['make_conf'] try: - with open(make_conf) as f: - data = f.readlines() - data = ''.join(x for x in data - if not x.startswith('PORTDIR_OVERLAY')) - with open(make_conf, 'w') as f: - f.write(data) + self.write_make_conf(setup=False) except OSError as e: raise CatalystError('Could not update %s: %s' % (make_conf, e)) diff --git a/catalyst/defaults.py b/catalyst/defaults.py index 0bba6f4..84ed282 100644 --- a/catalyst/defaults.py +++ b/catalyst/defaults.py @@ -59,6 +59,8 @@ confdefaults={ "snapshot_name": "portage-", "source_matching": "strict", "storedir": "/var/tmp/catalyst", + "target_distdir": "/var/portage/distfiles", + "target_pkgdir":"/var/portage/packages", } DEFAULT_CONFIG_FILE = '/etc/catalyst/catalyst.conf' diff --git a/etc/catalyst.conf b/etc/catalyst.conf index 2e61ea4..b4db063 100644 --- a/etc/catalyst.conf +++ b/etc/catalyst.conf @@ -85,6 +85,8 @@ portdir="/usr/portage" # repo_basedir="/usr" repo_name="portage" +target_distdir="/usr/portage/distfiles" +target_pkgdir="/usr/portage/packages" # sharedir specifies where all of the catalyst runtime executables # and other shared lib objects are.