]> err.no Git - dpkg/commitdiff
Add new '--clear-selections' option to dpkg (Andrew Suffield).
authorGuillem Jover <guillem@debian.org>
Sun, 9 Apr 2006 23:49:09 +0000 (23:49 +0000)
committerGuillem Jover <guillem@debian.org>
Sun, 9 Apr 2006 23:49:09 +0000 (23:49 +0000)
Closes: #112388
ChangeLog
debian/changelog
man/C/dpkg.1
man/ChangeLog
src/main.c
src/main.h
src/select.c

index 2e5a570a0b91ee4a7bd9938b08065e2271dd527c..4ac8ba51cc42331be7b174ddb76fc66737a6c1d9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-04-10  Andrew Suffield  <asuffield@debian.org>
+
+       * src/main.h (clearselections): New prototype.
+       * src/main.c (usage): Print '--clear-selections' option description.
+       (cmdinfos): Add clear-selectons action.
+       * src/select.c (clearselections): New function.
+
 2006-04-10  Guillem Jover  <guillem@debian.org>
 
        * src/main.h (fc_autoselect): Remove.
index 34f83392e444c0481b5ffe75075a401118a207ba..771aece6b54df3f8ee1082768442ee3414b172e1 100644 (file)
@@ -39,6 +39,8 @@ dpkg (1.13.18~) UNRELEASED; urgency=low
   * Document that 'dpkg --get-selections' and 'dpkg-query -l' without a
     pattern will not list packages in state purge. Closes: #355633
   * Obsolete force/refuse 'auto-select' dpkg option.
+  * Add new '--clear-selections' option to dpkg (Andrew Suffield).
+    Closes: #112388
 
   [ Christian Perrier ]
   * 
index 0d3e92cc448948a7d50aaa61b5506f07b1f634f7..25a4e72657549a69c6469d7fc735354587d36581 100644 (file)
@@ -204,6 +204,11 @@ in the format '<package> <state>', where state is one of install, hold,
 deinstall or purge. Blank lines and comment lines beginning with '#'
 are also permitted.
 .TP
+.B dpkg \-\-clear\-selections
+Set the requested state of every non-essential package to deinstall.
+This is intended to be used immediately before \-\-set\-selections, to
+deinstall any packages not in list given to \-\-set\-selections.
+.TP
 .B dpkg \-\-yet\-to\-unpack
 Searches for packages selected for installation, but which for some
 reason still haven't been installed.
index 5fb699482964f63b7e88cb91d2727cf0c982a697..5199be04d1895895e05d192812667bbf04f2fdf7 100644 (file)
@@ -1,3 +1,7 @@
+2006-04-10  Andrew Suffield  <asuffield@debian.org>
+
+       * C/dpkg.1: Document the new '--clear-selections' option.
+
 2006-04-10  Guillem Jover  <guillem@debian.org>
 
        * C/dpkg.1: Remove mention of obsolete force/refuse 'auto-select'
index c3c652d93155d0a9d7d75dac6ea4c388cab95c95..25bb8bb61d7a5f53284ce8fc9dca63d8b76f5975 100644 (file)
@@ -65,6 +65,7 @@ static void usage(void) {
 "  -P|--purge         <package-name> ... | -a|--pending\n"
 "  --get-selections [<pattern> ...]     Get list of selections to stdout.\n"
 "  --set-selections                     Set package selections from stdin.\n"
+"  --clear-selections                   Deselect every non-essential package.\n"
 "  --update-avail <Packages-file>       Replace available packages info.\n"
 "  --merge-avail <Packages-file>        Merge with info from file.\n"
 "  --clear-avail                        Erase existing available info.\n"
@@ -378,6 +379,7 @@ static const struct cmdinfo cmdinfos[]= {
   ACTIONBACKEND( "status",                  's', DPKGQUERY),
   ACTION( "get-selections",                  0,  act_getselections,        getselections   ),
   ACTION( "set-selections",                  0,  act_setselections,        setselections   ),
+  ACTION( "clear-selections",                0,  act_clearselections,      clearselections ),
   ACTIONBACKEND( "print-avail",             'p', DPKGQUERY),
   ACTION( "update-avail",                    0,  act_avreplace,            updateavailable ),
   ACTION( "merge-avail",                     0,  act_avmerge,              updateavailable ),
index 709f76f9e4b0bc685c6274af5379047ef38324a9..e1cd853c7c54136ea571603324232c6435bd628b 100644 (file)
@@ -53,7 +53,8 @@ enum action { act_unset, act_install, act_unpack, act_avail, act_configure,
               act_unpackchk, act_status, act_searchfiles, act_audit, act_listfiles,
               act_assertpredep, act_printarch, act_predeppackage, act_cmpversions,
               act_printinstarch, act_compareversions, act_printavail, act_avclear,
-              act_forgetold, act_getselections, act_setselections,
+              act_forgetold,
+              act_getselections, act_setselections, act_clearselections,
               act_assertepoch, act_assertlongfilenames, act_assertmulticonrep,
              act_commandfd };
 
@@ -139,6 +140,7 @@ int pkglistqsortcmp(const void *a, const void *b);
 
 void getselections(const char *const *argv);
 void setselections(const char *const *argv);
+void clearselections(const char *const *argv);
 
 /* from packages.c, remove.c and configure.c */
 
index a8becab2866751cf22eaef4bfc8824b27257d099..6887e1b6ac8c75cd2504afc3a8e50d704088ef1f 100644 (file)
@@ -144,3 +144,24 @@ void setselections(const char *const *argv) {
   varbufreset(&namevb);
   varbufreset(&selvb);
 }
+
+void clearselections(const char *const *argv)
+{
+  struct pkgiterator *it;
+  struct pkginfo *pkg;
+
+  if (*argv)
+    badusage(_("--clear-selections does not take any argument"));
+
+  modstatdb_init(admindir, msdbrw_write);
+
+  it = iterpkgstart();
+  while ((pkg = iterpkgnext(it))) {
+    if (!pkg->installed.essential)
+      pkg->want = want_deinstall;
+  }
+  iterpkgend(it);
+
+  modstatdb_shutdown();
+}
+