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: 33
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
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
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
Watchman
Watchman


Joined: 02 May 2003
Posts: 7470

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: 33
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: 122

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
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
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: 6

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
jamtat
Apprentice
Apprentice


Joined: 09 Aug 2003
Posts: 162

PostPosted: Thu Jul 09, 2015 2:23 am    Post subject: Reply with quote

I'm looking for something like this script in hopes I can set up a regular, semi-automated update/upgrade routine similar to the one I run on my Arch system (see my thread about that at https://forums.gentoo.org/viewtopic-p-7776432.html#7776432 ). Are the scripts described in the OP being maintained and improved? Or is this more of a one-shot, proof-of-concept type thing? Thanks.

LATER EDIT Also, btw, is the only purpose of oldlib-check to make certain that emerge @preserved-rebuild doesn't get run unecessarily? So the script described in the OP would, if that were the case, be superior to the script offered just above this post (by relvar) in that that latter runs emerge @preserved-rebuild regardless, while the former only runs it when needed?

YET LATER EDIT
jamtat wrote:
is the only purpose of oldlib-check to make certain that emerge @preserved-rebuild doesn't get run unecessarily?

I'm afraid you've confused the emerge @preserved-rebuild command with the revdep-rebuild command: those two commands do related, but slightly different, things (see https://wiki.gentoo.org/wiki/Preserve-libs ).
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