[pacman-dev] [PATCH] Standardize output when db.lck is present
From: Pang Yan Han <pangyanhan@gmail.com> When db.lck file is present, pacman -Syy and other Sync operations involving transactions show: :: Synchronizing package databases... error: failed to update core (unable to lock database) error: failed to update extra (unable to lock database) error: failed to update community (unable to lock database) error: failed to update multilib (unable to lock database) error: failed to synchronize any databases Whereas pacman -U <pkg> shows: error: failed to init transaction (unable to lock database) if you're sure a package manager is not already running, you can remove /var/lib/pacman/db.lck which is much more meaningful. Standardize the output to that of pacman -U when db.lck is present. Reported-by: Allan McRae <allan@archlinux.org> Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> --- src/pacman/sync.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/src/pacman/sync.c b/src/pacman/sync.c index ea32a26..37f6ecb 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -288,6 +288,15 @@ static int sync_synctree(int level, alpm_list_t *syncs) ret = alpm_db_update((level < 2 ? 0 : 1), db); if(ret < 0) { + enum _alpm_errno_t err = alpm_errno(config->handle); + pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to init transaction (%s)\n"), + alpm_strerror(err)); + if(err == ALPM_ERR_HANDLE_LOCK) { + fprintf(stderr, _(" if you're sure a package manager is not already\n" + " running, you can remove %s\n"), + alpm_option_get_lockfile(config->handle)); + return 0; + } pm_fprintf(stderr, ALPM_LOG_ERROR, _("failed to update %s (%s)\n"), alpm_db_get_name(db), alpm_strerror(alpm_errno(config->handle))); } else if(ret == 1) { -- 1.7.6.1.385.gb7fcd0
On Sat, Aug 27, 2011 at 10:14 PM, <pangyanhan@gmail.com> wrote:
From: Pang Yan Han <pangyanhan@gmail.com>
When db.lck file is present, pacman -Syy and other Sync operations involving transactions show:
:: Synchronizing package databases... error: failed to update core (unable to lock database) error: failed to update extra (unable to lock database) error: failed to update community (unable to lock database) error: failed to update multilib (unable to lock database) error: failed to synchronize any databases
Whereas pacman -U <pkg> shows:
error: failed to init transaction (unable to lock database) if you're sure a package manager is not already running, you can remove /var/lib/pacman/db.lck
which is much more meaningful. Standardize the output to that of pacman -U when db.lck is present.
I don't like the implementation of this, similar to Nagy's concerns. I'm fine with output that looks like this, however:
:: Synchronizing package databases... error: failed to update core (unable to lock database) error: failed to update extra (unable to lock database) error: failed to update community (unable to lock database) error: failed to update multilib (unable to lock database) error: failed to synchronize any databases if you're sure a package manager is not already running, you can remove /var/lib/pacman/db.lck
Does that seem OK? So I would add this check the error and "if you're sure" display code only to the !success block. I'd also be fine with displaying the "failed to init transaction" message in there too (see below). I would also prefer not to duplicate code and long messages; if we can extract this into a trans_error() util method of some sort that would be great. The entire `ret == -1` block in trans_init can probably be extracted. -Dan
participants (2)
-
Dan McGee
-
pangyanhan@gmail.com