]> git.proxmox.com Git - mirror_qemu.git/blob - tests/lcitool/refresh
Merge remote-tracking branch 'remotes/stsquad/tags/pull-for-7.0-180122-2' into staging
[mirror_qemu.git] / tests / lcitool / refresh
1 #!/usr/bin/python3
2 #
3 # Re-generate container recipes
4 #
5 # This script uses the "lcitool" available from
6 #
7 # https://gitlab.com/libvirt/libvirt-ci
8 #
9 # Copyright (c) 2020 Red Hat Inc.
10 #
11 # This work is licensed under the terms of the GNU GPL, version 2
12 # or (at your option) any later version. See the COPYING file in
13 # the top-level directory.
14
15 import sys
16 import os
17 import subprocess
18
19 from pathlib import Path
20
21 if len(sys.argv) != 1:
22 print("syntax: %s" % sys.argv[0], file=sys.stderr)
23 sys.exit(1)
24
25 self_dir = Path(__file__).parent
26 src_dir = self_dir.parent.parent
27 dockerfiles_dir = Path(src_dir, "tests", "docker", "dockerfiles")
28
29 lcitool_path = Path(self_dir, "libvirt-ci", "lcitool")
30
31 lcitool_cmd = [lcitool_path, "--data-dir", self_dir]
32
33 def atomic_write(filename, content):
34 tmp = filename.with_suffix(filename.suffix + ".tmp")
35 try:
36 with tmp.open("w") as fp:
37 print(content, file=fp, end="")
38 tmp.rename(filename)
39 except Exception as ex:
40 tmp.unlink()
41 raise
42
43 def generate(filename, cmd, trailer):
44 print("Generate %s" % filename)
45 lcitool=subprocess.run(cmd, capture_output=True)
46
47 if lcitool.returncode != 0:
48 raise Exception("Failed to generate %s: %s" % (filename, lcitool.stderr))
49
50 content = lcitool.stdout.decode("utf8")
51 if trailer is not None:
52 content += trailer
53 atomic_write(filename, content)
54
55 def generate_dockerfile(host, target, cross=None, trailer=None):
56 filename = Path(src_dir, "tests", "docker", "dockerfiles", host + ".docker")
57 cmd = lcitool_cmd + ["dockerfile"]
58 if cross is not None:
59 cmd.extend(["--cross", cross])
60 cmd.extend([target, "qemu"])
61 generate(filename, cmd, trailer)
62
63 def generate_cirrus(target, trailer=None):
64 filename = Path(src_dir, ".gitlab-ci.d", "cirrus", target + ".vars")
65 cmd = [lcitool_path, "variables", target, "qemu"]
66 generate(filename, cmd, trailer)
67
68 ubuntu1804_skipssh = [
69 "# https://bugs.launchpad.net/qemu/+bug/1838763\n",
70 "ENV QEMU_CONFIGURE_OPTS --disable-libssh\n"
71 ]
72
73 ubuntu2004_tsanhack = [
74 "# Apply patch https://reviews.llvm.org/D75820\n",
75 "# This is required for TSan in clang-10 to compile with QEMU.\n",
76 "RUN sed -i 's/^const/static const/g' /usr/lib/llvm-10/lib/clang/10.0.0/include/sanitizer/tsan_interface.h\n"
77 ]
78
79 try:
80 generate_dockerfile("centos8", "centos-8")
81 generate_dockerfile("fedora", "fedora-35")
82 generate_dockerfile("ubuntu1804", "ubuntu-1804",
83 trailer="".join(ubuntu1804_skipssh))
84 generate_dockerfile("ubuntu2004", "ubuntu-2004",
85 trailer="".join(ubuntu2004_tsanhack))
86 generate_dockerfile("opensuse-leap", "opensuse-leap-152")
87 generate_dockerfile("alpine", "alpine-edge")
88
89 generate_cirrus("freebsd-12")
90 generate_cirrus("freebsd-13")
91 generate_cirrus("macos-11")
92
93 sys.exit(0)
94 except Exception as ex:
95 print(str(ex), file=sys.stderr)
96 sys.exit(1)