Просмотр исходного кода

Change history branch so that it does not break the
apt ABI for the pkgPackageManager interface
(can be reverted on the next ABI break)

Michael Vogt лет назад: 16
Родитель
Сommit
a29b2c0b9c
4 измененных файлов с 37 добавлено и 15 удалено
  1. 23 11
      apt-pkg/deb/dpkgpm.cc
  2. 1 3
      apt-pkg/deb/dpkgpm.h
  3. 5 1
      apt-pkg/packagemanager.h
  4. 8 0
      debian/changelog

+ 23 - 11
apt-pkg/deb/dpkgpm.cc

@@ -562,7 +562,7 @@ void pkgDPkgPM::DoDpkgStatusFd(int statusfd, int OutStatusFd)
 }
 }
 									/*}}}*/
 									/*}}}*/
 // DPkgPM::WriteHistoryTag						/*{{{*/
 // DPkgPM::WriteHistoryTag						/*{{{*/
-void pkgDPkgPM::WriteHistoryTag(string tag, string value)
+void pkgDPkgPM::WriteHistoryTag(FILE *history_out, string tag, string value)
 {
 {
    if (value.size() > 0)
    if (value.size() > 0)
    {
    {
@@ -602,7 +602,7 @@ bool pkgDPkgPM::OpenLog()
 				   _config->Find("Dir::Log::History"));
 				   _config->Find("Dir::Log::History"));
    if (!history_name.empty())
    if (!history_name.empty())
    {
    {
-      history_out = fopen(history_name.c_str(),"a");
+      FILE *history_out = fopen(history_name.c_str(),"a");
       chmod(history_name.c_str(), 0644);
       chmod(history_name.c_str(), 0644);
       fprintf(history_out, "\nStart-Date: %s\n", timestr);
       fprintf(history_out, "\nStart-Date: %s\n", timestr);
       string remove, purge, install, upgrade, downgrade;
       string remove, purge, install, upgrade, downgrade;
@@ -622,12 +622,12 @@ bool pkgDPkgPM::OpenLog()
 	       remove += I.Name() + string(" (") + Cache[I].CurVersion + string("), ");	    
 	       remove += I.Name() + string(" (") + Cache[I].CurVersion + string("), ");	    
 	 }
 	 }
       }
       }
-      WriteHistoryTag("Install", install);
-      WriteHistoryTag("Upgrade", upgrade);
-      WriteHistoryTag("Downgrade",downgrade);
-      WriteHistoryTag("Remove",remove);
-      WriteHistoryTag("Purge",purge);
-      fflush(history_out);
+      WriteHistoryTag(history_out, "Install", install);
+      WriteHistoryTag(history_out, "Upgrade", upgrade);
+      WriteHistoryTag(history_out, "Downgrade",downgrade);
+      WriteHistoryTag(history_out, "Remove",remove);
+      WriteHistoryTag(history_out, "Purge",purge);
+      fclose(history_out);
    }
    }
    
    
    return true;
    return true;
@@ -650,10 +650,11 @@ bool pkgDPkgPM::CloseLog()
    }
    }
    term_out = NULL;
    term_out = NULL;
 
 
-   if(history_out)
+   string history_name = flCombine(_config->FindDir("Dir::Log"),
+				   _config->Find("Dir::Log::History"));
+   if (!history_name.empty())
    {
    {
-      if (dpkg_error.size() > 0)
-	 fprintf(history_out, "Error: %s\n", dpkg_error.c_str());
+      FILE *history_out = fopen(history_name.c_str(),"a");
       fprintf(history_out, "End-Date: %s\n", timestr);
       fprintf(history_out, "End-Date: %s\n", timestr);
       fclose(history_out);
       fclose(history_out);
    }
    }
@@ -1125,6 +1126,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 	 if(stopOnError)
 	 if(stopOnError)
 	    RunScripts("DPkg::Post-Invoke");
 	    RunScripts("DPkg::Post-Invoke");
 
 
