diff options
| author | Zuul <zuul@review.opendev.org> | 2024-11-15 12:09:58 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2024-11-15 12:09:58 +0000 |
| commit | dca8462bc491a93c6a6ae71e86d59a2dcb804ff5 (patch) | |
| tree | bc41637caaa762e5dce1452c16d3b5f52f3cbf96 /kolla | |
| parent | 68fa7d302095b5362f176b7e690e3cbaa516fae0 (diff) | |
| parent | 11f65c6c1d3bfd6a12f8e71d778d46d635010449 (diff) | |
| download | kolla-dca8462bc491a93c6a6ae71e86d59a2dcb804ff5.tar.gz kolla-dca8462bc491a93c6a6ae71e86d59a2dcb804ff5.zip | |
Merge "Add mechanism for patching files in containers"
Diffstat (limited to 'kolla')
| -rw-r--r-- | kolla/common/config.py | 2 | ||||
| -rw-r--r-- | kolla/image/build.py | 1 | ||||
| -rw-r--r-- | kolla/image/kolla_worker.py | 33 |
3 files changed, 35 insertions, 1 deletions
diff --git a/kolla/common/config.py b/kolla/common/config.py index 4a6fd4903..3075052ad 100644 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -178,6 +178,8 @@ _CLI_OPTS = [ help='The network mode for Docker build. Example: host'), cfg.BoolOpt('cache', default=True, help='Use the container engine cache when building'), + cfg.StrOpt('patches-path', default=None, + help='The path where patch files to be applied are located'), cfg.StrOpt('platform', default=None, help=('The platform to use for a cross-compile build. Should ' 'be set in conjunction with "--base-arch" argument. ' diff --git a/kolla/image/build.py b/kolla/image/build.py index 88189e2f7..9b6571d36 100644 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -140,6 +140,7 @@ def run_build(): kolla.setup_working_dir() kolla.find_dockerfiles() kolla.create_dockerfiles() + kolla.create_patch_files() kolla.build_image_list() kolla.find_parents() kolla.filter_images() diff --git a/kolla/image/kolla_worker.py b/kolla/image/kolla_worker.py index 1e3f4d861..798c8eaa7 100644 --- a/kolla/image/kolla_worker.py +++ b/kolla/image/kolla_worker.py @@ -141,6 +141,7 @@ class KollaWorker(object): self.image_statuses_unbuildable = dict() self.image_statuses_allowed_to_fail = dict() self.maintainer = conf.maintainer + self.patches_path = conf.patches_path try: self.engine_client = engine.getEngineClient(self.conf) @@ -322,7 +323,8 @@ class KollaWorker(object): 'distro_package_manager': self.distro_package_manager, 'rpm_setup': self.rpm_setup, 'build_date': build_date, - 'clean_package_cache': self.clean_package_cache} + 'clean_package_cache': self.clean_package_cache, + 'patches_path': self.patches_path} env = jinja2.Environment( # nosec: not used to render HTML loader=jinja2.FileSystemLoader(self.working_dir)) env.filters.update(self._get_filters()) @@ -349,6 +351,35 @@ class KollaWorker(object): f.write(content) LOG.debug("Wrote it to %s", content_path) + def create_patch_files(self): + for path in self.docker_build_paths: + image_name = os.path.basename(path) + src_patch_folder = os.path.join(self.patches_path, image_name) if \ + self.patches_path and os.path.isdir(self.patches_path) \ + else None + dest_patch_folder = os.path.join(path, "patches") + os.makedirs(dest_patch_folder, exist_ok=True) + + if not src_patch_folder or not os.path.isdir(src_patch_folder): + continue + + src_series_path = os.path.join(src_patch_folder, "series") + dest_series_path = os.path.join(dest_patch_folder, "series") + + if os.path.isfile(src_series_path): + shutil.copyfile(src_series_path, dest_series_path) + with open(src_series_path) as f: + patch_files = [line.strip() for line in f + if not line.startswith("#")] + else: + patch_files = [] + + for patch_file in patch_files: + src_patch_file = os.path.join(src_patch_folder, patch_file) + dest_patch_file = os.path.join(dest_patch_folder, patch_file) + if os.path.isfile(src_patch_file): + shutil.copyfile(src_patch_file, dest_patch_file) + def _merge_overrides(self, overrides): tpl_name = os.path.basename(overrides[0]) with open(overrides[0], 'r') as f: |
