Example #1
0
def task__download_packages() -> types.TaskDict:
    """Download packages locally."""
    def clean() -> None:
        """Delete cache and repositories on the ISO."""
        coreutils.rm_rf(constants.PKG_ROOT / 'var')
        for repository in REPOSITORIES:
            # Repository with an explicit list of packages are created by a
            # dedicated task that will also handle their cleaning, so we skip
            # them here.
            if repository.packages:
                continue
            coreutils.rm_rf(repository.rootdir)

    pkg_list = constants.ROOT / 'packages/packages.list'
    packages = _load_package_list(pkg_list)

    mounts = [
        docker_command.bind_mount(source=constants.PKG_ROOT,
                                  target=Path('/install_root')),
        docker_command.bind_mount(source=constants.REPO_ROOT,
                                  target=Path('/repositories')),
    ]
    dl_packages_callable = docker_command.DockerRun(
        command=['/entrypoint.sh', 'download_packages', *packages],
        builder=BUILDER,
        mounts=mounts,
        environment={'RELEASEVER': 7})
    return {
        'title':
        lambda task: utils.title_with_target1('GET PKGS', task),
        'actions': [dl_packages_callable],
        'targets': [constants.PKG_ROOT / 'var'],
        'file_dep': [pkg_list],
        'task_dep':
        ['_package_mkdir_root', '_package_mkdir_iso_root', '_build_container'],
        'clean': [clean],
        'uptodate': [True],
        # Prevent Docker from polluting our output.
        'verbosity':
        0,
    }
Example #2
0
    def _buildrepo_action(self) -> types.Action:
        """Return the command to run `buildrepo` inside a container."""
        mounts = [
            docker_command.bind_ro_mount(source=self.rootdir,
                                         target=Path('/repository')),
            docker_command.bind_mount(source=self.repodata,
                                      target=Path('/repository/repodata'))
        ]
        buildrepo_callable = docker_command.DockerRun(
            command=['/entrypoint.sh', 'buildrepo'],
            builder=self.builder,
            mounts=mounts,
            read_only=True)

        return buildrepo_callable
Example #3
0
    def _get_buildrpm_mounts(srpm_path: Path,
                             rpm_dir: Path) -> List[types.Mount]:
        """Return the list of container mounts required by `buildrpm`."""
        mounts = [
            # SRPM directory.
            docker_command.bind_ro_mount(source=srpm_path,
                                         target=Path('/rpmbuild/SRPMS',
                                                     srpm_path.name)),
            # RPM directory.
            docker_command.bind_mount(
                source=rpm_dir,
                target=Path('/rpmbuild/RPMS'),
            ),
            # rpmlint configuration file
            docker_command.DockerRun.RPMLINTRC_MOUNT
        ]

        return mounts
Example #4
0
 def generate_meta(self) -> types.TaskDict:
     """Generate the .meta file for the package."""
     spec_guest_file = Path('/rpmbuild/SPECS', self.spec.name)
     meta_guest_file = Path('/rpmbuild/META', self.meta.name)
     mounts = [
         docker_command.DockerRun.ENTRYPOINT_MOUNT,
         docker_command.bind_ro_mount(source=self.spec,
                                      target=spec_guest_file),
         docker_command.bind_mount(source=self.meta.parent,
                                   target=meta_guest_file.parent)
     ]
     command = ['/entrypoint.sh', 'buildmeta']
     rpmspec_config = {
         'hostname': 'build',
         'read_only': True,
         'remove': True
     }
     buildmeta_callable = docker_command.DockerRun(
         command=command,
         builder=self.builder,
         environment={
             'SPEC': self.spec.name,
             'META': self.meta.name
         },
         run_config=rpmspec_config,
         mounts=mounts)
     task = self.basic_task
     task.update({
         'name':
         'pkg_rpmspec',
         'actions': [buildmeta_callable],
         'doc':
         'Generate {}.meta'.format(self.name),
         'title':
         lambda task: utils.title_with_target1('RPMSPEC', task),
         'targets': [self.meta],
     })
     task['file_dep'].extend([self.spec])
     task['task_dep'].append('{}:{}'.format(self.basename,
                                            self.MKDIR_TASK_NAME))
     return task
Example #5
0
    def _get_buildsrpm_mounts(self, srpm_dir: Path) -> List[types.Mount]:
        """Return the list of container mounts required by `buildsrpm`."""
        mounts = [
            # .spec file
            docker_command.bind_ro_mount(source=self.spec,
                                         target=Path('/rpmbuild/SPECS',
                                                     self.spec.name)),
            # SRPM directory.
            docker_command.bind_mount(
                source=srpm_dir,
                target=Path('/rpmbuild/SRPMS'),
            ),
            # rpmlint configuration file
            docker_command.DockerRun.RPMLINTRC_MOUNT
        ]

        # Source files.
        for source in self.sources:
            mounts.append(
                docker_command.bind_ro_mount(source=source,
                                             target=Path(
                                                 '/rpmbuild/SOURCES',
                                                 source.name)))
        return mounts