xref: /openbmc/qemu/tests/vm/freebsd (revision 5c2ec9b61f33c18ef734e98a42d28ba99775b20c)
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"
2131719c37SPhilippe 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};
28*5c2ec9b6SAlex Bennée        gmake --output-sync -j{jobs} {target} {verbose};
29111e30c0SFam Zheng    """
30111e30c0SFam Zheng
31111e30c0SFam Zheng    def build_image(self, img):
32111e30c0SFam Zheng        cimg = self._download_with_cache("http://download.patchew.org/freebsd-11.1-amd64.img.xz",
33111e30c0SFam Zheng                sha256sum='adcb771549b37bc63826c501f05121a206ed3d9f55f49145908f7e1432d65891')
34111e30c0SFam Zheng        img_tmp_xz = img + ".tmp.xz"
35111e30c0SFam Zheng        img_tmp = img + ".tmp"
36111e30c0SFam Zheng        subprocess.check_call(["cp", "-f", cimg, img_tmp_xz])
37111e30c0SFam Zheng        subprocess.check_call(["xz", "-df", img_tmp_xz])
38111e30c0SFam Zheng        if os.path.exists(img):
39111e30c0SFam Zheng            os.remove(img)
40111e30c0SFam Zheng        os.rename(img_tmp, img)
41111e30c0SFam Zheng
42111e30c0SFam Zhengif __name__ == "__main__":
43111e30c0SFam Zheng    sys.exit(basevm.main(FreeBSDVM))
44