Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 818904 - savedconfig.eclass - config files collide when used in a multi-slotted package (sys-kernel/gentoo-kernel file collision on /etc/portage/savedconfig/sys-kernel/gentoo-kernel)
Summary: savedconfig.eclass - config files collide when used in a multi-slotted packag...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-19 11:27 UTC by Michael Moon
Modified: 2021-11-05 19:17 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge-info.txt,9.06 KB, text/plain)
2021-10-19 11:27 UTC, Michael Moon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Moon 2021-10-19 11:27:16 UTC
Created attachment 745773 [details]
emerge --info

Hmm, why is it colliding with itself?

Something to do with slots?

It's been working fine for ages (since 5.10 at least), not sure why this suddenly popped up today - someone changed something in an eclass perhaps?

l -rt /var/db/repos/gentoo/eclass says linux-info.eclass changed in my latest sync fwiw.
(also ruby-fakegem and qt5-build eclasses are last modified today but I doubt those are relevant to gentoo-kernel)

* Messages for package sys-kernel/gentoo-kernel-5.14.13:

* User patches applied.
* User patches applied.
* Building using saved configfile "/etc/portage/savedconfig/sys-kernel/gentoo-kernel"
* Your configuration for sys-kernel/gentoo-kernel-5.14.13 has been saved in
* "/etc/portage/savedconfig/sys-kernel/gentoo-kernel" for your editing pleasure.
* You can edit these files by hand and remerge this package with
* USE=savedconfig to customise the configuration.
* You can rename this file/directory to one of the following for
* its configuration to apply to multiple versions:
* ${PORTAGE_CONFIGROOT}/etc/portage/savedconfig/
* [${CTARGET}|${CHOST}|""]/${CATEGORY}/[${PF}|${P}|${PN}]
* This package will overwrite one or more files that may belong to other
* packages (see list below). You can use a command such as `portageq
* owners / <filename>` to identify the installed package that owns a
* file. If portageq reports that only one package owns a file then do
* NOT file a bug report. A bug report is only useful if it identifies at
* least two or more packages that are known to install the same file(s).
* If a collision occurs and you can not explain where the file came from
* then you should simply ignore the collision since there is not enough
* information to determine if a real problem exists. Please do NOT file
* a bug report at https://bugs.gentoo.org/ unless you report exactly
* which two packages install the same file(s). See
* https://wiki.gentoo.org/wiki/Knowledge_Base:Blockers for tips on how
* to solve the problem. And once again, please do NOT file a bug report
* unless you have completely understood the above message.
*
* Detected file collision(s):
*
*      /etc/portage/savedconfig/sys-kernel/gentoo-kernel
*
* Searching all installed packages for file collisions...
*
* Press Ctrl-C to Stop
*
* sys-kernel/gentoo-kernel-5.14.11:5.14.11::gentoo
*      /etc/portage/savedconfig/sys-kernel/gentoo-kernel
*
* sys-kernel/gentoo-kernel-5.14.12:5.14.12::gentoo
*      /etc/portage/savedconfig/sys-kernel/gentoo-kernel
*
* Package 'sys-kernel/gentoo-kernel-5.14.13' NOT merged due to file
* collisions. If necessary, refer to your elog messages for the whole
* content of the above message.

* Messages for package virtual/dist-kernel-5.14.13:

* emerge --keep-going: virtual/dist-kernel-5.14.13 dropped because it
* requires ~sys-kernel/gentoo-kernel-5.14.13
*
* The following 2 packages have failed to build, install, or execute
* postinst:
*
*  (sys-kernel/gentoo-kernel-5.14.13:5.14.13/5.14.13::gentoo, ebuild scheduled for merge), Log file:
*   '/var/tmp/portage/sys-kernel/gentoo-kernel-5.14.13/temp/build.log'
*  (virtual/dist-kernel-5.14.13:0/5.14.13::gentoo, ebuild scheduled for merge)
*
Comment 1 Mike Gilbert gentoo-dev 2021-10-20 00:47:40 UTC
Yeah, I don't think savedconfig really works with slots when you don't include ${PV} in the config file name.
Comment 2 Michael Moon 2021-10-28 11:35:13 UTC
Just ran into this again, except first it somehow lost my config completely and I had to re-fetch it from /proc/config.gz, then barfed when I tried to rebuild using my saved config.

If I call the file gentoo-kernel-$PV, won't I have to manually rename it for every kernel version?
Comment 3 Georgy Yakovlev archtester gentoo-dev 2021-10-30 02:16:53 UTC
I do the following, maybe it will help you

I have per-version configs that are installed as

