9594f8f1a8
Distro layer package 'python-keyring' has a dependency on flock layer package 'tsconfig'. This is s violation of the layering policy, preventing successful layerd builds. Get the SW_VERSION via parsing the /etc/build.info file instead of the tsconfig.tsconfig python module at run time. We do this so that python-keyring no longer has a runtime dependency on tsconfig. Test Plan: Pass: build python-keyring Pass: put the codes in a test.py. get the SW_VERSION variable by run the test.py in an environment in which build-info is installed. Pass: trigger exception if removing /etc/build.info, or no SW_VERSION in the file. Closes-Bug: https://bugs.launchpad.net/starlingx/+bug/1968611 Signed-off-by: Yue Tao <yue.tao@windriver.com> Change-Id: I7f0c4eaae7aacf5bcbef082817dc99a62600a162
47 lines
1.6 KiB
Diff
47 lines
1.6 KiB
Diff
From 6cceddb03a3cad7a09a70d0c2fdc901d9758c025 Mon Sep 17 00:00:00 2001
|
|
From: Yue Tao <Yue.Tao@windriver.com>
|
|
Date: Wed, 20 Apr 2022 14:29:27 +0800
|
|
Subject: [PATCH] Determine the SW_VERSION at run time
|
|
|
|
Get the SW_VERSION via parsing the /etc/build.info file instead of
|
|
tsconfig.tsconfig module at run time to break python-keyring run depends
|
|
on tsconfig.
|
|
|
|
Signed-off-by: Yue Tao <Yue.Tao@windriver.com>
|
|
---
|
|
keyring/util/platform_.py | 18 +++++++++++++++++-
|
|
1 file changed, 17 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/keyring/util/platform_.py b/keyring/util/platform_.py
|
|
index bb4d297..5eebd70 100644
|
|
--- a/keyring/util/platform_.py
|
|
+++ b/keyring/util/platform_.py
|
|
@@ -21,7 +21,23 @@ def _data_root_Linux():
|
|
Use freedesktop.org Base Dir Specfication to determine storage
|
|
location.
|
|
"""
|
|
- fallback = os.path.expanduser('/opt/platform/.keyring/')
|
|
+ build_info = "/etc/build.info"
|
|
+ try:
|
|
+ with open(build_info, 'r') as binfo:
|
|
+ lines = list(line for line in (p.strip() for p in binfo) if line)
|
|
+ except Exception as e:
|
|
+ print(e, file=sys.stderr)
|
|
+ raise IOError
|
|
+
|
|
+ sw_version = None
|
|
+ for entry in lines:
|
|
+ if entry.startswith('SW_VERSION='):
|
|
+ sw_version = entry.split("=")[1].strip('"')
|
|
+ break
|
|
+ if sw_version == None:
|
|
+ raise ValueError(f"No SW_VERSION found in {build_info}")
|
|
+ keyring_dir = os.path.join('/opt/platform/.keyring', sw_version)
|
|
+ fallback = os.path.expanduser(keyring_dir)
|
|
root = os.environ.get('XDG_DATA_HOME', None) or fallback
|
|
return os.path.join(root, 'python_keyring')
|
|
|
|
--
|
|
2.25.1
|
|
|