Bug#80810: apt: support for "apt-get source foo=1.0-1"
Package: apt
Version: 0.4.0 (cvs)
This is against current CVS. I made the DoSource able to get exact
versions. This will be especially useful with pools, and multi release
deb-src lines.
Attached is the fairly simple patch. Works well for me.
--
-----------=======-=-======-=========-----------=====------------=-=------
/ Ben Collins -- ...on that fantastic voyage... -- Debian GNU/Linux \
` bcollins@debian.org -- bcollins@openldap.org -- bcollins@linux.com '
`---=========------=======-------------=-=-----=-===-======-------=--=---'
Index: apt-get.cc
===================================================================
RCS file: /cvs/deity/apt/cmdline/apt-get.cc,v
retrieving revision 1.97.2.30
diff -u -u -r1.97.2.30 apt-get.cc
--- apt-get.cc 2000/12/19 05:21:08 1.97.2.30
+++ apt-get.cc 2000/12/29 04:52:34
@@ -1006,6 +1006,17 @@
pkgSrcRecords &SrcRecs,string &Src,
pkgDepCache &Cache)
{
+ char *TmpName = strdup(Name);
+ char *VerTag = strchr(TmpName,'=');
+ if (VerTag != 0)
+ *(VerTag++) = 0;
+ else
+ {
+ VerTag = strchr(TmpName,'_'); // For sbuild compat
+ if (VerTag != 0)
+ *(VerTag++) = 0;
+ }
+
/* Lookup the version of the package we would install if we were to
install a version and determine the source package name, then look
in the archive for a source package of the same name. In theory
@@ -1013,7 +1024,7 @@
today there aren't multi source versions in the archive. */
if (_config->FindB("APT::Get::Only-Source") == false)
{
- pkgCache::PkgIterator Pkg = Cache.FindPkg(Name);
+ pkgCache::PkgIterator Pkg = Cache.FindPkg(TmpName);
if (Pkg.end() == false)
{
pkgCache::VerIterator Ver = Cache.GetCandidateVer(Pkg);
@@ -1027,7 +1038,7 @@
// No source package name..
if (Src.empty() == true)
- Src = Name;
+ Src = TmpName;
// The best hit
pkgSrcRecords::Parser *Last = 0;
@@ -1045,7 +1056,23 @@
// Skip name mismatches
if (IsMatch == true && Parse->Package() != Src)
continue;
-
+
+ // If a version was specified, match it
+ if (VerTag != 0)
+ {
+ if (Parse->Package() == Src &&
+ Cache.VS().CmpVersion(VerTag,Ver) == 0)
+ {
+ Last = Parse;
+ Offset = Parse->Offset();
+ break;
+ }
+ else
+ {
+ continue;
+ }
+ }
+
// Newer version or an exact match
if (Last == 0 || Cache.VS().CmpVersion(Version,Ver) < 0 ||
(Parse->Package() == Src && IsMatch == false))
@@ -1056,6 +1083,8 @@
Version = Ver;
}
}
+
+ free(TmpName);
if (Last == 0)
return 0;
Reply to: