Skip to content

Commit 3a35214

Browse files
committed
Merge pull request #332 from antonini/master
Implemented the changelog to RPM
2 parents 03a2e0f + cc85056 commit 3a35214

File tree

10 files changed

+106
-4
lines changed

10 files changed

+106
-4
lines changed

src/main/scala/com/typesafe/sbt/packager/rpm/Keys.scala

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ trait RpmKeys {
1414
val rpmPrefix = SettingKey[Option[String]]("rpm-prefix", "File system prefix for relocatable package.")
1515
val rpmMetadata = SettingKey[RpmMetadata]("rpm-metadata", "Metadata associated with the generated RPM.")
1616

17+
// Changelog
18+
val rpmChangelogFile = SettingKey[Option[String]]("rpm-changelog-file", "RPM changelog file to be imported")
19+
1720
// DESCRIPTION KEYS
1821
// TODO - Summary and license are required.
1922
val rpmLicense = SettingKey[Option[String]]("rpm-license", "License of the code within the RPM.")

src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package rpm
55
import linux.{ LinuxPackageMapping, LinuxFileMetaData }
66
import sbt._
77
import com.typesafe.sbt.packager.linux.LinuxSymlink
8+
import java.io.File
89

910
case class RpmMetadata(
1011
name: String,
@@ -29,7 +30,8 @@ case class RpmDescription(
2930
url: Option[String] = None,
3031
group: Option[String] = None,
3132
packager: Option[String] = None,
32-
icon: Option[String] = None)
33+
icon: Option[String] = None,
34+
changelogFile: Option[String] = None)
3335

3436
case class RpmDependencies(
3537
provides: Seq[String] = Seq.empty,
@@ -204,8 +206,15 @@ case class RpmSpec(meta: RpmMetadata,
204206
// Write file mappings
205207
sb append fileSection
206208
// TODO - Write triggers...
207-
// TODO - Write changelog...
208-
209+
desc.changelogFile foreach { changelog =>
210+
val tmpFile = new File(changelog)
211+
if (tmpFile.isFile() && tmpFile.exists()) {
212+
// if (Files.exists(Paths.get(changelog))) {
213+
val content = scala.io.Source.fromFile(changelog).mkString
214+
sb append "%changelog\n"
215+
sb append ("%s\n" format content)
216+
}
217+
}
209218
sb.toString
210219
}
211220
}

src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ trait RpmPlugin extends Plugin with LinuxPlugin {
3939
rpmPosttrans := None,
4040
rpmPreun := None,
4141
rpmPostun := None,
42+
rpmChangelogFile := None,
4243
rpmBrpJavaRepackJars := false,
4344
rpmScriptsDirectory <<= sourceDirectory apply (_ / "rpm" / Names.Scriptlets),
4445
// Explicitly defer default settings to generic Linux Settings.
@@ -53,7 +54,7 @@ trait RpmPlugin extends Plugin with LinuxPlugin {
5354
rpmMetadata <<=
5455
(packageName, version, rpmRelease, rpmPrefix, packageArchitecture, rpmVendor, rpmOs, packageSummary, packageDescription, rpmAutoprov, rpmAutoreq) apply RpmMetadata,
5556
rpmDescription <<=
56-
(rpmLicense, rpmDistribution, rpmUrl, rpmGroup, rpmPackager, rpmIcon) apply RpmDescription,
57+
(rpmLicense, rpmDistribution, rpmUrl, rpmGroup, rpmPackager, rpmIcon, rpmChangelogFile) apply RpmDescription,
5758
rpmDependencies <<=
5859
(rpmProvides, rpmRequirements, rpmPrerequisites, rpmObsoletes, rpmConflicts) apply RpmDependencies,
5960
rpmPre <<= (rpmPre, rpmBrpJavaRepackJars) apply {
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import NativePackagerKeys._
2+
3+
packageArchetype.java_server
4+
5+
name := "rpm-test"
6+
7+
version := "0.1.0"
8+
9+
maintainer := "Endrigo Antonini <[email protected]>"
10+
11+
packageSummary := "Test rpm package with changelog"
12+
13+
packageDescription := """A fun package description of our software,
14+
with multiple lines."""
15+
16+
rpmRelease := "1"
17+
18+
rpmVendor := "eidoscode"
19+
20+
rpmUrl := Some("http://github.com/sbt/sbt-native-packager")
21+
22+
rpmLicense := Some("BSD")
23+
24+
rpmChangelogFile := Some("conf/changelog")
25+
26+
TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) =>
27+
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test.spec")
28+
// Check if the RPM writted the changelog tag on the task
29+
assert(spec contains "%changelog\n", "Spec doesn't contain %changelog tag on the SPEC")
30+
out.log.success("Successfully tested rpm test file")
31+
()
32+
}
33+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
* Sun Aug 24 2014 Team <[email protected]> - 1.1.0
2+
-Allow to login using social networks
3+
* Wed Aug 20 2014 Team <[email protected]> - 1.0.1
4+
-Vulnerability fix.
5+
-Other information.
6+
-Feature list.
7+
* Tue Aug 19 2014 Team <[email protected]> - 1.0.0
8+
-First version of the system
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))

