[PATCH] Make unlocking error messages uniform
Ashok Gautham Jadatharan
ScriptDevil at zoho.com
Thu Dec 2 07:11:19 UTC 2021
Upon failing to unlock the database, pacman -Su provides a useful tip
related to unlocking it by deleting /var/lib/pacman/db.lck if it already
exists.
This fixes pacman -Syu to provide the same tip upon failing to lock.
Signed-off-by: Ashok Gautham Jadatharan <ScriptDevil at zoho.com>
---
src/pacman/util.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 0f50ae0b..d3422739 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -152,12 +152,25 @@ int sync_syncdbs(int level, alpm_list_t *syncs)
{
int ret;
int force = (level < 2 ? 0 : 1);
+ alpm_errno_t err;
multibar_move_completed_up(false);
ret = alpm_db_update(config->handle, syncs, force);
+
if(ret < 0) {
+ err = alpm_errno(config->handle);
pm_printf(ALPM_LOG_ERROR, _("failed to synchronize all databases (%s)\n"),
- alpm_strerror(alpm_errno(config->handle)));
+ alpm_strerror(err));
+
+ if(err == ALPM_ERR_HANDLE_LOCK) {
+ const char *lockfile = alpm_option_get_lockfile(config->handle);
+ pm_printf(ALPM_LOG_ERROR, _("could not lock database: %s\n"),
+ strerror(errno));
+ if(access(lockfile, F_OK) == 0) {
+ fprintf(stderr, _(" if you're sure a package manager is not already\n"
+ " running, you can remove %s\n"), lockfile);
+ }
+ }
}
return (ret >= 0);
--
2.34.1
More information about the pacman-dev
mailing list