/etc/portage/savedconfig/sys-kernel/gentoo-kernel-5.10.x ( that's literal character x here )

and I simply create a symlink to that file

gentoo-kernel-5.10.x or similar will never get overwritten.
savedconfig will apply config from file symlink points to.


when new kernel arrives, I create new gentoo-kernel-5.14.x for example, and update symlink.

You can still loose symlink if you toggle savedconfig flag itself though.
Comment 4 Georgy Yakovlev archtester gentoo-dev 2021-10-30 02:19:46 UTC
an example listing:

gentoo-kernel -> gentoo-kernel-5.10.x
gentoo-kernel-5.10.x
gentoo-kernel-5.8.x
gentoo-kernel-5.9.x
linux-firmware-20210629
Comment 5 Georgy Yakovlev archtester gentoo-dev 2021-10-30 02:22:05 UTC
also you probably can use config.d instead of savedconfig

https://wiki.gentoo.org/wiki/Project:Distribution_Kernel#Using_.2Fetc.2Fkernel.2Fconfig.d

that way you can toggle individual options but leave base config to us.
ofc it does not work for everyone, but maybe it'll be enough for you.
Comment 6 Michael Moon 2021-10-31 16:49:23 UTC
The config.d approach sounds interesting, I might give that a try.

Got any convenient bash magic to tease out the necessary entries from my current config?
Comment 7 Mike Gilbert gentoo-dev 2021-10-31 19:03:14 UTC
(In reply to Michael Moon from comment #6)
> Got any convenient bash magic to tease out the necessary entries from my
> current config?

Given the original config file and your modified config file, you could generate an appropriate merge file using the "diffconfig" script from the kernel sources.

> scripts/diffconfig -m oldconfig newconfig > merge.config
Comment 8 Mike Gilbert gentoo-dev 2021-10-31 19:25:40 UTC
Patch sent for review.

https://archives.gentoo.org/gentoo-dev/message/b4c2e48ea7c666282f51802b7ec131fd
Comment 9 Michael Moon 2021-11-01 04:56:57 UTC
Thanks for the tip about diffconfig, I'll check that out.

If you revert the fix for bug 686348, is there a plan to reimplement that in a way that doesn't cause this issue (818904)? 686348 does seem to raise a valid point.
Comment 10 Mike Gilbert gentoo-dev 2021-11-01 05:32:24 UTC
(In reply to Michael Moon from comment #9)
> If you revert the fix for bug 686348, is there a plan to reimplement that in
> a way that doesn't cause this issue (818904)? 686348 does seem to raise a
> valid point.

I have no plan to re-implement it. In my view, it's not really a "problem" that needs solving.
Comment 11 Arfrever Frehtes Taifersar Arahesis 2021-11-04 05:58:35 UTC
In some simplification, configuration filenames patterns supported by savedconfig.eclass are:

/etc/portage/savedconfig/${CATEGORY}/${PF}
/etc/portage/savedconfig/${CATEGORY}/${P}
/etc/portage/savedconfig/${CATEGORY}/${PN}

After first building of given package, 
/etc/portage/savedconfig/${CATEGORY}/${PF} would be installed.

During next buildings, all patterns would be checked, in order, and first found one is read and later saved.

Switching from .../${CATEGORY}/${PF} to another pattern requires explicit renaming by user.
Until possible future extension of savedconfig.eclass to support multi-slotted packages, I would argue that it is user's mistake to switch to .../${CATEGORY}/${PN} pattern.


I would recommend to not revert that minor feature, which works well in single-slotted packages, and to think about possibly improving savedconfig.eclass.


Some possibility is to extend filenames of newly saved configuration files with a separator character and e.g. build date.
Example:
/etc/portage/savedconfig/${CATEGORY}/${PN}@$(date "+%Y%m%d%H%M%S")

restore_config() function would use file with highest number after "@".
Comment 12 Michael Moon 2021-11-04 06:04:06 UTC
The issue with using anything other than $PN is that the saved config doesn't get applied to new versions of the package - I tried renaming /etc/portage/savedconfig/gentoo-kernel to …-5.14.15 but the config didn't get used for 5.14.16 which left me with an unbootable system.

I also tried config.d but it seems like a ton of options that I put there were subsequently overwritten by I assume the ebuild or eclass config construction process
Comment 13 Mike Gilbert gentoo-dev 2021-11-04 15:52:35 UTC
(In reply to Arfrever Frehtes Taifersar Arahesis from comment #11)

With my patch to revert your change, I see savedconfig working like this:

1. User installs package intially.
2. User renames savedconfig/.../${PF} to ${PN}.
3. Initial builds of new slots use ${PN} when restoring the config, and save the resulting config in ${PF}.
4. Rebuilds use ${PF}, unless the user takes action to remove that file between rebuilds.

Behavior 3 will result in several copies of a similar config file existing. Not a big deal.

Behavior 4 is possibly undesired but I think this will suffice until someone actually submits a better patch that does not introduce file collisions.
Comment 14 Michael Moon 2021-11-04 16:16:59 UTC
What happens if the package doesn't own the savedconfig, ie it's copied during postinst or something?
Comment 15 Mike Gilbert gentoo-dev 2021-11-04 18:47:27 UTC
(In reply to Michael Moon from comment #14)
> What happens if the package doesn't own the savedconfig, ie it's copied
> during postinst or something?

Two problems:

1. That would bypass CONFIG_PROTECT.
2. It would leave behind orphaned files when the package is unmerged.
Comment 16 Larry the Git Cow gentoo-dev 2021-11-05 19:17:16 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=eb71dfec11e09ae40ae90f27305948097b6591a2

commit eb71dfec11e09ae40ae90f27305948097b6591a2
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2021-10-31 19:16:06 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2021-11-05 19:17:13 +0000

    savedconfig.eclass: do not re-use config file scheme
    
    This causes file collisions when save_config is used in a multi-slotted
    package and the config file is named ${PN}.
    
    Reverts: a0c35ad8ee8f8f89ba6044dd5b44e9479c6a1775
    Bug: https://bugs.gentoo.org/686348
    Closes: https://bugs.gentoo.org/818904
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 eclass/savedconfig.eclass | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)