Created
February 2, 2021 17:07
-
-
Save jberger/9ac064c5ffced2a382007ce6e65caebb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use App::cpm::CLI; | |
use File::Spec; | |
use Carton::CPANfile; | |
use Carton::Snapshot; | |
my $install_path = 'local'; | |
my $darkpan = 'https://darkpan.example.com/combined'; | |
# call the cli library directly rather than shelling out | |
# equivalent to running `$ cpm install ...` | |
App::cpm::CLI->new->run( | |
'install', | |
'-v', | |
'--color', | |
'--mirror', $darkpan, | |
'-L', $install_path, | |
'--exclude-vendor', # undocumented option that is needed for fully self-contained builds | |
'-r', "02packages,$darkpan", | |
'-r', 'metadb', | |
'--test', # run module tests | |
# features that carton snapshots by default | |
'--with-configure', '--with-build', '--with-runtime', '--with-test', '--with-develop', | |
@ARGV, # any additional cpm options can be passed as switches to this script | |
) && die "Installation failed\n"; | |
my $cpanfile_path = File::Spec->rel2abs('cpanfile'); | |
my $cpanfile = Carton::CPANfile->new(path => $cpanfile_path); | |
$cpanfile->load; | |
my $snapshot = Carton::Snapshot->new(path => "$cpanfile_path.snapshot"); | |
$snapshot->find_installs($install_path, $cpanfile->requirements); | |
$snapshot->save; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment