Re: [Patch] Pinning: Handle multiple package names per line
On Tue, Mar 06, 2007 at 12:02:38AM +0100, David Förster wrote:
> Hi,
Hi,
> currently pinning multiple related packages is pretty cumbersome as it
> requires a separate paragraph for each package. (Image pinning all
> KDE/PHP/xorg packages.)
>
> The attached patch allows to specify multiple package names in the Package:
> line in the preference file. It's pretty unintrusive but brings a big
> usability gain (imo). It applies to both 0.6.4 and 0.7 and updates the
> manpage too.
Thanks, can you please try the attach patch? I made it a bit more
c++ish.
Cheers,
Michael
=== modified file 'apt-pkg/policy.cc'
--- apt-pkg/policy.cc 2004-09-20 17:03:07 +0000
+++ apt-pkg/policy.cc 2007-04-20 15:40:33 +0000
@@ -36,6 +36,7 @@
#include <apti18n.h>
#include <iostream>
+#include <sstream>
/*}}}*/
using namespace std;
@@ -300,7 +301,13 @@
continue;
}
- Plcy.CreatePin(Type,Name,string(Word,End),priority);
+ istringstream s(Name);
+ string pkg;
+ while(!s.eof())
+ {
+ s >> pkg;
+ Plcy.CreatePin(Type, pkg, string(Word,End),priority);
+ };
}
Plcy.InitDefaults();
=== modified file 'debian/changelog'
--- debian/changelog 2007-04-17 13:33:19 +0000
+++ debian/changelog 2007-04-20 15:19:33 +0000
@@ -21,6 +21,8 @@
* [ABI] apt-pkg/acquire.{cc,h}:
- deal better with duplicated sources.list entries (avoid
double queuing of URLs) - this fixes hangs in bzip/gzip
+ * apt-pkg/policy.cc:
+ - allow multiple packages (thanks to David Foerster)
-- Michael Vogt <michael.vogt@ubuntu.com> Mon, 18 Dec 2006 19:39:05 +0100
=== modified file 'doc/apt_preferences.5.xml'
--- doc/apt_preferences.5.xml 2006-03-12 20:18:45 +0000
+++ doc/apt_preferences.5.xml 2007-04-20 15:02:12 +0000
@@ -143,10 +143,11 @@
and a general form.
<itemizedlist>
<listitem>
-<simpara>The specific form assigns a priority (a "Pin-Priority") to a
-specified package and specified version or version range. For example,
+<simpara>The specific form assigns a priority (a "Pin-Priority") to one or more
+specified packages and specified version or version range. For example,
the following record assigns a high priority to all versions of
-the <filename>perl</filename> package whose version number begins with "<literal>5.8</literal>".</simpara>
+the <filename>perl</filename> package whose version number begins with "<literal>5.8</literal>".
+Multiple packages can be separated by spaces.</simpara>
<programlisting>
Package: perl
Reply to: