Skip to content

Commit f3a8b17

Browse files
scpa1055cassava
authored andcommitted
vtd: Change compression method to avoid revision change
1 parent ec3a14c commit f3a8b17

File tree

8 files changed

+77
-74
lines changed

8 files changed

+77
-74
lines changed

optional/vtd/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ smoketest-req:
1111

1212
SELECT_VENDOR := $(wildcard vendor/*)
1313
.PHONY: ${SELECT_VENDOR}
14-
vendor/osi-sensor-1.0.0-vtd2.2: vendor/vtd vendor/open-simulation-interface-3.0.1
14+
vendor/osi-sensor-1.0.0-vtd2.2: vendor/vtd-2.2.0 vendor/open-simulation-interface-3.0.1
1515
vendor/open-simulation-interface-3.0.1: vendor/protobuf-2.6.1
1616
vendor/open-simulation-interface-3.2.0: vendor/protobuf-2.6.1
1717

optional/vtd/bin/vtd-launch

+5-2
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,12 @@ def start(
254254
shutil.copytree(vtd_setup, dst, symlinks=True)
255255

256256
elif vtd_setup_cloe is not None:
257-
vtd_setup_cloe = Path(os.getenv("VTD_SETUP_DIR")) / f"{vtd_setup_cloe}.tgz"
257+
# Compressing will add a timestamp to the package and therefore
258+
# leads to different package_hashes everytime we export with conan.
259+
# To avoid that, changing from .tgz to .tar was necessary
260+
vtd_setup_cloe = Path(os.getenv("VTD_SETUP_DIR")) / f"{vtd_setup_cloe}.tar"
258261
logging.info(f"Use setup: {vtd_setup_cloe}")
259-
with tarfile.open(vtd_setup_cloe, "r:gz") as tar:
262+
with tarfile.open(vtd_setup_cloe, "r:tar") as tar:
260263
dst = opt.runtime_dir / "Data" / "Setups" / "Current"
261264
if dst.exists():
262265
os.remove(dst)

optional/vtd/conanfile.py

+30-25
Original file line numberDiff line numberDiff line change
@@ -63,48 +63,53 @@ def build_requirements(self):
6363
self.test_requires("gtest/[~1.10]")
6464

6565
def _compress_and_remove(self, dir):
66+
# reset() will remove the packages metadata
67+
def reset(tarinfo):
68+
tarinfo.uid = tarinfo.gid = 0
69+
tarinfo.uname = ""
70+
tarinfo.gname = ""
71+
tarinfo.mtime = 1
72+
return tarinfo
73+
6674
if not dir.is_dir():
6775
return
68-
with tarfile.open(f"{dir.name}.tgz", "w:gz") as tar:
69-
tar.add(dir.path, arcname=os.path.basename(dir.path))
76+
# Compressing will add a timestamp to the package and therefore
77+
# leads to different package_hashes everytime we export with conan.
78+
# To avoid that, changing from .tgz to .tar was necessary
79+
with tarfile.open(f"{dir.name}.tar", "w:") as tar:
80+
tar.add(dir.path, arcname=os.path.basename(dir.path), filter=reset)
7081
rmtree(dir.path)
7182

7283
def _compress_setups(self):
7384
cwd = os.getcwd()
74-
os.chdir(f"{self.export_sources_folder}/{self._setup_folder}")
75-
with os.scandir() as scan:
76-
for dir in scan:
77-
self._compress_and_remove(dir)
85+
setup_dir = f"{self.export_sources_folder}/{self._setup_folder}"
86+
os.chdir(setup_dir)
87+
versions = [name for name in os.listdir(setup_dir) if os.path.isdir(os.path.join(setup_dir, name))]
88+
for version in versions:
89+
os.chdir(os.path.join(setup_dir, version))
90+
with os.scandir() as scan:
91+
for dir in scan:
92+
self._compress_and_remove(dir)
7893
os.chdir(cwd)
7994

8095
def export_sources(self):
8196
self.copy("*", dst=self._setup_folder, src=self._setup_folder, symlinks=True)
8297
self._compress_setups()
8398

84-
def _configure_cmake(self):
85-
vtd_api_version = str(self.requires.get("vtd-api"))
86-
if "vtd-api/2.2.0" in vtd_api_version:
87-
self.vtd_api_version = "2.2.0"
88-
else:
89-
self.vtd_api_version = "2022.3"
90-
91-
if self._cmake:
92-
return self._cmake
93-
self._cmake = CMake(self)
94-
self._cmake.definitions["VTD_API_VERSION"] = self.vtd_api_version
95-
self._cmake.definitions["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
96-
self._cmake.definitions["BuildTests"] = self.options.test
97-
self._cmake.definitions["TargetLintingExtended"] = self.options.pedantic
98-
self._cmake.configure()
99-
return self._cmake
100-
10199
def configure(self):
102100
self.options["open-simulation-interface"].shared = False
103101
self.options["open-simulation-interface"].fPIC = True
104102

105103
def generate(self):
104+
vtd_api_version = str(self.requires.get("vtd-api"))
105+
if "vtd-api/2.2.0" in vtd_api_version:
106+
self.vtd_api_version = "2.2.0"
107+
else:
108+
self.vtd_api_version = "2022.3"
106109
tc = cmake.CMakeToolchain(self)
107110
tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
111+
tc.preprocessor_definitions["VTD_API_VERSION"] = self.vtd_api_version
112+
tc.cache_variables["VTD_API_VERSION"] = self.vtd_api_version
108113
tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version
109114
tc.cache_variables["TargetLintingExtended"] = self.options.pedantic
110115
tc.generate()
@@ -120,9 +125,9 @@ def package(self):
120125
cm.install()
121126
self.copy("vtd-launch", dst="bin", src=f"{self.source_folder}/bin")
122127
self.copy(
123-
"*.tgz",
128+
"*.tar",
124129
dst=self._setup_folder,
125-
src=f"{self.source_folder}/{self._setup_folder}",
130+
src=f"{self.source_folder}/{self._setup_folder}/{self.vtd_api_version}"
126131
)
127132

128133
def package_id(self):

optional/vtd/tests/profile_with_vtd-2.2.0.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def requirements(self):
3535
self.requires(f"cloe-plugin-speedometer/{self.version}@cloe/develop")
3636
self.requires(f"cloe-plugin-virtue/{self.version}@cloe/develop")
3737
self.requires(f"cloe-plugin-vtd/{self.version}@cloe/develop")
38-
38+
self.requires("incbin/cci.20211107", override=True)
3939
# Runtime requirements for VTD.
4040
self.requires("osi-sensor/1.0.0-vtd2.2@cloe/stable")
4141
self.requires("vtd/2.2.0@cloe-restricted/stable")

optional/vtd/tests/profile_with_vtd-2022.3.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ def requirements(self):
3434
self.requires(f"cloe-plugin-noisy-sensor/{self.version}@cloe/develop")
3535
self.requires(f"cloe-plugin-speedometer/{self.version}@cloe/develop")
3636
self.requires(f"cloe-plugin-virtue/{self.version}@cloe/develop")
37-
37+
self.requires("incbin/cci.20211107", override=True)
3838
self.requires(f"cloe-plugin-vtd/{self.version}@cloe/develop")
3939
self.requires("vtd-api/2022.3@cloe/stable", override=True)
4040
# Runtime requirements for VTD.
41-
self.requires("osi-sensor/1.0.0-vtd2.2@cloe/stable")
4241
self.requires("vtd/2022.3@cloe-restricted/stable")
4342

4443
# Overrides:

optional/vtd/vendor/vtd-2022.3/Dockerfile

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
#
77
# Build the image like this:
88
#
9-
# docker build -t cloe/vtd-conan-package:2.2.0 Dockerfile vires
9+
# docker build -t cloe/vtd-conan-package:2022.3 Dockerfile vires
1010
#
1111
# And use it in another Dockerfile (with buildkit) like this:
1212
#
13-
# RUN --mount=type=bind,target=/root/.conan/vtd/2.2.0/cloe-restricted/stable,from=cloe/vtd-conan-package:2.2.0
13+
# RUN --mount=type=bind,target=/root/.conan/vtd/2022.3/cloe-restricted/stable,from=cloe/vtd-conan-package:2022.3
1414
#
1515
# Note, you can create this image even if you don't have anything in the vires
1616
# directory. It will result in an empty image, but it will allow the other
1717
# Docker builds to continue.
1818
#
19-
FROM ubuntu:18.04 AS build
19+
FROM ubuntu:20.04 AS build
2020

2121
ENV DEBIAN_FRONTEND=noninteractive
2222

23-
RUN --mount=type=cache,id=bionic-cache,target=/var/cache/apt \
24-
--mount=type=cache,id=bionic-lib,target=/var/lib/apt \
23+
RUN --mount=type=cache,id=ubuntu-20.04-cache,target=/var/cache/apt \
24+
--mount=type=cache,id=ubuntu-20.04-lib,target=/var/lib/apt \
2525
apt-get update && \
2626
apt-get install --no-install-recommends -y \
2727
build-essential \
@@ -145,7 +145,7 @@ RUN --mount=type=cache,id=bionic-cache,target=/var/cache/apt \
145145
rm -rf /var/lib/apt/lists/*
146146

147147
RUN pip3 install --upgrade pip && \
148-
pip3 install conan
148+
pip3 install "conan<2.0.0"
149149

150150
RUN conan profile new --detect default && \
151151
conan profile update settings.compiler.libcxx=libstdc++11 default
@@ -163,7 +163,7 @@ RUN conan create conanfile.py ${PACKAGE_FQN} && \
163163
conan remove -b -s -f vtd && \
164164
find /root/.conan/data -type d -name "dl" -exec rm -rf {} +
165165

166-
FROM ubuntu:18.04
166+
FROM ubuntu:20.04
167167
COPY --from=build /root/.conan/data/vtd /vtd
168168
RUN ln -s /vtd/*/*/*/package/* /VTD
169169
COPY --from=build /vtd/entrypoint.sh ./

optional/vtd/vendor/vtd-2022.3/conanfile.py

+13-20
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# mypy: ignore-errors
2+
# pylint: skip-file
3+
14
import os
25
import os.path
36
import shutil
@@ -72,7 +75,7 @@ class VtdConan(ConanFile):
7275
options = {
7376
"with_osi": [True, False],
7477
"with_road_designer": [True, False],
75-
"with_image_generator": [True, False],
78+
"with_image_generator": [True, False],
7679
}
7780
default_options = {
7881
"with_osi": True,
@@ -95,7 +98,8 @@ def export_sources(self):
9598

9699
def configure(self):
97100
if self.settings.os == "Windows":
98-
raise ConanInvalidConfiguration("VTD binaries do not exist for Windows")
101+
raise ConanInvalidConfiguration(
102+
"VTD binaries do not exist for Windows")
99103

100104
def build(self):
101105
src = Path(self.source_folder)
@@ -106,7 +110,7 @@ def build(self):
106110
def extract_archive(archive):
107111
print(f"Extracting: {archive}")
108112
tools.untargz(src / archive, dst)
109-
113+
110114
extract_archive(self._archive_base)
111115
libdir.mkdir()
112116
if self.options.with_osi:
@@ -118,73 +122,61 @@ def extract_archive(archive):
118122
shutil.rmtree(path)
119123
Path(vtddir / "Runtime/Core/ImageGenerator").unlink()
120124
remove_broken_symlinks()
121-
125+
122126
# Patch RPATH of several critical binaries.
123127
patch_rpath(
124128
vtddir / "Runtime/Core/ModuleManager/moduleManager.2022.3.40_flexlm",
125129
["$ORIGIN/../Lib", "$ORIGIN/lib"],
126130
)
127-
128131
patch_rpath(
129132
vtddir / "Runtime/Core/ModuleManager/lib/libVTDModulePlugin.so.2022",
130133
["$ORIGIN/../../Lib"]
131134
)
132-
133135
patch_rpath(
134136
vtddir / "Runtime/Core/ModuleManager/lib/libprotobuf.so.9",
135137
["$ORIGIN/../../Lib"]
136138
)
137-
138139
patch_rpath(
139140
vtddir / "Runtime/Core/ModuleManager/lib/libopen_simulation_interface.so",
140141
["$ORIGIN/../../Lib", "$ORIGIN"],
141142
)
142-
143143
patch_rpath(
144144
vtddir / "Runtime/Core/ModuleManager.cxx98/moduleManager.2022.3.40_flexlm",
145145
["$ORIGIN/../Lib", "$ORIGIN/lib"],
146146
)
147-
148147
patch_rpath(
149148
vtddir / "Runtime/Core/ModuleManager.cxx98/lib/libopen_simulation_interface.so",
150149
["$ORIGIN/../../Lib", "$ORIGIN"],
151150
)
152-
153151
patch_rpath(
154152
vtddir / "Runtime/Core/ModuleManager.cxx98/lib/libprotobuf.so.9",
155153
["$ORIGIN/../../Lib"],
156154
)
157-
158155
patch_rpath(
159156
vtddir / "Runtime/Core/ModuleManager.cxx98/lib/libVTDModulePlugin.so",
160157
["$ORIGIN/../../Lib"],
161158
)
162-
163159
patch_rpath(
164160
vtddir / "Runtime/Core/ModuleManager.cxx11/moduleManager.2022.3.40_flexlm",
165161
["$ORIGIN/../Lib", "$ORIGIN/lib"],
166162
)
167-
168-
169163
patch_rpath(
170164
vtddir / "Runtime/Core/ModuleManager.cxx11/lib/libVTDModulePlugin.so.2022",
171165
["$ORIGIN/../../Lib"],
172166
)
173-
174167
patch_rpath(
175168
vtddir / "Runtime/Core/ModuleManager.cxx11/lib/libopen_simulation_interface.so",
176169
["$ORIGIN/../../Lib", "$ORIGIN"],
177170
)
178-
179171
patch_rpath(
180172
vtddir / "Runtime/Core/ModuleManager.cxx11/lib/libprotobuf.so.9",
181173
["$ORIGIN/../../Lib"],
182174
)
183-
184175
patch_rpath(
185-
vtddir / "Runtime/Core/ParamServer/paramServer.2022.3.40", ["$ORIGIN/../Lib"]
176+
vtddir /
177+
"Runtime/Core/ParamServer/paramServer.2022.3.40", [
178+
"$ORIGIN/../Lib"]
186179
)
187-
188180
patch_rpath(
189181
vtddir / "Runtime/Core/Traffic/ghostdriver.2022.3.40_flexlm",
190182
["$ORIGIN/../Lib"],
@@ -194,7 +186,8 @@ def extract_archive(archive):
194186
for file in find_binary_files():
195187
try:
196188
patch_rpath(
197-
file, [f"$ORIGIN/{os.path.relpath(libdir, (dst / file).parent)}"]
189+
file, [
190+
f"$ORIGIN/{os.path.relpath(libdir, (dst / file).parent)}"]
198191
)
199192
except:
200193
# Not all files can be set, but even if this happens it doesn't appear
+19-16
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
#!/bin/bash
22
set -e
3-
4-
# This entrypoint script wraps VTD like it would be running in the foreground
5-
# VTD's startscript actually terminates itself and the main simulator proceeses
6-
# are regularly a bunch of orphans.
7-
# In order to compensate for this misbehavior, this script monitor's the state
3+
# This entrypoint script wraps VTD so it is as if it were running in the foreground.
4+
#
5+
# VTD's start script terminates itself, so that the main simulator processes
6+
# are regularly a bunch of orphans (zombies).
7+
# In order to compensate for this misbehavior, this script monitors the state
88
# of the most important process, the simServer. Its termination leads to the
99
# container's termination.
10+
#
1011
# All arguments are passed unchanged to the vtdStart.sh script.
11-
cd /vtd_setups && cp -r Cloe* /VTD/Data/Setups
12-
cd /VTD/Data/Setups && \
13-
rm -f Current && \
14-
ln -s Cloe.noGUInoIG Current
15-
16-
cd /VTD && bin/vtdStart.sh $@
12+
# Make Cloe setups available to VTD, since it expects everything
13+
# in its own directory.
14+
cd /vtd_setups
15+
cp -r Cloe* /VTD/Data/Setups
16+
# Within a container, use the noGUInoIG setup, since
17+
# we are not running in a desktop environment.
18+
cd /VTD/Data/Setups
19+
ln -sf Cloe.noGUInoIG Current
20+
# Start VTD
21+
cd /VTD
22+
bin/vtdStart.sh $@
1723

18-
# workaround for vtd start script starting vtd in the background
19-
while pidof simServer > /dev/null
20-
do
21-
sleep 1
22-
done
24+
pid=$(pidof simServer)
25+
wait $pid

0 commit comments

Comments
 (0)