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

Don't compress debian packages #787

Merged
merged 1 commit into from
May 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ object DebianPlugin extends AutoPlugin with DebianNativePackaging {
(maintainerScripts in Debian).value,
(linuxScriptReplacements in Debian).value,
(target in Universal).value
)
),
debianNativeBuildOptions := Nil
)

/**
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/com/typesafe/sbt/packager/debian/Keys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ trait DebianKeys {
val debianMakeChownReplacements = TaskKey[(String, String)]("debianMakeChownReplacements", "Creates the chown commands for correct own files and directories")

val debianPackageInstallSize = TaskKey[Long]("debian-installed-size")

val debianNativeBuildOptions = SettingKey[Seq[String]]("debian-native-build-options", "Options passed to dpkg-deb, e.g. compression level")
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ trait DebianNativePackaging extends DebianPluginLike {
* package.
*/
private[debian] def debianNativeSettings: Seq[Setting[_]] = inConfig(Debian)(Seq(
debianNativeBuildOptions += "-Znone", // packages are largely JARs, which are already compressed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't scope this. The setting is already prefixed with debian. I just realised it after reading the tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a bit too much refactoring for you, I can adjust that after merging.

Copy link
Contributor Author

@pauldraper pauldraper May 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This more a bug then a feature :( I think we clean this up in another PR. Thanks a lot for your work :)

genChanges <<= (packageBin, target, debianChangelog, name, version, debianPackageMetadata) map {
(pkg, tdir, changelog, name, version, data) =>
changelog match {
Expand Down Expand Up @@ -81,12 +82,12 @@ trait DebianNativePackaging extends DebianPluginLike {
},

/** Implementation of the actual packaging */
packageBin <<= (debianExplodedPackage, debianMD5sumsFile, debianSection, debianPriority, name, version, packageArchitecture, target, streams) map {
(pkgdir, _, section, priority, name, version, arch, tdir, s) =>
packageBin <<= (debianExplodedPackage, debianMD5sumsFile, debianSection, debianPriority, name, version, packageArchitecture, debianNativeBuildOptions, target, streams) map {
(pkgdir, _, section, priority, name, version, arch, options, tdir, s) =>
s.log.info("Building debian package with native implementation")
// Make the package. We put this in fakeroot, so we can build the package with root owning files.
val archive = archiveFilename(name, version, arch)
Process(Seq("fakeroot", "--", "dpkg-deb", "--build", pkgdir.getAbsolutePath, "../" + archive), Some(tdir)) ! s.log match {
Process(Seq("fakeroot", "--", "dpkg-deb", "--build") ++ options ++ Seq(pkgdir.getAbsolutePath, "../" + archive), Some(tdir)) ! s.log match {
case 0 => ()
case x => sys.error("Failure packaging debian file. Exit code: " + x)
}
Expand Down
14 changes: 14 additions & 0 deletions src/sbt-test/debian/native-build-compress/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
enablePlugins(DebianPlugin)

debianNativeBuildOptions in Debian := Nil

maintainer := "Maintainer <maintainer@example.com>"

packageDescription := "Description"

packageSummary := "Summary"

TaskKey[Unit]("check-deb-compression") := {
val deb = target.value / s"${(name in Debian).value}_${(version in Debian).value}_all.deb"
assert(Seq("ar", "-t", deb.toString).lines.exists(_.startsWith("data.tar."))) // exact extension varies by dpkg-deb version
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
2 changes: 2 additions & 0 deletions src/sbt-test/debian/native-build-compress/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> debian:packageBin
> check-deb-compression
12 changes: 12 additions & 0 deletions src/sbt-test/debian/native-build-default/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
enablePlugins(DebianPlugin)

maintainer := "Maintainer <maintainer@example.com>"

packageDescription := "Description"

packageSummary := "Summary"

TaskKey[Unit]("check-deb-compression") := {
val deb = target.value / s"${(name in Debian).value}_${(version in Debian).value}_all.deb"
assert(Seq("ar", "-t", deb.toString).lines.contains("data.tar"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
2 changes: 2 additions & 0 deletions src/sbt-test/debian/native-build-default/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
> debian:packageBin
> check-deb-compression
15 changes: 15 additions & 0 deletions src/sphinx/formats/debian.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ Enable the debian plugin to activate the native package implementation.

enablePlugins(DebianPlugin)

Native packaging
~~~~~~~~~~~~~~~~

Since JARs are by default already compressed, `DebianPlugin` disables additional compression of the debian package
contents.

To compress the debian package, override `debianNativeBuildOptions` with
`options <http://man7.org/linux/man-pages/man1/dpkg-deb.1.html>`_ for `dpkg-deb`.

.. code-block:: scala

debianNativeBuildOptions in Debian := Nil // dpkg-deb's default compression (currently xz)

debianNativeBuildOptions in Debian := Seq("-Zgzip", "-z3") // gzip compression at level 3

Java based packaging
~~~~~~~~~~~~~~~~~~~~

Expand Down