Skip to content

Commit 8d8c6dc

Browse files
authored
Patch tdnf to fix issue with installonlypkgs being removed by tdnf autoremove commands (#12102)
1 parent 0a08398 commit 8d8c6dc

File tree

6 files changed

+133
-25
lines changed

6 files changed

+133
-25
lines changed
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
From de3e822976773916caa913e4339a35c08a98569d Mon Sep 17 00:00:00 2001
2+
From: Sam Meluch <[email protected]>
3+
Date: Thu, 23 Jan 2025 11:55:10 -0800
4+
Subject: [PATCH] Retain installonlypkg install status on upgrade
5+
6+
---
7+
client/goal.c | 30 +++++++++++++++++++++
8+
pytests/tests/test_multiinstall.py | 42 ++++++++++++++++++++++++++++++
9+
2 files changed, 72 insertions(+)
10+
11+
diff --git a/client/goal.c b/client/goal.c
12+
index 4d95c71..f2360c4 100644
13+
--- a/client/goal.c
14+
+++ b/client/goal.c
15+
@@ -754,6 +754,36 @@ TDNFMarkAutoInstalled(
16+
}
17+
}
18+
}
19+
+ /* During upgrades, ppInfo->pPkgsToInstall contains any packages that are
20+
+ being installed as a dependency automatically as well as any
21+
+ ppszInstallOnlyPkgs which are installing a new version. The packages
22+
+ configured as installonlypkgs need to retain to retain their previous
23+
+ install status.
24+
+ */
25+
+ if (nFlag == 1 && pTdnf->pConf && pTdnf->pConf->ppszInstallOnlyPkgs)
26+
+ {
27+
+ for (int i = 0; pTdnf->pConf->ppszInstallOnlyPkgs[i]; i++)
28+
+ {
29+
+ if (strcmp(pTdnf->pConf->ppszInstallOnlyPkgs[i], pszName) == 0)
30+
+ {
31+
+ // Lookup current auto install status, ensure matching status
32+
+ int value = 0;
33+
+ rc = history_get_auto_flag(pHistoryCtx, pszName, &value);
34+
+ if (rc != 0)
35+
+ {
36+
+ dwError = ERROR_TDNF_HISTORY_ERROR;
37+
+ BAIL_ON_TDNF_ERROR(dwError);
38+
+ }
39+
+ if (value == 0)
40+
+ {
41+
+ // Packages previously marked as user installed should
42+
+ // remain user installed.
43+
+ nFlag = 0;
44+
+ break;
45+
+ }
46+
+ }
47+
+ }
48+
+ }
49+
if (!nAutoOnly || nFlag == 1)
50+
{
51+
rc = history_set_auto_flag(pHistoryCtx, pszName, nFlag);
52+
diff --git a/pytests/tests/test_multiinstall.py b/pytests/tests/test_multiinstall.py
53+
index efc921c..e069fe1 100644
54+
--- a/pytests/tests/test_multiinstall.py
55+
+++ b/pytests/tests/test_multiinstall.py
56+
@@ -149,3 +149,45 @@ def test_install_reinstall(utils):
57+
# both pkgs should remain installed:
58+
assert utils.check_package(pkgname, version=first)
59+
assert utils.check_package(pkgname, version=second)
60+
+
61+
+def test_autoremove_after_upgrade_user_installed(utils):
62+
+ pkgname = PKGNAME
63+
+ utils.erase_package(pkgname)
64+
+
65+
+ # install first version
66+
+ first = PKG_VERSIONS[0]
67+
+ utils.run(['tdnf', 'install', '-y', '--nogpgcheck', f"{pkgname}={first}"])
68+
+ assert utils.check_package(pkgname, version=first)
69+
+
70+
+ # upgrade to latest
71+
+ upgrade_version = PKG_VERSIONS[3]
72+
+ utils.run(['tdnf', 'upgrade', '-y', '--nogpgcheck'])
73+
+ assert utils.check_package(pkgname, version=upgrade_version)
74+
+
75+
+ utils.run(['tdnf', 'autoremove', '-y'])
76+
+ # check both packages remain installed after autoremove
77+
+ assert utils.check_package(pkgname, version=upgrade_version)
78+
+ assert utils.check_package(pkgname, version=first)
79+
+
80+
+def test_autoremove_after_upgrade_auto_installed(utils):
81+
+ pkgname = PKGNAME
82+
+ utils.erase_package(pkgname)
83+
+
84+
+ # install first version
85+
+ first = PKG_VERSIONS[0]
86+
+ utils.run(['tdnf', 'install', '-y', '--nogpgcheck', f"{pkgname}={first}"])
87+
+ assert utils.check_package(pkgname, version=first)
88+
+
89+
+ # mark package as autoinstalled
90+
+ ret = utils.run(['tdnf', 'mark', 'remove', pkgname])
91+
+ assert ret['retval'] == 0
92+
+
93+
+ # upgrade to latest
94+
+ upgrade_version = PKG_VERSIONS[3]
95+
+ utils.run(['tdnf', 'upgrade', '-y', '--nogpgcheck'])
96+
+ assert utils.check_package(pkgname, version=upgrade_version)
97+
+
98+
+ utils.run(['tdnf', 'autoremove', '-y'])
99+
+ # check both packages remain installed after autoremove
100+
+ assert not utils.check_package(pkgname, version=upgrade_version)
101+
+ assert not utils.check_package(pkgname, version=first)
102+
--
103+
2.34.1
104+

SPECS/tdnf/tdnf.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Summary: dnf equivalent using C libs
55
Name: tdnf
66
Version: 3.5.8
7-
Release: 6%{?dist}
7+
Release: 7%{?dist}
88
License: LGPLv2.1 AND GPLv2
99
Vendor: Microsoft Corporation
1010
Distribution: Azure Linux
@@ -32,6 +32,7 @@ Patch6: fix-tests-for-azl.patch
3232
# Install only package configuration and implemenation
3333
Patch7: tdnf-add-installonlypkgs-config.patch
3434
Patch8: tdnf-installonlypkgs.patch
35+
Patch10: tdnf-installonly-install-status.patch
3536

3637
#Cmake requires binutils
3738
BuildRequires: binutils
@@ -241,6 +242,9 @@ fi
241242
/%{_lib}/systemd/system/tdnf*
242243

243244
%changelog
245+
* Thu Jan 23 2025 Sam Meluch <[email protected]> - 3.5.8-7
246+
- Fix an issue with autoremove for installonlypkgs on tdnf
247+
244248
* Tue Nov 19 2024 Sam Meluch <[email protected]> - 3.5.8-6
245249
- Add kernel-64k installonlypkgs entry
246250

toolkit/resources/manifests/package/pkggen_core_aarch64.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ lua-5.4.6-1.azl3.aarch64.rpm
211211
lua-libs-5.4.6-1.azl3.aarch64.rpm
212212
azurelinux-rpm-macros-3.0-7.azl3.noarch.rpm
213213
azurelinux-check-macros-3.0-7.azl3.noarch.rpm
214-
tdnf-3.5.8-6.azl3.aarch64.rpm
215-
tdnf-cli-libs-3.5.8-6.azl3.aarch64.rpm
216-
tdnf-devel-3.5.8-6.azl3.aarch64.rpm
217-
tdnf-plugin-repogpgcheck-3.5.8-6.azl3.aarch64.rpm
214+
tdnf-3.5.8-7.azl3.aarch64.rpm
215+
tdnf-cli-libs-3.5.8-7.azl3.aarch64.rpm
216+
tdnf-devel-3.5.8-7.azl3.aarch64.rpm
217+
tdnf-plugin-repogpgcheck-3.5.8-7.azl3.aarch64.rpm
218218
libassuan-2.5.6-1.azl3.aarch64.rpm
219219
libassuan-devel-2.5.6-1.azl3.aarch64.rpm
220220
libgpg-error-1.47-1.azl3.aarch64.rpm

toolkit/resources/manifests/package/pkggen_core_x86_64.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ lua-5.4.6-1.azl3.x86_64.rpm
211211
lua-libs-5.4.6-1.azl3.x86_64.rpm
212212
azurelinux-rpm-macros-3.0-7.azl3.noarch.rpm
213213
azurelinux-check-macros-3.0-7.azl3.noarch.rpm
214-
tdnf-3.5.8-6.azl3.x86_64.rpm
215-
tdnf-cli-libs-3.5.8-6.azl3.x86_64.rpm
216-
tdnf-devel-3.5.8-6.azl3.x86_64.rpm
217-
tdnf-plugin-repogpgcheck-3.5.8-6.azl3.x86_64.rpm
214+
tdnf-3.5.8-7.azl3.x86_64.rpm
215+
tdnf-cli-libs-3.5.8-7.azl3.x86_64.rpm
216+
tdnf-devel-3.5.8-7.azl3.x86_64.rpm
217+
tdnf-plugin-repogpgcheck-3.5.8-7.azl3.x86_64.rpm
218218
libassuan-2.5.6-1.azl3.x86_64.rpm
219219
libassuan-devel-2.5.6-1.azl3.x86_64.rpm
220220
libgpg-error-1.47-1.azl3.x86_64.rpm

toolkit/resources/manifests/package/toolchain_aarch64.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,14 @@ systemd-bootstrap-libs-250.3-17.azl3.aarch64.rpm
584584
systemd-bootstrap-rpm-macros-250.3-17.azl3.noarch.rpm
585585
tar-1.35-1.azl3.aarch64.rpm
586586
tar-debuginfo-1.35-1.azl3.aarch64.rpm
587-
tdnf-3.5.8-6.azl3.aarch64.rpm
588-
tdnf-autoupdate-3.5.8-6.azl3.aarch64.rpm
589-
tdnf-cli-libs-3.5.8-6.azl3.aarch64.rpm
590-
tdnf-debuginfo-3.5.8-6.azl3.aarch64.rpm
591-
tdnf-devel-3.5.8-6.azl3.aarch64.rpm
592-
tdnf-plugin-metalink-3.5.8-6.azl3.aarch64.rpm
593-
tdnf-plugin-repogpgcheck-3.5.8-6.azl3.aarch64.rpm
594-
tdnf-python-3.5.8-6.azl3.aarch64.rpm
587+
tdnf-3.5.8-7.azl3.aarch64.rpm
588+
tdnf-autoupdate-3.5.8-7.azl3.aarch64.rpm
589+
tdnf-cli-libs-3.5.8-7.azl3.aarch64.rpm
590+
tdnf-debuginfo-3.5.8-7.azl3.aarch64.rpm
591+
tdnf-devel-3.5.8-7.azl3.aarch64.rpm
592+
tdnf-plugin-metalink-3.5.8-7.azl3.aarch64.rpm
593+
tdnf-plugin-repogpgcheck-3.5.8-7.azl3.aarch64.rpm
594+
tdnf-python-3.5.8-7.azl3.aarch64.rpm
595595
texinfo-7.0.3-1.azl3.aarch64.rpm
596596
texinfo-debuginfo-7.0.3-1.azl3.aarch64.rpm
597597
unzip-6.0-21.azl3.aarch64.rpm

toolkit/resources/manifests/package/toolchain_x86_64.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -592,14 +592,14 @@ systemd-bootstrap-libs-250.3-17.azl3.x86_64.rpm
592592
systemd-bootstrap-rpm-macros-250.3-17.azl3.noarch.rpm
593593
tar-1.35-1.azl3.x86_64.rpm
594594
tar-debuginfo-1.35-1.azl3.x86_64.rpm
595-
tdnf-3.5.8-6.azl3.x86_64.rpm
596-
tdnf-autoupdate-3.5.8-6.azl3.x86_64.rpm
597-
tdnf-cli-libs-3.5.8-6.azl3.x86_64.rpm
598-
tdnf-debuginfo-3.5.8-6.azl3.x86_64.rpm
599-
tdnf-devel-3.5.8-6.azl3.x86_64.rpm
600-
tdnf-plugin-metalink-3.5.8-6.azl3.x86_64.rpm
601-
tdnf-plugin-repogpgcheck-3.5.8-6.azl3.x86_64.rpm
602-
tdnf-python-3.5.8-6.azl3.x86_64.rpm
595+
tdnf-3.5.8-7.azl3.x86_64.rpm
596+
tdnf-autoupdate-3.5.8-7.azl3.x86_64.rpm
597+
tdnf-cli-libs-3.5.8-7.azl3.x86_64.rpm
598+
tdnf-debuginfo-3.5.8-7.azl3.x86_64.rpm
599+
tdnf-devel-3.5.8-7.azl3.x86_64.rpm
600+
tdnf-plugin-metalink-3.5.8-7.azl3.x86_64.rpm
601+
tdnf-plugin-repogpgcheck-3.5.8-7.azl3.x86_64.rpm
602+
tdnf-python-3.5.8-7.azl3.x86_64.rpm
603603
texinfo-7.0.3-1.azl3.x86_64.rpm
604604
texinfo-debuginfo-7.0.3-1.azl3.x86_64.rpm
605605
unzip-6.0-21.azl3.x86_64.rpm

0 commit comments

Comments
 (0)