tests/vm: Remove docker cross-compile test from CentOS VM
[qemu.git] / tests / lcitool / refresh
blob5e260f8cd6fe81a371ff4470d984c8b3204215aa
1 #!/usr/bin/env python3
3 # Re-generate container recipes
5 # This script uses the "lcitool" available from
7 #   https://gitlab.com/libvirt/libvirt-ci
9 # Copyright (c) 2020 Red Hat Inc.
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.
15 import sys
16 import subprocess
18 from pathlib import Path
20 if len(sys.argv) != 1:
21     print("syntax: %s" % sys.argv[0], file=sys.stderr)
22     sys.exit(1)
24 self_dir = Path(__file__).parent
25 src_dir = self_dir.parent.parent
26 dockerfiles_dir = Path(src_dir, "tests", "docker", "dockerfiles")
28 lcitool_path = Path(self_dir, "libvirt-ci", "lcitool")
30 lcitool_cmd = [lcitool_path, "--data-dir", self_dir]
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
44 def generate(filename, cmd, trailer):
45     print("Generate %s" % filename)
46     lcitool = subprocess.run(cmd, capture_output=True)
48     if lcitool.returncode != 0:
49         raise Exception("Failed to generate %s: %s" % (filename, lcitool.stderr))
51     content = lcitool.stdout.decode("utf8")
52     if trailer is not None:
53         content += trailer
54     atomic_write(filename, content)
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)
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)
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"
79 # Netmap still needs to be manually built as it is yet to be packaged
80 # into a distro. We also add cscope and gtags which are used in the CI
81 # test
82 debian11_extras = [
83     "# netmap/cscope/global\n",
84     "RUN DEBIAN_FRONTEND=noninteractive eatmydata \\\n",
85     "  apt install -y --no-install-recommends \\\n",
86     "  cscope\\\n",
87     "  global\\\n",
88     "  linux-headers-amd64\n",
89     "RUN git clone https://github.com/luigirizzo/netmap.git /usr/src/netmap\n",
90     "RUN cd /usr/src/netmap && git checkout v11.3\n",
91     "RUN cd /usr/src/netmap/LINUX && ./configure --no-drivers --no-apps --kernel-dir=$(ls -d /usr/src/linux-headers-*-amd64) && make install\n",
92     "ENV QEMU_CONFIGURE_OPTS --enable-netmap\n"
96 def debian_cross_build(prefix, targets):
97     conf = "ENV QEMU_CONFIGURE_OPTS --cross-prefix=%s\n" % (prefix)
98     targets = "ENV DEF_TARGET_LIST %s\n" % (targets)
99     return "".join([conf, targets])
102 # Update all the various build configurations.
103 # Please keep each group sorted alphabetically for easy reading.
106 try:
107     #
108     # Standard native builds
109     #
110     generate_dockerfile("alpine", "alpine-edge")
111     generate_dockerfile("centos8", "centos-stream-8")
112     generate_dockerfile("debian-amd64", "debian-11",
113                         trailer="".join(debian11_extras))
114     generate_dockerfile("fedora", "fedora-35")
115     generate_dockerfile("opensuse-leap", "opensuse-leap-152")
116     generate_dockerfile("ubuntu2004", "ubuntu-2004",
117                         trailer="".join(ubuntu2004_tsanhack))
119     #
120     # Cross compiling builds
121     #
122     generate_dockerfile("debian-arm64-cross", "debian-11",
123                         cross="aarch64",
124                         trailer=debian_cross_build("aarch64-linux-gnu-",
125                                                    "aarch64-softmmu,aarch64-linux-user"))
127     generate_dockerfile("debian-armel-cross", "debian-11",
128                         cross="armv6l",
129                         trailer=debian_cross_build("arm-linux-gnueabi-",
130                                                    "arm-softmmu,arm-linux-user,armeb-linux-user"))
132     generate_dockerfile("debian-armhf-cross", "debian-11",
133                         cross="armv7l",
134                         trailer=debian_cross_build("arm-linux-gnueabihf-",
135                                                    "arm-softmmu,arm-linux-user"))
137     generate_dockerfile("debian-mips64el-cross", "debian-11",
138                         cross="mips64el",
139                         trailer=debian_cross_build("mips64el-linux-gnuabi64-",
140                                                   "mips64el-softmmu,mips64el-linux-user"))
142     generate_dockerfile("debian-mipsel-cross", "debian-11",
143                         cross="mipsel",
144                         trailer=debian_cross_build("mipsel-linux-gnu-",
145                                                    "mipsel-softmmu,mipsel-linux-user"))
147     generate_dockerfile("debian-ppc64el-cross", "debian-11",
148                         cross="ppc64le",
149                         trailer=debian_cross_build("powerpc64le-linux-gnu-",
150                                                    "ppc64-softmmu,ppc64-linux-user"))
152     generate_dockerfile("debian-s390x-cross", "debian-11",
153                         cross="s390x",
154                         trailer=debian_cross_build("s390x-linux-gnu-",
155                                                    "s390x-softmmu,s390x-linux-user"))
157     #
158     # Cirrus packages lists for GitLab
159     #
160     generate_cirrus("freebsd-12")
161     generate_cirrus("freebsd-13")
162     generate_cirrus("macos-11")
164     sys.exit(0)
165 except Exception as ex:
166     print(str(ex), file=sys.stderr)
167     sys.exit(1)