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

* merge with matt, search for the right patch next instead of applying them in order

Patches applied:

 * apt@packages.debian.org/apt--main--0--patch-77
   Merge apt--mvo--0

 * apt@packages.debian.org/apt--main--0--patch-78
   Update changelog

 * apt@packages.debian.org/apt--main--0--patch-79
   Merge michael.vogt@ubuntu.com--2005/apt--mvo--0

 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-14
   * changelog entry for 0.6.34ubuntu1 added, MinAge default is 2 days now

 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-15
   * merged with matts tree

 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-16
   * changelog updated

 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-17
   * whitespace change to add incomplete log for last patch

 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-18
   * honor "Acquire::gpgv::Options" in apt-cdrom too

 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-19
   * corrected a incorrect use of string().c_str() (thanks to mdz!)

 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-20
   * supress output when /var/cache/apt/archives is empty; break when min-age is reached

 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-21
   * changed distro to "experimental", changed version number to 0.6.36
Michael Vogt лет назад: 21
Родитель
Сommit
94dc9d7d8b
6 измененных файлов с 90 добавлено и 23 удалено
  1. 41 15
      apt-pkg/acquire-item.cc
  2. 1 1
      apt-pkg/acquire-item.h
  3. 31 3
      apt-pkg/indexcopy.cc
  4. 1 1
      configure.in
  5. 3 3
      debian/apt.cron.daily
  6. 13 0
      debian/changelog

+ 41 - 15
apt-pkg/acquire-item.cc

@@ -142,7 +142,7 @@ void pkgAcquire::Item::Rename(string From,string To)
 pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
 				   string URI,string URIDesc,string ShortDesc,
 				   string ExpectedMD5, vector<DiffInfo> diffs) 
-   : Item(Owner), RealURI(URI), ExpectedMD5(ExpectedMD5), needed_files(diffs)
+   : Item(Owner), RealURI(URI), ExpectedMD5(ExpectedMD5), available_patches(diffs)
 {
    
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
@@ -171,7 +171,7 @@ pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire *Owner,
       return;
    }
 
-   if(needed_files.size() == 0)
+   if(available_patches.size() == 0)
       QueueDiffIndex(URI);
    else
       QueueNextDiff();
