1use {once_cell::sync::Lazy, std::collections::BTreeMap};
6
7type DistroVersion = Vec<(&'static str, &'static str)>;
8
9pub static GLIBC_VERSIONS_BY_DISTRO: Lazy<BTreeMap<&'static str, DistroVersion>> =
10 Lazy::new(|| {
11 let mut res: BTreeMap<&'static str, DistroVersion> = BTreeMap::new();
12
13 res.insert(
14 "Fedora",
15 vec![
16 ("16", "2.14"),
17 ("17", "2.15"),
18 ("18", "2.16"),
19 ("19", "2.17"),
20 ("20", "2.18"),
21 ("21", "2.20"),
22 ("22", "2.21"),
23 ("23", "2.22"),
24 ("24", "2.23"),
25 ("25", "2.24"),
26 ("26", "2.25"),
27 ("27", "2.26"),
28 ("28", "2.27"),
29 ("29", "2.28"),
30 ("30", "2.29"),
31 ("31", "2.30"),
32 ("32", "2.31"),
33 ("33", "2.32"),
34 ("34", "2.33"),
35 ("35", "2.34"),
36 ("36", "2.35"),
37 ],
38 );
39
40 res.insert(
41 "RHEL",
42 vec![("6", "2.12"), ("7", "2.17"), ("8", "2.28"), ("9", "2.34")],
43 );
44
45 res.insert(
46 "OpenSUSE",
47 vec![
48 ("11.4", "2.11"),
49 ("12.1", "2.14"),
50 ("12.2", "2.15"),
51 ("12.3", "2.17"),
52 ("13.1", "2.18"),
53 ("13.2", "2.19"),
54 ("42.1", "2.19"),
55 ("42.2", "2.22"),
56 ("42.3", "2.22"),
57 ("15.0", "2.26"),
58 ("15.1", "2.26"),
59 ("15.2", "2.26"),
60 ("15.3", "2.31"),
61 ("15.4", "2.31"),
62 ],
63 );
64
65 res.insert(
66 "Debian",
67 vec![
68 ("6", "2.11"),
69 ("7", "2.13"),
70 ("8", "2.19"),
71 ("9", "2.24"),
72 ("10", "2.28"),
73 ("11", "2.31"),
74 ],
75 );
76
77 res.insert(
78 "Ubuntu",
79 vec![
80 ("12.04", "2.15"),
81 ("14.04", "2.19"),
82 ("16.04", "2.23"),
83 ("18.04", "2.27"),
84 ("18.10", "2.28"),
85 ("19.04", "2.29"),
86 ("19.10", "2.30"),
87 ("20.04", "2.31"),
88 ("20.10", "2.32"),
89 ("22.04", "2.35"),
90 ],
91 );
92
93 res
94 });
95pub static GCC_VERSIONS_BY_DISTRO: Lazy<BTreeMap<&'static str, DistroVersion>> = Lazy::new(|| {
96 let mut res: BTreeMap<&'static str, DistroVersion> = BTreeMap::new();
97
98 res.insert(
99 "Fedora",
100 vec![
101 ("16", "4.6"),
102 ("17", "4.7"),
103 ("18", "4.7"),
104 ("19", "4.8"),
105 ("20", "4.8"),
106 ("21", "4.9"),
107 ("22", "4.9"),
108 ("23", "5.1"),
109 ("24", "6.1"),
110 ("25", "6.2"),
111 ("26", "7.1"),
112 ("27", "7.2"),
113 ("28", "8.0.1"),
114 ("29", "8.2.1"),
115 ("30", "9.0.1"),
116 ("31", "9.2.1"),
117 ("32", "10.0.1"),
118 ("33", "10.3.1"),
119 ("34", "11.2.1"),
120 ("35", "11.2.1"),
121 ("36", "12.0.1"),
122 ],
123 );
124
125 res.insert(
126 "RHEL",
127 vec![("6", "4.4"), ("7", "4.8"), ("8", "8.3.1"), ("9", "11.2.1")],
128 );
129
130 res.insert(
131 "OpenSUSE",
132 vec![
133 ("11.4", "4.5"),
134 ("12.1", "4.6"),
135 ("12.2", "4.7"),
136 ("12.3", "4.7"),
137 ("13.1", "4.8"),
138 ("13.2", "4.8"),
139 ("42.1", "4.8"),
140 ("42.2", "4.8.5"),
141 ("42.3", "4.8.5"),
142 ("15.0", "7.3.1"),
143 ("15.1", "10.2.1"),
144 ("15.2", "10.2.1"),
145 ("15.3", "11.3.0"),
146 ("15.4", "11.3.0"),
147 ],
148 );
149
150 res.insert(
151 "Debian",
152 vec![
153 ("6", "4.1"),
154 ("7", "4.4"),
155 ("8", "4.8"),
156 ("9", "6.3"),
157 ("10", "8.3"),
158 ("11", "10.2.1"),
159 ],
160 );
161
162 res.insert(
163 "Ubuntu",
164 vec![
165 ("12.04", "4.4"),
166 ("14.04", "4.4"),
167 ("16.04", "4.7"),
168 ("18.04", "7.3"),
169 ("20.04", "9.3"),
170 ("20.10", "10.2"),
171 ("22.04", "12"),
172 ],
173 );
174
175 res
176});
177
178pub fn find_minimum_distro_version(
180 version: &version_compare::Version,
181 distro_versions: &BTreeMap<&'static str, DistroVersion>,
182) -> Vec<String> {
183 let mut res: Vec<String> = Vec::new();
184
185 for (distro, dv) in distro_versions {
186 let mut found = false;
187
188 for (distro_version, version_version) in dv {
189 let version_version = version_compare::Version::from(version_version)
190 .expect("unable to parse distro version");
191
192 if &version_version >= version {
193 found = true;
194 res.push(format!("{} {}", distro, distro_version));
195 break;
196 }
197 }
198
199 if !found {
200 res.push(format!("No known {} versions supported", distro));
201 }
202 }
203
204 res
205}