Files
podman/contrib/cirrus/packer/image-builder-image_base-setup.sh
Ed Santiago 295c531ece cirrus lib.sh: refactor req_env_var()
Existing code was not working due to a bash gotcha ('exit'
from a pipeline). It also had unnecessary duplication.

New version is safer; also includes unit tests run under localunit.

Existing invocations of req_env_var replaced via:

   $ [ edit setup_environment.sh, move one closing quote to its own line ]
   $ perl -ni -e 's/(?<=req_env_var )"(\S+)\s+\$\1"/$1/; if (/req_env_var "$/ .. /^\s*"/) { chomp; s/(?<=\S)\s.*//; if (/^\s*"/) { print "\n" } else { unless (/req_env_var/) { s/^\s+//; print " ";} print;} } else { print }' $(ack -l req_env_var)
   $ [ hand-massage an incorrect instance of '@' in lib.sh:ircmsg() ]

Signed-off-by: Ed Santiago <santiago@redhat.com>
2019-05-02 08:14:59 -06:00

74 lines
1.5 KiB
Bash

#!/bin/bash
# This script is called by packer on a vanilla CentOS VM, to setup the image
# used for building images FROM base images. It's not intended to be used
# outside of this context.
set -e
[[ "$1" == "post" ]] || exit 0 # pre stage not needed
# Load in library (copied by packer, before this script was run)
source $GOSRC/$SCRIPT_BASE/lib.sh
req_env_var TIMESTAMP GOSRC SCRIPT_BASE PACKER_BASE
install_ooe
echo "Updating packages"
ooe.sh sudo yum -y update
echo "Configuring repositories"
ooe.sh sudo yum -y install centos-release-scl epel-release
echo "Installing packages"
ooe.sh sudo yum -y install \
genisoimage \
golang \
google-cloud-sdk \
libvirt \
libvirt-admin \
libvirt-client \
libvirt-daemon \
make \
python34 \
python34 \
python34-PyYAML \
python34-PyYAML \
qemu-img \
qemu-kvm \
qemu-kvm-tools \
qemu-user \
rsync \
rng-tools \
unzip \
util-linux \
vim
sudo systemctl enable rngd
sudo ln -s /usr/libexec/qemu-kvm /usr/bin/
sudo tee /etc/modprobe.d/kvm-nested.conf <<EOF
options kvm-intel nested=1
options kvm-intel enable_shadow_vmcs=1
options kvm-intel enable_apicv=1
options kvm-intel ept=1
EOF
echo "Installing packer"
sudo mkdir -p /root/$(basename $PACKER_BASE)
sudo cp $GOSRC/$PACKER_BASE/*packer* /root/$(basename $PACKER_BASE)
sudo mkdir -p /root/$(basename $SCRIPT_BASE)
sudo cp $GOSRC/$SCRIPT_BASE/*.sh /root/$(basename $SCRIPT_BASE)
install_scl_git
echo "Cleaning up"
cd /
rm -rf $GOSRC
rh_finalize
echo "SUCCESS!"