[英]How to pass parameters to overridden scripts with sbt-native-packager?
I am using sbt-native-packager to build an RPM. 我正在使用sbt-native-packager构建RPM。 I have some custom scripts for preInstall and postInstall as described here .
我有一个预安装和安装后一些自定义的脚本描述这里 。 Is there a way to pass parameters to these scripts from sbt?
有没有办法从sbt将参数传递给这些脚本?
Thanks 谢谢
@mgosk thanks for the idea. @mgosk感谢您的想法。 I'm adding a comment here to be able to format it.
我在这里添加评论以进行格式化。
I can't seem to make it work. 我似乎无法使其工作。 This is in my sbt file:
这是在我的sbt文件中:
val appName = "myApp" + packageSuffix
bashScriptExtraDefines += s"appName=$appName"
This is my scriptlet: 这是我的脚本:
${{template_declares}}
#start (or restart) the service
/etc/init.d/$appName restart
This is what get's generated in the rpm specs: 这是rpm规范中生成的内容:
${{template_declares}}
#start (or restart) the service
/etc/init.d/$appName restart
It's exactly the same thing. 这是完全一样的。 No substitution.
无替代。 Am i missing something?
我想念什么吗?
First you need to define extra variable in build.sbt
: 首先,您需要在
build.sbt
定义额外的变量:
bashScriptExtraDefines += s"""FOO=${sbtVariableHere}"""
Next add line ${{template_declares}}
to your shell script. 接下来,将
${{template_declares}}
行添加到您的Shell脚本中。 Native-packager template parser insert here bashScriptDefines
and bashScriptExtraDefines
that you define earlier. 本机打包程序模板解析器在此处插入您先前定义的
bashScriptDefines
和bashScriptExtraDefines
。
There you have more info: 那里您有更多信息:
http://www.scala-sbt.org/sbt-native-packager/archetypes/cheatsheet.html#bash-script-src-templates-bash-template http://www.scala-sbt.org/sbt-native-packager/archetypes/cheatsheet.html#bash-script-src-templates-bash-template
http://www.scala-sbt.org/sbt-native-packager/archetypes/java_app/customize.html#more-complex-scripts http://www.scala-sbt.org/sbt-native-packager/archetypes/java_app/customize.html#more-complex-scripts
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.