[pacman-dev] Add --nolist option for transactions
From: Dmitry Kudriavtsev <me@dk0.us> Adds a --nolist option for package transactions. This option removes the list display of packages to be installed or removed. Signed-off-by: Dmitry Kudriavtsev <me@dk0.us> --- src/pacman/conf.h | 4 +++- src/pacman/pacman.c | 5 +++++ src/pacman/remove.c | 7 +++++-- src/pacman/sync.c | 6 ++++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/pacman/conf.h b/src/pacman/conf.h index ababf2e0..1615d974 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -50,6 +50,7 @@ typedef struct __config_t { unsigned short help; unsigned short noconfirm; unsigned short noprogressbar; + unsigned short nolist; unsigned short logmask; unsigned short print; unsigned short checkspace; @@ -209,7 +210,8 @@ enum { OP_DOWNLOADONLY, OP_REFRESH, OP_ASSUMEINSTALLED, - OP_DISABLEDLTIMEOUT + OP_DISABLEDLTIMEOUT, + OP_NOLIST }; /* clean method */ diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index fe54793e..18505bf6 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -204,6 +204,7 @@ static void usage(int op, const char * const myname) addlist(_(" --dbonly only modify database entries, not package files\n")); addlist(_(" --noprogressbar do not show a progress bar when downloading files\n")); addlist(_(" --noscriptlet do not execute the install scriptlet if one exists\n")); + addlist(_(" --nolist do not list packages before performing operation\n")); addlist(_(" -p, --print print the targets instead of performing the operation\n")); addlist(_(" --print-format <string>\n" " specify how the targets should be printed\n")); @@ -652,6 +653,9 @@ static int parsearg_trans(int opt) case OP_ASSUMEINSTALLED: parsearg_util_addlist(&(config->assumeinstalled)); break; + case OP_NOLIST: + config->nolist = 1; + break; default: return 1; } @@ -964,6 +968,7 @@ static int parseargs(int argc, char *argv[]) {"dbonly", no_argument, 0, OP_DBONLY}, {"color", required_argument, 0, OP_COLOR}, {"disable-download-timeout", no_argument, 0, OP_DISABLEDLTIMEOUT}, + {"nolist", no_argument, 0, OP_NOLIST}, {0, 0, 0, 0} }; diff --git a/src/pacman/remove.c b/src/pacman/remove.c index a2269ed8..5df45c69 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -164,8 +164,11 @@ int pacman_remove(alpm_list_t *targets) } /* print targets and ask user confirmation */ - display_targets(); - printf("\n"); + if(!config->nolist) { + display_targets(); + printf("\n"); + } + if(yesno(_("Do you want to remove these packages?")) == 0) { retval = 1; goto cleanup; diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 3c6be89d..1e0c6c91 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -793,8 +793,10 @@ int sync_prepare_execute(void) goto cleanup; } - display_targets(); - printf("\n"); + if(!config->nolist) { + display_targets(); + printf("\n"); + } int confirm; if(config->op_s_downloadonly) { -- 2.18.0
On 07/07/18 10:32, me@dk0.us wrote:
From: Dmitry Kudriavtsev <me@dk0.us>
Adds a --nolist option for package transactions. This option removes the list display of packages to be installed or removed.
Signed-off-by: Dmitry Kudriavtsev <me@dk0.us> ---
I don't think this is a good option to include.
diff --git a/src/pacman/remove.c b/src/pacman/remove.c index a2269ed8..5df45c69 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -164,8 +164,11 @@ int pacman_remove(alpm_list_t *targets) }
/* print targets and ask user confirmation */ - display_targets(); - printf("\n"); + if(!config->nolist) { + display_targets(); + printf("\n"); + } +
Here pacman would print nothing then ask if it is OK to remove those packages.
if(yesno(_("Do you want to remove these packages?")) == 0) {
retval = 1; goto cleanup; diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 3c6be89d..1e0c6c91 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -793,8 +793,10 @@ int sync_prepare_execute(void) goto cleanup; }
- display_targets(); - printf("\n"); + if(!config->nolist) { + display_targets(); + printf("\n"); + }
int confirm; if(config->op_s_downloadonly) {
On Sat, Jul 07, 2018 at 05:17:32PM +1000, Allan McRae wrote:
On 07/07/18 10:32, me@dk0.us wrote:
From: Dmitry Kudriavtsev <me@dk0.us>
Adds a --nolist option for package transactions. This option removes the list display of packages to be installed or removed.
Signed-off-by: Dmitry Kudriavtsev <me@dk0.us> ---
I don't think this is a good option to include.
Why not?
diff --git a/src/pacman/remove.c b/src/pacman/remove.c index a2269ed8..5df45c69 100644 --- a/src/pacman/remove.c +++ b/src/pacman/remove.c @@ -164,8 +164,11 @@ int pacman_remove(alpm_list_t *targets) }
/* print targets and ask user confirmation */ - display_targets(); - printf("\n"); + if(!config->nolist) { + display_targets(); + printf("\n"); + } +
Here pacman would print nothing then ask if it is OK to remove those packages.
Should --nolist imply --noconfirm?
if(yesno(_("Do you want to remove these packages?")) == 0) {
retval = 1; goto cleanup; diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 3c6be89d..1e0c6c91 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -793,8 +793,10 @@ int sync_prepare_execute(void) goto cleanup; }
- display_targets(); - printf("\n"); + if(!config->nolist) { + display_targets(); + printf("\n"); + }
int confirm; if(config->op_s_downloadonly) {
On 07/09/18 at 01:47am, Dmitry Kudriavtsev wrote:
On Sat, Jul 07, 2018 at 05:17:32PM +1000, Allan McRae wrote:
On 07/07/18 10:32, me@dk0.us wrote:
From: Dmitry Kudriavtsev <me@dk0.us>
Adds a --nolist option for package transactions. This option removes the list display of packages to be installed or removed.
Signed-off-by: Dmitry Kudriavtsev <me@dk0.us> ---
I don't think this is a good option to include.
Why not?
Blindly installing/removing packages without knowing what they are is generally a bad idea. What is the use case for this feature?
On Mon, Jul 09, 2018 at 06:10:41AM -0400, Andrew Gregory wrote:
On 07/09/18 at 01:47am, Dmitry Kudriavtsev wrote:
On Sat, Jul 07, 2018 at 05:17:32PM +1000, Allan McRae wrote:
On 07/07/18 10:32, me@dk0.us wrote:
From: Dmitry Kudriavtsev <me@dk0.us>
Adds a --nolist option for package transactions. This option removes the list display of packages to be installed or removed.
Signed-off-by: Dmitry Kudriavtsev <me@dk0.us> ---
I don't think this is a good option to include.
Why not?
Blindly installing/removing packages without knowing what they are is generally a bad idea. What is the use case for this feature?
Installing a list of packages that are already known, mostly for use in scripting or with -d.
On 07/09/2018 05:58 PM, Dmitry Kudriavtsev wrote:
On Mon, Jul 09, 2018 at 06:10:41AM -0400, Andrew Gregory wrote:
On 07/09/18 at 01:47am, Dmitry Kudriavtsev wrote:
On Sat, Jul 07, 2018 at 05:17:32PM +1000, Allan McRae wrote:
On 07/07/18 10:32, me@dk0.us wrote:
From: Dmitry Kudriavtsev <me@dk0.us>
Adds a --nolist option for package transactions. This option removes the list display of packages to be installed or removed.
Signed-off-by: Dmitry Kudriavtsev <me@dk0.us> ---
I don't think this is a good option to include.
Why not?
Blindly installing/removing packages without knowing what they are is generally a bad idea. What is the use case for this feature?
Installing a list of packages that are already known, mostly for use in scripting or with -d.
I don't see why we should encourage people to do that, at all. If you desperately dislike standard output, nothing is stopping you from using: yes y | pacman -S --noconfirm "${packagelist[@]}" > /dev/null 2>&1 Which also gets rid of the list, but with more honesty. Though honestly, if you're scripting this it boggles my mind that you don't want to preserve standard output in logs that you aren't looking at unless something bad happens, in which case you want as much information as possible... -- Eli Schwartz Bug Wrangler and Trusted User
On Mon, Jul 09, 2018 at 06:25:48PM -0400, Eli Schwartz wrote:
On 07/09/2018 05:58 PM, Dmitry Kudriavtsev wrote:
On Mon, Jul 09, 2018 at 06:10:41AM -0400, Andrew Gregory wrote:
On 07/09/18 at 01:47am, Dmitry Kudriavtsev wrote:
On Sat, Jul 07, 2018 at 05:17:32PM +1000, Allan McRae wrote:
On 07/07/18 10:32, me@dk0.us wrote:
From: Dmitry Kudriavtsev <me@dk0.us>
Adds a --nolist option for package transactions. This option removes the list display of packages to be installed or removed.
Signed-off-by: Dmitry Kudriavtsev <me@dk0.us> ---
I don't think this is a good option to include.
Why not?
Blindly installing/removing packages without knowing what they are is generally a bad idea. What is the use case for this feature?
Installing a list of packages that are already known, mostly for use in scripting or with -d.
I don't see why we should encourage people to do that, at all.
If you desperately dislike standard output, nothing is stopping you from using:
yes y | pacman -S --noconfirm "${packagelist[@]}" > /dev/null 2>&1
Which also gets rid of the list, but with more honesty.
Though honestly, if you're scripting this it boggles my mind that you don't want to preserve standard output in logs that you aren't looking at unless something bad happens, in which case you want as much information as possible...
Don't the transactions still get logged in the system locs if the UseSyslog preference is enabled?
-- Eli Schwartz Bug Wrangler and Trusted User
On 07/09/2018 07:03 PM, Dmitry Kudriavtsev wrote:
Though honestly, if you're scripting this it boggles my mind that you don't want to preserve standard output in logs that you aren't looking at unless something bad happens, in which case you want as much information as possible...
Don't the transactions still get logged in the system locs if the UseSyslog preference is enabled?
It does get logged to pacman.log, but those logs record transactions and not e.g. runtime warnings for ignored packages, inconsistent/missing files, prompts to replace one package with another via conflicts or replaces, etc. I guess you could stitch together a proper view of what happened, if you really needed to... just logging output seems wiser though. -- Eli Schwartz Bug Wrangler and Trusted User
participants (5)
-
Allan McRae
-
Andrew Gregory
-
Dmitry Kudriavtsev
-
Eli Schwartz
-
me@dk0.us