dresult = job(component)
dlines.extend(dresult)
+ if os.path.isdir(self._workdir / "tmp_bin"):
+ # For every binary file that was copied to the tmp_bin directory by the jobs above, search for the existing file in the container and replace it.
+ dlines.append("ADD tmp_bin /tmpbin")
+ dlines.append("RUN for i in tmpbin/*; do find /usr/bin /usr/sbin -name $(basename $i) -exec mv -f $i '{}' \;; echo $(basename $i); done && rm -rf tmpbin")
+
+ if os.path.isdir(self._workdir / "tmp_lib"):
+ # For every library file that was copied to the tmp_lib directory by the jobs above, search for the existing file in the container and replace it.
+ dlines.append("ADD tmp_lib /tmplib")
+ dlines.append("RUN for i in tmplib/*; do find /usr/lib64 -name $(basename $i) -exec mv -f $i '{}' \;; echo $(basename $i); done && rm -rf tmplib")
+
+ if os.path.isdir(self._workdir / "tmp_bin"):
+ # by default locally built binaries assume /usr/local
+ dlines.append("RUN rm -rf /usr/local/lib64 && ln -sf /usr/lib64 /usr/local && ln -sf /usr/share/ceph /usr/local/share")
+ # locally built binaries assume libceph-common.so.2 is in /usr/lib64 - create link to library that was just copied
+ dlines.append("RUN ln -sf /usr/lib64/ceph/libceph-common.so.2 /usr/lib64/libceph-common.so.2")
+
with open(self._workdir / "Dockerfile", "w") as fout:
for line in dlines:
print(line, file=fout)
pass
os.link(src_path, dst_path)
- def _bins_and_libs(self, prefix, bin_patterns, lib_patterns):
+ def _bins_and_libs(self, prefix, bin_patterns, lib_patterns, exclude_prefixes=[]):
out = []
bin_src = self._ctx.build_dir / "bin"
bin_dst.mkdir(parents=True, exist_ok=True)
for path in bin_src.iterdir():
if any(path.match(m) for m in bin_patterns):
+ if any(path.match(f"{m}*") for m in exclude_prefixes):
+ continue
self._copy_binary(path, bin_dst / path.name)
- out.append(f"ADD {prefix}_bin /usr/bin")
lib_src = self._ctx.build_dir / "lib"
lib_dst = self._workdir / f"{prefix}_lib"
lib_dst.mkdir(parents=True, exist_ok=True)
for path in lib_src.iterdir():
if any(path.match(m) for m in lib_patterns):
+ if any(path.match(f"{m}*") for m in exclude_prefixes):
+ continue
self._copy_binary(path, lib_dst / path.name)
- out.append(f"ADD {prefix}_lib /usr/lib64")
return out
- def _conditional_libs(self, src_dir, name, destination, lib_patterns):
- lib_src = self._ctx.build_dir / src_dir
- lib_dst = self._workdir / name
- lib_dst.mkdir(parents=True, exist_ok=True)
- try:
- for path in lib_src.iterdir():
- if any(path.match(m) for m in lib_patterns):
- self._copy_binary(path, lib_dst / path.name)
- except FileNotFoundError as err:
- log.warning("skipping lib %s: %s", name, err)
- return f"ADD {name} {destination}"
-
def _py_site_packages(self):
"""Return the correct python site packages dir for the image."""
if self._cached_py_site_packages is not None:
# [Quoth the original script]:
# binaries are annoying because the ceph version is embedded all over
# the place, so we have to include everything but the kitchen sink.
- out = []
-
- out.extend(
- self._bins_and_libs(
- prefix="core",
- bin_patterns=["ceph-mgr", "ceph-mon", "ceph-osd", "rados"],
- lib_patterns=["libceph-common.so*", "librados.so*"],
- )
- )
-
- out.append(
- self._conditional_libs(
- src_dir="lib",
- name="eclib",
- destination="/usr/lib64/ceph/erasure-code",
- lib_patterns=["libec_*.so*"],
- )
- )
- out.append(
- self._conditional_libs(
- src_dir="lib",
- name="clslib",
- destination="/usr/lib64/rados-classes",
- lib_patterns=["libcls_*.so*"],
- )
- )
+ if not self._ctx.components_selected:
+ log.warning("Copying ALL locally built binaries over those that already exist in the image.")
+ bins=['*']
+ else:
+ bins=["ceph-mgr", "ceph-mon", "ceph-osd", "rados"]
- # [Quoth the original script]:
- # by default locally built binaries assume /usr/local
- out.append(
- "RUN rm -rf /usr/local/lib64 && ln -s /usr/lib64 /usr/local && ln -s /usr/share/ceph /usr/local/share"
+ return self._bins_and_libs(
+ prefix="tmp",
+ bin_patterns=bins,
+ lib_patterns=["*.so","*.so.*"],
+ exclude_prefixes=["ceph_test","test_","unittest_"],
)
-
return out
def _rgw_job(self, component):
return self._bins_and_libs(
- prefix="rgw",
+ prefix="tmp",
bin_patterns=["radosgw", "radosgw-admin"],
lib_patterns=["librados.so*", "libceph-common.so*"],
)
def _cephfs_job(self, component):
return self._bins_and_libs(
- prefix="cephfs",
+ prefix="tmp",
bin_patterns=["ceph-mds"],
lib_patterns=["libcephfs.so*"],
)
def _rbd_job(self, component):
return self._bins_and_libs(
- prefix="rbd",
+ prefix="tmp",
bin_patterns=["rbd", "rbd-mirror"],
lib_patterns=["librbd.so*"],
)