Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ requires 'Alien::Base::ModuleBuild';

requires 'Class::Method::Modifiers';

# workaround for https://github.com/matrix-org/sytest/issues/942:
# Crypt::NaCl::Sodium won't install with Alien::Sodium 2.0.
requires 'Alien::Sodium', '<2.0', 'AJGB/Alien-Sodium-1.0.8.0.tar.gz';

# this can be a pain to install.
#
# We used to have a libcrypt-nacl-sodium-perl deb, but it was only built for
Expand Down
30 changes: 19 additions & 11 deletions install-deps.pl
Original file line number Diff line number Diff line change
Expand Up @@ -31,42 +31,50 @@ sub check_installed
}

defined $want_ver or return 1;
unless( $want_ver =~ s/^>=\s+// ) {
print STDERR "TODO: can only perform '>=' version checks\n";
my $inst_ver = `$^X -M$mod -e 'print \$${mod}::VERSION'`;

if( $want_ver =~ s/^>=\s*// ) {
if( $inst_ver lt $want_ver ) {
die "$mod: got $inst_ver, want >=$want_ver\n";
}
} elsif( $want_ver =~ s/^<\s*// ) {
if( $inst_ver ge $want_ver ) {
die "$mod: got $inst_ver, want <$want_ver\n";
}
} else {
print STDERR "TODO: can only perform '<' and '>=' version checks: cannot support $want_ver\n";
return 1;
}

my $inst_ver = `$^X -M$mod -e 'print \$${mod}::VERSION'`;
if( $inst_ver lt $want_ver ) {
die "$mod: got $inst_ver, want $want_ver\n";
}
return 1;
}

sub requires
{
my ( $mod, $ver ) = @_;
my ( $mod, $ver, $dist_path ) = @_;

eval { check_installed( $mod, $ver ) } and return;

$dist_path //= $mod;

# TODO: check that some location is user-writable in @INC, and that it appears
# somehow in PERL_{MB,MM}_OPT

if( !$DRYRUN ) {
print STDERR "**** Installing $mod ****\n";
print STDERR "\n\n**** install-deps.pl: Installing $mod ****\n";

if( $NOTEST ) {
CPAN::Shell->notest('install', $mod);
CPAN::Shell->notest('install', $dist_path);
} else {
CPAN::Shell->install($mod);
CPAN::Shell->install($dist_path);
}

if( not eval { check_installed( $mod, $ver ) } ) {
print STDERR "Failed to import $mod even after installing: $@\n";
exit 1;
}
} else {
print qq($^X -MCPAN -e 'install "$mod"'\n);
print qq($^X -MCPAN -e 'install "$dist_path"'\n);
}
}

Expand Down