github.com/opencontainers/runc@v1.2.0-rc.1.0.20240520010911-492dc558cdd6/tests/integration/get-images.sh (about)

     1  #!/bin/bash
     2  
     3  # DO NOT EDIT!  Generated by "bootstrap-get-images.sh"
     4  
     5  # This script checks if container images needed for tests (currently
     6  # busybox and Debian 10 "Buster") are available locally, and downloads
     7  # them to testdata directory if not.
     8  #
     9  # The script is self-contained/standalone and is used from a few places
    10  # that need to ensure the images are downloaded. Its output is suitable
    11  # for consumption by shell via eval (see helpers.bash).
    12  
    13  set -e -u -o pipefail
    14  
    15  # Root directory of integration tests.
    16  INTEGRATION_ROOT=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
    17  # Test data path.
    18  TESTDATA="${INTEGRATION_ROOT}/testdata"
    19  # Sanity check: $TESTDATA directory must exist.
    20  if [ ! -d "$TESTDATA" ]; then
    21  	echo "Bad TESTDATA directory: $TESTDATA. Aborting" >&2
    22  	exit 1
    23  fi
    24  
    25  function get() {
    26  	local dest="$1" url="$2"
    27  
    28  	[ -e "$dest" ] && return
    29  
    30  	# Sanity check: $TESTDATA directory must be writable.
    31  	if [ ! -w "$TESTDATA" ]; then
    32  		echo "TESTDATA directory ($TESTDATA) not writable. Aborting" >&2
    33  		exit 1
    34  	fi
    35  
    36  	if ! curl -o "$dest" -fsSL --retry 5 "$url"; then
    37  		echo "Failed to get $url" 1>&2
    38  		exit 1
    39  	fi
    40  }
    41  
    42  arch=$(go env GOARCH)
    43  if [ "$arch" = 'arm' ]; then
    44  	arm=$(go env GOARM)
    45  	: "${arm:=7}"
    46  	arch=${arch}v$arm
    47  fi
    48  
    49  case $arch in
    50  amd64)
    51  	# https://github.com/docker-library/busybox/tree/dist-amd64
    52  	# https://github.com/docker-library/busybox/tree/31d342ad033e27c18723a516a2274ab39547be27/stable/glibc
    53  	url="https://github.com/docker-library/busybox/raw/31d342ad033e27c18723a516a2274ab39547be27/stable/glibc/busybox.tar.xz"
    54  	;;
    55  
    56  armv5)
    57  	# https://github.com/docker-library/busybox/tree/dist-arm32v5
    58  	# https://github.com/docker-library/busybox/tree/96ea82ea25565f78b50bd032d5768d64985d6e11/stable/glibc
    59  	url="https://github.com/docker-library/busybox/raw/96ea82ea25565f78b50bd032d5768d64985d6e11/stable/glibc/busybox.tar.xz"
    60  	;;
    61  
    62  armv7)
    63  	# https://github.com/docker-library/busybox/tree/dist-arm32v7
    64  	# https://github.com/docker-library/busybox/tree/5cb6c347469e86e4468e5e248de751b3598bb577/stable/glibc
    65  	url="https://github.com/docker-library/busybox/raw/5cb6c347469e86e4468e5e248de751b3598bb577/stable/glibc/busybox.tar.xz"
    66  	;;
    67  
    68  arm64)
    69  	# https://github.com/docker-library/busybox/tree/dist-arm64v8
    70  	# https://github.com/docker-library/busybox/tree/94c664b5ca464546266bce54be0082874a44c7b2/stable/glibc
    71  	url="https://github.com/docker-library/busybox/raw/94c664b5ca464546266bce54be0082874a44c7b2/stable/glibc/busybox.tar.xz"
    72  	;;
    73  
    74  386)
    75  	# https://github.com/docker-library/busybox/tree/dist-i386
    76  	# https://github.com/docker-library/busybox/tree/461a473aef31b7726ea99909a24551bf44565c05/stable/glibc
    77  	url="https://github.com/docker-library/busybox/raw/461a473aef31b7726ea99909a24551bf44565c05/stable/glibc/busybox.tar.xz"
    78  	;;
    79  
    80  mips64le)
    81  	# https://github.com/docker-library/busybox/tree/dist-mips64le
    82  	# https://github.com/docker-library/busybox/tree/47f73f7c735dcd6760a976bfe0012d251b6ef0a9/stable/glibc
    83  	url="https://github.com/docker-library/busybox/raw/47f73f7c735dcd6760a976bfe0012d251b6ef0a9/stable/glibc/busybox.tar.xz"
    84  	;;
    85  
    86  ppc64le)
    87  	# https://github.com/docker-library/busybox/tree/dist-ppc64le
    88  	# https://github.com/docker-library/busybox/tree/9ca13bc214717966383cf97e08606b444b7300e4/stable/glibc
    89  	url="https://github.com/docker-library/busybox/raw/9ca13bc214717966383cf97e08606b444b7300e4/stable/glibc/busybox.tar.xz"
    90  	;;
    91  
    92  s390x)
    93  	# https://github.com/docker-library/busybox/tree/dist-s390x
    94  	# https://github.com/docker-library/busybox/tree/a03814d21bcf97767121bb9422a742ec237a09e2/stable/glibc
    95  	url="https://github.com/docker-library/busybox/raw/a03814d21bcf97767121bb9422a742ec237a09e2/stable/glibc/busybox.tar.xz"
    96  	;;
    97  
    98  *)
    99  	echo >&2 "error: unsupported busybox architecture: $arch"
   100  	exit 1
   101  	;;
   102  esac
   103  rootfs="$TESTDATA/busybox-${arch}.tar.xz"
   104  get "$rootfs" "$url"
   105  var=busybox_image
   106  echo "${var^^}=$rootfs"
   107  
   108  case $arch in
   109  amd64)
   110  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/dist-amd64
   111  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/686d9f6eaada08a754bc7abf6f6184c65c5b378f/buster/slim
   112  	url="https://github.com/debuerreotype/docker-debian-artifacts/raw/686d9f6eaada08a754bc7abf6f6184c65c5b378f/buster/slim/rootfs.tar.xz"
   113  	;;
   114  
   115  armv5)
   116  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/dist-arm32v5
   117  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/155640b6e2e249dfaeee8795d5de539ef3e49417/buster/slim
   118  	url="https://github.com/debuerreotype/docker-debian-artifacts/raw/155640b6e2e249dfaeee8795d5de539ef3e49417/buster/slim/rootfs.tar.xz"
   119  	;;
   120  
   121  armv7)
   122  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/dist-arm32v7
   123  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/60ff0c2c6ce9556e5d8a2758dd2b3f3731716a6f/buster/slim
   124  	url="https://github.com/debuerreotype/docker-debian-artifacts/raw/60ff0c2c6ce9556e5d8a2758dd2b3f3731716a6f/buster/slim/rootfs.tar.xz"
   125  	;;
   126  
   127  arm64)
   128  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/dist-arm64v8
   129  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/2f108af35e22064c848b8628a7cac56192246dba/buster/slim
   130  	url="https://github.com/debuerreotype/docker-debian-artifacts/raw/2f108af35e22064c848b8628a7cac56192246dba/buster/slim/rootfs.tar.xz"
   131  	;;
   132  
   133  386)
   134  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/dist-i386
   135  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/e4db8aa97f4366e6f27ddbdeaed0773fe0288d47/buster/slim
   136  	url="https://github.com/debuerreotype/docker-debian-artifacts/raw/e4db8aa97f4366e6f27ddbdeaed0773fe0288d47/buster/slim/rootfs.tar.xz"
   137  	;;
   138  
   139  mips64le)
   140  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/dist-mips64le
   141  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/e28cbd76dcfba10446b1722aebb5a996121e3d27/buster/slim
   142  	url="https://github.com/debuerreotype/docker-debian-artifacts/raw/e28cbd76dcfba10446b1722aebb5a996121e3d27/buster/slim/rootfs.tar.xz"
   143  	;;
   144  
   145  ppc64le)
   146  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/dist-ppc64le
   147  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/3ba08903ca3fd48fe59ba92b02744a2f5d4d9d6f/buster/slim
   148  	url="https://github.com/debuerreotype/docker-debian-artifacts/raw/3ba08903ca3fd48fe59ba92b02744a2f5d4d9d6f/buster/slim/rootfs.tar.xz"
   149  	;;
   150  
   151  s390x)
   152  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/dist-s390x
   153  	# https://github.com/debuerreotype/docker-debian-artifacts/tree/2fddbf8fe632fc5865b140341b68a1358586fff2/buster/slim
   154  	url="https://github.com/debuerreotype/docker-debian-artifacts/raw/2fddbf8fe632fc5865b140341b68a1358586fff2/buster/slim/rootfs.tar.xz"
   155  	;;
   156  
   157  *)
   158  	echo >&2 "error: unsupported debian architecture: $arch"
   159  	exit 1
   160  	;;
   161  esac
   162  rootfs="$TESTDATA/debian-${arch}.tar.xz"
   163  get "$rootfs" "$url"
   164  var=debian_image
   165  echo "${var^^}=$rootfs"