Standardize app configs

Fixed versioning and adjusted some build files
to bring them as close to a standard as possible.

- Removed centos files
- Added version tracking via GITREVCOUNT
- Fixed mismatch in plugin name, set to python3-k8sapp-<app>
- Standardized plugin debian files (rules, *.install)
- Plugin wheels saved to /plugin instead of /plugin/<app>

Test Plan:
PASS - Build-pkgs -a
PASS - Build-image
PASS - Install, bootstrap, unlock
PASS - app tarball contains wheel file
PASS - wheel versioning updated properly

Story: 2010542
Task: 47192

Signed-off-by: Leonardo Fagundes Luz Serrano <Leonardo.FagundesLuzSerrano@windriver.com>
Change-Id: I73712a6b41639829cd56a02781bd8d80337a372a
This commit is contained in:
Leonardo Fagundes Luz Serrano 2022-12-20 17:01:30 -03:00
parent 056036a19b
commit 441d44eb2f
45 changed files with 59 additions and 226 deletions

View File

@ -28,11 +28,11 @@
- starlingx/update
- starlingx/utilities
files:
- python-k8sapp-oran-o2/*
- python3-k8sapp-oran-o2/*
vars:
tox_envlist: py39
python_version: 3.9
tox_extra_args: -c python-k8sapp-oran-o2/k8sapp_oran_o2/tox.ini
tox_extra_args: -c python3-k8sapp-oran-o2/k8sapp_oran_o2/tox.ini
- job:
name: k8sapp-oran-o2-tox-pylint
@ -46,10 +46,10 @@
- starlingx/update
- starlingx/utilities
files:
- python-k8sapp-oran-o2/*
- python3-k8sapp-oran-o2/*
vars:
tox_envlist: pylint
tox_extra_args: -c python-k8sapp-oran-o2/k8sapp_oran_o2/tox.ini
tox_extra_args: -c python3-k8sapp-oran-o2/k8sapp_oran_o2/tox.ini
- job:
name: stx-app-oran-o2-upload-git-mirror

View File

@ -1 +0,0 @@
flock

View File

@ -1 +0,0 @@
stx-oran-o2-helm

View File

@ -1,2 +0,0 @@
stx-oran-o2-helm
python-k8sapp-oran-o2

View File

@ -1,2 +0,0 @@
stx-oran-o2-helm
python-k8sapp-oran-o2

View File

@ -1 +0,0 @@
oran-o2-2.0.0.tar.gz#oran-o2#https://github.com/o-ran-sc/pti-o2/archive/2.0.0.tar.gz#http##

View File

@ -1 +1,2 @@
#stx-oran-o2-helm
stx-oran-o2-helm

View File

@ -1,2 +1,2 @@
python-k8sapp-oran-o2
python3-k8sapp-oran-o2
stx-oran-o2-helm

View File

@ -1,3 +0,0 @@
SRC_DIR="k8sapp_oran_o2"
TIS_PATCH_VER=PKG_GITREVCOUNT

View File

@ -1,52 +0,0 @@
%global app_name oran-o2
%global pypi_name k8sapp-oran-o2
%global sname k8sapp_oran_o2
Name: python-%{pypi_name}
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
Summary: StarlingX sysinv extensions: ORAN O2
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python-setuptools
BuildRequires: python-pbr
BuildRequires: python2-pip
BuildRequires: python2-wheel
%description
StarlingX sysinv extensions: ORAN O2 K8S app
%prep
%setup
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
%build
export PBR_VERSION=%{version}
%{__python2} setup.py build
%py2_build_wheel
%install
export PBR_VERSION=%{version}.%{tis_patch_ver}
export SKIP_PIP_INSTALL=1
%{__python2} setup.py install --skip-build --root %{buildroot}
mkdir -p ${RPM_BUILD_ROOT}/plugins/%{app_name}
install -m 644 dist/*.whl ${RPM_BUILD_ROOT}/plugins/%{app_name}/
%files
%{python2_sitelib}/%{sname}
%{python2_sitelib}/%{sname}-*.egg-info
%package wheels
Summary: %{name} wheels
%description wheels
Contains python wheels for %{name}
%files wheels
/plugins/*

View File

@ -1,2 +0,0 @@
usr/lib/python3/dist-packages/k8sapp_oran_o2-1.0.0.egg-info/*
usr/lib/python3/dist-packages/k8sapp_oran_o2/*

View File

@ -1,24 +0,0 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export APP_NAME=oran-o2
export PBR_VERSION=1.0.0
export PYBUILD_NAME=k8sapp_oran_o2
export ROOT=debian/tmp
%:
dh $@ --with=python3 --buildsystem=pybuild
override_dh_auto_install:
python3 setup.py install --install-layout=deb --root $(ROOT)
python3 setup.py bdist_wheel \
--universal \
-d $(ROOT)/plugins/$(APP_NAME)
override_dh_python3:
dh_python3 --shebang=/usr/bin/python3
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
PYTHONDIR=$(CURDIR) stestr run || true
endif

View File

@ -1,7 +0,0 @@
---
debname: python3-k8sapp-oran-o2
debver: 1.0-1
src_path: k8sapp_oran_o2
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true

View File

@ -0,0 +1 @@
plugins/*.whl

View File

@ -0,0 +1 @@
usr/lib/python3/dist-packages/k8sapp_*

View File

@ -0,0 +1,33 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export APP_NAME = oran-o2
export PYBUILD_NAME = k8sapp_oran_o2
export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
export MAJOR = $(shell echo $(DEB_VERSION) | cut -f 1 -d '-')
export MINOR_PATCH = $(shell echo $(DEB_VERSION) | cut -f 4 -d '.')
export PBR_VERSION = $(MAJOR).$(MINOR_PATCH)
export ROOT = $(CURDIR)/debian/tmp
export SKIP_PIP_INSTALL = 1
%:
dh $@ --with=python3 --buildsystem=pybuild
override_dh_auto_install:
env | sort
python3 setup.py install \
--install-layout=deb \
--root $(ROOT)
python3 setup.py bdist_wheel \
--universal \
-d $(ROOT)/plugins
override_dh_python3:
dh_python3 --shebang=/usr/bin/python3
override_dh_auto_test:
PYTHONDIR=$(CURDIR) stestr run

View File

@ -0,0 +1,9 @@
---
debname: python3-k8sapp-oran-o2
debver: 1.0-1
src_path: k8sapp_oran_o2
revision:
dist: $STX_DIST
GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/app-oran-o2
BASE_SRCREV: 49916455ef6c8d6fbee5293424a41c3d11d2eefb

View File

@ -35,5 +35,5 @@ systemconfig.helm_applications =
systemconfig.helm_plugins.oran_o2 =
001_oran-o2 = k8sapp_oran_o2.helm.oran_o2:Orano2Helm
[wheel]
[bdist_wheel]
universal = 1

View File

@ -1,5 +1,5 @@
[tox]
envlist = flake8,py27,py36,py39,pylint,bandit
envlist = flake8,py27,py39,pylint,bandit
minversion = 1.6
# disable source dist generation because Zuul fails on setting up
# pbr randomly in the sdist step.
@ -25,7 +25,7 @@ allowlist_externals = bash
install_command = pip install \
-v -v -v --use-deprecated legacy-resolver \
-c{toxinidir}/upper-constraints.txt \
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/stable/stein/upper-constraints.txt} \
-c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/stable/yoga/upper-constraints.txt} \
{opts} {packages}
# Note the hash seed is set to 0 until can be tested with a
@ -72,14 +72,6 @@ commands =
stestr run {posargs}
stestr slowest
[testenv:py36]
basepython = python3.6
usedevelop = True
commands =
{[testenv]commands}
stestr run {posargs}
stestr slowest
[testenv:py39]
basepython = python3.9
usedevelop = True

View File

@ -1,12 +0,0 @@
SRC_DIR="stx-oran-o2-helm"
CHART_TAR_NAME=oran-o2
FLUXCD_O2_VERSION=2.0.0
FLUXCD_TAR="$CHART_TAR_NAME-$FLUXCD_O2_VERSION.tar.gz"
COPY_LIST=" \
${CGCS_BASE}/downloads/$FLUXCD_TAR \
"
TIS_PATCH_VER=PKG_GITREVCOUNT

View File

@ -1,98 +0,0 @@
# Application tunables (maps to metadata)
%global app_name oran-o2
%global helm_repo stx-platform
%global fluxcd_o2_version 2.0.0
# Install location
%global app_folder /usr/local/share/applications/helm
# Build variables
%global helm_folder /usr/lib/helm
%global toolkit_version 0.1.0
Summary: StarlingX O-ORAN O2 Application FluxCD Helm Charts
Name: stx-oran-o2-helm
Version: 2.0.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: Wind River <info@windriver.com>
URL: unknown
Source0: %{name}-%{version}.tar.gz
Source1: oran-o2-%{fluxcd_o2_version}.tar.gz
BuildArch: noarch
BuildRequires: helm
BuildRequires: chartmuseum
BuildRequires: python-k8sapp-oran-o2
BuildRequires: python-k8sapp-oran-o2-wheels
%description
StarlingX O-ORAN O2 Application FluxCD Helm Charts
%prep
%setup
# set up fluxcd tar source
cd %{_builddir}
mkdir -p oran-o2
/usr/bin/tar -C oran-o2 --strip-components=1 -xvf %{SOURCE1}
%build
# Host a server for the charts
cd %{_builddir}/oran-o2
chartmuseum --debug --port=8879 --context-path='/charts' --storage="local" --storage-local-rootdir="." &
sleep 2
helm repo add local http://localhost:8879/charts
# Make Chart
mkdir -p %{_builddir}/oran-o2/o2-charts
mv %{_builddir}/oran-o2/charts/* %{_builddir}/oran-o2/o2-charts
mv %{_builddir}/oran-o2/o2-charts %{_builddir}/oran-o2/charts/oran-o2
cd %{_builddir}/stx-oran-o2-helm-%{version}
cp files/Makefile %{_builddir}/oran-o2/charts
cd %{_builddir}/oran-o2/charts
make oran-o2
# Terminate helm server (the last backgrounded task)
kill %1
# Create a chart tarball compliant with sysinv kube-app.py
%define app_staging %{_builddir}/staging
%define app_tarball_fluxcd %{app_name}-%{version}-%{tis_patch_ver}.tgz
# Setup staging
mkdir -p %{app_staging}
cd %{_builddir}/stx-oran-o2-helm-%{version}
cp files/metadata.yaml %{app_staging}
cp -Rv fluxcd-manifests %{app_staging}/
mkdir -p %{app_staging}/charts
cd %{_builddir}/oran-o2
cp charts/*.tgz %{app_staging}/charts
cd %{app_staging}
# Populate metadata
sed -i 's/@APP_NAME@/%{app_name}/g' %{app_staging}/metadata.yaml
sed -i 's/@APP_VERSION@/%{version}-%{tis_patch_ver}/g' %{app_staging}/metadata.yaml
sed -i 's/@HELM_REPO@/%{helm_repo}/g' %{app_staging}/metadata.yaml
# Copy the plugins: installed in the buildroot
mkdir -p %{app_staging}/plugins
cp /plugins/%{app_name}/*.whl %{app_staging}/plugins
find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
tar -zcf %{_builddir}/%{app_tarball_fluxcd} -C %{app_staging}/ .
# Cleanup staging
rm -fr %{app_staging}
%install
install -d -m 755 %{buildroot}/%{app_folder}
install -p -D -m 755 %{_builddir}/%{app_tarball_fluxcd} %{buildroot}/%{app_folder}
%files
%defattr(-,root,root,-)
%{app_folder}/%{app_tarball_fluxcd}

View File

@ -6,10 +6,10 @@ export APP_FOLDER = $(ROOT)/usr/local/share/applications/helm
export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
export MAJOR = $(shell echo $(DEB_VERSION) | cut -f 1 -d '.')
export MINOR_PATCH = $(shell echo $(DEB_VERSION) | cut -f 2 -d '.')
export MINOR = $(shell echo $(DEB_VERSION) | cut -f 2 -d '.')
export APP_NAME = oran-o2
export APP_VERSION = $(MAJOR).$(MINOR_PATCH)
export APP_VERSION = $(MAJOR).$(MINOR)
export APP_TARBALL_FLUXCD = $(APP_NAME)-$(APP_VERSION).tgz
export HELM_REPO = stx-platform
export STAGING_FLUXCD = staging-fluxcd
@ -55,7 +55,7 @@ override_dh_auto_build:
# Copy the plugins: installed in the buildroot
mkdir -p $(STAGING_FLUXCD)/plugins
cp /plugins/$(APP_NAME)/*.whl $(STAGING_FLUXCD)/plugins
cp /plugins/*.whl $(STAGING_FLUXCD)/plugins
cp -R fluxcd-manifests $(STAGING_FLUXCD)/

View File

@ -9,4 +9,6 @@ dl_files:
md5sum: b9dc448c4dbea0e5ad5f5702319eb24f
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true
GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/app-oran-o2
BASE_SRCREV: 49916455ef6c8d6fbee5293424a41c3d11d2eefb