From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/catalyst:pending commit in: etc/, catalyst/base/, catalyst/
Date: Wed, 22 Nov 2017 15:52:44 +0000 (UTC) [thread overview]
Message-ID: <1511313381.d5f54e2693f4277fee370927ef18265ebcc52ac1.dolsen@gentoo> (raw)
Message-ID: <20171122155244.BVoQVZGfXpDOXX38FGWXJwLEkP4jC-trXIB1mwZUdQc@z> (raw)
commit: d5f54e2693f4277fee370927ef18265ebcc52ac1
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 9 09:14:04 2017 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Wed Nov 22 01:16:21 2017 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d5f54e26
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 532f0997..67382b9a 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -213,8 +213,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
@@ -1051,96 +1056,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"] \
@@ -1183,12 +1198,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 0bba6f4d..84ed2822 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 2e61ea4f..b4db063c 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.
next reply other threads:[~2017-11-22 15:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-29 17:20 Brian Dolbec [this message]
2017-11-22 15:52 ` [gentoo-commits] proj/catalyst:pending commit in: etc/, catalyst/base/, catalyst/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2020-05-20 3:39 [gentoo-commits] proj/catalyst:pending/mattst88 commit in: catalyst/base/, catalyst/, etc/ Matt Turner
2020-05-21 20:25 ` [gentoo-commits] proj/catalyst:master commit in: catalyst/, catalyst/base/, etc/ Matt Turner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1511313381.d5f54e2693f4277fee370927ef18265ebcc52ac1.dolsen@gentoo \
--to=dolsen@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox