Eduardo Alberti 5179f7628a Fix unexpected behavior on reboot
when the machine reboots after the application upload and before
the "apply" command, the application doesn't install anymore.

To resolve this, the patch file was embedded in the lifecycle
file, removing the dependency on its presence in the file system.

Test Plan:
PASS: AIO-SX application upload, and install, successfully
PASS: AIO-SX application apply before a system reboot
PASS: AIO-SX application updated successfully
PASS: AIO-DX application upload, and install, successfully
PASS: AIO-DX application apply before a system reboot
PASS: AIO-DX application updated successfully
PASS: AIO-DX host swact

Closes-bug: #2084085
Change-Id: I88ba44f6d9d068fe5041fbefe3c032a34d1e393a
Signed-off-by: Eduardo Alberti <eduardo.alberti@windriver.com>
2024-10-28 11:31:37 -03:00

64 lines
2.1 KiB
Makefile

#!/usr/bin/make -f
# export DH_VERBOSE = 1
export ROOT = debian/tmp
export APP_FOLDER = $(ROOT)/usr/local/share/applications/helm
export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
export RELEASE = $(shell cat /etc/build.info | grep SW_VERSION | cut -d'"' -f2)
export REVISION = $(shell echo $(DEB_VERSION) | cut -f 4 -d '.')
export APP_NAME = kubernetes-power-manager
export APP_VERSION = $(RELEASE)-$(REVISION)
export APP_TARBALL = $(APP_NAME)-$(APP_VERSION).tgz
export HELM_REPO = stx-platform
export STAGING = staging
%:
dh $@
override_dh_auto_build:
# Setup the staging directory.
mkdir -p $(STAGING)
cp files/metadata.yaml $(STAGING)
cp -R fluxcd-manifests $(STAGING)
mkdir -p $(STAGING)/charts
cp /usr/lib/helm/kubernetes-power-manager-*.tgz $(STAGING)/charts
# Adjust the helmrelease yamls based on the chart versions
for c in $(STAGING)/charts/*; do \
chart=$$(basename $$c .tgz); \
chart_name=$${chart%-*}; \
chart_version=$${chart##*-}; \
echo "Found $$chart; name: $$chart_name, version: $$chart_version"; \
chart_manifest=$$(find $(STAGING)/fluxcd-manifests/$$chart_name -name helmrelease.yaml -exec grep -q $$chart_name {} \; -print); \
echo "Updating manifest: $$chart_manifest"; \
sed -i "s/REPLACE_HELM_CHART_VERSION/$$chart_version/g" $$chart_manifest; \
grep version $$chart_manifest; \
done
# Populate metadata
sed -i 's/APP_REPLACE_NAME/$(APP_NAME)/g' $(STAGING)/metadata.yaml
sed -i 's/APP_REPLACE_VERSION/$(APP_VERSION)/g' $(STAGING)/metadata.yaml
sed -i 's/HELM_REPLACE_REPO/$(HELM_REPO)/g' $(STAGING)/metadata.yaml
# Copy the plugins: installed in the buildroot
mkdir -p $(STAGING)/plugins
cp /plugins/*.whl $(STAGING)/plugins
# Create the app package.
cd $(STAGING) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
tar cfz $(APP_TARBALL) -C $(STAGING)/ .
# Cleanup staging
rm -rf $(STAGING)
override_dh_auto_install:
# Install the app tar file.
install -d -m 755 $(APP_FOLDER)
install -p -D -m 755 $(APP_TARBALL) $(APP_FOLDER)
override_dh_auto_test:
override_dh_usrlocal: