[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#957: log patch for dpkg



tags 957 +patch
thanks

I write a patch for dpkg to add a log file /var/log/dpkg for all
'install', 'remove' and 'purges' of packages.

Gruss
Grisu
-- 
Michael Bramer  -  a Debian Linux Developer      http://www.debsupport.de
PGP: finger grisu@db.debian.org  -- Linux Sysadmin   -- Use Debian Linux
Free Software is like sex: You don't know what you're missing until
you've tried it.
diff -ru dpkg-1.10.21/debian/changelog dpkg-1.10.21.1/debian/changelog
--- dpkg-1.10.21/debian/changelog	2004-04-25 19:57:38.000000000 +0200
+++ dpkg-1.10.21.1/debian/changelog	2004-06-03 06:40:26.000000000 +0200
@@ -1,3 +1,9 @@
+dpkg (1.10.21.1) unstable; urgency=low
+
+  * add writelog in dpkg
+
+ -- Michael Bramer <grisu@debian.org>  Thu,  3 Jun 2004 06:39:46 +0200
+
 dpkg (1.10.21) unstable; urgency=low
 
   * Fix incorrect linked list node removal code that caused every second
diff -ru dpkg-1.10.21/main/help.c dpkg-1.10.21.1/main/help.c
--- dpkg-1.10.21/main/help.c	2003-10-25 22:03:21.000000000 +0200
+++ dpkg-1.10.21.1/main/help.c	2004-06-03 06:55:52.000000000 +0200
@@ -403,6 +403,21 @@
   putc('\n',stderr);
 }
 
+void writelog(const char *fmt, ...) {
+  va_list ap;
+  FILE *logf;
+
+  logf= fopen("/var/log/dpkg","a");
+  if (!logf)
+    ohshite(_("unable to create log file"));
+  fprintf(logf,"%d: ",time(0));
+  va_start(ap,fmt);
+  vfprintf(logf,fmt,ap);
+  va_end(ap);
+  putc('\n',logf);
+  fclose(logf);
+}
+
 int isdirectoryinuse(struct filenamenode *file, struct pkginfo *pkg) {
   /* Returns 1 if the file is used by packages other than pkg, 0 otherwise. */
   struct filepackages *packageslump;
diff -ru dpkg-1.10.21/main/main.h dpkg-1.10.21.1/main/main.h
--- dpkg-1.10.21/main/main.h	2002-05-20 07:56:02.000000000 +0200
+++ dpkg-1.10.21.1/main/main.h	2004-06-03 06:43:55.000000000 +0200
@@ -212,6 +212,8 @@
 void debug(int which, const char *fmt, ...) PRINTFFORMAT(2,3);
 void check_libver(void);
 
+void writelog(const char *fmt, ...); 
+
 /* from depcon.c */
 
 int depisok(struct dependency *dep, struct varbuf *whynot,
diff -ru dpkg-1.10.21/main/processarc.c dpkg-1.10.21.1/main/processarc.c
--- dpkg-1.10.21/main/processarc.c	2004-03-08 19:37:03.000000000 +0100
+++ dpkg-1.10.21.1/main/processarc.c	2004-06-03 16:51:27.000000000 +0200
@@ -279,13 +279,19 @@
   ensure_allinstfiles_available();
   filesdbinit();
   
-  if (pkg->status != stat_notinstalled && pkg->status != stat_configfiles)
+  if (pkg->status != stat_notinstalled && pkg->status != stat_configfiles) {
     printf(_("Preparing to replace %s %s (using %s) ...\n"),
            pkg->name,
            versiondescribe(&pkg->installed.version,vdew_nonambig),
            pfilename);
-  else
+    if (!f_noact) 
+      writelog("%s: replacing %s %s",pkg->name,versiondescribe(&pkg->installed.version,vdew_nonambig),versiondescribe(&pkg->available.version,vdew_nonambig));
+  } else {
     printf(_("Unpacking %s (from %s) ...\n"),pkg->name,pfilename);
+    if (!f_noact) 
+      writelog("%s: unpacking %s %s",pkg->name,versiondescribe(&pkg->available.version,vdew_nonambig));
+  }
+
 
   if (f_noact) {
     pop_cleanup(ehflag_normaltidy);
diff -ru dpkg-1.10.21/main/remove.c dpkg-1.10.21.1/main/remove.c
--- dpkg-1.10.21/main/remove.c	2004-03-12 21:25:18.000000000 +0100
+++ dpkg-1.10.21.1/main/remove.c	2004-06-03 16:59:45.000000000 +0200
@@ -162,6 +162,9 @@
   oldconffsetflags(pkg->installed.conffiles);
     
   printf(_("Removing %s ...\n"),pkg->name);
+  if (!f_noact) 
+    writelog("%s: removing %s",pkg->name,versiondescribe(&pkg->installed.version,vdew_nonambig));
+
   if (pkg->status == stat_halfconfigured || pkg->status == stat_installed) {
 
     if (pkg->status == stat_installed || pkg->status == stat_halfconfigured) {
@@ -390,6 +393,8 @@
   char *p;
   const char *const *ext;
 
+    if (!f_noact) 
+      writelog("%s: purging %s %s",pkg->name,versiondescribe(&pkg->installed.version,vdew_nonambig));
     printf(_("Purging configuration files for %s ...\n"),pkg->name);
     ensure_packagefiles_available(pkg); /* We may have modified this above. */
 

Reply to: