From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 0F50E1382C5 for ; Sat, 23 Jan 2021 23:39:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 054A7E0815; Sat, 23 Jan 2021 23:39:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 74730E0815 for ; Sat, 23 Jan 2021 23:39:10 +0000 (UTC) From: Zac Medico To: gentoo-portage-dev@lists.gentoo.org Cc: Zac Medico Subject: [gentoo-portage-dev] [PATCH] emaint --fix merges: add -y, --yes option Date: Sat, 23 Jan 2021 15:38:49 -0800 Message-Id: <20210123233849.44785-1-zmedico@gentoo.org> X-Mailer: git-send-email 2.26.2 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: be5f2b7a-fc7a-4bec-b615-5a8aa5139a8f X-Archives-Hash: ef4e08ccc107614d9ca85f86008c59cf Since the emaint --fix merges uses emerge --ask, add a -y, --yes option to use --ask=n instead. Bug: https://bugs.gentoo.org/766767 Signed-off-by: Zac Medico --- lib/portage/emaint/modules/merges/__init__.py | 14 ++++++++++++-- lib/portage/emaint/modules/merges/merges.py | 11 +++++++---- man/emaint.1 | 6 +++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/portage/emaint/modules/merges/__init__.py b/lib/portage/emaint/modules/merges/__init__.py index 89aa758a0..449f39dce 100644 --- a/lib/portage/emaint/modules/merges/__init__.py +++ b/lib/portage/emaint/modules/merges/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2005-2014 Gentoo Foundation +# Copyright 2005-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 doc = """Scan for failed merges and fix them.""" @@ -26,7 +26,17 @@ module_spec = { 'action': 'store_true', 'func': 'purge' } - } + }, + 'opt_desc': { + 'yes': { + "short": "-y", + "long": "--yes", + "help": ("(merges submodule only): Do not prompt for " + "emerge invocations"), + "action": "store_true", + "dest": "yes", + } + }, } } } diff --git a/lib/portage/emaint/modules/merges/merges.py b/lib/portage/emaint/modules/merges/merges.py index 775dc59d2..d60916f1e 100644 --- a/lib/portage/emaint/modules/merges/merges.py +++ b/lib/portage/emaint/modules/merges/merges.py @@ -1,4 +1,4 @@ -# Copyright 2005-2020 Gentoo Authors +# Copyright 2005-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 import portage @@ -186,7 +186,7 @@ class MergesHandler: pkg_atoms.add(pkg_atom) - def _emerge_pkg_atoms(self, module_output, pkg_atoms): + def _emerge_pkg_atoms(self, module_output, pkg_atoms, yes=False): """ Emerge the specified packages atoms. @@ -194,6 +194,8 @@ class MergesHandler: @type module_output: Class @param pkg_atoms: packages atoms to emerge @type pkg_atoms: set + @param yes: do not prompt for emerge invocations + @type yes: bool @rtype: list @return: List of results """ @@ -206,7 +208,7 @@ class MergesHandler: portage._python_interpreter, '-b', os.path.join(EPREFIX or '/', 'usr', 'bin', 'emerge'), - '--ask', + '--ask=n' if yes else '--ask', '--quiet', '--oneshot', '--complete-graph=y' @@ -265,7 +267,8 @@ class MergesHandler: errors.append(', '.join(sorted(failed_pkgs))) return (False, errors) self._remove_failed_dirs(failed_pkgs) - results = self._emerge_pkg_atoms(module_output, pkg_atoms) + results = self._emerge_pkg_atoms(module_output, pkg_atoms, + yes=kwargs.get('options', {}).get("yes", False)) # list any new failed merges for pkg in sorted(self._scan()): results.append("'%s' still found as a failed merge." % pkg) diff --git a/man/emaint.1 b/man/emaint.1 index d244756e9..c9f8ab939 100644 --- a/man/emaint.1 +++ b/man/emaint.1 @@ -1,4 +1,4 @@ -.TH "EMAINT" "1" "Jan 2017" "Portage VERSION" "Portage" +.TH "EMAINT" "1" "Jan 2021" "Portage VERSION" "Portage" .SH NAME emaint \- performs package management related system health checks and maintenance .SH SYNOPSIS @@ -82,6 +82,10 @@ OPTION .BR \-t \ \fINUM\fR,\ \-\-time \ \fINUM\fR Changes the minimum age \fINUM\fR (in days) of the logs to be listed or deleted. +.SH OPTIONS merges command only +.TP +.BR \-y ", " \-\-yes +Do not prompt for emerge invocations. .SH OPTIONS sync command only .TP .BR \-a ", " \-\-auto -- 2.26.2