我在 Linux 机器上使用 AWS Elastic Beanstalk,需要在 .ebextensions 中安装一些字体:
container_commands:
01_getfont:
command: sudo yum -y install http://somesite.com/rpm/webcore-fonts-3.0-1.noarch.rpm
第一次效果很好,安装了字体。
第二次当我再次部署 EB 时,它现在给了我这个错误:
应用程序更新在 2019-01-28T23:44:14Z 失败,退出状态为 1 和错误:.ebextensions/fonts.config 中的 container_command 01_getfont 失败。
Loaded plugins: priorities, update-motd, upgrade-helper
Examining /var/tmp/yum-root-0Yx1DY/webcore-fonts-3.0-1.noarch.rpm: webcore-fonts-3.0-1.noarch
/var/tmp/yum-root-0Yx1DY/webcore-fonts-3.0-1.noarch.rpm: does not update installed package.
Error: Nothing to do.
当该软件包第二次安装在同一个 EC2 实例上时,如何避免出现该错误?
最佳答案
后来我找到了这个问题的答案,将其张贴在这里以供其他有类似问题的人受益。
我改用重新安装:
sudo yum -y reinstall http://somesite.com/rpm/webcore-fonts-3.0-1.noarch.rpm
这将在第一次和所有其他部署时间起作用。
编辑:
如果未安装软件包,上述方法不起作用以及重新安装将失败。我最终检测到该软件包是否已安装,如果没有,请安装它,否则重新安装:
command: sudo yum -q list installed webcore-fonts.noarch &>/dev/null && sudo yum -y reinstall http://somesite.com/rpm/webcore-fonts-3.0-1.noarch.rpm || sudo yum -y install http://somesite.com/rpm/webcore-fonts-3.0-1.noarch.rpm
关于shell - 已安装软件包时避免 yum 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54412088/