From: Guillem Jover Date: Sun, 9 Apr 2006 23:49:09 +0000 (+0000) Subject: Add new '--clear-selections' option to dpkg (Andrew Suffield). X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f34270adb20a888bc46a159e780c9036f0696dc3;p=dpkg Add new '--clear-selections' option to dpkg (Andrew Suffield). Closes: #112388 --- diff --git a/ChangeLog b/ChangeLog index 2e5a570a..4ac8ba51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-04-10 Andrew Suffield + + * 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 * src/main.h (fc_autoselect): Remove. diff --git a/debian/changelog b/debian/changelog index 34f83392..771aece6 100644 --- a/debian/changelog +++ b/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 ] * diff --git a/man/C/dpkg.1 b/man/C/dpkg.1 index 0d3e92cc..25a4e726 100644 --- a/man/C/dpkg.1 +++ b/man/C/dpkg.1 @@ -204,6 +204,11 @@ in the format ' ', 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. diff --git a/man/ChangeLog b/man/ChangeLog index 5fb69948..5199be04 100644 --- a/man/ChangeLog +++ b/man/ChangeLog @@ -1,3 +1,7 @@ +2006-04-10 Andrew Suffield + + * C/dpkg.1: Document the new '--clear-selections' option. + 2006-04-10 Guillem Jover * C/dpkg.1: Remove mention of obsolete force/refuse 'auto-select' diff --git a/src/main.c b/src/main.c index c3c652d9..25bb8bb6 100644 --- a/src/main.c +++ b/src/main.c @@ -65,6 +65,7 @@ static void usage(void) { " -P|--purge ... | -a|--pending\n" " --get-selections [ ...] 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 Replace available packages info.\n" " --merge-avail 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 ), diff --git a/src/main.h b/src/main.h index 709f76f9..e1cd853c 100644 --- a/src/main.h +++ b/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 */ diff --git a/src/select.c b/src/select.c index a8becab2..6887e1b6 100644 --- a/src/select.c +++ b/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(); +} +