Advertisement
Guest User

Untitled

a guest
Oct 12th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. #
  2. # Set DISTRO_VERSION and SDK_VERSION from git describe
  3. #
  4.  
  5. DISTRO_VERSION = "${@get_custom_distro_version(d)}"
  6.  
  7. def get_custom_distro_version(d):
  8.     import os
  9.     import bb
  10.  
  11.     datetime = d.getVar('DATETIME')
  12.     persist = bb.persist_data.persist('custom', d)
  13.     key = 'distro_version_git'
  14.  
  15.     # Check if we have a valid cached value
  16.     if key in persist and ':' in persist[key]:
  17.         cached_datetime, cached_ver = persist[key].split(':', maxsplit=1)
  18.         if cached_datetime == datetime:
  19.             return cached_ver
  20.  
  21.     srcdir = os.path.abspath(os.path.join(d.getVar('BBLAYERS_FETCH_DIR'), '..'))
  22.  
  23.     try:
  24.         ver, _ = bb.process.run('git describe --tags --dirty --long 2>/dev/null', cwd=srcdir)
  25.         ver = ver.strip()
  26.     except bb.process.ExecutionError:
  27.         bb.warn("Unable to set DISTRO_VERSION from git describe. Using '0.0'.")
  28.         ver = '0.0'
  29.  
  30.     bb.warn(f"Caching DISTRO_VERSION='{ver}' for build date {datetime}")
  31.     persist[key] = f"{datetime}:{ver}"
  32.     return ver
  33.  
  34. # Do not include date/time in hash, since this is only used to detect different bitbake runs
  35. get_custom_distro_version[vardepsexclude] = "DATETIME"
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement