Update from upstream #11

Closed
soksanichenko wants to merge 158 commits from a8_updated into a8
2 changed files with 58 additions and 23 deletions
Showing only changes of commit 8a2d0162d9 - Show all commits

View File

@ -14,33 +14,34 @@
# along with this program; if not, see <https://gnu.org/licenses/>.
import json
import glob
import json
import os
import shutil
import threading
from six.moves import cPickle as pickle
from kobo.rpmlib import parse_nvra
from kobo.shortcuts import run
from productmd.rpms import Rpms
from six.moves import cPickle as pickle
try:
from queue import Queue
except ImportError:
from Queue import Queue
from pungi.wrappers.scm import get_file_from_scm
from .link import link_files
from ...wrappers.createrepo import CreaterepoWrapper
import pungi.wrappers.kojiwrapper
from pungi.compose import get_ordered_variant_uids
from pungi.arch import get_compatible_arches, split_name_arch
from pungi.phases.base import PhaseBase
from pungi.util import get_arch_data, get_arch_variant_data, get_variant_data, makedirs
from pungi.compose import get_ordered_variant_uids
from pungi.module_util import Modulemd, collect_module_defaults
from pungi.phases.base import PhaseBase
from pungi.phases.createrepo import add_modular_metadata
from pungi.util import (get_arch_data, get_arch_variant_data, get_variant_data,
makedirs)
from pungi.wrappers.scm import get_file_from_scm
from ...wrappers.createrepo import CreaterepoWrapper
from .link import link_files
def get_gather_source(name):
@ -81,10 +82,11 @@ class GatherPhase(PhaseBase):
if variant.modules:
errors.append("Modular compose requires libmodulemd package.")
# check whether variants from configuration value
# 'variant_as_lookaside' are correct
variant_as_lookaside = self.compose.conf.get("variant_as_lookaside", [])
all_variants = self.compose.all_variants
# check whether variants from configuration value
# 'variant_as_lookaside' are correct
for (requiring, required) in variant_as_lookaside:
if requiring in all_variants and required not in all_variants:
errors.append(
@ -92,6 +94,15 @@ class GatherPhase(PhaseBase):
"required by %r" % (required, requiring)
)
# check whether variants from configuration value
# 'variant_as_lookaside' have same architectures
for (requiring, required) in variant_as_lookaside:
if requiring in all_variants and required in all_variants and \
sorted(all_variants[requiring].arches) \
!= sorted(all_variants[required].arches):
errors.append("variant_as_lookaside: variant \'%s\' doesn't have same "
"architectures as \'%s\'" % (requiring, required))
if errors:
raise ValueError("\n".join(errors))
@ -641,16 +652,21 @@ def _make_lookaside_repo(compose, variant, arch, pkg_map, package_sets=None):
path_prefix = prefixes[compose.conf["pkgset_source"]]()
package_list = set()
for pkg_arch in pkg_map.keys():
for pkg_type, packages in pkg_map[pkg_arch][variant.uid].items():
# We want all packages for current arch, and SRPMs for any
# arch. Ultimately there will only be one source repository, so
# we need a union of all SRPMs.
if pkg_type == "srpm" or pkg_arch == arch:
for pkg in packages:
pkg = pkg["path"]
if path_prefix and pkg.startswith(path_prefix):
pkg = pkg[len(path_prefix) :]
package_list.add(pkg)
try:
for pkg_type, packages in pkg_map[pkg_arch][variant.uid].items():
# We want all packages for current arch, and SRPMs for any
# arch. Ultimately there will only be one source repository, so
# we need a union of all SRPMs.
if pkg_type == "srpm" or pkg_arch == arch:
for pkg in packages:
pkg = pkg["path"]
if path_prefix and pkg.startswith(path_prefix):
pkg = pkg[len(path_prefix) :]
package_list.add(pkg)
except KeyError:
raise RuntimeError("Variant \'%s\' does not have architecture "
"\'%s\'!" % (variant, pkg_arch))
pkglist = compose.paths.work.lookaside_package_list(arch=arch, variant=variant)
with open(pkglist, "w") as f:
for pkg in sorted(package_list):

View File

@ -2,9 +2,10 @@
import copy
import json
import mock
import os
import mock
try:
import unittest2 as unittest
except ImportError:
@ -13,8 +14,8 @@ except ImportError:
import six
from pungi.phases import gather
from pungi.phases.pkgset.common import MaterializedPackageSet
from pungi.phases.gather import _mk_pkg_map
from pungi.phases.pkgset.common import MaterializedPackageSet
from tests import helpers
from tests.helpers import MockPackageSet, MockPkg
@ -1581,6 +1582,24 @@ class TestGatherPhase(helpers.PungiTestCase):
phase = gather.GatherPhase(compose, pkgset_phase)
phase.validate()
def test_validates_variants_architecture_mismatch(self):
pkgset_phase = mock.Mock()
compose = helpers.DummyCompose(
self.topdir, {"variant_as_lookaside": [("Everything", "Client")]}
)
phase = gather.GatherPhase(compose, pkgset_phase)
with self.assertRaises(ValueError) as ctx:
phase.validate()
self.assertIn("'Everything' doesn't have", str(ctx.exception))
def test_validates_variants_architecture_match(self):
pkgset_phase = mock.Mock()
compose = helpers.DummyCompose(
self.topdir, {"variant_as_lookaside": [("Everything", "Everything")]}
)
phase = gather.GatherPhase(compose, pkgset_phase)
phase.validate()
class TestGetPackagesToGather(helpers.PungiTestCase):
def setUp(self):