mirror-checker/kernel.py

31 lines
929 B
Python

"""
Contains Kernel class
"""
import requests
from distro import Distro
from shared import CSC_MIRROR
class Kernel(Distro):
"""Kernel class"""
@staticmethod
def __get_line_count(checksum_file_url):
"""Get Kernel line count of checksum file"""
response_text = requests.get(checksum_file_url).text
return len(response_text.split('\n'))
@staticmethod
def name():
"""Get name of Kernel"""
return "Kernel"
@staticmethod
def check():
"""Check if Kernel packages are up-to-date"""
official_line_count = Kernel.__get_line_count(
"https://mirrors.edge.kernel.org/pub/linux/kernel/next/sha256sums.asc")
csc_line_count = Kernel.__get_line_count(
f"{CSC_MIRROR}kernel.org/linux/kernel/next/sha256sums.asc")
# A new update on a certain day adds 2 new lines
return official_line_count <= csc_line_count + 2