After some thoughts I comeup with the delta introducing
Post-Install-Pkgs. Now apt-get will pass names of the packages passed
to dpkg command to the Post-Install-Pkgs hook. I would prefere this to
be the names of packages successfully executed by dpkg, but this will
require elimination of "the same operation in a row" optimization (via
J itterator). I suspect you won't like it in my code. :o) But, if by
some chance you don't mind me doing this I can send you the delta
eleminating the optimization and collecting names of the packages in
the right place.

Hope you like it.
Igor

diff -ru apt-0.5.3.orig/apt-pkg/deb/dpkgpm.cc apt-0.5.3/apt-pkg/deb/dpkgpm.cc
--- apt-0.5.3.orig/apt-pkg/deb/dpkgpm.cc        Mon Feb 26 23:14:22 2001
+++ apt-0.5.3/apt-pkg/deb/dpkgpm.cc     Sat Aug 11 23:20:57 2001
@@ -147,7 +147,7 @@
 // ---------------------------------------------------------------------
 /* This is part of the helper script communication interface, it sends
    very complete information down to the other end of the pipe.*/
-bool pkgDPkgPM::SendV2Pkgs(FILE *F)
+bool pkgDPkgPM::SendV2Pkgs(FILE *F, vector<Item>& PkgList)
 {
    fprintf(F,"VERSION 2\n");
    
@@ -177,7 +177,7 @@
    fprintf(F,"\n");
  
    // Write out the package actions in order.
-   for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+   for (vector<Item>::iterator I = PkgList.begin(); I != PkgList.end(); I++)
    {
       pkgDepCache::StateCache &S = Cache[I->Pkg];
       
@@ -232,7 +232,7 @@
 /* This looks for a list of scripts to run from the configuration file
    each one is run and is fed on standard input a list of all .deb files
    that are due to be installed. */
-bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
+bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf, vector<Item>& PkgList)
 {
    Configuration::Item const *Opts = _config->Tree(Cnf);
    if (Opts == 0 || Opts->Child == 0)
@@ -288,7 +288,7 @@
       bool Die = false;
       if (Version <= 1)
       {
-        for (vector<Item>::iterator I = List.begin(); I != List.end(); I++)
+        for (vector<Item>::iterator I=PkgList.begin(); I!=PkgList.end(); I++)
         {
            // Only deal with packages to be installed from .deb
            if (I->Op != Item::Install)
@@ -309,7 +309,7 @@
         }
       }
       else
-        Die = !SendV2Pkgs(F);
+        Die = !SendV2Pkgs(F, PkgList);
 
       fclose(F);
       if (Die == true)
@@ -333,10 +333,12 @@
 /* This globs the operations and calls dpkg */
 bool pkgDPkgPM::Go()
 {
+   vector<Item> PkgList;
+
    if (RunScripts("DPkg::Pre-Invoke") == false)
       return false;
 
-   if (RunScriptsWithPkgs("DPkg::Pre-Install-Pkgs") == false)
+   if (RunScriptsWithPkgs("DPkg::Pre-Install-Pkgs", List) == false)
       return false;
 
    for (vector<Item>::iterator I = List.begin(); I != List.end();)
@@ -408,6 +410,7 @@
               return _error->Error("Internal Error, Pathname to install is not 
absolute '%s'",I->File.c_str());
            Args[n++] = I->File.c_str();
            Size += strlen(Args[n-1]);
+           PkgList.push_back(Item(I->Op, I->Pkg, I->File));
         }
       }      
       else
@@ -416,6 +419,7 @@
         {
            Args[n++] = I->Pkg.Name();
            Size += strlen(Args[n-1]);
+           PkgList.push_back(Item(I->Op, I->Pkg));
         }       
       }      
       Args[n] = 0;
@@ -479,6 +483,7 @@
       {
         if (errno == EINTR)
            continue;
+        RunScriptsWithPkgs("DPkg::Post-Install-Pkgs", PkgList);
         RunScripts("DPkg::Post-Invoke");
         return _error->Errno("waitpid","Couldn't wait for subprocess");
       }
@@ -490,6 +495,7 @@
       // Check for an error code.
       if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
       {
+        RunScriptsWithPkgs("DPkg::Post-Install-Pkgs", PkgList);
         RunScripts("DPkg::Post-Invoke");
         if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV)
            return _error->Error("Sub-process %s received a segmentation 
fault.",Args[0]);
@@ -501,9 +507,11 @@
       }      
    }
 
+   bool result = RunScriptsWithPkgs("DPkg::Post-Install-Pkgs", PkgList);
+
    if (RunScripts("DPkg::Post-Invoke") == false)
       return false;
-   return true;
+   return result;
 }
                                                                        /*}}}*/
 // pkgDpkgPM::Reset - Dump the contents of the command list            /*{{{*/
diff -ru apt-0.5.3.orig/apt-pkg/deb/dpkgpm.h apt-0.5.3/apt-pkg/deb/dpkgpm.h
--- apt-0.5.3.orig/apt-pkg/deb/dpkgpm.h Tue Feb 20 02:03:17 2001
+++ apt-0.5.3/apt-pkg/deb/dpkgpm.h      Sat Aug 11 23:00:53 2001
@@ -36,8 +36,8 @@
 
    // Helpers
    bool RunScripts(const char *Cnf);
-   bool RunScriptsWithPkgs(const char *Cnf);
-   bool SendV2Pkgs(FILE *F);
+   bool RunScriptsWithPkgs(const char *Cnf, vector<Item>& PkgList);
+   bool SendV2Pkgs(FILE *F, vector<Item>& PkgList);
    
    // The Actuall installation implementation
    virtual bool Install(PkgIterator Pkg,string File);

Reply via email to