Skip to content

Commit 6be318e

Browse files
committed
Fix package version
1 parent cdcd47d commit 6be318e

File tree

4 files changed

+58
-44
lines changed

4 files changed

+58
-44
lines changed

debian.sbt

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import Common.{stableVersion, snapshotVersion, betaVersion}
1+
import Common.{betaVersion, snapshotVersion, stableVersion, versionUsage}
22

3-
linuxPackageMappings in Debian += packageMapping(file("LICENSE") -> "/usr/share/doc/thehive/copyright").withPerms("644")
3+
linuxPackageMappings in Debian += packageMapping(file("LICENSE") "/usr/share/doc/thehive/copyright").withPerms("644")
44
version in Debian := {
55
version.value match {
6-
case stableVersion(_, _) => version.value
7-
case betaVersion(v1, v2) => v1 + "-0.1RC" + v2
8-
case snapshotVersion(_, _) => version.value + "-SNAPSHOT"
9-
case _ => sys.error("Invalid version: " + version.value)
6+
case stableVersion(_, _) version.value
7+
case betaVersion(v1, v2, v3) v1 + "-0." + v3 + "RC" + v2
8+
case snapshotVersion(stableVersion(v1, v2)) v1 + "-" + v2 + "-SNAPSHOT"
9+
case snapshotVersion(betaVersion(v1, v2, v3)) v1 + "-0." + v3 + "RC" + v2 + "-SNAPSHOT"
10+
case _ versionUsage(version.value)
1011
}
1112
}
1213
debianPackageRecommends := Seq("elasticsearch")
@@ -16,4 +17,4 @@ maintainerScripts in Debian := maintainerScriptsFromDirectory(
1617
Seq(DebianConstants.Postinst, DebianConstants.Prerm, DebianConstants.Postrm)
1718
)
1819
linuxEtcDefaultTemplate in Debian := (baseDirectory.value / "package" / "etc_default_thehive").asURL
19-
linuxMakeStartScript in Debian := None
20+
linuxMakeStartScript in Debian := None

docker.sbt

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import Common.{betaVersion, snapshotVersion, stableVersion}
1+
import Common.{betaVersion, snapshotVersion, stableVersion, versionUsage}
22
import com.typesafe.sbt.packager.docker.{Cmd, ExecCmd}
33

44
version in Docker := {
55
version.value match {
6-
case stableVersion(_, _) version.value
7-
case betaVersion(v1, v2) v1 + "-0.1RC" + v2
8-
case snapshotVersion(_, _) version.value + "-SNAPSHOT"
9-
case _ sys.error("Invalid version: " + version.value)
6+
case stableVersion(_, _) version.value
7+
case betaVersion(v1, v2, v3) v1 + "-0." + v3 + "RC" + v2
8+
case snapshotVersion(stableVersion(v1, v2)) v1 + "-" + v2 + "-SNAPSHOT"
9+
case snapshotVersion(betaVersion(v1, v2, v3)) v1 + "-0." + v3 + "RC" + v2 + "-SNAPSHOT"
10+
case _ versionUsage(version.value)
1011
}
1112
}
1213
defaultLinuxInstallLocation in Docker := "/opt/thehive"

project/Common.scala

+23-16
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,44 @@ object Common {
1515
scalaVersion := Dependencies.scalaVersion,
1616
scalacOptions ++= Seq(
1717
"-deprecation", // Emit warning and location for usages of deprecated APIs.
18-
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
19-
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
18+
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
19+
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
2020
//"-Xfatal-warnings", // Fail the compilation if there are any warnings.
21-
"-Xlint", // Enable recommended additional warnings.
22-
"-Ywarn-adapted-args", // Warn if an argument list is modified to match the receiver.
23-
"-Ywarn-dead-code", // Warn when dead code is identified.
24-
"-Ywarn-inaccessible", // Warn about inaccessible types in method signatures.
21+
"-Xlint", // Enable recommended additional warnings.
22+
"-Ywarn-adapted-args", // Warn if an argument list is modified to match the receiver.
23+
"-Ywarn-dead-code", // Warn when dead code is identified.
24+
"-Ywarn-inaccessible", // Warn about inaccessible types in method signatures.
2525
"-Ywarn-nullary-override", // Warn when non-nullary overrides nullary, e.g. def foo() over def foo.
26-
"-Ywarn-numeric-widen" // Warn when numerics are widened.
26+
"-Ywarn-numeric-widen" // Warn when numerics are widened.
2727
),
2828
scalacOptions in Test ~= { options
2929
options filterNot (_ == "-Ywarn-dead-code") // Allow dead code in tests (to support using mockito).
3030
},
3131
parallelExecution in Test := false,
3232
fork in Test := true,
3333
javaOptions += "-Xmx1G",
34-
3534
// Redirect logs from ElasticSearch (which uses log4j2) to slf4j
3635
libraryDependencies += "org.apache.logging.log4j" % "log4j-to-slf4j" % "2.9.1",
3736
excludeDependencies += "org.apache.logging.log4j" % "log4j-core"
3837
)
3938

4039
val stableVersion: Regex = "(\\d+\\.\\d+\\.\\d+)-(\\d+)".r
41-
val betaVersion: Regex = "(\\d+\\.\\d+\\.\\d+)-[Rr][Cc](\\d+)".r
40+
val betaVersion: Regex = "(\\d+\\.\\d+\\.\\d+)-[Rr][Cc](\\d+)-(\\d+)".r
41+
4242
object snapshotVersion {
43-
def unapplySeq(version: String): Option[List[String]] = {
44-
if (version.endsWith("-SNAPSHOT")) {
45-
val v = version.dropRight(9)
46-
stableVersion.unapplySeq(v) orElse betaVersion.unapplySeq(v)
47-
}
43+
44+
def unapply(version: String): Option[String] =
45+
if (version.endsWith("-SNAPSHOT")) Some(version.dropRight(9))
4846
else None
49-
}
5047
}
51-
}
48+
49+
def versionUsage(version: String): Nothing =
50+
sys.error(
51+
s"Invalid version: $version\n" +
52+
"The accepted formats for version are:\n" +
53+
" - 1.2.3-4\n" +
54+
" - 1.2.3-RC4-5\n" +
55+
" - 1.2.3-4-SNAPSHOT\n" +
56+
" - 1.2.3-RC4-5-SNAPSHOT"
57+
)
58+
}

rpm.sbt

+21-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
import Common.{stableVersion, snapshotVersion, betaVersion}
1+
import Common.{betaVersion, snapshotVersion, stableVersion, versionUsage}
22

33
version in Rpm := {
44
version.value match {
5-
case stableVersion(v1, v2) => v1
6-
case betaVersion(v1, v2) => v1
7-
case snapshotVersion(v1, v2) => v1
8-
case _ => sys.error("Invalid version: " + version.value)
5+
case stableVersion(v1, _) v1
6+
case betaVersion(v1, _, _) v1
7+
case snapshotVersion(stableVersion(v1, _)) v1
8+
case snapshotVersion(betaVersion(v1, _, _)) v1
9+
case _ versionUsage(version.value)
910
}
1011
}
1112
rpmRelease := {
1213
version.value match {
13-
case stableVersion(_, v2) => v2
14-
case betaVersion(v1, v2) => "0.1RC" + v2
15-
case snapshotVersion(v1, v2) => v2 + "-SNAPSHOT"
16-
case _ => sys.error("Invalid version: " + version.value)
14+
case stableVersion(_, v2) v2
15+
case betaVersion(_, v2, v3) "0." + v3 + "RC" + v2
16+
case snapshotVersion(stableVersion(_, v2)) v2 + "-SNAPSHOT"
17+
case snapshotVersion(betaVersion(_, v2, v3)) "0." + v3 + "RC" + v2 + "-SNAPSHOT"
18+
case _ versionUsage(version.value)
1719
}
1820
}
21+
1922
rpmVendor := organizationName.value
2023
rpmUrl := organizationHomepage.value.map(_.toString)
2124
rpmLicense := Some("AGPL")
@@ -35,12 +38,14 @@ linuxPackageMappings in Rpm := configWithNoReplace((linuxPackageMappings in Rpm)
3538
packageBin in Rpm := {
3639
import scala.sys.process._
3740
val rpmFile = (packageBin in Rpm).value
38-
Process("rpm" ::
39-
"--define" :: "_gpg_name TheHive Project" ::
40-
"--define" :: "_signature gpg" ::
41-
"--define" :: "__gpg_check_password_cmd /bin/true" ::
42-
"--define" :: "__gpg_sign_cmd %{__gpg} gpg --batch --no-verbose --no-armor --use-agent --no-secmem-warning -u \"%{_gpg_name}\" -sbo %{__signature_filename} %{__plaintext_filename}" ::
43-
"--addsign" :: rpmFile.toString ::
44-
Nil).!!
41+
Process(
42+
"rpm" ::
43+
"--define" :: "_gpg_name TheHive Project" ::
44+
"--define" :: "_signature gpg" ::
45+
"--define" :: "__gpg_check_password_cmd /bin/true" ::
46+
"--define" :: "__gpg_sign_cmd %{__gpg} gpg --batch --no-verbose --no-armor --use-agent --no-secmem-warning -u \"%{_gpg_name}\" -sbo %{__signature_filename} %{__plaintext_filename}" ::
47+
"--addsign" :: rpmFile.toString ::
48+
Nil
49+
).!!
4550
rpmFile
4651
}

0 commit comments

Comments
 (0)