-#!/bin/env python3
+#!/usr/bin/env python3
import os
import sys
import subprocess
import shutil
import utils
+import database
from conf import conf
from conf import sf
import exceptions
import loop
-import solution
def all():
base()
- gen_nbscript()
parse_kconfig()
gen_requred()
- if conf.gen_all_solution_oninit:
- solution.generate()
+ # check if database is initialized
+ database.database()
def base():
- try: os.mkdir(sf(conf.build_folder))
+ print('Initialize base...')
+ try:
+ os.mkdir(sf(conf.build_folder))
+ except FileExistsError:
+ pass
+ try:
+ os.mkdir(sf(conf.configurations_folder))
+ except FileExistsError:
+ pass
+ try:
+ os.mkdir(sf(conf.log_folder))
except FileExistsError:
pass
def parse_kconfig():
"Execute parse_kconfig in linux_sources directory."
+ if os.path.isfile(sf(conf.symbol_map_file)) and \
+ os.path.isfile(sf(conf.rules_file)) and \
+ os.path.isfile(sf(conf.variable_count_file)):
+ print('Warning: parse_kconfig not executed. Files already exists.')
+ return
+ print('Executing parse_kconfig...')
env = dict(os.environ)
wd = os.getcwd()
os.chdir(sf(conf.linux_sources))
def gen_requred():
- "Generates required depenpency from .config file in linux source tree."
+ "Generates required depenpency from dot_config file."
+ print('Generating required configuration...')
- if not os.path.isfile(sf(conf.linux_dot_config)):
- raise exceptions.MissingFile(sf(conf.linux_dot_config),
- 'Generate initial configuration. Execute make defconfig in linux folder. Or use make menuconfig and change configuration.')
+ if not os.path.isfile(sf(conf.dot_config)):
+ raise exceptions.MissingFile(sf(conf.dot_config),
+ 'Generate fixed configuration. Use make dot_config.')
utils.build_symbol_map() # Ensure smap existence
- srmap = {value:key for key, value in utils.smap.items()}
+ srmap = {value:key for key, value in utils.smap.items()} # swap dictionary
- shutil.copy(sf(conf.linux_dot_config), sf(conf.dot_config_back_file))
+ shutil.copy(sf(conf.dot_config), sf(conf.dot_config_back_file))
- with open(sf(conf.linux_dot_config), 'r') as f:
+ with open(sf(conf.dot_config), 'r') as f:
with open(sf(conf.required_file), 'w') as freq:
- with open(sf(conf.dot_config_fragment_file), 'w') as fconf:
- for line in f:
- if (line[0] == '#') or (not '=' in line):
- continue
- indx = line.index('=')
- if (line[7:indx] == "MODULES"): # skip if modules set
- raise exceptions.ConfigurationError("Initial kernel configuration must have MODULES disabled.")
- if (line[indx + 1] == 'y'):
- freq.write(str(srmap[line[7:indx]]) + "\n")
- elif (line[indx + 1] == 'n' or line[indx + 1] == 'm'):
- freq.write("-" + str(srmap[line[7:indx]]) + "\n")
- else:
- fconf.write(line);
- freq.write("-" + str(srmap["MODULES"]) + "\n"); # force modules no
-
-
-def gen_nbscript():
- if os.path.isfile(sf(conf.nbscript)):
- print("Warning: file " + conf.nbscript +
- " already exists. Generation skipped.")
- return
+ for line in f:
+ if (line[0] == '#') or (not '=' in line):
+ continue
+ indx = line.index('=')
+ if (line[indx + 1] == 'y'):
+ if line[7:indx] == "MODULES": # exception if modules set
+ raise exceptions.ConfigurationError("Fixed kernel configuration must have MODULES disabled.")
+ freq.write(str(srmap[line[7:indx]]) + "\n")
+ elif (line[indx + 1] == 'n' or line[indx + 1] == 'm'):
+ freq.write("-" + str(srmap[line[7:indx]]) + "\n")
- with open(sf(conf.nbscript), 'w') as f:
- f.write('# generated novaboot script. Please don\'t edit unless you know what are you doing.\n')
- f.write('load ' + sf(conf.linux_image) + ' console=ttyS0,115200\n')
- f.write('load ' + sf(conf.buildroot_initram) + '\n')
#################################################################################