mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-25 09:21:10 +00:00
container: Fix image extension to .raw for systemd v260
The new version of systemd in Debian testing expects the symlinked file to be ending with .raw as well. So, our .img files weren't being recognized by machinectl as machine images. Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net> [sunil: Remove old symlink forcefully] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
2307f5fbf2
commit
65fecdc4cd
27
container
27
container
@ -689,10 +689,27 @@ def _verify_signature(hkp_client: str, data_file: pathlib.Path,
|
||||
|
||||
def _extract_image(compressed_file: pathlib.Path):
|
||||
"""Extract the image file."""
|
||||
decompressed_file = compressed_file.with_suffix('')
|
||||
# Strip the .xz extension, then replace .img with .raw
|
||||
decompressed_file = compressed_file.with_suffix('').with_suffix('.raw')
|
||||
older_image = compressed_file.with_suffix('')
|
||||
|
||||
if decompressed_file.exists():
|
||||
return decompressed_file
|
||||
|
||||
# Rename older image and its corresponding state files.
|
||||
if older_image.exists():
|
||||
logger.info('Renaming .img file to .raw')
|
||||
older_image.rename(decompressed_file)
|
||||
|
||||
for ext in ['.setup', '.provisioned']:
|
||||
old_state = older_image.with_suffix(older_image.suffix + ext)
|
||||
new_state = decompressed_file.with_suffix(
|
||||
decompressed_file.suffix + ext)
|
||||
if old_state.exists():
|
||||
old_state.rename(new_state)
|
||||
|
||||
return decompressed_file
|
||||
|
||||
logger.info('Decompressing file %s', compressed_file)
|
||||
partial_file = compressed_file.with_suffix('.partial')
|
||||
with partial_file.open('w', encoding='utf-8') as file_handle:
|
||||
@ -715,7 +732,8 @@ def _get_compressed_image_path(distribution: str) -> pathlib.Path:
|
||||
def _get_image_file(distribution: str) -> pathlib.Path:
|
||||
"""Return the path of the image file."""
|
||||
compressed_image = _get_compressed_image_path(distribution)
|
||||
return compressed_image.with_suffix('')
|
||||
# Strip the .xz extension, then replace .img with .raw
|
||||
return compressed_image.with_suffix('').with_suffix('.raw')
|
||||
|
||||
|
||||
def _get_project_folder() -> pathlib.Path:
|
||||
@ -1337,9 +1355,8 @@ VirtualEthernet=yes
|
||||
if result.returncode:
|
||||
raise Exception(f'Image file {image_link} is not a symlink.')
|
||||
|
||||
subprocess.run(['sudo', 'rm', '--force',
|
||||
str(image_link)], check=False)
|
||||
|
||||
# May be linked to wrong place (such as old .img file)
|
||||
subprocess.run(['sudo', 'rm', '--force', str(image_link)], check=False)
|
||||
subprocess.run([
|
||||
'sudo', 'ln', '--symbolic',
|
||||
str(image_file.resolve()),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user