xref: /openbmc/qemu/tests/vm/freebsd (revision 31719c37f500a62aeb739ddeea87db89e8c2fcb1)
1111e30c0SFam Zheng#!/usr/bin/env python
2111e30c0SFam Zheng#
3111e30c0SFam Zheng# FreeBSD VM image
4111e30c0SFam Zheng#
5111e30c0SFam Zheng# Copyright 2017 Red Hat Inc.
6111e30c0SFam Zheng#
7111e30c0SFam Zheng# Authors:
8111e30c0SFam Zheng#  Fam Zheng <famz@redhat.com>
9111e30c0SFam Zheng#
10111e30c0SFam Zheng# This code is licensed under the GPL version 2 or later.  See
11111e30c0SFam Zheng# the COPYING file in the top-level directory.
12111e30c0SFam Zheng#
13111e30c0SFam Zheng
14111e30c0SFam Zhengimport os
15111e30c0SFam Zhengimport sys
16111e30c0SFam Zhengimport subprocess
17111e30c0SFam Zhengimport basevm
18111e30c0SFam Zheng
19111e30c0SFam Zhengclass FreeBSDVM(basevm.BaseVM):
20111e30c0SFam Zheng    name = "freebsd"
21*31719c37SPhilippe Mathieu-Daudé    arch = "x86_64"
22111e30c0SFam Zheng    BUILD_SCRIPT = """
23111e30c0SFam Zheng        set -e;
2444b69d50SPeter Maydell        rm -rf /var/tmp/qemu-test.*
25111e30c0SFam Zheng        cd $(mktemp -d /var/tmp/qemu-test.XXXXXX);
26111e30c0SFam Zheng        tar -xf /dev/vtbd1;
27111e30c0SFam Zheng        ./configure {configure_opts};
28f2d4becdSPeter Maydell        gmake --output-sync -j{jobs} {verbose};
29f2d4becdSPeter Maydell        gmake --output-sync -j{jobs} check {verbose};
30111e30c0SFam Zheng    """
31111e30c0SFam Zheng
32111e30c0SFam Zheng    def build_image(self, img):
33111e30c0SFam Zheng        cimg = self._download_with_cache("http://download.patchew.org/freebsd-11.1-amd64.img.xz",
34111e30c0SFam Zheng                sha256sum='adcb771549b37bc63826c501f05121a206ed3d9f55f49145908f7e1432d65891')
35111e30c0SFam Zheng        img_tmp_xz = img + ".tmp.xz"
36111e30c0SFam Zheng        img_tmp = img + ".tmp"
37111e30c0SFam Zheng        subprocess.check_call(["cp", "-f", cimg, img_tmp_xz])
38111e30c0SFam Zheng        subprocess.check_call(["xz", "-df", img_tmp_xz])
39111e30c0SFam Zheng        if os.path.exists(img):
40111e30c0SFam Zheng            os.remove(img)
41111e30c0SFam Zheng        os.rename(img_tmp, img)
42111e30c0SFam Zheng
43111e30c0SFam Zhengif __name__ == "__main__":
44111e30c0SFam Zheng    sys.exit(basevm.main(FreeBSDVM))
45