Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Discussion & Documentation Documentation, Tips & Tricks
  • Search

Gentoo update script

Unofficial documentation for various parts of Gentoo Linux. Note: This is not a support forum.
Post Reply
Advanced search
8 posts • Page 1 of 1
Author
Message
SunMar
n00b
n00b
Posts: 33
Joined: Mon Nov 15, 2004 5:26 am
Location: The Netherlands

Gentoo update script

  • Quote

Post by SunMar » Fri Nov 28, 2014 11:02 am

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.
Top
steveL
Watchman
Watchman
Posts: 5153
Joined: Wed Sep 13, 2006 1:18 pm
Location: The Peanut Gallery

  • Quote

Post by steveL » Fri Nov 28, 2014 11:50 am

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 [topic=546828]update[/topic]; 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.
Top
krinn
Watchman
Watchman
User avatar
Posts: 7476
Joined: Fri May 02, 2003 6:14 am

  • Quote

Post by krinn » Fri Nov 28, 2014 11:59 am

Code: Select all

find /lib32/ /usr/lib32/ /lib64/ /usr/lib64/ -type f -name '*.so*' \
you know x86 system just doesn't have any of these dir?
Top
SunMar
n00b
n00b
Posts: 33
Joined: Mon Nov 15, 2004 5:26 am
Location: The Netherlands

  • Quote

Post by SunMar » Fri Nov 28, 2014 12:43 pm

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 [topic=546828]update[/topic]; 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 :).
Top
AaylaSecura
Tux's lil' helper
Tux's lil' helper
Posts: 122
Joined: Thu Jun 09, 2011 6:53 pm

  • Quote

Post by AaylaSecura » Fri Nov 28, 2014 1:17 pm

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: Select all

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

Code: Select all

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: Select all

find /lib32/ /usr/lib32/ /lib64/ /usr/lib64/ -type f -name '*.so*' \
    | grep -v 'so$' \
why not:

Code: Select all

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

Code: Select all

find /lib32/ /usr/lib32/ /lib64/ /usr/lib64/ -type f -name '*.so.*' \
* also, instead of:

Code: Select all

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: Select all

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: Select all

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

Code: Select all

check=$(ls -1 \
   $(comm -23 /tmp/duplib1.$$ /tmp/duplib2.$$ \
   | sed -e 's/$/.so*/'))
Top
steveL
Watchman
Watchman
Posts: 5153
Joined: Wed Sep 13, 2006 1:18 pm
Location: The Peanut Gallery

  • Quote

Post by steveL » Fri Nov 28, 2014 7:18 pm

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. ;)
Top
relvar
n00b
n00b
Posts: 6
Joined: Fri Oct 03, 2014 3:29 am

Update script

  • Quote

Post by relvar » Mon Dec 29, 2014 4:19 am

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]
Top
jamtat
Apprentice
Apprentice
Posts: 162
Joined: Sat Aug 09, 2003 3:33 pm

  • Quote

Post by jamtat » Thu Jul 09, 2015 2:23 am

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-7 ... ml#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 ).
Top
Post Reply

8 posts • Page 1 of 1

Return to “Documentation, Tips & Tricks”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic