mirror of https://github.com/sbt/sbt.git
Test migration to a dedicated packaging plugin.
This commit is contained in:
parent
34fed66022
commit
1776f10a5c
|
|
@ -1,94 +1,36 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import com.typesafe.packager.debian.DebianPlugin._
|
||||
import com.typesafe.packager.linux.{LinuxPackageMapping, LinuxFileMetaData}
|
||||
import com.typesafe.packager.debian.Keys._
|
||||
import sbt.Keys.{baseDirectory,sbtVersion,sourceDirectory}
|
||||
|
||||
object DebianPkg {
|
||||
val Debian = config("debian-pkg")
|
||||
val makeDebianExplodedPackage = TaskKey[File]("make-debian-exploded-package")
|
||||
val makeZippedPackageSource = TaskKey[Unit]("make-zipped-package-source")
|
||||
val genControlFile = TaskKey[File]("generate-control-file")
|
||||
val lintian = TaskKey[Unit]("lintian", "Displays lintian error messages associated with the package")
|
||||
val showMan = TaskKey[Unit]("show-man", "shows the sbt program man page")
|
||||
|
||||
val settings: Seq[Setting[_]] = Seq(
|
||||
resourceDirectory in Debian <<= baseDirectory(_ / "src" / "debian"),
|
||||
resourceDirectory in Debian in makeZippedPackageSource <<= baseDirectory(_ / "src" / "debian-gzipped"),
|
||||
mappings in Debian <<= resourceDirectory in Debian map { d => (d.*** --- d) x (relativeTo(d)) },
|
||||
mappings in Debian in makeZippedPackageSource <<= resourceDirectory in Debian in makeZippedPackageSource map { d => (d.*** --- d) x (relativeTo(d)) },
|
||||
// TODO - put sbt-version into the generated sbt script.
|
||||
mappings in Debian <+= baseDirectory map { dir => (dir / "sbt" -> "usr/bin/sbt") },
|
||||
|
||||
val settings: Seq[Setting[_]] = debianSettings ++ Seq(
|
||||
maintainer in Debian := "Josh Suereth <joshua.suereth@typesafe.com>",
|
||||
name in Debian := "sbt",
|
||||
version in Debian <<= (version, sbtVersion) apply { (v, sv) =>
|
||||
sv + "-build-" + (v split "\\." map (_.toInt) dropWhile (_ == 0) map ("%02d" format _) mkString "")
|
||||
sv + "-build-" + (v split "\\." map (_.toInt) dropWhile (_ == 0) map ("%02d" format _) mkString "")
|
||||
},
|
||||
target in Debian <<= (target, name in Debian, version in Debian) apply ((t,n, v) => t / (n +"-"+ v)),
|
||||
genControlFile <<= (name in Debian, version in Debian, target in Debian) map {
|
||||
(name, version, dir) =>
|
||||
val cfile = dir / "DEBIAN" / "control"
|
||||
IO.writer(cfile, ControlFileContent, java.nio.charset.Charset.defaultCharset, false) { o =>
|
||||
val out = new java.io.PrintWriter(o)
|
||||
out println ("Package: %s" format name)
|
||||
out println ("Version: %s" format version)
|
||||
out println ControlFileContent
|
||||
}
|
||||
cfile
|
||||
debianPackageDependencies in Debian ++= Seq("curl", "java2-runtime", "bash (>= 2.05a-11)"),
|
||||
debianPackageRecommends in Debian += "git",
|
||||
packageDescription in Debian := """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 in Debian <+= (baseDirectory) map { bd =>
|
||||
(packageForDebian((bd / "sbt") -> "usr/bin/sbt")
|
||||
withUser "root" withGroup "root" withPerms "0755")
|
||||
},
|
||||
makeDebianExplodedPackage <<= (mappings in Debian, genControlFile, target in Debian) map { (files, _, dir) =>
|
||||
for((file, target) <- files) {
|
||||
val tfile = dir / target
|
||||
if(file.isDirectory) IO.createDirectory(tfile)
|
||||
else IO.copyFile(file,tfile)
|
||||
}
|
||||
dir
|
||||
},
|
||||
makeZippedPackageSource <<= (mappings in Debian in makeZippedPackageSource, target in Debian) map { (files, dir) =>
|
||||
for((file, target) <- files) {
|
||||
val tfile = dir / target
|
||||
if(file.isDirectory) IO.createDirectory(tfile)
|
||||
else {
|
||||
val zipped = new File(tfile.getAbsolutePath + ".gz")
|
||||
IO delete zipped
|
||||
IO.copyFile(file,tfile)
|
||||
Process(Seq("gzip", "--best", tfile.getAbsolutePath), Some(tfile.getParentFile)).!
|
||||
}
|
||||
}
|
||||
dir
|
||||
},
|
||||
packageBin in Debian <<= (makeDebianExplodedPackage, makeZippedPackageSource, target in Debian, name in Debian, version in Debian) map { (pkgdir, _, tdir, n, v) =>
|
||||
// Assign appropriate permissions
|
||||
val isDirectory = (_: File).isDirectory
|
||||
val dirs = (tdir.***).get filter isDirectory
|
||||
val bins = (tdir / "usr" / "bin" ***).get filterNot isDirectory
|
||||
val data = (tdir / "usr" / "share" ***).get filterNot isDirectory
|
||||
val perms = Map("0755" -> (dirs ++ bins),
|
||||
"0644" -> data)
|
||||
val commands = for {
|
||||
(perm, files) <- perms
|
||||
file <- files
|
||||
p = Process("chmod " + perm + " " + file.getAbsolutePath)
|
||||
} p.!
|
||||
|
||||
// Make the package. We put this in fakeroot, so we can build the package with root owning files.
|
||||
Process(Seq("fakeroot", "--", "dpkg-deb", "--build", pkgdir.getAbsolutePath), Some(tdir)).!
|
||||
tdir.getParentFile / (n + "-" + v + ".deb")
|
||||
},
|
||||
lintian <<= (packageBin in Debian) map { file =>
|
||||
println("lintian -c " + file.getName + " on " + file.getParentFile.getAbsolutePath)
|
||||
Process(Seq("lintian", "-c", "-v", file.getName), Some(file.getParentFile)).!
|
||||
},
|
||||
showMan <<= (resourceDirectory in Debian in makeZippedPackageSource) map { dir =>
|
||||
Process("groff -man -Tascii " + (dir / "usr" / "share" / "man" / "man1" / "sbt.1").getAbsolutePath).!
|
||||
linuxPackageMappings in Debian <+= (sourceDirectory in Debian) map { bd =>
|
||||
packageForDebian(
|
||||
(bd / "usr/share/doc/sbt/copyright") -> "usr/share/doc/sbt/copyright"
|
||||
) withUser "root" withGroup "root" withPerms "0644"
|
||||
},
|
||||
linuxPackageMappings in Debian <+= (sourceDirectory) map { bd =>
|
||||
packageForDebian(
|
||||
(bd / "debian/changelog") -> "usr/share/doc/sbt/changelog.gz",
|
||||
(bd / "linux" / "usr/share/man/man1/sbt.1") -> "usr/share/man/man1/sbt.1.gz"
|
||||
) withUser "root" withGroup "root" withPerms "0644" gzipped
|
||||
}
|
||||
)
|
||||
|
||||
// TODO - Use default-jre-headless?
|
||||
final val ControlFileContent = """Section: java
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
Depends: curl, java2-runtime, bash (>= 2.05a-11)
|
||||
Recommends: git
|
||||
Maintainer: Josh Suereth <joshua.suereth@typesafe.com>
|
||||
Description: Simple Build Tool
|
||||
This script provides a native way to run the Simple Build Tool,
|
||||
a build tool for Scala software, also called SBT.
|
||||
"""
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
import sbt._
|
||||
|
||||
object PluginBuild extends Build {
|
||||
override def projects = Seq(root)
|
||||
|
||||
val root = Project("root", file(".")) dependsOn(packager)
|
||||
|
||||
lazy val packager = RootProject(file("/home/jsuereth/projects/typesafe/sbt-native-packager"))
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
sbt Debian maintainer and upstream author are identical.
|
||||
Therefore see also normal changelog file for Debian changes.
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
sbt
|
||||
|
||||
Copyright: Typesafe, Inc.
|
||||
|
||||
2011-11-28
|
||||
|
||||
The home page of sbt package is at:
|
||||
http://github.com/paulp/sbt-extras
|
||||
|
||||
The entire code base may be distributed under the terms of the BSD license, which appears immediately below.
|
||||
|
||||
Copyright (c) 2011, Typesafe, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
Loading…
Reference in New Issue