[elbe-devel] [PATCH 5/8] buildrepo: final touches on cdrom build

Torben Hohn torben.hohn at linutronix.de
Fri Oct 19 16:07:34 CEST 2018


On Fri, Oct 19, 2018 at 03:47:04PM +0200, Manuel Traut wrote:
> On Thu, Sep 27, 2018 at 12:34:18PM +0200, Torben Hohn wrote:
> > Check for cdrom build, and only create the initvm Source Repo and
> > archive dir, but dont try adding source pkgs. They are not available
> > anyways.
> > 
> > the cdrom build is now triggered using the --cdrom-mount-path option,
> > since the source.xml found in /var/cache/elbe/source.xml does not
> > carry the modified cdrom mirror section.
> > 
> > When preseed late is running, the cdrom is not mounted anymore.
> > mounting the cdrom from init-elbe.sh does not work because the
> > in-target command cleans up mounts, that happened in the target.
> > 
> > Add --cdrom-device option, so that "elbe buildrepo" can issue the mount
> > command itself. Also rename opt.cdrom to opt.cdrom_path to avoid
> > confusion.
> > 
> > Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
> > ---
> >  elbepack/commands/buildrepo.py | 36 +++++++++++++++++++++++++++++++++---
> >  1 file changed, 33 insertions(+), 3 deletions(-)
> > 
> > diff --git a/elbepack/commands/buildrepo.py b/elbepack/commands/buildrepo.py
> > index c08da229..84c0ef33 100644
> > --- a/elbepack/commands/buildrepo.py
> > +++ b/elbepack/commands/buildrepo.py
> > @@ -45,9 +45,12 @@ def run_command(argv):
> >                         dest="skip_validation", default=False,
> >                         help="Skip xml schema validation")
> >  
> > -    oparser.add_option("--cdrom-mount-path", dest="cdrom",
> > +    oparser.add_option("--cdrom-mount-path", dest="cdrom_path",
> >                         help="path where cdrom is mounted")
> >  
> > +    oparser.add_option("--cdrom-device", dest="cdrom_device",
> > +                       help="cdrom device, in case it has to be mounted")
> > +
> >      oparser.add_option("--apt-archive", dest="archive",
> >                         default="/var/cache/elbe/binaries/main",
> >                         help="path where binary packages are downloaded to.")
> > @@ -71,12 +74,30 @@ def run_command(argv):
> >          sys.exit(20)
> >  
> >      log = StdoutLog()
> > -    mirror = xml.get_initvm_primary_mirror(opt.cdrom)
> > +
> > +    if opt.cdrom_path:
> > +        if opt.cdrom_device:
> > +            log.do('mount "%s" "%s"' % (opt.cdrom_device, opt.cdrom_path))
> > +
> > +        # a cdrom build is identified by the cdrom option
> > +        # the xml file that is copied into the initvm
> > +        # by the initrd does not have the cdrom tags setup.
> > +        mirror = "file://%s" % opt.cdrom_path
> > +    else:
> > +        mirror = xml.get_initvm_primary_mirror(opt.cdrom_path)
> > +
> >      init_codename = xml.get_initvm_codename()
> >  
> >      # Binary Repo
> >      #
> > -    repo = CdromInitRepo(init_codename, opt.binrepo, log, 0, mirror)
> > +    try:
> > +        repo = CdromInitRepo(init_codename, opt.binrepo, log, 0, mirror)
> > +    except Exception:
> 
> we decided not to catch all Exceptions, is there a good reason for that?
> If -> add a comment and pylint annotations
> 
> Wouldn't it make sense to log the exception?
> 
> > +        log.printo('cant create repo')
> > +        log.do('mount')
> > +        log.do('ls -R /')
> > +        raise

i raise the exception again !

however... looking at this. this just seems to be debug
code, that should actually be dropped.


> > +
> >      hostfs.mkdir_p(opt.archive)
> >  
> >      pkglist = get_initvm_pkglist()
> > @@ -113,6 +134,15 @@ def run_command(argv):
> >      repo = CdromSrcRepo(init_codename, init_codename, opt.srcrepo, log, 0, mirror)
> >      hostfs.mkdir_p(opt.srcarchive)
> >  
> > +    # a cdrom build does not have sources
> > +    # skip adding packages to the source repo
> > +    #
> > +    # FIXME: we need a way to add source cdroms later on
> > +    if opt.cdrom_path:
> > +        if opt.cdrom_device:
> > +            log.do('umount "%s"' % opt.cdrom_device)
> > +        sys.exit(0)
> > +
> >      for pkg in pkglist:
> >          try:
> >              p = cache[pkg.name]
> > -- 
> > 2.11.0
> > 
> > 
> > _______________________________________________
> > 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
-------------- 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/20181019/08eba652/attachment.sig>


More information about the elbe-devel mailing list