gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/test/podman/run.sh (about)

     1  #!/bin/bash
     2  
     3  # Copyright 2022 The gVisor Authors.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http://www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  set -u -x -e -o pipefail
    18  
    19  export DEBIAN_FRONTEND=noninteractive
    20  sudo -E apt-get install -qy podman
    21  
    22  test_dir="$(mktemp -d /tmp/gvisor-podman.XXXXXX)"
    23  podman_runtime="${test_dir}/runsc.podman"
    24  
    25  cleanup() {
    26          rm -rf "${test_dir}"
    27  }
    28  trap cleanup EXIT
    29  
    30  make copy TARGETS=runsc DESTINATION="${test_dir}"
    31  cat > "${podman_runtime}" <<EOF
    32  #!/bin/bash
    33  
    34  exec $test_dir/runsc --ignore-cgroups --debug --debug-log ${test_dir}/runsc.log ${RUNTIME_ARGS:-} "\$@"
    35  EOF
    36  chmod ugo+x "${podman_runtime}"
    37  chmod ugo+x "${test_dir}/runsc"
    38  chmod ugo+xwr "${test_dir}"
    39  grep podman-testuser /etc/passwd || \
    40  adduser   --disabled-login  --disabled-password podman-testuser < /dev/null
    41  (
    42          cd /
    43          sudo -u podman-testuser podman run --runtime "${podman_runtime}" alpine echo "Hello, world"
    44  )