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

builddep support for apt, part 2



Here is a patch for apt-get so that apt-get source <foo> will also install
build-dependencies of foo, and remove build-conflicts of foo.

I don't really like this patch; comments/suggestions on how to better do
this will be appreciated.

Incidentally, Jason, I checked the patch into the aliencode branch...... not
sure if that's what you wanted.

Index: apt-get.cc
===================================================================
RCS file: /cvs/deity/apt/cmdline/apt-get.cc,v
retrieving revision 1.97.2.3
diff -u -r1.97.2.3 apt-get.cc
--- apt-get.cc	2000/06/18 07:28:09	1.97.2.3
+++ apt-get.cc	2000/06/26 00:08:34
@@ -1463,6 +1463,58 @@
 			I->MD5Hash,I->Size,Last->Source()->SourceInfo(Src,
 			Last->Version(),Comp),Src);
       }
+
+      // Process the build-dependencies too
+      if (_config->FindB("APT::Get::BuildDepends",true) == true)
+      {
+         vector<pkgSrcRecords::Parser::BuildDepRec> BuildDeps;
+         if (Last->BuildDepends(BuildDeps) == false)
+            return _error->Error("Unable to get build-dependency information for %s",Src.c_str());
+   
+         if (BuildDeps.size() > 0) 
+	 {
+   	    unsigned int ExpectedInst = 0;
+            vector <pkgSrcRecords::Parser::BuildDepRec>::iterator D;
+            pkgProblemResolver Fix(Cache);
+            for (D = BuildDeps.begin(); D != BuildDeps.end(); D++)
+   	    {
+   	       pkgCache::PkgIterator Pkg = Cache->FindPkg((*D).Package);
+   	       if (Pkg.end() == true)
+   	          return _error->Error("%s dependency on %s cannot be satisfied because the package %s cannot be found", Last->BuildDepType((*D).Type), Src.c_str(), (*D).Package.c_str());
+	       pkgCache::VerIterator IV = (*Cache)[Pkg].InstVerIter(*Cache);
+
+   	       if ((*D).Type == pkgSrcRecords::Parser::BuildConflict || (*D).Type == pkgSrcRecords::Parser::BuildConflictIndep) 
+	       {
+	          // conflict; need to remove if we have an installed version 
+		  // that satisfy the version criteria
+		  if (IV.end() == false && ((*D).Version == "" ||
+		      pkgCheckDep((*D).Version.c_str(), IV.VerStr(), (*D).Op) == true)) {
+		         Cache->MarkDelete(Pkg,false); 	       
+	          }
+	       } else {
+	          // depends; need to install or upgrade if we don't have the
+		  // package installed or if the version does not satisfy the
+		  // build dep. This is complicated by the fact that if we
+		  // depend on a version lower than what we already have 
+		  // installed it is not clear what should be done; in practice
+		  // this case should be rare though and right now nothing
+		  // is done about it :-(
+		  if (IV.end() == true || ((*D).Version != "" &&
+		      pkgCheckDep((*D).Version.c_str(), IV.VerStr(), (*D).Op) == false)) {
+		         Cache->MarkInstall(Pkg,true);
+	          }
+	       }	       
+   	    }
+      
+            Fix.InstallProtect();
+            if (Fix.Resolve(true) == false)
+               _error->Discard();
+   
+            // Now we check the state of the packages,
+            if (Cache->BrokenCount() != 0)
+   	       return _error->Error("Some broken packages were found while trying to process build-dependencies.\nYou might want to run `apt-get -f install' to correct these.");
+         }
+      }
    }
    
    // Display statistics
@@ -1524,6 +1576,13 @@
    if (Failed == true)
       return _error->Error("Failed to fetch some archives.");
    
+   if (_config->FindB("APT::Get::BuildDepends", true) == true)
+   {
+      cout << "Processing package build dependencies" << endl;
+      if (InstallPackages(Cache, false))
+         return _error->Error("Failed to process build dependencies");
+   }
+
    if (_config->FindB("APT::Get::Download-only",false) == true)
       return true;
    

randolph
-- 
Debian Developer <tausq@debian.org>
http://www.TauSq.org/



Reply to: