5

I'm having a script provisioner in vagrant. My box is ubuntu 64bit Precise. The relevant lines of my script look like this:

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

The error code is:

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!

The problem is that despite I know that the repo has expired keys and is not for 64bit architecture (32bit only). Still I'd like to install relevant packages from it (which is possible, using: <package_name>:i386). However during update due to non-exit status vagrant stops and doesn't continue my script any more.

Is there a way (either of vagrant or on the apt-get side) to make vagrant happy and continue execution of my script?

4

2 回答 2

16

您可以使用以下命令将错误状态强制为零; true

sudo sh -c "apt-get update -qq ; true"
于 2013-11-12T08:50:05.053 回答
4

比 Igor 的建议稍微简单的方法是使其成为布尔语句:

apt-get update -qq || true

这避免了调用不必要的子shell。

于 2018-03-09T22:18:33.763 回答