]> git.proxmox.com Git - mirror_qemu.git/blob - tests/lcitool/refresh
tests/docker: update debian-armhf-cross with lcitool
[mirror_qemu.git] / tests / lcitool / refresh
1 #!/usr/bin/env 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 subprocess
17
18 from pathlib import Path
19
20 if len(sys.argv) != 1:
21 print("syntax: %s" % sys.argv[0], file=sys.stderr)
22 sys.exit(1)
23
24 self_dir = Path(__file__).parent
25 src_dir = self_dir.parent.parent
26 dockerfiles_dir = Path(src_dir, "tests", "docker", "dockerfiles")
27
28 lcitool_path = Path(self_dir, "libvirt-ci", "lcitool")
29
30 lcitool_cmd = [lcitool_path, "--data-dir", self_dir]
31
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
44 def generate(filename, cmd, trailer):
45 print("Generate %s" % filename)
46 lcitool = subprocess.run(cmd, capture_output=True)
47
48 if lcitool.returncode != 0:
49 raise Exception("Failed to generate %s: %s" % (filename, lcitool.stderr))
50
51 content = lcitool.stdout.decode("utf8")
52 if trailer is not None:
53 content += trailer
54 atomic_write(filename, content)
55
56
57 def generate_dockerfile(host, target, cross=None, trailer=None):
58 filename = Path(src_dir, "tests", "docker", "dockerfiles", host + ".docker")
59 cmd = lcitool_cmd + ["dockerfile"]
60 if cross is not None:
61 cmd.extend(["--cross", cross])
62 cmd.extend([target, "qemu"])
63 generate(filename, cmd, trailer)
64
65
66 def generate_cirrus(target, trailer=None):
67 filename = Path(src_dir, ".gitlab-ci.d", "cirrus", target + ".vars")
68 cmd = lcitool_cmd + ["variables", target, "qemu"]
69 generate(filename, cmd, trailer)
70
71
72 ubuntu2004_tsanhack = [
73 "# Apply patch https://reviews.llvm.org/D75820\n",
74 "# This is required for TSan in clang-10 to compile with QEMU.\n",
75 "RUN sed -i 's/^const/static const/g' /usr/lib/llvm-10/lib/clang/10.0.0/include/sanitizer/tsan_interface.h\n"
76 ]
77
78
79 def debian_cross_build(prefix, targets):
80 conf = "ENV QEMU_CONFIGURE_OPTS --cross-prefix=%s\n" % (prefix)
81 targets = "ENV DEF_TARGET_LIST %s\n" % (targets)
82 return "".join([conf, targets])
83
84 #
85 # Update all the various build configurations.
86 # Please keep each group sorted alphabetically for easy reading.
87 #
88
89 try:
90 #
91 # Standard native builds
92 #
93 generate_dockerfile("alpine", "alpine-edge")
94 generate_dockerfile("centos8", "centos-stream-8")
95 generate_dockerfile("fedora", "fedora-35")
96 generate_dockerfile("opensuse-leap", "opensuse-leap-152")
97 generate_dockerfile("ubuntu2004", "ubuntu-2004",
98 trailer="".join(ubuntu2004_tsanhack))
99
100 #
101 # Cross compiling builds
102 #
103 generate_dockerfile("debian-arm64-cross", "debian-11",
104 cross="aarch64",
105 trailer=debian_cross_build("aarch64-linux-gnu-",
106 "aarch64-softmmu,aarch64-linux-user"))
107
108 generate_dockerfile("debian-armhf-cross", "debian-11",
109 cross="armv7l",
110 trailer=debian_cross_build("arm-linux-gnueabihf-",
111 "arm-softmmu,arm-linux-user"))
112
113 generate_dockerfile("debian-s390x-cross", "debian-11",
114 cross="s390x",
115 trailer=debian_cross_build("s390x-linux-gnu-",
116 "s390x-softmmu,s390x-linux-user"))
117
118 #
119 # Cirrus packages lists for GitLab
120 #
121 generate_cirrus("freebsd-12")
122 generate_cirrus("freebsd-13")
123 generate_cirrus("macos-11")
124
125 sys.exit(0)
126 except Exception as ex:
127 print(str(ex), file=sys.stderr)
128 sys.exit(1)