pkgcore icon indicating copy to clipboard operation
pkgcore copied to clipboard

pkgcheck: error: invalid symlink: '/etc/portage/make.profile'

Open xmhd opened this issue 4 years ago • 2 comments

tldr; pkgcheck currently only supports make.profile as a symlink to the relevant profile, while Portage supports make.profile as a directory with a 'parent file' (i.e. /etc/portage/make.profile/parent) pointing to the relevant profile within $PORTDIR/profiles (i.e. /var/db/repos/gentoo/profiles/default/linux/amd64/17.1/hardened)

This is handled in Portage via:

if make.profile is symlink .... do else if make.profile is not symlink and is directory ... read file 'parent' and process all entries

As far as I can tell, pkgcore is handling this logic in the following file https://github.com/pkgcore/pkgcore/blob/master/src/pkgcore/ebuild/portage_conf.py

I am happy to help implement this and keep pkgcore 1:1 with Portage in this regard.

xmhd avatar Apr 26 '21 20:04 xmhd

I am happy to help implement this and keep pkgcore 1:1 with Portage in this regard.

Feel free to open a PR.

radhermit avatar May 19 '21 05:05 radhermit

I tried to workaround this issue by specifying -p <profile> but got the same error. I have also tried to specify the "location" parameter but it doesn't seem accepted by pkgcheck.

blshkv avatar Aug 05 '22 00:08 blshkv

@xmhd if you can provide a bit more of a repro, that would be appreciated. My read of your original report is that of /etc/make.conf/profile as a UserProfile- a configuration I personaly use- but it would save debugging if I knew exactly what your failure scenario was.

ferringb avatar Dec 26 '22 05:12 ferringb

@ferringb

By default in Gentoo /etc/portage/make.profile is a symlink to an entry in the profiles directory of ::gentoo. However Portage supports having make.profile be a directory rather than a symlink, with a 'parent' file containing filepaths of valid profiles i.e. /var/db/repos/gentoo/profiles/default/linux/amd64/17.1/hardened.

When using RepoMan, this works fine. However when you start using pkgcheck it does not work as pkgcheck only accepts make.profile being a symlink.

So .... if you remove your /etc/portage/make.profile symlink and replace it with a directory, add a file named 'parent' and then add a filepath for a profile of your choosing .... run pkgcheck and it will exit out due to an 'invalid symlink'.

tldr; /etc/portage/make.profile must be a symlink when using pkgcheck, whereas Portage has support for /etc/portage/make.profile being a directory

xmhd avatar Dec 26 '22 14:12 xmhd

Could you (those using make.profile as dir and not symlink) test if fixed by https://github.com/pkgcore/pkgcore/pull/390 applied to pkgcore?

arthurzam avatar Jan 02 '23 20:01 arthurzam

@arthurzam

EDIT: disregard, working. cheers

FYI I don't agree with /etc/portage/profile taking precedence because of /etc/portage/make.profile being a directory. The original support for make.profile being a directory was so that /etc/portage/make/profile/parent can have multiple entries to have multiple profiles enabled at once .... e.g. Funtoo has utilised this since 2015.

xmhd avatar Jan 03 '23 01:01 xmhd

Did you apply the patch in the PR or not?

thesamesam avatar Jan 03 '23 01:01 thesamesam

Did you apply the patch in the PR or not?

:-) disregard my previous, I have had one too many coca colas and thought that PR had been merged. Tested now and working.

xmhd avatar Jan 03 '23 01:01 xmhd

the patch doesn't work for me:

pkgcheck scan 
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/pkgcore/ebuild/profiles.py", line 279, in parents
    parents.append(kls(path))
  File "/usr/lib/python3.10/site-packages/snakeoil/caching.py", line 114, in __call__
    instance = super(WeakInstMeta, cls).__call__(*a, **kw)
  File "/usr/lib/python3.10/site-packages/pkgcore/ebuild/profiles.py", line 172, in __init__
    raise NonexistentProfile(self.path)
pkgcore.ebuild.profiles.NonexistentProfile: failed parsing '/etc/portage/make.profile/gentoo:default/linux/amd64/17.1/hardened': nonexistent profile directory

PoC: /etc/portage/make.profile/parent

gentoo:default/linux/amd64/17.1/hardened
gentoo:targets/desktop/plasma
pentoo:pentoo/overlay

blshkv avatar Jan 03 '23 08:01 blshkv

the patch doesn't work for me:

pkgcheck scan 
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/pkgcore/ebuild/profiles.py", line 279, in parents
    parents.append(kls(path))
  File "/usr/lib/python3.10/site-packages/snakeoil/caching.py", line 114, in __call__
    instance = super(WeakInstMeta, cls).__call__(*a, **kw)
  File "/usr/lib/python3.10/site-packages/pkgcore/ebuild/profiles.py", line 172, in __init__
    raise NonexistentProfile(self.path)
pkgcore.ebuild.profiles.NonexistentProfile: failed parsing '/etc/portage/make.profile/gentoo:default/linux/amd64/17.1/hardened': nonexistent profile directory

PoC: /etc/portage/make.profile/parent

gentoo:default/linux/amd64/17.1/hardened
gentoo:targets/desktop/plasma
pentoo:pentoo/overlay

I've tried with:

gentoo:default/linux/amd64/17.0/musl

And I can confirm the same result as @blshkv. Portage does support this FYI.

However it works with the full file path:

/var/db/repos/gentoo/profiles/default/linux/amd64/17.0/musl

xmhd avatar Jan 03 '23 10:01 xmhd

@blshkv @xmhd OK, I see this as separate problem, as parent of format [repo id]:[relative path] are unsupported by pkgcore - and I will open an issue in pkgcore for adding support for this.

arthurzam avatar Jan 03 '23 18:01 arthurzam

@blshkv @xmhd OK, I see this as separate problem, as parent of format [repo id]:[relative path] are unsupported by pkgcore - and I will open an issue in pkgcore for adding support for this.

FYI, please know that this format isn't described by PMS, so technically this is a portage extension undocumented anywhere officially.

arthurzam avatar Jan 03 '23 18:01 arthurzam