Skip to content
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

Merged
merged 1 commit into from
Feb 23, 2013

Conversation

saeta
Copy link
Contributor

@saeta saeta commented Feb 12, 2013

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.

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.
@saeta
Copy link
Contributor Author

saeta commented Feb 12, 2013

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.

@saeta
Copy link
Contributor Author

saeta commented Feb 20, 2013

Ping @jsuereth. Do you mind taking a look? Thanks!

@jsuereth
Copy link
Member

Sorry man, I did a review a while ago and forgot to write comments.

One quick question: If you put files in src/debian/DEBIAN, do they not automatically get added correctly?

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...

@saeta
Copy link
Contributor Author

saeta commented Feb 21, 2013

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.

@jsuereth
Copy link
Member

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:

  • pulling static files from filesystem (rpms have to be inline in the spec,
    so you must parse)
  • generating files (like source generators or resource generators).
  • inline in the build (fooScriptSource := """code""")

Would you mind if things change in a 0.6?

jsuereth added a commit that referenced this pull request Feb 23, 2013
Add support for package maintainer scripts.
@jsuereth jsuereth merged commit f0182d4 into sbt:master Feb 23, 2013
@saeta
Copy link
Contributor Author

saeta commented Feb 24, 2013

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. :-)

@saeta saeta deleted the saeta-debian-maintainer-scripts branch February 24, 2013 20:45
@saeta
Copy link
Contributor Author

saeta commented Mar 6, 2013

Hey @jsuereth,

Do you mind cutting the point release and pushing it into the artifactory repository?

Thanks!
-Brennan

@jsuereth
Copy link
Member

jsuereth commented Mar 7, 2013

DOH! Not at all. Pushing now.

@jsuereth
Copy link
Member

jsuereth commented Mar 7, 2013

Ok, 0.5.4 is out!

@saeta
Copy link
Contributor Author

saeta commented Mar 8, 2013

Thanks!

@jw-devops-n jw-devops-n mentioned this pull request Jun 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants