How do I ensure that old shared content is removed when using Module::Build's share_dir option?

StackOverflow https://stackoverflow.com/questions/13188343

  •  29-07-2021
  •  | 
  •  

Domanda

I'm using Module::Build's share_dir option to install read-only supplementary content when users install my Perl module.

How do I ensure that the old content added by previous versions of my module is deleted when a new version of my module is installed?

Thanks in advance for your help.

È stato utile?

Soluzione

Yanick Champoux has recently been dealing with this problem. To do so he has created File::ShareDir::Tarball and its Dist::Zilla counterpart Dist::Zilla::Plugin::ShareDir::Tarball. The idea is that your entire sharedir is tarred so that it is only one directory. Then when your module is upgraded, the tarball is replaced and it is in the state you expect.

Altri suggerimenti

If you're removing files from a distribution I recommend making Makefile.PL or Build.PL refuse to install, add this

my $mod = 'CGI';
if( eval "require $mod; 1" ){
  die "

YOU HAVE TO UNINSTALL $mod before you can upgrade, use one of
cpanp -u  $mod  --force
pm-uninstall -vf $mod


";
}

Or better yet, add a pre-amble which does the actual uninstalling (maybe with ExtUtils::Install::uninstall($packlist) )

Usually you'll know which version of your module requires complete uninstalling, so you might want to add a version check ...

FWIW, this would make a good Module::Build/Module::Install/ExtUtils::MakeMaker addition/extension/plugin that accepts something like

requires_uninstall_if_installed  => '<3000' ,
requires_uninstall_if_installed  => { CGI => '<3000', 'CGI::Util' => '<3000' },
requires_uninstall_if_installed  => [ qw' CGI CGI::Util '],

requires_uninstall_if_installed( '<3000' );
requires_uninstall_if_installed( { CGI => '<3000', 'CGI::Util' => '<3000' } );
requires_uninstall_if_installed( [ qw' CGI CGI::Util '] );

I have now uploaded Module::Build::CleanInstall to hopefully address issues like this. Hopefully it helps. A big thanks goes to Yanick and so-not-like-openid-anonymity for the inspiration.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top