From 1daaafe2a31048a1b71a893b186541d7122a56b7 Mon Sep 17 00:00:00 2001 From: Alex Pyrgiotis Date: Tue, 1 Nov 2022 15:34:04 +0200 Subject: [PATCH] install: Introduce a script for installing Podman Introduce a script for installing Podman in Ubuntu Focal, in environments that may, or may not, have sudo installed. Also, update our CircleCI configuration to use this script when installing Podman. --- .circleci/config.yml | 20 +++++----- install/linux/install-podman-ubuntu-focal.sh | 40 ++++++++++++++++++++ 2 files changed, 49 insertions(+), 11 deletions(-) create mode 100755 install/linux/install-podman-ubuntu-focal.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 56baa08..6762169 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,14 @@ version: 2.1 aliases: + - &provide-podman + name: Provide Podman in Ubuntu Focal + command: ./install/linux/install-podman-ubuntu-focal.sh --repo-only + + - &install-podman + name: Install Podman in Ubuntu Focal + command: ./install/linux/install-podman-ubuntu-focal.sh + - &install-dependencies-deb name: Install dependencies (deb) command: | @@ -121,18 +129,8 @@ jobs: machine: image: ubuntu-2004:202111-01 steps: - # https://www.atlantic.net/dedicated-server-hosting/how-to-install-and-use-podman-on-ubuntu-20-04/ - - run: - name: Install podman on Ubuntu 20.04 - command: | - export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true - source /etc/os-release - sudo sh -c "echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list" - wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key -O- | sudo apt-key add - - sudo apt-get update -qq -y - sudo apt-get -qq --yes install podman - podman --version - checkout + - run: *install-podman - run: name: Install poetry dependencies command: | diff --git a/install/linux/install-podman-ubuntu-focal.sh b/install/linux/install-podman-ubuntu-focal.sh new file mode 100755 index 0000000..34351ec --- /dev/null +++ b/install/linux/install-podman-ubuntu-focal.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Development script for installing Podman on Ubuntu Focal. Mainly to be used as +# part of our CI pipelines, where we may install Podman on environments that +# don't have sudo. + +set -e + +if [[ "$EUID" -ne 0 ]]; then + SUDO=sudo +else + SUDO= +fi + +provide() { + $SUDO apt-get update + $SUDO apt-get install curl wget gnupg2 -y + source /etc/os-release + $SUDO sh -c "echo 'deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /' \ + > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list" + wget -nv https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key -O- \ + | $SUDO apt-key add - + $SUDO apt-get update -qq -y +} + +install() { + $SUDO apt-get -qq --yes install podman + podman --version +} + +if [[ "$1" == "--repo-only" ]]; then + provide +elif [[ "$1" == "" ]]; then + provide + install +else + echo "Unexpected argument: $1" + echo "Usage: $0 [--repo-only]" + exit 1 +fi