@@ -261,7 +261,8 @@ bool pkgAcqIndexDiffs::ApplyDiff(string PatchFile)
    if (Process == 0)
    {
       chdir(_config->FindDir("Dir::State::lists").c_str());
-      string cmd = "(zcat " + PatchFile + "; echo \"wq\" ) | red  " + FinalFile + " >/dev/null 2>/dev/null";
+      // for some reason "red" fails with the pdiffs from p.d.o/~aba ?!? 
+      string cmd = "(zcat " + PatchFile + "; echo \"wq\" ) | /bin/ed  " + FinalFile + " >/dev/null 2>/dev/null";
       if(Debug)
 	 std::clog << "Runing: " << cmd << std::endl;
       res = system(cmd.c_str());
@@ -277,16 +278,35 @@ bool pkgAcqIndexDiffs::ApplyDiff(string PatchFile)
 
 bool pkgAcqIndexDiffs::QueueNextDiff()
 {
-   // FIXME: don't use the needed_files[0] but check sha1 and search
-   //        for the right patch in needed_files
-   //        -> and rename needed_files to "available_patches" 
+   // calc sha1 of the just patched file
+   string FinalFile = _config->FindDir("Dir::State::lists");
+   FinalFile += URItoFileName(RealURI);
+
+   FileFd fd(FinalFile, FileFd::ReadOnly);
+   SHA1Summation SHA1;
+   SHA1.AddFD(fd.Fd(), fd.Size());
+   string local_sha1 = string(SHA1.Result());
+
+   // see if we have a patch for it, the patch list must be ordered
+   for(vector<DiffInfo>::iterator I=available_patches.begin();
+       I != available_patches.end(); I++) {
+      // if the patch does not fit, it's not interessting
+      if((*I).sha1 != local_sha1)
+	 available_patches.erase(I);
+   }
+
+   // error checking and falling back if no patch was found
+   if(available_patches.size() == 0) { 
+      Failed("", NULL);
+      return false;
+   }
 
-   // queue diff
-   Desc.URI = string(RealURI) + string(".diff/") + needed_files[0].file + string(".gz");
-   Desc.Description = needed_files[0].file + string(".pdiff");
+   // queue the right diff
+   Desc.URI = string(RealURI) + string(".diff/") + available_patches[0].file + string(".gz");
+   Desc.Description = available_patches[0].file + string(".pdiff");
 
    DestFile = _config->FindDir("Dir::State::lists") + "partial/";
-   DestFile += URItoFileName(RealURI + string(".diff/") + needed_files[0].file);
+   DestFile += URItoFileName(RealURI + string(".diff/") + available_patches[0].file);
 
    if(Debug)
       std::clog << "pkgAcqIndexDiffs::QueueNextDiff(): " << Desc.URI << std::endl;
@@ -341,7 +361,7 @@ bool pkgAcqIndexDiffs::ParseIndexDiff(string IndexDiffFile)
 	 if(found) {
 	    if(Debug)
 	       std::clog << "Need to get diff: " << d.file << std::endl;
-	    needed_files.push_back(d);
+	    available_patches.push_back(d);
 	 }
       }
       // no information how to get the patches, bail out
@@ -353,7 +373,7 @@ bool pkgAcqIndexDiffs::ParseIndexDiff(string IndexDiffFile)
       } else {
 	 // queue the diffs
 	 new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
-			      ExpectedMD5, needed_files);
+			      ExpectedMD5, available_patches);
 	 Finish();
 	 return true;
       }
