View previous topic :: View next topic |
Author |
Message |
cyberjun Apprentice
Joined: 06 Nov 2005 Posts: 293
|
Posted: Thu Sep 29, 2011 6:47 am Post subject: compile world [bash script] |
|
|
Hi,
I have put together a short script for compiling the entire tree (prompted by the latest gcc 4.5.3-r1 stabilization) at your leisure. It stops and prompts after compiling 10 packages and shows the list of next 10 packages which will be compiled. It exits if it encounters an error while compilation.
It is for people using gentoo on laptops like me. The aim is to give you a chance to pause the compilation mid way and resume when you can.
It may be redundant for most people as emerge --resume can very well take care of things. Although the script is not very refined or robust, I hope it will be helpful for some people.
To prepare the input file, following steps can be used:
Quote: | 1. emerge -pve world > temp1.txt
2. Edit the file in an editor and remove initial and last 6 lines so that only actual package names remain on each line.
3. cat temp1.txt | cut -d']' -f2 | cut -d' ' -f2 > temp.txt
|
I have not used equery list '*' because the above approach preserves the build order. Please note that this script does not automate the complete gcc upgrade process. It just helps in the "compile world" part. Please follow the gcc upgrade guide if you are upgrading to new gcc version.
Script follows:
Quote: | #!/bin/bash
if [ -a "/root/compile_done.txt" ]; then
count=`cat /root/compile_done.txt`;
else
count=0;
fi
startfrom=$((count+1));
for atom in $(tail -n +$startfrom temp.txt);
do
echo 'emerge -av1 ='$atom;
emerge -v1 =$atom;
if [ $? -eq 0 ]; then
count=$((count+1));
echo $count > /root/compile_done.txt;
else
exit;
fi
modulo=$((count % 10));
echo $modulo;
if [ $modulo -eq 0 ]; then
echo $count
show=$((count+1));
tail -n +$show temp.txt | head
read -p "Press any key to continue..." -n1 -s;
else
continue;
fi
done
echo $count
|
--cyberjun |
|
Back to top |
|
|
ppurka Advocate
Joined: 26 Dec 2004 Posts: 3256
|
Posted: Thu Sep 29, 2011 4:19 pm Post subject: |
|
|
Can you not run the compilation in screen and then Ctrl-z to pause the compilation? Later when you want to resume you could simply use fg. If you want to close down your terminal, you could detach screen by using Ctrl-a d and later reattach it by using screen -r. _________________ emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/ |
|
Back to top |
|
|
cyberjun Apprentice
Joined: 06 Nov 2005 Posts: 293
|
Posted: Thu Sep 29, 2011 4:23 pm Post subject: |
|
|
Yes. Thats right. However pausing and resuming a particular compilation messes up compile time logs in qlop -tH output
This way I can pause between every 10 emerges without affecting qlop.
--cyberjun |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10587 Location: Somewhere over Atlanta, Georgia
|
Posted: Thu Sep 29, 2011 7:24 pm Post subject: |
|
|
Moved from Portage & Programming to Documentation, Tips & Tricks.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
steveL Watchman
Joined: 13 Sep 2006 Posts: 5153 Location: The Peanut Gallery
|
Posted: Fri Oct 07, 2011 3:54 pm Post subject: |
|
|
Your basic loop of emerging one package at a time in the list is what update started out doing, and still does unless you're using multiple jobs, although it was also designed to filter the output from single emerge's (which was only kind when we started.) It's a much larger script nowadays of course.
You can type update --stop while one is running, from another terminal (or same one if you've backgrounded the first update) to make it stop after the current package. (Running just update will ask you if you want the running one to stop after current package.) This means you can pause at any time you like while not losing any work.
Or you can just hit CTRL-C if you want it to bail out immediately (which will mean current package will have to be restarted.)
In either case, you can resume with update -r which historically has been more reliable than lower-level emerge --resume. |
|
Back to top |
|
|
|