def module_action(export_dir, arg): strip = 0 env.display(env.HEADER_OK, 'action breplace ' + arg['id'], env.OPTION_NONE) id = arg['id'].split('::', 1) filepath = id[0] label = id[1] tmpfilepath = env.temporary(env.OPTION_FILE) srcf = open(export_dir + '/' + filepath, 'r') dstf = open(tmpfilepath, 'w') line = srcf.readline() startpattern = re.compile(".*[[]block\:\:" + label + "[]].*") endpattern = re.compile(".*[[]/block\:\:" + label + "[]].*") while line != "": if strip == 0: if startpattern.match(line) != None: strip = 1 dstf.write(arg['data']) if strip != 1: dstf.write(line) if strip == 1: if endpattern.match(line) != None: strip = 2 line = srcf.readline() dstf.close() srcf.close() env.copy(tmpfilepath, export_dir + '/' + filepath, env.OPTION_NONE) env.remove(tmpfilepath, env.OPTION_NONE) if strip == 0: env.display(env.HEADER_ERROR, 'no block ' + label + ' in file ' + filepath, env.OPTION_NONE) return -1 return 0
def install(): input = None # warn the user before performing any action. warning() # display some stuff. env.display(env.HEADER_OK, "installing kaneton binaries on the boot device", env.OPTION_NONE) env.copy(env._KANETON_, env._IMAGE_, env.OPTION_NONE)
def build(): # warn the user before performing any action. warning() # display some stuff. env.display(env.HEADER_NONE, "", env.OPTION_NONE) env.display(env.HEADER_OK, "initializing the boot device", env.OPTION_NONE) # for each boot mode, initialize the boot device. if (env._BOOT_MODE_ == "peripheral") or (env._BOOT_MODE_ == "network"): env.push(env._UDEVICE_, env.pull(g_image, env.OPTION_NONE), env.OPTION_NONE) elif env._BOOT_MODE_ == "image": env.copy(g_image, env._IMAGE_, env.OPTION_NONE) else: env.display(env.HEADER_ERROR, "unknown boot mode '" + env._BOOT_MODE_ + "'", env.OPTION_NONE) sys.exit(42)
def install(): component = None # warn the user before performing any action. warning() # display some stuff. env.display(env.HEADER_NONE, "", env.OPTION_NONE) env.display(env.HEADER_OK, "installing kaneton binaries on the boot device", env.OPTION_NONE) # generates the grub menu file. menu() # depending on the boot mode and boot device, install the kaneton binaries # and the grub menu file. if env._BOOT_MODE_ == "peripheral": if env.load(g_menu, env._MDEVICE_, "/boot/grub/menu.lst", env.OPTION_DEVICE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: if env.load(component, env._MDEVICE_, "/modules/", env.OPTION_DEVICE) != 0: env.display(env.HEADER_ERROR, "unable to load the component '" + component + "'", env.OPTION_NONE) sys.exit(42) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) elif env._BOOT_MODE_ == "network": if env.load(g_menu, env._MDEVICE_, "/boot/grub/menu.lst", env.OPTION_DEVICE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: env.copy(component, env._TFTP_DIRECTORY_, env.OPTION_NONE) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) elif env._BOOT_MODE_ == "image": if env.load(g_menu, env._IMAGE_, "/boot/grub/menu.lst", env.OPTION_IMAGE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: if env.load(component, env._IMAGE_, "/modules/", env.OPTION_IMAGE) != 0: env.display(env.HEADER_ERROR, "unable to load the component '" + component + "'", env.OPTION_NONE) sys.exit(42) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) else: env.display(env.HEADER_ERROR, "unknown boot mode '" + env._BOOT_MODE_ + "'", env.OPTION_NONE) sys.exit(42)
def install(): component = None # warn the user before performing any action. warning() # display some stuff. env.display(env.HEADER_NONE, "", env.OPTION_NONE) env.display(env.HEADER_OK, "installing kaneton binaries on the boot device", env.OPTION_NONE) # generates the grub menu file. menu() # depending on the boot mode and boot device, install the kaneton binaries # and the grub menu file. if env._BOOT_MODE_ == "peripheral": if env.load(g_menu, env._MDEVICE_, "/boot/grub/menu.lst", env.OPTION_DEVICE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: if env.load(component, env._MDEVICE_, "/modules/", env.OPTION_DEVICE) != 0: env.display( env.HEADER_ERROR, "unable to load the component '" + component + "'", env.OPTION_NONE) sys.exit(42) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) elif env._BOOT_MODE_ == "network": if env.load(g_menu, env._MDEVICE_, "/boot/grub/menu.lst", env.OPTION_DEVICE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: env.copy(component, env._TFTP_DIRECTORY_, env.OPTION_NONE) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) elif env._BOOT_MODE_ == "image": if env.load(g_menu, env._IMAGE_, "/boot/grub/menu.lst", env.OPTION_IMAGE) != 0: env.display(env.HEADER_ERROR, "unable to load the menu.lst file", env.OPTION_NONE) sys.exit(42) for component in g_components: if not env.path(component, env.OPTION_EXIST): env.display(env.HEADER_ERROR, " " + component, env.OPTION_NONE) else: if env.load(component, env._IMAGE_, "/modules/", env.OPTION_IMAGE) != 0: env.display( env.HEADER_ERROR, "unable to load the component '" + component + "'", env.OPTION_NONE) sys.exit(42) env.display(env.HEADER_OK, " " + component, env.OPTION_NONE) else: env.display(env.HEADER_ERROR, "unknown boot mode '" + env._BOOT_MODE_ + "'", env.OPTION_NONE) sys.exit(42)
def module_action(export_dir, arg): env.display(env.HEADER_OK, 'action freplace ' + arg['src'] + ' to ' + arg['dst'], env.OPTION_NONE) env.copy(export_dir + '/' + arg['src'], export_dir + '/' + arg['dst'], env.OPTION_NONE) return 0
def module_action(export_dir, arg): env.display(env.HEADER_OK, 'action localexport', env.OPTION_NONE) env.copy(env._SOURCE_DIR_, export_dir, env.OPTION_NONE) return 0