Skip to content

Commit 445759e

Browse files
Ophirr33muuki88
authored andcommitted
#1178 attempt at adding in rpm epochs (#1179)
* #1178 attempt at adding in rpm epochs * #1178 removed extraneous sys.exit
1 parent 8038c04 commit 445759e

File tree

8 files changed

+36
-4
lines changed

8 files changed

+36
-4
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1932,4 +1932,4 @@
19321932
## [0.1.0](https://github.com/sbt/sbt-native-packager/tree/0.1.0) (2012-01-16)
19331933

19341934

1935-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
1935+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*

integration-tests-ansible/test-project-play-rpm/packaging.sbt

+2
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ rpmRelease := "1"
2828
rpmVendor := "DemoVendor"
2929

3030
rpmLicense := Some("Apache-2.0")
31+
32+
rpmEpoch := Some(1)

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

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ trait RpmKeys {
2121
// DESCRIPTION KEYS
2222
// TODO - Summary and license are required.
2323
val rpmLicense = SettingKey[Option[String]]("rpm-license", "License of the code within the RPM.")
24+
val rpmEpoch = SettingKey[Option[Int]]("rpm-epoch", "Epoch of the generated RPM.")
2425
val rpmDistribution = SettingKey[Option[String]]("rpm-distribution")
2526
val rpmUrl =
2627
SettingKey[Option[String]]("rpm-url", "Url to include in the RPM.")

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ case class RpmMetadata(name: String,
1818
summary: String,
1919
description: String,
2020
autoprov: String,
21-
autoreq: String)
21+
autoreq: String,
22+
epoch: Option[Int])
2223

2324
/**
2425
* The Description used to generate an RPM
@@ -222,6 +223,11 @@ case class RpmSpec(meta: RpmMetadata,
222223
sb append ("Version: %s\n" format meta.version)
223224
sb append ("Release: %s\n" format meta.release)
224225
sb append ("Summary: %s\n" format meta.summary)
226+
227+
meta.epoch filter (_ >= 0) foreach { epoch =>
228+
sb append ("Epoch: %d\n" format epoch)
229+
}
230+
225231
meta.prefix foreach { v =>
226232
sb append ("prefix: %s\n" format v)
227233
}

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ object RpmPlugin extends AutoPlugin {
6969
rpmPrefix := None,
7070
rpmVendor := "", // TODO - Maybe pull in organization?
7171
rpmLicense := None,
72+
rpmEpoch := None,
7273
rpmDistribution := None,
7374
rpmUrl := None,
7475
rpmGroup := None,
@@ -105,7 +106,8 @@ object RpmPlugin extends AutoPlugin {
105106
validatePackageValidators in Rpm := Seq(
106107
nonEmptyMappings((linuxPackageMappings in Rpm).value.flatMap(_.mappings)),
107108
filesExist((linuxPackageMappings in Rpm).value.flatMap(_.mappings)),
108-
checkMaintainer((maintainer in Rpm).value, asWarning = false)
109+
checkMaintainer((maintainer in Rpm).value, asWarning = false),
110+
epochIsNaturalNumber((rpmEpoch in Rpm).value.getOrElse(0))
109111
),
110112
// override the linux sourceDirectory setting
111113
sourceDirectory in Rpm := sourceDirectory.value,
@@ -121,7 +123,8 @@ object RpmPlugin extends AutoPlugin {
121123
(packageSummary in Rpm).value,
122124
(packageDescription in Rpm).value,
123125
rpmAutoprov.value,
124-
rpmAutoreq.value
126+
rpmAutoreq.value,
127+
rpmEpoch.value
125128
),
126129
rpmDescription := RpmDescription(
127130
rpmLicense.value,

src/main/scala/com/typesafe/sbt/packager/validation/package.scala

+11
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,15 @@ package object validation {
6363
}
6464
}
6565

66+
def epochIsNaturalNumber(epoch: Int): Validation.Validator = () => {
67+
if (epoch < 0) {
68+
ValidationError(
69+
description = s"The Epoch cannot be a negative number (found $epoch)",
70+
howToFix = "Change rpmEpoch to Some(n), where n >= 0"
71+
) :: Nil
72+
} else {
73+
Nil
74+
}
75+
}
76+
6677
}

src/sbt-test/rpm/simple-rpm/build.sbt

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ rpmUrl := Some("http://github.com/sbt/sbt-native-packager")
2121

2222
rpmLicense := Some("BSD")
2323

24+
rpmEpoch := Some(1)
25+
2426
packageArchitecture in Rpm := "x86_64"
2527

2628
linuxPackageMappings in Rpm := {
@@ -38,6 +40,7 @@ TaskKey[Unit]("checkSpecFile") := {
3840
assert(spec contains "Release: 1", "Contains project release")
3941
assert(spec contains "Summary: Test rpm package", "Contains project summary")
4042
assert(spec contains "License: BSD", "Contains project license")
43+
assert(spec contains "Epoch: 1", "Contains epoch of 1")
4144
assert(spec contains "Vendor: typesafe", "Contains project vendor")
4245
assert(spec contains "URL: http://github.com/sbt/sbt-native-packager", "Contains project url")
4346
assert(spec contains "BuildArch: x86_64", "Contains project package architecture")

src/sphinx/formats/rpm.rst

+6
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ Informational Settings
123123
``rpmLicense``
124124
The license associated with software in the RPM.
125125

126+
``rpmEpoch``
127+
The epoch is the most significant number used when resolving different versions
128+
for the same RPM. For a given package, packages with the highest epoch will be
129+
used, and in the event of a tie it will fall back to comparing the version and
130+
release.
131+
126132
Dependency Settings
127133
~~~~~~~~~~~~~~~~~~~
128134

0 commit comments

Comments
 (0)