Add writable directory to python path

After moving system application plugins to /var/stx_app/plugins,
platform-integ-apps fails. The reason of failing is because the new
plugins path is not searchable by python.
This is to fix the issue by adding the new plugins path to python path.

Passed: provision starlingx (Centos) and successfully
        apply platform-integ-apps
Passed: provision starlingx (Debian) and successfully
        apply platform-integ-apps

Change-Id: I24909d0fcfbf65eb69bb4d6e633d2c8e334d098f
Closes-bug: https://bugs.launchpad.net/starlingx/+bug/1972019
Signed-off-by: Bin Qian <bin.qian@windriver.com>
This commit is contained in:
Bin Qian 2022-05-05 17:16:54 -04:00
parent 4b65918992
commit 413074ad96
13 changed files with 132 additions and 0 deletions

View File

@ -30,3 +30,4 @@ openvswitch-config
multus-config
tuned-config
dmesg-config
python-siteconfig

View File

@ -15,6 +15,7 @@ ntp-config
openldap-config
openssh-config
pam-config
python-siteconfig
rabbitmq-server-config
rsync-config
shadow-utils-config

View File

@ -0,0 +1,2 @@
SRC_DIR="files"
TIS_PATCH_VER=PKG_GITREVCOUNT

View File

@ -0,0 +1,40 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2022 Wind River Systems, Inc.
#
Summary: python-siteconfig
Name: python-siteconfig
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: StarlingX
URL: unknown
BuildArch: noarch
Source: %name-%version.tar.gz
%define pythonroot /usr/lib64/python2.7/site-packages
%define stx_app_plugind /var/stx_app/plugins
Summary: package StarlingX configuration files for additional site-package.
%description
package StarlingX configuration files for additional site-package.
%prep
%setup
%build
%install
mkdir -p %{pythonroot}
%{__install} -p -D -m 0755 sitecustomize.py %{buildroot}%{pythonroot}/sitecustomize.py
%post
%files
%defattr(-,root,root,-)
%{pythonroot}/sitecustomize.py
%{pythonroot}/sitecustomize.pyc
%{pythonroot}/sitecustomize.pyo

View File

@ -0,0 +1,5 @@
python-siteconfig (1.0-1) unstable; urgency=medium
* Initial release
-- Bin Qian <bin.qian@windriver.com> Thru, 05 May 2022 10:10:10

View File

@ -0,0 +1,17 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# Copyright (C) 2022 Wind River Systems, Inc.
#
Source: python-siteconfig
Section: admin
Priority: optional
Maintainer: StarlingX Developers <starlingx-discuss@lists.starlingx.io>
Build-Depends: debhelper-compat (= 13)
Standards-Version: 4.4.1
Homepage: https://www.starlingx.io
Package: python-siteconfig
Architecture: any
Description: Package StarlingX configuration for additional site-package path.

View File

@ -0,0 +1,25 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files: *
Copyright: (c) 2022 Wind River Systems, Inc
License: Apache-2
Files: debian/*
Copyright: 2022 Wind River Systems, Inc
License: Apache-2
License: Apache-2
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
.
https://www.apache.org/licenses/LICENSE-2.0
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
.
On Debian-based systems the full text of the Apache version 2.0 license
can be found in `/usr/share/common-licenses/Apache-2.0'.

View File

@ -0,0 +1,6 @@
#!/bin/sh
mv /etc/python3.9/sitecustomize.py /etc/python3.9/sitecustomize.py.original
cp /etc/python3.9/sitecustomize.py.stx /etc/python3.9/sitecustomize.py
#DEBHELPER#

View File

@ -0,0 +1 @@
sitecustomize.py.stx /etc/python3.9/

View File

@ -0,0 +1,7 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#export DH_VERBOSE = 1
%:
dh $@

View File

@ -0,0 +1,7 @@
---
debname: python-siteconfig
debver: 1.0-1
src_path: source
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true

View File

@ -0,0 +1,6 @@
import site
# Add a writable location to sys.path for discovery of
# application plugin modules
site.addsitedir('/var/stx_app/plugins')

View File

@ -0,0 +1,14 @@
# install the apport exception handler if available
try:
import apport_python_hook
except ImportError:
pass
else:
apport_python_hook.install()
import site
# A writable location to sys.path for discovery of application
# plugin modules
site.addsitedir('/var/stx_app/plugins')