Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
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
SunMar
n00b
n00b


Joined: 15 Nov 2004
Posts: 30
Location: The Netherlands

PostPosted: Fri Nov 28, 2014 11:02 am    Post subject: Gentoo update script Reply with quote

Hi,

I like keeping my Gentoo system up-to-date (including new use flags, deep depedency checking and build dependencies) and clean from packages that are no longer required, but also make sure that updates don't break things like linked libraries. To achive this quite a few things have to be done seperately; sync, update, etc-update (if applicable), depclean and revdep-rebuild. That can be an arduous task so I made a script which does it all for me, which I'd like to share. Maybe others think this is useful to them too, and any input if things could be done better would be welcome too :).

It's not an advanced script, but it handles the following things:
1. Check for last sync time and only sync if the portage tree when it has not been synched in the past 24 hours (can be overridden with --sync or --no-sync).
2. Run "emerge -uvDNa --with-bdeps=y @world" to update the system, including new USE flags, checking the whole dependency tree and including build time dependencies for the entire @world tree.
3. Run "etc-update" to update any configuration files (if applicable).
4. Run "emerge -ca" to clean obsolete packages.
5. Check for preserved/old libraries (this script checks for preserved libraries and if present runs emerge @preserved-rebuild, after that it does an extra check for remaining old libraries which is a leftover from before the preserve-libs feature was added to portage).
6. Run "revdep-rebuild" to make sure everything is still linked properly.
7. Run "eclean-dist --destructive" to free up space and keep /usr/portage/distfiles/ in check.

I use eix to sync the portage tree (provided by app-portage/eix) and eclean-dist to clean emerge downloads (provided by app-portage/gentoolkit), but that can of course be changed in the script. The script aborts if any of the steps results in an error. Note that you should always carefully examine anything done by emerge, all emerge commands include --ask, but I'm not responsible if you break your system :). Placing the files in /usr/local/sbin should do the trick. If you like to skip some steps or have stuff done differently feel free to change the scripts as you see fit.

gentoo-update
oldlib-check

Hopefully it's useful to others and/or people have tips/suggestions to improve the script(s) :).

Sincerely,

SunMar.
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 3639
Location: The Peanut Gallery

PostPosted: Fri Nov 28, 2014 11:50 am    Post subject: Reply with quote

Hey SunMar,

I know how you feel; I started a script to wrap portage as an exercise in learning bash, in late 2006/early 2007. It's quite a monster now, but very handy. (I would have split it more, but I wanted to see whether BASH would fall over, on a 32-bit machine; it never did.)

One thing I'd say is: don't use backticks for command substitution. $(..) has been in POSIX since at least 1996, and is recommended as the default method in #bash on IRC: chat.freenode.net which I highly recommend to you.

I'd be interested to know what you think of update; if there's something you'd like added that it doesn't currently do. For example eclean et al are left as separate processes, since we don't do them very often, but some of your description sounds quite nice.

Oh, you should know about BASH arithmetic context too; if ((sync)); then for example, is quicker than using [[ $sync -eq 1 ]] ime.

Good luck with your journey in BASH scripting :-)

Regards,
steveL.
Back to top
View user's profile Send private message
krinn
Advocate
Advocate


Joined: 02 May 2003
Posts: 4741

PostPosted: Fri Nov 28, 2014 11:59 am    Post subject: Reply with quote

Code:
find /lib32/ /usr/lib32/ /lib64/ /usr/lib64/ -type f -name '*.so*' \

you know x86 system just doesn't have any of these dir?
Back to top
View user's profile Send private message
SunMar
n00b
n00b


Joined: 15 Nov 2004
Posts: 30
Location: The Netherlands

PostPosted: Fri Nov 28, 2014 12:43 pm    Post subject: Reply with quote

steveL wrote:
Hey SunMar,

I know how you feel; I started a script to wrap portage as an exercise in learning bash, in late 2006/early 2007. It's quite a monster now, but very handy. (I would have split it more, but I wanted to see whether BASH would fall over, on a 32-bit machine; it never did.)

One thing I'd say is: don't use backticks for command substitution. $(..) has been in POSIX since at least 1996, and is recommended as the default method in #bash on IRC: chat.freenode.net which I highly recommend to you.

I'd be interested to know what you think of update; if there's something you'd like added that it doesn't currently do. For example eclean et al are left as separate processes, since we don't do them very often, but some of your description sounds quite nice.

