Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Safely Stopping Emerge
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
junkmonkey
n00b
n00b


Joined: 28 Oct 2006
Posts: 6

PostPosted: Sat Oct 28, 2006 1:08 pm    Post subject: Safely Stopping Emerge Reply with quote

Hi,

Is there a way that I don't know about to instruct 'emerge' to stop after completing merging the current package? I was thinking something like kill -s USR1. Or perhaps there's a better way.

Right now I'm doing a large emerge --newuse world, which is going to take a few hours. Halfway through building glibc I realise that I want to change a few use flags, which I know don't affect the package that's currently being built. So I change the use flags, then sit here twiddling my thumbs for the next hour or so waiting for glibc to finish emerging so I can hit Ctrl-C and start emerge --newuse world again to work with the updated flags.

Surely I'm not the only one who has done that? I'd like to tell emerge to just stop after it has merged the current package so I don't need to sit here staring at the screen waiting for my Ctrl-C moment to come up. Yes, of course I could just interrupt that package or even the next one... but I don't really want to do that.
Back to top
View user's profile Send private message
hielvc
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2805
Location: Oceanside, Ca

PostPosted: Sat Oct 28, 2006 3:14 pm    Post subject: Reply with quote

Its not elegent but "CNTRL C" will stop emerge. If your doing -uDN update, particularly if your going to change your USE flags, then just re-run your original command. Anything that is not affected by the change in USE flags and or has already been update wont be rebuilt.

If this was in the middile of an --emptytree system/world then to restart where you were "emerge --resume".


The one other cavate is when you stop emerge or it fails while biulding something it leaves crud behind in the /var/tmp/portage directory. So you should periodicaly "rm -r /var/tmp/portage/* " to clean it out.
_________________
An A-Z Index of the Linux BASH command line
Back to top
View user's profile Send private message
Dlareh
Advocate
Advocate


Joined: 06 Aug 2005
Posts: 2102

PostPosted: Sat Oct 28, 2006 3:30 pm    Post subject: Reply with quote

He specifically said CTRL+C is not what he's looking for. He wants the currently building package to finish merging, and THEN for emerge to stop.
_________________
"Mr Thomas Edison has been up on the two previous nights discovering 'a bug' in his phonograph." --Pall Mall Gazette (1889)
Are we THERE yet?
Back to top
View user's profile Send private message
hielvc
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2805
Location: Oceanside, Ca

PostPosted: Sat Oct 28, 2006 3:46 pm    Post subject: Reply with quote

I was never smart enough to figure out how to do that :lol: Did you :?:
_________________
An A-Z Index of the Linux BASH command line
Back to top
View user's profile Send private message
junkmonkey
n00b
n00b


Joined: 28 Oct 2006
Posts: 6

PostPosted: Sat Oct 28, 2006 4:59 pm    Post subject: Reply with quote

Thanks Dlareh, you saved me a post. :)

I guess I could write a script that watches emerge.log for 'completed emerge' and then kills emerge - it would probably work as well as me watching and stopping it by hand. It's just not a very clean solution! Also wouldn't work with more than one emerge at once, and will presumably interrupt the next package just as it's starting. No worse than me hitting Ctrl-C but not a lot better.

I'll give it a go though.
Back to top
View user's profile Send private message
hielvc
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2805
Location: Oceanside, Ca

PostPosted: Sat Oct 28, 2006 5:41 pm    Post subject: Reply with quote

1. CNTRL C 2 keystrokes :wink:

2. parrellal emerges, unless your just fetching files, is guaranteed to bork. Portage is still subject to circulaur dependencies and out of step emerges, pkg1 fails because it needs pkg2. You restart emerge it installs pkg2 and then some time latter pkg1. Granted there have been major improvements in portage to handle these problems but still happen with a single emerge so what do you think will happen with a parallel emerge ?

3. And I agree the only way I can see would be to "&&" or "tee" the output of emerge. The one way you could do it would be to put the out put of emerge into a list an use a for loop. You could then monitor for a stop sig and kick out of the loop.
_________________
An A-Z Index of the Linux BASH command line
Back to top
View user's profile Send private message
junkmonkey
n00b
n00b


Joined: 28 Oct 2006
Posts: 6

PostPosted: Sat Oct 28, 2006 6:23 pm    Post subject: Reply with quote

hielvc wrote:
1. CNTRL C 2 keystrokes :wink:

... and minutes/hours/days of watching the screen until a sensible point to stop. ;)

Quote:
2. parrellal emerges, unless your just fetching files, is guaranteed to bork. Portage is still subject to circulaur dependencies and out of step emerges, pkg1 fails because it needs pkg2. You restart emerge it installs pkg2 and then some time latter pkg1. Granted there have been major improvements in portage to handle these problems but still happen with a single emerge so what do you think will happen with a parallel emerge ?

Indeed. It's not something I make a habit of doing, I was just pointing out a potential problem watching the log file output.

