2011-11-29 00:52:47 +01:00
|
|
|
import sbt._
|
2011-12-21 17:21:16 +01:00
|
|
|
import com.typesafe.packager.Keys._
|
|
|
|
|
import sbt.Keys._
|
|
|
|
|
import com.typesafe.packager.PackagerPlugin._
|
2011-11-29 00:52:47 +01:00
|
|
|
|
2011-12-21 19:52:26 +01:00
|
|
|
object Packaging {
|
2011-12-21 20:39:57 +01:00
|
|
|
|
|
|
|
|
val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url")
|
|
|
|
|
val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location")
|
|
|
|
|
val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar")
|
2011-12-20 03:15:10 +01:00
|
|
|
|
2011-12-21 17:21:16 +01:00
|
|
|
val settings: Seq[Setting[_]] = packagerSettings ++ Seq(
|
2011-12-21 20:39:57 +01:00
|
|
|
sbtLaunchJarUrl <<= sbtVersion apply ("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+_+"/sbt-launch.jar"),
|
|
|
|
|
sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"),
|
|
|
|
|
sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) =>
|
|
|
|
|
import dispatch._
|
|
|
|
|
if(!file.exists) {
|
|
|
|
|
val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file))
|
|
|
|
|
try Http(url(uri) >>> writer)
|
|
|
|
|
finally writer.close()
|
|
|
|
|
}
|
|
|
|
|
// TODO - GPG Trust validation.
|
|
|
|
|
file
|
|
|
|
|
},
|
2011-12-21 04:25:02 +01:00
|
|
|
// GENERAL LINUX PACKAGING STUFFS
|
|
|
|
|
maintainer := "Josh Suereth <joshua.suereth@typesafe.com>",
|
|
|
|
|
packageDescription := """Simple Build Tool
|
|
|
|
|
This script provides a native way to run the Simple Build Tool,
|
|
|
|
|
a build tool for Scala software, also called SBT.""",
|
|
|
|
|
linuxPackageMappings <+= (baseDirectory) map { bd =>
|
2011-12-21 17:21:16 +01:00
|
|
|
(packageMapping((bd / "sbt") -> "/usr/bin/sbt")
|
2011-12-21 04:25:02 +01:00
|
|
|
withUser "root" withGroup "root" withPerms "0755")
|
|
|
|
|
},
|
|
|
|
|
linuxPackageMappings <+= (sourceDirectory) map { bd =>
|
2011-12-21 17:21:16 +01:00
|
|
|
(packageMapping(
|
2011-12-21 04:25:02 +01:00
|
|
|
(bd / "linux" / "usr/share/man/man1/sbt.1") -> "/usr/share/man/man1/sbt.1.gz"
|
2011-12-21 17:21:16 +01:00
|
|
|
) withPerms "0644" gzipped) asDocs()
|
2011-12-21 04:25:02 +01:00
|
|
|
},
|
2011-12-21 19:52:26 +01:00
|
|
|
linuxPackageMappings <+= (sourceDirectory in Linux) map { bd =>
|
2011-12-21 17:21:16 +01:00
|
|
|
packageMapping(
|
2011-12-21 04:25:02 +01:00
|
|
|
(bd / "usr/share/doc/sbt/copyright") -> "/usr/share/doc/sbt/copyright"
|
2011-12-21 17:21:16 +01:00
|
|
|
) withPerms "0644" asDocs()
|
2011-12-21 04:25:02 +01:00
|
|
|
},
|
2011-12-21 19:52:26 +01:00
|
|
|
linuxPackageMappings <+= (sourceDirectory in Linux) map { bd =>
|
2011-12-21 17:21:16 +01:00
|
|
|
packageMapping(
|
|
|
|
|
(bd / "usr/share/doc/sbt") -> "/usr/share/doc/sbt"
|
|
|
|
|
) asDocs()
|
|
|
|
|
},
|
2011-12-21 20:20:16 +01:00
|
|
|
linuxPackageMappings <+= (sourceDirectory in Linux) map { bd =>
|
|
|
|
|
packageMapping(
|
|
|
|
|
(bd / "etc/sbt") -> "/etc/sbt"
|
|
|
|
|
) withConfig()
|
|
|
|
|
},
|
|
|
|
|
linuxPackageMappings <+= (sourceDirectory in Linux) map { bd =>
|
|
|
|
|
packageMapping(
|
|
|
|
|
(bd / "etc/sbt/sbtopts") -> "/etc/sbt/sbtopts"
|
|
|
|
|
) withPerms "0644" withConfig()
|
|
|
|
|
},
|
2011-12-21 20:39:57 +01:00
|
|
|
linuxPackageMappings <+= (sbtLaunchJar, sourceDirectory in Linux, sbtVersion) map { (jar, dir, v) =>
|
|
|
|
|
packageMapping(dir -> "/usr/lib/sbt",
|
|
|
|
|
dir -> ("/usr/lib/sbt/" + v),
|
|
|
|
|
jar -> ("/usr/lib/sbt/"+v+"/sbt-launch.jar")) withPerms "0755"
|
|
|
|
|
},
|
2011-12-21 04:25:02 +01:00
|
|
|
// DEBIAN SPECIFIC
|
2011-11-29 00:52:47 +01:00
|
|
|
name in Debian := "sbt",
|
|
|
|
|
version in Debian <<= (version, sbtVersion) apply { (v, sv) =>
|
2011-12-20 03:15:10 +01:00
|
|
|
sv + "-build-" + (v split "\\." map (_.toInt) dropWhile (_ == 0) map ("%02d" format _) mkString "")
|
2011-11-29 00:52:47 +01:00
|
|
|
},
|
2011-12-20 03:15:10 +01:00
|
|
|
debianPackageDependencies in Debian ++= Seq("curl", "java2-runtime", "bash (>= 2.05a-11)"),
|
|
|
|
|
debianPackageRecommends in Debian += "git",
|
|
|
|
|
linuxPackageMappings in Debian <+= (sourceDirectory) map { bd =>
|
2011-12-21 17:21:16 +01:00
|
|
|
(packageMapping(
|
2011-12-21 04:25:02 +01:00
|
|
|
(bd / "debian/changelog") -> "/usr/share/doc/sbt/changelog.gz"
|
2011-12-21 17:21:16 +01:00
|
|
|
) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs()
|
2011-12-21 04:25:02 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// RPM SPECIFIC
|
|
|
|
|
name in Rpm := "sbt",
|
|
|
|
|
version in Rpm <<= sbtVersion.identity,
|
|
|
|
|
rpmRelease := "1",
|
2011-12-21 15:34:47 +01:00
|
|
|
rpmVendor := "typesafe",
|
|
|
|
|
rpmUrl := Some("http://github.com/paulp/sbt-extras"),
|
|
|
|
|
rpmSummary := Some("Simple Build Tool for Scala-driven builds."),
|
2011-12-24 06:46:15 +01:00
|
|
|
rpmLicense := Some("BSD"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// WINDOWS SPECIFIC
|
|
|
|
|
name in Windows := "sbt",
|
|
|
|
|
wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"),
|
|
|
|
|
mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" },
|
|
|
|
|
mappings in packageMsi in Windows <+= sourceDirectory in Windows map { d =>
|
|
|
|
|
(d / "sbt.bat") -> "sbt.bat" }
|
2011-11-29 00:52:47 +01:00
|
|
|
)
|
|
|
|
|
}
|