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 RPM 'Prefix'. #242

Merged
merged 3 commits into from
Jun 6, 2014
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
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.")
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't there need to be a default value for this in the acrchetypes as well?

Copy link
Author

Choose a reason for hiding this comment

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

Maybe? Prefix: is not a required field what would you think it would be?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not familiar with the prefix option. What's its purpose?

Copy link
Contributor

Choose a reason for hiding this comment

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

@jayaras is right. By default this should be None as this field is optional and only for special use cases.

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