Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 396169 - savedconfig.eclass - re-building and then upgrading deletes previous configuration
Summary: savedconfig.eclass - re-building and then upgrading deletes previous configur...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-27 05:29 UTC by thomas
Modified: 2023-06-21 10:52 UTC (History)
2 users (show)

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


Attachments
emerge --info --verbose output (emerge.log,12.72 KB, text/plain)
2012-01-02 04:41 UTC, thomas
Details
emerged dropbear, edited config, updated (dropbearEmerge.log,232.45 KB, text/plain)
2012-01-03 16:56 UTC, thomas
Details
Emerge log of steps that remove dwm savedconfig (dwm.log,13.07 KB, text/plain)
2012-01-03 20:53 UTC, thomas
Details
Emerge deletes savedconfig after re-emerge of program followed by update (emerge.log,23.04 KB, text/plain)
2012-01-03 22:20 UTC, thomas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description thomas 2011-12-27 05:29:51 UTC
When a version specific savedconfig exists and you update x11-wm/dwm with USE=savedconfig, the ebuild deletes the old version then reports that no config exists, much to the ire of the user who poured time into customizing the file that emerge deleted. The ebuild should not delete savedconfig.

Reproducible: Always

Steps to Reproduce:
1.Have a version specific savedconfig for x11-wm/dwm and USE=savedconfig
2.Update dwm with emerge
3.Emerge deletes savedconfig with no warning or input
Actual Results:  
Lose savedconfig.

Expected Results:  
Not touched savedconfig, potentially even copied over to a savedconfig for the new version and attempted an emerge with the old config.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2011-12-27 20:29:30 UTC
It's nothing to do with x11-wm/dwm, really - the savedconfig.eclass uses $PF, maybe in error.
Comment 2 SpanKY gentoo-dev 2011-12-28 04:44:23 UTC
the eclass doesn't delete anything.  it also uses $PF by default on purpose, but i probably could be convinced to have it use $P instead.  not that that would change the behavior you speak of.
Comment 3 Zac Medico gentoo-dev 2011-12-28 05:04:29 UTC
I guess we could add a variable that's similar to CONFIG_PROTECT, that would prevent files in specific directories from being unmerged. As it is, we have behavior like this hardcoded for /lib/modules, and the default COLLISION_IGNORE="/lib/modules" setting is used to ignore file collisions that result from this behavior.

How about if we call the new variable UNINSTALL_EXCLUDE, and make it default to UNINSTALL_EXCLUDE="/lib/modules /etc/portage/savedconfig". Would you want to ignore file collisions by default in /etc/portage/savedconfig? If so, we could add it to the default COLLISION_IGNORE setting.
Comment 4 SpanKY gentoo-dev 2011-12-31 08:12:12 UTC
what we want here is to leave the files behind only if they're modified.  i.e. we want something like ORPHANS_UNINSTALL_EXCLUDE=/etc/portage/savedconfig/.

i don't think this dir should be special in terms of collision handling ... nothing would own it, so the file would get clobbered ...
Comment 5 Zac Medico gentoo-dev 2011-12-31 09:35:42 UTC
Now I'm thinking the problem is that the user has CONFIG_PROTECT_MASK="/etc/portage" set, because FEATURES=unmerge-orphans does not apply to CONFIG_PROTECTed packages that have been modified since they were installed.
Comment 6 SpanKY gentoo-dev 2011-12-31 21:14:52 UTC
thomasward: can you post `emerge --info --verbose` ?

things seem to work for me as expected:

  # emerge ~dropbear-0.53.1
  # printf '#define foo\n' >> /etc/portage/savedconfig/net-misc/dropbear-0.53.1
  # emerge ~dropbear-2011.54
  --- !mtime   obj /etc/portage/savedconfig/net-misc/dropbear-0.53.1
  < /etc/portage/savedconfig/net-misc/dropbear-0.53.1 is left behind >
Comment 7 thomas 2012-01-02 04:41:21 UTC
Created attachment 297607 [details]
emerge --info --verbose output

Here's my emerge --info --verbose
Comment 8 SpanKY gentoo-dev 2012-01-02 08:08:08 UTC
and try running my example series of dropbear commands and post the output as an attachment that you see ?
Comment 9 thomas 2012-01-03 16:56:01 UTC
Created attachment 297809 [details]
emerged dropbear, edited config, updated

