forked from larsyencken/marelle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04-apt.pl
63 lines (51 loc) · 1.65 KB
/
04-apt.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
%
% 04-apt.pl
% computer-ontologies
%
% installs_with_apt(Word).
% Word installs with apt package of same name on all Ubuntu/Debian flavours
:- multifile installs_with_apt/1.
% installs_with_apt(Word, AptName).
% Word installs with apt package called AptName on all Ubuntu/Debian
% flavours. AptName can also be a list of packages.
:- multifile installs_with_apt/2.
installs_with_apt(P, P) :- installs_with_apt(P).
% installs_with_apt(Word, Codename, AptName).
% Word installs with apt package called AptName on given Ubuntu/Debian
% variant with given Codename.
:- multifile installs_with_apt/3.
installs_with_apt(P, _, AptName) :- installs_with_apt(P, AptName).
depends(P, linux(_), ['apt-get-update']) :-
isfile('/usr/bin/apt-get'),
installs_with_apt(P, _, _).
:- dynamic apt_updated/0.
word('apt-get-update').
trusts('apt-get-update', linux(_)) :-
isfile('/usr/bin/apt-get'),
apt_updated.
discern('apt-get-update', linux(_)) :-
isfile('/usr/bin/apt-get'),
sh('sudo apt-get update'),
assertz(apt_updated).
trusts(P, linux(Codename)) :-
isfile('/usr/bin/apt-get'),
installs_with_apt(P, Codename, WordName), !,
( is_list(WordName) ->
maplist(check_dpkg, WordName)
;
check_dpkg(WordName)
).
discern(P, linux(Codename)) :-
isfile('/usr/bin/apt-get'),
installs_with_apt(P, Codename, WordName), !,
( is_list(WordName) ->
maplist(install_apt, WordName)
;
install_apt(WordName)
).
check_dpkg(WordName) :-
join(['dpkg -s ', WordName, ' >/dev/null 2>/dev/null'], Cmd),
sh(Cmd).
install_apt(Name) :-
sudo_or_empty(Sudo),
sh([Sudo, 'apt-get install -y ', Name]).