[elbe-devel] [PATCH 1/5] packers: add Packer class implementation
Torben Hohn
torben.hohn at linutronix.de
Mon Jan 28 11:49:24 CET 2019
On Mon, Jan 28, 2019 at 11:38:26AM +0100, John Ogness wrote:
> 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.
errm... yes. sorry. i forgot that.
>
> > + 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
--
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
can be found here): https://linutronix.de/kontakt/Datenschutz.php
Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen |
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20190128/d5b52b15/attachment.sig>
More information about the elbe-devel
mailing list