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