/usr/lib/python3/dist-packages/uaclient
NameSizeModeActions
api/-0755rm
cli/-0755rm
clouds/-0755rm
daemon/-0755rm
entitlements/-0755rm
files/-0755rm
http/-0755rm
messages/-0755rm
timer/-0755rm
__pycache__/-0755rm
actions.py151870644editdlrm
apt.py371260644editdlrm
apt_news.py85870644editdlrm
config.py193610644editdlrm
contract.py367430644editdlrm
contract_data_types.py101740644editdlrm
data_types.py143290644editdlrm
defaults.py32690644editdlrm
event_logger.py82570644editdlrm
exceptions.py187240644editdlrm
gpg.py8360644editdlrm
livepatch.py131600644editdlrm
lock.py45250644editdlrm
log.py50170644editdlrm
secret_manager.py6480644editdlrm
security_status.py267850644editdlrm
snap.py64150644editdlrm
status.py292120644editdlrm
system.py287930644editdlrm
types.py3080644editdlrm
update_contract_info.py15860644editdlrm
upgrade_lts_contract.py32950644editdlrm
util.py158200644editdlrm
version.py26990644editdlrm
yaml.py8400644editdlrm
__init__.py00644editdlrm
Edit: /usr/lib/python3/dist-packages/uaclient/upgrade_lts_contract.py (3295B)
#!/usr/bin/env python3 """ This function is called from lib/upgrade_lts_contract.py and from lib/reboot_cmds.py This function should be used after running do-release-upgrade in a machine. It will detect any contract deltas between the release before do-release-upgrade and the current release. If we find any differences in the uaclient contract between those releases, we will apply that difference in the upgraded release. For example, suppose we are on Trusty and we are upgrading to Xenial. We found that the apt url for esm services on trusty: https://esm.ubuntu.com/ubuntu While on Xenial, the apt url is: https://esm.ubuntu.com/infra/ubuntu This script will detect differences like that and update the Xenial system to reflect them. """ import fcntl import logging from uaclient import defaults, exceptions, messages, system, util from uaclient.api import ProgressWrapper from uaclient.api.u.pro.status.is_attached.v1 import _is_attached from uaclient.config import UAConfig from uaclient.entitlements import ( entitlement_factory, entitlements_enable_order, ) from uaclient.entitlements.entitlement_status import ( ApplicabilityStatus, ApplicationStatus, ) # We consider the past release for LTSs to be the last LTS, # because we don't have any services available on non-LTS. # This makes it safer for us to try to process contract deltas. # For example, we had "jammy": "focal" even when Impish was # still supported. current_codename_to_past_codename = { "xenial": "trusty", "bionic": "xenial", "focal": "bionic", "jammy": "focal", "noble": "jammy", "plucky": "noble", "questing": "plucky", } LOG = logging.getLogger(util.replace_top_level_logger_name(__name__)) def process_contract_delta_after_apt_lock(cfg: UAConfig) -> None: LOG.debug("Check whether to upgrade-lts-contract") if not _is_attached(cfg).is_attached: LOG.debug("Skipping upgrade-lts-contract. Machine is unattached") return LOG.debug("Starting upgrade-lts-contract.") print(messages.RELEASE_UPGRADE_STARTING) print(messages.RELEASE_UPGRADE_APT_LOCK_WAIT) # Get the apt lock when it's released after do-release-upgrade with open("/var/lib/apt/lists/lock", "w") as lockfile: fcntl.lockf(lockfile.fileno(), fcntl.LOCK_EX) for name in entitlements_enable_order(cfg): try: entitlement = entitlement_factory( cfg=cfg, name=name, variant="", ) except exceptions.EntitlementNotFoundError: LOG.debug("entitlement not found: %s", name) application_status, _ = entitlement.application_status() applicability_status, _ = entitlement.applicability_status() if ( application_status == ApplicationStatus.ENABLED and applicability_status == ApplicabilityStatus.INAPPLICABLE ): LOG.debug("upgrade-lts-contract disabling %s", name) ret = entitlement._perform_disable(progress=ProgressWrapper()) if not ret: LOG.debug("upgrade-lts-contract failed disabling %s", name) print(messages.RELEASE_UPGRADE_SUCCESS) def remove_private_esm_apt_cache(): system.ensure_folder_absent(defaults.ESM_APT_ROOTDIR)