Subject: bug#10878: "make dist" with read-only srcdir generates read-only tarball

From: Stefano Lattarini <[email-masked]>
Date: Fri, 24 Feb 2012 20:25:28 +0100

On 02/24/2012 07:34 PM, Nick Bowler wrote:
>
> On 2012-02-24 19:19 +0100, Stefano Lattarini wrote:
>>
>> But it's the package that expects its distributed files to be writable
>> that is assuming too much; if such package wants its expectation to
>> safely hold, it should add something like this in its 'dist-hook':
>>
>>     find $(distdir) -exec chmod u+w '{}' ';'
> 
> So I've done this now, but note that this is actually harder than you
> make it out to be.
>
True, but only a little ...

> If the package adds prerequisites to the dist-hook target ... [SNIP]
>
... you can do this:

  make-distdir-writable:
	find $(distdir) -exec chmod u+w '{}' ';'
  dist_hook_prereqs = foo bar
  dist-hook: $(dist_hook_prereqs)
  $(dist_hook_prereqs): make-distdir-writable

> (I find it is generally good practice for -hook and -local
> targets to use prerequisites with commands instead of putting commands
> directly in those targets)
>
JFTR, I agree.

> to the dist-hook target, one would want the
> permissions to be fixed *before* executing the prerequisite targets.
> But this cannot be done by simply adding things directly to the
> dist-hook target.
> 
>>> Distcheck should also refrain from testing this.
>>
>> Nope; distcheck testing that the distributed package builds correctly with
>> a read-only source tree is a feature, not a bug, since the GCS require this.
> 
> I'm not talking about building the package, which absolutely should work
> from a read-only source tree.  I'm talking about creating a distribution
> tarball,
>
But the distribution tarball created by automake *won't* have write
permissions stripped (assuming they were present in the first place,
of course).

> with "make dist": something only package maintainers (that's
> me!) will generally do.
> 
> As it stands, "make dist" currently does not work properly from a
> read-only source tree.
>
I honestly don't see why not; if you don't want to put readonly files in
the distributed tarball, don't create the tarball from a readonly srcdir.
It's not like automake is removing the write permissions itslef (now,
that would quite be a bug!); it's you who have removed it before creating
the tarball:

  % tar xf test-1.0.tar.gz
  % chmod -R a-w test-1.0 # <-- !HERE!
  % mkdir build && cd build
  % ../test-1.0/configure && make dist
  % tar tvf test-1.0.tar.gz

To stress this again: if *you* had removed the executable bit from your
test scripts, would you blame it on automake if "make distcheck" stopped
working?  I don't think so.

> The tarball generated by my minimal example (an empty Makefile.am!) is
> clearly broken, and I would not want to be caught distributing such a thing.
> 
> Cheers,

Regards,
  Stefano