cloudian: fix rpm pkging post install/uninstall step

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
Rohit Yadav 2017-10-03 14:59:00 +05:30
parent 34b62fa9c9
commit 2206741559
3 changed files with 48 additions and 104 deletions

View File

@ -3,7 +3,7 @@
echo "Preparing to package Cloudian Connector"
RPMDIR="$PWD/rpmbuild"
PKG="cloudian-cloudstack-4.9"
PKG="cloudian-cloudstack"
VERSION=`(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version) | grep --color=none '^[0-9]\.'`
if echo $VERSION | grep -q SNAPSHOT ; then
@ -37,5 +37,6 @@ if [ $? -ne 0 ]; then
exit 3
else
echo "RPM Build Done"
mv rpmbuild/RPMS/noarch/$PKG*rpm .
fi
exit

View File

@ -1,14 +1,14 @@
%define name cloudian-cloudstack
%define release 1
%define version 4.9
%define version 4.9_6.2
%define summary Integrates Cloudian into CloudStack
%define dataroot_dir %{_datarootdir}/cloudstack-management
%define client_dir %{dataroot_dir}/webapps/client
%define bin_dir %{_sbindir}
%define docs_dir %{_defaultdocdir}/cloudian-cloudstack
%define rpm_state_dir %{_localstatedir}/lib/rpm-state/cloudian-cloudstack
%define dataroot_dir %{_datarootdir}/cloudstack-management
%define client_dir %{dataroot_dir}/webapps/client
%define bin_dir %{_sbindir}
%define docs_dir %{_defaultdocdir}/cloudian-cloudstack
Summary: %{summary}
Vendor: Cloudian Inc.
@ -17,12 +17,13 @@ License: ASL 2.0
Name: %{name}
Version: %{version}
Release: %{release}
Source: %{name}-%{version}.tgz
Source: %{name}.tgz
BuildArch: noarch
Group: System Environment/Libraries
Requires: cloudstack-management >= 4.9
Requires: jre >= 1.7
Requires: sed
Requires: gzip
%description
@ -31,40 +32,41 @@ CloudStack users are also provisioned in Cloudian and users can use
Cloudian embedded in the CloudStack UI using single-sign-on.
%prep
# Unpack the source tar file
%setup -q -c -n %{name}
%build
# Build backend server jar
mvn clean install -o
# Copy UI plugin
cp -r ../../../../../../ui/plugins/cloudian .
# Build docs
cd docs && make && cd ..
%install
%__rm -rf %{buildroot}
%define appbase %{_builddir}/%{buildsubdir}
%define client %{appbase}/client
%define buildroot_docs %{buildroot}/%{docs_dir}
%define buildroot_rpm_state %{buildroot}/%{rpm_state_dir}
%define buildroot_client %{buildroot}/%{client_dir}
%define buildroot_webinf %{buildroot_client}/WEB-INF
%define buildroot_plugins %{buildroot_client}/plugins
%define buildroot_webinf %{buildroot_client}/WEB-INF
%define buildroot_docs %{buildroot}/%{docs_dir}
%__install -d %{buildroot_docs}
%__install -d %{buildroot_rpm_state}
%__install -d %{buildroot_client}
%__install -d %{buildroot_webinf}/lib
%__install -d %{buildroot_plugins}/cloudian
%__install -d %{buildroot_webinf}/lib
%__install -d %{buildroot_docs}
# Install our server side jar files
# Install our server side jar
%__install -m 0644 %{appbase}/target/cloud-plugin-integrations-cloudian-connector-*.jar %{buildroot_webinf}/lib/
# Install our ui plugin
%__install -m 0644 %{appbase}/cloudian/* %{buildroot_plugins}/cloudian/
%__install -m 0644 %{appbase}/cloudian/* %{buildroot_plugins}/cloudian/
# Install the script to enable/disable our connector
%__install -m 0644 %{appbase}/docs/*.html %{buildroot_docs}
%__install -m 0644 %{appbase}/docs/*.txt %{buildroot_docs}
# Install the docs
%__install -m 0644 %{appbase}/docs/*.html %{buildroot_docs}
%__install -m 0644 %{appbase}/docs/*.txt %{buildroot_docs}
%files
# List of files in the RPM
@ -72,99 +74,32 @@ cp -r ../../../../../../ui/plugins/cloudian .
%{client_dir}/WEB-INF/lib/*
%{client_dir}/plugins/cloudian/*
# our enable/disable script
%{rpm_state_dir}
%doc %{docs_dir}/*
%clean
# clean the buildroot
%__rm -rf %{buildroot}
%pre
# RPM pre-install script
if [ $1 -ge 2 ] ; then
# Upgrade is in progress.
# Only want to trigger if only the other package was updated.
touch %{rpm_state_dir}/notrigger
/usr/sbin/cloudian-cloudstack.sh status 1>/dev/null
if [ $? -eq 3 ] ; then
# Existing connector is enabled. Disable it now using the
# old patches and old script. Remember also to re-enable
# it in %post which will have our new script and new patches.
/usr/sbin/cloudian-cloudstack.sh disable norestart
touch %{rpm_state_dir}/enable
fi
fi
exit 0
%post
# RPM post-install script
if [ $1 -ge 2 ] ; then
# Upgrading. Check if package needs to be re-enabled.
if [ -e %{rpm_state_dir}/enable ] ; then
/usr/sbin/cloudian-cloudstack.sh enable
rm -f %{rpm_state_dir}/enable
if [ -f /usr/share/cloudstack-management/webapps/client/plugins/plugins.js ]; then
if ! grep -q cloudian /usr/share/cloudstack-management/webapps/client/plugins/plugins.js; then
rm -f /usr/share/cloudstack-management/webapps/client/plugins/plugins.js.gz
sed -i "/cloudStack.plugins/a 'cloudian'," /usr/share/cloudstack-management/webapps/client/plugins/plugins.js
gzip -c /usr/share/cloudstack-management/webapps/client/plugins/plugins.js > /usr/share/cloudstack-management/webapps/client/plugins/plugins.js.gz
fi
exit 0
fi
# Installation will require configuration.
cat 1>&2 << EOF
=====================================================================
HyperStore Connect for CloudPlatform has been successfully installed.
The next steps are:
1. # cloudian-cloudstack.sh configure
2. # cloudian-cloudstack.sh enable
Should you ever wish to disable the connector:
3. # cloudian-cloudstack.sh disable
=====================================================================
EOF
exit 0
%triggerin -- cloudstack-management
# RPM trigger on (re)install of cloudstack-management package
# or an install of our own package in which case we avoid running
if [ -e %{rpm_state_dir}/notrigger ] ; then
rm -f %{rpm_state_dir}/notrigger
exit 0
fi
# Other than that, only trigger if enabled.
/usr/sbin/cloudian-cloudstack.sh status 1>/dev/null
if [ $? -eq 3 ] ; then
# cloudstack-management server which owns the files that we patch has
# been re-installed (or force erased and installed) while our connector
# was enabled. Running disable and enable is dangerous the management
# servers files may have changed and no longer be patchable. At this
# point, it's best to clean up the .orig files of our patches and
# disable the connector without reverting the patches.
/usr/sbin/cloudian-cloudstack.sh forget
cat 1>&2 << EOF
=====================================================================
The cloudian-cloudstack connector has detected that a package that it
relies on "cloudstack-management" server has been re-installed. The
connector has been disabled.
You can re-enable the connector using:
1. # cloudian-cloudstack.sh enable
=====================================================================
EOF
fi
exit 0
%preun
# RPM pre-uninstall script
# For Upgrade, pre and post take care of things. In preun, we just
# have to disable the connector if it's enabled.
if [ $1 -eq 0 ] ; then
# Actual Un-install (not upgrade)
/usr/sbin/cloudian-cloudstack.sh disable
fi
exit 0
%postun
# RPM post-uninstall script
if [ -f /usr/share/cloudstack-management/webapps/client/plugins/plugins.js ]; then
if grep -q cloudian /usr/share/cloudstack-management/webapps/client/plugins/plugins.js; then
rm -f /usr/share/cloudstack-management/webapps/client/plugins/plugins.js.gz
sed -i "/'cloudian'/d" /usr/share/cloudstack-management/webapps/client/plugins/plugins.js
gzip -c /usr/share/cloudstack-management/webapps/client/plugins/plugins.js > /usr/share/cloudstack-management/webapps/client/plugins/plugins.js.gz
fi
fi
exit 0
%changelog

View File

@ -18,6 +18,10 @@ Version and the Cloudian Client version.
[options="header",cols="2,3,4"]
|======================
|Connector Version|CloudStack Compatibility|Cloudian Compatibility
|4.2.1_2.4-1|4.2.1|Versions 2.x only
|4.2.1_4.0.1-1|4.2.1|Versions 3.x onwards
|4.3_4.0.1-1|4.3|Versions 3.x onwards
|4.5_5.0-1|4.5|Versions 5.x onwards
|4.7_5.0-1|4.7|Versions 5.x onwards
|4.9_6.2-1|4.9|Versions 6.2 onwards
|======================
@ -41,12 +45,16 @@ Updated for Java 7::
Re-implementation of Connector::
Re-implemented Connector per CloudStack best-practices.
Configuration moved as CloudStack configuration::
Moved Cloudian configuration to CloudStack configuration.
New Configurations::
New configurations to fine-tune API call timeouts, SSL validations etc.
Moved Cloudian configuration to CloudStack configuration. Deprecates use
of connector properties file.
Simplifies Connector Administration::
Simplifies connector installation, configuration, uninstallation and
upgrades.
New API timeout configuration::
New configurations to fine-tune API call timeout.
User and Group auto-provisioning::
Better auto-provisioning of CloudStack users and domains as Cloudian users
and groups.
Better auto-provisioning and de-provisioning of CloudStack users and domains
as Cloudian users and groups.
Documentation Updates::
Various documentation updates.