+	 string dpkg_error;
 	 if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV) 
 	 if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV) 
 	    strprintf(dpkg_error, "Sub-process %s received a segmentation fault.",Args[0]);
 	    strprintf(dpkg_error, "Sub-process %s received a segmentation fault.",Args[0]);
 	 else if (WIFEXITED(Status) != 0)
 	 else if (WIFEXITED(Status) != 0)
@@ -1133,7 +1135,17 @@ bool pkgDPkgPM::Go(int OutStatusFd)
 	    strprintf(dpkg_error, "Sub-process %s exited unexpectedly",Args[0]);
 	    strprintf(dpkg_error, "Sub-process %s exited unexpectedly",Args[0]);
 
 
 	 if(dpkg_error.size() > 0)
 	 if(dpkg_error.size() > 0)
+	 {
 	    _error->Error(dpkg_error.c_str());
 	    _error->Error(dpkg_error.c_str());
+	    string history_name = flCombine(_config->FindDir("Dir::Log"),
+					    _config->Find("Dir::Log::History"));
+	    if (!history_name.empty())
+	    {
+	       FILE *history_out = fopen(history_name.c_str(),"a");
+	       fprintf(history_out, "Error: %s\n", dpkg_error.c_str());
+	       fclose(history_out);
+	    }
+	 }
 
 
 	 if(stopOnError) 
 	 if(stopOnError) 
 	 {
 	 {

+ 1 - 3
apt-pkg/deb/dpkgpm.h

@@ -29,8 +29,6 @@ class pkgDPkgPM : public pkgPackageManager
    char dpkgbuf[1024];
    char dpkgbuf[1024];
    int dpkgbuf_pos;
    int dpkgbuf_pos;
    FILE *term_out;
    FILE *term_out;
-   FILE *history_out;
-   string dpkg_error;
 
 
    protected:
    protected:
    int pkgFailures;
    int pkgFailures;
@@ -70,7 +68,7 @@ class pkgDPkgPM : public pkgPackageManager
    // Helpers
    // Helpers
    bool RunScriptsWithPkgs(const char *Cnf);
    bool RunScriptsWithPkgs(const char *Cnf);
    bool SendV2Pkgs(FILE *F);
    bool SendV2Pkgs(FILE *F);
-   void WriteHistoryTag(string tag, string value);
+   void WriteHistoryTag(FILE* history_out, string tag, string value);
 
 
    // apport integration
    // apport integration
    void WriteApportReport(const char *pkgpath, const char *errormsg);
    void WriteApportReport(const char *pkgpath, const char *errormsg);

+ 5 - 1
apt-pkg/packagemanager.h

@@ -49,7 +49,11 @@ class pkgPackageManager : protected pkgCache::Namespace
    bool Debug;
    bool Debug;
          
          
    bool DepAdd(pkgOrderList &Order,PkgIterator P,int Depth = 0);
    bool DepAdd(pkgOrderList &Order,PkgIterator P,int Depth = 0);
-   void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth = 0);
+   // binary-compat change, fix on next abi break
+   void ImmediateAdd(PkgIterator P, bool UseInstallVer) {
+      ImmediateAdd(P, UseInstallVer, 0);
+   }
+   void ImmediateAdd(PkgIterator P, bool UseInstallVer, unsigned const int &Depth);
    virtual OrderResult OrderInstall();
    virtual OrderResult OrderInstall();
    bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
    bool CheckRConflicts(PkgIterator Pkg,DepIterator Dep,const char *Ver);
    bool CreateOrderList();
    bool CreateOrderList();

+ 8 - 0
debian/changelog

@@ -1,3 +1,11 @@
+apt (0.7.25ubuntu2) lucid; urgency=low
+
+  * Change history branch so that it does not break the 
+    apt ABI for the pkgPackageManager interface
+    (can be reverted on the next ABI break)
+
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Wed, 23 Dec 2009 10:14:16 +0100
+
 apt (0.7.25ubuntu1) lucid; urgency=low
 apt (0.7.25ubuntu1) lucid; urgency=low
 
 
   * Merged from the mvo branch
   * Merged from the mvo branch