Quote:
3. And I agree the only way I can see would be to "&&" or "tee" the output of emerge. The one way you could do it would be to put the out put of emerge into a list an use a for loop. You could then monitor for a stop sig and kick out of the loop.

Good suggestion. A bit of a pain though - normally I'd want to stop emerge from doing its thing because I'd forgotten something. If I was sensible enough to put emerge into a loop and monitor it I'd probably be sensible enough to get my use flags sorted before running it. ;)
Back to top
View user's profile Send private message
hielvc
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2805
Location: Oceanside, Ca

PostPosted: Sat Oct 28, 2006 7:02 pm    Post subject: Reply with quote

The only place you dont want to do a CNTRL C is during the install phase or the un-install phase of an emerge. I have tested this feature thourghly since April of 2002 :P
_________________
An A-Z Index of the Linux BASH command line
Back to top
View user's profile Send private message
TheX
Guru
Guru


Joined: 31 Jul 2004
Posts: 349
Location: .de

PostPosted: Sat Oct 28, 2006 8:32 pm    Post subject: Reply with quote

if you are updateing the system with
Code:
emerge -u package pakage1

you can resume with
Code:
emerge -u --resume package package1
Back to top
View user's profile Send private message
TheX
Guru
Guru


Joined: 31 Jul 2004
Posts: 349
Location: .de

PostPosted: Sat Oct 28, 2006 8:34 pm    Post subject: Reply with quote

if one package is always breaking the process but all other should be emerged, you can jump over tho the next package by starting
Code:
emerge -u --resume --skipfirst package package1
Back to top
View user's profile Send private message
junkmonkey
n00b
n00b


Joined: 28 Oct 2006
Posts: 6

PostPosted: Sat Oct 28, 2006 8:49 pm    Post subject: Reply with quote

Thanks... but it's the stopping the emerge I'm talking about, not the starting it back up again! I'd just like to do it after the current package has finished merging, without me having to sit there and watch for it to finish.
Back to top
View user's profile Send private message
Kasumi_Ninja
Veteran
Veteran


Joined: 18 Feb 2006
Posts: 1825
Location: The Netherlands

PostPosted: Thu May 10, 2007 5:49 am    Post subject: Reply with quote

junkmonkey wrote:
Thanks... but it's the stopping the emerge I'm talking about, not the starting it back up again! I'd just like to do it after the current package has finished merging, without me having to sit there and watch for it to finish.


I have used the following workaround:

Code:
# /etc/init.d/net.eth0 stop
# cd /usr/portage/distfiles
# rm *

_________________
Please add [solved] to the initial post's subject line if you feel your problem is resolved. Help answer the unanswered
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


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

PostPosted: Thu May 10, 2007 6:23 am    Post subject: Reply with quote

hielvc wrote:
If this was in the middile of an --emptytree system/world then to restart where you were "emerge --resume".

Not such a good idea when you changed useflags as the depgraph won't be recalculated.
TheX wrote:
if you are updateing the system with
Code:
emerge -u package pakage1

Unless you actually know what -u does exactly (and most people don't) I'd strongly recommend to not use it for anything other than "world" or "system" as the results are generally not what people expect.


Last edited by Genone on Thu May 10, 2007 6:28 am; edited 1 time in total
Back to top
View user's profile Send private message
AllenJB
Veteran
Veteran


Joined: 02 Sep 2005
Posts: 1285

PostPosted: Thu May 10, 2007 11:56 am    Post subject: Reply with quote

It would be quite nice if there was a method of safely stopping emerge (in a "finish the current package then stop" kind of way). Whether it's catching Ctrl+C or some other method. There are occasionally times when I need to interrupt long emerges for whatever reason (usually 'cause I need the processor back for a while for gaming or something).

I'll also note here that sometimes it seems you have to hit Ctrl+C several times to completely get out of emerge. I suspect this is something to do with multiple simultaneous compiles, or just the build system that the package uses.

Genone:
Am I right in thinking that you're saying that because -u only updates a package and its immediate dependencies, not its entire dep. tree?
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


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

PostPosted: Fri May 11, 2007 5:03 am    Post subject: Reply with quote

AllenJB wrote:
Genone:
Am I right in thinking that you're saying that because -u only updates a package and its immediate dependencies, not its entire dep. tree?

BEcause of the deps yes, but more as most people (from my experience) expect portage to not update deps unless absolutely required in these cases.
Back to top
View user's profile Send private message
L29Ah
n00b
n00b


Joined: 18 Oct 2010
Posts: 17

PostPosted: Sat May 17, 2025 11:28 pm    Post subject: Reply with quote

Code:
tail -Fn0 /var/log/emerge.log | grep -q '::: completed emerge' && killall emerge
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23452

PostPosted: Sun May 18, 2025 12:51 am    Post subject: Reply with quote

