Update from upstream #11
@ -14,33 +14,34 @@
|
|||||||
# along with this program; if not, see <https://gnu.org/licenses/>.
|
# along with this program; if not, see <https://gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
import json
|
|
||||||
import glob
|
import glob
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
from six.moves import cPickle as pickle
|
|
||||||
|
|
||||||
from kobo.rpmlib import parse_nvra
|
from kobo.rpmlib import parse_nvra
|
||||||
from kobo.shortcuts import run
|
from kobo.shortcuts import run
|
||||||
from productmd.rpms import Rpms
|
from productmd.rpms import Rpms
|
||||||
|
from six.moves import cPickle as pickle
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from Queue import Queue
|
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
|
import pungi.wrappers.kojiwrapper
|
||||||
|
|
||||||
from pungi.compose import get_ordered_variant_uids
|
|
||||||
from pungi.arch import get_compatible_arches, split_name_arch
|
from pungi.arch import get_compatible_arches, split_name_arch
|
||||||
from pungi.phases.base import PhaseBase
|
from pungi.compose import get_ordered_variant_uids
|
||||||
from pungi.util import get_arch_data, get_arch_variant_data, get_variant_data, makedirs
|
|
||||||
from pungi.module_util import Modulemd, collect_module_defaults
|
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.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):
|
def get_gather_source(name):
|
||||||
@ -81,10 +82,11 @@ class GatherPhase(PhaseBase):
|
|||||||
if variant.modules:
|
if variant.modules:
|
||||||
errors.append("Modular compose requires libmodulemd package.")
|
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", [])
|
variant_as_lookaside = self.compose.conf.get("variant_as_lookaside", [])
|
||||||
all_variants = self.compose.all_variants
|
all_variants = self.compose.all_variants
|
||||||
|
|
||||||
|
# check whether variants from configuration value
|
||||||
|
# 'variant_as_lookaside' are correct
|
||||||
for (requiring, required) in variant_as_lookaside:
|
for (requiring, required) in variant_as_lookaside:
|
||||||
if requiring in all_variants and required not in all_variants:
|
if requiring in all_variants and required not in all_variants:
|
||||||
errors.append(
|
errors.append(
|
||||||
@ -92,6 +94,15 @@ class GatherPhase(PhaseBase):
|
|||||||
"required by %r" % (required, requiring)
|
"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:
|
if errors:
|
||||||
raise ValueError("\n".join(errors))
|
raise ValueError("\n".join(errors))
|
||||||
|
|
||||||
@ -641,6 +652,7 @@ def _make_lookaside_repo(compose, variant, arch, pkg_map, package_sets=None):
|
|||||||
path_prefix = prefixes[compose.conf["pkgset_source"]]()
|
path_prefix = prefixes[compose.conf["pkgset_source"]]()
|
||||||
package_list = set()
|
package_list = set()
|
||||||
for pkg_arch in pkg_map.keys():
|
for pkg_arch in pkg_map.keys():
|
||||||
|
try:
|
||||||
for pkg_type, packages in pkg_map[pkg_arch][variant.uid].items():
|
for pkg_type, packages in pkg_map[pkg_arch][variant.uid].items():
|
||||||
# We want all packages for current arch, and SRPMs for any
|
# We want all packages for current arch, and SRPMs for any
|
||||||
# arch. Ultimately there will only be one source repository, so
|
# arch. Ultimately there will only be one source repository, so
|
||||||
@ -651,6 +663,10 @@ def _make_lookaside_repo(compose, variant, arch, pkg_map, package_sets=None):
|
|||||||
if path_prefix and pkg.startswith(path_prefix):
|
if path_prefix and pkg.startswith(path_prefix):
|
||||||
pkg = pkg[len(path_prefix) :]
|
pkg = pkg[len(path_prefix) :]
|
||||||
package_list.add(pkg)
|
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)
|
pkglist = compose.paths.work.lookaside_package_list(arch=arch, variant=variant)
|
||||||
with open(pkglist, "w") as f:
|
with open(pkglist, "w") as f:
|
||||||
for pkg in sorted(package_list):
|
for pkg in sorted(package_list):
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import mock
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import unittest2 as unittest
|
import unittest2 as unittest
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -13,8 +14,8 @@ except ImportError:
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from pungi.phases import gather
|
from pungi.phases import gather
|
||||||
from pungi.phases.pkgset.common import MaterializedPackageSet
|
|
||||||
from pungi.phases.gather import _mk_pkg_map
|
from pungi.phases.gather import _mk_pkg_map
|
||||||
|
from pungi.phases.pkgset.common import MaterializedPackageSet
|
||||||
from tests import helpers
|
from tests import helpers
|
||||||
from tests.helpers import MockPackageSet, MockPkg
|
from tests.helpers import MockPackageSet, MockPkg
|
||||||
|
|
||||||
@ -1581,6 +1582,24 @@ class TestGatherPhase(helpers.PungiTestCase):
|
|||||||
phase = gather.GatherPhase(compose, pkgset_phase)
|
phase = gather.GatherPhase(compose, pkgset_phase)
|
||||||
phase.validate()
|
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):
|
class TestGetPackagesToGather(helpers.PungiTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user