Skip to content

Commit

Permalink
Merge pull request #101 from cevich/netavark
Browse files Browse the repository at this point in the history
Add fedora-netavark VM image
  • Loading branch information
cevich authored Dec 9, 2021
2 parents 99307a2 + d019630 commit d63b522
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ cache_images_task:
- <<: *cache_image
env:
PACKER_BUILDS: "prior-fedora"
- <<: *cache_image
env:
PACKER_BUILDS: "fedora-netavark"
- <<: *cache_image
env:
PACKER_BUILDS: "ubuntu"
Expand Down Expand Up @@ -228,6 +231,7 @@ imgts_task:
ubuntu-b${IMG_SFX}
fedora-c${IMG_SFX}
prior-fedora-c${IMG_SFX}
fedora-netavark-c${IMG_SFX}
ubuntu-c${IMG_SFX}
clone_script: &noop mkdir -p "${CIRRUS_WORKING_DIR}" # source is not needed
script: "/usr/local/bin/entrypoint.sh"
Expand Down
65 changes: 65 additions & 0 deletions cache_images/fedora-netavark_packaging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

# This script is called from fedora_setup.sh and various Dockerfiles.
# It's not intended to be used outside of those contexts. It assumes the lib.sh
# library has already been sourced, and that all "ground-up" package-related activity
# needs to be done, including repository setup and initial update.

set -e

SCRIPT_FILEPATH=$(realpath "${BASH_SOURCE[0]}")
SCRIPT_DIRPATH=$(dirname "$SCRIPT_FILEPATH")
REPO_DIRPATH=$(realpath "$SCRIPT_DIRPATH/../")

# shellcheck source=./lib.sh
source "$REPO_DIRPATH/lib.sh"

msg "Updating/Installing repos and packages for $OS_REL_VER"

bigto ooe.sh $SUDO dnf update -y

INSTALL_PACKAGES=(\
bats
bridge-utils
bzip2
cargo
clippy
curl
dbus-daemon
findutils
firewalld
git
gzip
hostname
iproute
iptables
iputils
jq
kernel-modules
make
nftables
nmap-ncat
openssl
openssl-devel
policycoreutils
redhat-rpm-config
rpm-build
rsync
rust
rustfmt
sed
tar
time
xz
zip
)

msg "Installing general build/test dependencies"
bigto $SUDO dnf install -y "${INSTALL_PACKAGES[@]}"

msg "Installing netavark-specific toolchain dependencies"
export CARGO_HOME="/var/cache/cargo" # must match .cirrus.yml in netavark repo
$SUDO env CARGO_HOME=$CARGO_HOME cargo install mandown sccache

# It was observed in F33, dnf install doesn't always get you the latest/greatest
lilto $SUDO dnf update -y
45 changes: 28 additions & 17 deletions cache_images/fedora_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,36 @@ source "$REPO_DIRPATH/lib.sh"
# for both VM and container image build workflows.
req_env_vars PACKER_BUILD_NAME

bash $SCRIPT_DIRPATH/fedora_packaging.sh

if ! ((CONTAINER)); then
msg "Enabling cgroup management from containers"
ooe.sh $SUDO setsebool -P container_manage_cgroup true
# shellcheck disable=SC2154
if [[ "$PACKER_BUILD_NAME" =~ "netavark" ]]; then
bash $SCRIPT_DIRPATH/fedora-netavark_packaging.sh
else
bash $SCRIPT_DIRPATH/fedora_packaging.sh
fi

# shellcheck disable=SC2154
if ! ((CONTAINER)) && [[ "$PACKER_BUILD_NAME" =~ prior ]]; then
warn "Disabling CgroupsV2 kernel command-line option for systemd"
SEDCMD='s/^GRUB_CMDLINE_LINUX="(.*)"/GRUB_CMDLINE_LINUX="\1 systemd.unified_cgroup_hierarchy=0"/'
ooe.sh $SUDO sed -re "$SEDCMD" -i /etc/default/grub
# This is always a symlink to the correct location under /boot/...
ooe.sh $SUDO grub2-mkconfig -o $($SUDO realpath --physical /etc/grub2.cfg)
# This is needed to update the /boot/loader/entries/... file to match grub
# config (bug?). Discovered Jul 28, 2021 on newly build F33 images. Never
# a problem before this point :(
ooe.sh $SUDO grubby --grub2 --update-kernel=$($SUDO grubby --default-kernel) \
--args="systemd.unified_cgroup_hierarchy=0"
# Only on VMs
if ! ((CONTAINER)); then
if [[ ! "$PACKER_BUILD_NAME" =~ netavark ]]; then
msg "Enabling cgroup management from containers"
ooe.sh $SUDO setsebool -P container_manage_cgroup true
else
msg "Setting up VM for netavark testing"
echo -e '# Added during VM Image build\nsctp' |
$SUDO tee /etc/modules-load.d/netavark_ci_sctp
fi

if [[ "$PACKER_BUILD_NAME" =~ prior ]]; then
warn "Disabling CgroupsV2 kernel command-line option for systemd"
SEDCMD='s/^GRUB_CMDLINE_LINUX="(.*)"/GRUB_CMDLINE_LINUX="\1 systemd.unified_cgroup_hierarchy=0"/'
ooe.sh $SUDO sed -re "$SEDCMD" -i /etc/default/grub
# This is always a symlink to the correct location under /boot/...
ooe.sh $SUDO grub2-mkconfig -o $($SUDO realpath --physical /etc/grub2.cfg)
# This is needed to update the /boot/loader/entries/... file to match grub
# config (bug?). Discovered Jul 28, 2021 on newly build F33 images. Never
# a problem before this point :(
ooe.sh $SUDO grubby --grub2 --update-kernel=$($SUDO grubby --default-kernel) \
--args="systemd.unified_cgroup_hierarchy=0"
fi
fi

nm_ignore_cni
Expand Down
7 changes: 6 additions & 1 deletion cache_images/gce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ builders:
name: 'prior-fedora'
source_image_family: 'prior-fedora-base'

- <<: *gce_hosted_image
name: 'fedora-netavark'
source_image: 'fedora-b{{user `IMG_SFX`}}'
source_image_family: 'fedora-base'

provisioners:
- type: 'shell'
inline:
Expand All @@ -60,7 +65,7 @@ provisioners:
source: '{{ pwd }}/'
destination: "/tmp/automation_images"

- only: ['fedora', 'prior-fedora']
- only: ['fedora', 'prior-fedora', 'fedora-netavark']
type: 'shell'
inline:
- 'set -e'
Expand Down

0 comments on commit d63b522

Please sign in to comment.