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