Add unversioned linking and checksums

Add symlinked versions of all images that are unversioned. This is
primarily for users who would like a URL path to the latest ISO for a
particular release. This is also for cases like osinfo where there
should be a generic path per major release.
This commit is contained in:
Louis Abel 2022-08-05 01:24:49 -07:00
parent 18b985cdcc
commit bffff511f3
Signed by untrusted user: label
GPG Key ID: B37E62D143879B36
4 changed files with 75 additions and 44 deletions

View File

@ -17,6 +17,8 @@ parser.add_argument('--logger', type=str)
parser.add_argument('--extra-iso', type=str, help="Granular choice in which iso is built") parser.add_argument('--extra-iso', type=str, help="Granular choice in which iso is built")
parser.add_argument('--extra-iso-mode', type=str, default='local') parser.add_argument('--extra-iso-mode', type=str, default='local')
parser.add_argument('--hashed', action='store_true') parser.add_argument('--hashed', action='store_true')
parser.add_argument('--updated-image', action='store_true')
parser.add_argument('--image-increment',type=str, default='0')
results = parser.parse_args() results = parser.parse_args()
rlvars = rldict[results.release] rlvars = rldict[results.release]
major = rlvars['major'] major = rlvars['major']
@ -32,7 +34,9 @@ a = IsoBuild(
extra_iso_mode=results.extra_iso_mode, extra_iso_mode=results.extra_iso_mode,
compose_dir_is_here=results.local_compose, compose_dir_is_here=results.local_compose,
hashed=results.hashed, hashed=results.hashed,
logger=results.logger logger=results.logger,
updated_image=results.updated_image,
image_increment=results.image_increment
) )
def run(): def run():

View File

@ -23,3 +23,9 @@ fi
{{ make_manifest }} {{ make_manifest }}
{% if extra_iso_mode == "podman" %}
# symlink to unversioned image name
ln -sf {{ isoname }} {{ generic_isoname }}
ln -sf {{ isoname }}.manifest {{ generic_isoname }}.manifest
{% endif %}

View File

@ -96,7 +96,8 @@ class RepoSync:
# Relevant major version items # Relevant major version items
self.shortname = config['shortname'] self.shortname = config['shortname']
self.revision = rlvars['revision'] + "-" + rlvars['rclvl'] self.revision_level = rlvars['revision'] + "-" + rlvars['rclvl']
self.revision = rlvars['revision']
self.fullversion = rlvars['revision'] self.fullversion = rlvars['revision']
self.arches = rlvars['allowed_arches'] self.arches = rlvars['allowed_arches']
self.project_id = rlvars['project_id'] self.project_id = rlvars['project_id']
@ -178,7 +179,7 @@ class RepoSync:
self.log.addHandler(handler) self.log.addHandler(handler)
self.log.info('reposync init') self.log.info('reposync init')
self.log.info(self.revision) self.log.info(self.revision_level)
# The repo name should be valid # The repo name should be valid
if self.repo is not None: if self.repo is not None:

View File

