| git.druid.rocks | index | druid520 | mp | src/ | install.pl |
src/install.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::util qw(fail confirm spin_start spin_stop);
use mplib::db qw(read_db);
use mplib::resolve qw(init install_pkg expand_meta plan_resolution);
my $flags = mplib::config::parse_flags(\@ARGV);
mplib::config::load($flags);
fail("install needs at least one package name") unless @ARGV;
init();
my $db = read_db();
my @names = map { expand_meta($_, $db) } @ARGV;
# plan_resolution validates the WHOLE request up front (see its own doc
# comment in mplib::resolve) before any package here actually installs
# anything -- with --no-deps, nothing below ever resolves a dependency
# at all, so there is nothing to plan and planning could only produce a
# false failure for a request --no-deps would have let through.
unless($CFG->{NODEPS})
{
spin_start("resolving dependencies...");
my ($status, $result) = plan_resolution(\@names, $db);
spin_stop();
if($status eq 'fail')
{
fail("cannot satisfy this request: $result");
}
elsif($status eq 'ok')
{
for my $tag (keys %$result)
{
next if defined $CFG->{conf}{"TARGET_$tag"} && $CFG->{conf}{"TARGET_$tag"} ne '';
$CFG->{conf}{"TARGET_$tag"} = $result->{$tag};
}
}
# 'punt': the planner declined to judge this request (e.g. a
# per-package SYSROOT= override it doesn't model) -- fall through and
# let install_pkg's own resolve_dep/pick_provider resolve everything
# exactly as if this block had never run.
}
confirm("install: " . join(' ', @names) . " -- continue?");
install_pkg($_, $db, {}, 1) for @names;