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

Support for multiple Prefix values in RPM spec. #698

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion src/main/scala/com/typesafe/sbt/packager/rpm/Keys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ trait RpmKeys {
val rpmVendor = SettingKey[String]("rpm-vendor", "Name of the vendor for this RPM.")
val rpmOs = SettingKey[String]("rpm-os", "Name of the os for this RPM.")
val rpmRelease = SettingKey[String]("rpm-release", "Special release number for this rpm (vs. the software).")
val rpmPrefix = SettingKey[Option[String]]("rpm-prefix", "File system prefix for relocatable package.")
val rpmPrefix = SettingKey[Seq[String]]("rpm-prefix", "File system prefix for relocatable package.")
val rpmMetadata = SettingKey[RpmMetadata]("rpm-metadata", "Metadata associated with the generated RPM.")

// Changelog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ case class RpmMetadata(
name: String,
version: String,
release: String,
prefix: Option[String] = None,
prefix: Seq[String] = Seq.empty,
arch: String,
vendor: String,
os: String,
Expand Down Expand Up @@ -206,7 +206,7 @@ case class RpmSpec(
sb append ("Version: %s\n" format meta.version)
sb append ("Release: %s\n" format meta.release)
sb append ("Summary: %s\n" format meta.summary)
meta.prefix foreach { v => sb append ("prefix: %s\n" format v) }
meta.prefix foreach { v => sb append ("Prefix: %s\n" format v) }

desc.license foreach { v => sb append ("License: %s\n" format v) }
desc.distribution foreach { v => sb append ("Distribution: %s\n" format v) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ object RpmPlugin extends AutoPlugin {
override lazy val projectSettings = Seq(
rpmOs := "Linux", // TODO - default to something else?
rpmRelease := "1",
rpmPrefix := None,
rpmPrefix := Seq.empty,
rpmVendor := "", // TODO - Maybe pull in organization?
rpmLicense := None,
rpmDistribution := None,
Expand Down
39 changes: 29 additions & 10 deletions src/sphinx/formats/rpm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Meta Settings
~~~~~~~~~~~~~

``rpmPrefix``
The path passed set as the base for the revocable package
The path or paths allowed to be relocatable in the file system.

``rpmChangelogFile``
External file to be imported and used to generate the changelog of the RPM.
Expand Down Expand Up @@ -222,20 +222,39 @@ Customize
Rpm Prefix
~~~~~~~~~~

The rpm prefix allows you to create a relocatable package as defined by http://www.rpm.org/max-rpm/s1-rpm-reloc-prefix-tag.html.
This optional setting with a handful of overrides to scriptlets and templates will allow you to create a working java_server
archetype that can be relocated in the file system.
The rpm prefix allows you to create a relocatable package as defined by http://www.rpm.org/max-rpm/s1-rpm-reloc-prefix-tag.html
and http://rpm5.org/docs/api/relocatable.html. This optional setting with a handful of overrides to scriptlets and templates
will allow you to create a working java_server archetype that can be relocated in the file system. By default, the sbt RPM
packager will create paths in the RPM spec as such:

.. code-block:: bash

Example Settings:
/usr/share/ + (packageName in Linux).value # The main application path
/var/log/ + (packageName in Linux).value # The application log path
/etc/default/ + (packageName in Linux).value # config file of the application
/var/run/ + (packageName in Linux).value # The runtime path (for PID file, etc)
/etc/init.d/ + (packageName in Linux).value # Upstart daemon file, this may also be /etc/init for a SysVinit daemon file

The above paths, if specified in the ``rpmPrefix`` ``Seq`` list, will then allow those paths to be relocatable at the time
the RPM is being installed:

.. code-block:: scala

defaultLinuxInstallLocation := "/opt/package_root",
rpmPrefix := Some(defaultLinuxInstallLocation),
linuxPackageSymlinks := Seq.empty,
defaultLinuxLogsLocation := defaultLinuxInstallLocation + "/" + name

rpmPrefix ++= Seq("/usr/share", "/var/log")

.. code-block:: bash

rpm -ivh output.rpm --relocate /usr/share=/opt/app/packageName/share --relocate /var/log=/opt/app/packageName/log

One main warning to note: At the time of writing this documentation, the daemon file (``/etc/init.d/packageName`` or
``/etc/init/packageName``) will not be automatically updated to use the relocated paths because relocation occurs after
the daemon file has been written and implanted in the RPM file. This can be handled by in a number of ways:

* Create a ``src/templates/start`` file as defined in the :ref:`Cheatsheet`.
* Use a tool like `ansible`_ (or other scripting tools like bash, sed, awk, python, ...), to alter the file post-install of the RPM.
* Instead of relocating, use a post-install tool to create symbolic links from the paths desired to the actual install paths.

.. _ansible: http://www.ansible.com/

rpmChangelogFile
~~~~~~~~~~~~~~~~
Expand Down