View previous topic :: View next topic |
Author |
Message |
leifbk Guru
Joined: 05 Jan 2004 Posts: 415 Location: Bærum, Norway
|
Posted: Fri Jun 10, 2016 4:19 pm Post subject: Should "emerge --depclean" protect sources of runn |
|
|
As I'm running my computer 24/7 for weeks on end, I'm usually not compiling every new kernel version. With my recent conversion from running stable to ~arch, this question has become even more acute. I'm always running "emerge --ask --depclean" after each world update, and mostly it's the sources of the running kernel that it wants to purge. That's rather inconvenient for packages like PostgreSQL that's looking for the sources of the currently running kernel, and complains loudly when there are none.
I haven't delved into the source of emerge, but I believe that it should be rather trivial to protect the sources of the running kernel from a depclean, eg. by running a "uname -r". I'd like to propose a feature request on bugs.gentoo.org, but want to hear the opinion of others about it first.
---
Edit, one month later: As suggested by Buffoon in the very first reply to this thread,
Code: | emerge --ask --depclean --exclude gentoo-sources |
does exactly what I need. I have been using this method for the last month.
This has been an interesting discussion, and I hope that others have found it useful as well. _________________ Grumpy old man
Last edited by leifbk on Sun Jul 10, 2016 4:59 pm; edited 1 time in total |
|
Back to top |
|
|
Buffoon Veteran
Joined: 17 Jun 2015 Posts: 1369 Location: EU or US
|
Posted: Fri Jun 10, 2016 4:31 pm Post subject: |
|
|
I run depclean with --exclude gentoo-sources, good enough solution for me. |
|
Back to top |
|
|
leifbk Guru
Joined: 05 Jan 2004 Posts: 415 Location: Bærum, Norway
|
Posted: Fri Jun 10, 2016 4:44 pm Post subject: |
|
|
Buffoon wrote: | I run depclean with --exclude gentoo-sources, good enough solution for me. |
Yes, that's of course a viable solution (and shame on me for not having read the fine manual closely enough to discover the --exclude option ). But I'd like to see the default behaviour of depclean changed, so that it would leave the newest kernel sources as well as the sources of the running kernel alone, and then purge all other kernel sources. That is the behaviour that I consider would adhere best to the old "principle of least surprise". _________________ Grumpy old man |
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Fri Jun 10, 2016 4:52 pm Post subject: |
|
|
this is a reasonable request and one that annoys me soo much. I quite often forget to upgrade my kernel (using 4.4.1 atm) and more often than not I am "forced" to perform the upgrade process because a depclean remove the kernel i am running and say... nvidia driver update. _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
Buffoon Veteran
Joined: 17 Jun 2015 Posts: 1369 Location: EU or US
|
Posted: Fri Jun 10, 2016 5:31 pm Post subject: |
|
|
As a matter of fact I run emerge @world with --exclude gentoo-sources, too. So I never have unwanted sources installed. |
|
Back to top |
|
|
alinefr Tux's lil' helper
Joined: 05 Jul 2009 Posts: 113 Location: São Paulo, Brasil
|
Posted: Fri Jun 10, 2016 6:16 pm Post subject: |
|
|
I have /etc/portage/postsync.d/keep-gentoo-sources:
Code: |
#!/bin/bash
PKGNAME=gentoo-sources
CURPV=`uname -r | cut -d '-' -f 1`
for gkversion in `equery l -F '$version' $PKGNAME`; do
if [ $CURPV == $gkversion ]; then
emerge -q --noreplace =${PKGNAME}-${gkversion}
else
emerge --deselect =${PKGNAME}-${gkversion}
fi
done
|
So every time I run emerge --sync it either adds gentoo-sources for the running kernel or removes any other gentoo-sources to/from @world set. |
|
Back to top |
|
|
cboldt Veteran
Joined: 24 Aug 2005 Posts: 1046
|
Posted: Fri Jun 10, 2016 7:54 pm Post subject: |
|
|
I had one machine that was cruising toward a 1,000 day uptime, and I wasn't going to reboot it, so I too wanted to keep at least that version of the kernel sources, while periodically building (but not booting into) later kernels.
The fix I used was to manually add a "keep this kernel" version to the world file.
In the file "/var/lib/portage/world"
Code: | sys-kernel/gentoo-sources
sys-kernel/gentoo-sources:3.7.10 |
At some point I was ready to move on, and I just removed that "versioned" line from the world file.
I see that the "emerge" command has a '--noreplace' option too, which makes the same sort of entry in the "world" file. |
|
Back to top |
|
|
Josef.95 Advocate
Joined: 03 Sep 2007 Posts: 4558 Location: Germany
|
Posted: Fri Jun 10, 2016 11:34 pm Post subject: |
|
|
Hm, I think it's good as is it.
We can exactly set the desired sources version in /etc/portage/package.{accept_keywords,mask,unmask}
and add the preferred sources slot in the world file, so that a "emerge -av --depclean" not remove desired source slots.
(sorry for my bad english) |
|
Back to top |
|
|
krinn Watchman
Joined: 02 May 2003 Posts: 7470
|
Posted: Sat Jun 11, 2016 10:12 am Post subject: |
|
|
leifbk wrote: | But I'd like to see the default behaviour of depclean changed, so that it would leave the newest kernel sources as well as the sources of the running kernel alone, and then purge all other kernel sources. That is the behaviour that I consider would adhere best to the old "principle of least surprise". |
So you assume someone only use latest or running kernel sources, alas, if you keep some backup kernel, it would exactly be one that doesn't fit your list: it should be previous one (you are now using lastest one), and it will not be running one.
With your logic, portage is aiming at removing a "useful" kernel, and your suggest is, make portage again removing a "useful" kernel.
Again if we follow your logic: portage has pull a new version that you don't need, but portage will protect "latest", but latest is not useful for you, the one useful is now "previous", hence protecting "latest" will lead to your useful kernel sources unprotected.
Portage have no real way to predict a user mind, it has no way to tag any kernel sources as useful, while user can hint portage thru package.provide or world by adding needed version in it.
There's only one case where portage could predict a usage of a kernel, the running one, but having portage providing such protection to that kernel only, will lead user to care even less about kernel sources, and while danger is still there, portage is hiding it, i'm unsure if it will really help user to teach him to not care about his kernel sources ; with that "mentality" in mind (user know portage take care of his kernel), such user running depclean from a livecd will suffer pain as it will easy forget the protection is not active anymore.
I'm against such protection myself, because when they add some kind of protection, they generally never add any kind of way to disable it.
While users have over abusing depclean, many users think depclean is now just a "normal" operation, while depclean is and will always be dangerous, and in no way a "normal" operation, but something user should take time to care about.
Because many users already has abuse depclean, they add a "tiny" protection in it, to use it your system must be --update --newuse --deep... prior it.
While it is some kind of weak protection against depclean abusing users, it is already bug me out, i couldn't run depclean like i wish anymore, and bad depclean users have been teach to update their system prior running it, not really something that teach them to care about it, and do worst than good as i think it has teach them bad: depclean refuse to work if system is not in a certain state -> so if system is in a "good" state to run depclean, it mean it's safe to run depclean now... |
|
Back to top |
|
|
Tony0945 Watchman
Joined: 25 Jul 2006 Posts: 5127 Location: Illinois, USA
|
Posted: Sat Jun 11, 2016 3:30 pm Post subject: |
|
|
I use a combinaton of cboldt's and Buffoon's methods. I try to rember to --exclude gentoo-sources, but I have gentoo-sources in accept-keywords and manually add the latest stable version to the world file. That way, if I inadvertantly forget, the latest stable and latest unstable versions are always there.
Also, the sources are not automatically removed by --depclean. You have to manually remove them with rm -r, so the running kernel's sources should always be found unless you manually erased them and forget to remove the choice from your bootloader. |
|
Back to top |
|
|
Jaglover Watchman
Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
|
Back to top |
|
|
Tony0945 Watchman
Joined: 25 Jul 2006 Posts: 5127 Location: Illinois, USA
|
Posted: Sat Jun 11, 2016 4:36 pm Post subject: |
|
|
Jaglover wrote: | Correction, kernel sources installed by emerge are removed by depclean. The files not installed by emerge are left behind. Technically, if you do make mrproper and then depclean nothing will be left behind. |
They are always left behind on my machine and portage posts a message to that effect. I run stable portage so maybe that has changed in later versions. |
|
Back to top |
|
|
Jaglover Watchman
Joined: 29 May 2005 Posts: 8291 Location: Saint Amant, Acadiana
|
|
Back to top |
|
|
spikyatlinux n00b
Joined: 18 Sep 2010 Posts: 31
|
Posted: Sat Jun 11, 2016 8:14 pm Post subject: |
|
|
I´ve set these settings so depclean didn´t purge my kernels.
I´m deleting only this version which I didnt´t use anymore or after some time of testing, with the following command
Quote: | emerge -C gentoo-sources:4.1-r1 | or whatever version you want to remove.
/etc/portage/sets.conf
Code: | [kernels]
class = portage.sets.dbapi.OwnerSet
world-candidate = False
files = /usr/src |
/var/lib/portage/world_sets
Don´t know if this is usable for you...
Regards |
|
Back to top |
|
|
leifbk Guru
Joined: 05 Jan 2004 Posts: 415 Location: Bærum, Norway
|
Posted: Sat Jun 25, 2016 10:41 am Post subject: |
|
|
Thanks to all for your points of view as well as several excellent suggestions. For now, I'll just use Buffoon's method and run depclean with --exclude gentoo-sources, and then run a full depclean whenever I build a new kernel and after having booted into it and checked that everything works. I don't mind having several unused source trees in /usr/src, I've got a 500 GB system partition on a raid-1 and am currently using about 7% of it. (My /home is on a separate raid-5)
I also liked alinefr's script, which seems to actually do what I asked for. But I feel that just excluding the kernel sources from everyday depclean usage gives me overall a better control, - which I guess is krinn's point as well _________________ Grumpy old man |
|
Back to top |
|
|
Roman_Gruber Advocate
Joined: 03 Oct 2006 Posts: 3846 Location: Austro Bavaria
|
Posted: Sat Jun 25, 2016 11:42 am Post subject: Re: Should "emerge --depclean" protect sources of |
|
|
leifbk wrote: | As I'm running my computer 24/7 for weeks on end, I'm usually not compiling every new kernel version. With my recent conversion from running stable to ~arch, this question has become even more acute. I'm always running "emerge --ask --depclean" after each world update, and mostly it's the sources of the running kernel that it wants to purge. That's rather inconvenient for packages like PostgreSQL that's looking for the sources of the currently running kernel, and complains loudly when there are none.
I haven't delved into the source of emerge, but I believe that it should be rather trivial to protect the sources of the running kernel from a depclean, eg. by running a "uname -r". I'd like to propose a feature request on bugs.gentoo.org, but want to hear the opinion of others about it first. |
As a long term gentoo user I had the following approach.
Mask newer kernel sources which were in use.
Mask newer binary display drivers which were in use.
These days updating nvidia-drivers do not cause issues. but they did in the past when i stayed at the same version. Maybe unable to replace the kernel module, whatever.
--
running emerge --depclean usually causes more troulbes as its worth. I usually check manually whats suggested and than go manually through the dependencies until i see if i really do not need it
--
When you wawnt the default behaviour changed, you could create an alias so the --exclude option is always in use. Maybe there is a feature to add some stuff so it is not removed ...
--
I usually only upgrade both kernel and nvidia-drivers at the same time when both have a new version. Else i keep them masked. And my upgrade is usually only once a month for both.
--
gentoo is not a newbie distro, and linux mint for example purges hole grub and other directories which has caused data loss. even those binary distros are unable to keep boot and kernels in a sane state.
When you masked newer version of your kernel and binary drivers you do not have to remove them later.
I think the approach as it is as a long term user is sufficient for this topic. |
|
Back to top |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9535 Location: beyond the rim
|
Posted: Tue Jun 28, 2016 11:06 am Post subject: |
|
|
leifbk wrote: | But I'd like to see the default behaviour of depclean changed, so that it would leave the newest kernel sources as well as the sources of the running kernel alone, and then purge all other kernel sources. That is the behaviour that I consider would adhere best to the old "principle of least surprise". |
How do you tell which kernel sources map to the current kernel binary? (Hint: the uname info doesn't have to match the package name in any way)
And how is the currently running kernel different from other kernels listed in your bootloader configuration?
Also what do you consider the "newest" kernel? Highest version number, most recently merged, most recently built, most recently installed kernel binary, ...? Those can all be different versions. And what about if you have different kernel sources (e.g. gentoo-sources and vanilla-sources) merged?
There are so many special cases to consider it's best to stick with the default rules and let the users determine what they actually want. Consistency is sometimes better than convenience. |
|
Back to top |
|
|
Fitzcarraldo Advocate
Joined: 30 Aug 2008 Posts: 2034 Location: United Kingdom
|
Posted: Tue Jun 28, 2016 4:46 pm Post subject: |
|
|
Like cboldt. I simply add to my world file the specific kernel source I want to protect:
Code: | $ grep gentoo-sources /var/lib/portage/world
sys-kernel/gentoo-sources
sys-kernel/gentoo-sources:3.18.11 |
Works a treat. _________________ Clevo W230SS: amd64, VIDEO_CARDS="intel modesetting nvidia".
Compal NBLB2: ~amd64, xf86-video-ati. Dual boot Win 7 Pro 64-bit.
OpenRC udev elogind & KDE on both.
Fitzcarraldo's blog |
|
Back to top |
|
|
freedomlives n00b
Joined: 19 Aug 2011 Posts: 32 Location: Slovakia
|
Posted: Sat Jul 09, 2016 3:53 pm Post subject: |
|
|
Ran into this problem after updating vmware. Thought the easy way out would be to just emerge virtualbox. Just need to run one windows application to get the instructions for repairing my car (Alfa Romeo eLearn), but seems I am forced to update my kernel, since the running kernel is a year old and no longer even in portage, otherwise I'd re-emerge it, and recompile it, since I have the /proc/config.gz
|
|
Back to top |
|
|
Naib Watchman
Joined: 21 May 2004 Posts: 6051 Location: Removed by Neddy
|
Posted: Sat Jul 09, 2016 3:57 pm Post subject: |
|
|
Genone wrote: | leifbk wrote: | But I'd like to see the default behaviour of depclean changed, so that it would leave the newest kernel sources as well as the sources of the running kernel alone, and then purge all other kernel sources. That is the behaviour that I consider would adhere best to the old "principle of least surprise". |
How do you tell which kernel sources map to the current kernel binary? (Hint: the uname info doesn't have to match the package name in any way)
And how is the currently running kernel different from other kernels listed in your bootloader configuration?
Also what do you consider the "newest" kernel? Highest version number, most recently merged, most recently built, most recently installed kernel binary, ...? Those can all be different versions. And what about if you have different kernel sources (e.g. gentoo-sources and vanilla-sources) merged?
There are so many special cases to consider it's best to stick with the default rules and let the users determine what they actually want. Consistency is sometimes better than convenience. | I agree the variability is huge and thus stick with the proven is the safest.
What would be involved in adding an --exclude option to depclean?
emerge --depclean --exclude gentoo-source-1.2.3
and thus provide the user with a convenient method to isolate a package that could be removed. This seems a bit cleaner than hacking the world file, especially as that would have to be done witrh every kernel you want. _________________
Quote: | Removed by Chiitoo |
|
|
Back to top |
|
|
freedomlives n00b
Joined: 19 Aug 2011 Posts: 32 Location: Slovakia
|
Posted: Sat Jul 09, 2016 4:13 pm Post subject: |
|
|
I would use spikyatlinux suggests with portage sets, but I don't quite understand what it is doing, so need to read up first. But for me, I don't see any point for portage to delete anything from /usr/src
Since I have to go there anyway to compile new kernels, it is no problem for me to manually delete old sources once I'm sure I don't need them. |
|
Back to top |
|
|
Genone Retired Dev
Joined: 14 Mar 2003 Posts: 9535 Location: beyond the rim
|
Posted: Sat Jul 09, 2016 8:12 pm Post subject: |
|
|
Naib wrote: | What would be involved in adding an --exclude option to depclean? |
You'll have to ask the people familiar with the current codebase. |
|
Back to top |
|
|
Atmmac Tux's lil' helper
Joined: 17 Oct 2013 Posts: 130 Location: Watertown, MA
|
Posted: Tue Jul 12, 2016 8:47 pm Post subject: |
|
|
I always use emerge --noreplace gentoo-sources:x.x.x after a kernel upgrade.
Then emerge --unmerge after new kernel upgrades. Easier than excluding on depclean every time. |
|
Back to top |
|
|
|