[elbe-devel] [PATCH 1/5] packers: add Packer class implementation
John Ogness
john.ogness at linutronix.de
Mon Jan 28 11:38:26 CET 2019
Hi Torben,
On 2019-01-28, Torben Hohn <torben.hohn at linutronix.de> wrote:
> using tar as a packer can not be modelled using the tuples
> approach.
>
> Implement a Baseclass and a dict mapping packernames to
> Packer objects. Also implement NoPacker class, which does nothing
> and returns the fname right away.
>
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
> elbepack/packers.py | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 77 insertions(+)
> create mode 100644 elbepack/packers.py
>
> diff --git a/elbepack/packers.py b/elbepack/packers.py
> new file mode 100644
> index 00000000..20680bc4
> --- /dev/null
> +++ b/elbepack/packers.py
[...]
> +class TarArchiver(Packer):
> + # pylint: disable=too-few-public-methods
> + def __init__(self, flag, suffix):
> + self.flag = flag
> + self.suffix = suffix
> +
> + def pack_file(self, log, builddir, fname):
> + try:
> + fpath = os.path.join(builddir, fname)
> + dirname = os.path.dirname(fpath)
> + basename = os.path.basename(fpath)
> + archname = fpath + self.suffix
> + log.do('tar cv%sf "%s" --sparse -C "%s" "%s"' % (self.flag,
> + archname,
> + dirname,
> + basename))
Why not do:
log.do('rm -f "%s"' % fpath)
Since the original file can't be used and it is really big, why waste
initvm space? I think it should be deleted.
> + except CommandError:
> + # in case of an error, we just return None
> + # which means, that the orig file does not
> + # exist anymore.
> + #
> + # Even if it actually exists, it might be
> + # much to big to download it and remove
> + # the sparsity.
> + return None
> +
> + return fname + self.suffix
John Ogness
More information about the elbe-devel
mailing list