[elbe-devel] [PATCH 49/75] hdimg: Fix Pylint

Torben Hohn torben.hohn at linutronix.de
Thu Jun 4 18:17:00 CEST 2020


On Wed, Jun 03, 2020 at 03:50:23PM -0400, Olivier Dion wrote:
> On Fri, 29 May 2020, Torben Hohn <torben.hohn at linutronix.de> wrote:
> > On Mon, May 25, 2020 at 11:42:42AM -0400, Olivier Dion wrote:
> >> @@ -261,18 +265,23 @@ class grubinstaller97(grubinstaller_base):
> >>  
> >>              chroot(imagemnt, "update-initramfs -u -k all")
> >>  
> >> -            # Replace groot and kopt because
> >> -            # else they will be given bad values
> >> -            do('chroot %s sed -in "s/^# groot=.*$/# groot=\(hd0,%d\)/" %s' %
> >> +            # Replace groot and kopt because else they will be given
> >> +            # bad values
> >> +            #
> >> +            # FIXME - Pylint says: Using possibly undefined loop variable
> >> +            # 'entry' (undefined-loop-variable).  entry is defined in
> >> +            # the previous for-loop.
> >> +            # # pylint: disable=undefined-loop-variable
> >> +            do(r'chroot %s sed -in "s/^# groot=.*$/# groot=\(hd0,%d\)/" %s' %
> >>                 (imagemnt, int(entry.partnum) - 1, "/boot/grub/menu.lst"))
> >> -            do('chroot %s sed -in "s/^# kopt=.*$/# kopt=root=LABEL=%s/" %s' %
> >> +            do(r'chroot %s sed -in "s/^# kopt=.*$/# kopt=root=LABEL=%s/" %s' %
> >>                 (imagemnt, entry.label, "/boot/grub/menu.lst"))
> >
> > oh man, this code is pretty broken.
> > It will break, when more than one HD image is used.
> 
> Would indenting the body up to 'chroot(imagemnt, "update-grub")' in the
> loop fixes that?

no. then you would install grub for every loop iteration.
And it would only work, once all the filesystem have been mounted
into the correct places.

> 
> >
> > using entry is also just working out of luck.
> > entry will simply point the the deepest filesystem.
> > which is /boot in most cases.
> 
> -- 
> Olivier Dion
> Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen

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