Move image checksum collecting to separate phase
The checksums are still generated in the ImageBuild and CreatISO phases, but collecting of them into single file is moved from pungi-koji script into a separate phase. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
5ff5ffc259
commit
359eb444e5
@ -212,6 +212,7 @@ def run_compose(compose):
|
|||||||
createiso_phase = pungi.phases.CreateisoPhase(compose)
|
createiso_phase = pungi.phases.CreateisoPhase(compose)
|
||||||
liveimages_phase = pungi.phases.LiveImagesPhase(compose)
|
liveimages_phase = pungi.phases.LiveImagesPhase(compose)
|
||||||
image_build_phase = pungi.phases.ImageBuildPhase(compose)
|
image_build_phase = pungi.phases.ImageBuildPhase(compose)
|
||||||
|
image_checksum_phase = pungi.phases.ImageChecksumPhase(compose)
|
||||||
test_phase = pungi.phases.TestPhase(compose)
|
test_phase = pungi.phases.TestPhase(compose)
|
||||||
|
|
||||||
# check if all config options are set
|
# check if all config options are set
|
||||||
@ -219,7 +220,7 @@ def run_compose(compose):
|
|||||||
for phase in (init_phase, pkgset_phase, createrepo_phase,
|
for phase in (init_phase, pkgset_phase, createrepo_phase,
|
||||||
buildinstall_phase, productimg_phase, gather_phase,
|
buildinstall_phase, productimg_phase, gather_phase,
|
||||||
extrafiles_phase, createiso_phase, liveimages_phase,
|
extrafiles_phase, createiso_phase, liveimages_phase,
|
||||||
image_build_phase, test_phase):
|
image_build_phase, image_checksum_phase, test_phase):
|
||||||
if phase.skip():
|
if phase.skip():
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
@ -289,19 +290,8 @@ def run_compose(compose):
|
|||||||
liveimages_phase.stop()
|
liveimages_phase.stop()
|
||||||
image_build_phase.stop()
|
image_build_phase.stop()
|
||||||
|
|
||||||
# merge checksum files
|
image_checksum_phase.start()
|
||||||
for variant in compose.get_variants(types=["variant", "layered-product"]):
|
image_checksum_phase.stop()
|
||||||
for arch in variant.arches + ["src"]:
|
|
||||||
iso_dir = compose.paths.compose.iso_dir(arch, variant, create_dir=False)
|
|
||||||
if not iso_dir or not os.path.exists(iso_dir):
|
|
||||||
continue
|
|
||||||
for checksum_type in ("md5", "sha1", "sha256"):
|
|
||||||
checksum_upper = "%sSUM" % checksum_type.upper()
|
|
||||||
checksums = sorted([i for i in os.listdir(iso_dir) if i.endswith(".%s" % checksum_upper)])
|
|
||||||
fo = open(os.path.join(iso_dir, checksum_upper), "w")
|
|
||||||
for i in checksums:
|
|
||||||
data = open(os.path.join(iso_dir, i), "r").read()
|
|
||||||
fo.write(data)
|
|
||||||
|
|
||||||
pungi.metadata.write_compose_info(compose)
|
pungi.metadata.write_compose_info(compose)
|
||||||
compose.im.dump(compose.paths.compose.metadata("images.json"))
|
compose.im.dump(compose.paths.compose.metadata("images.json"))
|
||||||
|
@ -27,3 +27,4 @@ from createiso import CreateisoPhase # noqa
|
|||||||
from live_images import LiveImagesPhase # noqa
|
from live_images import LiveImagesPhase # noqa
|
||||||
from image_build import ImageBuildPhase # noqa
|
from image_build import ImageBuildPhase # noqa
|
||||||
from test import TestPhase # noqa
|
from test import TestPhase # noqa
|
||||||
|
from image_checksum import ImageChecksumPhase # noqa
|
||||||
|
30
pungi/phases/image_checksum.py
Normal file
30
pungi/phases/image_checksum.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from .base import PhaseBase
|
||||||
|
|
||||||
|
|
||||||
|
class ImageChecksumPhase(PhaseBase):
|
||||||
|
"""Go through images generated in ImageBuild phase and generate their
|
||||||
|
checksums.
|
||||||
|
"""
|
||||||
|
|
||||||
|
name = 'image_checksum'
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
compose = self.compose
|
||||||
|
# merge checksum files
|
||||||
|
for variant in compose.get_variants(types=["variant", "layered-product"]):
|
||||||
|
for arch in variant.arches + ["src"]:
|
||||||
|
iso_dir = compose.paths.compose.iso_dir(arch, variant, create_dir=False)
|
||||||
|
if not iso_dir or not os.path.exists(iso_dir):
|
||||||
|
continue
|
||||||
|
for checksum_type in ("md5", "sha1", "sha256"):
|
||||||
|
checksum_upper = "%sSUM" % checksum_type.upper()
|
||||||
|
checksums = sorted([i for i in os.listdir(iso_dir) if i.endswith(".%s" % checksum_upper)])
|
||||||
|
fo = open(os.path.join(iso_dir, checksum_upper), "w")
|
||||||
|
for i in checksums:
|
||||||
|
data = open(os.path.join(iso_dir, i), "r").read()
|
||||||
|
fo.write(data)
|
||||||
|
fo.close()
|
Loading…
Reference in New Issue
Block a user