xref: /openbmc/qemu/tests/vm/freebsd (revision f2d4becdc765b0f8d3095283644c6b62fa5d525a)
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"
21111e30c0SFam Zheng    BUILD_SCRIPT = """
22111e30c0SFam Zheng        set -e;
23111e30c0SFam Zheng        cd $(mktemp -d /var/tmp/qemu-test.XXXXXX);
24111e30c0SFam Zheng        tar -xf /dev/vtbd1;
25111e30c0SFam Zheng        ./configure {configure_opts};
26*f2d4becdSPeter Maydell        gmake --output-sync -j{jobs} {verbose};
27*f2d4becdSPeter Maydell        gmake --output-sync -j{jobs} check {verbose};
28111e30c0SFam Zheng    """
29111e30c0SFam Zheng
30111e30c0SFam Zheng    def build_image(self, img):
31111e30c0SFam Zheng        cimg = self._download_with_cache("http://download.patchew.org/freebsd-11.1-amd64.img.xz",
32111e30c0SFam Zheng                sha256sum='adcb771549b37bc63826c501f05121a206ed3d9f55f49145908f7e1432d65891')
33111e30c0SFam Zheng        img_tmp_xz = img + ".tmp.xz"
34111e30c0SFam Zheng        img_tmp = img + ".tmp"
35111e30c0SFam Zheng        subprocess.check_call(["cp", "-f", cimg, img_tmp_xz])
36111e30c0SFam Zheng        subprocess.check_call(["xz", "-df", img_tmp_xz])
37111e30c0SFam Zheng        if os.path.exists(img):
38111e30c0SFam Zheng            os.remove(img)
39111e30c0SFam Zheng        os.rename(img_tmp, img)
40111e30c0SFam Zheng
41111e30c0SFam Zhengif __name__ == "__main__":
42111e30c0SFam Zheng    sys.exit(basevm.main(FreeBSDVM))
43