src/sbt-test/rpm/changelog-test/test

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Run the debian packaging.
2+
> rpm:package-bin
3+
$ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm
4+
$ exists target/rpm/SPECS/rpm-test.spec
5+
6+
# Check files for defaults
7+
> check-spec-file
8+
> set NativePackagerKeys.rpmBrpJavaRepackJars := true
9+
> check-spec-file

src/sphinx/DetailedTopics/redhat.rst

+26
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Rpms require the following specific settings:
1616
rpmVendor := "typesafe",
1717
rpmUrl := Some("http://github.com/paulp/sbt-extras"),
1818
rpmLicense := Some("BSD"),
19+
rpmChangelogFile := Some("changelog")
1920
2021
2122
Informational Settings
@@ -63,6 +64,9 @@ Meta Settings
6364
``rpmPrefix``
6465
The path passed set as the base for the revocable package
6566

67+
``rpmChangelogFile``
68+
External file to be imported and used to generate the changelog of the RPM.
69+
6670

6771
Scriptlet Settings
6872
~~~~~~~~~~~~~~~~~~
@@ -119,6 +123,28 @@ Example Settings
119123
defaultLinuxLogsLocation := defaultLinuxInstallLocation + "/" + name
120124
121125
126+
rpmChangelogFile
127+
----------
128+
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.
129+
130+
Example Settings
131+
~~~~~~~~~~~~~~~~~~
132+
133+
.. code-block:: scala
134+
135+
changelog := "changelog.txt",
136+
rpmChangelogFile := Some(changelog)
137+
138+
139+
.. code-block:: txt
140+
* Sun Aug 24 2014 Team <[email protected]> - 1.1.0
141+
-Allow to login using social networks
142+
* Wed Aug 20 2014 Team <[email protected]> - 1.0.1
143+
-Vulnerability fix.
144+
* Tue Aug 19 2014 Team <[email protected]> - 1.0.0
145+
-First version of the system
146+
147+
122148
Template Changes
123149
~~~~~~~~~~~~~~~~~~
124150
Apply the following changes to the default init start script. You can find this in the sbt-native-packager source.

test-project/build.sbt

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ rpmVendor := "typesafe"
2929

3030
rpmLicense := Some("BSD")
3131

32+
rpmChangelogFile := Some("changelog.txt")
33+
3234
//debianMakePrermScript := Some(sourceDirectory.value / "deb" / "control" / "prerm") //change defaults
3335

3436

test-project/changelog.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
* Sun Aug 24 2014 Team <[email protected]> - 1.1.0
2+
-Allow to login using social networks
3+
* Wed Aug 20 2014 Team <[email protected]> - 1.0.1
4+
-Vulnerability fix.
5+
-Other information.
6+
-Feature list.
7+
* Tue Aug 19 2014 Team <[email protected]> - 1.0.0
8+
-First version of the system
9+

0 commit comments

Comments
 (0)