[elbe-devel] [PATCH v2 1/5] elbeproject: Add gen_licenses method

Torben Hohn torben.hohn at linutronix.de
Thu Apr 2 12:08:56 CEST 2020


On Mon, Mar 16, 2020 at 12:24:44PM -0400, Olivier Dion wrote:
> On Sun, 15 Mar 2020, Olivier Dion <dion at linutronix.de> wrote:
> > The method check for the existance of the copyright file for each
> > packages of a RFS.  If a copyright file is missing, it's copied from
> > the buildenv.  If the file is also missing from the buildenv, then an
> > error is emitted.

I dont quite understand, why you want to copy files into the target fs.
Normally usr/share/doc is removed in finetuning, to save space.

The target is a subset of the files found in the buildenv.
There might be corner cases, when packages are upgraded / installed
in fintuning. (one usecase is multiarch, which can be only had using
finetuning, but we want proper support for this later on)

But you can assume, that target is a subset of buildenv.

So the target-licence.xml shall actually be generated from
the files in buildenv. No copying.
Just use the pkg list obtained from dump.

i think you can just remove the whole "if env is not self.buildenv:"
block. and this should work.

iirc the calls to gen_licenses() already do this.


> >
> > Signed-off-by: Olivier Dion <dion at linutronix.de>
> > ---
> >  elbepack/elbeproject.py | 42 +++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 42 insertions(+)
> >
> > diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
> > index b64a5fcb..765dd956 100644
> > --- a/elbepack/elbeproject.py
> > +++ b/elbepack/elbeproject.py
> > @@ -923,3 +923,45 @@ class ElbeProject (object):
> >              except SystemError as e:
> >                  logging.exception("Commiting changes failed")
> >                  raise AptCacheCommitError(str(e))
> > +
> > +    def gen_licenses(self, rfs, env, pkg_list):
> > +
> > +        lic_txt_fname = os.path.join(self.builddir,
> > +                                     "licence-%s.txt" % rfs)
> > +        lic_xml_fname = os.path.join(self.builddir,
> > +                                     "licence-%s.xml" % rfs)
> > +        pkg_list.sort()
> > +
> > +        if env is not self.buildenv:
> > +
> > +            DOC = "/usr/share/doc"
> > +
> > +            do("rm -rf '%s'" % env.rfs.fname(DOC))
> 
>                Err this command is not part of the patch.  It was there only to
>                force copying for testing ..


> > +
> > +            if not env.rfs.exists(DOC):
> > +                logging.warning("%s doesn't exists in RFS %s, "
> > +                                "but is need for licenses generation",
> > +                                DOC, rfs)
> > +                env.rfs.mkdir_p(DOC)
> > +
> > +            for pkg in pkg_list:
> > +
> > +                pkg_doc = os.path.join(DOC, pkg, "copyright")
> > +
> > +                if env.rfs.exists(pkg_doc):
> > +                    continue
> > +
> > +                env.rfs.mkdir_p(os.path.join(DOC, pkg))
> > +
> > +                # Try to copy from buildenv or fail
> > +                try:
> > +                    do("cp '%s' '%s'" % (self.buildenv.rfs.fname(pkg_doc),
> > +                                         env.rfs.fname(pkg_doc)))
> > +                except CommandError as e:
> > +                    logging.error("Missing copyright file for package '%s' in RFS '%s'. "
> > +                                  "The copyright file can not be found in the buildenv" %
> > +                                  (pkg, rfs))
> > +
> > +        with io.open(lic_txt_fname, 'w+',
> > +                     encoding='utf-8', errors='replace') as f:
> > +            env.rfs.write_licenses(f, pkg_list, lic_xml_fname)
> > -- 
> > 2.25.1
> >
> -- 
> Olivier Dion
> Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
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



More information about the elbe-devel mailing list