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" 21fdfaa332SFam Zheng BUILD_SCRIPT = """ 22fdfaa332SFam Zheng set -e; 23*44b69d50SPeter Maydell rm -rf /var/tmp/qemu-test.* 24fdfaa332SFam Zheng cd $(mktemp -d /var/tmp/qemu-test.XXXXXX); 25fdfaa332SFam Zheng tar -xf /dev/rsd1c; 26fdfaa332SFam Zheng ./configure --cc=x86_64-unknown-openbsd6.1-gcc-4.9.4 --python=python2.7 {configure_opts}; 27f2d4becdSPeter Maydell gmake --output-sync -j{jobs} {verbose}; 28fdfaa332SFam Zheng # XXX: "gmake check" seems to always hang or fail 29f2d4becdSPeter Maydell #gmake --output-sync -j{jobs} check {verbose}; 30fdfaa332SFam Zheng """ 31fdfaa332SFam Zheng 32fdfaa332SFam Zheng def build_image(self, img): 33fdfaa332SFam Zheng cimg = self._download_with_cache("http://download.patchew.org/openbsd-6.1-amd64.img.xz", 34fdfaa332SFam Zheng sha256sum='8c6cedc483e602cfee5e04f0406c64eb99138495e8ca580bc0293bcf0640c1bf') 35fdfaa332SFam Zheng img_tmp_xz = img + ".tmp.xz" 36fdfaa332SFam Zheng img_tmp = img + ".tmp" 37fdfaa332SFam Zheng subprocess.check_call(["cp", "-f", cimg, img_tmp_xz]) 38fdfaa332SFam Zheng subprocess.check_call(["xz", "-df", img_tmp_xz]) 39fdfaa332SFam Zheng if os.path.exists(img): 40fdfaa332SFam Zheng os.remove(img) 41fdfaa332SFam Zheng os.rename(img_tmp, img) 42fdfaa332SFam Zheng 43fdfaa332SFam Zhengif __name__ == "__main__": 44fdfaa332SFam Zheng sys.exit(basevm.main(OpenBSDVM)) 45