class ISUPkgsMakerCtx:
- def __init__(self, images_dir: Path, use_images: bool, tmp_dir: Path, profile_name: str, out_dir: Path, key: Union[Path, None], file_mapper: FileMapper):
+ def __init__(self, images_dir: Path, use_images: bool, tmp_dir: Path, profile_name: str, out_dir: Path, key: Union[Path, None], file_mapper: FileMapper, sign_cmd: str):
self.images_dir = images_dir
self.use_images = use_images
self.tmp_dir = tmp_dir
self.out_dir = out_dir
self.key = key
self.file_mapper = file_mapper
+ self.sign_cmd = sign_cmd
class ISUSinglePkgMakerCtx(ISUPkgsMakerCtx):
hash = self._hash_of_file(sha256, f_path)
file.write(f"{hash} {f_path.relative_to(self._ctx.pkg_dir)}\n")
+ sign_cmd = self._ctx.sign_cmd
+ logger.info("Signing {} file with external command".format(self.CHECKSUM_FILE))
+ signed_sum_path = str(sum_path) + '.sign'
+ if subprocess.call([sign_cmd, sum_path, signed_sum_path]) != 0:
+ logger.warning("Subprocess call to signing command failed!")
+
def _zip_pkg(self) -> Path:
out_name = self._ctx.out_dir / self._ctx.cfg.name
out_name_zip = out_name.with_suffix('.zip')
class ISUPkgsMaker:
- def __init__(self, images_dir: Path, use_images: bool, tmp_dir: Path, profile_name: str, out_dir: Path, key: Union[Path, None], file_mapper: FileMapper):
- self._ctx = ISUPkgsMakerCtx(images_dir, use_images, tmp_dir, profile_name, out_dir, key, file_mapper)
+ def __init__(self, images_dir: Path, use_images: bool, tmp_dir: Path, profile_name: str, out_dir: Path, key: Union[Path, None], file_mapper: FileMapper, sign_cmd: str):
+ self._ctx = ISUPkgsMakerCtx(images_dir, use_images, tmp_dir, profile_name, out_dir, key, file_mapper, sign_cmd)
def __enter__(self):
return self
help="File with image<->path mapping")
parser.add_argument('--key', '-k', type=str, required=False,
help="Signing key")
+ parser.add_argument('--sign-cmd', type=str, required=False,
+ help="Signing command")
parser.add_argument('--profile-name', type=str, required=False,
default=os.getenv('PROFILE_NAME'),
help="Profile name")
args.profile_name,
Path(os.path.realpath(args.out)),
Path(args.key) if args.key else None,
- map) as isu_pkgs_maker:
+ map,
+ args.sign_cmd) as isu_pkgs_maker:
isu_pkgs_maker.run(rpk_info, args.exit_on_any_error)
except NoISUConfigDirException:
return os.EX_OK
class ISUPkgsMakerCtx(object):
- def __init__(self, images_dir, use_images, tmp_dir, profile_name, out_dir, key, file_mapper):
+ def __init__(self, images_dir, use_images, tmp_dir, profile_name, out_dir, key, file_mapper, sign_cmd):
self.images_dir = images_dir
self.use_images = use_images
self.tmp_dir = tmp_dir
self.out_dir = out_dir
self.key = key
self.file_mapper = file_mapper
+ self.sign_cmd = sign_cmd
class ISUSinglePkgMakerCtx(ISUPkgsMakerCtx):
hash = self._hash_of_file(sha256, f_path)
line = u"{} {}\n".format(hash ,os.path.relpath(f_path, start=str(self._ctx.pkg_dir)))
file.write(line)
+ sign_cmd = self._ctx.sign_cmd
+ logger.info("Signing {} file with external command".format(self.CHECKSUM_FILE))
+ signed_sum_path = sum_path + '.sign'
+ if subprocess.call([sign_cmd, sum_path, signed_sum_path]) != 0:
+ logger.warning("Subprocess call to signing command failed!")
def _zip_pkg(self):
out_name = os.path.join(self._ctx.out_dir, self._ctx.cfg.name)
class ISUPkgsMaker:
- def __init__(self, images_dir, use_images, tmp_dir, profile_name, out_dir, key, file_mapper):
- self._ctx = ISUPkgsMakerCtx(images_dir, use_images, tmp_dir, profile_name, out_dir, key, file_mapper)
+ def __init__(self, images_dir, use_images, tmp_dir, profile_name, out_dir, key, file_mapper, sign_cmd):
+ self._ctx = ISUPkgsMakerCtx(images_dir, use_images, tmp_dir, profile_name, out_dir, key, file_mapper, sign_cmd)
def __enter__(self):
return self
help="File with image<->path mapping")
parser.add_argument('--key', '-k', type=str, required=False,
help="Signing key")
+ parser.add_argument('--sign-cmd', type=str, required=False,
+ help="Signing command")
parser.add_argument('--profile-name', type=str, required=False,
default=os.getenv('PROFILE_NAME'),
help="Profile name")
args.profile_name,
os.path.realpath(args.out),
args.key,
- map) as isu_pkgs_maker:
+ map,
+ args.sign_cmd) as isu_pkgs_maker:
isu_pkgs_maker.run(rpk_info, args.exit_on_any_error)
except NoISUConfigDirException:
return os.EX_OK