@@ -394,11 +414,11 @@ void pkgAcqIndexDiffs::Done(string Message,unsigned long Size,string Md5Hash,
    // sucess in downloading a diff
    if(Desc.URI.find(".diff") != string::npos) {
       ApplyDiff(DestFile);
-      needed_files.erase(needed_files.begin());
+      available_patches.erase(available_patches.begin());
 
-      if(needed_files.size() > 0) {
+      if(available_patches.size() > 0) {
 	 new pkgAcqIndexDiffs(Owner, RealURI, Description, Desc.ShortDesc,
-			      ExpectedMD5, needed_files);
+			      ExpectedMD5, available_patches);
       } else {
 	 Finish(true);
 	 return;
@@ -618,6 +638,12 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
       // File was already in place.  It needs to be re-verified
       // because Release might have changed, so Move it into partial
       Rename(Final,DestFile);
+      // unlink the file and do not try to use I-M-S and Last-Modified
+      // if the users proxy is broken
+      if(_config->FindB("Acquire::BrokenProxy", false) == true) {
+	 std::cerr << "forcing re-get of the signature file as requested" << std::endl;
+	 unlink(DestFile.c_str());
+      }
    }
 
    QueueURI(Desc);

+ 1 - 1
apt-pkg/acquire-item.h

@@ -99,7 +99,7 @@ class pkgAcqIndexDiffs : public pkgAcquire::Item
       string sha1;
       unsigned long size;
    };
-   vector<DiffInfo> needed_files;
+   vector<DiffInfo> available_patches;
    
 
    public:

+ 31 - 3
apt-pkg/indexcopy.cc

@@ -593,17 +593,45 @@ bool SigVerify::CopyAndVerify(string CDROM,string Name,vector<string> &SigList,
 
       // verify the gpg signature of "Release"
       // gpg --verify "*I+Release.gpg", "*I+Release"
+      const char *Args[400];
+      unsigned int i = 0;
+
       string gpgvpath = _config->Find("Dir::Bin::gpg", "/usr/bin/gpgv");
       string pubringpath = _config->Find("Apt::GPGV::TrustedKeyring", "/etc/apt/trusted.gpg");
+      string releasegpg = *I+"Release.gpg";
+      string release = *I+"Release";
+
+      Args[i++] = gpgvpath.c_str();
+      Args[i++] = "--keyring";
+      Args[i++] = pubringpath.c_str();
+      Configuration::Item const *Opts;
+      Opts = _config->Tree("Acquire::gpgv::Options");
+      if (Opts != 0)
+      {
+         Opts = Opts->Child;
+	 for (; Opts != 0; Opts = Opts->Next)
+         {
+            if (Opts->Value.empty() == true)
+               continue;
+            Args[i++] = Opts->Value.c_str();
+	    if(i >= 390) { 
+	       _error->Error("Argument list from Acquire::gpgv::Options too long. Exiting.");
+	       return false;
+	    }
+         }
+      }
+      
+      Args[i++] = releasegpg.c_str();
+      Args[i++] = release.c_str();
+      Args[i++] = NULL;
+      
       pid_t pid = ExecFork();
       if(pid < 0) {
 	 _error->Error("Fork failed");
 	 return false;
       }
       if(pid == 0) {
-	 execlp(gpgvpath.c_str(), gpgvpath.c_str(), "--keyring", 
-		pubringpath.c_str(), string(*I+"Release.gpg").c_str(), 
-		string(*I+"Release").c_str(), NULL);
+	 execvp(gpgvpath.c_str(), (char**)Args);
       }
       if(!ExecWait(pid, "gpgv")) {
 	 _error->Warning("Signature verification failed for: %s",

+ 1 - 1
configure.in

@@ -18,7 +18,7 @@ AC_CONFIG_AUX_DIR(buildlib)
 AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in include/apti18n.h:buildlib/apti18n.h.in)
 
 dnl -- SET THIS TO THE RELEASE VERSION --
-AC_DEFINE_UNQUOTED(VERSION,"0.6.35")
+AC_DEFINE_UNQUOTED(VERSION,"0.6.36")
 PACKAGE="apt"
 AC_DEFINE_UNQUOTED(PACKAGE,"$PACKAGE")
 AC_SUBST(PACKAGE)

+ 3 - 3
debian/apt.cron.daily

@@ -74,7 +74,7 @@ check_size_constraints()
 {
     # min-age in days
     MaxAge=0
-    MinAge=1
+    MinAge=2
     MaxSize=0
     CacheDir="var/cache/apt"
     CacheArchive="archives/"
@@ -110,7 +110,7 @@ check_size_constraints()
 	MinAge=$(($MinAge*24*60*60))
 
 	# reverse-sort by mtime
-	for file in $(ls -rt $Cache/*.deb); do 
+	for file in $(ls -rt $Cache/*.deb 2>/dev/null); do 
 	    du=$(du -s $Cache)
 	    size=${du%%/*}
 	    # check if the cache is small enough
@@ -125,7 +125,7 @@ check_size_constraints()
 		#echo "$file ($delta), $MinAge"
 		if [ $delta -le $MinAge ]; then
 		    #echo "Skiping $file (delta=$delta)"
-		    continue
+		    break
 		fi
 	    fi
 

+ 13 - 0
debian/changelog

@@ -1,3 +1,16 @@
+apt (0.6.36) experimental; urgency=low
+
+  * Merge apt--mvo--0:
+    - apt-pkg/acquire-item.cc:
+      added "Acquire::BrokenProxy" that will force apt to always 
+      re-get the Release.gpg file (for broken proxies)
+    - debian/apt.cron.daily:
+      MinAge is defaulting to 2 days now to prevent over-aggresive removal 
+    - apt-pkg/cdrom.cc:
+      honor "Acquire::gpgv::Options" when verifying the signature (Ubuntu #8496)
+ 
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Thu, 31 Mar 2005 20:37:11 +0200
+
 apt (0.6.35) hoary; urgency=low
 
   * Merge apt--mvo--0 (incorporates 0.6.34ubuntu1):