From ad9d056d565fb23f9db4c63588ea5bcc59f8d016 Mon Sep 17 00:00:00 2001 From: Bruce Potter Date: Tue, 28 Apr 2020 11:00:10 -0400 Subject: [PATCH] tested rpm installation in docker container --- pkg/rpm/horizon-cli/horizon-cli.spec | 6 +++--- pkg/rpm/horizon/Makefile | 2 +- pkg/rpm/horizon/horizon.spec | 32 +++++++++++++++++----------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/pkg/rpm/horizon-cli/horizon-cli.spec b/pkg/rpm/horizon-cli/horizon-cli.spec index bc63a0890..ea5c195ee 100644 --- a/pkg/rpm/horizon-cli/horizon-cli.spec +++ b/pkg/rpm/horizon-cli/horizon-cli.spec @@ -8,7 +8,7 @@ Source: horizon-cli-%{version}.tar.gz Packager: Open-horizon BuildArch: x86_64 Provides: horizon-cli = %{version} -Requires: docker +#todo: restore: Requires: docker #Prefix: /usr/horizon #Vendor: ? @@ -16,7 +16,7 @@ Requires: docker #BuildRoot: ? %description -Open-horizon edge node agent +Open-horizon command line interface %prep %setup -q @@ -45,7 +45,7 @@ cp -a fs/* $RPM_BUILD_ROOT/ #%doc LICENSE COPYRIGHT /usr/horizon /etc/horizon -/etc/bash_completion.d +/etc/bash_completion.d/hzn_bash_autocomplete.sh %post # Runs after the pkg is installed diff --git a/pkg/rpm/horizon/Makefile b/pkg/rpm/horizon/Makefile index 92cccf89d..febb2a1b5 100644 --- a/pkg/rpm/horizon/Makefile +++ b/pkg/rpm/horizon/Makefile @@ -1,7 +1,7 @@ SHELL ?= /bin/bash -e #todo: not sure where/how to get this automatically export VERSION ?= 2.26.0 -export RELEASE ?= 1 +export RELEASE ?= 2 # rpmbuild does not give us a good way to set topdir, so use the default location RPMROOT ?= $(HOME)/rpmbuild RPMNAME ?= horizon diff --git a/pkg/rpm/horizon/horizon.spec b/pkg/rpm/horizon/horizon.spec index ab34e01f7..ed4a56def 100644 --- a/pkg/rpm/horizon/horizon.spec +++ b/pkg/rpm/horizon/horizon.spec @@ -9,6 +9,8 @@ Packager: Open-horizon BuildArch: x86_64 Provides: horizon = %{version} Requires: horizon-cli docker +# for testing installation in docker container: +#Requires: horizon-cli #Prefix: /usr/horizon #Vendor: ? @@ -50,12 +52,14 @@ cp -a fs/* $RPM_BUILD_ROOT/ %post # Runs after the pkg is installed -systemctl daemon-reload -systemctl enable horizon.service -if systemctl --quiet is-active horizon.service; then - systemctl stop horizon.service # in case this was an update -fi -systemctl start horizon.service +#if systemctl > /dev/null 2>&1; then # for testing installation in docker container + systemctl daemon-reload + systemctl enable horizon.service + if systemctl --quiet is-active horizon.service; then + systemctl stop horizon.service # in case this was an update + fi + systemctl start horizon.service +#fi %preun # This runs before the pkg is removed. But the way rpm updates work is the newer rpm is installed 1st (with reference counting on the files), @@ -80,11 +84,13 @@ if [ "$1" = "0" ]; then fi # Now shutdown the daemon - if systemctl --quiet is-enabled horizon.service; then - systemctl disable horizon.service - fi - systemctl daemon-reload - systemctl reset-failed + #if systemctl > /dev/null 2>&1; then # for testing installation in docker container + if systemctl --quiet is-enabled horizon.service; then + systemctl disable horizon.service + fi + systemctl daemon-reload + systemctl reset-failed + #fi fi %postun @@ -106,10 +112,10 @@ if [ "$1" = "0" ]; then fi # remove networks; some errors are expected b/c we're issuing remove command for even networks that should have already been removed by anax - cat /var/horizon/prerm.bridges <(echo $containers | jq -r '.NetworkSettings.Networks | keys[]') | sort | uniq | grep -v 'bridge' | xargs docker network rm 2> /dev/null + cat /var/horizon/prerm.bridges <<< $(echo $containers | jq -r '.NetworkSettings.Networks | keys[]') | sort | uniq | grep -v 'bridge' | xargs docker network rm 2> /dev/null # remove container images; TODO: use labels to remove infrastructure container images too once they are tagged properly upon - cat /var/horizon/prerm.images <(echo $containers | jq -r '.Config.Image') | sort | uniq | xargs docker rmi 2> /dev/null + cat /var/horizon/prerm.images <<< $(echo $containers | jq -r '.Config.Image') | sort | uniq | xargs docker rmi 2> /dev/null #todo: in the debian pkg, these cmds only run for the purge option. There doesn't seem to be an rpm equivalent rm -Rf /etc/horizon /var/cache/horizon /etc/default/horizon /var/tmp/horizon /var/run/horizon