From c5b35114e5257e5604c593d77c287f5154785bdb Mon Sep 17 00:00:00 2001 From: Jay Aras Date: Wed, 30 Apr 2014 16:40:33 -0700 Subject: [PATCH 1/3] add prefix --- src/main/scala/com/typesafe/sbt/packager/rpm/Keys.scala | 1 + src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala | 2 ++ src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/scala/com/typesafe/sbt/packager/rpm/Keys.scala b/src/main/scala/com/typesafe/sbt/packager/rpm/Keys.scala index 9c5377990..c90294cb0 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/Keys.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/Keys.scala @@ -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 diff --git a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala index 373de9fb6..55c44a2ab 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala @@ -10,6 +10,7 @@ case class RpmMetadata( name: String, version: String, release: String, + prefix: Option[String] = None, arch: String, vendor: String, os: String, @@ -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) + sb append ("prefix: %s\n" format meta.prefix) desc.license foreach { v => sb append ("License: %s\n" format v) } desc.distribution foreach { v => sb append ("Distribution: %s\n" format v) } diff --git a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala index 3c250e724..58d4ff456 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala @@ -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, @@ -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.apply), rpmDescription <<= (rpmLicense, rpmDistribution, rpmUrl, rpmGroup, rpmPackager, rpmIcon) apply RpmDescription, rpmDependencies <<= From bd87027dd7105644ce0a59eb5dd2a8df79ead524 Mon Sep 17 00:00:00 2001 From: Jay Aras Date: Wed, 30 Apr 2014 17:17:10 -0700 Subject: [PATCH 2/3] woops --- src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala | 2 +- src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala index 55c44a2ab..0b6e6c6e7 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala @@ -169,7 +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) - sb append ("prefix: %s\n" format meta.prefix) + 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) } diff --git a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala index 58d4ff456..3767f74b7 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala @@ -47,7 +47,7 @@ trait RpmPlugin extends Plugin with LinuxPlugin { ) ++ inConfig(Rpm)(Seq( packageArchitecture := "noarch", rpmMetadata <<= - (name, version, rpmRelease, rpmPrefix, 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 <<= From 10f51e993410044860ad32f3684c5ab8b6f38f2d Mon Sep 17 00:00:00 2001 From: Jay Aras Date: Wed, 4 Jun 2014 14:30:42 -0500 Subject: [PATCH 3/3] add section on the prefix and an example use case --- src/sphinx/DetailedTopics/redhat.rst | 62 ++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/sphinx/DetailedTopics/redhat.rst b/src/sphinx/DetailedTopics/redhat.rst index 605d8a848..1e6ba3187 100644 --- a/src/sphinx/DetailedTopics/redhat.rst +++ b/src/sphinx/DetailedTopics/redhat.rst @@ -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 ~~~~~~~~~~~~~~~~~~ @@ -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 ---------------