Skip to content

Commit

Permalink
packaging: refactor build list generation
Browse files Browse the repository at this point in the history
  • Loading branch information
jbertran committed Sep 17, 2019
1 parent cff6b58 commit 5db249c
Showing 1 changed file with 31 additions and 24 deletions.
55 changes: 31 additions & 24 deletions buildchain/buildchain/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,32 @@ def _deb_package(name: str, sources: Path) -> targets.DEBPackage:
),
}

_RPM_TO_BUILD_PKG_NAMES : List[str] = []
_DEB_TO_BUILD_PKG_NAMES : List[str] = []
DEB_TO_BUILD : Dict[str, Tuple[targets.DEBPackage, ...]] = {
'scality': (
# SOS report custom plugins.
_deb_package(
name='metalk8s-sosreport',
sources=config.ROOT/'packages/common/metalk8s-sosreport',
),
_deb_package(
name='calico-cni-plugin',
sources=SCALITY_RPM_REPOSITORY.get_rpm_path(CALICO_RPM)
),
)
}

def _list_packages_to_build(
pkg_cats: Dict[str, Tuple[targets.Package, ...]]
) -> List[str]:
return [
pkg.name for pkg_list in pkg_cats.values()
for pkg in pkg_list
]


_RPM_TO_BUILD_PKG_NAMES : List[str] = _list_packages_to_build(RPM_TO_BUILD)
_DEB_TO_BUILD_PKG_NAMES : List[str] = _list_packages_to_build(DEB_TO_BUILD)

for pkgs in RPM_TO_BUILD.values():
for pkg in pkgs:
_RPM_TO_BUILD_PKG_NAMES.append(pkg.name)

# All packages not referenced in `RPM_TO_BUILD` but listed in
# `versions.RPM_PACKAGES` are supposed to be downloaded.
Expand All @@ -323,6 +343,12 @@ def _deb_package(name: str, sources: Path) -> targets.DEBPackage:
if package.name not in _RPM_TO_BUILD_PKG_NAMES
)

DEB_TO_DOWNLOAD : FrozenSet[str] = frozenset(
"{p.name}".format(p=package)
for package in versions.DEB_PACKAGES
if package.name not in DEB_TO_BUILD
)


def _list_packages_to_download(
package_versions: Tuple[versions.Package, ...],
Expand Down Expand Up @@ -395,24 +421,5 @@ def _list_packages_to_download(
),
)

DEB_TO_BUILD : Dict[str, Tuple[targets.DEBPackage, ...]] = {
'scality': (
# SOS report custom plugins.
_deb_package(
name='metalk8s-sosreport',
sources=config.ROOT/'packages/common/metalk8s-sosreport',
),
_deb_package(
name='calico-cni-plugin',
sources=SCALITY_RPM_REPOSITORY.get_rpm_path(CALICO_RPM)
),
)
}

DEB_TO_DOWNLOAD : FrozenSet[str] = frozenset(
"{p.name}".format(p=package)
for package in versions.DEB_PACKAGES
if package.name not in DEB_TO_BUILD
)

__all__ = utils.export_only_tasks(__name__)

0 comments on commit 5db249c

Please sign in to comment.