File: //lib/python3/dist-packages/uaclient/__pycache__/version.cpython-310.pyc
o
�.�c> � @ s� d Z ddlZddlZddlmZ ddlmZ ddlm Z m
Z
mZ ddlm
Z
mZ ddlmZ ddlmZ d Zd
ZdZdefd
d�Zdee fdd�Zdee fdd�ZdS )z"
Client version related functions
� N)�inf)�Optional)�compare_versions� get_apt_cache_policy_for_package�get_apt_cache_time)�CANDIDATE_CACHE_PATH�UAC_RUN_PATH)�ProcessExecutionError)�subpz27.13.3z27.13.3~22.04.1zCandidate: (?P<candidate>.*?)\n�returnc C sp t �d�st S tj�tj�t��} tj�tj�| d��r6g d�}zt|�\}}|� � W S t
y5 Y tS w tS )aO Return the packaged version as a string
Prefer the binary PACKAGED_VESION set by debian/rules to DEB_VERSION.
If unavailable, check for a .git development environments:
a. If run in our upstream repo `git describe` will gives a leading
XX.Y so return the --long version to allow daily build recipes
to count commit offset from upstream's XX.Y signed tag.
b. If run in a git-ubuntu pkg repo, upstream tags aren't visible,
believe __VERSION__ is correct - there is and MUST always be a
test to make sure it matches debian/changelog
z@@PACKAGED_VERSIONz.git)�git�describez
--abbrev=8z--match=[0-9]*z--long)�PACKAGED_VERSION�
startswith�os�path�dirname�__file__�exists�joinr
�stripr �__VERSION__)�topdir�cmd�out�_� r �2/usr/lib/python3/dist-packages/uaclient/version.py�get_version s
�r c C s t � pt} tj�t�rt�t�j| k r`d }z9td�}t �
t|�}|rM|�d�}tj
tdd� ttd��}|�|� W d � |W S 1 sEw Y |W S W n ty_ |d ur]| Y S Y nw zttd��}|�� �� W d � W S 1 sxw Y W d S ty� Y d S w )Nzubuntu-advantage-tools� candidateT)�exist_ok�w�r)r r r r r r �stat�st_mtimer �re�search�CANDIDATE_REGEX�group�makedirsr �open�write� Exception�readr )�last_apt_cache_update�candidate_version�policy�match�fr r r �get_last_known_candidate1 sB
��
�����
$���r3 c C s t � } | rt| t� d�r| S d S )N�gt)r3 r r )r r r r �check_for_new_versionP s r5 )�__doc__�os.pathr r% �mathr �typingr �uaclient.aptr r r �uaclient.defaultsr r �uaclient.exceptionsr �uaclient.systemr
r r r'