@@ -3,6 +3,7 @@ package com.typesafe.sbt.packager.rpm
3
3
import sbt ._
4
4
import com .typesafe .sbt .packager .Compat ._
5
5
import com .typesafe .sbt .packager .linux .LinuxSymlink
6
+ import sbt .Keys .{artifactPath , packageBin }
6
7
7
8
object RpmHelper {
8
9
@@ -26,6 +27,9 @@ object RpmHelper {
26
27
workArea
27
28
}
28
29
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
+
29
33
/**
30
34
* Build the rpm package
31
35
*
@@ -36,9 +40,12 @@ object RpmHelper {
36
40
*/
37
41
def buildRpm (spec : RpmSpec , stagingArea : File , log : sbt.Logger ): File = {
38
42
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
42
49
}
43
50
44
51
private [this ] def copyFiles (spec : RpmSpec , workArea : File , log : sbt.Logger ): Unit = {
0 commit comments