diff --git a/CHANGELOG.md b/CHANGELOG.md index 285d45c18..cf624547d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1917,4 +1917,4 @@ ## [0.1.0](https://github.com/sbt/sbt-native-packager/tree/0.1.0) (2012-01-16) -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* diff --git a/integration-tests-ansible/test-project-play-rpm/packaging.sbt b/integration-tests-ansible/test-project-play-rpm/packaging.sbt index 8211a4c1e..3648ffc5f 100644 --- a/integration-tests-ansible/test-project-play-rpm/packaging.sbt +++ b/integration-tests-ansible/test-project-play-rpm/packaging.sbt @@ -28,3 +28,5 @@ rpmRelease := "1" rpmVendor := "DemoVendor" rpmLicense := Some("Apache-2.0") + +rpmEpoch := Some(1) 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 0132ac94a..fbfd7f003 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/Keys.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/Keys.scala @@ -21,6 +21,7 @@ trait RpmKeys { // DESCRIPTION KEYS // TODO - Summary and license are required. val rpmLicense = SettingKey[Option[String]]("rpm-license", "License of the code within the RPM.") + val rpmEpoch = SettingKey[Option[Int]]("rpm-epoch", "Epoch of the generated RPM.") val rpmDistribution = SettingKey[Option[String]]("rpm-distribution") val rpmUrl = SettingKey[Option[String]]("rpm-url", "Url to include in the RPM.") 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 4480691f4..98261f52d 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmMetadata.scala @@ -18,7 +18,8 @@ case class RpmMetadata(name: String, summary: String, description: String, autoprov: String, - autoreq: String) + autoreq: String, + epoch: Option[Int]) /** * The Description used to generate an RPM @@ -222,6 +223,11 @@ 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.epoch filter (_ >= 0) foreach { epoch => + sb append ("Epoch: %d\n" format epoch) + } + meta.prefix foreach { v => sb append ("prefix: %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 7b6ad8a2b..4d209b4af 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala @@ -69,6 +69,7 @@ object RpmPlugin extends AutoPlugin { rpmPrefix := None, rpmVendor := "", // TODO - Maybe pull in organization? rpmLicense := None, + rpmEpoch := None, rpmDistribution := None, rpmUrl := None, rpmGroup := None, @@ -105,7 +106,8 @@ object RpmPlugin extends AutoPlugin { validatePackageValidators in Rpm := Seq( nonEmptyMappings((linuxPackageMappings in Rpm).value.flatMap(_.mappings)), filesExist((linuxPackageMappings in Rpm).value.flatMap(_.mappings)), - checkMaintainer((maintainer in Rpm).value, asWarning = false) + checkMaintainer((maintainer in Rpm).value, asWarning = false), + epochIsNaturalNumber((rpmEpoch in Rpm).value.getOrElse(0)) ), // override the linux sourceDirectory setting sourceDirectory in Rpm := sourceDirectory.value, @@ -121,7 +123,8 @@ object RpmPlugin extends AutoPlugin { (packageSummary in Rpm).value, (packageDescription in Rpm).value, rpmAutoprov.value, - rpmAutoreq.value + rpmAutoreq.value, + rpmEpoch.value ), rpmDescription := RpmDescription( rpmLicense.value, diff --git a/src/main/scala/com/typesafe/sbt/packager/validation/package.scala b/src/main/scala/com/typesafe/sbt/packager/validation/package.scala index 02204fea1..66e337f59 100644 --- a/src/main/scala/com/typesafe/sbt/packager/validation/package.scala +++ b/src/main/scala/com/typesafe/sbt/packager/validation/package.scala @@ -63,4 +63,16 @@ package object validation { } } + def epochIsNaturalNumber(epoch: Int): Validation.Validator = () => { + sys.error(s"Passed: $epoch") + if (epoch < 0) { + ValidationError( + description = s"The Epoch cannot be a negative number (found $epoch)", + howToFix = "Change rpmEpoch to Some(n), where n >= 0" + ) :: Nil + } else { + Nil + } + } + } diff --git a/src/sbt-test/rpm/simple-rpm/build.sbt b/src/sbt-test/rpm/simple-rpm/build.sbt index 735e12740..963454439 100644 --- a/src/sbt-test/rpm/simple-rpm/build.sbt +++ b/src/sbt-test/rpm/simple-rpm/build.sbt @@ -21,6 +21,8 @@ rpmUrl := Some("http://github.com/sbt/sbt-native-packager") rpmLicense := Some("BSD") +rpmEpoch := Some(1) + packageArchitecture in Rpm := "x86_64" linuxPackageMappings in Rpm := { @@ -38,6 +40,7 @@ TaskKey[Unit]("checkSpecFile") := { assert(spec contains "Release: 1", "Contains project release") assert(spec contains "Summary: Test rpm package", "Contains project summary") assert(spec contains "License: BSD", "Contains project license") + assert(spec contains "Epoch: 1", "Contains epoch of 1") assert(spec contains "Vendor: typesafe", "Contains project vendor") assert(spec contains "URL: http://github.com/sbt/sbt-native-packager", "Contains project url") assert(spec contains "BuildArch: x86_64", "Contains project package architecture") diff --git a/src/sphinx/formats/rpm.rst b/src/sphinx/formats/rpm.rst index c55818974..44c55c5f1 100644 --- a/src/sphinx/formats/rpm.rst +++ b/src/sphinx/formats/rpm.rst @@ -123,6 +123,12 @@ Informational Settings ``rpmLicense`` The license associated with software in the RPM. + ``rpmEpoch`` + The epoch is the most significant number used when resolving different versions + for the same RPM. For a given package, packages with the highest epoch will be + used, and in the event of a tie it will fall back to comparing the version and + release. + Dependency Settings ~~~~~~~~~~~~~~~~~~~