|
|
|
@ -1,11 +1,19 @@
|
|
|
|
|
import os
|
|
|
|
|
from calculate.utils.fs import readFile
|
|
|
|
|
from calculate.variables.datavars import Variable, Namespace, Dependence, \
|
|
|
|
|
StringType, BooleanType, HashType, Calculate
|
|
|
|
|
from calculate.variables.datavars import (
|
|
|
|
|
Variable,
|
|
|
|
|
Namespace,
|
|
|
|
|
StringType,
|
|
|
|
|
BooleanType,
|
|
|
|
|
HashType,
|
|
|
|
|
Calculate
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_ebuild_phase():
|
|
|
|
|
return os.environ.get("EBUILD_PHASE", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_chroot_status():
|
|
|
|
|
"""Detect chroot mode by different mountinfo"""
|
|
|
|
|
pid = os.getpid()
|
|
|
|
@ -19,25 +27,16 @@ def get_chroot_status():
|
|
|
|
|
except Exception:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_system_boot():
|
|
|
|
|
if os.readlink('/proc/self/fd/0') == '/dev/console':
|
|
|
|
|
return True
|
|
|
|
|
else:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
Variable("ebuild_phase", type=StringType,
|
|
|
|
|
source=Calculate(get_ebuild_phase))
|
|
|
|
|
Variable("chroot_status", type=BooleanType,
|
|
|
|
|
source=Calculate(get_chroot_status))
|
|
|
|
|
Variable("system_boot_set", type=BooleanType,
|
|
|
|
|
source=Calculate(is_system_boot))
|
|
|
|
|
|
|
|
|
|
# Переменная, в которую будут помещаться пути к текущим шаблонам.
|
|
|
|
|
Variable("current_template", type=StringType, source="")
|
|
|
|
|
|
|
|
|
|
class CmdlineParams(object):
|
|
|
|
|
"""
|
|
|
|
|
Параметры опции загрузки ядра calculate=
|
|
|
|
|
"""Параметры опции загрузки ядра calculate=
|
|
|
|
|
"""
|
|
|
|
|
# названия параметров
|
|
|
|
|
Calculate = "calculate"
|
|
|
|
@ -56,6 +55,7 @@ class CmdlineParams(object):
|
|
|
|
|
Audio = "audio"
|
|
|
|
|
Clock = "clock"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_cmdline_parameter(paramname):
|
|
|
|
|
cmdLine = "/proc/cmdline"
|
|
|
|
|
for param in readFile(cmdLine).split(" "):
|
|
|
|
@ -64,6 +64,7 @@ def get_cmdline_parameter(paramname):
|
|
|
|
|
return value
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_calculate_cmdline():
|
|
|
|
|
names = (
|
|
|
|
|
CmdlineParams.Locale,
|
|
|
|
@ -89,27 +90,45 @@ def get_calculate_cmdline():
|
|
|
|
|
pass
|
|
|
|
|
return params
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_isoscan_filename():
|
|
|
|
|
value = get_cmdline_parameter(CmdlineParams.IsoscanFile)
|
|
|
|
|
if value is not None:
|
|
|
|
|
return value
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_isoscan_fullpath(base_path, filename):
|
|
|
|
|
if filename:
|
|
|
|
|
return os.path.join(base_path.value, filename.value.lstrip("/"))
|
|
|
|
|
return ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def import_variables():
|
|
|
|
|
Variable("ebuild_phase", type=StringType,
|
|
|
|
|
source=Calculate(get_ebuild_phase))
|
|
|
|
|
|
|
|
|
|
Variable("chroot_status", type=BooleanType,
|
|
|
|
|
source=Calculate(get_chroot_status))
|
|
|
|
|
|
|
|
|
|
Variable("system_boot_set", type=BooleanType,
|
|
|
|
|
source=Calculate(is_system_boot))
|
|
|
|
|
|
|
|
|
|
# Переменная, в которую будут помещаться пути к текущим шаблонам.
|
|
|
|
|
Variable("current_template", type=StringType, source="")
|
|
|
|
|
|
|
|
|
|
with Namespace('cmdline'):
|
|
|
|
|
Variable("calculate", type=HashType.fixed,
|
|
|
|
|
source=Calculate(get_calculate_cmdline))
|
|
|
|
|
|
|
|
|
|
Variable("isoscan_filename", type=StringType,
|
|
|
|
|
source=Calculate(get_isoscan_filename))
|
|
|
|
|
|
|
|
|
|
with Namespace('isoscan'):
|
|
|
|
|
Variable("base_path", type=StringType,
|
|
|
|
|
source="/run/initramfs/isoscan")
|
|
|
|
|
|
|
|
|
|
Variable("full_path", type=StringType,
|
|
|
|
|
source=Calculate(get_isoscan_fullpath,
|
|
|
|
|
'.base_path', 'main.cl.cmdline.isoscan_filename'
|
|
|
|
|
))
|
|
|
|
|
'.base_path',
|
|
|
|
|
'main.cl.cmdline.isoscan_filename'))
|
|
|
|
|