Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
A Simple Gentoo Update script.
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
Clapper
Apprentice
Apprentice


Joined: 29 Sep 2003
Posts: 177

PostPosted: Wed Jul 27, 2005 4:33 pm    Post subject: A Simple Gentoo Update script. Reply with quote

To make administering my Gentoo system easier, I have cobbled a little script together that I run
manually to update my system. After using this once or twice a week, for over a year, I can say
it has made keeping my Gentoo box up to date really easy. Understand what this does, before you
use it, and modify it to suit your needs.

First, I have "emerge sync" automated to download updates once a day, so I don't have to wait on
this step when I want to run my update script (be nice, and don't do this more than once a day, at most).

This goes in my crontab file to download the changes daily at 4:00 a.m.:

Code:

1 4 * * *  nice -n 19 emerge sync


To actually perform my updates to the system, I manually run the following script. This runs 5 programs, any
of which can be skipped (although I usually do the entire sequence). The script
does demand a little user interaction, which is good, and it tells you what it wants to do.


These programs called by the script can be a little resource intensive, so everything is run with
"nice -n 19" prefixed so other applications on the system can get higher priority.

Here is what the script actually does, along with some man page snippets:



Quote:


Option to emerge updates to World:


Script first gives you a print out of what it would like to update by running "emerge -uDpv |more ".

script output: "Press Y to continue updating, any other key to skip..."
Answer y or no to continue.


Here is what "emerge -uDv" does:

--update (-u)
Updates packages to the best version available, which may not always be the highest version number
due to masking for testing and development. This will also update direct dependencies which may
not be what you want. In general, use this option only in combination with the world or system
target.

--deep (-D)
When used in conjunction with --update, this flag forces emerge to consider the entire dependency
tree of packages, instead of checking only the immediate dependencies of the packages. As an exam-
ple, this catches updates in libraries that are not directly listed in the dependencies of a pack-
age.
--verbose (-v)
Tell emerge to run in verbose mode. Currently this flag causes emerge to print out GNU info
errors, if any, and to show the USE flags that will be used for each package when pretending.



Option to resume a failed emerge world sequence:


script output: Press Y to emerge again, skipping any package which may have previously failed, any other key to skip...
Answer y to continue a failed emerge sequence

If a package fails, you can pick up where your emerging left off (emerge -uDv world --skipfirst --resume)


Option to update configuration files:


script output: "Press Y to update configuration files, any other key to skip."
Answer y to continue, other key to skip.


This runs dispatch-conf.

Here is what dispatch-conf does:

dispatch-conf is designed to be run after merging new packages in order to see if there are updates to the
configuration files. If a new configuration file will overwrite an old one, dispatch-conf will prompt the
user for a decision about how to resolve the discrepancy.


Option to emerge depclean:



script output: "Starting Emerge Depclean....."
(ouput of emerge -pv depclean | more)
"Press Y to continue emerge depclean, any other key to skip..."

Press y to perform what emerge depclean suggests.


Here is what emerge -v depclean does:

Determines all packages installed on the system that have no explicit reason for being there.
emerge generates a list of packages which it expects to be installed by checking the system package
list and the world file. It then compares that list to the list of packages which are actually
installed; the differences are listed as unnecessary packages and then unmerged after a short time-
out. WARNING: Removing some packages may cause packages which link to the removed package to stop
working and complain about missing libraries. Re-emerge the complaining package to fix this issue.
Note that changes in USE flags can drastically affect the output of --depclean.



Option to perform reverse dependency rebuild:


script output: "Starting reverse dependency -rebuild....."
(output of revdep-rebuild -pv |more )
"Press Y to continue reverse dependency rebuild, any other key to quit.."

Press y to perform what revdep-rebuild suggests.


Here is what revdep-rebuild does:

Broken reverse dependency rebuilder






Here is the actual script, which I call, what else, update-system-script



Code:

#!/bin/bash

nice -n 19 emerge -uDpv world |more

echo -e "\xa"
echo -n "Press y to continue updating, any other key to skip..."
read var1
if [ "$var1" = "y" ]; then
emerge -uDv world
fi


echo -e "\xa"
echo -n "Press y to emerge again, skipping any package which may have previously failed, any other key to skip..."
read var1
if [ "$var1" = "y" ]; then
emerge -uDv world --skipfirst --resume
fi

echo -e "\xa"
echo -n "Press y to update configuration files, any other key to skip."
read var1
if [ "$var1" = "y" ]; then
dispatch-conf
fi


echo -e "\xa Starting Emerge Depclean....."
nice -n 19 emerge -pv depclean | more

echo -e "\xa"
echo -n "Press y to continue emerge depclean, any other key to skip..."
read var1
if [ "$var1" = "y" ]; then
nice -n 19 emerge -v depclean
fi


echo -e "\xa Starting reverse dependency -rebuild....."
nice -n 19 revdep-rebuild -pv |more

echo -e "\xa"
echo -n "Press y to continue reverse dependency rebuild, any other key to quit.."
read var1
if [ "$var1" = "y" ]; then
nice -n 19 revdep-rebuild -v
fi



Last edited by Clapper on Wed Jul 27, 2005 7:21 pm; edited 1 time in total
Back to top
View user's profile Send private message
ikaro
Advocate
Advocate


Joined: 14 Jul 2003
Posts: 2527
Location: Denmark

PostPosted: Wed Jul 27, 2005 5:06 pm    Post subject: Reply with quote

its easier just to set up aliases in your shell profile.

Code:

alias sync="sudo nice -19 emerge -q --nospinner sync"
alias udv="sudo nice -n 19 emerge -q --nospinner -uDv world"
alias udvs="sudo nice -n 19 emerge -q --nospinner -uDv world --skipfirst --resume"
alias dpatch="sudo dispatch-conf"
alias dclean="sudo nice -n 19 emerge -v depclean"
alias revdep="sudo nice -n 19 revdep-rebuild -v"


even keybindigs:
(fvwm)

Code:

Key       s       A     C      Exec sudo nice -19 emerge -q --nospinner sync
Key       u       A     C      Exec sudo nice -19 emerge -q --nospinner uD
... etc...

_________________
linux: #232767
Back to top
View user's profile Send private message
Clapper
Apprentice
Apprentice


Joined: 29 Sep 2003
Posts: 177

PostPosted: Wed Jul 27, 2005 6:46 pm    Post subject: Reply with quote

ikaro wrote:
its easier just to set up aliases in your shell profile.



Probably so, especially if you are going to perform one to two of the functions. I typically like to run through all the functions, and I am apt to forget commands or aliases, so a do-it-all script is easier for me.

I administer remote boxes, and copying the script to them makes it pretty simple.

Your mileage may vary! :wink:
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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