start moving formatting to f strings

This commit is contained in:
Louis Abel 2023-03-14 01:40:13 -07:00
parent 34c8ee08ab
commit ddbe8db346
Signed by: label
GPG Key ID: B37E62D143879B36
1 changed files with 43 additions and 164 deletions

View File

@ -138,10 +138,7 @@ class IsoBuild:
self.compose_latest_dir = os.path.join( self.compose_latest_dir = os.path.join(
config['compose_root'], config['compose_root'],
major, major,
"latest-{}-{}".format( f"latest-{self.shortname}-{self.profile}"
self.shortname,
self.profile
)
) )
self.compose_latest_sync = os.path.join( self.compose_latest_sync = os.path.join(
@ -371,11 +368,7 @@ class IsoBuild:
source_path = latest_artifacts[arch] source_path = latest_artifacts[arch]
full_drop = '{}/lorax-{}-{}.tar.gz'.format( full_drop = f'{lorax_arch_dir}/lorax-{self.release}-{arch}.tar.gz'
lorax_arch_dir,
self.release,
arch
)
if not os.path.exists(lorax_arch_dir): if not os.path.exists(lorax_arch_dir):
os.makedirs(lorax_arch_dir, exist_ok=True) os.makedirs(lorax_arch_dir, exist_ok=True)
@ -403,10 +396,7 @@ class IsoBuild:
self.log.info(Color.INFO + 'Beginning unpack phase...') self.log.info(Color.INFO + 'Beginning unpack phase...')
for arch in arches_to_unpack: for arch in arches_to_unpack:
tarname = 'lorax-{}-{}.tar.gz'.format( tarname = f'lorax-{self.release}-{arch}.tar.gz'
self.release,
arch
)
tarball = os.path.join( tarball = os.path.join(
self.lorax_work_dir, self.lorax_work_dir,
@ -523,22 +513,13 @@ class IsoBuild:
if self.release_candidate: if self.release_candidate:
rclevel = '-' + self.rclvl rclevel = '-' + self.rclvl
discname = '{}-{}.{}{}-{}-{}.iso'.format( discname = f'{self.shortname}-{self.major_version}.{self.minor_version}{rclevel}-{arch}-boot.iso'
self.shortname,
self.major_version,
self.minor_version,
rclevel,
arch,
'boot'
)
isobootpath = os.path.join(iso_to_go, discname) isobootpath = os.path.join(iso_to_go, discname)
manifest = '{}.manifest'.format(isobootpath) manifest = f'{isoboothpath}.manifest'
link_name = '{}-{}-boot.iso'.format(self.shortname, arch) link_name = f'{self.shortname}-{arch}-boot.iso'
link_manifest = link_name + '.manifest' link_manifest = link_name + '.manifest'
latest_link_name = '{}-{}-latest-{}-boot.iso'.format(self.shortname, latest_link_name = f'{self.shortname}-{self.major_version}-latest-{arch}-boot.iso'
self.major_version,
arch)
latest_link_manifest = latest_link_name + '.manifest' latest_link_manifest = latest_link_name + '.manifest'
isobootpath = os.path.join(iso_to_go, discname) isobootpath = os.path.join(iso_to_go, discname)
linkbootpath = os.path.join(iso_to_go, link_name) linkbootpath = os.path.join(iso_to_go, link_name)
@ -813,11 +794,11 @@ class IsoBuild:
xorriso_template = self.tmplenv.get_template('xorriso.tmpl.txt') xorriso_template = self.tmplenv.get_template('xorriso.tmpl.txt')
iso_readme_template = self.tmplenv.get_template('ISOREADME.tmpl') iso_readme_template = self.tmplenv.get_template('ISOREADME.tmpl')
mock_iso_path = '/var/tmp/lorax-{}.cfg'.format(self.major_version) mock_iso_path = f'/var/tmp/lorax-{self.major_version}.cfg'
mock_sh_path = '{}/extraisobuild-{}-{}.sh'.format(entries_dir, arch, image) mock_sh_path = f'{entries_dir}/extraisobuild-{arch}-{image}.sh'
iso_template_path = '{}/buildExtraImage-{}-{}.sh'.format(entries_dir, arch, image) iso_template_path = f'{entries_dir}/buildExtraImage-{arch}-{image}.sh'
xorriso_template_path = '{}/xorriso-{}-{}.txt'.format(entries_dir, arch, image) xorriso_template_path = f'{entries_dir}/xorriso-{arch}-{image}.txt'
iso_readme_path = '{}/{}/README'.format(self.iso_work_dir, arch) iso_readme_path = f'{self.iso_work_dir}/{arch}/README'
#print(iso_readme_path) #print(iso_readme_path)
log_root = os.path.join( log_root = os.path.join(
@ -829,7 +810,7 @@ class IsoBuild:
if not os.path.exists(log_root): if not os.path.exists(log_root):
os.makedirs(log_root, exist_ok=True) os.makedirs(log_root, exist_ok=True)
log_path_command = '| tee -a {}/{}-{}.log'.format(log_root, arch, image) log_path_command = f'| tee -a {log_root}/{arch}-{image}.log'
# This is kind of a hack. Installing xorrisofs sets the alternatives to # This is kind of a hack. Installing xorrisofs sets the alternatives to
# it, so backwards compatibility is sort of guaranteed. But we want to # it, so backwards compatibility is sort of guaranteed. But we want to
@ -850,31 +831,10 @@ class IsoBuild:
if self.updated_image: if self.updated_image:
datestamp = '-' + self.updated_image_date datestamp = '-' + self.updated_image_date
volid = '{}-{}-{}{}-{}-{}'.format( volid = f'{self.shortname}-{self.major_version}-{self.minor_version}{rclevel}-{arch}-{volname}'
self.shortname, isoname = f'{self.shortname}-{self.revision}{rclevel}{datestamp}-{arch}-{image}.iso'
self.major_version, generic_isoname = f'{self.shortname}-{arch}-{image}.iso'
self.minor_version, latest_isoname = f'{self.shortname}-{self.major_version}-latest-{arch}-{image}.iso'
rclevel,
arch,
volname
)
isoname = '{}-{}{}{}-{}-{}.iso'.format(
self.shortname,
self.revision,
rclevel,
datestamp,
arch,
image
)
generic_isoname = '{}-{}-{}.iso'.format(self.shortname, arch, image)
latest_isoname = '{}-{}-latest-{}-{}.iso'.format(
self.shortname,
self.major_version,
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),
@ -986,7 +946,7 @@ class IsoBuild:
have mock available. have mock available.
""" """
entries_dir = os.path.join(work_root, "entries") entries_dir = os.path.join(work_root, "entries")
extra_iso_cmd = '/bin/bash {}/extraisobuild-{}-{}.sh'.format(entries_dir, arch, image) extra_iso_cmd = f'/bin/bash {entries_dir}/extraisobuild-{arch}-{image}.sh'
self.log.info('Starting mock build...') self.log.info('Starting mock build...')
p = subprocess.call(shlex.split(extra_iso_cmd)) p = subprocess.call(shlex.split(extra_iso_cmd))
if p != 0: if p != 0:
@ -1022,7 +982,7 @@ class IsoBuild:
arch_sync = arches.copy() arch_sync = arches.copy()
for a in arch_sync: for a in arch_sync:
entry_name = 'buildExtraImage-{}-{}.sh'.format(a, i) entry_name = f'buildExtraImage-{a}-{i}.sh'
entry_name_list.append(entry_name) entry_name_list.append(entry_name)
rclevel = '' rclevel = ''
@ -1080,10 +1040,7 @@ class IsoBuild:
join_all_pods = ' '.join(entry_name_list) join_all_pods = ' '.join(entry_name_list)
time.sleep(3) time.sleep(3)
self.log.info(Color.INFO + 'Building ' + i + ' ...') self.log.info(Color.INFO + 'Building ' + i + ' ...')
pod_watcher = '{} wait {}'.format( pod_watcher = f'{cmd} wait {join_all_pods}'
cmd,
join_all_pods
)
watch_man = subprocess.call( watch_man = subprocess.call(
shlex.split(pod_watcher), shlex.split(pod_watcher),
@ -1095,10 +1052,7 @@ class IsoBuild:
# code. # code.
pattern = "Exited (0)" pattern = "Exited (0)"
for pod in entry_name_list: for pod in entry_name_list:
checkcmd = '{} ps -f status=exited -f name={}'.format( checkcmd = f'{cmd} ps -f status=exited -f name={pod}'
cmd,
pod
)
podcheck = subprocess.Popen( podcheck = subprocess.Popen(
checkcmd, checkcmd,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
@ -1111,10 +1065,7 @@ class IsoBuild:
self.log.error(Color.FAIL + pod) self.log.error(Color.FAIL + pod)
bad_exit_list.append(pod) bad_exit_list.append(pod)
rmcmd = '{} rm {}'.format( rmcmd = f'{cmd} rm {join_all_pods}'
cmd,
join_all_pods
)
rmpod = subprocess.Popen( rmpod = subprocess.Popen(
rmcmd, rmcmd,
@ -1202,20 +1153,12 @@ class IsoBuild:
for k, v in self._get_grafts([rd_for_var]).items(): for k, v in self._get_grafts([rd_for_var]).items():
files[os.path.join(repo, "repodata", k)] = v files[os.path.join(repo, "repodata", k)] = v
grafts = '{}/{}-{}-grafts'.format( grafts = f'{lorax_base_dir}/{iso}-{arch}-grafts'
lorax_base_dir,
iso,
arch
)
xorrs = '{}/xorriso-{}-{}.txt'.format( xorrs = f'{lorax_base_dir}/xorriso-{iso}-{arch}.txt'
lorax_base_dir,
iso,
arch
)
# Generate exclusion list/dict # Generate exclusion list/dict
boot_manifest = '{}/lorax/images/boot.iso.manifest'.format(lorax_base_dir) boot_manifest = f'{lorax_base_dir}/lorax/images/boot.iso.manifest'
try: try:
with open(boot_manifest) as i: with open(boot_manifest) as i:
@ -1501,15 +1444,9 @@ class IsoBuild:
drop_name = source_path.split('/')[-3] + fsuffix drop_name = source_path.split('/')[-3] + fsuffix
checksum_name = drop_name + '.CHECKSUM' checksum_name = drop_name + '.CHECKSUM'
full_drop = '{}/{}'.format( full_drop = f'{image_arch_dir}/{drop_name}'
image_arch_dir,
drop_name
)
checksum_drop = '{}/{}.CHECKSUM'.format( checksum_drop = f'{image_arch_dir}/{drop_name}.CHECKSUM'
image_arch_dir,
drop_name
)
if not os.path.exists(image_arch_dir): if not os.path.exists(image_arch_dir):
os.makedirs(image_arch_dir, exist_ok=True) os.makedirs(image_arch_dir, exist_ok=True)
@ -1695,10 +1632,7 @@ class LiveBuild:
self.compose_latest_dir = os.path.join( self.compose_latest_dir = os.path.join(
config['compose_root'], config['compose_root'],
major, major,
"latest-{}-{}".format( f"latest-{self.shortname}-{self.profile}"
self.shortname,
self.profile
)
) )
self.compose_latest_sync = os.path.join( self.compose_latest_sync = os.path.join(
@ -1821,17 +1755,9 @@ class LiveBuild:
if self.peridot: if self.peridot:
kloc = 'peridot' kloc = 'peridot'
mock_iso_path = '/var/tmp/live-{}.cfg'.format(self.major_version) mock_iso_path = f'/var/tmp/live-{self.major_version}.cfg'
mock_sh_path = '{}/liveisobuild-{}-{}.sh'.format( mock_sh_path = f'{entries_dir}/liveisobuild-{self.current_arch}-{image}.sh'
entries_dir, iso_template_path = f'{entries_dir}/buildLiveImage-{self.current_arch}-{image}.sh'
self.current_arch,
image
)
iso_template_path = '{}/buildLiveImage-{}-{}.sh'.format(
entries_dir,
self.current_arch,
image
)
log_root = os.path.join( log_root = os.path.join(
work_root, work_root,
@ -1844,27 +1770,12 @@ class LiveBuild:
if not os.path.exists(log_root): if not os.path.exists(log_root):
os.makedirs(log_root, exist_ok=True) os.makedirs(log_root, exist_ok=True)
log_path_command = '| tee -a {}/{}-{}.log'.format( log_path_command = f'| tee -a {log_root}/{self.current_arch}-{image}.log'
log_root,
self.current_arch,
image
)
required_pkgs = self.livemap['required_pkgs'] required_pkgs = self.livemap['required_pkgs']
volid = '{}-{}-{}-{}'.format( volid = f'{self.shortname}-{self.major_version}-{self.minor_version}-{image}'
self.shortname,
self.major_version,
self.minor_version,
image
)
isoname = '{}-{}-{}-{}-{}.iso'.format( isoname = f'{self.shortname}-{self.release}-{image}-{self.current_arch}-{self.date}.iso'
self.shortname,
self.release,
image,
self.current_arch,
self.date
)
live_pkg_cmd = '/usr/bin/dnf install {} -y {}'.format( live_pkg_cmd = '/usr/bin/dnf install {} -y {}'.format(
' '.join(required_pkgs), ' '.join(required_pkgs),
@ -1961,17 +1872,10 @@ class LiveBuild:
self.log.warn(Color.WARN + 'This mode does not work properly. It will fail.') self.log.warn(Color.WARN + 'This mode does not work properly. It will fail.')
for i in images: for i in images:
image_name = i image_name = i
entry_name = 'buildLiveImage-{}-{}.sh'.format(arch, i) entry_name = f'buildLiveImage-{arch}-{i}.sh'
entry_name_list.append(entry_name) entry_name_list.append(entry_name)
isoname = '{}/{}-{}-{}-{}-{}.iso'.format( isoname = f'{arch}/{self.shortname}-{i}-{self.major_version}-{arch}-{self.date}.iso'
arch,
self.shortname,
i,
self.major_version,
arch,
self.date
)
checksum_list.append(isoname) checksum_list.append(isoname)
@ -1999,10 +1903,7 @@ class LiveBuild:
time.sleep(3) time.sleep(3)
self.log.info(Color.INFO + 'Building requested live images ...') self.log.info(Color.INFO + 'Building requested live images ...')
pod_watcher = '{} wait {}'.format( pod_watcher = f'{cmd} wait {join_all_pods}'
cmd,
join_all_pods
)
watch_man = subprocess.call( watch_man = subprocess.call(
shlex.split(pod_watcher), shlex.split(pod_watcher),
@ -2014,10 +1915,7 @@ class LiveBuild:
# code. # code.
pattern = "Exited (0)" pattern = "Exited (0)"
for pod in entry_name_list: for pod in entry_name_list:
checkcmd = '{} ps -f status=exited -f name={}'.format( checkcmd = f'{cmd} ps -f status=exited -f name={pod}'
cmd,
pod
)
podcheck = subprocess.Popen( podcheck = subprocess.Popen(
checkcmd, checkcmd,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
@ -2030,10 +1928,7 @@ class LiveBuild:
self.log.error(Color.FAIL + pod) self.log.error(Color.FAIL + pod)
bad_exit_list.append(pod) bad_exit_list.append(pod)
rmcmd = '{} rm {}'.format( rmcmd = f'{cmd} rm {join_all_pods}'
cmd,
join_all_pods
)
rmpod = subprocess.Popen( rmpod = subprocess.Popen(
rmcmd, rmcmd,
@ -2073,25 +1968,9 @@ class LiveBuild:
""" """
entries_dir = os.path.join(work_root, "entries") entries_dir = os.path.join(work_root, "entries")
live_dir_arch = os.path.join(self.live_work_dir, arch) live_dir_arch = os.path.join(self.live_work_dir, arch)
isoname = '{}-{}-{}-{}-{}.iso'.format( isoname = f'{self.shortname}-{self.release}-{image}-{arch}-{self.date}.iso'
self.shortname, isolink = f'{self.shortname}-{self.major_version}-{image}-{arch}-latest.iso'
self.release, live_res_dir = f'/var/lib/mock/{self.shortname.lower()}-{self.major_version}-{arch}/result'
image,
arch,
self.date
)
isolink = '{}-{}-{}-{}-{}.iso'.format(
self.shortname,
self.major_version,
image,
arch,
'latest'
)
live_res_dir = '/var/lib/mock/{}-{}-{}/result'.format(
self.shortname.lower(),
self.major_version,
arch
)
if self.justcopyit: if self.justcopyit:
if os.path.exists(os.path.join(live_dir_arch, isoname)): if os.path.exists(os.path.join(live_dir_arch, isoname)):
@ -2102,7 +1981,7 @@ class LiveBuild:
self.log.warn(Color.WARN + 'Skipping.') self.log.warn(Color.WARN + 'Skipping.')
return return
live_iso_cmd = '/bin/bash {}/liveisobuild-{}-{}.sh'.format(entries_dir, arch, image) live_iso_cmd = f'/bin/bash {entries_dir}/liveisobuild-{arch}-{image}.sh'
self.log.info('Starting mock build...') self.log.info('Starting mock build...')
p = subprocess.call(shlex.split(live_iso_cmd)) p = subprocess.call(shlex.split(live_iso_cmd))
if p != 0: if p != 0: