diff --git a/src/sphinx/archetypes.rst b/src/sphinx/archetypes.rst index 9ce0c2017..2942bcf2f 100644 --- a/src/sphinx/archetypes.rst +++ b/src/sphinx/archetypes.rst @@ -75,7 +75,11 @@ Java Server This archetype is designed for Java applications that are intended to run as servers or services. This archetype includes wiring an application to start -immediately upon startup. +immediately upon startup. To activate this archetype replace ``packageArchetype.java_application`` with + +.. code-block:: scala + + packageArchetype.java_server Currently supported operating systems: diff --git a/src/sphinx/debian.rst b/src/sphinx/debian.rst index 3f43caa48..c8e3dc7f5 100644 --- a/src/sphinx/debian.rst +++ b/src/sphinx/debian.rst @@ -37,6 +37,8 @@ Debian requires the following specific settings: are placed in the ``DEBIAN`` file when building. Some of these files can be autogenerated, for example when using a package archetype, like server_application. Howeve, any autogenerated file can be overridden by placing your own files in the ``src/debian/DEBIAN`` directory. + + `` Tasks @@ -49,3 +51,110 @@ The Debian support grants the following commands: ``debian:lintian`` Generates the ``.deb`` file and runs the ``lintian`` command to look for issues in the package. Useful for debugging. + + +Examples +-------- + +Plain Debian Packaging +~~~~~~~~~~~~~~~~~~~~~~ + +For a basic debian packaging your ``build.sbt`` must contain the following settings + +.. code-block:: scala + + import NativePackagerKeys._ + + name := "Debian Example" + + version := "1.0" + + packageArchetype.java_application + + maintainer := "Max Smith " + + packageSummary := "Hello World Debian Package" + + packageDescription := """A fun package description of our software, + with multiple lines.""" + +When you run ``sbt debian:packageBin`` you will find a debian package in your ``target`` folder. + +Multi OS Packaging with Debian +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you package for multiple operating systems you may have to be a bit more explicit in your ``build.sbt``. +For example + +.. code-block:: scala + + import NativePackagerKeys._ + + name := "Example Package" + + version := "1.0" + + packageArchetype.java_application + + maintainer in Debian := "Max Smith " + + maintainer in Windows := "Jane Smith " + + packageSummary in Debian := "Hello World Debian Package" + + packageSummary in Windows := "Hello World Windows Package" + + packageDescription := """A fun package description of our software, + with multiple lines.""" + +As you see, we duplicated the ``maintainer`` and ``packageSummary`` setting, but defined it for +different configuration scopes. + +Customizing Debian Packaging +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +A Debian package provides metadata, which includes **dependencies** and **recommendations**. +A basic example to depend on java and recommend a git installation. + +.. code-block:: scala + + debianPackageDependencies in Debian ++= Seq("java2-runtime", "bash (>= 2.05a-11)") + + debianPackageRecommends in Debian += "git" + +To hook into the debian package lifecycle (https://wiki.debian.org/MaintainerScripts) you +can add ``preinst`` , ``postinst`` , ``prerm`` and/or ``postrm`` scripts. Just place them into +``src/debian/DEBIAN``. + +If you use the ``packageArchetype.java_server`` there are predefined ``postinst`` and +``preinst`` files, which start/stop the application on install/remove calls. Existing +maintainer scripts will be extended not overidden. + +Your control scripts are in a different castle.. directory? No problem. + +.. code-block:: scala + + debianControlScriptsDirectory <<= (sourceDirectory) apply (_ / "deb" / "control") + +Customizing Debian Server Archetype +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The debian packaging supports the ``packageArchetype.java_server``, which generates +autostart scripts and some default links for logging and configuration. + +The default configuration looks like this (that means you don't have to add anything!) + +.. code-block:: scala + + import com.typesafe.sbt.packager.archetypes.ServerLoader.{Upstart, SystemV} + + serverLoading := Upstart + + daemonUser := "root" + +Change these values as you need. When you change the ``daemonUser`` make sure +you alter the ``packageMappings`` correctly. All users you define in the +``packageMappings`` will be generated within in the ``postinst`` script and +removed with ``apt-get purge`` through the ``postrm`` script. + +For more informations look at the :ref:`Archetypes` page.