如何解决使用 sbt-native-packager 构建 deb 的变更日志错误?

How to solve changelog error for building deb with sbt-native-packager?

我的 build.sbt 文件中包含以下内容,以使用基于 Java 的 .deb 包构建并发布到 Artifactory 存储库:

enablePlugins(JavaAppPackaging, DebianPlugin, JDebPackaging, DebianDeployPlugin)

但是,当我尝试执行 debian:publish 时,出现错误:

Creating changes file: /foo/bar/target/bar_1.0.0-SNAPSHOT_all.changes
java.lang.RuntimeException: Cannot generate .changes file without a changelog
    at scala.sys.package$.error(package.scala:27)
    at com.typesafe.sbt.packager.debian.DebianNativePackaging$$anonfun$debianNativeSettings.apply(NativePackaging.scala:49)
    at com.typesafe.sbt.packager.debian.DebianNativePackaging$$anonfun$debianNativeSettings.apply(NativePackaging.scala:47)
    at scala.Function6$$anonfun$tupled.apply(Function6.scala:35)
    at scala.Function6$$anonfun$tupled.apply(Function6.scala:34)
    at scala.Function1$$anonfun$compose.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$$anonfun$apply.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit$$anonfun$apply.apply(Execute.scala:228)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:237)
    at sbt.Execute$$anonfun$submit.apply(Execute.scala:228)
    at sbt.Execute$$anonfun$submit.apply(Execute.scala:228)
    at sbt.ConcurrentRestrictions$$anon$$anonfun.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[error] (debian:genChanges) Cannot generate .changes file without a changelog
[error] Total time: 1 s, completed 15-Jul-2016 09:47:53

我尝试添加

changelog in Debian := ""

到我的 build.sbt,如 the sbt native packager documentation 中所述(好吧,文档没有指定它是什么类型,但我认为 sbt 会告诉我我的类型是否错误,这样没事的)。但后来我收到了:

/foo/bar/build.sbt:31: error: not found: value changelog
changelog in Debian := ""
^
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?

我搜索了显示设置变更日志的示例,但找不到。

尝试changelog in Debian := None

DebianDeployPlugin 似乎无法与 JDebPackaging 一起使用,而且我不是 sbt 专家,无法弄清楚原因。

但是如果只是构建 .deb 文件,添加:

就足够了
debianChangelog in Debian := Some(file("debian/changelog"))

并创建一个包含

的文件debian/changelog
project-name (x.y.z) UNRELEASED; urgency=low

     * Initial no-op application.

 -- Your Name <your.email@example.com>  Fri, 15 Jul 2016 12:18:00 +0100

您还可以通过将以下行添加到 build.sbt

来忽略更改日志设置
import com.typesafe.sbt.packager.SettingsHelper._
makeDeploymentSettings(Debian, packageBin in Debian, "deb")

此代码命令dpkg-deb到运行只有deb building phase,没有changelog generation phase