Skip to content

Commit

Permalink
IGNITE-15957: DEB and RPM initial commit (apache#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pochatkin authored Oct 11, 2022
1 parent 081b7c2 commit a197120
Show file tree
Hide file tree
Showing 30 changed files with 590 additions and 451 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.sh text eol=lf
*.env text eol=lf
*.service text eol=lf
*.conf text eol=lf
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Apache Ignite
Copyright 2021 The Apache Software Foundation
Copyright 2022 The Apache Software Foundation

This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ javacc = "com.intershop.gradle.javacc:4.0.1"
shadow = "com.github.johnrengelman.shadow:7.1.2"
cmake = "net.freudasoft.gradle-cmake-plugin:0.0.4"
modernizer = "com.github.andygoossens.modernizer:1.6.2"
nebula = "nebula.ospackage:9.1.1"
docker = "com.palantir.docker:0.34.0"

[libraries]
Expand Down
8 changes: 8 additions & 0 deletions modules/runner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,11 @@ dependencies {
checkstyleMain {
enabled = false
}

jar {
manifest {
attributes(
'Main-Class': 'org.apache.ignite.app.IgniteCliRunner'
)
}
}
98 changes: 95 additions & 3 deletions packaging/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ plugins {
id 'java'
id 'distribution'
alias(libs.plugins.docker)
alias(libs.plugins.nebula)
}

configurations {
Expand All @@ -27,6 +28,8 @@ configurations {
cliScripts
}

import org.apache.tools.ant.filters.ReplaceTokens

dependencies {
dbArtifacts(project(':ignite-runner'))
cliArtifacts(project(':ignite-cli'))
Expand Down Expand Up @@ -60,9 +63,9 @@ def dbContents = spec -> {
from ("$rootDir/assembly/README.md")
}
into('etc') {
from ("$rootDir/packaging/scripts/bootstrap-config")
from ("$rootDir/packaging/config/ignite-config.conf")
from ("$rootDir/packaging/config/ignite.java.util.logging.properties")
from ("${buildDir}/scripts/bootstrap-config")
from ("${buildDir}/config/ignite-config.conf")
from ("${buildDir}/config/ignite.java.util.logging.properties")
}
into('bin') {
fileMode 0755
Expand Down Expand Up @@ -129,3 +132,92 @@ task allDistZip(type: Zip) {
}

allDistZip.dependsOn cliDistZip, dbDistZip

def tokens = [
PRODUCT_NAME : 'ignite3db',
PRODUCT_DISPLAY_NAME : 'Apache Ignite',
USERNAME : 'ignite3',
GROUPNAME : 'ignite3',
INSTALL_DIR : '/usr/share/ignite3db',
CONF_DIR : '/etc/ignite3db',
LOG_DIR : '/var/log/ignite3db',
PID_DIR : '/var/run/ignite3db',
VARS_FILE_NAME : 'vars.env',
MIN_PRODUCT_VERSION : project.version.toString(),
PRODUCT_VERSION : project.version.toString(),
IGNITE_CONF_FILE : 'ignite-config.conf',
IGNITE_WORK_DIR : '/usr/share/ignite3db/work'
]

task replaceConfigVars(type: Copy) {
from("${projectDir}/config")
filter(ReplaceTokens, tokens: tokens)
into("${buildDir}/config")
}

task replaceScriptVars(type: Copy) {
from("${projectDir}/linux")
filter(ReplaceTokens, tokens: tokens)
into("${buildDir}/linux")
}

buildRpm {
dependsOn replaceScriptVars, replaceConfigVars
configurationFile = "/etc/ignite3/vars.env"

installUtils file("${buildDir}/linux/service/vars.env")
installUtils file("${buildDir}/linux/common.sh")
preInstall file("${buildDir}/linux/preInstall.sh")
postInstall file("${buildDir}/linux/postInstall.sh")
preUninstall file("${buildDir}/linux/rpm/preUninstall.sh")
postUninstall file("${buildDir}/linux/rpm/postUninstall.sh")
}

buildDeb {
dependsOn replaceScriptVars, replaceConfigVars
configurationFile = "/etc/ignite3/vars.env"

installUtils file("${buildDir}/linux/service/vars.env")
installUtils file("${buildDir}/linux/common.sh")
preInstall file("${buildDir}/linux/preInstall.sh")
postInstall file("${buildDir}/linux/postInstall.sh")
preUninstall file("${buildDir}/linux/deb/preUninstall.sh")
postUninstall file("${buildDir}/linux/deb/postUninstall.sh")
}

ospackage {
license "ASL 2.0"
packageName 'ignite3db'
packageGroup "System Environment/Daemons"
url "https://ignite.apache.org"
user tokens.USERNAME
packageDescription "This package will install Apache Ignite"
os LINUX

into(tokens.INSTALL_DIR) {
into("") {
from "${buildDir}/linux/service/ignite3db.service"
from "${buildDir}/linux/service/ignite3db.conf"
from("${buildDir}/linux/start.sh") {
fileMode 0755
}
}

into("lib") {
from configurations.dbArtifacts
}

into("etc") {
fileType CONFIG
from "${buildDir}/linux/service/vars.env"
from "${buildDir}/config/ignite.java.util.logging.properties"
from "${buildDir}/config/ignite-config.conf"
}

into("etc") {
from sourceSets.main.resources
}
}
link "/etc/ignite3db", "${tokens.INSTALL_DIR}/etc/"
link "/opt/ignite3db", "${tokens.INSTALL_DIR}"
}
12 changes: 7 additions & 5 deletions packaging/config/ignite.java.util.logging.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#
# Comma-separated list of logging "handlers". Note that some of them may be
# reconfigured (or even removed) at runtime according to system properties.
handlers=java.util.logging.ConsoleHandler
handlers=java.util.logging.FileHandler

#
# Default global logging level.
Expand All @@ -37,9 +37,11 @@ handlers=java.util.logging.ConsoleHandler
#
.level=INFO

# Console handler logs all messages with importance level `INFO` and above
# Console handler logs all messages with importance level `SEVERE` and above
# into standard error stream (`System.err`).
#
java.util.logging.ConsoleHandler.formatter = org.apache.ignite.lang.JavaLoggerFormatter
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.encoding = UTF-8
java.util.logging.FileHandler.formatter = org.apache.ignite.lang.JavaLoggerFormatter
java.util.logging.FileHandler.pattern = @LOG_DIR@/ignite3db-%g.log
java.util.logging.FileHandler.level = INFO
java.util.logging.FileHandler.limit = 10485760
java.util.logging.FileHandler.count = 10
5 changes: 0 additions & 5 deletions packaging/deb/changelog

This file was deleted.

14 changes: 0 additions & 14 deletions packaging/deb/control

This file was deleted.

11 changes: 0 additions & 11 deletions packaging/deb/copyright

This file was deleted.

36 changes: 0 additions & 36 deletions packaging/deb/rules

This file was deleted.

79 changes: 79 additions & 0 deletions packaging/linux/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/sh
#
# 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.
#

source_user_group() {
USERNAME="@USERNAME@"
GROUPNAME="@GROUPNAME@"

if [ ! "$(getent passwd ${USERNAME})" ]; then
/usr/sbin/useradd "${USERNAME}"
fi

if [ ! "$(getent group ${GROUPNAME})" ]; then
sudo groupadd "${GROUPNAME}"
sudo usermod -a -G "${GROUPNAME}" "${USERNAME}"
fi

if [ -f "@CONF_DIR@/@VARS_FILE_NAME@" ]; then . "@CONF_DIR@/@VARS_FILE_NAME@"; fi
}

pre_uninstall() {
if command -v initctl >/dev/null && initctl version | grep upstart >/dev/null; then
if test -f '@PID_DIR@/@[email protected]'; then
initctl stop '@PRODUCT_NAME@' >/dev/null 2>&1
fi
elif command -v systemctl >/dev/null && systemctl --version | grep systemd >/dev/null; then
if (systemctl is-active --quiet '@PRODUCT_NAME@'); then
systemctl stop '@PRODUCT_NAME@' >/dev/null 2>&1
fi
if (systemctl is-enabled --quiet '@PRODUCT_NAME@'); then
systemctl disable '@PRODUCT_NAME@'
fi
else
pid=$(pgrep -f '@PRODUCT_NAME@')
[ -n "$pid" ] && kill "$pid"
sleep 5
pid=$(pgrep -f '@PRODUCT_NAME@')
[ -n "$pid" ] && kill -9 "$pid"
fi
}

post_uninstall_remove() {
/bin/rm -rf '@INSTALL_DIR@' >/dev/null 2>&1
/bin/rm -rf '@LOG_DIR@' >/dev/null 2>&1
if command -v initctl >/dev/null && initctl version | grep upstart >/dev/null; then
/bin/rm -f '/etc/init/@[email protected]' >/dev/null 2>&1
/bin/rm -rf '@PID_DIR@' >/dev/null 2>&1
initctl reload-configuration
echo " @PRODUCT_DISPLAY_NAME@ uninstalled successfully."
elif command -v systemctl >/dev/null && systemctl --version | grep systemd >/dev/null; then
/bin/rm -f '/usr/lib/systemd/system/@[email protected]' >/dev/null 2>&1
systemctl daemon-reload
echo " @PRODUCT_DISPLAY_NAME@ uninstalled successfully."
fi
}

post_uninstall_upgrade() {
if command -v initctl >/dev/null && initctl version | grep upstart >/dev/null; then
initctl restart '@PRODUCT_NAME@'
echo " @PRODUCT_DISPLAY_NAME@ upgraded successfully."
elif command -v systemctl >/dev/null && systemctl --version | grep systemd >/dev/null; then
systemctl restart '@PRODUCT_NAME@'
echo " @PRODUCT_DISPLAY_NAME@ upgraded successfully."
fi
}
25 changes: 25 additions & 0 deletions packaging/linux/deb/postUninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
#
# 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.
#

case "$1" in
remove|purge)
post_uninstall_remove
;;
upgrade)
post_uninstall_upgrade
esac
19 changes: 19 additions & 0 deletions packaging/linux/deb/preUninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
#
# 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.
#

pre_uninstall
Loading

0 comments on commit a197120

Please sign in to comment.