Skip to content

Commit 1fdaba0

Browse files
committed
Introduce RPM / packageBin / artifactPath setting. Closes sbt#1287
1 parent 6039c2e commit 1fdaba0

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.typesafe.sbt.packager.rpm
33
import sbt._
44
import com.typesafe.sbt.packager.Compat._
55
import com.typesafe.sbt.packager.linux.LinuxSymlink
6+
import sbt.Keys.{artifactPath, packageBin}
67

78
object RpmHelper {
89

@@ -26,6 +27,9 @@ object RpmHelper {
2627
workArea
2728
}
2829

30+
private[rpm] def defaultRpmArtifactPath(stagingArea: File, meta: RpmMetadata): File =
31+
stagingArea / "RPMS" / meta.arch / s"${meta.name}-${meta.version}-${meta.release}.${meta.arch}.rpm"
32+
2933
/**
3034
* Build the rpm package
3135
*
@@ -36,9 +40,12 @@ object RpmHelper {
3640
*/
3741
def buildRpm(spec: RpmSpec, stagingArea: File, log: sbt.Logger): File = {
3842
buildPackage(stagingArea, spec, log)
39-
// We should probably return the File that was created.
40-
val rpmname = "%s-%s-%s.%s.rpm" format (spec.meta.name, spec.meta.version, spec.meta.release, spec.meta.arch)
41-
stagingArea / "RPMS" / spec.meta.arch / rpmname
43+
// buildPackage uses rpmbuild command which always generates the file at defaultRpmArtifactPath
44+
// If the artifactPath is not the default value then we need to copy the file.
45+
val defaultPath = defaultRpmArtifactPath(stagingArea, spec.meta)
46+
val path = (artifactPath in (RpmPlugin.autoImport.Rpm, packageBin)).value
47+
if (path.getCanonicalFile != defaultPath.getCanonicalFile) IO.copyFile(defaultPath, path)
48+
path
4249
}
4350

4451
private[this] def copyFiles(spec: RpmSpec, workArea: File, log: sbt.Logger): Unit = {

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

+2
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,8 @@ object RpmPlugin extends AutoPlugin {
165165
(defaultLinuxInstallLocation in Rpm).value
166166
),
167167
stage in Rpm := RpmHelper.stage(rpmSpecConfig.value, (target in Rpm).value, streams.value.log),
168+
artifactPath in (Rpm, packageBin) := RpmHelper
169+
.defaultRpmArtifactPath((stage in Rpm).value, rpmSpecConfig.value.meta),
168170
packageBin in Rpm := RpmHelper.buildRpm(rpmSpecConfig.value, (stage in Rpm).value, streams.value.log),
169171
rpmLint := {
170172
sys.process.Process(Seq("rpmlint", "-v", (packageBin in Rpm).value.getAbsolutePath)) ! streams.value.log match {

0 commit comments

Comments
 (0)