Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Should "emerge --depclean" protect sources of running kernel
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
leifbk
Guru
Guru


Joined: 05 Jan 2004
Posts: 415
Location: Bærum, Norway

PostPosted: Fri Jun 10, 2016 4:19 pm    Post subject: Should "emerge --depclean" protect sources of runn Reply with quote

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
View user's profile Send private message
Buffoon
Veteran
Veteran


Joined: 17 Jun 2015
Posts: 1369
Location: EU or US

PostPosted: Fri Jun 10, 2016 4:31 pm    Post subject: Reply with quote

I run depclean with --exclude gentoo-sources, good enough solution for me.
Back to top
View user's profile Send private message
leifbk
Guru
Guru


Joined: 05 Jan 2004
Posts: 415
Location: Bærum, Norway

PostPosted: Fri Jun 10, 2016 4:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Fri Jun 10, 2016 4:52 pm    Post subject: Reply with quote

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
View user's profile Send private message
Buffoon
Veteran
Veteran


Joined: 17 Jun 2015
Posts: 1369
Location: EU or US

PostPosted: Fri Jun 10, 2016 5:31 pm    Post subject: Reply with quote

As a matter of fact I run emerge @world with --exclude gentoo-sources, too. So I never have unwanted sources installed.
Back to top
View user's profile Send private message
alinefr
Tux's lil' helper
Tux's lil' helper


Joined: 05 Jul 2009
Posts: 113
Location: São Paulo, Brasil

PostPosted: Fri Jun 10, 2016 6:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
cboldt
Veteran
Veteran


Joined: 24 Aug 2005
Posts: 1046

PostPosted: Fri Jun 10, 2016 7:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
Josef.95
Advocate
Advocate


Joined: 03 Sep 2007
Posts: 4558
Location: Germany

PostPosted: Fri Jun 10, 2016 11:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

PostPosted: Sat Jun 11, 2016 10:12 am    Post subject: Reply with quote

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
View user's profile Send private message
Tony0945
Watchman
Watchman


Joined: 25 Jul 2006
Posts: 5127
Location: Illinois, USA

PostPosted: Sat Jun 11, 2016 3:30 pm    Post subject: Reply with quote

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
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Sat Jun 11, 2016 3:41 pm    Post subject: Reply with quote

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.
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
Tony0945
Watchman
Watchman


Joined: 25 Jul 2006
Posts: 5127
Location: Illinois, USA

PostPosted: Sat Jun 11, 2016 4:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
Jaglover
Watchman
Watchman


Joined: 29 May 2005
Posts: 8291
Location: Saint Amant, Acadiana

PostPosted: Sat Jun 11, 2016 5:20 pm    Post subject: Reply with quote

Have a closer look at what's left behind, the sources are gone. The files you compiled are left behind.
_________________
My Gentoo installation notes.
Please learn how to denote units correctly!
Back to top
View user's profile Send private message
spikyatlinux
n00b
n00b


Joined: 18 Sep 2010
Posts: 31

PostPosted: Sat Jun 11, 2016 8:14 pm    Post subject: Reply with quote

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
Quote:
@kernels



Don´t know if this is usable for you...

Regards
Back to top
View user's profile Send private message
leifbk
Guru
Guru


Joined: 05 Jan 2004
Posts: 415
Location: Bærum, Norway

PostPosted: Sat Jun 25, 2016 10:41 am    Post subject: Reply with quote

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
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Sat Jun 25, 2016 11:42 am    Post subject: Re: Should "emerge --depclean" protect sources of Reply with quote

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
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9535
Location: beyond the rim

PostPosted: Tue Jun 28, 2016 11:06 am    Post subject: Reply with quote

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
View user's profile Send private message
Fitzcarraldo
Advocate
Advocate


Joined: 30 Aug 2008
Posts: 2034
Location: United Kingdom

PostPosted: Tue Jun 28, 2016 4:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
freedomlives
n00b
n00b


Joined: 19 Aug 2011
Posts: 32
Location: Slovakia

PostPosted: Sat Jul 09, 2016 3:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
Naib
Watchman
Watchman


Joined: 21 May 2004
Posts: 6051
Location: Removed by Neddy

PostPosted: Sat Jul 09, 2016 3:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
freedomlives
n00b
n00b


Joined: 19 Aug 2011
Posts: 32
Location: Slovakia

PostPosted: Sat Jul 09, 2016 4:13 pm    Post subject: Reply with quote

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
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9535
Location: beyond the rim

PostPosted: Sat Jul 09, 2016 8:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
Atmmac
Tux's lil' helper
Tux's lil' helper


Joined: 17 Oct 2013
Posts: 130
Location: Watertown, MA

PostPosted: Tue Jul 12, 2016 8:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum