2

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.

Markon
  • 143
  • 1
  • 1
  • 7

1 Answers1

3

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.

Fbo
  • 893
  • 5
  • 7