1c88ee46cSPhilippe Mathieu-Daudé#!/usr/bin/env python3 21bd26988SFam Zheng# 3*70457c60SJohn Snow# CentOS 8 Stream image 41bd26988SFam Zheng# 5*70457c60SJohn Snow# Copyright 2018, 2022 Red Hat Inc. 61bd26988SFam Zheng# 71bd26988SFam Zheng# Authors: 81bd26988SFam Zheng# Fam Zheng <famz@redhat.com> 91bd26988SFam Zheng# 101bd26988SFam Zheng# This code is licensed under the GPL version 2 or later. See 111bd26988SFam Zheng# the COPYING file in the top-level directory. 121bd26988SFam Zheng# 131bd26988SFam Zheng 141bd26988SFam Zhengimport os 151bd26988SFam Zhengimport sys 161bd26988SFam Zhengimport subprocess 171bd26988SFam Zhengimport basevm 181bd26988SFam Zhengimport time 191bd26988SFam Zheng 201bd26988SFam Zhengclass CentosVM(basevm.BaseVM): 211bd26988SFam Zheng name = "centos" 2231719c37SPhilippe Mathieu-Daudé arch = "x86_64" 231bd26988SFam Zheng BUILD_SCRIPT = """ 241bd26988SFam Zheng set -e; 251bd26988SFam Zheng cd $(mktemp -d); 261bd26988SFam Zheng export SRC_ARCHIVE=/dev/vdb; 271bd26988SFam Zheng sudo chmod a+r $SRC_ARCHIVE; 281bd26988SFam Zheng tar -xf $SRC_ARCHIVE; 29fb1fa97cSDaniel P. Berrangé make docker-test-block@centos8 {verbose} J={jobs} NETWORK=1; 30fb1fa97cSDaniel P. Berrangé make docker-test-quick@centos8 {verbose} J={jobs} NETWORK=1; 311bd26988SFam Zheng """ 321bd26988SFam Zheng 331bd26988SFam Zheng def build_image(self, img): 34*70457c60SJohn Snow cimg = self._download_with_cache("https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-GenericCloud-8-20220125.1.x86_64.qcow2") 351bd26988SFam Zheng img_tmp = img + ".tmp" 361ab330eaSJohn Snow subprocess.check_call(['cp', '-f', cimg, img_tmp]) 371e48931cSWainer dos Santos Moschetta self.exec_qemu_img("resize", img_tmp, "50G") 38b081986cSRobert Foley self.boot(img_tmp, extra_args = ["-cdrom", self.gen_cloud_init_iso()]) 391bd26988SFam Zheng self.wait_ssh() 401bd26988SFam Zheng self.ssh_root_check("touch /etc/cloud/cloud-init.disabled") 41fb1fa97cSDaniel P. Berrangé self.ssh_root_check("dnf update -y") 42fb1fa97cSDaniel P. Berrangé self.ssh_root_check("dnf install -y dnf-plugins-core") 43fb1fa97cSDaniel P. Berrangé self.ssh_root_check("dnf config-manager --set-enabled powertools") 44fb1fa97cSDaniel P. Berrangé self.ssh_root_check("dnf install -y podman make ninja-build git python3") 451bd26988SFam Zheng self.ssh_root("poweroff") 461bd26988SFam Zheng self.wait() 471bd26988SFam Zheng os.rename(img_tmp, img) 481bd26988SFam Zheng return 0 491bd26988SFam Zheng 501bd26988SFam Zhengif __name__ == "__main__": 511bd26988SFam Zheng sys.exit(basevm.main(CentosVM)) 52