Check Gentoo updates and notify


Please note that this blog has been moved.

Now it has its own domain: mynixworld.info🙂

If you want to read the latest version of this article (recommended) please click here and I open the page for you.

In Gentoo, to update your portage tree to the latest version one can do:

emerge –sync

In Gentoo, to fetch and merge the latest available packages into your system one can do:

emerge -pvDuN world

emerge -DuN world

In Gentoo, to remove the unnecessary dependencies that might remain and must to be removed one can do:

emerge -p –depclean

emerge –depclean

In Gentoo, to rebuild the missing dependencies one can do:

revdep-rebuild -pv

revdep-rebuild

In Gentoo, sometimes you need to update some configuration files after an package update. One can do that by:

dispatch-conf

In Gentoo, is sometimes also necessary to handle the new configuration files, so one can do:

etc-update

Many things can be done in Gentoo. That’s why for me Gentoo means power. BUT I like to do Gentoo in my own way so I wrote a little daemon (sync-emerge) which synchronize (once, in background) the portage tree at system start-up and a second bash script (which start once at session start-up) that check if exists new packages are available to be merged and if there are then send a balloon notification on the desktop informing user about that.

Later you can emerge those new packages by traditional means (emerge is your friend).

The daemon (sync-emerge):

 #!/sbin/runscript

opts="reload"

depend() {
after net
}

start() {
ebegin "Starting to synchronize the portage tree"
emerge --sync 1>/dev/null
eend $?
return 0
}

stop() {
ebegin "Stopping the sync-emerge daemon"
eend $?
return 0
}

reload() {
ebegin "Reloading sync-emerge"
eend $?

start
}

Copy this daemon at /etc/init.d/sync-emerge and configure your system to start it at start-up:

rc-update add sync-emerge default

The session bash script (check-emerge):

#!/bin/bash

while [ -n "$(/etc/init.d/sync-emerge status|awk '/starting/ {print 1}')" ];do
sleep 10 #wait 5 minutes, until the X daemon will synchronize the emerge database
done

NEWS=$(emerge -pvDuN world|awk '/\[ebuild/ {if ($2=="U") {u++}; if ($2=="R") {r++}; if ($2=="D") {d++}; if($2=="F"){f++}; if($2=="I"){i++}; if($2=="B"){b++};} END {total=u+r+d+f+i+b; if(total>0){ print total" package available for update :"; if (u>0) {print " - updating : "u}; if (r>0){print " - replacing : "r};if(d>0){print " - downgrading : "d};if(f>0){print " - fetch restricted : "f};if(i>0){print " - interactive : "i};if(b>0){print " - blocked : "b};}}')

if [ -n "$NEWS" ];then
notify-send -i "/usr/share/icons/Tango/48x48/status/dialog-information.png" "Update available" "$NEWS"
fi

If you are using Xfce then you can go into Settings -> Session and Startup -> Application Autostart and define a new startup application like:

  • name=check-emerge
  • command=[path-to]/check-emerge

where [path-to] is the path to check-emerge bash script.

Note: don’t forget to set both scripts as executable (chmod +x <file>)

About Eugen Mihailescu

Always looking to learn more about *nix world, about the fundamental concepts of arithmetic, algebra and geometry. I am also passionate about programming, database and systems administration.
This entry was posted in linux and tagged , , . Bookmark the permalink.

2 Responses to Check Gentoo updates and notify

  1. Sean Lijek says:

    If I turn off my computer before I go out somewhere, and turn it back on, can’t I get in trouble if I sync the portage tree more than once per day?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s