* [gentoo-catalyst] [PATCH 2/2] Move from PORTDIR_OVERLAY to repos.conf
@ 2020-10-17 19:00 Felix Bier
2020-10-17 20:11 ` Matt Turner
2020-10-18 15:15 ` [gentoo-catalyst] " Felix Bier
0 siblings, 2 replies; 9+ messages in thread
From: Felix Bier @ 2020-10-17 19:00 UTC (permalink / raw
To: gentoo-catalyst@lists.gentoo.org
This commit fixes the following issues:
* The PORTDIR_OVERLAY variable has been deprecated by Gentoo.
With this commit, the variable is no longer written to the
generated make.conf. Instead, a config file
/etc/portage/repos.conf/<repo-name>.conf
is generated for each overlay. The repo name is read from the
overlay using the portage API. Internally, portage parses
metadata/layout.conf and profiles/repo_name to obtain the name.
References:
https://wiki.gentoo.org/wiki//etc/portage/make.conf
https://wiki.gentoo.org/wiki//etc/portage/repos.conf
* All overlays were copied into the same target directory. If the
same file name occurred in multiple overlays, the last overlay
would overwrite all previous files with this name. In particular,
only the metadata/layout.conf of the last overlay was retained,
so it was not possible to reference the other overlays e.g. via
the masters entry in the layout.conf or the portage-2 syntax
for specifying a parent profile from another overlay. Also,
this created problems when the overlays contained ebuilds
for the same package, but with differing versions, because
after copying, the target directory contained both versions of the
ebuild but only the manifest file of the last overlay.
With this commit, each overlay is copied into a separate
sub-directory, e.g. /var/gentoo/repos/local/<repo-name>/.
This directory is referenced via the location entry in the
generated /etc/portage/repos.conf/<repo-name>.conf.
---
catalyst/base/stagebase.py | 72 ++++++++++++++++++++++++++++----------
catalyst/defaults.py | 1 +
catalyst/support.py | 18 ++++++++++
3 files changed, 72 insertions(+), 19 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index ac0f4f24..3d4f2a76 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1,4 +1,5 @@
+import configparser
import copy
import os
import platform
@@ -17,7 +18,8 @@ from DeComp.compress import CompressMap
from catalyst import log
from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS,
PORT_LOGDIR_CLEAN)
from catalyst.support import (CatalystError, file_locate, normpath,
- cmd, read_makeconf, ismount, file_check)
+ cmd, read_makeconf, get_repo_name,
ismount,
+ file_check)
from catalyst.base.targetbase import TargetBase
from catalyst.base.clearbase import ClearBase
from catalyst.base.genbase import GenBase
@@ -821,17 +823,48 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
self.resume.enable("setup_confdir")
+ def get_repo_conf_path(self, repo_name):
+ """ Construct repo conf path:
/etc/portage/repos.conf/{name}.conf """
+ return normpath(os.path.join(self.settings['repos_conf'],
repo_name + ".conf"))
+
+ def get_overlay_location(self, repo_name):
+ """ Construct overlay repo path:
/var/gentoo/repos/local/{name} """
+ return normpath(os.path.join(self.settings['local_overlay'],
repo_name))
+
+ def write_repo_conf(self, repo_name, config):
+ """ Write ConfigParser to
{chroot}/etc/portage/repo.conf/{name}.conf """
+ repo_conf = self.get_repo_conf_path(repo_name)
+ chroot_repo_conf = self.settings['chroot_path'] + repo_conf
+ log.info('Creating repo config %s.', chroot_repo_conf)
+ ensure_dirs(os.path.dirname(chroot_repo_conf))
+
+ try:
+ with open(chroot_repo_conf, 'w') as myf:
+ config.write(myf)
+ except OSError as e:
+ raise CatalystError('Could not write {}: {}'.format(
+ chroot_repo_conf, e)) from e
+
def portage_overlay(self):
- """ We copy the contents of our overlays to /usr/local/portage
"""
+ """ We copy the contents of our overlays to
/var/gentoo/repos/local/{name} """
if "portage_overlay" in self.settings:
for x in self.settings["portage_overlay"]:
if os.path.exists(x):
- log.info('Copying overlay dir %s', x)
- ensure_dirs(
- self.settings['chroot_path'] +
self.settings['local_overlay'])
- cmd("cp -a " + x + "/* " +
self.settings["chroot_path"] +
- self.settings["local_overlay"],
- env=self.env)
+ name = get_repo_name(x)
+
+ location = self.get_overlay_location(name)
+ config = configparser.ConfigParser()
+ config[name] = {'location': location}
+ self.write_repo_conf(name, config)
+
+ chroot_location = normpath(
+ self.settings['chroot_path'] + location)
+ log.info('Copying overlay dir %s to %s',
+ x, chroot_location)
+ ensure_dirs(chroot_location)
+ cmd('cp -a ' + x + '/* ' + chroot_location,
env=self.env)
+ else:
+ log.warning('Skipping missing overlay %s.', x)
def root_overlay(self):
""" Copy over the root_overlay """
@@ -1080,12 +1113,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
varname = x.split('_')[1].upper()
myf.write(f'{varname}="{self.settings[x]}"\n')
- 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'
@@ -1157,11 +1184,18 @@ class StageBase(TargetBase, ClearBase,
GenBase):
log.warning("You've been hacking. Clearing target patches:
%s", target)
clear_path(target)
- # Remove our overlay
- overlay = normpath(
- self.settings["chroot_path"] +
self.settings["local_overlay"])
- if os.path.exists(overlay):
- clear_path(overlay)
+ # Remove our overlays
+ if "portage_overlay" in self.settings:
+ for repo_path in self.settings["portage_overlay"]:
+ repo_name = get_repo_name(repo_path)
+
+ repo_conf = self.get_repo_conf_path(repo_name)
+ chroot_repo_conf = self.settings["chroot_path"] +
repo_conf
+ clear_path(chroot_repo_conf)
+
+ location = self.get_overlay_location(repo_name)
+ chroot_location = self.settings['chroot_path'] +
location
+ clear_path(chroot_location)
if "sticky-config" not in self.settings["options"]:
# re-write the make.conf to be sure it is clean
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index c153fcc4..9660a7f3 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -38,6 +38,7 @@ confdefaults = {
"local_overlay": "/var/db/repos/local",
"port_conf": "/etc/portage",
"make_conf": "%(port_conf)s/make.conf",
+ "repos_conf": "%(port_conf)s/repos.conf",
"options": set(),
"pkgdir": "/var/cache/binpkgs",
"port_tmpdir": "/var/tmp/portage",
diff --git a/catalyst/support.py b/catalyst/support.py
index a6a6854a..b8069c7d 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -7,6 +7,8 @@ import shutil
import time
from subprocess import Popen
+from portage.repository.config import RepoConfig
+
from catalyst import log
BASH_BINARY = "/bin/bash"
@@ -179,6 +181,22 @@ def read_makeconf(mymakeconffile):
return makeconf
+def get_repo_name(repo_path):
+ """ Get the name of the repo at the given repo_path.
+
+ References:
+
https://wiki.gentoo.org/wiki/Repository_format/profiles/repo_name
+
https://wiki.gentoo.org/wiki/Repository_format/metadata/layout.conf#repo-name
+ """
+
+ repo_config = RepoConfig(None, {"location": repo_path})
+
+ if repo_config.missing_repo_name:
+ raise CatalystError("Missing name in repository
{}".format(repo_path))
+
+ return repo_config.name
+
+
def pathcompare(path1, path2):
# Change double slashes to slash
path1 = re.sub(r"//", r"/", path1)
--
2.28.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [gentoo-catalyst] [PATCH 2/2] Move from PORTDIR_OVERLAY to repos.conf
2020-10-17 19:00 [gentoo-catalyst] [PATCH 2/2] Move from PORTDIR_OVERLAY to repos.conf Felix Bier
@ 2020-10-17 20:11 ` Matt Turner
2020-10-18 13:58 ` [Newsletter] " Felix Bier
2020-10-18 15:15 ` [gentoo-catalyst] " Felix Bier
1 sibling, 1 reply; 9+ messages in thread
From: Matt Turner @ 2020-10-17 20:11 UTC (permalink / raw
To: gentoo-catalyst
On Sat, Oct 17, 2020 at 12:00 PM Felix Bier
<Felix.Bier@rohde-schwarz.com> wrote:
>
> This commit fixes the following issues:
>
> * The PORTDIR_OVERLAY variable has been deprecated by Gentoo.
>
> With this commit, the variable is no longer written to the
> generated make.conf. Instead, a config file
> /etc/portage/repos.conf/<repo-name>.conf
> is generated for each overlay. The repo name is read from the
> overlay using the portage API. Internally, portage parses
> metadata/layout.conf and profiles/repo_name to obtain the name.
>
> References:
> https://wiki.gentoo.org/wiki//etc/portage/make.conf
> https://wiki.gentoo.org/wiki//etc/portage/repos.conf
>
> * All overlays were copied into the same target directory. If the
> same file name occurred in multiple overlays, the last overlay
> would overwrite all previous files with this name. In particular,
> only the metadata/layout.conf of the last overlay was retained,
> so it was not possible to reference the other overlays e.g. via
> the masters entry in the layout.conf or the portage-2 syntax
> for specifying a parent profile from another overlay. Also,
> this created problems when the overlays contained ebuilds
> for the same package, but with differing versions, because
> after copying, the target directory contained both versions of the
> ebuild but only the manifest file of the last overlay.
>
> With this commit, each overlay is copied into a separate
> sub-directory, e.g. /var/gentoo/repos/local/<repo-name>/.
> This directory is referenced via the location entry in the
> generated /etc/portage/repos.conf/<repo-name>.conf.
> ---
Hello,
Thank you for the patches. I'm happy to see them.
I cannot apply the patches however. This one in particular is badly
line wrapped by your mail client. I tried fixing it up, but either
failed or don't know what this is supposed to apply to.
It looks like the intention is for this to apply to the
catalyst-3.0-stable branch since it discusses copying overlays into a
subdirectory, rather than any mention of squashfs snapshots.
I really don't want new feature work on the catalyst-3.0-stable
branch, for example. If that is the target, then please consider
rebasing the work onto the master branch.
Matt
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Newsletter] Re: [gentoo-catalyst] [PATCH 2/2] Move from PORTDIR_OVERLAY to repos.conf
2020-10-17 20:11 ` Matt Turner
@ 2020-10-18 13:58 ` Felix Bier
2020-10-30 16:13 ` Matt Turner
0 siblings, 1 reply; 9+ messages in thread
From: Felix Bier @ 2020-10-18 13:58 UTC (permalink / raw
To: gentoo-catalyst@lists.gentoo.org
Am Samstag, den 17.10.2020, 13:11 -0700 schrieb Matt Turner:
> On Sat, Oct 17, 2020 at 12:00 PM Felix Bier
> <Felix.Bier@rohde-schwarz.com> wrote:
> >
> > This commit fixes the following issues:
> >
> > * The PORTDIR_OVERLAY variable has been deprecated by Gentoo.
> >
> > With this commit, the variable is no longer written to the
> > generated make.conf. Instead, a config file
> > /etc/portage/repos.conf/<repo-name>.conf
> > is generated for each overlay. The repo name is read from the
> > overlay using the portage API. Internally, portage parses
> > metadata/layout.conf and profiles/repo_name to obtain the name.
> >
> > References:
> > https://wiki.gentoo.org/wiki//etc/portage/make.conf
> > https://wiki.gentoo.org/wiki//etc/portage/repos.conf
> >
> > * All overlays were copied into the same target directory. If the
> > same file name occurred in multiple overlays, the last overlay
> > would overwrite all previous files with this name. In
> > particular,
> > only the metadata/layout.conf of the last overlay was retained,
> > so it was not possible to reference the other overlays e.g. via
> > the masters entry in the layout.conf or the portage-2 syntax
> > for specifying a parent profile from another overlay. Also,
> > this created problems when the overlays contained ebuilds
> > for the same package, but with differing versions, because
> > after copying, the target directory contained both versions of
> > the
> > ebuild but only the manifest file of the last overlay.
> >
> > With this commit, each overlay is copied into a separate
> > sub-directory, e.g. /var/gentoo/repos/local/<repo-name>/.
> > This directory is referenced via the location entry in the
> > generated /etc/portage/repos.conf/<repo-name>.conf.
> > ---
>
> Hello,
>
> Thank you for the patches. I'm happy to see them.
>
> I cannot apply the patches however. This one in particular is badly
> line wrapped by your mail client. I tried fixing it up, but either
> failed or don't know what this is supposed to apply to.
>
> It looks like the intention is for this to apply to the
> catalyst-3.0-stable branch since it discusses copying overlays into a
> subdirectory, rather than any mention of squashfs snapshots.
>
> I really don't want new feature work on the catalyst-3.0-stable
> branch, for example. If that is the target, then please consider
> rebasing the work onto the master branch.
>
> Matt
Hello Matt,
thank you for the initial review.
I'm sorry for the formatting issues, I will check my mail client's
format settings and resend the patches.
The patches are intendend for the master branch. I agree that this
feature should not be in the stable branch.
My understanding is that in the master branch, the squashfs is only
used for the main repository, whereas the overlays are still copied as
directories (in the StageBase.portage_overlay() function).
This patch only removes PORTDIR_OVERLAY, not PORTDIR, so it should not
be a problem that the main repository is squashed. I kept the helper
functions that this patch adds general, so that they can be reused for
a later PORTDIR removal, but I would prefer to do that in a separate
step.
I don't know if there are plans to also switch the overlays to
squashfs. My intuition would be that the overlays would usually be much
smaller than the main repository, so squashing them would have less
benefit. Even if there is a plan to switch the overlays to squashfs (or
bind-mounting, which I would prefer), I think my patch would still be
helpful for that, since it would not be possible to create multiple
mounts with the same target directory (such as /var/db/repo/local). So
creating subdirectories (/var/db/repo/local/overlay1,
/var/db/repo/local/overlay2 etc.) would still be needed.
Best regards,
Felix
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Newsletter] Re: [gentoo-catalyst] [PATCH 2/2] Move from PORTDIR_OVERLAY to repos.conf
2020-10-18 13:58 ` [Newsletter] " Felix Bier
@ 2020-10-30 16:13 ` Matt Turner
0 siblings, 0 replies; 9+ messages in thread
From: Matt Turner @ 2020-10-30 16:13 UTC (permalink / raw
To: gentoo-catalyst
On Sun, Oct 18, 2020 at 9:58 AM Felix Bier <Felix.Bier@rohde-schwarz.com> wrote:
>
> Am Samstag, den 17.10.2020, 13:11 -0700 schrieb Matt Turner:
> > On Sat, Oct 17, 2020 at 12:00 PM Felix Bier
> > <Felix.Bier@rohde-schwarz.com> wrote:
> > >
> > > This commit fixes the following issues:
> > >
> > > * The PORTDIR_OVERLAY variable has been deprecated by Gentoo.
> > >
> > > With this commit, the variable is no longer written to the
> > > generated make.conf. Instead, a config file
> > > /etc/portage/repos.conf/<repo-name>.conf
> > > is generated for each overlay. The repo name is read from the
> > > overlay using the portage API. Internally, portage parses
> > > metadata/layout.conf and profiles/repo_name to obtain the name.
> > >
> > > References:
> > > https://wiki.gentoo.org/wiki//etc/portage/make.conf
> > > https://wiki.gentoo.org/wiki//etc/portage/repos.conf
> > >
> > > * All overlays were copied into the same target directory. If the
> > > same file name occurred in multiple overlays, the last overlay
> > > would overwrite all previous files with this name. In
> > > particular,
> > > only the metadata/layout.conf of the last overlay was retained,
> > > so it was not possible to reference the other overlays e.g. via
> > > the masters entry in the layout.conf or the portage-2 syntax
> > > for specifying a parent profile from another overlay. Also,
> > > this created problems when the overlays contained ebuilds
> > > for the same package, but with differing versions, because
> > > after copying, the target directory contained both versions of
> > > the
> > > ebuild but only the manifest file of the last overlay.
> > >
> > > With this commit, each overlay is copied into a separate
> > > sub-directory, e.g. /var/gentoo/repos/local/<repo-name>/.
> > > This directory is referenced via the location entry in the
> > > generated /etc/portage/repos.conf/<repo-name>.conf.
> > > ---
> >
> > Hello,
> >
> > Thank you for the patches. I'm happy to see them.
> >
> > I cannot apply the patches however. This one in particular is badly
> > line wrapped by your mail client. I tried fixing it up, but either
> > failed or don't know what this is supposed to apply to.
> >
> > It looks like the intention is for this to apply to the
> > catalyst-3.0-stable branch since it discusses copying overlays into a
> > subdirectory, rather than any mention of squashfs snapshots.
> >
> > I really don't want new feature work on the catalyst-3.0-stable
> > branch, for example. If that is the target, then please consider
> > rebasing the work onto the master branch.
> >
> > Matt
>
> Hello Matt,
> thank you for the initial review.
>
> I'm sorry for the formatting issues, I will check my mail client's
> format settings and resend the patches.
>
> The patches are intendend for the master branch. I agree that this
> feature should not be in the stable branch.
>
> My understanding is that in the master branch, the squashfs is only
> used for the main repository, whereas the overlays are still copied as
> directories (in the StageBase.portage_overlay() function).
>
> This patch only removes PORTDIR_OVERLAY, not PORTDIR, so it should not
> be a problem that the main repository is squashed. I kept the helper
> functions that this patch adds general, so that they can be reused for
> a later PORTDIR removal, but I would prefer to do that in a separate
> step.
Right. I guess I was expecting a transition from PORTDIR +
PORTDIR_OVERLAY to the modern just-a-bunch-of-repos repos.conf system.
That's totally fine to not make the leap all at once.
There's actually a patch in https://bugs.gentoo.org/560518 that
creates repos.conf, if you're interested in any follow on work :)
> I don't know if there are plans to also switch the overlays to
> squashfs. My intuition would be that the overlays would usually be much
> smaller than the main repository, so squashing them would have less
> benefit. Even if there is a plan to switch the overlays to squashfs (or
> bind-mounting, which I would prefer), I think my patch would still be
> helpful for that, since it would not be possible to create multiple
> mounts with the same target directory (such as /var/db/repo/local). So
> creating subdirectories (/var/db/repo/local/overlay1,
> /var/db/repo/local/overlay2 etc.) would still be needed.
An additional advantage of squashfs snapshots is that they're
snapshots. In that way, we should be able to reproduce a build from
exactly the same inputs. You're right that the other advantages of
squashfs snapshots (smaller size, not copying 1GB of small files,
quick cleanup, etc) don't really apply to the same degree to small
overlays.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [gentoo-catalyst] Re: [PATCH 2/2] Move from PORTDIR_OVERLAY to repos.conf
2020-10-17 19:00 [gentoo-catalyst] [PATCH 2/2] Move from PORTDIR_OVERLAY to repos.conf Felix Bier
2020-10-17 20:11 ` Matt Turner
@ 2020-10-18 15:15 ` Felix Bier
2020-10-30 16:07 ` Matt Turner
1 sibling, 1 reply; 9+ messages in thread
From: Felix Bier @ 2020-10-18 15:15 UTC (permalink / raw
To: gentoo-catalyst@lists.gentoo.org
This commit fixes the following issues:
* The PORTDIR_OVERLAY variable has been deprecated by Gentoo.
With this commit, the variable is no longer written to the
generated make.conf. Instead, a config file
/etc/portage/repos.conf/<repo-name>.conf
is generated for each overlay. The repo name is read from the
overlay using the portage API. Internally, portage parses
metadata/layout.conf and profiles/repo_name to obtain the name.
References:
https://wiki.gentoo.org/wiki//etc/portage/make.conf
https://wiki.gentoo.org/wiki//etc/portage/repos.conf
* All overlays were copied into the same target directory. If the
same file name occurred in multiple overlays, the last overlay
would overwrite all previous files with this name. In particular,
only the metadata/layout.conf of the last overlay was retained,
so it was not possible to reference the other overlays e.g. via
the masters entry in the layout.conf or the portage-2 syntax
for specifying a parent profile from another overlay. Also,
this created problems when the overlays contained ebuilds
for the same package, but with differing versions, because
after copying, the target directory contained both versions of the
ebuild but only the manifest file of the last overlay.
With this commit, each overlay is copied into a separate
sub-directory, e.g. /var/gentoo/repos/local/<repo-name>/.
This directory is referenced via the location entry in the
generated /etc/portage/repos.conf/<repo-name>.conf.
---
catalyst/base/stagebase.py | 72 ++++++++++++++++++++++++++++----------
catalyst/defaults.py | 1 +
catalyst/support.py | 18 ++++++++++
3 files changed, 72 insertions(+), 19 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index ac0f4f24..3d4f2a76 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1,4 +1,5 @@
+import configparser
import copy
import os
import platform
@@ -17,7 +18,8 @@ from DeComp.compress import CompressMap
from catalyst import log
from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN)
from catalyst.support import (CatalystError, file_locate, normpath,
- cmd, read_makeconf, ismount, file_check)
+ cmd, read_makeconf, get_repo_name, ismount,
+ file_check)
from catalyst.base.targetbase import TargetBase
from catalyst.base.clearbase import ClearBase
from catalyst.base.genbase import GenBase
@@ -821,17 +823,48 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
self.resume.enable("setup_confdir")
+ def get_repo_conf_path(self, repo_name):
+ """ Construct repo conf path: /etc/portage/repos.conf/{name}.conf """
+ return normpath(os.path.join(self.settings['repos_conf'], repo_name + ".conf"))
+
+ def get_overlay_location(self, repo_name):
+ """ Construct overlay repo path: /var/gentoo/repos/local/{name} """
+ return normpath(os.path.join(self.settings['local_overlay'], repo_name))
+
+ def write_repo_conf(self, repo_name, config):
+ """ Write ConfigParser to {chroot}/etc/portage/repo.conf/{name}.conf """
+ repo_conf = self.get_repo_conf_path(repo_name)
+ chroot_repo_conf = self.settings['chroot_path'] + repo_conf
+ log.info('Creating repo config %s.', chroot_repo_conf)
+ ensure_dirs(os.path.dirname(chroot_repo_conf))
+
+ try:
+ with open(chroot_repo_conf, 'w') as myf:
+ config.write(myf)
+ except OSError as e:
+ raise CatalystError('Could not write {}: {}'.format(
+ chroot_repo_conf, e)) from e
+
def portage_overlay(self):
- """ We copy the contents of our overlays to /usr/local/portage """
+ """ We copy the contents of our overlays to /var/gentoo/repos/local/{name} """
if "portage_overlay" in self.settings:
for x in self.settings["portage_overlay"]:
if os.path.exists(x):
- log.info('Copying overlay dir %s', x)
- ensure_dirs(
- self.settings['chroot_path'] + self.settings['local_overlay'])
- cmd("cp -a " + x + "/* " + self.settings["chroot_path"] +
- self.settings["local_overlay"],
- env=self.env)
+ name = get_repo_name(x)
+
+ location = self.get_overlay_location(name)
+ config = configparser.ConfigParser()
+ config[name] = {'location': location}
+ self.write_repo_conf(name, config)
+
+ chroot_location = normpath(
+ self.settings['chroot_path'] + location)
+ log.info('Copying overlay dir %s to %s',
+ x, chroot_location)
+ ensure_dirs(chroot_location)
+ cmd('cp -a ' + x + '/* ' + chroot_location, env=self.env)
+ else:
+ log.warning('Skipping missing overlay %s.', x)
def root_overlay(self):
""" Copy over the root_overlay """
@@ -1080,12 +1113,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
varname = x.split('_')[1].upper()
myf.write(f'{varname}="{self.settings[x]}"\n')
- 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'
@@ -1157,11 +1184,18 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.warning("You've been hacking. Clearing target patches: %s", target)
clear_path(target)
- # Remove our overlay
- overlay = normpath(
- self.settings["chroot_path"] + self.settings["local_overlay"])
- if os.path.exists(overlay):
- clear_path(overlay)
+ # Remove our overlays
+ if "portage_overlay" in self.settings:
+ for repo_path in self.settings["portage_overlay"]:
+ repo_name = get_repo_name(repo_path)
+
+ repo_conf = self.get_repo_conf_path(repo_name)
+ chroot_repo_conf = self.settings["chroot_path"] + repo_conf
+ clear_path(chroot_repo_conf)
+
+ location = self.get_overlay_location(repo_name)
+ chroot_location = self.settings['chroot_path'] + location
+ clear_path(chroot_location)
if "sticky-config" not in self.settings["options"]:
# re-write the make.conf to be sure it is clean
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index c153fcc4..9660a7f3 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -38,6 +38,7 @@ confdefaults = {
"local_overlay": "/var/db/repos/local",
"port_conf": "/etc/portage",
"make_conf": "%(port_conf)s/make.conf",
+ "repos_conf": "%(port_conf)s/repos.conf",
"options": set(),
"pkgdir": "/var/cache/binpkgs",
"port_tmpdir": "/var/tmp/portage",
diff --git a/catalyst/support.py b/catalyst/support.py
index a6a6854a..b8069c7d 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -7,6 +7,8 @@ import shutil
import time
from subprocess import Popen
+from portage.repository.config import RepoConfig
+
from catalyst import log
BASH_BINARY = "/bin/bash"
@@ -179,6 +181,22 @@ def read_makeconf(mymakeconffile):
return makeconf
+def get_repo_name(repo_path):
+ """ Get the name of the repo at the given repo_path.
+
+ References:
+ https://wiki.gentoo.org/wiki/Repository_format/profiles/repo_name
+ https://wiki.gentoo.org/wiki/Repository_format/metadata/layout.conf#repo-name
+ """
+
+ repo_config = RepoConfig(None, {"location": repo_path})
+
+ if repo_config.missing_repo_name:
+ raise CatalystError("Missing name in repository {}".format(repo_path))
+
+ return repo_config.name
+
+
def pathcompare(path1, path2):
# Change double slashes to slash
path1 = re.sub(r"//", r"/", path1)
--
2.28.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [gentoo-catalyst] Re: [PATCH 2/2] Move from PORTDIR_OVERLAY to repos.conf
2020-10-18 15:15 ` [gentoo-catalyst] " Felix Bier
@ 2020-10-30 16:07 ` Matt Turner
2020-10-31 21:24 ` Brian Dolbec
2020-11-10 1:03 ` [Newsletter] " Felix Bier
0 siblings, 2 replies; 9+ messages in thread
From: Matt Turner @ 2020-10-30 16:07 UTC (permalink / raw
To: gentoo-catalyst
On Sun, Oct 18, 2020 at 11:15 AM Felix Bier
<Felix.Bier@rohde-schwarz.com> wrote:
>
> This commit fixes the following issues:
>
> * The PORTDIR_OVERLAY variable has been deprecated by Gentoo.
>
> With this commit, the variable is no longer written to the
> generated make.conf. Instead, a config file
> /etc/portage/repos.conf/<repo-name>.conf
> is generated for each overlay. The repo name is read from the
> overlay using the portage API. Internally, portage parses
> metadata/layout.conf and profiles/repo_name to obtain the name.
>
> References:
> https://wiki.gentoo.org/wiki//etc/portage/make.conf
> https://wiki.gentoo.org/wiki//etc/portage/repos.conf
>
> * All overlays were copied into the same target directory. If the
> same file name occurred in multiple overlays, the last overlay
> would overwrite all previous files with this name. In particular,
> only the metadata/layout.conf of the last overlay was retained,
> so it was not possible to reference the other overlays e.g. via
> the masters entry in the layout.conf or the portage-2 syntax
> for specifying a parent profile from another overlay. Also,
> this created problems when the overlays contained ebuilds
> for the same package, but with differing versions, because
> after copying, the target directory contained both versions of the
> ebuild but only the manifest file of the last overlay.
>
> With this commit, each overlay is copied into a separate
> sub-directory, e.g. /var/gentoo/repos/local/<repo-name>/.
I see this /var/gentoo/repos path used as an example in a few places
but not actually in any code. I think our example should match the
default structure these days, e.g., /var/db/repos/<repo-name>.
> This directory is referenced via the location entry in the
> generated /etc/portage/repos.conf/<repo-name>.conf.
> ---
> catalyst/base/stagebase.py | 72 ++++++++++++++++++++++++++++----------
> catalyst/defaults.py | 1 +
> catalyst/support.py | 18 ++++++++++
> 3 files changed, 72 insertions(+), 19 deletions(-)
>
> diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
> index ac0f4f24..3d4f2a76 100644
> --- a/catalyst/base/stagebase.py
> +++ b/catalyst/base/stagebase.py
> @@ -1,4 +1,5 @@
>
> +import configparser
> import copy
> import os
> import platform
> @@ -17,7 +18,8 @@ from DeComp.compress import CompressMap
> from catalyst import log
> from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN)
> from catalyst.support import (CatalystError, file_locate, normpath,
> - cmd, read_makeconf, ismount, file_check)
> + cmd, read_makeconf, get_repo_name, ismount,
> + file_check)
> from catalyst.base.targetbase import TargetBase
> from catalyst.base.clearbase import ClearBase
> from catalyst.base.genbase import GenBase
> @@ -821,17 +823,48 @@ class StageBase(TargetBase, ClearBase, GenBase):
> env=self.env)
> self.resume.enable("setup_confdir")
>
> + def get_repo_conf_path(self, repo_name):
> + """ Construct repo conf path: /etc/portage/repos.conf/{name}.conf """
> + return normpath(os.path.join(self.settings['repos_conf'], repo_name + ".conf"))
I would rather we use pathlib and not add new uses of normpath.
> +
> + def get_overlay_location(self, repo_name):
> + """ Construct overlay repo path: /var/gentoo/repos/local/{name} """
> + return normpath(os.path.join(self.settings['local_overlay'], repo_name))
> +
> + def write_repo_conf(self, repo_name, config):
> + """ Write ConfigParser to {chroot}/etc/portage/repo.conf/{name}.conf """
> + repo_conf = self.get_repo_conf_path(repo_name)
> + chroot_repo_conf = self.settings['chroot_path'] + repo_conf
> + log.info('Creating repo config %s.', chroot_repo_conf)
> + ensure_dirs(os.path.dirname(chroot_repo_conf))
Same thing: I'd rather use pathlib and use Path.mkdir and not add new
uses of ensure_dirs.
> +
> + try:
> + with open(chroot_repo_conf, 'w') as myf:
Let's rename myf. The 'my' prefix pattern in catalyst is not a good
one. Even just 'f' or 'file' would be better, IMO.
> + config.write(myf)
> + except OSError as e:
> + raise CatalystError('Could not write {}: {}'.format(
> + chroot_repo_conf, e)) from e
> +
> def portage_overlay(self):
Feel free to rename things, like this function if their name no longer
matches the current terminology.
> - """ We copy the contents of our overlays to /usr/local/portage """
> + """ We copy the contents of our overlays to /var/gentoo/repos/local/{name} """
Let's not use a real path here. It only stands to confuse the reader.
> if "portage_overlay" in self.settings:
> for x in self.settings["portage_overlay"]:
> if os.path.exists(x):
> - log.info('Copying overlay dir %s', x)
> - ensure_dirs(
> - self.settings['chroot_path'] + self.settings['local_overlay'])
> - cmd("cp -a " + x + "/* " + self.settings["chroot_path"] +
> - self.settings["local_overlay"],
> - env=self.env)
> + name = get_repo_name(x)
> +
> + location = self.get_overlay_location(name)
> + config = configparser.ConfigParser()
> + config[name] = {'location': location}
> + self.write_repo_conf(name, config)
> +
> + chroot_location = normpath(
> + self.settings['chroot_path'] + location)
> + log.info('Copying overlay dir %s to %s',
> + x, chroot_location)
> + ensure_dirs(chroot_location)
> + cmd('cp -a ' + x + '/* ' + chroot_location, env=self.env)
> + else:
> + log.warning('Skipping missing overlay %s.', x)
>
> def root_overlay(self):
> """ Copy over the root_overlay """
> @@ -1080,12 +1113,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
> varname = x.split('_')[1].upper()
> myf.write(f'{varname}="{self.settings[x]}"\n')
>
> - 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'
> @@ -1157,11 +1184,18 @@ class StageBase(TargetBase, ClearBase, GenBase):
> log.warning("You've been hacking. Clearing target patches: %s", target)
> clear_path(target)
>
> - # Remove our overlay
> - overlay = normpath(
> - self.settings["chroot_path"] + self.settings["local_overlay"])
> - if os.path.exists(overlay):
> - clear_path(overlay)
> + # Remove our overlays
> + if "portage_overlay" in self.settings:
> + for repo_path in self.settings["portage_overlay"]:
> + repo_name = get_repo_name(repo_path)
> +
> + repo_conf = self.get_repo_conf_path(repo_name)
> + chroot_repo_conf = self.settings["chroot_path"] + repo_conf
> + clear_path(chroot_repo_conf)
> +
> + location = self.get_overlay_location(repo_name)
> + chroot_location = self.settings['chroot_path'] + location
> + clear_path(chroot_location)
>
> if "sticky-config" not in self.settings["options"]:
> # re-write the make.conf to be sure it is clean
> diff --git a/catalyst/defaults.py b/catalyst/defaults.py
> index c153fcc4..9660a7f3 100644
> --- a/catalyst/defaults.py
> +++ b/catalyst/defaults.py
> @@ -38,6 +38,7 @@ confdefaults = {
> "local_overlay": "/var/db/repos/local",
> "port_conf": "/etc/portage",
> "make_conf": "%(port_conf)s/make.conf",
> + "repos_conf": "%(port_conf)s/repos.conf",
> "options": set(),
> "pkgdir": "/var/cache/binpkgs",
> "port_tmpdir": "/var/tmp/portage",
> diff --git a/catalyst/support.py b/catalyst/support.py
> index a6a6854a..b8069c7d 100644
> --- a/catalyst/support.py
> +++ b/catalyst/support.py
> @@ -7,6 +7,8 @@ import shutil
> import time
> from subprocess import Popen
>
> +from portage.repository.config import RepoConfig
> +
> from catalyst import log
>
> BASH_BINARY = "/bin/bash"
> @@ -179,6 +181,22 @@ def read_makeconf(mymakeconffile):
> return makeconf
>
>
> +def get_repo_name(repo_path):
> + """ Get the name of the repo at the given repo_path.
> +
> + References:
> + https://wiki.gentoo.org/wiki/Repository_format/profiles/repo_name
> + https://wiki.gentoo.org/wiki/Repository_format/metadata/layout.conf#repo-name
> + """
> +
> + repo_config = RepoConfig(None, {"location": repo_path})
> +
> + if repo_config.missing_repo_name:
> + raise CatalystError("Missing name in repository {}".format(repo_path))
I'd prefer to use f-strings unless there's a good reason not to.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-catalyst] Re: [PATCH 2/2] Move from PORTDIR_OVERLAY to repos.conf
2020-10-30 16:07 ` Matt Turner
@ 2020-10-31 21:24 ` Brian Dolbec
2020-10-31 22:28 ` Matt Turner
2020-11-10 1:03 ` [Newsletter] " Felix Bier
1 sibling, 1 reply; 9+ messages in thread
From: Brian Dolbec @ 2020-10-31 21:24 UTC (permalink / raw
To: gentoo-catalyst
On Fri, 30 Oct 2020 12:07:56 -0400
Matt Turner <mattst88@gentoo.org> wrote:
> On Sun, Oct 18, 2020 at 11:15 AM Felix Bier
> <Felix.Bier@rohde-schwarz.com> wrote:
> >
> > This commit fixes the following issues:
> >
> > * The PORTDIR_OVERLAY variable has been deprecated by Gentoo.
> >
> > With this commit, the variable is no longer written to the
> > generated make.conf. Instead, a config file
> > /etc/portage/repos.conf/<repo-name>.conf
> > is generated for each overlay. The repo name is read from the
> > overlay using the portage API. Internally, portage parses
> > metadata/layout.conf and profiles/repo_name to obtain the name.
> >
> > References:
> > https://wiki.gentoo.org/wiki//etc/portage/make.conf
> > https://wiki.gentoo.org/wiki//etc/portage/repos.conf
> >
> > * All overlays were copied into the same target directory. If the
> > same file name occurred in multiple overlays, the last overlay
> > would overwrite all previous files with this name. In
> > particular, only the metadata/layout.conf of the last overlay was
> > retained, so it was not possible to reference the other overlays
> > e.g. via the masters entry in the layout.conf or the portage-2
> > syntax for specifying a parent profile from another overlay. Also,
> > this created problems when the overlays contained ebuilds
> > for the same package, but with differing versions, because
> > after copying, the target directory contained both versions of
> > the ebuild but only the manifest file of the last overlay.
> >
> > With this commit, each overlay is copied into a separate
> > sub-directory, e.g. /var/gentoo/repos/local/<repo-name>/.
>
> I see this /var/gentoo/repos path used as an example in a few places
> but not actually in any code. I think our example should match the
> default structure these days, e.g., /var/db/repos/<repo-name>.
>
> > This directory is referenced via the location entry in the
> > generated /etc/portage/repos.conf/<repo-name>.conf.
> > ---
> > catalyst/base/stagebase.py | 72
> > ++++++++++++++++++++++++++++---------- catalyst/defaults.py |
> > +
> > + def get_overlay_location(self, repo_name):
> > + """ Construct overlay repo path:
> > /var/gentoo/repos/local/{name} """
> > + return
> > normpath(os.path.join(self.settings['local_overlay'], repo_name)) +
> > + def write_repo_conf(self, repo_name, config):
> > + """ Write ConfigParser to
> > {chroot}/etc/portage/repo.conf/{name}.conf """
> > + repo_conf = self.get_repo_conf_path(repo_name)
> > + chroot_repo_conf = self.settings['chroot_path'] + repo_conf
> > + log.info('Creating repo config %s.', chroot_repo_conf)
> > + ensure_dirs(os.path.dirname(chroot_repo_conf))
>
> Same thing: I'd rather use pathlib and use Path.mkdir and not add new
> uses of ensure_dirs.
>
> > +
> > + try:
> > + with open(chroot_repo_conf, 'w') as myf:
>
> Let's rename myf. The 'my' prefix pattern in catalyst is not a good
> one. Even just 'f' or 'file' would be better, IMO.
>
file is a python reserved word, use _file or some other variant to not
re-assign the python file definition.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Newsletter] Re: [gentoo-catalyst] Re: [PATCH 2/2] Move from PORTDIR_OVERLAY to repos.conf
2020-10-30 16:07 ` Matt Turner
2020-10-31 21:24 ` Brian Dolbec
@ 2020-11-10 1:03 ` Felix Bier
1 sibling, 0 replies; 9+ messages in thread
From: Felix Bier @ 2020-11-10 1:03 UTC (permalink / raw
To: gentoo-catalyst@lists.gentoo.org
This commit fixes the following issues:
* The PORTDIR_OVERLAY variable has been deprecated by Gentoo.
With this commit, the variable is no longer written to the
generated make.conf. Instead, a config file
/etc/portage/repos.conf/<repo-name>.conf
is generated for each overlay. The repo name is read from the
overlay using the portage API. Internally, portage parses
metadata/layout.conf and profiles/repo_name to obtain the name.
References:
https://wiki.gentoo.org/wiki//etc/portage/make.conf
https://wiki.gentoo.org/wiki//etc/portage/repos.conf
* All overlays were copied into the same target directory. If the
same file name occurred in multiple overlays, the last overlay
would overwrite all previous files with this name. In particular,
only the metadata/layout.conf of the last overlay was retained,
so it was not possible to reference the other overlays e.g. via
the masters entry in the layout.conf or the portage-2 syntax
for specifying a parent profile from another overlay. Also,
this created problems when the overlays contained ebuilds
for the same package, but with differing versions, because
after copying, the target directory contained both versions of the
ebuild but only the manifest file of the last overlay.
With this commit, each overlay is copied into a separate
sub-directory, e.g. /var/db/repos/<repo-name>.
This directory is referenced via the location entry in the
generated /etc/portage/repos.conf/<repo-name>.conf.
Signed-off-by: Felix Bier <felix.bier@rohde-schwarz.com>
---
catalyst/base/stagebase.py | 84 ++++++++++++++++++++++++++++----------
catalyst/defaults.py | 2 +-
catalyst/support.py | 18 ++++++++
3 files changed, 81 insertions(+), 23 deletions(-)
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
index 21cf96a0..fe79b55a 100644
--- a/catalyst/base/stagebase.py
+++ b/catalyst/base/stagebase.py
@@ -1,4 +1,5 @@
+import configparser
import copy
import os
import platform
@@ -19,8 +20,8 @@ from catalyst import log
from catalyst.context import namespace
from catalyst.defaults import (confdefaults, MOUNT_DEFAULTS, PORT_LOGDIR_CLEAN)
from catalyst.support import (CatalystError, file_locate, normpath,
- cmd, read_makeconf, ismount, file_check,
- sanitize_name)
+ cmd, read_makeconf, get_repo_name, ismount,
+ file_check, sanitize_name)
from catalyst.base.targetbase import TargetBase
from catalyst.base.clearbase import ClearBase
from catalyst.base.genbase import GenBase
@@ -786,17 +787,55 @@ class StageBase(TargetBase, ClearBase, GenBase):
env=self.env)
self.resume.enable("setup_confdir")
+ def to_chroot(self, path):
+ """ Prepend chroot path to the given path. """
+
+ chroot = Path(self.settings['chroot_path'])
+ return chroot / path.relative_to(path.anchor)
+
+ def get_repo_conf_path(self, repo_name):
+ """ Construct repo conf path: {repos_conf}/{name}.conf """
+ return Path(self.settings['repos_conf'], repo_name + ".conf")
+
+ def get_repo_location(self, repo_name):
+ """ Construct overlay repo path: {repo_basedir}/{name} """
+ return Path(self.settings['repo_basedir'], repo_name)
+
+ def write_repo_conf(self, repo_name, config):
+ """ Write ConfigParser to {chroot}/{repos_conf}/{name}.conf """
+
+ repo_conf = self.get_repo_conf_path(repo_name)
+
+ repo_conf_chroot = self.to_chroot(repo_conf)
+ repo_conf_chroot.parent.mkdir(mode=0o755, parents=True, exist_ok=True)
+
+ log.info(f'Creating repo config {repo_conf_chroot}.')
+
+ try:
+ with open(repo_conf_chroot, 'w') as f:
+ config.write(f)
+ except OSError as e:
+ raise CatalystError(f'Could not write {repo_conf_chroot}: {e}') from e
+
def portage_overlay(self):
- """ We copy the contents of our overlays to /usr/local/portage """
+ """ We copy the contents of our repos to get_repo_location(repo_name) """
if "portage_overlay" in self.settings:
for x in self.settings["portage_overlay"]:
if os.path.exists(x):
- log.info('Copying overlay dir %s', x)
- ensure_dirs(
- self.settings['chroot_path'] + self.settings['local_overlay'])
- cmd("cp -a " + x + "/* " + self.settings["chroot_path"] +
- self.settings["local_overlay"],
- env=self.env)
+ name = get_repo_name(x)
+
+ location = self.get_repo_location(name)
+ config = configparser.ConfigParser()
+ config[name] = {'location': location}
+ self.write_repo_conf(name, config)
+
+ location_chroot = self.to_chroot(location)
+ location_chroot.mkdir(mode=0o755, parents=True, exist_ok=True)
+
+ log.info(f'Copying overlay dir {x} to {location_chroot}')
+ cmd(f'cp -a {x}/* {location_chroot}', env=self.env)
+ else:
+ log.warning(f'Skipping missing overlay {x}.')
def root_overlay(self):
""" Copy over the root_overlay """
@@ -852,8 +891,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
cxt = libmount.Context(source=source, target=target,
fstype=fstype, options=options)
cxt.mount()
- except OSError as e:
- raise CatalystError(f"Couldn't mount: {source}, {e.strerror}")
+ except Exception as e:
+ raise CatalystError(f"Couldn't mount: {source}, {e}")
def chroot_setup(self):
self.makeconf = read_makeconf(normpath(self.settings["chroot_path"] +
@@ -1018,12 +1057,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
varname = x.split('_')[1].upper()
myf.write(f'{varname}="{self.settings[x]}"\n')
- 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'
@@ -1097,11 +1130,18 @@ class StageBase(TargetBase, ClearBase, GenBase):
log.warning("You've been hacking. Clearing target patches: %s", target)
clear_path(target)
- # Remove our overlay
- overlay = normpath(
- self.settings["chroot_path"] + self.settings["local_overlay"])
- if os.path.exists(overlay):
- clear_path(overlay)
+ # Remove our overlays
+ if "portage_overlay" in self.settings:
+ for repo_path in self.settings["portage_overlay"]:
+ repo_name = get_repo_name(repo_path)
+
+ repo_conf = self.get_repo_conf_path(repo_name)
+ chroot_repo_conf = self.to_chroot(repo_conf)
+ chroot_repo_conf.unlink()
+
+ location = self.get_repo_location(repo_name)
+ chroot_location = self.to_chroot(location)
+ clear_path(str(chroot_location))
if "sticky-config" not in self.settings["options"]:
# re-write the make.conf to be sure it is clean
diff --git a/catalyst/defaults.py b/catalyst/defaults.py
index 0f399b56..3f12b8d5 100644
--- a/catalyst/defaults.py
+++ b/catalyst/defaults.py
@@ -38,9 +38,9 @@ confdefaults = {
"distdir": portage.settings['DISTDIR'],
"icecream": "/var/cache/icecream",
'list_xattrs_opt': LIST_XATTRS_OPTIONS['linux'],
- "local_overlay": "/var/db/repos/local",
"port_conf": "/etc/portage",
"make_conf": "%(port_conf)s/make.conf",
+ "repos_conf": "%(port_conf)s/repos.conf",
"options": set(),
"pkgdir": "/var/cache/binpkgs",
"port_tmpdir": "/var/tmp/portage",
diff --git a/catalyst/support.py b/catalyst/support.py
index ddbd9ab9..f3a865a7 100644
--- a/catalyst/support.py
+++ b/catalyst/support.py
@@ -10,6 +10,8 @@ from subprocess import Popen
import libmount
+from portage.repository.config import RepoConfig
+
from catalyst import log
BASH_BINARY = "/bin/bash"
@@ -182,6 +184,22 @@ def read_makeconf(mymakeconffile):
return makeconf
+def get_repo_name(repo_path):
+ """ Get the name of the repo at the given repo_path.
+
+ References:
+ https://wiki.gentoo.org/wiki/Repository_format/profiles/repo_name
+ https://wiki.gentoo.org/wiki/Repository_format/metadata/layout.conf#repo-name
+ """
+
+ repo_config = RepoConfig(None, {"location": repo_path})
+
+ if repo_config.missing_repo_name:
+ raise CatalystError(f"Missing name in repository {repo_path}")
+
+ return repo_config.name
+
+
def ismount(path):
"""Like os.path.ismount, but also support bind mounts"""
path = Path(path)
--
2.29.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-11-10 1:03 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-17 19:00 [gentoo-catalyst] [PATCH 2/2] Move from PORTDIR_OVERLAY to repos.conf Felix Bier
2020-10-17 20:11 ` Matt Turner
2020-10-18 13:58 ` [Newsletter] " Felix Bier
2020-10-30 16:13 ` Matt Turner
2020-10-18 15:15 ` [gentoo-catalyst] " Felix Bier
2020-10-30 16:07 ` Matt Turner
2020-10-31 21:24 ` Brian Dolbec
2020-10-31 22:28 ` Matt Turner
2020-11-10 1:03 ` [Newsletter] " Felix Bier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox