~jan0sch/smederee

Showing details for patch f9db03f883b92decfa7e0c37ad868f7f744d1cd7.
2022-08-08 (Mon), 2:38 PM - Jens Grassel - f9db03f883b92decfa7e0c37ad868f7f744d1cd7

Packaging: Add Plugins and configuration

- create config to package hub module
  - debian package
  - rpm package
Summary of changes
2 files modified with 54 lines added and 2 lines removed
  • build.sbt with 52 added and 2 removed lines
  • project/plugins.sbt with 2 added and 0 removed lines
diff -rN -u old-smederee/build.sbt new-smederee/build.sbt
--- old-smederee/build.sbt	2025-02-02 20:02:51.562316374 +0000
+++ new-smederee/build.sbt	2025-02-02 20:02:51.562316374 +0000
@@ -17,7 +17,7 @@
 inThisBuild(
   Seq(
     scalaVersion := "3.1.3",
-    organization := "com.wegtam",
+    organization := "de.smederee",
     organizationName := "Contributors as noted in the AUTHORS.md file",
     scalacOptions ++= Seq(
         "-deprecation",
@@ -141,7 +141,15 @@
   project
     .in(file("modules/hub"))
     .dependsOn(darcs, email, i18n, security, twirl)
-    .enablePlugins(AutomateHeaderPlugin, SbtTwirl)
+    .enablePlugins(
+      AutomateHeaderPlugin,
+      DebianPlugin,
+      JavaServerAppPackaging,
+      JDebPackaging,
+      RpmPlugin,
+      SbtTwirl,
+      SystemdPlugin
+    )
     .configs(IntegrationTest)
     .settings(commonSettings)
     .settings(
@@ -203,6 +211,48 @@
         "org.http4s.Uri"
       )
     )
+    .settings(
+      Seq(
+        daemonUser := "smederee",
+        daemonGroup := "smederee",
+        Debian / debianPackageProvides += "smederee",
+        Debian / debianPackageDependencies += "openjdk-17-jre-headless",
+        defaultLinuxInstallLocation := "/opt",
+        maintainer := "Wegtam GmbH <devops@wegtam.com>",
+        rpmLicense := Option("BSL-1.1"),
+        rpmVendor := "Wegtam GmbH <devops@wegtam.com>",
+        // Create an empty `conf/production.conf` file if it does not exist.
+        Debian / maintainerScripts := maintainerScriptsAppend((Debian / maintainerScripts).value)(
+          DebianConstants.Postinst -> Seq(
+            s"touch ${defaultLinuxInstallLocation.value}/${normalizedName.value}/conf/production.conf",
+            s"chown ${daemonUser.value}:${daemonGroup.value} ${defaultLinuxInstallLocation.value}/${normalizedName.value}/conf/production.conf"
+          ).mkString(" && ") // Chain both commands together in the shell.
+        ),
+        // Require a service restart after installation / update.
+        Debian / maintainerScripts := maintainerScriptsAppend((Debian / maintainerScripts).value)(
+          DebianConstants.Postinst -> s"restartService ${normalizedName.value}"
+        ),
+        // Create an empty `conf/production.conf` file if it does not exist.
+        Rpm / maintainerScripts := maintainerScriptsAppend((Rpm / maintainerScripts).value)(
+          RpmConstants.Post -> Seq(
+            s"touch ${defaultLinuxInstallLocation.value}/${normalizedName.value}/conf/production.conf",
+            s"chown ${daemonUser.value}:${daemonGroup.value} ${defaultLinuxInstallLocation.value}/${normalizedName.value}/conf/production.conf"
+          ).mkString(" && ") // Chain both commands together in the shell.
+        ),
+        // Require a service restart after installation / update.
+        Rpm / maintainerScripts := maintainerScriptsAppend((Rpm / maintainerScripts).value)(
+          RpmConstants.Post -> s"restartService ${normalizedName.value}"
+        ),
+        packageSummary := "Smederee - Software collaboration platform.",
+        packageDescription := "Leverage the power of the darcs vcs to handle your projects with ease and confidence",
+        Debian / requiredStartFacilities := Option("$local_fs $remote_fs $network $postgresql"),
+        // Do not package API docs.
+        Compile / packageDoc / publishArtifact := false,
+        Compile / doc / sources := Seq.empty,
+        // Require tests to be run before building a debian package.
+        Debian / packageBin := ((Debian / packageBin) dependsOn (Test / test) dependsOn (IntegrationTest / test)).value
+      )
+    )
 
 lazy val i18n =
   project
diff -rN -u old-smederee/project/plugins.sbt new-smederee/project/plugins.sbt
--- old-smederee/project/plugins.sbt	2025-02-02 20:02:51.562316374 +0000
+++ new-smederee/project/plugins.sbt	2025-02-02 20:02:51.562316374 +0000
@@ -8,3 +8,5 @@
 addSbtPlugin("com.typesafe.sbt"      % "sbt-site"                   % "1.4.1")
 addSbtPlugin("com.typesafe.sbt"      % "sbt-twirl"                  % "1.5.1")
 addSbtPlugin("com.github.sbt"        % "sbt-unidoc"                 % "0.5.0")
+// Needed to build debian packages via java (for sbt-native-packager).
+libraryDependencies += "org.vafer" % "jdeb" % "1.10" artifacts (Artifact("jdeb", "jar", "jar"))