Selaa lähdekoodia

Add new '--clear-selections' option to dpkg (Andrew Suffield).
Closes: #112388

Guillem Jover 20 vuotta sitten
vanhempi
commit
f34270adb2
7 muutettua tiedostoa jossa 44 lisäystä ja 1 poistoa
  1. 7 0
      ChangeLog
  2. 2 0
      debian/changelog
  3. 5 0
      man/C/dpkg.1
  4. 4 0
      man/ChangeLog
  5. 2 0
      src/main.c
  6. 3 1
      src/main.h
  7. 21 0
      src/select.c

+ 7 - 0
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.

+ 2 - 0
debian/changelog

@@ -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 ]
   * 

+ 5 - 0
man/C/dpkg.1

@@ -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.

+ 4 - 0
man/ChangeLog

@@ -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'

+ 2 - 0
src/main.c

@@ -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 ),

+ 3 - 1
src/main.h

@@ -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 */
 

+ 21 - 0
src/select.c

@@ -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();
+}
+