Bug#1053887: apt does not error and exit under some circumstances
Package: apt
Version: 2.6.0-1deepin5
Severity: normal
X-Debbugs-Cc: black-desk <me@black-desk.cn>, lichenggang@uniontech.com, sweetyfish@deepin.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Hi,
When a system is configured with no sources.list, or removing all
`Packages` files under /var/lib/apt/lists, running apt install with
a ReGex matching a local package and a non-existent version, apt doesn't
work as expected. For instance, running `apt installing '^apt$=10000`
is not failing.
Steps to Reproduce:
1. Remove sources.list and Removing all files under sources.list.d/
2. Run apt update to clean all caches
3. Run apt install '^apt$'=1000
Expected Behavior:
$ LANG=C apt install '^apt$'=1000
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package apt is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Version '1000' for 'apt' was not found
$ echo $?
100
Actual Behavior:
$ LANG=C apt install '^apt$'=1000
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'apt' for regex '^apt$'
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ echo $?
0
After bisecting the source, we found that this bug is introduced in "Allow =version
and /release selector on virtual packages" (572810e9f321237873d1536c88991d7825c6f1db).
In apt-pkg/cacheset.cc:493, when `Match.Find()` fails, the program runs
helper.canNotGetVersion(CacheSetHelper::VERSIONNUMBER, Cache, P).
However, ShowErrors are set previously in apt-pkg/cacheset.cc:468:
if (pkgset.getConstructor() != CacheSetHelper::UNKNOWN)
errors = helper.showErrors(false);
When attempting inserting error "Version '%s' for '%s' was not found" in
canNotGetVerFromVersionNumber, the error is ignored with ShowError=false;
A possible fix is to set ShowErrors to true before helper.canNotGetVersion()
and set it back afterwards.
Thanks!
Tianyu Chen @ deepin
- -- System Information:
Distributor ID: Deepin
Description: Deepin 23
Release: 23
Codename: beige
Architecture: x86_64
Kernel: Linux 6.1.32-amd64-desktop-hwe (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=zh_CN.UTF-8, LC_CTYPE=zh_CN.UTF-8 (charmap=UTF-8), LANGUAGE=zh_CN
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages apt depends on:
ii adduser 3.131-1deepin2
ii base-passwd 3.6.0
ii deepin-keyring 2021.06.07-1
ii gpgv 2.2.27-2+rb1
ii libapt-pkg6.0 2.6.0-1deepin5
ii libc6 2.35-deepin3
ii libgcc-s1 11.2.0-deepin2+rb2
ii libgnutls30 3.7.2-2
ii libseccomp2 2.5.4-1
ii libstdc++6 11.2.0-deepin2+rb2
ii libsystemd0 254-1
Versions of packages apt recommends:
ii ca-certificates 20211016
Versions of packages apt suggests:
pn apt-doc <none>
ii aptitude 0.8.13.1-1+dde
ii dpkg-dev 1.21.20-1deepin2+rb6
ii gnupg 2.2.27-2+rb1
pn powermgmt-base <none>
- -- no debconf information
-----BEGIN PGP SIGNATURE-----
iQJKBAEBCgA0FiEEymuVC2ScVNxadrE1GcPUSWHDMHwFAmUpYroWHHN3ZWV0eWZp
c2hAZGVlcGluLm9yZwAKCRAZw9RJYcMwfKCqD/40LtQrTl1oSwIYp8rqol6MJFTD
G6g9Lb8fKG43B9mulA6o0K3LTBiIx3iFJFKy3WGMv3sce608SXYbcTX3ypHKokkh
/XX+LmblDRixN/Oz0qhzPEJDMbS7wslY2c1NxqJRxSFlPoglT8JNhCLYuIHEaUSP
4mLF79JcPTvYf659GTtfJKDpafyb03oMtCkMxlJW7n2HT53jhtvZN6lwr7D+GPqp
goNRUgBVeDyiNC5AqBSnB/fogSoB/yBcwhOwQ9fy8lWgiBEn/Lk2NNN9D0htfzJK
S5K1Qq6W3A7/jmqqZ3GkNnhZASwBBbB6GSrVMXYXgIsr9fNp31+5ZduqmDBxgno0
/k8oivKw6IR4y95AWvL2y7EaEGcR6u1VIVEIKIIapeuHwDw+1XjRuCxPzT+jJGOn
sxNU/QZ23j+LzlMRlXZfKV0sk3WFaxV0zIdWhH12h3sfd62gI2W43jYWVrRltYaU
OtpYo4HC7tV+60KeIVPXIUNcwZHS+8mTq6vNaJS73rdYaVVKHSHE8TbJaGfZe3Qo
As7ZSD0FYnS9kV9icQ0x5uKzbqHSE4JVkihewO8mWoYDDXBNcgoiRoXEV9vTSuEY
eabrQTR2j2xUf/pWDX9rmZFVjMDJGImH3VvE2a981hq5OYgH0L0XCEpFJV84dAyM
g7EoWii8wrMK53LLUw==
=X3oU
-----END PGP SIGNATURE-----
Reply to: