-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for package maintainer scripts. #10
Conversation
Debian allows packages to have {pre|post} install and {pre|post} removal scripts. They are used to manage and configure the system in ways that files alone cannot (e.g. add user) This change allows users of the sbt native packager to include these files (optionally) in their generated debs.
I have tested this by publishing the sbt native packager locally, and then bundling a new project on top of this. Build.scala: import sbt._
import Keys._
import play.Project._
import com.typesafe.sbt.packager.Keys._
import com.typesafe.sbt.SbtNativePackager
import com.typesafe.sbt.SbtNativePackager._
object ApplicationBuild extends Build {
val appName = "testing"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
jdbc,
anorm
)
val main = play.Project(appName, appVersion, appDependencies).settings(
SbtNativePackager.packagerSettings:_*).settings(
// Add your own project settings here
maintainer in Debian := "Brennan Saeta <[email protected]>",
name in Debian <<= name("aptsera-" + _),
packageSummary in Debian := "Coursera's Secret Service",
packageDescription in Debian := "Coursera's stuff",
linuxPackageMappings in Debian <++= (dist, target, normalizedName, version) map { (dist, target, id, version) =>
val tmpdir = IO.createTemporaryDirectory
IO.unzip(dist, tmpdir)
val base = tmpdir / (id + "-" + version)
val destination = new File("/coursera") / id
(for {
jar <- IO.listFiles(base / "lib")
} yield (packageMapping(jar -> (destination / "lib" / jar.getName).getAbsolutePath) withUser "root" withGroup "root")).toSeq ++
Seq(packageMapping((base / "start") -> (destination / "start").getAbsolutePath) withUser "root" withGroup "root" withPerms "0744"
},
debianMaintainerScripts <++= (baseDirectory) map { (baseDirectory) =>
println(baseDirectory)
Seq((baseDirectory / "preinst", "preinst"))
},
// RPM muck
rpmRelease := "1",
rpmVendor := "Coursera",
// Windows muck
wixConfig <<= (sbtVersion, sourceDirectory in Windows) map ((a, b) => <Wix></Wix>)
)
} Let me know if you need anything more from me. |
Ping @jsuereth. Do you mind taking a look? Thanks! |
Sorry man, I did a review a while ago and forgot to write comments. One quick question: If you put files in Also I had plans to add some kind of support across RPM + Debian and try unify the "feel" of the install scripts between them. For the 0.5.x series, I'm cool taking this patch, but would love to hear advice on how to make RPM + DEB feel more similar... |
I unfortunately don't have enough experience with building RPM's. :-/ I wanted to be an available hook, because I'm building those files with SBT instead of constant files. |
Ah, right. OK, I'll merge as is and get you a point release. For 0.6 I'll look into unifying features between the two like:
Would you mind if things change in a 0.6? |
Add support for package maintainer scripts.
Nah, definitely don't mind if things change. In fact, I think they should change. I have already been thinking about ways this stuff should change to add exactly the features you describe. :-) |
Hey @jsuereth, Do you mind cutting the point release and pushing it into the artifactory repository? Thanks! |
DOH! Not at all. Pushing now. |
Ok, 0.5.4 is out! |
Thanks! |
Debian allows packages to have {pre|post} install and {pre|post} removal
scripts. They are used to manage and configure the system in ways that files
alone cannot (e.g. add user) This change allows users of the sbt native
packager to include these files (optionally) in their generated debs.