0

我写了我的第一个水龙头,所以我仍然不确定它是如何工作的。我写了这个小公式:

class Konversation < Formula
  desc "Konversation is a tool to generate rich and diversified responses to the user of a voice application."
  homepage "https://github.com/rewe-digital-incubator/Konversation/"
  url "https://github.com/rewe-digital-incubator/Konversation/releases/download/1.0.0/konversation-cli.jar"
  sha256 "6123d126278faae2419f5de00411a1b67ae57e0cf2265a5d484ed6f9786baaca"

  def install
    prefix.install "#{buildpath}/konversation-cli.jar"
    File.write("#{buildpath}/konversation", "java -jar #{prefix}/konversation-cli.jar $@")
    bin.install "#{buildpath}/konversation"
    system "chmod", "+x", "#{bin}/konversation"
  end
end

但是我无法运行我的工具,因为“konversation”可执行文件没有 x 权限。我试图用系统 chmod 来解决这个问题,但是我看到我的 x 标志在安装后被 brew 作为某种清理删除:

==> Cleaning
Fixing /home/linuxbrew/.linuxbrew/opt/konversation/bin/konversation permissions from 777 to 444

如何正确设置文件权限?

请注意,我不想将 shell 脚本本身托管在某个地方,因为我没有看到将 shell 脚本和 jar 文件打包到另一个 zip 文件中以防贫乏。

如果您想自己尝试,请尝试以下命令:

brew install rekire/packages/konversation
4

1 回答 1

1

Shell 脚本需要有一个 shebang 行,否则安装后清理程序将设置其权限,就好像它不是可执行文件一样。在这种特定情况下,我建议:

  • 改用bin.write_jar_script——这将为 JAR 脚本设置正确的环境
  • install .jarslibexec代替prefix-- 以避免不必要的文件污染前缀。

来自 Homebrew/homebrew-core 的示例公式

于 2019-05-15T06:10:22.953 回答