Determine the SW_VERSION at run time
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
This commit is contained in:
parent
f3d747859d
commit
9594f8f1a8
@ -1,13 +0,0 @@
|
||||
The source patch keyring_path_change.patch import
|
||||
tsconfig, so add tsconfig to Depends
|
||||
|
||||
--- a/debian/control
|
||||
+++ b/debian/control
|
||||
@@ -20,6 +20,7 @@ Package: python3-keyring
|
||||
Architecture: all
|
||||
Depends: python3-jeepney (>= 0.4.2),
|
||||
python3-secretstorage (>= 3.2),
|
||||
+ tsconfig
|
||||
${misc:Depends},
|
||||
${python3:Depends}
|
||||
Suggests: gnome-keyring, libkf5wallet-bin, python3-dbus, python3-keyrings.alt
|
@ -1 +0,0 @@
|
||||
debian-depend-tsconfig.patch
|
@ -0,0 +1,46 @@
|
||||
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
|
||||
|
@ -1,23 +0,0 @@
|
||||
---
|
||||
keyring/util/platform_.py | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/keyring/util/platform_.py
|
||||
+++ b/keyring/util/platform_.py
|
||||
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import platform
|
||||
+from tsconfig.tsconfig import SW_VERSION
|
||||
|
||||
|
||||
def _settings_root_XP():
|
||||
@@ -21,7 +22,8 @@ def _data_root_Linux():
|
||||
Use freedesktop.org Base Dir Specfication to determine storage
|
||||
location.
|
||||
"""
|
||||
- fallback = os.path.expanduser('/opt/platform/.keyring/')
|
||||
+ 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')
|
||||
|
@ -1,2 +1,2 @@
|
||||
no_keyring_password.patch
|
||||
keyring_path_change.patch
|
||||
0001-Determine-the-SW_VERSION-at-run-time.patch
|
||||
|
Loading…
Reference in New Issue
Block a user