Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm writing a Python system script and I need to be notified when a program gets installed/upgraded/removed.

First of all, I thought to interface my application to an apt-dbus daemon. Unluckily I've not found it, and while I'm waiting for its implementation (and it can take a long time), I'm studying another method to do it.

So I've thought about pyinotify. Maybe I could be notified every time that the file/var/log/apt/history.log changes and then I'd just parse the added lines to get what I expected.

Can you suggest me another safe way to do it?

Thank you.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

It's not respond to all your requierements but it can help : Use Pre-Install-Pkgs, the command is just fired when installing, with dpkg, apt, aptitude :

cat /etc/apt/apt.conf.d/80user 
DPkg::Pre-Install-Pkgs {"logger ";}

In syslog :

Sep 10 22:08:35 Bart logger: /var/cache/apt/archives/scim-python-common_0.1.13~rc1-2build1_all.deb
Sep 10 22:08:35 Bart logger: /var/cache/apt/archives/python-scim_0.1.13~rc1-2build1_i386.deb
Sep 10 22:08:35 Bart logger: /var/cache/apt/archives/scim-python_0.1.13~rc1-2build1_i386.deb

You can replace logger with the command you want, like mail for example.

share|improve this answer
    
+! brilliant and useful! –  Michael Gorsuch Sep 10 '10 at 20:19
    
Pre-Remove-Pkgs or Pre-Upgrade-Pkgs does not seem exist ... –  Fbo Sep 10 '10 at 20:36
    
Thank you for your reply, but in the meanwhile I've applied what I said: read every line written when dpkg/apt is used, using pyinotify to be notified when history.log is modified/closed and so on. It works fine. –  Markon Sep 11 '10 at 11:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.