Without doubt, one of Gentoo's best features is its package management system, Portage. Portage makes it very easy to update your entire system with one simple command. Sadly, things don't always go as smooth as they should. Almost every Gentoo user has typed emerge -uD world and gone to bed with the hope of waking up in the morning to a completely up to date system. Unfortunately, it's more likely that you.ll wake up to a failed emerge on package 3 of 220. And so the troubleshoot and emerge --resume process begins.
Enter update-world to save the day. Update-world is a bash script that was recently created by count_zero and in the forums. The script controls the update process and forces portage to skip past failed builds and continue compiling packages until the update list is finished. Failed builds are added to a list for review once the update is finished.
Note: The script does depend on the 'equery' command, part of app-portage/gentoolkit. |
Obviously before you can start using the script, you'll need to download it, put it somewhere in your path, and make it executable.
Code Listing |
# wget -O /usr/bin/update-world |
Now we're ready to start using the script.
Code Listing |
# update-world --prepare |
This begins the update process by creating a list of packages to be emerged, as produced by emerge -uD --newuse world. (Alternatively, you can use update-world --empty to create a list of all packages on the system, akin to emerge -e world). This command creates a list called 'emergelist' in ~/.update-world/. Now, you can use your favorite editor to modify this list how you like--remove packages, change versions, etc. When you have the emergelist how you like it, you're ready to move onto the next step:
Code Listing |
# update-world --install |
This command actually starts the build process, just as if you had typed emerge -uD world. The difference is, if a package fails for some reason or another, that package is added to a list 'failedlist' in ~/.update-world/. Also, a link to the portage log file for that package (usually located in /var/log/portage) is created in ~/.update-world/[date]/log/. Once the process is done, you'll be presented with a list of failed packages to take care of all at once, saving much time. If you ever need to stop the process, just hit 'Control-C' to abort the process. The update can then be restarted at any time, just where it left off, by retyping update-world --install.
代码如下:
# update-world 1.5
# count_zero 2006
# Licensed under the GPLv2
#
# update-world is a bash script that forces an emerge -uD world to continue, even
# in the face of (inevitable) compile failures.
# and the script jumps to the next package in the queue.
#
# just run update-world --prepare (or --empty) followed by update-world --install.
#
# Release Notes:
# v1.5: now handles 'fetch restriction' properly
# v1.4: uses '--newuse' for emerges to respect new use flags
# v1.3: uses '--oneshot' for emerges so they don't get added to the world file.
# v1.2: Script now detects log directly instead of accepting only /var/log/portage
# v1.1: minor bugfix to allow package without version to be added to 'emergelist'
# v1.0: Release
#
#
# Set the program directory and important variables
homedir=~/.update-world
workdir="$homedir/`date +%F`"
logdir="$workdir/log"
mkdir -p $logdir
touch $homedir/failedlist
emergelist=$homedir/emergelist
emergetemp=$workdir/emergetemp
failedlist=$homedir/failedlist
portlogdir=`cat /etc/make.conf | grep PORT_LOGDIR | sed 's/PORT_LOGDIR=//' | sed 's/\"//g' | sed 's/\/$//'`
masked=$homedir/masked
# parameter for '--empty' to emerge -e world
if [[ $1 == '--empty' || $1 == '-e' ]]
fi
#### update-world --prepare ####
# Prepare the list of packages to emerge into emerglist
if [[ $1 == "--prepare" || $1 == "-p" || $1 == '--empty' || $1 == '-e' ]]
Continue anyway? (y/n) "
echo
$fetchrestricted
Please download the sources from the location specified in the ebuild to /usr/portage/distfiles/ and rerun this script."
These are the packages that will be installed.
just edit the file 'emergelist' in $homedir. When finished, run
'update-world --install'"
#### update-world --install ####
# Install the packages listed in emergelist
elif [[ $1 == "--install" || $1 == "-i" ]]