Skip to content

Commit

Permalink
Unify branches (#67)
Browse files Browse the repository at this point in the history
* Ignore deprecation notice for distutils on jammy

* Decompress vmlinuz on ARM64

* evert "Ignore deprecation notice for distutils on jammy"

This reverts commit 4c42f32.

Co-authored-by: Jeremy Soller <[email protected]>
Co-authored-by: Lucy <[email protected]>
  • Loading branch information
3 people authored Jul 22, 2022
1 parent bdefe03 commit 41819bb
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions kernelstub/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
terms.
"""

import os, shutil, logging
import os, shutil, logging, platform, gzip

from pathlib import Path

Expand Down Expand Up @@ -118,10 +118,17 @@ def setup_kernel(self, kernel_opts, setup_loader=False, overwrite=False, simulat
self.log.debug('kernel being copied to %s' % self.kernel_dest)

try:
self.copy_files(
self.opsys.kernel_path,
self.kernel_dest,
simulate=simulate)
arch = platform.machine()
if arch == "arm64" or arch == "aarch64":
self.gunzip_files(
self.opsys.kernel_path,
self.kernel_dest,
simulate=simulate)
else:
self.copy_files(
self.opsys.kernel_path,
self.kernel_dest,
simulate=simulate)

except FileOpsError as e:
self.log.exception(
Expand Down Expand Up @@ -237,6 +244,23 @@ def ensure_dir(self, directory, simulate=False):
self.log.debug(e)
return False

def gunzip_files(self, src, dest, simulate): # Decompress file src to dest
if simulate:
self.log.info('Simulate decompressing: %s => %s' % (src, dest))
return True
else:
try:
self.log.debug('Decompressing: %s => %s' % (src, dest))
with gzip.open(src, 'rb') as in_obj:
with open(dest, 'wb') as out_obj:
shutil.copyfileobj(in_obj, out_obj)
return True
except Exception as e:
self.log.debug(e)
raise FileOpsError("Could not decompress one or more files.")
return False


def copy_files(self, src, dest, simulate): # Copy file src into dest
if simulate:
self.log.info('Simulate copying: %s => %s' % (src, dest))
Expand Down

0 comments on commit 41819bb

Please sign in to comment.