You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vk...@apache.org on 2021/08/16 21:08:00 UTC
[ignite-3] branch main updated: IGNITE-14016 - RPM package for
Ignite 3 (#29)
This is an automated email from the ASF dual-hosted git repository.
vkulichenko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 4a7f0a8 IGNITE-14016 - RPM package for Ignite 3 (#29)
4a7f0a8 is described below
commit 4a7f0a8c7d6409f28c270e41d496bab932d280f8
Author: Peter Ivanov <mr...@gmail.com>
AuthorDate: Tue Aug 17 00:07:55 2021 +0300
IGNITE-14016 - RPM package for Ignite 3 (#29)
---
deliveries/rpm/.gitignore | 2 +
deliveries/rpm/Dockerfile | 42 +++++++
deliveries/rpm/README.md | 48 ++++++++
deliveries/rpm/apache-ignite.spec | 236 ++++++++++++++++++++++++++++++++++++++
deliveries/rpm/build.sh | 38 ++++++
modules/cli/ignite.sh | 2 +-
6 files changed, 367 insertions(+), 1 deletion(-)
diff --git a/deliveries/rpm/.gitignore b/deliveries/rpm/.gitignore
new file mode 100644
index 0000000..6760d34
--- /dev/null
+++ b/deliveries/rpm/.gitignore
@@ -0,0 +1,2 @@
+ignite
+*.rpm
diff --git a/deliveries/rpm/Dockerfile b/deliveries/rpm/Dockerfile
new file mode 100644
index 0000000..a5a6620
--- /dev/null
+++ b/deliveries/rpm/Dockerfile
@@ -0,0 +1,42 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+FROM centos:8
+
+
+ENV TZ=Europe/Moscow
+ARG RPM_WORK_DIR="/tmp"
+ARG PACKAGE_VERSION
+
+
+WORKDIR ${RPM_WORK_DIR}
+
+
+# Install dependencies
+RUN yum check-update || true && \
+ yum install -y rpm-build
+
+
+# Copy build required files
+COPY apache-ignite.spec \
+ ignite \
+ build.sh \
+ ./
+
+
+# Run build
+RUN bash build.sh ${PACKAGE_VERSION}
+
diff --git a/deliveries/rpm/README.md b/deliveries/rpm/README.md
new file mode 100644
index 0000000..2fabbd9
--- /dev/null
+++ b/deliveries/rpm/README.md
@@ -0,0 +1,48 @@
+# Apache Ignite RPM package build
+
+
+### Prerequisites
+
+* **Operation system**: CentOS 8
+
+* **Packages**: rpm-build
+
+* **Assembled and prepared Apache Ignite**:
+```bash
+cd <project root>
+mvn clean package -Dmaven.test.skip
+cp -rfv modules/cli/target/ignite \
+ deliveries/rpm/
+```
+
+* **Exported package version variable**
+```bash
+cd deliveries/rpm
+PACKAGE_VERSION="$(grep -E '^\*' apache-ignite.spec | head -1 | sed -r 's|.*\s-\s||')"
+```
+
+<br/>
+
+
+### Building
+Run build script (from RPM build directory):
+```bash
+bash build.sh "${PACKAGE_VERSION}"
+```
+Built RPM package will be in RPM build directory
+
+<br/>
+
+### Building in Docker
+Run from RPM build directory:
+```bash
+
+docker build . --pull \
+ --build-arg PACKAGE_VERSION="${PACKAGE_VERSION}" \
+ -t apache-ignite-rpm:${PACKAGE_VERSION}
+docker run --rm \
+ --entrypoint \
+ cat apache-ignite-rpm:${PACKAGE_VERSION} /tmp/apache-ignite-${PACKAGE_VERSION}.noarch.rpm > apache-ignite-${PACKAGE_VERSION}.noarch.rpm
+```
+Built RPM package will be in RPM build directory
+
diff --git a/deliveries/rpm/apache-ignite.spec b/deliveries/rpm/apache-ignite.spec
new file mode 100644
index 0000000..6b293ac
--- /dev/null
+++ b/deliveries/rpm/apache-ignite.spec
@@ -0,0 +1,236 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+%define __jar_repack %{nil}
+%define user ignite
+%define _libdir /usr/lib
+%define _log %{_var}/log
+%define _sharedstatedir /var/lib
+
+
+
+#-------------------------------------------------------------------------------
+#
+# Packages' descriptions
+#
+Name: apache-ignite
+Version: 3.0.0
+Release: 1
+Summary: Apache Ignite In-Memory Computing, Database and Caching Platform
+Group: Development/System
+License: ASL 2.0
+URL: https://ignite.apache.org
+Requires: java-11 which
+Requires(pre): shadow-utils
+Provides: %{name}
+AutoReq: no
+AutoProv: no
+BuildArch: noarch
+%description
+Apache Ignite is a distributed database for high-performance computing with in-memory speed.
+
+
+
+%pre
+#-------------------------------------------------------------------------------
+#
+# Preinstall scripts
+# $1 can be:
+# 1 - Initial installation
+# 2 - Upgrade
+#
+echo "Preinstall mode: '$1'"
+case $1 in
+ 1|configure)
+ # Add service user
+ /usr/sbin/useradd -r -M -d %{_datadir}/%{name} -s /bin/bash %{user}
+ #useradd -r -md %{_datadir}/%{name} %{user}
+ #[ -f "%{_datadir}/%{name}/.bashrc" ] && echo "cd ~" >> %{_datadir}/%{name}/.bashrc
+ ;;
+esac
+
+
+
+%post
+#-------------------------------------------------------------------------------
+#
+# Postinstall scripts
+# $1 can be:
+# 1 - Initial installation
+# 2 - Upgrade
+#
+
+echoUpgradeMessage () {
+ echo "======================================================================================================="
+ echo " WARNING: Updating Apache Ignite's cluster version requires updating every node before starting grid "
+ echo "======================================================================================================="
+}
+
+case $1 in
+ 1|configure)
+ # DEB postinst upgrade
+ if [ ! -z "${2}" ]; then
+ echoUpgradeMessage
+ fi
+
+ # Set firewall rules
+ if [[ "$(type firewall-cmd &>/dev/null; echo $?)" -eq 0 && "$(systemctl is-active firewalld 2>/dev/null)" == "active" ]]
+ then
+ for port in s d
+ do
+ ${firewallCmd} -p tcp -m multiport --${port}ports 11211:11220,47500:47509,47100:47109 -j ACCEPT &>/dev/null
+ ${firewallCmd} -p udp -m multiport --${port}ports 47400:47409 -j ACCEPT &>/dev/null
+ done
+ ${firewallCmd} -m pkttype --pkt-type multicast -j ACCEPT &>/dev/null
+
+ systemctl restart firewalld
+ fi
+ ;;
+ 2)
+ # RPM postinst upgrade
+ echoUpgradeMessage
+esac
+
+# Copy and configure skel
+cp -rfv /etc/skel/.bash* %{_datadir}/%{name}
+echo "cd ~" >> %{_datadir}/%{name}/.bashrc
+
+# Change ownership for work and log directories (yum resets permissions on upgrade nevertheless)
+chown -R %{user}:%{user} %{_datadir}/%{name} \
+ %{_sharedstatedir}/%{name} \
+ %{_log}/%{name} \
+ %{_bindir}/ignite
+
+
+
+%preun
+#-------------------------------------------------------------------------------
+#
+# Pre-uninstall scripts
+# $1 can be:
+# 0 - Uninstallation
+# 1 - Upgrade
+#
+
+stopIgniteNodes () {
+ echo "Stopping ignite nodes"
+}
+
+case $1 in
+ 0|remove)
+ # Stop all nodes (both service and standalone)
+ stopIgniteNodes
+ ;;
+ 1|upgrade)
+ # Stop all nodes (both service and standalone)
+ echo "=================================================================================="
+ echo " WARNING: All running Apache Ignite's nodes will be stopped upon package update "
+ echo "=================================================================================="
+ stopIgniteNodes
+ ;;
+esac
+
+
+
+%postun
+#-------------------------------------------------------------------------------
+#
+# Post-uninstall scripts
+# $1 can be:
+# 0 - Uninstallation
+# 1 - Upgrade
+#
+
+case $1 in
+ 0|remove)
+ # Remove user
+ userdel %{user}
+
+ # Remove service PID directory
+ rm -rfv /var/run/%{name}
+
+ # Remove firewalld rules if firewalld is installed and running
+ if [[ "$(type firewall-cmd &>/dev/null; echo $?)" -eq 0 && "$(systemctl is-active firewalld)" == "active" ]]
+ then
+ for port in s d
+ do
+ firewall-cmd --permanent --direct --remove-rule ipv4 filter INPUT 0 -p tcp -m multiport --${port}ports 11211:11220,47500:47509,47100:47109 -j ACCEPT &>/dev/null
+ firewall-cmd --permanent --direct --remove-rule ipv4 filter INPUT 0 -p udp -m multiport --${port}ports 47400:47409 -j ACCEPT &>/dev/null
+ done
+ firewall-cmd --permanent --direct --remove-rule ipv4 filter INPUT 0 -m pkttype --pkt-type multicast -j ACCEPT &>/dev/null
+ systemctl restart firewalld
+ fi
+ ;;
+ 1|upgrade)
+ :
+ ;;
+esac
+
+
+
+%install
+#-------------------------------------------------------------------------------
+#
+# Prepare packages' layout
+#
+
+# Create base directory structure
+mkdir -pv %{buildroot}%{_datadir}/%{name}
+mkdir -pv %{buildroot}%{_libdir}/%{name}
+mkdir -pv %{buildroot}%{_log}/%{name}
+mkdir -pv %{buildroot}%{_sharedstatedir}/%{name}
+mkdir -pv %{buildroot}%{_sysconfdir}/%{name}
+mkdir -pv %{buildroot}%{_bindir}
+
+# Install binary
+cp -rfv ignite %{buildroot}%{_bindir}
+chmod +x %{buildroot}%{_bindir}/ignite
+
+# Install ignite-cli configuraton file
+touch %{buildroot}%{_sysconfdir}/%{name}/cfg
+echo "bin=%{_libdir}/%{name}" >> %{buildroot}%{_sysconfdir}/%{name}/cfg
+echo "work=%{_sharedstatedir}/%{name}" >> %{buildroot}%{_sysconfdir}/%{name}/cfg
+echo "config=%{_sysconfdir}/%{name}" >> %{buildroot}%{_sysconfdir}/%{name}/cfg
+echo "log=%{_log}/%{name}" >> %{buildroot}%{_sysconfdir}/%{name}/cfg
+ln -sfv %{_sysconfdir}/%{name}/cfg %{buildroot}%{_datadir}/%{name}/.ignitecfg
+
+
+
+%files
+#-------------------------------------------------------------------------------
+#
+# Package file list check
+#
+
+%dir %{_datadir}/%{name}
+%dir %{_sysconfdir}/%{name}
+%dir %{_sharedstatedir}/%{name}
+%dir %{_log}/%{name}
+
+%{_libdir}/%{name}
+%{_bindir}/ignite
+%{_sysconfdir}/%{name}
+%{_datadir}/%{name}/.ignitecfg
+
+
+%changelog
+#-------------------------------------------------------------------------------
+#
+# Changelog
+#
+
+* Fri Dec 11 2020 Petr Ivanov <mr...@gmail.com> - 3.0.0-1
+- Apache Ignite 3 initial release
+
diff --git a/deliveries/rpm/build.sh b/deliveries/rpm/build.sh
new file mode 100644
index 0000000..e51b568
--- /dev/null
+++ b/deliveries/rpm/build.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+set -o nounset; set -o errexit; set -o pipefail; set -o errtrace; set -o functrace
+
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+## VARS ##
+PACKAGE_VERSION="${1}"
+
+RPM_WORK_DIR="/tmp/apache-ignite-rpm"
+
+
+
+## START ##
+mkdir -pv ${RPM_WORK_DIR}/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
+cp -rfv ignite ${RPM_WORK_DIR}/BUILD/
+cp -rfv apache-ignite.spec ${RPM_WORK_DIR}/SPECS/
+sed -r "4 i if [ \"\$(whoami)\" != \"ignite\" ]; then echo \"Ignite CLI can only be run by 'ignite' user.\"; echo \"Swith user to ignite by executing '(sudo) su ignite'\"; exit 1; fi" \
+ -i ${RPM_WORK_DIR}/BUILD/ignite
+rpmbuild -bb \
+ --define "_topdir ${RPM_WORK_DIR}" \
+ ${RPM_WORK_DIR}/SPECS/apache-ignite.spec
+cp -rfv ${RPM_WORK_DIR}/RPMS/noarch/apache-ignite-${PACKAGE_VERSION}.noarch.rpm ./
+
diff --git a/modules/cli/ignite.sh b/modules/cli/ignite.sh
index ebe345d..ce80090 100644
--- a/modules/cli/ignite.sh
+++ b/modules/cli/ignite.sh
@@ -17,7 +17,7 @@
set -o nounset; set -o errexit; set -o pipefail; set -o errtrace; set -o functrace
-MYSELF=`which "${0}" 2>/dev/null`
+MYSELF=$(which "${0}" 2>/dev/null)
[ $? -gt 0 -a -f "${0}" ] && MYSELF="./${0}"
java=java
if test -n "${JAVA_HOME:-}"; then