我正在vagrant中使用脚本配置,我的虚拟机是64位的ubuntu Precise版本。相关的脚本行看起来像这样:
sudo bash -c 'echo "deb https://oss.oracle.com/debian/ unstable main non-free" >/etc/apt/sources.list.d/oracle.list'
wget -q https://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- | sudo apt-key add -
sudo apt-get update -qq
错误代码为:
W: GPG error: https://oss.oracle.com unstable Release: The following signatures were invalid: KEYEXPIRED 1378511808 KEYEXPIRED 1378511808 KEYEXPIRED 1378511808
W: Failed to fetch https://oss.oracle.com/debian/dists/unstable/main/binary-amd64/Packages The requested URL returned error: 404
W: Failed to fetch https://oss.oracle.com/debian/dists/unstable/non-free/binary-amd64/Packages The requested URL returned error: 404
E: Some index files failed to download. They have been ignored, or old ones used instead.
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
问题在于,尽管我知道该存储库存在过期的密钥并且不支持64位架构(仅支持32位),但我仍然想从中安装相关软件包(使用:
<package_name>:i386
)。然而,在更新过程中,由于非退出状态,vagrant停止执行并不再继续我的脚本。是否有一种方法(无论是通过vagrant还是通过
apt-get
)可以使vagrant保持愉快并继续执行我的脚本?
|
而不是;
。请查看更新后的答案。 - Peter Butkovic;
,Vagrant 会检测到非零状态并再次失败。但是,使用|
时,Vagrant 必须一次性执行所有命令 => 没有机会检测链中不在末尾的命令的退出状态。这就是原因。请注意,如果您将答案保留为现在的样子,它是不正确的。 - Peter Butkovicsudo sh -c 'apt-get update -qq ; true'
?问题在于你用shell覆盖了带有非零退出代码的命令;vargrant看不出任何可疑之处。而且加上| true
是错误的,因为你会在管道之前失去命令的stdout。 - Igor Chubinver > nul
、cmd /c "exit /b 0"
或者set "errorlevel="
。请尝试使用它们。 - Igor Chubin