@ -105,7 +105,8 @@ class IsoBuild:
self.arches = rlvars['allowed_arches'] self.arches = rlvars['allowed_arches']
self.release = rlvars['revision'] self.release = rlvars['revision']
self.minor_version = rlvars['minor'] self.minor_version = rlvars['minor']
self.revision = rlvars['revision'] + "-" + rlvars['rclvl'] self.revision_level = rlvars['revision'] + "-" + rlvars['rclvl']
self.revision = rlvars['revision']
self.rclvl = rlvars['rclvl'] self.rclvl = rlvars['rclvl']
self.repos = rlvars['iso_map']['lorax']['repos'] self.repos = rlvars['iso_map']['lorax']['repos']
self.repo_base_url = config['repo_base_url'] self.repo_base_url = config['repo_base_url']
@ -119,12 +120,6 @@ class IsoBuild:
if 'container' in rlvars and len(rlvars['container']) > 0: if 'container' in rlvars and len(rlvars['container']) > 0:
self.container = rlvars['container'] self.container = rlvars['container']
self.staging_dir = os.path.join(
config['staging_root'],
config['category_stub'],
self.revision
)
# all bucket related info # all bucket related info
self.s3_region = config['aws_region'] self.s3_region = config['aws_region']
self.s3_bucket = config['bucket'] self.s3_bucket = config['bucket']
@ -202,7 +197,7 @@ class IsoBuild:
self.compose_dir_is_here, self.compose_dir_is_here,
self.hashed self.hashed
) )
self.log.info(self.revision) self.log.info(self.revision_level)
def run(self): def run(self):
work_root = os.path.join( work_root = os.path.join(
@ -516,21 +511,9 @@ class IsoBuild:
) )
def _copy_boot_to_work(self, force_unpack, arch): def _copy_boot_to_work(self, force_unpack, arch):
src_to_image = os.path.join( src_to_image = os.path.join(self.lorax_work_dir, arch, 'lorax')
self.lorax_work_dir, iso_to_go = os.path.join(self.iso_work_dir, arch)
arch, path_to_src_image = os.path.join(src_to_image, 'images/boot.iso')
'lorax'
)
iso_to_go = os.path.join(
self.iso_work_dir,
arch
)
path_to_src_image = '{}/{}'.format(
src_to_image,
'/images/boot.iso'
)
rclevel = '' rclevel = ''
if self.release_candidate: if self.release_candidate:
@ -545,15 +528,13 @@ class IsoBuild:
'boot' 'boot'
) )
isobootpath = '{}/{}'.format( isobootpath = os.path.join(iso_to_go, discname)
iso_to_go, manifest = '{}.manifest'.format(isobootpath)
discname link_name = '{}-{}-boot.iso'.format(self.shortname, arch)
) link_manifest = link_name + '.manifest'
isobootpath = os.path.join(iso_to_go, discname)
manifest = '{}.{}'.format( linkbootpath = os.path.join(iso_to_go, link_name)
isobootpath, manifestlink = os.path.join(iso_to_go, link_manifest)
'manifest'
)
if not force_unpack: if not force_unpack:
file_check = isobootpath file_check = isobootpath
@ -563,9 +544,18 @@ class IsoBuild:
self.log.info('Copying %s boot iso to work directory...' % arch) self.log.info('Copying %s boot iso to work directory...' % arch)
os.makedirs(iso_to_go, exist_ok=True) os.makedirs(iso_to_go, exist_ok=True)
shutil.copy2(path_to_src_image, isobootpath) try:
shutil.copy2(path_to_src_image, isobootpath)
if os.path.exists(linkbootpath):
os.remove(linkbootpath)
os.symlink(discname, linkbootpath)
except Exception as e:
self.log.error(Color.FAIL + 'We could not copy the image or create a symlink.')
raise SystemExit(e)
if os.path.exists(path_to_src_image + '.manifest'): if os.path.exists(path_to_src_image + '.manifest'):
shutil.copy2(path_to_src_image + '.manifest', manifest) shutil.copy2(path_to_src_image + '.manifest', manifest)
os.symlink(manifest.split('/')[-1], manifestlink)
self.log.info('Creating checksum for %s boot iso...' % arch) self.log.info('Creating checksum for %s boot iso...' % arch)
checksum = Shared.get_checksum(isobootpath, self.checksum, self.log) checksum = Shared.get_checksum(isobootpath, self.checksum, self.log)
@ -576,6 +566,14 @@ class IsoBuild:
c.write(checksum) c.write(checksum)
c.close() c.close()
#linksum = Shared.get_checksum(linkbootpath, self.checksum, self.log)
#if not linksum:
# self.log.error(Color.FAIL + linkbootpath + ' not found! Did we actually make the symlink?')
# return
#with open(linkbootpath + '.CHECKSUM', "w+") as l:
# l.write(linksum)
# l.close()
def _copy_nondisc_to_repo(self, force_unpack, arch, repo): def _copy_nondisc_to_repo(self, force_unpack, arch, repo):
""" """
Syncs data from a non-disc set of images to the appropriate repo. Repo Syncs data from a non-disc set of images to the appropriate repo. Repo
@ -818,7 +816,7 @@ class IsoBuild:
datestamp = '' datestamp = ''
if self.updated_image: if self.updated_image:
datestamp = '-' + self.updated_image_date.copy() datestamp = '-' + self.updated_image_date
volid = '{}-{}-{}{}-{}-{}'.format( volid = '{}-{}-{}{}-{}-{}'.format(
self.shortname, self.shortname,
@ -829,15 +827,17 @@ class IsoBuild:
volname volname
) )
isoname = '{}-{}.{}{}-{}-{}.iso'.format( isoname = '{}-{}{}{}-{}-{}.iso'.format(
self.shortname, self.shortname,
self.major_version, self.revision,
self.minor_version,
rclevel, rclevel,
datestamp,
arch, arch,
image image
) )
generic_isoname = '{}-{}-{}.iso'.format(self.shortname, arch, image)
lorax_pkg_cmd = '/usr/bin/dnf install {} -y {}'.format( lorax_pkg_cmd = '/usr/bin/dnf install {} -y {}'.format(
' '.join(required_pkgs), ' '.join(required_pkgs),
log_path_command log_path_command
@ -914,6 +914,7 @@ class IsoBuild:
make_manifest=make_manifest, make_manifest=make_manifest,
lorax_pkg_cmd=lorax_pkg_cmd, lorax_pkg_cmd=lorax_pkg_cmd,
isoname=isoname, isoname=isoname,
generic_isoname=generic_isoname,
) )
mock_iso_entry = open(mock_iso_path, "w+") mock_iso_entry = open(mock_iso_path, "w+")
@ -963,6 +964,11 @@ class IsoBuild:
isos_dir = os.path.join(work_root, "isos") isos_dir = os.path.join(work_root, "isos")
bad_exit_list = [] bad_exit_list = []
checksum_list = [] checksum_list = []
datestamp = ''
if self.updated_image:
datestamp = '-' + self.updated_image_date
for i in images: for i in images:
entry_name_list = [] entry_name_list = []
image_name = i image_name = i
@ -976,17 +982,25 @@ class IsoBuild:
if self.release_candidate: if self.release_candidate:
rclevel = '-' + self.rclvl rclevel = '-' + self.rclvl
isoname = '{}/{}-{}.{}{}-{}-{}.iso'.format( isoname = '{}/{}-{}{}{}-{}-{}.iso'.format(
a, a,
self.shortname, self.shortname,
self.major_version, self.revision,
self.minor_version,
rclevel, rclevel,
datestamp,
a,
i
)
genericname = '{}/{}-{}-{}.iso'.format(
a,
self.shortname,
a, a,
i i
) )
checksum_list.append(isoname) checksum_list.append(isoname)
checksum_list.append(genericname)
for pod in entry_name_list: for pod in entry_name_list:
podman_cmd_entry = '{} run -d -it -v "{}:{}" -v "{}:{}" --name {} --entrypoint {}/{} {}'.format( podman_cmd_entry = '{} run -d -it -v "{}:{}" -v "{}:{}" --name {} --entrypoint {}/{} {}'.format(
@ -1477,6 +1491,8 @@ class LiveBuild:
image=None, image=None,
justcopyit: bool = False, justcopyit: bool = False,
force_build: bool = False, force_build: bool = False,
updated_image: bool = False,
image_increment: str = '0',
logger=None logger=None
): ):
@ -1490,7 +1506,6 @@ class LiveBuild:
self.major_version = major self.major_version = major
self.compose_dir_is_here = compose_dir_is_here self.compose_dir_is_here = compose_dir_is_here
self.date_stamp = config['date_stamp'] self.date_stamp = config['date_stamp']
self.date = time.strftime("%Y%m%d", time.localtime())
self.compose_root = config['compose_root'] self.compose_root = config['compose_root']
self.compose_base = config['compose_root'] + "/" + major self.compose_base = config['compose_root'] + "/" + major
self.current_arch = config['arch'] self.current_arch = config['arch']
@ -1524,6 +1539,11 @@ class LiveBuild:
if 'container' in rlvars and len(rlvars['container']) > 0: if 'container' in rlvars and len(rlvars['container']) > 0:
self.container = rlvars['container'] self.container = rlvars['container']
self.updated_image = updated_image
self.updated_image_increment = "." + image_increment
self.date = (time.strftime("%Y%m%d", time.localtime())
+ self.updated_image_increment)
# Templates # Templates
file_loader = FileSystemLoader(f"{_rootdir}/templates") file_loader = FileSystemLoader(f"{_rootdir}/templates")
self.tmplenv = Environment(loader=file_loader) self.tmplenv = Environment(loader=file_loader)