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
|
# Copyright 2016 Chris Lamb <lamby@debian.org>
#
# This file 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 file 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 file. If not, see <https://www.gnu.org/licenses/>.
import os
import re
import requests
re_line = re.compile(r'(?!#)(?P<pkg>[^\s]+)')
class DebSecSupport(set):
def __init__(self, update_cache):
if update_cache:
self.update_cache()
self.load()
def update_cache(self):
print("Updating {} from {} ...".format(self.cache, self.url))
response = requests.get(self.url, allow_redirects=True)
response.raise_for_status()
with open(self.cache, 'w') as f:
f.write(response.text)
def load(self):
with open(self.cache, 'r') as f:
for x in f.readlines():
m = re_line.match(x)
if m is not None:
self.add(m.group('pkg'))
class UnsupportedPackages(DebSecSupport):
URL = "https://salsa.debian.org/debian/debian-security-support/raw/master/security-support-ended.deb{}"
CACHED_DATA_PATH = "~/.cache/security-support-ended.deb{}"
def __init__(self, debian_version=7, update_cache=True):
self.debian_version = debian_version
self.url = self.URL.format(self.debian_version)
self.cache = os.path.expanduser(self.CACHED_DATA_PATH).format(
self.debian_version,
)
super(UnsupportedPackages, self).__init__(update_cache)
class LimitedSupportPackages(DebSecSupport):
URL = "https://salsa.debian.org/debian/debian-security-support/raw/master/security-support-limited"
CACHED_DATA_PATH = "~/.cache/security-support-limited"
def __init__(self, update_cache=True):
self.url = self.URL
self.cache = os.path.expanduser(self.CACHED_DATA_PATH)
super(LimitedSupportPackages, self).__init__(update_cache)
|