So updating dropbear did not obliterate the previous savedconfig. it does still occur for x11-wm/dwm, and I am not the only person experiencing this behavior:
http://forums.gentoo.org/viewtopic-t-704481-highlight-dwm+savedconfig.html
Comment 10 SpanKY gentoo-dev 2012-01-03 20:03:38 UTC
then show the log of dwm.  it doesn't do it for me there either:

 # emerge -v '<dwm-6'
 # printf '#define foo\n' >> /etc/portage/savedconfig/x11-wm/dwm-5.9
 # emerge -v dwm
 < /etc/portage/savedconfig/x11-wm/dwm-5.9 still exists >
Comment 11 thomas 2012-01-03 20:53:27 UTC
Created attachment 297841 [details]
Emerge log of steps that remove dwm savedconfig

I can reproduce this bug every single time. Here are the steps:

1) have a dwm-5.9 in portage's savedconfig
2) have USE=savedconfig
3) install x11-wm/dwm-5.9: emerge ~dwm-5.9
4) Update dwm (will update to dwm-6.0 at the moment: emerge -u dwm

This leaves the user with a default savedconfig for dwm-6.0 and a deleted savedconfig for dwm-5.9 without any user input.
Comment 12 SpanKY gentoo-dev 2012-01-03 21:46:22 UTC
Comment on attachment 297841 [details]
Emerge log of steps that remove dwm savedconfig

if you don't edit the savedconfig, then it *should* get removed automatically.  it only stays behind if you modify it.

thus your log (which shows you did not edit the 5.9 config file) is showing expected behavior and not a bug.
Comment 13 thomas 2012-01-03 22:20:40 UTC
Created attachment 297851 [details]
Emerge deletes savedconfig after re-emerge of program followed by update

I have finally narrowed down a reproducible test case that shows portage deletes a modified savedconfig (you can see it through the log I attached but here's the summary)

1) Un-emerge dwm and delete any savedconfig for x11-wm/dwm
2) Set USE=savedconfig in /etc/make.conf
3) emerge ~dwm-5.9
At this stage, portage generates a default savedconfig
4) Modify savedconfig (I used vim in the log)
Now since this is dwm, I must re-emerge dwm so I can have my changes actually take effect
5) emerge ~dwm-5.9
Now I have my modified dwm with a savedconfig I changed. An update hits the portage tree:
6) emerge -u dwm
Portage deletes dwm-5.9 savedconfig and puts in a generic dwm-6 savedconfig, since it thinks the one is brand new. Why? I suppose since it was unmodified since the last emerge. Portage must check to see if it is modified since the last emerge. If it's not, then it deletes it. If it is, it doesn't delete it.
Comment 14 Zac Medico gentoo-dev 2012-01-03 23:10:01 UTC
(In reply to comment #13)
> 6) emerge -u dwm
> Portage deletes dwm-5.9 savedconfig and puts in a generic dwm-6 savedconfig,
> since it thinks the one is brand new. Why? I suppose since it was unmodified
> since the last emerge. Portage must check to see if it is modified since the
> last emerge. If it's not, then it deletes it. If it is, it doesn't delete it.

In order to avoid that, savedconfig.eclass could to something like this in pkg_postinst:

   find "${ROOT}"/etc/portage/savedconfig/${CATEGORY}/${PF} | xargs touch
Comment 15 thomas 2012-01-04 01:07:29 UTC
I don't think that would delete an unchanged savedconfig which *should* happen, right? 

How about upon removing x11-wm/dwm, portage diff's the default savedconfig the ebuild installs with the savedconfig in /etc/portage/savedconfig/ ? If any change exists, then keep it, else delete it.

Sound reasonable?
Comment 16 SpanKY gentoo-dev 2012-01-04 06:02:13 UTC
this is because during the re-emerge, the modified version is integrated into the build and then considered the new baseline.  so it installs that, and the contents match that of what was installed, and the upgrade automatically drops the now-considered-unmodified version.

the eclass could save/restore/install the unmodified config, but then every rebuild would incur an etc-update.  i'd consider this sub-optimal, but maybe people would prefer that.

