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

[Patch] Pinning: Handle multiple package names per line



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.

Regards, David

ps: I'm new to C++ only knowing C so so the string handling might not be as 
elegant.
--- apt-pkg/policy.cc.orig      2007-03-05 23:16:38.000000000 +0100
+++ apt-pkg/policy.cc   2007-03-05 23:18:08.000000000 +0100
@@ -300,7 +300,16 @@
          continue;
       }

-      Plcy.CreatePin(Type,Name,string(Word,End),priority);
+      int curWordEnd;
+      do {
+         for (curWordEnd = 0; !isspace(Name[curWordEnd]) && curWordEnd < Name.length(); curWordEnd++);
+         Plcy.CreatePin(Type,Name.substr(0, curWordEnd), string(Word,End),priority);
+         for(; isspace(Name[curWordEnd]); curWordEnd++);
+         Name.erase(0,curWordEnd);
+      } while (!Name.empty());
    }

    Plcy.InitDefaults();
--- doc/apt_preferences.5       2006-12-04 18:43:47.000000000 +0100
+++ doc/apt_preferences.5.orig  2007-03-05 23:35:28.000000000 +0100
@@ -121,9 +121,9 @@
 The APT preferences file allows the system administrator to control the assignment of priorities. The file consists of one or more multi\-line records separated by blank lines. Records can have one of two forms, a specific form and a general form.
 .TP 3n
 \(bu
-The specific form assigns a priority (a "Pin\-Priority") to a specified package and specified version or version range. For example, the following record assigns a high priority to all versions of the
+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
 \fIperl\fR
-package whose version number begins with "5.8".
+package whose version number begins with "5.8". Multiple packages can be separated by spaces.
 .sp
 .RS 3n
 .nf
--- doc/apt_preferences.5.xml   2006-12-04 15:37:35.000000000 +0100
+++ doc/apt_preferences.5.xml.orig      2007-03-05 23:35:36.000000000 +0100
@@ -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

Attachment: pgpe8me3cJGXN.pgp
Description: PGP signature


Reply to: