From patchwork Thu Dec 2 07:11:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashok Gautham Jadatharan X-Patchwork-Id: 1990 Return-Path: Delivered-To: patchwork@archlinux.org Received: from mail.archlinux.org [2a01:4f9:c010:3052::1] by patchwork.archlinux.org with IMAP (fetchmail-6.4.24) for (single-drop); Thu, 02 Dec 2021 07:11:46 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id CM/uArJxqGFu+wYAK+/4rw (envelope-from ) for ; Thu, 02 Dec 2021 07:11:46 +0000 Received: from lists.archlinux.org (lists.archlinux.org [IPv6:2a01:4f9:c010:9eb4::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.archlinux.org (Postfix) with ESMTPS id 9AE80AED413; Thu, 2 Dec 2021 07:11:44 +0000 (UTC) Received: from lists.archlinux.org (localhost [IPv6:::1]) by lists.archlinux.org (Postfix) with ESMTP id 445CCA2BF77; Thu, 2 Dec 2021 07:11:44 +0000 (UTC) X-Original-To: pacman-dev@lists.archlinux.org Delivered-To: pacman-dev@lists.archlinux.org Received: from sender4-of-o55.zoho.com (sender4-of-o55.zoho.com [136.143.188.55]) by lists.archlinux.org (Postfix) with ESMTPS id 35DA8A2BF5B for ; Thu, 2 Dec 2021 07:11:41 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1638429097; cv=none; d=zohomail.com; s=zohoarc; b=ZhMutNdDyTdfwFumZZA7m4uAKhmv8zzpkovtQ5ljzJll5d4KvVK6iB63FyIBhPV8xhGzXblPxsuzwtrKvoxIvVUO2W0fMJUN3LVQVff7tdh5oF5W8n5dWf+V6qe1e1yht+Ly9XUBoArNLK59bAK/1pXfdOtpMaywHGM66h1jTMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1638429097; h=Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=VXFCBnitjna6hk6FWdQhbt00k+hL0wHnwBdY5mU0j2w=; b=Qw3c6ZmZT2Yos1yMYKPlGnKoaLlbaoKVSzNoN2oT9lq1i8nYRpVmkfX9sjs4lwbYhuVmz5N2g6+2ll0qQNQlhKOk2zXDf47uTdQF8HzjM/AMVH5wSHCIqePGPY68yNH7sWpYKyx46OqchscNrTS/zbvRgpISMR27VFw/VbbVC6g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=zoho.com; spf=pass smtp.mailfrom=ScriptDevil@zoho.com; dmarc=pass header.from= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=from:to:cc:subject:date:message-id:mime-version; b=CjnnkQDmiOmdCgehCizcU6v/ehz+kghEjVdEtcVOQxrC/SSRYZK3Ogyw0u4hA5aIvcp62Iyug4hK SDalDshrGRJu+j9tLy/i/JZkUBAHsNgeJWJV0nxus7HLBv+Om2zv DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1638429097; s=zm2020; d=zoho.com; i=ScriptDevil@zoho.com; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Transfer-Encoding; bh=VXFCBnitjna6hk6FWdQhbt00k+hL0wHnwBdY5mU0j2w=; b=Zwo8wBP8sg8o1OkGNVRWemJGNoyx09T/PpyJmH2A7kpHDT6hd37FHjBgkQo3qihm ia3NX2U0wCTjefgncIyAsghg8dKNYhb3AMJye/2BwEVXHwoNSxN34M2nzCcGYZrYTju uFCrjm5RUcMJMifQa9R+h6kWOD85SF9AU2BJZSng= Received: from jughead.nvclient.nvidia.com\044nvidia.com (202.164.25.5 [202.164.25.5]) by mx.zohomail.com with SMTPS id 1638429093815280.19467595024946; Wed, 1 Dec 2021 23:11:33 -0800 (PST) From: Ashok Gautham Jadatharan To: pacman-dev@lists.archlinux.org Cc: Ashok Gautham Jadatharan Subject: [PATCH] Make unlocking error messages uniform Date: Thu, 2 Dec 2021 12:41:19 +0530 Message-Id: <20211202071119.11347-1-ScriptDevil@zoho.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-ZohoMailClient: External X-BeenThere: pacman-dev@lists.archlinux.org X-Mailman-Version: 2.1.37 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pacman-dev-bounces@lists.archlinux.org Sender: "pacman-dev" Authentication-Results: mail.archlinux.org; dkim=pass header.d=zoho.com header.s=zm2020 header.b=Zwo8wBP8; arc=pass ("zohomail.com:s=zohoarc:i=1"); dmarc=pass (policy=reject) header.from=zoho.com; spf=pass (mail.archlinux.org: domain of pacman-dev-bounces@lists.archlinux.org designates 2a01:4f9:c010:9eb4::1 as permitted sender) smtp.mailfrom=pacman-dev-bounces@lists.archlinux.org X-Rspamd-Queue-Id: 9AE80AED413 X-Spamd-Result: default: False [-1.41 / 15.00]; ARC_ALLOW(-1.00)[zohomail.com:s=zohoarc:i=1]; MID_CONTAINS_FROM(1.00)[]; RCVD_DKIM_ARC_DNSWL_MED(-0.50)[]; DMARC_POLICY_ALLOW(-0.50)[zoho.com,reject]; R_MISSING_CHARSET(0.50)[]; R_SPF_ALLOW(-0.20)[+ip6:2a01:4f9:c010:9eb4::1]; RCVD_IN_DNSWL_MED(-0.20)[2a01:4f9:c010:9eb4::1:from]; MAILLIST(-0.20)[mailman]; R_DKIM_ALLOW(-0.20)[zoho.com:s=zm2020]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[136.143.188.55:received]; PREVIOUSLY_DELIVERED(0.00)[pacman-dev@lists.archlinux.org]; NEURAL_HAM(-0.00)[-1.000]; DWL_DNSWL_NONE(0.00)[zoho.com:dkim]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:24940, ipnet:2a01:4f9::/32, country:DE]; RCPT_COUNT_TWO(0.00)[2]; RCVD_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[zoho.com]; FROM_NEQ_ENVFROM(0.00)[ScriptDevil@zoho.com,pacman-dev-bounces@lists.archlinux.org]; DKIM_TRACE(0.00)[zoho.com:+]; MIME_TRACE(0.00)[0:+]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; FREEMAIL_CC(0.00)[zoho.com]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Server: mail.archlinux.org 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 --- 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);