【问题标题】:Run shell script within homebrew formula在自制公式中运行 shell 脚本
【发布时间】:2017-07-23 08:45:07
【问题描述】:

我想在 homebrew (cask) 公式中运行一个本地 shell 脚本,它会在安装后进行一些修改。木桶公式是稳定的,因为它总是安装“最新”,因此手动插入不应该在不久的将来被更新覆盖(我希望)。

我试过了

exec '~/bin/script.sh'
system '~/bin/script.sh'

两者都不起作用。我该怎么做?

编辑:尝试使用@Ortomalas 我得到的答案:

Error: Command failed to execute!

==> Failed command:
/usr/bin/sudo -E -- sed -i .bak 20i<style>*{text-rendering: optimizeLegibility;}</style>  /Applications/RStudio.app/Contents/Resources/www/index.htm

==> Standard Output of failed command:


==> Standard Error of failed command:
sed: 1: "20i<style>*{text-render ...": command i expects \ followed by text

postflight:

postflight do
    # Unhide the application
      system_command 'sed',
                     args: ['-i .bak', "20i\<style>*{text-rendering: optimizeLegibility;}</style>\ ", "#{appdir}/RStudio.app/Contents/Resources/www/index.htm"],
                     sudo: true
end

我尝试了使用system_command 的各种方法,但没有成功。上面的这个例子展示了一种尝试。

作为一种解决方法,我这样做如下:

brew cask install rstudio-daily && bash ~/bin/Fira-code-ligatures.sh

但是,我真的更愿意将我的自定义 bash 脚本集成到 homebrew 公式中。

【问题讨论】:

  • 您是否在~/bin/Fira-code-ligatures.sh 上设置了chmod +x?。你能告诉我们你的飞行后块吗?
  • 查看新更新@OrtomalaLokni
  • 可以给我们看一下~/bin/Fira-code-ligatures.sh的内容吗?
  • sed -i.bak '20i\ &lt;style&gt;*{text-rendering: optimizeLegibility;}&lt;/style&gt;\ ' /Applications/RStudio.app/Contents/Resources/www/index.htm -> 使用上面的“解决方法”可以正常工作

标签: shell homebrew homebrew-cask


【解决方案1】:

您可以包含postflight 块。 parralels-desktop cask 是这样做的:

postflight do
    # Unhide the application
    system_command '/usr/bin/chflags',
                   args: ['nohidden', "#{appdir}/Parallels Desktop.app"],
                   sudo: true
  end

用你自己的值替换。

【讨论】:

    猜你喜欢
    • 2021-07-11
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-18
    • 1970-01-01
    相关资源
    最近更新 更多