to avoid that, the eclass would have to add a pkg_preinst() hook to automatically migrate the user-modified version over the default config so that it both shows up as modified and doesn't incur the etc-update.

i don't think `touch` would help as it would leave behind unmodified files.  the current system is nice in that it doesn't leave behind cruft.
Comment 17 SpanKY gentoo-dev 2012-01-04 07:37:07 UTC
the pkg_{pre,post}inst hooks appear to be unavoidable.  portage will do "trivial" merges by considering things which are comments in one language (like shell scripts) as trivial even though in the actual language, these are not comments.  simple example being "#define FOO".

i'm not saying this is a failing in portage -- the whole savedconfig setup is kind of a hack.

another option might be to have save_config save the files in one location and make the user manually copy them to another.  downside obviously being that this can be a bit confusing for users trying to tweak things.
Comment 18 SpanKY gentoo-dev 2012-01-04 08:22:41 UTC
i've coded up examples for the various methods, and they all suck.  i'm just going to go with the least sucky in terms of maintenance: if you have USE=savedconfig, then the eclass will do as Zac suggested and touch all the files in pkg_postinst.  this will leave files to rot over time, but they're small enough to not worry about for now, and it'll only affect the USE=savedconfig people who are presumably editing the files anyways.
Comment 20 BT 2012-11-28 08:42:28 UTC
This issue is still present for me. I'm not sure if the commit in comment #19 was supposed to fix it or if it's intended behaviour.

I upgraded linux-firmware-20120719 to linux-firmware-20120924. The savedconfig for linux-firmware-20120719 was deleted and a new one (without my edits) was created for linux-firmware-20120924.

Is there any way to avoid this issue?
Comment 21 Zac Medico gentoo-dev 2012-11-28 10:07:54 UTC
(In reply to comment #20)
> This issue is still present for me. I'm not sure if the commit in comment
> #19 was supposed to fix it or if it's intended behaviour.

Yes, it was.

> I upgraded linux-firmware-20120719 to linux-firmware-20120924. The
> savedconfig for linux-firmware-20120719 was deleted and a new one (without
> my edits) was created for linux-firmware-20120924.
> 
> Is there any way to avoid this issue?

Check your emerge --info and make sure that CONFIG_PROTECT contains /etc, and CONFIG_PROTECT_MASK does NOT contain /etc/portage.

(In reply to comment #3)
> I guess we could add a variable that's similar to CONFIG_PROTECT, that would
> prevent files in specific directories from being unmerged. As it is, we have
> behavior like this hardcoded for /lib/modules, and the default
> COLLISION_IGNORE="/lib/modules" setting is used to ignore file collisions
> that result from this behavior.

Recent versions of portage (2.1.11*) support an UNINSTALL_IGNORE which defaults to UNINSTALL_IGNORE="/lib/modules/*". So, you can use a setting like this to protect /etc/portage/savedconfig:

  UNINSTALL_IGNORE="${UNINSTALL_IGNORE} /etc/portage/savedconfig/*"
Comment 22 BT 2012-11-28 10:57:42 UTC
(In reply to comment #21)
> Recent versions of portage (2.1.11*) support an UNINSTALL_IGNORE which
> defaults to UNINSTALL_IGNORE="/lib/modules/*". So, you can use a setting
> like this to protect /etc/portage/savedconfig:
> 
>   UNINSTALL_IGNORE="${UNINSTALL_IGNORE} /etc/portage/savedconfig/*"

I added that line to make.conf and it appears to be working. The previous savedconfig is left behind and a new one (without edits) is created. This is definitely better than the previous behaviour. Thanks for the help.
Comment 23 Jernej Jakob 2023-06-21 10:52:27 UTC
Portage still deletes the savedconfig of the unmerged version by default. It has annoyed me a couple times so far as I had to go restore the config out of a backup to transfer it to the new package version. I know I could name it without the version part but I like to keep them separate so that the old config doesn't cause a build failure if its format isn't compatible, then I can manually adapt it and re-merge.
It would be nice if the behavior described in comment #21 of UNINSTALL_IGNORE were the default.
I checked that CONFIG_PROTECT{,_MASK} are set as they should but the savedconfig is still deleted.