LU-2186 .treeinfo file in AlmaLinux public kickstart repo should contain AppStream variant
- We are modifying existing repo's .treeinfo: -- Take info about included variants from iso's .treeinfo and put it to repo's .treeinfo Change-Id: I29bf655d90994e8a1bda40ad04568dd7364f5dca
This commit is contained in:
parent
2e48c9a56f
commit
02686d7bdf
@ -250,6 +250,12 @@ def get_iso_contents(
|
||||
original_treeinfo,
|
||||
os.path.join(extra_files_dir, ".treeinfo"),
|
||||
)
|
||||
tweak_repo_treeinfo(
|
||||
compose,
|
||||
include_variants,
|
||||
original_treeinfo,
|
||||
original_treeinfo,
|
||||
)
|
||||
|
||||
# Add extra files specific for the ISO
|
||||
files.update(
|
||||
@ -261,6 +267,45 @@ def get_iso_contents(
|
||||
return gp
|
||||
|
||||
|
||||
def tweak_repo_treeinfo(compose, include_variants, source_file, dest_file):
|
||||
"""
|
||||
The method includes the variants to file .treeinfo of a variant. It takes
|
||||
the variants which are described
|
||||
by options `extra_isos -> include_variants`.
|
||||
"""
|
||||
ti = productmd.treeinfo.TreeInfo()
|
||||
ti.load(source_file)
|
||||
main_variant = next(iter(ti.variants))
|
||||
for variant_uid in include_variants:
|
||||
variant = compose.all_variants[variant_uid]
|
||||
var = productmd.treeinfo.Variant(ti)
|
||||
var.id = variant.id
|
||||
var.uid = variant.uid
|
||||
var.name = variant.name
|
||||
var.type = variant.type
|
||||
ti.variants.add(var)
|
||||
|
||||
for variant_id in ti.variants:
|
||||
var = ti.variants[variant_id]
|
||||
if variant_id == main_variant:
|
||||
var.paths.packages = 'Packages'
|
||||
var.paths.repository = '.'
|
||||
else:
|
||||
var.paths.packages = os.path.join(
|
||||
'../../..',
|
||||
var.uid,
|
||||
var.arch,
|
||||
'os/Packages',
|
||||
)
|
||||
var.paths.repository = os.path.join(
|
||||
'../../..',
|
||||
var.uid,
|
||||
var.arch,
|
||||
'os',
|
||||
)
|
||||
ti.dump(dest_file)
|
||||
|
||||
|
||||
def tweak_treeinfo(compose, include_variants, source_file, dest_file):
|
||||
ti = load_and_tweak_treeinfo(source_file)
|
||||
for variant_uid in include_variants:
|
||||
@ -276,7 +321,6 @@ def tweak_treeinfo(compose, include_variants, source_file, dest_file):
|
||||
var = ti.variants[variant_id]
|
||||
var.paths.packages = os.path.join(var.uid, "Packages")
|
||||
var.paths.repository = var.uid
|
||||
|
||||
ti.dump(dest_file)
|
||||
|
||||
|
||||
|
58
tests/fixtures/extraiso-tweaked-expected.treeinfo
vendored
Normal file
58
tests/fixtures/extraiso-tweaked-expected.treeinfo
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
[checksums]
|
||||
images/boot.iso = sha256:fc8a4be604b6425746f12fa706116eb940f93358f036b8fbbe518b516cb6870c
|
||||
|
||||
[general]
|
||||
; WARNING.0 = This section provides compatibility with pre-productmd treeinfos.
|
||||
; WARNING.1 = Read productmd documentation for details about new format.
|
||||
arch = x86_64
|
||||
family = Test
|
||||
name = Test 1.0
|
||||
packagedir = ../../../Client/x86_64/os/Packages
|
||||
platforms = x86_64,xen
|
||||
repository = ../../../Client/x86_64/os
|
||||
timestamp = 1531881582
|
||||
variant = Client
|
||||
variants = Client,Server
|
||||
version = 1.0
|
||||
|
||||
[header]
|
||||
type = productmd.treeinfo
|
||||
version = 1.2
|
||||
|
||||
[images-x86_64]
|
||||
boot.iso = images/boot.iso
|
||||
|
||||
[images-xen]
|
||||
initrd = images/pxeboot/initrd.img
|
||||
kernel = images/pxeboot/vmlinuz
|
||||
|
||||
[release]
|
||||
name = Test
|
||||
short = T
|
||||
version = 1.0
|
||||
|
||||
[stage2]
|
||||
mainimage = images/install.img
|
||||
|
||||
[tree]
|
||||
arch = x86_64
|
||||
build_timestamp = 1531881582
|
||||
platforms = x86_64,xen
|
||||
variants = Client,Server
|
||||
|
||||
[variant-Client]
|
||||
id = Client
|
||||
name = Client
|
||||
packages = ../../../Client/x86_64/os/Packages
|
||||
repository = ../../../Client/x86_64/os
|
||||
type = variant
|
||||
uid = Client
|
||||
|
||||
[variant-Server]
|
||||
id = Server
|
||||
name = Server
|
||||
packages = Packages
|
||||
repository = .
|
||||
type = variant
|
||||
uid = Server
|
||||
|
@ -7,7 +7,7 @@ import shutil
|
||||
import tempfile
|
||||
from collections import defaultdict
|
||||
|
||||
import mock
|
||||
from unittest import mock
|
||||
import six
|
||||
from kobo.rpmlib import parse_nvr
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
import mock
|
||||
from typing import AnyStr, List
|
||||
from unittest import mock
|
||||
import six
|
||||
|
||||
import os
|
||||
@ -616,6 +615,7 @@ class GetExtraFilesTest(helpers.PungiTestCase):
|
||||
)
|
||||
|
||||
|
||||
@mock.patch("pungi.phases.extra_isos.tweak_repo_treeinfo")
|
||||
@mock.patch("pungi.phases.extra_isos.tweak_treeinfo")
|
||||
@mock.patch("pungi.wrappers.iso.write_graft_points")
|
||||
@mock.patch("pungi.wrappers.iso.get_graft_points")
|
||||
@ -625,7 +625,7 @@ class GetIsoContentsTest(helpers.PungiTestCase):
|
||||
self.compose = helpers.DummyCompose(self.topdir, {})
|
||||
self.variant = self.compose.variants["Server"]
|
||||
|
||||
def test_non_bootable_binary(self, ggp, wgp, tt):
|
||||
def test_non_bootable_binary(self, ggp, wgp, tt, trt):
|
||||
gp = {
|
||||
"compose/Client/x86_64/os/Packages": {"f/foo.rpm": "/mnt/f/foo.rpm"},
|
||||
"compose/Client/x86_64/os/repodata": {
|
||||
@ -695,7 +695,15 @@ class GetIsoContentsTest(helpers.PungiTestCase):
|
||||
],
|
||||
)
|
||||
|
||||
def test_inherit_extra_files(self, ggp, wgp, tt):
|
||||
# Check correct call to tweak_repo_treeinfo
|
||||
self._tweak_repo_treeinfo_call_list_checker(
|
||||
trt_mock=trt,
|
||||
main_variant='Server',
|
||||
addon_variants=['Client'],
|
||||
sub_path='x86_64/os',
|
||||
)
|
||||
|
||||
def test_inherit_extra_files(self, ggp, wgp, tt, trt):
|
||||
gp = {
|
||||
"compose/Client/x86_64/os/Packages": {"f/foo.rpm": "/mnt/f/foo.rpm"},
|
||||
"compose/Client/x86_64/os/repodata": {
|
||||
@ -769,7 +777,15 @@ class GetIsoContentsTest(helpers.PungiTestCase):
|
||||
],
|
||||
)
|
||||
|
||||
def test_source(self, ggp, wgp, tt):
|
||||
# Check correct call to tweak_repo_treeinfo
|
||||
self._tweak_repo_treeinfo_call_list_checker(
|
||||
trt_mock=trt,
|
||||
main_variant='Server',
|
||||
addon_variants=['Client'],
|
||||
sub_path='x86_64/os',
|
||||
)
|
||||
|
||||
def test_source(self, ggp, wgp, tt, trt):
|
||||
gp = {
|
||||
"compose/Client/source/tree/Packages": {"f/foo.rpm": "/mnt/f/foo.rpm"},
|
||||
"compose/Client/source/tree/repodata": {
|
||||
@ -838,7 +854,15 @@ class GetIsoContentsTest(helpers.PungiTestCase):
|
||||
],
|
||||
)
|
||||
|
||||
def test_bootable(self, ggp, wgp, tt):
|
||||
# Check correct call to tweak_repo_treeinfo
|
||||
self._tweak_repo_treeinfo_call_list_checker(
|
||||
trt_mock=trt,
|
||||
main_variant='Server',
|
||||
addon_variants=['Client'],
|
||||
sub_path='source/tree',
|
||||
)
|
||||
|
||||
def test_bootable(self, ggp, wgp, tt, trt):
|
||||
self.compose.conf["buildinstall_method"] = "lorax"
|
||||
|
||||
bi_dir = os.path.join(self.topdir, "work/x86_64/buildinstall/Server")
|
||||
@ -940,6 +964,42 @@ class GetIsoContentsTest(helpers.PungiTestCase):
|
||||
],
|
||||
)
|
||||
|
||||
# Check correct call to tweak_repo_treeinfo
|
||||
self._tweak_repo_treeinfo_call_list_checker(
|
||||
trt_mock=trt,
|
||||
main_variant='Server',
|
||||
addon_variants=['Client'],
|
||||
sub_path='x86_64/os',
|
||||
)
|
||||
|
||||
def _tweak_repo_treeinfo_call_list_checker(
|
||||
self,
|
||||
trt_mock: mock.Mock,
|
||||
main_variant: AnyStr,
|
||||
addon_variants: List[AnyStr],
|
||||
sub_path: AnyStr) -> None:
|
||||
"""
|
||||
Check correct call to tweak_repo_treeinfo
|
||||
"""
|
||||
path_to_treeinfo = os.path.join(
|
||||
self.topdir,
|
||||
'compose',
|
||||
main_variant,
|
||||
sub_path,
|
||||
'.treeinfo',
|
||||
)
|
||||
self.assertEqual(
|
||||
trt_mock.call_args_list,
|
||||
[
|
||||
mock.call(
|
||||
self.compose,
|
||||
addon_variants,
|
||||
path_to_treeinfo,
|
||||
path_to_treeinfo,
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
class GetFilenameTest(helpers.PungiTestCase):
|
||||
def test_use_original_name(self):
|
||||
@ -1017,6 +1077,15 @@ class TweakTreeinfoTest(helpers.PungiTestCase):
|
||||
|
||||
self.assertFilesEqual(output, expected)
|
||||
|
||||
def test_repo_tweak(self):
|
||||
compose = helpers.DummyCompose(self.topdir, {})
|
||||
input = os.path.join(helpers.FIXTURE_DIR, "extraiso.treeinfo")
|
||||
output = os.path.join(self.topdir, "actual-treeinfo")
|
||||
expected = os.path.join(helpers.FIXTURE_DIR, "extraiso-tweaked-expected.treeinfo")
|
||||
extra_isos.tweak_repo_treeinfo(compose, ["Client"], input, output)
|
||||
|
||||
self.assertFilesEqual(output, expected)
|
||||
|
||||
|
||||
class PrepareMetadataTest(helpers.PungiTestCase):
|
||||
@mock.patch("pungi.metadata.create_media_repo")
|
||||
|
Loading…
Reference in New Issue
Block a user