ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: Alexey Tourbin <at@altlinux.ru>
To: ALT Devel discussion list <devel@lists.altlinux.org>
Subject: [devel] [PATCH] apt virtual packages
Date: Sun, 17 Dec 2006 16:43:40 +0300
Message-ID: <20061217134340.GA6148@localhost.localdomain> (raw)
In-Reply-To: <20061215012503.GK13476@localhost.localdomain>


[-- Attachment #1.1: Type: text/plain, Size: 1350 bytes --]

On Fri, Dec 15, 2006 at 04:25:03AM +0300, Alexey Tourbin wrote:
> On Fri, Dec 15, 2006 at 02:40:38AM +0300, Alexey Tourbin wrote:
> > Т.е. 2.4.4-alt2.1 в этом месте не видно вообще.
> > Соответственно, дальше, вероятно, стоит ковырять pkgVersionMatch::Find.
> 
> Вот фикс, с которым будет выбираться не первая попавшаяся, а последняя
> попавшаяся версия.  install python-devel=2.4 теперь работает (в том
> смысле, что установить можно только 2.4.4-alt2.1).
> 
> --- apt-pkg/versionmatch.cc-	2006-12-15 01:11:52 +0000
> +++ apt-pkg/versionmatch.cc	2006-12-15 01:15:17 +0000
> @@ -205,10 +205,10 @@ pkgCache::VerIterator pkgVersionMatch::F
>           if (VerPrefixMatch || (HasRelease && strchr(PrvVerStr, '-') == NULL))
>           {
>              if (MatchVer(PrvVerStr,VerStr,VerPrefixMatch) == true)
> -               return Prv.OwnerVer();
> +               Ver = Prv.OwnerVer();
>           } else {
>              if (VS->CheckDep(PrvVerStr,VerOp,VerStr.c_str()) == true)
> -               return Prv.OwnerVer();
> +               Ver = Prv.OwnerVer();
>           }
>        }
>     }
> 
> Впрочем install python-base=2.4.4-alt2 python-devel=2.4
> не работает ни так ни сяк.

Этот патч был неправильным, потому что версии в ProvidesList на самом
деле не отсортированы.  Вот правильный вариант патча (прицеплен).

[-- Attachment #1.2: versionmatch.patch --]
[-- Type: text/plain, Size: 3061 bytes --]

--- apt-0.5.15lorg2/apt-pkg/versionmatch.h-	2006-06-17 22:00:13 +0400
+++ apt-0.5.15lorg2/apt-pkg/versionmatch.h	2006-12-17 15:49:08 +0300
@@ -36,6 +36,7 @@
 #endif
 
 #include <string>
+#include <list>
 #include <apt-pkg/pkgcache.h>
 
 using std::string;
@@ -70,6 +71,7 @@
 			       
    // CNC:2003-11-05
    pkgVersionMatch(string Data,MatchType Type,int Op=pkgCache::Dep::Equals);
+   std::list<pkgCache::VerIterator> FindAll(pkgCache::PkgIterator Pkg);
 };
 
 #endif
--- apt-0.5.15lorg2/apt-pkg/versionmatch.cc-	2006-12-15 04:11:52 +0300
+++ apt-0.5.15lorg2/apt-pkg/versionmatch.cc	2006-12-17 16:38:44 +0300
@@ -164,11 +164,17 @@
 // VersionMatch::Find - Locate the best match for the select type	/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-pkgCache::VerIterator pkgVersionMatch::Find(pkgCache::PkgIterator Pkg)
+static inline bool
+vercmpOrder(const pkgCache::VerIterator &a, const pkgCache::VerIterator &b)
+{
+   return a.CompareVer(b) < 0;
+}
+std::list<pkgCache::VerIterator> pkgVersionMatch::FindAll(pkgCache::PkgIterator Pkg)
 {
    // CNC:2003-11-05
    pkgVersioningSystem *VS = Pkg.Cache()->VS;
    pkgCache::VerIterator Ver = Pkg.VersionList();
+   std::list<pkgCache::VerIterator> found;
 
    for (; Ver.end() == false; Ver++)
    {
@@ -178,10 +184,10 @@
          if (VerPrefixMatch)
 	 {
 	    if (MatchVer(Ver.VerStr(),VerStr,VerPrefixMatch) == true)
-	       return Ver;
+	       found.push_back(Ver);
 	 } else {
 	    if (VS->CheckDep(Ver.VerStr(),VerOp,VerStr.c_str()) == true)
-	       return Ver;
+	       found.push_back(Ver);
 	 }
 
 	 continue;
@@ -189,8 +195,11 @@
       
       for (pkgCache::VerFileIterator VF = Ver.FileList(); VF.end() == false; VF++)
 	 if (FileMatch(VF.File()) == true)
-	    return Ver;
+	    found.push_back(Ver);
    }
+
+   if (found.size() > 0)
+      goto done;
       
    // CNC:2003-11-11 - Virtual package handling.
    if (Type == Version)
@@ -205,15 +214,32 @@
          if (VerPrefixMatch || (HasRelease && strchr(PrvVerStr, '-') == NULL))
          {
             if (MatchVer(PrvVerStr,VerStr,VerPrefixMatch) == true)
-               return Prv.OwnerVer();
+               found.push_back(Prv.OwnerVer());
          } else {
             if (VS->CheckDep(PrvVerStr,VerOp,VerStr.c_str()) == true)
-               return Prv.OwnerVer();
+               found.push_back(Prv.OwnerVer());
          }
       }
    }
 
