Server : nginx/1.18.0 System : Linux localhost 6.14.3-x86_64-linode168 #1 SMP PREEMPT_DYNAMIC Mon Apr 21 19:47:55 EDT 2025 x86_64 User : www-data ( 33) PHP Version : 8.0.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /usr/lib/python3/dist-packages/uaclient/ |
"""
Version determination functions
These are in their own file so they can be imported by setup.py before we have
any of our dependencies installed.
"""
import os.path
from uaclient import util
__VERSION__ = "27.6"
PACKAGED_VERSION = "27.6~20.04.1"
VERSION_TMPL = "{version}{feature_suffix}"
def get_version(_args=None, features={}):
"""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,
parse the debian/changelog in that case
"""
feature_suffix = ""
for key, value in sorted(features.items()):
feature_suffix += " {enabled}{name}".format(
enabled="+" if value else "-", name=key
)
if not PACKAGED_VERSION.startswith("@@PACKAGED_VERSION"):
return VERSION_TMPL.format(
version=PACKAGED_VERSION, feature_suffix=feature_suffix
)
topdir = os.path.dirname(os.path.dirname(__file__))
if os.path.exists(os.path.join(topdir, ".git")):
cmd = ["git", "describe", "--abbrev=8", "--match=[0-9]*", "--long"]
try:
out, _ = util.subp(cmd)
return out.strip() + feature_suffix
except util.ProcessExecutionError:
# Rely on debian/changelog because we are in a git-ubuntu or other
# packaging repo
cmd = ["dpkg-parsechangelog", "-S", "version"]
out, _ = util.subp(cmd)
return VERSION_TMPL.format(
version=out.strip(), feature_suffix=feature_suffix
)
return VERSION_TMPL.format(
version=__VERSION__, feature_suffix=feature_suffix
)