def build_package(self) -> types.TaskDict: """Build DEB packages from source files.""" mounts = [ utils.bind_ro_mount(source=self.sources, target=Path('/debbuild/pkg-src')), utils.bind_ro_mount(source=self.debuild_sources, target=Path('/debbuild/pkg-meta')), utils.bind_mount(source=constants.PKG_DEB_ROOT, target=Path('/debbuild/result')), ] builddeb_callable = docker_command.DockerRun( command=['/entrypoint.sh', 'builddeb'], builder=self.builder, run_config=docker_command.DEB_BASE_CONFIG, mounts=mounts, environment={ 'VERSION': '{}-{}'.format(self.version, self.build_id) }, ) task = self.basic_task task.update({ 'name': 'build_deb_pkg', 'actions': [builddeb_callable], 'doc': 'Build DEB package from sources for {}'.format(self.name), 'title': utils.title_with_target1('BUILD DEB'), 'targets': [self.deb], }) task['file_dep'].extend(coreutils.ls_files_rec(self.sources)) task['file_dep'].extend(coreutils.ls_files_rec(self.debuild_sources)) task['task_dep'].append('_package_mkdir_deb_iso_root') task['task_dep'].append('_build_deb_container') return task
def expand_dep(self) -> List[Path]: """Expand the Dockerfile path dependency to regular files.""" source = self.match.group('src') path = self.dockerfile_path.parent / Path(source) # Simple file if path.is_file(): return [path] # Directory or `.` if path.is_dir(): return list(coreutils.ls_files_rec(path)) # Globs - `*` or specific e.g. `*.py`, `*.repo` return [ sub_path for sub_path in path.parent.glob(path.name) if sub_path.is_file() ]
def task__iso_build() -> types.TaskDict: """Create the ISO from the files in ISO_ROOT.""" def mkisofs() -> None: """Create an ISO file (delete on error).""" cmd = [ config.ExtCommand.MKISOFS.value, '-output', ISO_FILE, '-quiet', '-rock', '-joliet', '-joliet-long', '-full-iso9660-filenames', '-volid', '{} {}'.format(config.PROJECT_NAME, versions.VERSION), '--iso-level', '3', '-gid', '0', '-uid', '0', '-input-charset', 'utf-8', '-output-charset', 'utf-8', constants.ISO_ROOT ] try: subprocess.run(cmd, check=True) except: utils.unlink_if_exist(ISO_FILE) raise doc = 'Create the ISO from the files in {}.'.format( utils.build_relpath(constants.ISO_ROOT) ) # Every file used for the ISO is a dependency. depends = list(coreutils.ls_files_rec(constants.ISO_ROOT)) depends.append(versions.VERSION_FILE) return { 'title': utils.title_with_target1('MKISOFS'), 'doc': doc, 'actions': [mkisofs], 'targets': [ISO_FILE], 'file_dep': depends, 'task_dep': ['check_for:mkisofs', '_build_root', '_iso_mkdir_root'], 'clean': True, }
def task__iso_build() -> types.TaskDict: """Create the ISO from the files in ISO_ROOT.""" mkisofs = [ config.MKISOFS, '-output', ISO_FILE, '-quiet', '-rock', '-joliet', '-joliet-long', '-full-iso9660-filenames', '-volid', '{} {}'.format(config.PROJECT_NAME, constants.VERSION), '--iso-level', '3', '-gid', '0', '-uid', '0', '-input-charset', 'utf-8', '-output-charset', 'utf-8', constants.ISO_ROOT ] doc = 'Create the ISO from the files in {}.'.format( utils.build_relpath(constants.ISO_ROOT)) # Every file used for the ISO is a dependency. depends = list(coreutils.ls_files_rec(constants.ISO_ROOT)) depends.append(constants.VERSION_FILE) return { 'title': lambda task: utils.title_with_target1('MKISOFS', task), 'doc': doc, 'actions': [mkisofs], 'targets': [ISO_FILE], 'file_dep': depends, 'task_dep': ['_build_root', '_iso_mkdir_root'], 'clean': True, }
'KEEPALIVED_IMAGE': constants.CENTOS_BASE_IMAGE, 'KEEPALIVED_VERSION': constants.KEEPALIVED_VERSION, 'BUILD_DATE': datetime.datetime.now( datetime.timezone.utc).astimezone().isoformat(), 'VCS_REF': constants.GIT_REF or '<unknown>', 'VERSION': KEEPALIVED_IMAGE_TAG, 'METALK8S_VERSION': constants.VERSION, }, task_dep=['_image_mkdir_root'], file_dep=[constants.ROOT / 'images' / 'keepalived' / 'entrypoint.sh'], ), targets.LocalImage( name='metalk8s-ui', version='0.2', dockerfile=constants.ROOT / 'ui' / 'Dockerfile', destination=constants.ISO_IMAGE_ROOT, save_on_disk=True, build_args={'NGINX_IMAGE_VERSION': NGINX_IMAGE_VERSION}, task_dep=['_image_mkdir_root'], file_dep=list(coreutils.ls_files_rec(constants.ROOT / 'ui')), ), ) __all__ = utils.export_only_tasks(__name__)
# }}} # Container images to build {{{ TO_BUILD: Tuple[targets.LocalImage, ...] = ( _local_image( name='salt-master', build_args={'SALT_VERSION': versions.SALT_VERSION}, ), _local_image( name='metalk8s-ui', dockerfile=constants.ROOT / 'ui' / 'Dockerfile', build_args={ 'NGINX_IMAGE_VERSION': versions.NGINX_IMAGE_VERSION, 'NODE_IMAGE_VERSION': versions.NODEJS_IMAGE_VERSION, }, file_dep=( list(coreutils.ls_files_rec(constants.ROOT / 'ui' / 'public')) + list(coreutils.ls_files_rec(constants.ROOT / 'ui' / 'src')) + [ constants.ROOT / 'ui' / 'package.json', constants.ROOT / 'ui' / 'package-lock.json', constants.ROOT / 'ui' / 'conf' / 'nginx.conf' ])), _local_image( name='metalk8s-utils', build_args={ 'BASE_IMAGE': versions.CENTOS_BASE_IMAGE, 'BASE_IMAGE_SHA256': versions.CENTOS_BASE_IMAGE_SHA256, 'BUILD_DATE': datetime.datetime.now( datetime.timezone.utc).astimezone().isoformat(),