Posted by hruske on Thu 7 Jul 2005 at 01:40
Since dpkg only acquired logging facilities with version 1.13, which didn't make it to Sarge, I'm going to present a way to get package installation logged.
Apt has a nice configuration system, which in Debian is split among more files located in /etc/apt/apt.conf.d/. This can be very helpful when implementing simple logging.
If we put a file in the directory /etc/apt/apt.conf.d/ with following content:
DPkg::Pre-Install-Pkgs {"/usr/local/bin/log-apt-get ";};
Apt will then execute command /usr/local/bin/log-apt-get before installing every package. Apt also has similar configuration options such as DPkg::Pre-Invoke and DPkg::Post-Invoke, but these are not really suitable for logging, as only Pre-Install-Pkgs passes package name (path) on to command (to stdin).
Now we need to create the log-apt-get command to record the information:
#!/bin/bash
while read paket;
do echo $(date +'%b %e %R:%S') ${paket#/var/cache/apt/archives/} >> /var/log/apt-get.log;
done
Package installations are now logged in the following following format:
Jul 7 03:44:20 less_382-2_amd64.deb Jul 7 03:45:06 gzip_1.3.5-11_amd64.deb
NOTE: There are a few drawbacks. Since this is an Apt hack, it will only log installs made with Apt. If a package is installed directly with dpkg, it will not be logged. Also this is a much less verbose log compared to log made by dpkg version 1.13.
This log will also not contain entries for package removal.
(If you're using aptitude you can find it's logs located in the file /var/log/aptitude.
Downloading Debian Packages through a ProxyAnothing example of using the apt configuration files is to instruct apt-get to download packages via a proxy server.
Simply place the following into a file such as /etc/apt/apt.conf.d/proxy:
Acquire::http::Proxy "http://proxy:8080";
For an FTP proxy add a stanza like this, but be sure, to change only proxy hostname and port.
Acquire::ftp
{
Proxy "ftp://proxy:2121/";
ProxyLogin
{
"USER $(SITE_USER)@$(SITE)";
"PASS $(SITE_PASS)";
}
}
This article can be found online at the Debian Administration website at the following bookmarkable URL (along with associated comments):
This article is copyright 2005 hruske - please ask for permission to republish or translate.