-
Notifications
You must be signed in to change notification settings - Fork 444
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
Adding some documentation to the debian package. #127
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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,104 @@ 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 <[email protected]>" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A nice generic name. I like it. However, Max Fightmaster is a real person, and I feel would make this example pop :) |
||
|
||
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 Packagin with Debian | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/Packagin/Packaging |
||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
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 <[email protected]>" | ||
|
||
maintainer in Windows := "Jane Smith <[email protected]>" | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be worth stating the |
||
|
||
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" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be worth adding information about the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also the example should probably not be root, as to encourage folks not to use root... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well this is the default, but I get the point people will copy'n'paste-code this (even they don't have too as mentioned one sentence above). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'm debating making it not the default as well (just for server archetype)... WDYT? we should try to promote "best" (good) practices in the default configurations.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, didn't get that :) Is there a way to enforce configuration settings in sbt? The idea would be to add a setting appUser := "player"
// This would be the defaults
appGroup <<= appUser
daemonUser <<= appUser
defaultPackageUser <<= appUser
defaultPackageGroup <<= appGroup
useDefaultPackagePermissions := true
This would create a lot of new configuration settings and essentially a bunch of new features. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'd love to see normalized name used, if we can. Anyone have a link to user name restrictions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From the user add man page "It is usually recommended to only use usernames that begin with a lower case letter or an underscore, followed by lower case letters, digits, underscores, or dashes. They can end with a dollar sign. In regular expression terms: [a-z_][a-z0-9_-]*[$]? On Debian, the only constraints are that usernames must neither start with a dash (-) nor contain a colon (:) or a whitespace (space: , end of line: \n, tabulation: \t, etc.). Note that using a slash (/) may break the default algorithm for the definition of the users home directory. Usernames may only be up to 32 characters long." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the 32-character thing we may need to enforce, otherwise I think normalizedName fits.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The configuration can actually be found here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds great to me! |
||
|
||
Change these values as you need. For more informations look at the :ref:`Archetypes` page |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this fixing up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, no idea. Will remove this.