forked from larsyencken/marelle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08-pacman.pl
43 lines (33 loc) · 1.14 KB
/
08-pacman.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
%
% 08-pacman.pl
% computer-deps
%
% installs_with_pacman(Word).
% Word installs with pacman package of same name on Arch Linux
:- multifile installs_with_pacman/1.
% installs_with_pacman(Word, PacName).
% Word installs with pacman package called PacName on Arch Linux
% PacName can also be a list of packages.
:- multifile installs_with_pacman/2.
installs_with_pacman(W, W) :- installs_with_pacman(W).
:- dynamic pacman_updated/0.
word('pacman-update').
trusts('pacman-update', linux(arch)) :- pacman_updated.
discern('pacman-update', linux(arch)) :-
sh('sudo pacman -Syu'),
assertz(pacman_updated).
supports(W, linux(arch), ['pacman-update']) :-
installs_with_pacman(W, _).
% attempt to install a package with pacman
install_pacman(Word) :-
sudo_or_empty(Sudo),
sh([Sudo, 'pacman -S --noconfirm ', Word]).
% succeed only if the package is already installed
check_pacman(Word) :-
sh(['pacman -Qi ', Word, '>/dev/null 2>/dev/null']).
trusts(W, linux(arch)) :-
installs_with_pacman(W, WordName), !,
check_pacman(WordName).
discern(W, linux(arch)) :-
installs_with_pacman(W, WordName), !,
install_pacman(WordName).