Skip to content

Commit

Permalink
Merge pull request #242 from jayaras/master
Browse files Browse the repository at this point in the history
support RPM 'Prefix'.
  • Loading branch information
muuki88 committed Jun 6, 2014
2 parents a1d9600 + 10f51e9 commit 03473a6
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/scala/com/typesafe/sbt/packager/rpm/Keys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +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 rpmMetadata = SettingKey[RpmMetadata]("rpm-metadata", "Metadata associated with the generated RPM.")

// DESCRIPTION KEYS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ case class RpmMetadata(
name: String,
version: String,
release: String,
prefix: Option[String] = None,
arch: String,
vendor: String,
os: String,
Expand Down Expand Up @@ -168,6 +169,7 @@ case class RpmSpec(meta: RpmMetadata,
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) }

desc.license foreach { v => sb append ("License: %s\n" format v) }
desc.distribution foreach { v => sb append ("Distribution: %s\n" format v) }
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ trait RpmPlugin extends Plugin with LinuxPlugin {
def rpmSettings: Seq[Setting[_]] = Seq(
rpmOs := "Linux", // TODO - default to something else?
rpmRelease := "0",
rpmPrefix := None,
rpmVendor := "", // TODO - Maybe pull in organization?
rpmLicense := None,
rpmDistribution := None,
Expand Down Expand Up @@ -46,7 +47,7 @@ trait RpmPlugin extends Plugin with LinuxPlugin {
) ++ inConfig(Rpm)(Seq(
packageArchitecture := "noarch",
rpmMetadata <<=
(name, version, rpmRelease, packageArchitecture, rpmVendor, rpmOs, packageSummary, packageDescription, rpmAutoprov, rpmAutoreq) apply (RpmMetadata.apply),
(name, version, rpmRelease, rpmPrefix, packageArchitecture, rpmVendor, rpmOs, packageSummary, packageDescription, rpmAutoprov, rpmAutoreq) apply RpmMetadata,
rpmDescription <<=
(rpmLicense, rpmDistribution, rpmUrl, rpmGroup, rpmPackager, rpmIcon) apply RpmDescription,
rpmDependencies <<=
Expand Down
62 changes: 62 additions & 0 deletions src/sphinx/DetailedTopics/redhat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ Dependency Settings
``rpmConflcits``
The packages this RPM conflicts with and cannot be installed with.

Meta Settings
~~~~~~~~~~~~~

``rpmPrefix``
The path passed set as the base for the revocable package


Scriptlet Settings
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -96,6 +102,62 @@ The Rpm support grants the following commands:

``rpm:rpmlint``
Generates the ``.rpm`` file and runs the ``rpmlint`` command to look for issues in the package. Useful for debugging.


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.

Example Settings
~~~~~~~~~~~~~~~~~~

.. code-block:: scala
defaultLinuxInstallLocation := "/opt/package_root",
rpmPrefix := Some(defaultLinuxInstallLocation),
linuxPackageSymlinks := Seq.empty,
defaultLinuxLogsLocation := defaultLinuxInstallLocation + "/" + name
Template Changes
~~~~~~~~~~~~~~~~~~
Apply the following changes to the default init start script. You can find this in the sbt-native-packager source.


``src/templates/start``

.. code-block:: bash
...
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
# smb could define some additional options in $RUN_OPTS
RUN_CMD="${PACKAGE_PREFIX}/${{app_name}}/bin/${{app_name}}"
...
Scriptlet Changes
~~~~~~~~~~~~~~~~~~
Apply the following changes to the scriptlets that can be found in the sbt-native-packager source.

``src/rpm/scriptlets/post-rpm``

.. code-block:: bash
...
echo "PACKAGE_PREFIX=${RPM_INSTALL_PREFIX}" > /etc/sysconfig/${{app_name}}
...
``src/rpm/scriptlets/preun-rpm``

.. code-block:: bash
...
rm /etc/sysconfig/${{app_name}}
...
Jar Repackaging
---------------
Expand Down

0 comments on commit 03473a6

Please sign in to comment.