1fdfaa332SFam Zheng#!/usr/bin/env python 2fdfaa332SFam Zheng# 3fdfaa332SFam Zheng# OpenBSD VM image 4fdfaa332SFam Zheng# 5fdfaa332SFam Zheng# Copyright 2017 Red Hat Inc. 6fdfaa332SFam Zheng# 7fdfaa332SFam Zheng# Authors: 8fdfaa332SFam Zheng# Fam Zheng <famz@redhat.com> 9fdfaa332SFam Zheng# 10fdfaa332SFam Zheng# This code is licensed under the GPL version 2 or later. See 11fdfaa332SFam Zheng# the COPYING file in the top-level directory. 12fdfaa332SFam Zheng# 13fdfaa332SFam Zheng 14fdfaa332SFam Zhengimport os 15fdfaa332SFam Zhengimport sys 16fdfaa332SFam Zhengimport subprocess 17fdfaa332SFam Zhengimport basevm 18fdfaa332SFam Zheng 19fdfaa332SFam Zhengclass OpenBSDVM(basevm.BaseVM): 20fdfaa332SFam Zheng name = "openbsd" 21*31719c37SPhilippe Mathieu-Daudé arch = "x86_64" 22fdfaa332SFam Zheng BUILD_SCRIPT = """ 23fdfaa332SFam Zheng set -e; 2444b69d50SPeter Maydell rm -rf /var/tmp/qemu-test.* 25fdfaa332SFam Zheng cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); 26fdfaa332SFam Zheng tar -xf /dev/rsd1c; 27fdfaa332SFam Zheng ./configure --cc=x86_64-unknown-openbsd6.1-gcc-4.9.4 --python=python2.7 {configure_opts}; 28f2d4becdSPeter Maydell gmake --output-sync -j{jobs} {verbose}; 29fdfaa332SFam Zheng # XXX: "gmake check" seems to always hang or fail 30f2d4becdSPeter Maydell #gmake --output-sync -j{jobs} check {verbose}; 31fdfaa332SFam Zheng """ 32fdfaa332SFam Zheng 33fdfaa332SFam Zheng def build_image(self, img): 34fdfaa332SFam Zheng cimg = self._download_with_cache("http://download.patchew.org/openbsd-6.1-amd64.img.xz", 35fdfaa332SFam Zheng sha256sum='8c6cedc483e602cfee5e04f0406c64eb99138495e8ca580bc0293bcf0640c1bf') 36fdfaa332SFam Zheng img_tmp_xz = img + ".tmp.xz" 37fdfaa332SFam Zheng img_tmp = img + ".tmp" 38fdfaa332SFam Zheng subprocess.check_call(["cp", "-f", cimg, img_tmp_xz]) 39fdfaa332SFam Zheng subprocess.check_call(["xz", "-df", img_tmp_xz]) 40fdfaa332SFam Zheng if os.path.exists(img): 41fdfaa332SFam Zheng os.remove(img) 42fdfaa332SFam Zheng os.rename(img_tmp, img) 43fdfaa332SFam Zheng 44fdfaa332SFam Zhengif __name__ == "__main__": 45fdfaa332SFam Zheng sys.exit(basevm.main(OpenBSDVM)) 46