From patchwork Mon Sep 20 19:35:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: morganamilo X-Patchwork-Id: 1968 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.21) for (single-drop); Mon, 20 Sep 2021 19:36:07 +0000 (UTC) Received: from mail.archlinux.org by mail.archlinux.org with LMTP id sZeSL6biSGGU0AUAK+/4rw (envelope-from ) for ; Mon, 20 Sep 2021 19:36:06 +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 B354192D895; Mon, 20 Sep 2021 19:36:05 +0000 (UTC) Received: from lists.archlinux.org (localhost [IPv6:::1]) by lists.archlinux.org (Postfix) with ESMTP id 65799845EEB; Mon, 20 Sep 2021 19:36:05 +0000 (UTC) X-Original-To: pacman-dev@lists.archlinux.org Delivered-To: pacman-dev@lists.archlinux.org Received: from mail.archlinux.org (mail.archlinux.org [IPv6:2a01:4f9:c010:3052::1]) by lists.archlinux.org (Postfix) with ESMTPS id CC321845EC0 for ; Mon, 20 Sep 2021 19:36:02 +0000 (UTC) From: morganamilo DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=archlinux.org; s=dkim-ed25519; t=1632166562; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=XhX9aQCANFjwmE8np+XdA9YDO1LgVU5fG7ZqQKUkCBo=; b=/zOoMZSWP+xLkNPaAfScPPeLGYH5ABqMaOwW5bzN/J1uik1ALtfVr/YZgrNp3DVrDYenRk 1exqrYHhqlRGABAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=archlinux.org; s=dkim-rsa; t=1632166562; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=XhX9aQCANFjwmE8np+XdA9YDO1LgVU5fG7ZqQKUkCBo=; b=ZdmyiPxx1qPLrBc2QgjkYyC8tcKbq80nb60szNDteTdISTd99URCqD9jRF9PvY6M2iyyNa hRqLEBF5xGYNkD977IWQulDzTTg3bNAhoLKbRzBRpmp2HOJHTtHBkYV9bkgF1GPvt42ULu 9p0GHz9lcWTilE+aLnh/CGFeUvW9ymdq/49DrBHeXF+0E4jy/APC1tjgR46aPe8opCCdtt iWun2sPYnFMLT3WBoh+47IxSzFpBXEpvVNd34+b2FeQOuGSwv6hujrkT0UJHZFBjgGx2fZ nxgrIJ0z0zYWeoTspJajtGO4Xlc/+gNsK6oujNtdJA0EOkLuwrLfv9+JGWebEtsTiF5sqB JD4DWOWCYKrGM8nUCdIXMl6ZzZM/S2Gho4NBXb+dBAXC+551eWejwSYykAs8jWZj1OgSHv +gaUre40PxWobqGkommr1P2wh3iaLnMmWsPbweD5Ybb8qre8sTzK2MLdICSJind+dcoJoz oRogA6FtTZnJ7c56UuqVnJmh6tSbQOYW9OhmRBe/kAHI0CgTKLh/RbVPcRiMCXPfmkbM/k ttPDOPcTEdLNcjYw5uS/xKijTlrLTA6kuor1XKzW7yid8SgUrP93aydTKsJiB+sWfO9lX6 1KyOL6x6BJOZfcPfh5jdc1ZRtMbUpvCk6N7GYZsBRSODEK5EGHfSY= To: pacman-dev@lists.archlinux.org Date: Mon, 20 Sep 2021 20:35:16 +0100 Message-Id: <20210920193517.259549-1-morganamilo@archlinux.org> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Subject: [pacman-dev] [PATCH 1/3] alpm: add ALPM_TRANS_FLAG_NOKEEP X-BeenThere: pacman-dev@lists.archlinux.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussion list for pacman development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Discussion list for pacman development Errors-To: pacman-dev-bounces@lists.archlinux.org Sender: "pacman-dev" Authentication-Results: mail.archlinux.org; dkim=fail ("headers eddsa verify failed") header.d=archlinux.org header.s=dkim-ed25519 header.b="/zOoMZSW"; dkim=fail ("headers rsa verify failed") header.d=archlinux.org header.s=dkim-rsa header.b=ZdmyiPxx; dmarc=pass (policy=none) header.from=archlinux.org; 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: B354192D895 X-Spamd-Result: default: False [2.09 / 15.00]; SPOOF_REPLYTO(2.00)[archlinux.org,lists.archlinux.org]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; DMARC_POLICY_ALLOW_WITH_FAILURES(-0.50)[]; RCVD_IN_DNSWL_MED(-0.40)[2a01:4f9:c010:9eb4::1:from,2a01:4f9:c010:3052::1:received]; MAILLIST(-0.20)[mailman]; R_SPF_ALLOW(-0.20)[+ip6:2a01:4f9:c010:9eb4::1:c]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; FROM_HAS_DN(0.00)[]; HAS_REPLYTO(0.00)[pacman-dev@lists.archlinux.org]; ARC_NA(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[pacman-dev@lists.archlinux.org]; RCPT_COUNT_ONE(0.00)[1]; FROM_NEQ_ENVFROM(0.00)[morganamilo@archlinux.org,pacman-dev-bounces@lists.archlinux.org]; RCVD_TLS_LAST(0.00)[]; NEURAL_HAM(-0.00)[-1.000]; R_DKIM_REJECT(0.00)[archlinux.org:s=dkim-ed25519,archlinux.org:s=dkim-rsa]; TO_DN_NONE(0.00)[]; ASN(0.00)[asn:24940, ipnet:2a01:4f9::/32, country:DE]; RCVD_COUNT_THREE(0.00)[3]; DMARC_POLICY_ALLOW(0.00)[archlinux.org,none]; DKIM_TRACE(0.00)[archlinux.org:-]; MIME_TRACE(0.00)[0:+]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Server: mail.archlinux.org this flag prevents backup files from being kept on package installation. This is useful for resetting a package's config files back to their original state. Implements FS#59908 although with it's own flag name instead of reusing nosave. This allows nokeep to optionally create a pacnew that you can then choose to disable by also setting nosave. --- I actually very dislike NOKEEP but it was the best I could come up with I would have prefered overwrite or nosave but they are taken. Better names are welcome. --- lib/libalpm/alpm.h | 3 ++- lib/libalpm/remove.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 8d8fe243..c6048b63 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -2704,7 +2704,8 @@ int alpm_pkg_mtree_close(const alpm_pkg_t *pkg, struct archive *archive); typedef enum _alpm_transflag_t { /** Ignore dependency checks. */ ALPM_TRANS_FLAG_NODEPS = 1, - /* (1 << 1) flag can go here */ + /** Don't keep backup files when installing packages. */ + ALPM_TRANS_FLAG_NOKEEP = (1 << 1), /** Delete files even if they are tagged as backup. */ ALPM_TRANS_FLAG_NOSAVE = (1 << 2), /** Ignore version numbers when checking dependencies. */ diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c index de39724a..233fff0c 100644 --- a/lib/libalpm/remove.c +++ b/lib/libalpm/remove.c @@ -575,7 +575,9 @@ static int should_skip_file(alpm_handle_t *handle, { return _alpm_fnmatch_patterns(handle->noupgrade, path) == 0 || alpm_list_find_str(handle->trans->skip_remove, path) - || (newpkg && _alpm_needbackup(path, newpkg) + || (!(handle->trans->flags & ALPM_TRANS_FLAG_NOKEEP) + && newpkg + && _alpm_needbackup(path, newpkg) && alpm_filelist_contains(alpm_pkg_get_files(newpkg), path)); }