-
Notifications
You must be signed in to change notification settings - Fork 4
/
predicates.pl
103 lines (79 loc) · 2.9 KB
/
predicates.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
%% -*- prolog -*-
%%---------------------------------------------------------------
%% Project : logilic
%% File : predicates.pl
%% Copyright : (C) 2012 Frederic Lepied
%% Author : Frederic Lepied
%% Created On : Thu Nov 22 20:41:20 2012
%% Purpose : predicates to reason on licenses
%%---------------------------------------------------------------
%% This program is free software; you can redistribute it and/or modify
%% it under the terms of the GNU General Public License as published by
%% the Free Software Foundation; either version 2 of the License, or
%% (at your option) any later version.
%%
%% This program is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%% GNU General Public License for more details.
%%
%% You should have received a copy of the GNU General Public License along
%% with this program; if not, write to the Free Software Foundation, Inc.,
%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%---------------------------------------------------------------
%% dependencies for programs
dependency(Prog, _, Lic, Req, Prog) :-
executable(Prog, Ver),
license(Prog, Lic, Ver), requirement(Lic, Req).
%% dependencies for libraries
dependency(Prog, Lib, Lic, Req, Lib) :-
executable(Prog, _), library(Lib, Ver),
link(Prog, Lib),
license(Lib, Lic, Ver), requirement(Lic, Req).
%% dependencies for (L)GPL contaminated programs
dependency(Prog, Lib, Lic, provide_sourcecode, Prog) :-
executable(Prog, _),
library(Lib, Ver),
link(Prog, Lib),
license(Lib, Lic, Ver), contaminate(Lic).
dependency(Prog, Lib, Lic, provide_sourcecode, Prog) :-
executable(Prog, _), library(Lib, Ver),
staticlink(Prog, Lib),
license(Lib, Lic, Ver), staticlink_contaminate(Lic).
%% utilities
link(Prog, Lib) :-
staticlink(Prog, Lib).
link(Prog, Lib) :-
dynamiclink(Prog, Lib).
duty(Obj, Req) :-
dependency(_, _, _, Req, Obj).
component(C, V) :-
library(C, V).
component(C, V) :-
executable(C, V).
component(C, V) :-
testtool(C, V).
component(C, V) :-
buildtool(C, V).
not(Goal) :-
call(Goal),!,fail.
not(Goal).
%% entry points: predicates used to request duties and license infos
duties(L) :-
findall((Y,Z), duty(Y, Z), L).
licenses(Prog, Lics) :-
executable(Prog, ProgVer), license(Prog, ProgLic, ProgVer),
findall(Lic, (link(Prog, Dep), library(Dep, Ver), license(Dep, Lic, Ver)), LibLics),
append(LibLics, [ProgLic], Lics).
compatible_licenses(Lics) :-
incompatible_licenses(Group1, Group2),
member(Lic1, Group1),
member(Lic1, Lics),
member(Lic2, Group2),
member(Lic2, Lics),
!,
fail.
compatible_licenses(Lics).
invalid_components(L) :-
findall(C, (component(C, V), not(license(C, _, V))), L).
%% predicates.pl ends here