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: 47197

Signed-off-by: Leonardo Fagundes Luz Serrano <Leonardo.FagundesLuzSerrano@windriver.com>
Change-Id: I099f6e68145750f429a7c95ed200b6abf4649061
This commit is contained in:
Leonardo Fagundes Luz Serrano 2022-12-21 06:40:34 -03:00
parent 7e29fb67cf
commit 6c32612686
47 changed files with 58 additions and 253 deletions

View File

@ -29,11 +29,11 @@
- starlingx/update
- starlingx/utilities
files:
- python-k8sapp-auditd/*
- python3-k8sapp-auditd/*
vars:
tox_envlist: py39
python_version: 3.9
tox_extra_args: -c python-k8sapp-auditd/k8sapp_auditd/tox.ini
tox_extra_args: -c python3-k8sapp-auditd/k8sapp_auditd/tox.ini
- job:
name: k8sapp-auditd-tox-flake8
@ -42,10 +42,10 @@
Run flake8 test for k8sapp_auditd
nodeset: ubuntu-bionic
files:
- python-k8sapp-auditd/*
- python3-k8sapp-auditd/*
vars:
tox_envlist: flake8
tox_extra_args: -c python-k8sapp-auditd/k8sapp_auditd/tox.ini
tox_extra_args: -c python3-k8sapp-auditd/k8sapp_auditd/tox.ini
- job:
name: k8sapp-auditd-tox-pylint
parent: tox
@ -58,10 +58,10 @@
- starlingx/update
- starlingx/utilities
files:
- python-k8sapp-auditd/*
- python3-k8sapp-auditd/*
vars:
tox_envlist: pylint
tox_extra_args: -c python-k8sapp-auditd/k8sapp_auditd/tox.ini
tox_extra_args: -c python3-k8sapp-auditd/k8sapp_auditd/tox.ini
- job:
name: k8sapp-auditd-tox-bandit
parent: tox
@ -69,7 +69,7 @@
Run bandit test for k8sapp_auditd
nodeset: ubuntu-bionic
files:
- python-k8sapp-auditd/*
- python3-k8sapp-auditd/*
vars:
tox_envlist: bandit
tox_extra_args: -c python-k8sapp-auditd/k8sapp_auditd/tox.ini
tox_extra_args: -c python3-k8sapp-auditd/k8sapp_auditd/tox.ini

View File

@ -1 +0,0 @@
flock

View File

@ -1 +0,0 @@
stx-audit-helm

View File

@ -1,2 +0,0 @@
stx-audit-helm
python-k8sapp-auditd

View File

@ -1,2 +0,0 @@
stx-audit-helm
python-k8sapp-auditd

View File

@ -1 +0,0 @@
stx-audit-helm

View File

@ -1,3 +1,2 @@
python-k8sapp-auditd
python3-k8sapp-auditd
stx-audit-helm

View File

@ -1,9 +0,0 @@
SRC_DIR="k8sapp_auditd"
OPT_DEP_LIST="$STX_BASE/audit-armada-app/stx-audit-helm"
TIS_PATCH_VER=GITREVCOUNT
# Keep the SRCREV in sync with stx-auditd-helm so the app version is the same
# as the plugin version
TIS_BASE_SRCREV=eeb94bddc8c4c6e513adfae5505e174e0445deed

View File

@ -1,52 +0,0 @@
%global app_name auditd
%global pypi_name k8sapp-auditd
%global sname k8sapp_auditd
Name: python-%{pypi_name}
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
Summary: StarlingX sysinv extensions: Auditd
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: AUDITD 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_auditd-1.0.0.egg-info/*
usr/lib/python3/dist-packages/k8sapp_auditd/*

View File

@ -1,26 +0,0 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export APP_NAME=auditd
export PBR_VERSION=1.0.0
export PYBUILD_NAME=k8sapp-auditd
export ROOT=$(CURDIR)/debian/tmp
export SKIP_PIP_INSTALL=1
%:
dh $@ --with=python3 --buildsystem=pybuild
override_dh_auto_build:
python3 setup.py build
override_dh_auto_install:
python3 setup.py install --install-layout=deb --skip-build --root $(ROOT)
python3 setup.py bdist_wheel \
--universal \
-d $(ROOT)/plugins/$(APP_NAME)
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
# (tbogue) FIXME
PYTHONDIR=$(CURDIR) stestr run || true
endif

View File

@ -1,7 +0,0 @@
---
debname: python3-k8sapp-auditd
debver: 1.0-1
src_path: k8sapp_auditd
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 = auditd
export PYBUILD_NAME = k8sapp-auditd
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-auditd
debver: 1.0-1
src_path: k8sapp_auditd
revision:
dist: $STX_DIST
GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/audit-armada-app
BASE_SRCREV: eeb94bddc8c4c6e513adfae5505e174e0445deed

View File

@ -33,5 +33,5 @@ systemconfig.helm_applications =
systemconfig.helm_plugins.auditd =
001_auditd = k8sapp_auditd.helm.auditd:AuditdHelm
[wheel]
[bdist_wheel]
universal = 1

View File

@ -1,6 +0,0 @@
SRC_DIR="stx-audit-helm"
OPT_DEP_LIST="$STX_BASE/audit-armada-app/python-k8sapp-auditd"
TIS_PATCH_VER=GITREVCOUNT
TIS_BASE_SRCREV=eeb94bddc8c4c6e513adfae5505e174e0445deed

View File

@ -1,14 +0,0 @@
ARG BASE
FROM ${BASE} AS stx
RUN yum -y update
RUN yum -y install\
audit
COPY startAuditd.sh .
RUN mkdir -p /etc/audit
RUN touch /etc/audit/audit.rules
RUN chmod 600 /etc/audit/audit.rules
RUN chmod 755 startAuditd.sh
ENTRYPOINT ["./startAuditd.sh"]

View File

@ -1,26 +0,0 @@
#!/bin/bash
#
# Copyright (c) 2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
set -u
echo "Starting auditd …"
# update /etc/audit/audit.rules with any changes made to
# /etc/audit/rules.d/audit.rules
augenrules --load
# start auditd with no fork to run in the background in the container
/sbin/auditd -n -l
EXIT_STATUS=$?
if [ "$EXIT_STATUS" -ne "0" ]; then
echo "Error code: $EXIT_STATUS"
echo "Could not start auditd" >&2
fi
exit ${EXIT_STATUS}

View File

@ -1,87 +0,0 @@
#
# Copyright (c) 2021-2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# Application tunables (maps to metadata)
%global app_name auditd
%global helm_repo stx-platform
# 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 AUDITD FluxCD Helm Charts
Name: stx-audit-helm
Version: 1.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
BuildArch: noarch
BuildRequires: helm
BuildRequires: python-k8sapp-auditd
BuildRequires: python-k8sapp-auditd-wheels
%description
StarlingX AUDITD Helm Charts
%prep
%setup -n %{name}-%{version}
%build
cd helm-charts
make
cd -
# 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}
cp files/metadata.yaml %{app_staging}
mkdir -p %{app_staging}/charts
cp helm-charts/*.tgz %{app_staging}/charts
# 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
cp -R fluxcd-manifests %{app_staging}/
# calculate checksum of all files in app_staging
cd %{app_staging}
find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
tar -zcf %{_builddir}/%{app_tarball_fluxcd} -C %{app_staging}/ .
cd -
# 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}
install -m 644 -p -D files/auditd.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/auditd.logrotate
%files
%defattr(-,root,root,-)
%{app_folder}/%{app_tarball_fluxcd}
# logfile config files
%{_sysconfdir}/logrotate.d/auditd.logrotate

View File

@ -1,3 +0,0 @@
BUILDER=docker
LABEL=stx-audit
DOCKER_CONTEXT=docker/stx-audit

View File

@ -34,7 +34,7 @@ override_dh_auto_build:
# Copy the plugins: installed in the buildroot
mkdir -p $(STAGING)/plugins
cp /plugins/$(APP_NAME)/*.whl $(STAGING)/plugins
cp /plugins/*.whl $(STAGING)/plugins
# package fluxcd
cp -R fluxcd-manifests $(STAGING)/

View File

@ -4,4 +4,6 @@ debver: 1.0-1
src_path: stx-audit-helm
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true
GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/audit-armada-app
BASE_SRCREV: eeb94bddc8c4c6e513adfae5505e174e0445deed