Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Thoughts of building an emerge resume mid package
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
xboom31
n00b
n00b


Joined: 27 Aug 2024
Posts: 1

PostPosted: Thu Mar 20, 2025 10:54 pm    Post subject: Thoughts of building an emerge resume mid package Reply with quote

Hello, Gentoo is the best OS ever but comping for days when you decide to do an emptytree is not really fun.
I know emerge --resume is good enough for most people but I really dream of having the option to resume compilation mid-package for things like qtwebengine and so on.
I was thinking what if I could save the state of the emerge and somehow resume it later? Maybe modify portage that when you kill it it prompts you with a question if you want to save it's state?
Would that be something you guys might me interested in or is just something no one cares about and they just use ccache and/or distcc?
I would really like to develop such a thing. How would you guys do it and why isn't it there already? Maybe because of some architectural limitations or nobody bothered? What are your thoughts?
Thanks for your time!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


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

PostPosted: Thu Mar 20, 2025 11:17 pm    Post subject: Reply with quote

xboom31,

Welcome to Gentoo.

Code:
emerge --resume
starts from the beginning of the package (or packages) that were interrupted.

The ebuild command sort of lets you ho what you want as you can run the phase functions individually.
Try
Code:
ebuild /full/path/to/<package>.ebuild prepare

Follow that with
Code:
ebuild /full/path/to/<package>.ebuild compile

Nothing is installed yet.

Its intended for debugging. See
Code:
man ebuild
then play but not with anything you can't afford to break. :)
_________________
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
sublogic
Guru
Guru


Joined: 21 Mar 2022
Posts: 349
Location: Pennsylvania, USA

PostPosted: Fri Mar 21, 2025 12:25 am    Post subject: Re: Thoughts of building an emerge resume mid package Reply with quote

xboom31 wrote:
I know emerge --resume is good enough for most people but I really dream of having the option to resume compilation mid-package for things like qtwebengine and so on.
I was thinking what if I could save the state of the emerge and somehow resume it later? Maybe modify portage that when you kill it it prompts you with a question if you want to save it's state?

Outline of a possible solution: if you send a STOP signal to a big, long-running process, it ... stops (but does not crash!) and gradually pages out to swap as other process use up memory. Later when you send a CONT signal, the stopped process faults back in and picks up where it left off.

Now, an emerge is not just one big process. It spawns multiple worker and you have to catch enough of them. Perhaps this ?
Code:
# pkill -STOP ebuild
or
Code:
# pkill -STOP make; pkill -STOP ninja
depending on the build system running at the time. Or maybe there is a way to pick them up by session ID or cgroup, I don't know. Can someone familiar with portage internals can suggest a better way ? You don't have to get them all, if you stop enough of the build system the running compilations will finish and no new ones will start. The work in progress will stay in /var/tmp/portage/ until you wake the thing up with
Code:
# pkill -CONT ebuild # or whatever else you used


DISCLAIMER: I never tried this. Let us know if it breaks anything ...
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23635

PostPosted: Fri Mar 21, 2025 12:56 am    Post subject: Reply with quote

We get questions like this periodically, and the answer is always that you cannot assume that every package has a build system that can reliably recover from being killed in the middle. That then leads to the suggestions here, that you should pause the build, but not terminate it, so that when you unpause, it can resume exactly where it left off.

I would be wary of using SIGSTOP for this. If I wanted to suspend something, I would do it using the cgroup freezing mechanism. A bit of care before starting Portage can ensure that emerge and all its children (and nothing else) are in the same cgroup, making it easy to freeze.
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