You are not logged in.

#1 2012-03-15 18:42:21

lebel
Member
Registered: 2011-11-08
Posts: 9

[SOLVED] Displaying updated packages

I know that when I'm on the shell I can use pacman or yaourt to update my system, I can see if there is any new packages and update them. What I would like is a way to receive a daily email showing updated packages so I can remotely log on the server and update the system if I judge the updates important enough.

I already do a similar thing on my FreeBSD boxes (I'm more of a BSD guy than a Linux one, but I digress).

While thinking more about it, would something like this work:

pacman -Syy >/dev/null | yaourt --query --upgrades --aur

EDIT: Solution: see my last post in this thread.

Last edited by lebel (2012-03-16 01:07:36)

Offline

#2 2012-03-15 19:17:12

wolfcore
Member
From: California
Registered: 2012-03-06
Posts: 137

Re: [SOLVED] Displaying updated packages

A quick search turned up this, which needs some tweaking to generate emails, but it's close to what you want.

Offline

#3 2012-03-15 19:19:38

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Displaying updated packages

Have a look at http://www.andreascarpino.it/blog/posts … s-part-ii/ too.


Edit: wrt to e-mails, I suggest something lightweight, like mailx:

echo "$(<your command goes here>)" | mailx -s "daily update" your.mail@gmail.com

Last edited by karol (2012-03-15 19:26:33)

Offline

#4 2012-03-15 19:43:50

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [SOLVED] Displaying updated packages

There's no reason to use "pacman -Syy" in that script. It just wastes bandwidth. One "-y" is enough.

Btw, can't yaourt update the database on it's own?


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#5 2012-03-15 19:46:50

lebel
Member
Registered: 2011-11-08
Posts: 9

Re: [SOLVED] Displaying updated packages

I think I might have made it to work and do what I want, I have the following in my cronjob:

(yaourt -Sy >/dev/null && yaourt -Qu --aur) | mailx -E -s "ozone.mydomain.com: new packages" root@mydomain.com

And it works just fine and right now only display:

extra/libsocialweb 0.25.20-0

Offline

#6 2012-03-15 20:07:26

keenerd
Package Maintainer (PM)
Registered: 2007-02-22
Posts: 647
Website

Re: [SOLVED] Displaying updated packages

There is also no reason to use -Sy at all, because it makes it too easy to break your system.  Try Xyne's python based update notifier, it does the correct thing.  Or checkupdates, which is bash based.  (And will be in contrib once I get emailing patches sorted out.)  There is also cron-pacmatic as part of the pacmatic package, which reports updates and a few other things too.

Offline

#7 2012-03-15 20:25:32

lebel
Member
Registered: 2011-11-08
Posts: 9

Re: [SOLVED] Displaying updated packages

keenerd wrote:

There is also no reason to use -Sy at all, because it makes it too easy to break your system.

Why?  With yaourt (or pacman) -Sy, only the database of the packages are updated, if need be. Two "y" would download the database for each repo even tho they weren't modified.

The following generate a proper simple output of the out of date packages.

(yaourt -Sy >/dev/null && yaourt -Qu --aur) | sort | mailx -E -s "cumulus.mydomain.com: new packages" root@mydomain.com

The output is even sorted.

(eg. the current output on one of my machine is:

aur/dnscrypt-proxy 0.9.3-1
core/bash 4.2.024-1
core/libedit 20120311_3.0-1
core/mkinitcpio 0.8.4-1
core/mkinitcpio-busybox 1.19.4-2
core/sudo 1.8.4.p4-1
core/udev 181-4
core/usbutils 005-1
core/util-linux 2.21-5
extra/lua 5.1.5-1

Offline

#8 2012-03-15 20:42:38

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Displaying updated packages

If you run 'pacman -Sy' and then 'pacman -S foo' you might run into some issues. The whole point of the script is to update only when needed and I'm not sure if you will remember to run 'pacman -Su' / 'pacman -Syu' before installing new packages.
That's why you should use e.g. a fake db instead of the regular one.

Offline

#9 2012-03-15 20:48:58

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [SOLVED] Displaying updated packages

lebel wrote:
keenerd wrote:

There is also no reason to use -Sy at all, because it makes it too easy to break your system.

Why?  With yaourt (or pacman) -Sy, only the database of the packages are updated, if need be. Two "y" would download the database for each repo even tho they weren't modified.

When you run "pacman -Sy", you download the latest database files. After that point, any packages that you install will be the latest versions. If you don't run "pacman -Su" first, then you may install a new package without updating one of the libraries that it depends on, which may break the package. That is why it is recommended to always run "pacman -Syu". It makes sure that you always have consistent dependencies.

Or course, if you know for sure that you will never install a package without running "pacman -u" first, then it doesn't matter. If that is not the case, it would be better to create a separate directory, symlink "/var/lib/pacman/local" into that directory, and then use that directory as the database directory in your scripts (pacman -Syb /path/to/dir). That way, the system database is not affected. To save further bandwidth, you can just copy the downloaded databases in the alternative database directory into the default database directory when you want to update the system databases.

Last edited by Xyne (2012-03-15 20:50:16)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#10 2012-03-15 20:50:24

lebel
Member
Registered: 2011-11-08
Posts: 9

Re: [SOLVED] Displaying updated packages

karol wrote:

If you run 'pacman -Sy' and then 'pacman -S foo' you might run into some issues. The whole point of the script is to update only when needed and I'm not sure if you will remember to run 'pacman -Su' / 'pacman -Syu' before installing new packages.
That's why you should use e.g. a fake db instead of the regular one.

Well, I know the way it works in Archlinux is that you should be sure that your whole system is updated before installing new packages. The purpose of this script is to be aware that new packages are available on specific servers so I can go and update the system if need be (and before I need to install any new things).

Offline

#11 2012-03-15 20:53:06

lebel
Member
Registered: 2011-11-08
Posts: 9

Re: [SOLVED] Displaying updated packages

Xyne wrote:

Or course, if you know for sure that you will never install a package without running "pacman -u" first, then it doesn't matter. If that is not the case, it would be better to create a separate directory, symlink "/var/lib/pacman/local" into that directory, and then use that directory as the database directory in your scripts (pacman -Syb /path/to/dir). That way, the system database is not affected. To save further bandwidth, you can just copy the downloaded databases in the alternative database directory into the default database directory when you want to update the system databases.

You have a really good point here. If I were to keep that "temporary/permanent local" directory on the system and always work from there, it wouldn't messes with the "production/real" pacman database and still show me what I want. Thank you for the precision. I hope I get it correctly.

Offline

#12 2012-03-15 20:53:09

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Displaying updated packages

It's your system and it's up to you to employ a simple but a bit risky way of doing things.
https://bbs.archlinux.org/viewtopic.php?id=89328 is 2-years old but still should give plenty info on this subject.

Offline

#13 2012-03-15 21:19:39

lebel
Member
Registered: 2011-11-08
Posts: 9

Re: [SOLVED] Displaying updated packages

karol wrote:

It's your system and it's up to you to employ a simple but a bit risky way of doing things.
https://bbs.archlinux.org/viewtopic.php?id=89328 is 2-years old but still should give plenty info on this subject.

My new cronjob looks like this now:

(rsync -a /var/lib/pacman/. /var/lib/pacman.local && pacman -Sy -b /var/lib/pacman.local >/dev/null && yaourt -Qu --aur -b /var/lib/pacman.local) | sort | mailx -E -s "cumulus.mydomain.com: new packages" root@mydomain.com

It copies the content of the current "production" database into /var/lib/pacman.local, update it with -Sy and then check if there is new packages available without ever touching the current system database.

Is this more sensible?

Offline

#14 2012-03-16 12:11:49

lebel
Member
Registered: 2011-11-08
Posts: 9

Re: [SOLVED] Displaying updated packages

lebel wrote:
(rsync -a /var/lib/pacman/. /var/lib/pacman.local && pacman -Sy -b /var/lib/pacman.local >/dev/null && yaourt -Qu --aur -b /var/lib/pacman.local) | sort | mailx -E -s "cumulus.mydomain.com: new packages" root@mydomain.com

It copies the content of the current "production" database into /var/lib/pacman.local, update it with -Sy and then check if there is new packages available without ever touching the current system database.

Is this more sensible?

Looks like -b on yaourt doesn't work as with pacman, so it doesn't use the "copy" of the database I made with rsync.

Offline

#15 2012-03-16 18:55:09

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: [SOLVED] Displaying updated packages

If you know Python, you could easily modify the display function of Paconky to return the list of upgradable repo and AUR packages.

Another approach would be to just rsync the server's local database to your system and check it locally for updates.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

Board footer

Powered by FluxBB