Open-source IoT Platform - Device management, data collection, processing and visualization.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

215 lines
6.0 KiB

// SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
// SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
import org.apache.tools.ant.filters.ReplaceTokens
import org.redline_rpm.header.Flags
plugins {
id "com.netflix.nebula.ospackage" version "12.1.1"
}
buildDir = projectBuildDir
version = projectVersion
base {
distsDirectory = layout.buildDirectory.dir("./")
}
// OS Package plugin configuration
ospackage {
packageName = pkgName
version = pkgVersion
release = 1
os = LINUX
type = BINARY
into pkgInstallFolder
user = pkgUser
permissionGroup = pkgUser
// Copy the actual .jar file
from(mainJar) {
// Strip the version from the jar filename
rename { String fileName ->
"${pkgName}.jar"
}
filePermissions {
unix('r-x------') // 0500
}
into "bin"
}
from("${buildDir}/control/launcher") {
rename { String fileName ->
"${pkgName}"
}
filePermissions {
unix('r-x------') // 0500
}
into "bin"
}
from("${buildDir}/control/java-env") {
filePermissions {
unix('rw-r--r--') // 0644
}
into "bin"
}
if("${pkgCopyInstallScripts}".equalsIgnoreCase("true")) {
// Copy the install files
from("${buildDir}/bin/install/install.sh") {
filePermissions {
unix('rwxrwxr-x') // 0775
}
into "bin/install"
}
from("${buildDir}/bin/install/upgrade.sh") {
filePermissions {
unix('rwxrwxr-x') // 0775
}
into "bin/install"
}
from("${buildDir}/bin/install/logback.xml") {
into "bin/install"
}
}
// Copy the config files
from("${buildDir}/conf") {
exclude "${pkgName}.conf"
fileType CONFIG | NOREPLACE
filePermissions {
unix('rwxr-xr--') // 0754
}
into "conf"
}
// Copy the data files
from("${buildDir}/data") {
fileType CONFIG | NOREPLACE
filePermissions {
unix('rwxr-xr--') // 0754
}
into "data"
}
// Copy the extensions files
from("${buildDir}/extensions") {
into "extensions"
}
}
// Configure our RPM build task
buildRpm {
arch = NOARCH
archiveFileName = "${pkgName}.rpm"
// The RPM writer overwrites the file in place without truncating it, so a smaller rebuild keeps stale bytes
doFirst {
archiveFile.get().asFile.delete()
}
// RPM boolean expression syntax, since .or() chaining is for DEB only
requires("(java-${pkgMinJavaVersion} or java-${pkgMinJavaVersion}-headless or jre-${pkgMinJavaVersion} or jre-${pkgMinJavaVersion}-headless)")
requires("shadow-utils", "", Flags.SCRIPT_PRE)
if ("${pkgRequiresFonts}".equalsIgnoreCase("true")) {
requires("fontconfig")
requires("dejavu-sans-fonts")
}
from("${buildDir}/conf") {
include "${pkgName}.conf"
filter(ReplaceTokens, tokens: ['pkg.platform': 'rpm'])
fileType CONFIG | NOREPLACE
filePermissions {
unix('rwxr-xr--') // 0754
}
into "${pkgInstallFolder}/conf"
}
preInstall file("${buildDir}/control/rpm/preinst")
postInstall file("${buildDir}/control/rpm/postinst")
preUninstall file("${buildDir}/control/rpm/prerm")
postUninstall file("${buildDir}/control/rpm/postrm")
user = pkgUser
permissionGroup = pkgUser
// Copy the system unit files
from("${buildDir}/control/template.service") {
addParentDirs = false
filePermissions {
unix('rw-r--r--') // 0644
}
into "/usr/lib/systemd/system"
rename { String filename ->
"${pkgName}.service"
}
}
link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml")
link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")
}
// Same as the buildRpm task
buildDeb {
arch = "all"
archiveFileName = "${pkgName}.deb"
requires("openjdk-${pkgMinJavaVersion}-jre").or("java${pkgMinJavaVersion}-runtime").or("oracle-java${pkgMinJavaVersion}-installer").or("openjdk-${pkgMinJavaVersion}-jre-headless")
preDepends("adduser")
if ("${pkgRequiresFonts}".equalsIgnoreCase("true")) {
requires("fontconfig")
requires("fonts-dejavu-core")
// Debian and Ubuntu OpenJDK builds load the system HarfBuzz for text layout but only recommend it
requires("libharfbuzz0b")
}
from("${buildDir}/conf") {
include "${pkgName}.conf"
filter(ReplaceTokens, tokens: ['pkg.platform': 'deb'])
fileType CONFIG | NOREPLACE
filePermissions {
unix('rwxr-xr--') // 0754
}
into "${pkgInstallFolder}/conf"
}
configurationFile("${pkgInstallFolder}/conf/${pkgName}.conf")
configurationFile("${pkgInstallFolder}/conf/${pkgName}.yml")
configurationFile("${pkgInstallFolder}/conf/logback.xml")
configurationFile("${pkgInstallFolder}/conf/actor-system.conf")
preInstall file("${buildDir}/control/deb/preinst")
postInstall file("${buildDir}/control/deb/postinst")
preUninstall file("${buildDir}/control/deb/prerm")
postUninstall file("${buildDir}/control/deb/postrm")
user = pkgUser
permissionGroup = pkgUser
// Copy the system unit files
from("${buildDir}/control/template.service") {
addParentDirs = false
filePermissions {
unix('rw-r--r--') // 0644
}
into "/lib/systemd/system"
rename { String filename ->
"${pkgName}.service"
}
}
link("${pkgInstallFolder}/bin/${pkgName}.yml", "${pkgInstallFolder}/conf/${pkgName}.yml")
link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")
}
buildDeb.onlyIf { findProperty('skipDeb') != 'true' }
buildRpm.onlyIf { findProperty('skipRpm') != 'true' }