build.gradle 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /**
  2. * Copyright © 2016-2022 The Thingsboard Authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import org.apache.tools.ant.filters.ReplaceTokens
  17. plugins {
  18. id "nebula.ospackage" version "8.6.3"
  19. }
  20. buildDir = projectBuildDir
  21. version = projectVersion
  22. distsDirName = "./"
  23. // OS Package plugin configuration
  24. ospackage {
  25. packageName = pkgName
  26. version = "${project.version}"
  27. release = 1
  28. os = LINUX
  29. type = BINARY
  30. into pkgInstallFolder
  31. user pkgUser
  32. permissionGroup pkgUser
  33. // Copy the executable file
  34. from("${buildDir}/package/linux/bin/${pkgName}") {
  35. fileMode 0500
  36. into "bin"
  37. }
  38. // Copy the init file
  39. from("${buildDir}/package/linux/init/template") {
  40. fileMode 0500
  41. into "init"
  42. rename { String filename ->
  43. "${pkgName}"
  44. }
  45. }
  46. // Copy the config files
  47. from("${buildDir}/package/linux/conf") {
  48. fileType CONFIG | NOREPLACE
  49. fileMode 0754
  50. into "conf"
  51. }
  52. // Copy web files
  53. from("${buildDir}/web") {
  54. into "web"
  55. }
  56. }
  57. // Configure our RPM build task
  58. buildRpm {
  59. arch = X86_64
  60. archiveVersion = projectVersion.replace('-', '')
  61. archiveFileName = "${pkgName}.rpm"
  62. preInstall file("${buildDir}/control/rpm/preinst")
  63. postInstall file("${buildDir}/control/rpm/postinst")
  64. preUninstall file("${buildDir}/control/rpm/prerm")
  65. postUninstall file("${buildDir}/control/rpm/postrm")
  66. user pkgUser
  67. permissionGroup pkgUser
  68. // Copy the system unit files
  69. from("${buildDir}/control/template.service") {
  70. addParentDirs = false
  71. fileMode 0644
  72. into "/usr/lib/systemd/system"
  73. rename { String filename ->
  74. "${pkgName}.service"
  75. }
  76. }
  77. link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")
  78. }
  79. // Same as the buildRpm task
  80. buildDeb {
  81. arch = "amd64"
  82. archiveFileName = "${pkgName}.deb"
  83. configurationFile("${pkgInstallFolder}/conf/${pkgName}.conf")
  84. configurationFile("${pkgInstallFolder}/conf/custom-environment-variables.yml")
  85. configurationFile("${pkgInstallFolder}/conf/default.yml")
  86. configurationFile("${pkgInstallFolder}/conf/logger.js")
  87. preInstall file("${buildDir}/control/deb/preinst")
  88. postInstall file("${buildDir}/control/deb/postinst")
  89. preUninstall file("${buildDir}/control/deb/prerm")
  90. postUninstall file("${buildDir}/control/deb/postrm")
  91. user pkgUser
  92. permissionGroup pkgUser
  93. // Copy the system unit files
  94. from("${buildDir}/control/template.service") {
  95. addParentDirs = false
  96. fileMode 0644
  97. into "/lib/systemd/system"
  98. rename { String filename ->
  99. "${pkgName}.service"
  100. }
  101. }
  102. link("/etc/${pkgName}/conf", "${pkgInstallFolder}/conf")
  103. }