Oh, you should know about BASH arithmetic context too; if ((sync)); then for example, is quicker than using [[ $sync -eq 1 ]] ime.

Good luck with your journey in BASH scripting :-)

Regards,
steveL.


Thank you for the input! Is the website and the forum thread the same, or is one outdated? Definitately going to look into that when I have time.

krinn wrote:
you know x86 system just doesn't have any of these dir?


Thank you for the reply. I'm aware that those lib dirs are not always available, but for now I'm the only one using the script, if other people use the script I wouldn't mind making it less specific to my configuration. But I'm going to look into steve's update script first :).
Back to top
View user's profile Send private message
AaylaSecura
Tux's lil' helper
Tux's lil' helper


Joined: 09 Jun 2011
Posts: 78
Location: Coruscant

PostPosted: Fri Nov 28, 2014 1:17 pm    Post subject: Reply with quote

SunMar wrote:
I'm aware that those lib dirs are not always available, but for now I'm the only one using the script, if other people use the script I wouldn't mind making it less specific to my configuration.

I think you should do that before making the script available for others to use. Plus, someone correct me if I'm wrong, but isn't it as simple as replacing:
Code:
find /lib32/ /usr/lib32/ /lib64/ /usr/lib64/ -type f -name '*.so*'

with:
Code:
lib_dirs=$(ls -d /lib32 \
    /lib64 \
    /$(readlink /lib || echo lib) \
    /usr/lib32 \
    /usr/lib64 \
    /usr/$(readlink /usr/lib || echo lib) \
    2>/dev/null \
    | sort -u)

find $lib_dirs -type f -name '*.so*'


Some remarks:

* instead of:
Code:
find /lib32/ /usr/lib32/ /lib64/ /usr/lib64/ -type f -name '*.so*' \
    | grep -v 'so$' \

why not:
Code:
find /lib32/ /usr/lib32/ /lib64/ /usr/lib64/ -type f -name '*.so?*' \

or even:
Code:
find /lib32/ /usr/lib32/ /lib64/ /usr/lib64/ -type f -name '*.so.*' \


* also, instead of:
Code:
find /lib32/ /usr/lib32/ /lib64/ /usr/lib64/ -type f -name '*.so.*' \
    | sed 's/\.so.*//' \
    | sort \
    > /tmp/duplib1.$$
sort -u < /tmp/duplib1.$$ > /tmp/duplib2.$$

why not:
Code:
find /lib32/ /usr/lib32/ /lib64/ /usr/lib64/ -type f -name '*.so.*' \
    | sed 's/\.so.*//' \
    | sort \
    | tee /tmp/duplib1.$$ \
    | sort -u > /tmp/duplib2.$$


* instead of:
Code:
check=`diff /tmp/duplib1.$$ /tmp/duplib2.$$ \
    | grep '^<' \
    | sed -e 's/^< /ls -1 /' -e 's/$/.so*/' \
    | sh`

why not:
Code:
check=$(ls -1 \
   $(comm -23 /tmp/duplib1.$$ /tmp/duplib2.$$ \
   | sed -e 's/$/.so*/'))
Back to top
View user's profile Send private message
steveL
Advocate
Advocate


Joined: 13 Sep 2006
Posts: 3639
Location: The Peanut Gallery

PostPosted: Fri Nov 28, 2014 7:18 pm    Post subject: Reply with quote

SunMar wrote:
Is the website and the forum thread the same, or is one outdated? Definitely going to look into that when I have time.

Cool :) Same thing, forum is where it started and we occasionally discuss issues; use the git ebuild though, as the other one is two years old. Will likely push a "release" when --toolchain is working fine (in flux atm) and nothing's changed for a bit.

Don't forget: #bash are your (sometimes grumpy) friends. ;)
Back to top
View user's profile Send private message
relvar
n00b
n00b


Joined: 03 Oct 2014
Posts: 4

PostPosted: Mon Dec 29, 2014 4:19 am    Post subject: Update script Reply with quote

I use this:

[code]
#!/bin/bash

# update portage and world if needed

source /etc/profile;

stamp="/usr/portage/metadata/timestamp.x"
if [ -f "$stamp" ]
then
rm /usr/portage/metadata/timestamp.x
fi

emerge-webrsync &&
emerge --update --deep --with-bdeps=y @world &&
emerge --depclean &&
revdep-rebuild &&
eclean -d distfiles &&

exit 0
[/code]
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