-   // This will be Ended by now.
+done:
+   // best versions go first
+   found.sort(vercmpOrder);
+   found.unique();
+   found.reverse();
+   return found;
+}
+
+pkgCache::VerIterator pkgVersionMatch::Find(pkgCache::PkgIterator Pkg)
+{
+   std::list<pkgCache::VerIterator> found = FindAll(Pkg);
+   if (found.size() > 0)
+      return found.front();
+
+   // return "empty" iterator at its end
+   pkgCache::VerIterator Ver = Pkg.VersionList();
+   while (Ver.end() == false)
+      Ver++;
    return Ver;
 }
 									/*}}}*/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2006-12-17 13:43 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-09 22:32 [devel] " Alexey Tourbin
2006-10-09 22:41 ` Dmitry V. Levin
2006-10-10  0:40   ` Alexey Tourbin
2006-10-10 15:39     ` Dmitry V. Levin
2006-10-10 15:52       ` Alexey Tourbin
2006-10-10 22:11         ` Dmitry V. Levin
2006-10-11  0:16           ` Alexey Tourbin
2006-10-12  9:18             ` Serge Pavlovsky
2006-12-07 22:52             ` Dmitry V. Levin
2006-12-08 21:27               ` Alexey Tourbin
2006-12-08 21:43                 ` Dmitry V. Levin
2006-12-08 21:59                   ` Alexey Tourbin
2006-12-08 22:01                 ` Dmitry V. Levin
2006-12-08 22:23                   ` Dmitry V. Levin
2006-12-13  3:35               ` Alexey Tourbin
2006-12-14 23:40               ` Alexey Tourbin
2006-12-14 23:46                 ` Alexey Tourbin
2006-12-14 23:54                   ` Alexey Tourbin
2006-12-15  1:25                 ` Alexey Tourbin
2006-12-15 13:49                   ` Michael Shigorin
2006-12-15 16:52                     ` Alexey Tourbin
2006-12-15 22:27                   ` Dmitry V. Levin
2006-12-15 22:42                     ` Alexey Tourbin
2006-12-16 12:03                       ` Alexey I. Froloff
2006-12-16 20:19                         ` Alexey Tourbin
2006-12-16 21:02                           ` Dmitry V. Levin
2006-12-16 21:08                             ` Alexey Tourbin
2006-12-16 21:26                               ` Dmitry V. Levin
2006-12-16 21:42                                 ` Alexey Tourbin
2006-12-17 13:51                             ` Alexey I. Froloff
2006-12-17 14:12                               ` Alexey Tourbin
2006-12-17 16:47                                 ` [devel] Papadimitriou Alexey Tourbin
2006-12-17 16:58                                 ` [devel] apt virtual packages Alex V. Myltsev
2006-12-17 17:45                                   ` Alexey Tourbin
2006-12-17 17:57                                     ` [devel] [JT] " Alex V. Myltsev
2006-12-17 18:13                                       ` Alexey Tourbin
2006-12-17  9:58                     ` [devel] " Alexey Tourbin
2006-12-17 10:02                       ` Alexey Tourbin
2006-12-17 10:37                         ` Alexey Tourbin
2006-12-17 13:43                   ` Alexey Tourbin [this message]
2006-12-17 13:46                     ` [devel] gendiff Alexey Tourbin
2006-12-17 14:14                     ` [devel] [PATCH] apt virtual packages Alexey Tourbin
2006-12-17 16:09                       ` Alexey Tourbin
2006-12-17 16:15                         ` Alexey Tourbin
2006-12-17 17:05                           ` Hihin Ruslan
2006-12-17 17:17                             ` Alexey Tourbin
2006-12-17 16:41                         ` Alexey Tourbin
2006-12-17 16:49                           ` [devel] std::sort Alex V. Myltsev
2006-12-17 17:15                             ` Alexey Tourbin
2006-12-17 17:54                               ` [devel] [JT] std::sort Alex V. Myltsev
2006-12-17 18:06                                 ` Alexey Tourbin
2006-12-17 19:42                                 ` Hihin Ruslan
2006-12-17 20:01                                   ` Hihin Ruslan
2006-12-17 20:33                                     ` Hihin Ruslan
2006-12-17 20:18                                   ` Alex V. Myltsev
2006-12-18  7:51                                     ` Hihin Ruslan
2006-12-18 10:39                         ` [devel] [PATCH] apt virtual packages Led
2006-12-18 13:17                           ` Alexey Tourbin
2006-12-17 16:51                       ` Dmitry V. Levin
2006-12-20 17:25                     ` Alexey Tourbin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061217134340.GA6148@localhost.localdomain \
    --to=at@altlinux.ru \
    --cc=devel@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git