4

I've encountered a scenario where I'm building a Perl module as part of another Build system on a Windows machine. I use the --install_base option of Module::Build to specify a temporary directory to put module files until the overall build system can use them. Unfortunately, that other Build system has a problem if any of its files that it depends on are read only - it tries to delete any generated files before rebuilding them, and it can't clean any read-only files (it tries to delete it, and it's read only, which gives an error.) By default, Module::Build installs its libraries with the read-only bit enabled.

One option would be to make a new step in the build process that removes the read-only bit from the installed files, but due to the nature of the build tool that will require a second temporary directory...ugh.

Is it possible to configure a Module::Build based installer to NOT enable that read-only bit when the files are installed to the --install_base directory? If so, how?

Robert P
  • 15,707
  • 10
  • 68
  • 112
  • I've had severe issues with this too, and I'd have to dig back to see what we did about it. If you want to talk about it in private, since I can't disclose all of the details publicly, let me know. – brian d foy Jul 21 '11 at 02:35
  • @brian: Thanks for the offer; I won't take you up on it now (found a work-around: I force the tool to NOT delete them on a clean) but maybe some time else if this work-around fails. – Robert P Jul 21 '11 at 21:36

1 Answers1

4

No, it's not a configurable option. It's done in the copy_if_modified method in Module::Build::Base:

# mode is read-only + (executable if source is executable)
my $mode = oct(444) | ( $self->is_executable($file) ? oct(111) : 0 );
chmod( $mode, $to_path );

If you controlled the Build.PL, you could subclass Module::Build and override copy_if_modified to call the base class and then chmod the file writable. But I get the impression you're just trying to install someone else's module.

Probably the easiest thing to do would be to install a copy of Module::Build in a private directory, then edit it to use oct(666) (or whatever mode you want). Then invoke perl -I /path/to/customized/Module/Build Build.PL. Or, (as you said) just use the standard Module::Build and add a separate step to mark everything writable afterwards.

Update: ysth is right; it's ExtUtils::Install that actually does the final copy. copy_if_modified is for populating blib. But ExtUtils::Install also hardcodes the mode to read-only. You could use a customized version of ExtUtils::Install, but it's probably easier to just have a separate step.

cjm
  • 61,471
  • 9
  • 126
  • 175
  • are you sure copy_if_modified isn't just used to copy into blib/? I think the actual installation is done with ExtUtils::Install (which hardcodes 0444 (+0111 if any execute bit is set on the source)), but I gave up looking at the code before determining for certain. – ysth Jul 21 '11 at 02:59
  • This is exactly where my investigation led, thanks for the confirmation! – Robert P Jul 21 '11 at 15:37