0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ダウンロード失敗でリトライする vcpkg

Posted at

はじめに

vcpkg はとても便利ですが,パッケージのダウンロード元から 503 エラーが返ってくると Download failed と言ってリトライしてくれません。

コンテナの Dockerfile から vcpkg を呼び,クラシックモードでいくつかのパッケージをインストールした状態を作りたいのですが,これだとコンテナビルドがランダムに失敗してつらいです。

解決方法

薄いラッパスクリプトを書きました。
vcpkg がエラーを返し,かつ出力に Download failed が入っているときだけコマンドを繰り返します。
また,リトライの前に少しだけスリープするようにしてみました。

#!/bin/bash

set -o pipefail

while true; do
    tmpfile=$(mktemp /tmp/vcpkg-retry.XXXXXX)
    vcpkg "$@" | tee $tmpfile
    vret=$?
    grep "Download failed" $tmpfile
    gret=$?
    rm $tmpfile

    if [ $vret -eq 0 -o $gret -ne 0 ]; then
        exit $vret
    fi

    sleep 3
done
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?