|
|
|
@ -19,6 +19,7 @@ import sys
|
|
|
|
|
import re
|
|
|
|
|
from os import path
|
|
|
|
|
import hashlib
|
|
|
|
|
import glob
|
|
|
|
|
from calculate.lib.datavars import Variable, VariableError, ReadonlyVariable
|
|
|
|
|
from calculate.lib.utils.portage import isPkgInstalled
|
|
|
|
|
from calculate.lib.utils.files import readFile
|
|
|
|
@ -340,14 +341,29 @@ class VariableClGrubImageHash(ReadonlyVariable):
|
|
|
|
|
Контрольная сумма изображения для grub
|
|
|
|
|
"""
|
|
|
|
|
grub_image = "/boot/grub/grub-calculate.png"
|
|
|
|
|
theme_data = "/etc/grub.d/05_theme"
|
|
|
|
|
|
|
|
|
|
def get_image_md5(self, source):
|
|
|
|
|
return hashlib.md5(readFile(source)).hexdigest()
|
|
|
|
|
|
|
|
|
|
def get_config_md5(selfself, source):
|
|
|
|
|
return hashlib.md5(readFile(source, grab=True)).hexdigest()
|
|
|
|
|
|
|
|
|
|
def get_checksum(self):
|
|
|
|
|
data = []
|
|
|
|
|
if path.exists(self.grub_image):
|
|
|
|
|
data.append(self.get_image_md5(self.grub_image))
|
|
|
|
|
else:
|
|
|
|
|
data.append("-")
|
|
|
|
|
if path.exists(self.theme_data):
|
|
|
|
|
data.append(self.get_config_md5(self.theme_data))
|
|
|
|
|
else:
|
|
|
|
|
data.append("-")
|
|
|
|
|
return "".join(data)
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
if self.Get('cl_setup') == 'theme':
|
|
|
|
|
if path.exists(self.grub_image):
|
|
|
|
|
return self.get_image_md5(self.grub_image)
|
|
|
|
|
if self.Get('cl_setup') == 'themes':
|
|
|
|
|
return self.get_checksum()
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
class VariableClGrubImageUpdateSet(VariableClGrubImageHash):
|
|
|
|
@ -357,10 +373,7 @@ class VariableClGrubImageUpdateSet(VariableClGrubImageHash):
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|
if self.Get('cl_setup') == 'themes':
|
|
|
|
|
if path.exists(self.grub_image):
|
|
|
|
|
newmd5 = self.get_image_md5(self.grub_image)
|
|
|
|
|
else:
|
|
|
|
|
newmd5 = ""
|
|
|
|
|
newmd5 = self.get_checksum()
|
|
|
|
|
return "on" if newmd5 != self.Get('cl_grub_image_hash') else "off"
|
|
|
|
|
return "off"
|
|
|
|
|
|
|
|
|
@ -371,10 +384,18 @@ class VariableClSplashImageHash(ReadonlyVariable):
|
|
|
|
|
hash_files = ("/etc/splash/calculate/images/verbose.md5",
|
|
|
|
|
"/etc/splash/calculate/images/silent.md5")
|
|
|
|
|
|
|
|
|
|
cfg_files = "/etc/splash/calculate/*.cfg"
|
|
|
|
|
|
|
|
|
|
def get_config_md5(selfself, source):
|
|
|
|
|
return hashlib.md5(readFile(source, grab=True)).hexdigest()
|
|
|
|
|
|
|
|
|
|
def get_hash_data(self, sources):
|
|
|
|
|
data = []
|
|
|
|
|
for fn in sources:
|
|
|
|
|
data.append(readFile(fn) or "-")
|
|
|
|
|
for fn in glob.glob(self.cfg_files):
|
|
|
|
|
data.append(self.get_config_md5(fn))
|
|
|
|
|
break
|
|
|
|
|
return "".join(data)
|
|
|
|
|
|
|
|
|
|
def get(self):
|
|
|
|
|