Skip to content

Commit

Permalink
tested rpm installation in docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce Potter committed Apr 28, 2020
1 parent 56ca531 commit ad9d056
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
6 changes: 3 additions & 3 deletions pkg/rpm/horizon-cli/horizon-cli.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ 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: ?
#Distribution: ?
#BuildRoot: ?

%description
Open-horizon edge node agent
Open-horizon command line interface

%prep
%setup -q
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/rpm/horizon/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 19 additions & 13 deletions pkg/rpm/horizon/horizon.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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: ?
Expand Down Expand Up @@ -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),
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ad9d056

Please sign in to comment.