L29Ah: why are you resurrecting long finished threads? This is the third such thread you raised recently, after you raised the 2010 thread Are you using maintainer-needed packages? on April 14, and then you raised the 2005 thread Default permissions on $HOME on May 9. Raising old threads can be useful if you have a new contribution and the original question was never solved. In this case, I think your answer is not even new:
L29Ah wrote:
Code:
tail -Fn0 /var/log/emerge.log | grep -q '::: completed emerge' && killall emerge
This is effectively what junkmonkey contemplated in 2006, and decided against because of various failure modes.
Back to top
View user's profile Send private message
L29Ah
n00b
n00b


Joined: 18 Oct 2010
Posts: 17

PostPosted: Sun May 18, 2025 1:08 am    Post subject: Reply with quote

Hu wrote:
L29Ah: why are you resurrecting long finished threads? This is the third such thread you raised recently, after you raised the 2010 thread Are you using maintainer-needed packages? on April 14, and then you raised the 2005 thread Default permissions on $HOME on May 9. Raising old threads can be useful if you have a new contribution and the original question was never solved. In this case, I think your answer is not even new:
L29Ah wrote:
Code:
tail -Fn0 /var/log/emerge.log | grep -q '::: completed emerge' && killall emerge
This is effectively what junkmonkey contemplated in 2006, and decided against because of various failure modes.

Because they hit the top of web searches when i look for problems, and i want to share the solution i found with people facing the same problem and finding the same pages. Ten thousand views of this thread suggests that i'm not the only facing the problem since 2007. I don't see a reason not to contribute to old threads, and i do have a good contribution, as the complete solution that i posted was never shared here, and is useful despite the possible edge cases where it is inadequate.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3650

PostPosted: Sun May 18, 2025 2:02 am    Post subject: Reply with quote

19 years is 7000 days. 10k views is well within reach of spiders indexing stuff.
Just saying.
.
.
.
Damn, we're growing old!
Anyway, it would be nice to have some way to finish already started jobs and then terminate, but in the absence of such feature Ctrl+C has served me well enough. Interrupting a compilation is safe, even though it wastes some time.
_________________
Make Computing Fun Again
Back to top
View user's profile Send private message
Slippery Jim
Apprentice
Apprentice


Joined: 08 Jan 2005
Posts: 295

PostPosted: Mon May 19, 2025 9:21 am    Post subject: Reply with quote

Quote:

Hu wrote:
L29Ah: why are you resurrecting long finished threads?


Not sure why Hu's butthurt about this. He's usually pretty chill. L29Ah is actively trying to contribute, and the thread wasn't marked [SOLVED]. I might have posted an opinion if I'd seen the thread before now. AFAIK there's no canonical solution to this in portage ATM. Is there some etiquette point I'm missing here?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 55262
Location: 56N 3W

PostPosted: Mon May 19, 2025 9:38 am    Post subject: Reply with quote

Slippery Jim,

In general, topics over a year old are not useful. Gentoo changes too quickly, so it's more productive to start a new topic than resurrect an old topic, that was correct at the time, but is now misleading.
Its a feature of rolling releases.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23452

PostPosted: Mon May 19, 2025 1:41 pm    Post subject: Reply with quote

Slippery Jim wrote:
Quote:

Hu wrote:
L29Ah: why are you resurrecting long finished threads?


Not sure why Hu's butthurt about this. He's usually pretty chill. L29Ah is actively trying to contribute, and the thread wasn't marked [SOLVED]. I might have posted an opinion if I'd seen the thread before now. AFAIK there's no canonical solution to this in portage ATM. Is there some etiquette point I'm missing here?
As I wrote above, raising old threads can be useful if the resurrection is a useful contribution. In this case, I thought L29Ah's post was neither new nor correct, as it rehashed a technique that was considered and rejected in 2006. It provided no context for why the proposal was suitable. It did not rebut any of the reasons that justmonkey gave for why this was a bad approach, not even a simple hand-wave of "I think justmonkey's concerns were unfounded, and that doing this will be fine."

Also, as I referenced in my earlier post, this is not the first such long dead resurrection. I usually ignore the first case of thread necromancy by a user, on the assumption they had a one-off instance of inattentiveness to the thread's context. In this case, L29Ah dug up three different old threads and restarted them. That suggests to me a pattern either of digging out old threads deliberately, or a pattern of routine inattentiveness. If the user is frequently inattentive, a reminder to be more careful is appropriate. If the user is digging out old threads deliberately, a caution not to bother with it would be appropriate since, as Neddy says, such threads are often of limited applicability to current systems, so it may be a waste of the necromancer's time to write the post.
Back to top
View user's profile Send private message
Slippery Jim
Apprentice
Apprentice


Joined: 08 Jan 2005
Posts: 295

PostPosted: Tue May 20, 2025 12:21 am    Post subject: Reply with quote

Alright. I'll try to be mindful of that in the future myself. Thanks for the feedback Hu, Neddy.

And FWIW, I think Junkmonkey's idea of hooking a signal in the top-level emerge is probably the correct way to implement what he wanted to do, since it could sensibly manage any currently running parallel child processes, to allow them to complete. Ok, I'll shut up now.
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



OSZAR »