| git.druid.rocks | index | druid520 | mp | src/ | verify.pl |
src/verify.pl
#!/usr/bin/env perl
use v5.16;
use strict;
use warnings FATAL => 'all';
use FindBin;
use lib "$FindBin::Bin";
use mplib::config qw($CFG);
use mplib::version qw(parse_dep_token);
use mplib::resolve qw(init find_portdir try_pkgconf all_ports);
my $flags = mplib::config::parse_flags(\@ARGV);
mplib::config::load($flags);
init();
my $bad = 0;
my @targets;
if(@ARGV)
{
# split a "name:slot" argument (e.g. what "mp slots" itself prints
# back) before find_portdir, same as fetch.pl/install_pkg -- the
# combined string never matches find_portdir's plain-name scan.
@targets = map { my $tok = parse_dep_token($_); { name => $_, dir => find_portdir($tok->{name}, $tok->{slot}, $tok->{repo}) } } @ARGV;
}
else
{
@targets = map { { name => "$_->{cat}/$_->{name}", dir => $_->{dir} } } all_ports();
}
for my $t (@targets)
{
my $reason;
my $pc;
# checks the RESOLVED phases (works uniformly for a legacy add.sh/
# del.sh port and a new single-file phase/class port -- resolve_port,
# under try_pkgconf, already merged classes and the legacy fallback).
if(!$t->{dir}) { $reason = 'no such port'; }
elsif(!($pc = try_pkgconf($t->{dir}))) { $reason = 'bad pkg.conf'; }
elsif(!$pc->{_phases}{install}) { $reason = 'no install phase (and no legacy add.sh)'; }
elsif(!$pc->{_phases}{remove}) { $reason = 'no remove phase (and no legacy del.sh)'; }
if(!$reason)
{
print "ok: $t->{name}.\n";
}
else
{
print "err: $t->{name}, $reason.\n";
$bad = 1;
}
}
exit(1) if $bad;