Open fititnt opened 3 years ago
/usr/lib/python3/dist-packages/apt/cache.py
, around 299 def __getitem__(self, key):
# type: (object) -> Package
""" look like a dictionary (get key) """
try:
key = str(key)
rawpkg = self._cache[key]
except KeyError:
raise KeyError('The cache has no package named %r' % key)
# It might be excluded due to not having a version or something
if not self.__is_real_pkg(rawpkg):
raise KeyError('The cache has no package named %r' % key)
pkg = self._rawpkg_to_pkg(rawpkg)
return pkg
/usr/local/sbin/tails-additional-software
, line 415-466def apt_hook_pre():
"""Subcommand to handle Dpkg::Pre-Install-Pkgs."""
_exit_if_in_live_build()
logging.info("Saving package changes")
apt_cache = apt.cache.Cache()
installed_packages = []
removed_packages = []
line = sys.stdin.readline()
if not line.startswith("VERSION 3"):
raise ASPDataError("APT data is not version 3")
line = sys.stdin.readline()
# Ignore configuration space, which ends with an empty line
while line != "\n":
line = sys.stdin.readline()
# Package action lines
for line in sys.stdin:
# Package action lines consist of five fields in Version 2: package
# name (without architecture qualification even if foreign), old
# version, direction of version change (< for upgrades, > for
# downgrades, = for no change), new version, action. The version
# fields are "-" for no version at all (for example when installing
# a package for the first time; no version is treated as earlier
# than any real version, so that is an upgrade, indicated as - <
# 1.23.4). The action field is "**CONFIGURE**" if the package is
# being configured, "**REMOVE**" if it is being removed, or the
# filename of a .deb file if it is being unpacked.
#
# In Version 3 after each version field follows the architecture of
# this version, which is "-" if there is no version, and a field
# showing the MultiArch type "same", "foreign", "allowed" or "none".
# Note that "none" is an incorrect typename which is just kept to
# remain compatible, it should be read as "no" and users are
# encouraged to support both.
#
# Example:
#
# colordif - - none < 1.0.16-1 all none **CONFIGURE**
package_name, old_version, old_arch, old_multiarch, direction, \
new_version, new_arch, new_multiarch, action = line.split()
if action.endswith(".deb"):
# Filter packages that will only be upgraded
if not apt_cache[package_name].is_installed:
installed_packages.append(package_name)
elif action.endswith("**REMOVE**"):
removed_packages.append(package_name)
result = {"installed": installed_packages, "removed": removed_packages}
with open(ASP_STATE_PACKAGES, 'w') as f:
json.dump(result, f)
/usr/local/sbin/tails-additional-software
, hotfixsudo gedit /usr/local/sbin/tails-additional-software
if action.endswith(".deb"):
# Filter packages that will only be upgraded
if not apt_cache[package_name].is_installed:
installed_packages.append(package_name)
We check if apt_cache[package_name]
is valid before trying to check if is_installed
if action.endswith(".deb"):
# Filter packages that will only be upgraded
if (package_name not in apt_cache) or apt_cache[package_name].is_installed:
installed_packages.append(package_name)
Even with previous hotfix, while it allow to install .deb files one time, if the user marked the software to automaticaly re-install, I think we hit another bug.
Tails seems to try to install vscode with sudo apt install code
but since this was an deb file, thats not the right command.
While I agree that the hotfix would not solve 100% of the problem, it at least allow install .deb files once. Good. Not perfect, but at least good.
See:
How to reproduce the error
complete log