[PATCH 6/8] When creating a dir, wait till finished

5 views
Skip to first unread message

Andreas J. Reichel

unread,
Jan 24, 2018, 5:26:30 AM1/24/18
to efibootg...@googlegroups.com, Andreas Reichel
From: Andreas Reichel <andreas.r...@siemens.com>

efibootguard.bbclass creates an iso directory,
which sometimes is not ready yet before chdir'ing
into this new directory. Prevent this by correctly
fetching the result.

Signed-off-by: Andreas Reichel <andreas.r...@siemens.com>
---
classes/efibootguard.bbclass | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/classes/efibootguard.bbclass b/classes/efibootguard.bbclass
index c979e23..553da57 100644
--- a/classes/efibootguard.bbclass
+++ b/classes/efibootguard.bbclass
@@ -70,7 +70,9 @@ python build_efi_cfg() {

make_isodir_cmd = ["mkdir", "-p", isodir]
p = Popen(make_isodir_cmd)
-
+ (out, err) = p.communicate()
+ if not p.returncode == 0:
+ bb.fatal("Could not create isodir: %s" % isodir)
os.chdir(isodir)
p = Popen([bg_setenv_cmd, "--file", "--kernel=vmlinuz", "--watchdog=30"], \
stdout=PIPE, stderr=PIPE)
--
2.16.0

Jan Kiszka

unread,
Jan 29, 2018, 8:36:27 AM1/29/18
to [ext] Andreas J. Reichel, efibootg...@googlegroups.com
On 2018-01-24 11:23, [ext] Andreas J. Reichel wrote:
> From: Andreas Reichel <andreas.r...@siemens.com>
>
> efibootguard.bbclass creates an iso directory,
> which sometimes is not ready yet before chdir'ing
> into this new directory. Prevent this by correctly
> fetching the result.

Can you clarify what "not ready yet" exactly means? This sounds to me
like an ordering issue ("will be ready later"), but then the patch below
which simply fails the build does not match the description.

Jan

>
> Signed-off-by: Andreas Reichel <andreas.r...@siemens.com>
> ---
> classes/efibootguard.bbclass | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/classes/efibootguard.bbclass b/classes/efibootguard.bbclass
> index c979e23..553da57 100644
> --- a/classes/efibootguard.bbclass
> +++ b/classes/efibootguard.bbclass
> @@ -70,7 +70,9 @@ python build_efi_cfg() {
>
> make_isodir_cmd = ["mkdir", "-p", isodir]
> p = Popen(make_isodir_cmd)
> -
> + (out, err) = p.communicate()
> + if not p.returncode == 0:
> + bb.fatal("Could not create isodir: %s" % isodir)
> os.chdir(isodir)
> p = Popen([bg_setenv_cmd, "--file", "--kernel=vmlinuz", "--watchdog=30"], \
> stdout=PIPE, stderr=PIPE)
>


--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

Andreas Reichel

unread,
Jan 29, 2018, 8:48:31 AM1/29/18
to Jan Kiszka, efibootg...@googlegroups.com
On Mon, Jan 29, 2018 at 02:36:24PM +0100, Jan Kiszka wrote:
> On 2018-01-24 11:23, [ext] Andreas J. Reichel wrote:
> > From: Andreas Reichel <andreas.r...@siemens.com>
> >
> > efibootguard.bbclass creates an iso directory,
> > which sometimes is not ready yet before chdir'ing
> > into this new directory. Prevent this by correctly
> > fetching the result.
>
> Can you clarify what "not ready yet" exactly means? This sounds to me
> like an ordering issue ("will be ready later"), but then the patch below
> which simply fails the build does not match the description.
>
Not ready means the directory is not ready, i.e. does not exist yet.
A call to Popen runs its process async, so if "communicate" is not
called, "os.chdir" can be executed before "mkdir" is finished. A call to
communicate waits until the result of mkdir is available.

Andreas
> Jan
>
> >
> > Signed-off-by: Andreas Reichel <andreas.r...@siemens.com>
> > ---
> > classes/efibootguard.bbclass | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/classes/efibootguard.bbclass b/classes/efibootguard.bbclass
> > index c979e23..553da57 100644
> > --- a/classes/efibootguard.bbclass
> > +++ b/classes/efibootguard.bbclass
> > @@ -70,7 +70,9 @@ python build_efi_cfg() {
> >
> > make_isodir_cmd = ["mkdir", "-p", isodir]
> > p = Popen(make_isodir_cmd)
> > -
> > + (out, err) = p.communicate()
> > + if not p.returncode == 0:
> > + bb.fatal("Could not create isodir: %s" % isodir)
> > os.chdir(isodir)
> > p = Popen([bg_setenv_cmd, "--file", "--kernel=vmlinuz", "--watchdog=30"], \
> > stdout=PIPE, stderr=PIPE)
> >
>
>
> --
> Siemens AG, Corporate Technology, CT RDA IOT SES-DE
> Corporate Competence Center Embedded Linux

--
Andreas Reichel
Dipl.-Phys. (Univ.)
Software Consultant

Andreas...@tngtech.com, +49-174-3180074
TNG Technology Consulting GmbH, Betastr. 13a, 85774 Unterfoehring
Geschaeftsfuehrer: Henrik Klagges, Dr. Robert Dahlke, Gerhard Mueller
Sitz: Unterfoehring * Amtsgericht Muenchen * HRB 135082

Jan Kiszka

unread,
Jan 29, 2018, 8:52:32 AM1/29/18
to Andreas Reichel, efibootg...@googlegroups.com
On 2018-01-29 14:45, Andreas Reichel wrote:
> On Mon, Jan 29, 2018 at 02:36:24PM +0100, Jan Kiszka wrote:
>> On 2018-01-24 11:23, [ext] Andreas J. Reichel wrote:
>>> From: Andreas Reichel <andreas.r...@siemens.com>
>>>
>>> efibootguard.bbclass creates an iso directory,
>>> which sometimes is not ready yet before chdir'ing
>>> into this new directory. Prevent this by correctly
>>> fetching the result.
>>
>> Can you clarify what "not ready yet" exactly means? This sounds to me
>> like an ordering issue ("will be ready later"), but then the patch below
>> which simply fails the build does not match the description.
>>
> Not ready means the directory is not ready, i.e. does not exist yet.
> A call to Popen runs its process async, so if "communicate" is not
> called, "os.chdir" can be executed before "mkdir" is finished. A call to
> communicate waits until the result of mkdir is available.

OK, thanks for clarifying.

Jan
Reply all
Reply to author
Forward
0 new messages