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

Implemented the changelog to RPM #332

Merged
merged 5 commits into from
Aug 29, 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
3 changes: 3 additions & 0 deletions src/main/scala/com/typesafe/sbt/packager/rpm/Keys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ trait RpmKeys {
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.")

// Changelog
val rpmChangelogFile = SettingKey[Option[String]]("rpm-changelog-file", "RPM changelog file to be imported")

// DESCRIPTION KEYS
// TODO - Summary and license are required.
val rpmLicense = SettingKey[Option[String]]("rpm-license", "License of the code within the RPM.")
Expand Down
15 changes: 12 additions & 3 deletions src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package rpm
import linux.{ LinuxPackageMapping, LinuxFileMetaData }
import sbt._
import com.typesafe.sbt.packager.linux.LinuxSymlink
import java.io.File

case class RpmMetadata(
name: String,
Expand All @@ -29,7 +30,8 @@ case class RpmDescription(
url: Option[String] = None,
group: Option[String] = None,
packager: Option[String] = None,
icon: Option[String] = None)
icon: Option[String] = None,
changelogFile: Option[String] = None)

case class RpmDependencies(
provides: Seq[String] = Seq.empty,
Expand Down Expand Up @@ -204,8 +206,15 @@ case class RpmSpec(meta: RpmMetadata,
// Write file mappings
sb append fileSection
// TODO - Write triggers...
// TODO - Write changelog...

desc.changelogFile foreach { changelog =>
val tmpFile = new File(changelog)
if (tmpFile.isFile() && tmpFile.exists()) {
// if (Files.exists(Paths.get(changelog))) {
val content = scala.io.Source.fromFile(changelog).mkString
sb append "%changelog\n"
sb append ("%s\n" format content)
}
}
sb.toString
}
}
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 @@ -39,6 +39,7 @@ trait RpmPlugin extends Plugin with LinuxPlugin {
rpmPosttrans := None,
rpmPreun := None,
rpmPostun := None,
rpmChangelogFile := None,
rpmBrpJavaRepackJars := false,
rpmScriptsDirectory <<= sourceDirectory apply (_ / "rpm" / Names.Scriptlets),
// Explicitly defer default settings to generic Linux Settings.
Expand All @@ -53,7 +54,7 @@ trait RpmPlugin extends Plugin with LinuxPlugin {
rpmMetadata <<=
(packageName, version, rpmRelease, rpmPrefix, packageArchitecture, rpmVendor, rpmOs, packageSummary, packageDescription, rpmAutoprov, rpmAutoreq) apply RpmMetadata,
rpmDescription <<=
(rpmLicense, rpmDistribution, rpmUrl, rpmGroup, rpmPackager, rpmIcon) apply RpmDescription,
(rpmLicense, rpmDistribution, rpmUrl, rpmGroup, rpmPackager, rpmIcon, rpmChangelogFile) apply RpmDescription,
rpmDependencies <<=
(rpmProvides, rpmRequirements, rpmPrerequisites, rpmObsoletes, rpmConflicts) apply RpmDependencies,
rpmPre <<= (rpmPre, rpmBrpJavaRepackJars) apply {
Expand Down
33 changes: 33 additions & 0 deletions src/sbt-test/rpm/changelog-test/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import NativePackagerKeys._

packageArchetype.java_server

name := "rpm-test"

version := "0.1.0"

maintainer := "Endrigo Antonini <[email protected]>"

packageSummary := "Test rpm package with changelog"

packageDescription := """A fun package description of our software,
with multiple lines."""

rpmRelease := "1"

rpmVendor := "eidoscode"

rpmUrl := Some("http://github.com/sbt/sbt-native-packager")

rpmLicense := Some("BSD")

rpmChangelogFile := Some("conf/changelog")

TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test.spec")
// Check if the RPM writted the changelog tag on the task
assert(spec contains "%changelog\n", "Spec doesn't contain %changelog tag on the SPEC")
out.log.success("Successfully tested rpm test file")
()
}

9 changes: 9 additions & 0 deletions src/sbt-test/rpm/changelog-test/conf/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* Sun Aug 24 2014 Team <[email protected]> - 1.1.0
-Allow to login using social networks
* Wed Aug 20 2014 Team <[email protected]> - 1.0.1
-Vulnerability fix.
-Other information.
-Feature list.
* Tue Aug 19 2014 Team <[email protected]> - 1.0.0
-First version of the system

1 change: 1 addition & 0 deletions src/sbt-test/rpm/changelog-test/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
9 changes: 9 additions & 0 deletions src/sbt-test/rpm/changelog-test/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Run the debian packaging.
> rpm:package-bin
$ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm
$ exists target/rpm/SPECS/rpm-test.spec

# Check files for defaults
> check-spec-file
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
> check-spec-file
26 changes: 26 additions & 0 deletions src/sphinx/DetailedTopics/redhat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Rpms require the following specific settings:
rpmVendor := "typesafe",
rpmUrl := Some("http://github.com/paulp/sbt-extras"),
rpmLicense := Some("BSD"),
rpmChangelogFile := Some("changelog")


Informational Settings
Expand Down Expand Up @@ -63,6 +64,9 @@ Meta Settings
``rpmPrefix``
The path passed set as the base for the revocable package

``rpmChangelogFile``
External file to be imported and used to generate the changelog of the RPM.


Scriptlet Settings
~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -119,6 +123,28 @@ Example Settings
defaultLinuxLogsLocation := defaultLinuxInstallLocation + "/" + name


rpmChangelogFile
----------
The rpmChangelogFile property allows you to set a source that will be imported and used on the RPM generation. So if you use rpm commands to see the changelog it brings that information. You have to create the content on that file following the RPM conventions that are available here http://fedoraproject.org/wiki/Packaging:Guidelines#Changelogs.

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

.. code-block:: scala

changelog := "changelog.txt",
rpmChangelogFile := Some(changelog)


.. code-block:: txt
* Sun Aug 24 2014 Team <[email protected]> - 1.1.0
-Allow to login using social networks
* Wed Aug 20 2014 Team <[email protected]> - 1.0.1
-Vulnerability fix.
* Tue Aug 19 2014 Team <[email protected]> - 1.0.0
-First version of the system


Template Changes
~~~~~~~~~~~~~~~~~~
Apply the following changes to the default init start script. You can find this in the sbt-native-packager source.
Expand Down
2 changes: 2 additions & 0 deletions test-project/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ rpmVendor := "typesafe"

rpmLicense := Some("BSD")

rpmChangelogFile := Some("changelog.txt")

//debianMakePrermScript := Some(sourceDirectory.value / "deb" / "control" / "prerm") //change defaults


Expand Down
9 changes: 9 additions & 0 deletions test-project/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* Sun Aug 24 2014 Team <[email protected]> - 1.1.0
-Allow to login using social networks
* Wed Aug 20 2014 Team <[email protected]> - 1.0.1
-Vulnerability fix.
-Other information.
-Feature list.
* Tue Aug 19 2014 Team <[email protected]> - 1.0.0
-First version of the system