Subject: Re: bug#19614: Split packaging invocation to catch errors

From: Bogdan <[email-masked]>
Date: Tue, 18 Jul 2023 21:26:44 +0200

Nick Bowler <[email-masked]>, Tue Jul 18 2023 08:55:53 GMT+0200
(Central European Summer Time)
> On 2023-07-17, Karl Berry <[email-masked]> wrote:
>> Hi Dimitrios, Bogdan - back on this bug from 2015 (sorry):
>>      https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19614
>>
>> Bogdan sent a patch that splits the tar and compress into separate
>> invocations.  It seems basically good to me, but the dist-formats test
>> fails because it builds multiple archive formats (.tar.gz, .tar.bz2,
>> etc.) in parallel, and so removing $(distdir).tar (and .err) files are
>> subject to a race condition.
>
>>   dist-gzip: distdir
>> -	tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c
>>> $(distdir).tar.gz
>> +	tardir=$(distdir) && $(am__tar) > $(distdir).tar 2>$(distdir).tarerr
>>
>> So my question is, will it suffice in this limited case to just put $$
>> into the filenames? It seems like it should be ok to me, but I'm not
>> sure I have enough imagination to know why that would fail. I can't see
>> figuring out how to run mktemp here.
>
> With the tar file generation as a separate command, it should be
> straightforward to avoid this problem by just moving the tar generation
> and error checking commands into a separate rule.  Then changing all the
> various dist-xyz commands to depend on that instead of distdir.  Example:
>
>    $(distdir).tar: distdir
>    	commands to tar it
>
>    dist-gzip: $(distdir).tar
>    	commands to gzip it
>
> and so on.  Then there should be no race with parallel "make dist" as
> the tar file will only be generated once.

  Probably a better idea than mine, e.g.

tmpname=`mktemp $(distdir)/dist.XXXXXX`
tardir=$(distdir) && $(am__tar) > $(tmpname).tar 2>$(distdir).err

or

tardir=$(distdir) && $(am__tar) > $(distdir)-$RANDOM.tar 2>$(distdir).err

[...]

--
Regards - Bogdan ('bogdro') D.                 (GNU/Linux & FreeDOS)
X86 assembly (DOS, GNU/Linux):    http://bogdro.evai.pl/index-en.php
Soft(EN): http://bogdro.evai.pl/soft  http://bogdro.evai.pl/soft4asm
www.Xiph.org  www.TorProject.org  www.LibreOffice.org  www.GnuPG.org