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