def create_repoint_bundle_script(self): """Function that generates script for repointing the RELEASE files in the bundle to their current location """ if platform != 'win32': rs_fp = open( installSynApps.join_path('__temp__', 'repoint_bundle.sh'), 'w') rs_fp.write('#!/bin/bash\n\n') rs_fp.write( '#\n# Script auto-generated by installSynApps on {}\n#\n\n'. format(datetime.datetime.now())) rs_fp.write( 'BUNDLE_LOC=$(pwd)\nEPICS_BASE=$BUNDLE_LOC/base\nSUPPORT=$BUNDLE_LOC/support\n\n' ) rs_fp.write( 'sed -i "s|^EPICS_BASE=.*|EPICS_BASE=$EPICS_BASE|g" "$SUPPORT/configure/RELEASE"\n' ) rs_fp.write( 'sed -i "s|^SUPPORT=.*|SUPPORT=$SUPPORT|g" "$SUPPORT/configure/RELEASE"\n\n' ) rs_fp.write('cd $SUPPORT\n') rs_fp.write('make release\n\n') rs_fp.write( 'sed -i "s|^EPICS_BASE=.*|EPICS_BASE=$EPICS_BASE|g" "$SUPPORT/areaDetector/configure/RELEASE_PRODS.local"\n' ) rs_fp.write( 'sed -i "s|^SUPPORT=.*|SUPPORT=$SUPPORT|g" "$SUPPORT/areaDetector/configure/RELEASE_SUPPORT.local"\n' ) os.chmod(installSynApps.join_path('__temp__', 'repoint_bundle.sh'), 0o755) rs_fp.close()
def cleanup_tar_staging(self, filename, module=None): """Function that cleans up tar staging point, and closes readme file. Parameters ---------- filename : str file path string module : InstallModule Optional install module to create single module add-on package Returns ------- int Return code of tar creation call. """ LOG.debug('Generating README file with module version and append instructions...') shutil.copy(installSynApps.join_path(self.output_location, 'README_{}.txt'.format(filename)), installSynApps.join_path('__temp__', 'README_{}.txt'.format(filename))) LOG.write('Tarring...') out = subprocess.call(['tar', 'czf', filename + '.tgz', '-C', '__temp__', '.']) if out < 0: return out os.rename(filename + '.tgz', installSynApps.join_path(self.output_location, filename + '.tgz')) LOG.write('Done. Wrote tarball to {}.'.format(self.output_location)) LOG.write('Name of tarball: {}'.format(installSynApps.join_path(self.output_location, filename + '.tgz'))) shutil.rmtree('__temp__') return out
def create_single_module_tarball(self, filename, module, with_sources): """Function responsible for creating a tarball for a single module. Used to add modules to existing distributions. Parameters ---------- filename : str Name of output file module : InstallModule The module to add to the package """ readme_path = installSynApps.join_path( self.output_location, 'README_{}.txt'.format(filename)) self.setup_tar_staging() os.rename(installSynApps.join_path('__temp__', 'epicsbundle-1'), '__temp__/{}'.format(module.name)) self.grab_module('__temp__/{}'.format(module.name), module, include_src=with_sources) self.file_generator.generate_readme(filename, installation_type='addon', readme_path=readme_path, module=module) result = self.cleanup_tar_staging(filename, module=module) return result
def generate_unique_cmd(self, action): LOG.debug('Generating template unique.cmd from ioc environment...') ioc_path = installSynApps.join_path(self.ioc_template_dir, action.ioc_name) unique_fp = open(installSynApps.join_path(ioc_path, 'unique.cmd'), 'w') unique_fp.write( '###############################################################\n' ) unique_fp.write( '# installSynApps Auto-Generated IOC Template{:<19}#\n'.format('')) unique_fp.write( '# Meant for use with bundles running ADCore {:<19} #\n'.format( self.install_config.get_core_version())) unique_fp.write('# Generated: {:<53}#\n'.format( str(datetime.datetime.now()))) unique_fp.write( '###############################################################\n\n\n' ) for env_var in action.epics_environment.keys(): unique_fp.write('epicsEnvSet("{}",{}"{}")\n'.format( env_var, ' ' * (32 - len(env_var)), action.epics_environment[env_var])) unique_fp.close()
def check_module_dependencies(self, module): """Function that checks inter-module dependencies Grabs dependencies form the configure/RELEASE file. Modules that are under areaDetector get ADSupport and ADCore added as dependencies as well. Parameters ---------- module : InstallModule install module for which to check dependencies """ release_path = installSynApps.join_path(module.abs_path, installSynApps.join_path('configure', 'RELEASE')) if os.path.exists(release_path): release_file = open(release_path, 'r') lines = release_file.readlines() release_file.close() for line in lines: if not line.startswith('#') and '=' in line: line = line.strip() line = re.sub(' +', '', line) dep = line.split('=')[0] if dep not in module.dependencies and dep not in self.dependency_ignore_list and dep != module.name: module.dependencies.append(dep) if dep == 'AREA_DETECTOR' or (module.rel_path.startswith('$(AREA_DETECTOR)') and module.name != 'ADSUPPORT' and module.name != 'ADCORE'): module.dependencies.append('ADSUPPORT') module.dependencies.append('ADCORE')
def create_dummy_ioc(self, action): LOG.debug("-------------------------------------------") LOG.debug("Setup process for dummy IOC template " + action.ioc_name) LOG.debug("-------------------------------------------") ioc_top_path, executable_path, iocBoot_path = self.find_paths_for_action( action.ioc_type) if executable_path is None: LOG.debug( 'Warning - Could not find binary for {}, skipping...'.format( action.ioc_type)) return elif ioc_top_path is None or iocBoot_path is None: LOG.debug( 'WARNING - Could not find ioc top and iocBoot folder, for {}. Skipping...' .format(action.ioc_type)) if os.path.exists( installSynApps.join_path(self.ioc_template_dir, action.ioc_name)): shutil.rmtree( installSynApps.join_path(self.ioc_template_dir, action.ioc_name)) LOG.debug('Generating template IOC for {}...'.format(action.ioc_type)) ioc_path = installSynApps.join_path(self.ioc_template_dir, action.ioc_name) os.mkdir(ioc_path) os.mkdir(installSynApps.join_path(ioc_path, 'autosave')) current_base_len = 0 current_base = None for file in os.listdir(iocBoot_path): next = installSynApps.join_path(iocBoot_path, file) if os.path.isfile(next) and file.startswith('st'): fp = open(next, 'r') lines = fp.readlines() fp.close() if len(lines) > current_base_len: current_base = next current_base_len = len(lines) if current_base is None: LOG.debug( 'ERROR - Could not fine suitable st_base file. Aborting...') return self.generate_st_cmd(action, executable_path, current_base) self.generate_unique_cmd(action) self.generate_env_paths(ioc_top_path, iocBoot_path, ioc_path, action) self.grab_dependencies_from_bundle(ioc_path, iocBoot_path) self.create_config_file(action) #self.make_ignore_files(action) TODO LOG.debug('Done.')
def get_lib_path_for_module(self, module_path, architecture, delimeter): """Generates a library path for specific module """ bin_loc = installSynApps.join_path(module_path, 'bin') bin_loc = installSynApps.join_path(bin_loc, architecture) lib_loc = installSynApps.join_path(module_path, 'lib') lib_loc = installSynApps.join_path(lib_loc, architecture) return bin_loc + delimeter + lib_loc + delimeter
def create_config_file(self, action): LOG.debug('Generating config file for use with procServ...') ioc_path = installSynApps.join_path(self.ioc_template_dir, action.ioc_name) config_fp = open(installSynApps.join_path(ioc_path, 'config'), 'w') config_fp.write('NAME={}\nPORT={}\nUSER=softioc\nHOST={}\n'.format( action.ioc_name, '4000', 'localhost')) config_fp.close()
def create_tarball(self, filename, flat_format, with_sources): """Function responsible for creating the tarball given a filename. Parameters ---------- filename : str name for output tarball and readme file flat_format=True : bool flag to toggle generating flat vs. non-flat binaries with_sources : bool flag to include non-build artefact files with bundle Returns ------- out : int 0 if success <0 if failure """ readme_path = installSynApps.join_path( self.output_location, 'README_{}.txt'.format(filename)) self.setup_tar_staging() self.grab_base('__temp__', include_src=with_sources) support_top = '__temp__' if not flat_format: LOG.write('Non-flat output binary structure selected.') support_top = installSynApps.join_path('__temp__', 'support') os.mkdir(support_top) ad_top = installSynApps.join_path(support_top, 'areaDetector') os.mkdir(ad_top) for module in self.install_config.get_module_list(): if (module.name in self.required_in_package or module.package == "YES" or (with_sources and module.build == "YES")) and not module.name == "EPICS_BASE": if module.rel_path.startswith('$(AREA_DETECTOR)'): self.grab_module(ad_top, module, include_src=with_sources) else: self.grab_module(support_top, module, include_src=with_sources) self.file_generator.generate_readme(filename, installation_type='bundle', readme_path=readme_path) self.ioc_gen.init_template_dir() self.ioc_gen.generate_dummy_iocs() if with_sources: self.create_repoint_bundle_script() result = self.cleanup_tar_staging(filename) return result
def grab_dependencies_from_bundle(self, ioc_path, iocBoot_path): LOG.debug('Collecting additional iocBoot files from bundle...') for file in os.listdir(iocBoot_path): target = installSynApps.join_path(iocBoot_path, file) if os.path.isfile(target): if not file.startswith( ('Makefile', 'st', 'test', 'READ', 'dll', 'envPaths')) and not file.endswith(('.xml', '.txt')): shutil.copyfile(target, installSynApps.join_path(ioc_path, file))
def update_support_macros(self): """Updates the macros in the support configuration files. """ support_config = installSynApps.join_path(self.install_config.support_path, "configure") self.update_macros(support_config, False, False) # Some modules don't correctly have their RELEASE files updated by make release. Fix that here for module in self.install_config.get_module_list(): if module.clone == 'YES' and module.build == 'YES': rel = installSynApps.join_path(module.abs_path, 'configure', 'RELEASE') if os.path.exists(rel): LOG.write('Updating RELEASE file for {}...'.format(module.name)) self.update_macros(rel, True, True, single_file=True)
def create_opi_tarball(self): """Function that collects autoconverted .opi files from epics_dir. OPI screens are saved in output_location/ad_opis and creats a tarball. Returns ------- int 0 if suceeded, nonzero otherwise """ opi_base_dir = installSynApps.join_path(self.output_location, '__opis_temp__') opi_dir = installSynApps.join_path(opi_base_dir, 'opis') try: os.mkdir(opi_base_dir) os.mkdir(opi_dir) except OSError: LOG.write('Error creating ' + opi_dir + ' directory', ) for (root, _, files) in os.walk(self.install_config.install_location, topdown=True): for name in files: if '.opi' in name and 'autoconvert' in root: file_name = installSynApps.join_path(root, name) try: shutil.copy(file_name, opi_dir) except OSError: LOG.debug("Can't copy {} to {}".format( file_name, opi_dir)) opi_tarball_basename = 'opis_{}'.format( self.install_config.get_core_version()) opi_tarball = opi_tarball_basename counter = 1 while os.path.exists( installSynApps.join_path(self.output_location, opi_tarball + '.tgz')): opi_tarball = opi_tarball_basename + '_({})'.format(counter) counter = counter + 1 out = subprocess.call( ['tar', 'czf', opi_tarball + '.tgz', '-C', opi_base_dir, '.']) shutil.rmtree(opi_base_dir) os.rename( opi_tarball + '.tgz', installSynApps.join_path(self.output_location, opi_tarball + '.tgz')) return out
def create_bundle_cleanup_tool(self): """Simple function that spawns basic scripts used to remove unused bundles. """ if os.path.exists(self.output_location): if platform == 'win32': cleanup_tool_path = installSynApps.join_path(self.output_location, 'cleanup.bat') cleanup_tool = open(cleanup_tool_path, 'w') cleanup_tool.write('@echo OFF\n\ndel *.tgz\ndel *.txt\n\n') cleanup_tool.close() else: cleanup_tool_path = installSynApps.join_path(self.output_location, 'cleanup.sh') cleanup_tool = open(cleanup_tool_path, 'w') cleanup_tool.write('#!/bin/bash\n\nrm *.tgz\nrm *.txt\n\n') os.chmod(cleanup_tool_path, 0o755) cleanup_tool.close()
def generate_remake_sources(self): """Function that creates a bash/batch script for regenerating binaries from sources """ LOG.debug('Autogenerating regenerateSources bash script') regenerate_fp = open(installSynApps.join_path(self.install_config.install_location, 'autogenerated', 'regenerateSources.sh'), 'w+') regenerate_fp.write('#!/bin/bash\n\ngit clone https://github.com/NSLS-II/installSynApps\n') isa_version, isa_commit_hash = installSynApps.find_isa_version() regenerate_fp.write('cd installSynApps\n') if isa_commit_hash is not None: regenerate_fp.write('git checkout {}\n'.format(isa_commit_hash)) else: regenerate_fp.write('git checkout -q {}\n'.format(isa_version)) abs_loc = os.path.abspath(self.install_config.install_location) regenerate_fp.write('./installCLI.py -i {} -c {} -p -y\n\n'.format(installSynApps.join_path(abs_loc, 'regenerated'), installSynApps.join_path(abs_loc, 'build-config'))) regenerate_fp.close()
def generate_build_config(self, top_location, module, readme_fp): """Function that writes the build configuration used to create the source/binary package. Parameters ---------- top_location : str Output location of the package module : installSynApps.DataModel.install_module.InstallModule If not None, module being packaged as add on readme_fp : file pointer Open file pointer for README file. """ if module is None: LOG.write('Copying build configuration into bundle.') writer = WRITER.ConfigWriter(self.install_config) build_config_dir = installSynApps.join_path( top_location, 'build-config') writer.write_install_config(filepath=build_config_dir, overwrite_existing=True) self.write_readme_heading('Build environment version information', readme_fp) else: self.write_readme_heading('Implementing add on in exisitng bundle', readme_fp) readme_fp.write( 'This add on tarball contains a folder with a compiled version of {}.\n' .format(module.name)) readme_fp.write( 'To use it with an existing bundle, please copy the folder into {} in the target bundle.\n' .format(module.rel_path)) readme_fp.write( 'It is also recommended to edit the build-config for the bundle to reflect the inclusion of this module.\n\n' )
def parse_custom_build_scripts(self, install_config): """Function that checks for custom build scripts Parameters ---------- install_config : InstallConfiguration Checks for custom build scripts for install modules """ # make sure the build script path is absolute build_script_folder = os.path.abspath(installSynApps.join_path(self.configure_path, 'customBuildScripts')) if os.path.exists(build_script_folder): for module in install_config.get_module_list(): for file in os.listdir(build_script_folder): if file.startswith(module.name): module.custom_build_script_path = installSynApps.join_path(build_script_folder, file)
def add_missing_support_macros(self): """Function that appends any paths to the support/configure/RELEASE file that were not in it originally """ to_append_commented = [] to_append = [] for module in self.install_config.get_module_list(): if module.clone == "YES": was_found = False rel_file = open(installSynApps.join_path(self.install_config.support_path, "configure/RELEASE"), "r") line = rel_file.readline() while line: if line.startswith(module.name + "="): was_found = True line = rel_file.readline() if not was_found and not module.name in self.add_to_release_blacklist and not module.name.startswith("AD"): if module.build == "YES": to_append.append([module.name, module.rel_path]) else: to_append_commented.append([module.name, module.rel_path]) rel_file.close() app_file = open(self.install_config.support_path + "/configure/RELEASE", "a") for mod in to_append: LOG.debug('Adding {} path to support/configure/RELEASE'.format(mod[0])) app_file.write("{}={}\n".format(mod[0], mod[1])) for mod in to_append_commented: LOG.debug('Adding commented {} path to support/configure/RELEASE'.format(mod[0])) app_file.write("#{}={}\n".format(mod[0], mod[1])) app_file.close()
def inject_to_file(self, injector_file): """Function that injects contents of specified file into target First, convert to absolute path given the install config. Then open it in append mode, then write all uncommented lines in the injector file into the target, and then close both Parameters ---------- injector_file_path : InjectorFile object representing injector file """ target_path = injector_file.target if target_path is None or len(target_path) == 0: return target_path = self.install_config.convert_path_abs(target_path) target_file = os.path.basename(target_path) if (not os.path.exists(target_path)): return if target_file.startswith("EXAMPLE_"): target_path_no_example = installSynApps.join_path(os.path.dirname(target_path), target_file[8:]) if os.path.exists(target_path): os.rename(target_path, target_path_no_example) target_path = target_path_no_example target_fp = open(target_path, "a") target_fp.write("\n# ------------The following was auto-generated by installSynApps-------\n\n") if injector_file.contents is not None: LOG.debug('Injecting into {}'.format(target_path)) target_fp.write(injector_file.contents) LOG.debug(injector_file.contents, force_no_timestamp=True) LOG.debug('Injection Done.') target_fp.write("\n# --------------------------Auto-generated end----------------------\n") target_fp.close()
def generate_uninstall(self): """Function that generates an uninstall file based on currently loaded install_config """ LOG.debug('Autogenerating bash uninstall script') uninstall_fp = open(installSynApps.join_path(self.install_config.install_location, "/autogenerated/uninstall.sh"), "w+") uninstall_fp.write("#!/bin/bash\n") uninstall_fp.write(self.message) modules = self.install_config.get_module_list() modules.reverse() for module in modules: if module.build == "YES": uninstall_fp.write("{}={}\n".format(module.name, module.abs_path)) for module in modules: if module.build == "YES": uninstall_fp.write("cd ${}\n".format(module.name)) uninstall_fp.write("make clean uninstall\n") uninstall_fp.write("make clean uninstall\n") modules.reverse() uninstall_fp.close()
def generate_st_cmd(self, action, executable_path, st_base_path): LOG.debug( 'Generating st.cmd using base file:\n{}'.format(st_base_path)) ioc_path = installSynApps.join_path(self.ioc_template_dir, action.ioc_name) lib_path = self.get_lib_path_str(action) # Create base st.cmd, add call to executable st = self.initialize_st_base_file(ioc_path, lib_path, executable_path) LOG.debug('Writing base st.cmd file') # Define envPaths st.write('< envPaths\n\n') # Open existing st.cmd base file st_base_fp = open(st_base_path, 'r') # Read through the lines, add a 'unique.cmd' call after all env sets, and add envSet calls to action environment lines = st_base_fp.readlines() wrote_unique = False for line in lines: if line.startswith( '#!') or 'unique.cmd' in line or 'envPaths' in line: pass elif line.startswith('#'): st.write(line) elif 'Config(' in line and not wrote_unique: st.write('\n< unique.cmd\n\n') st.write(line) wrote_unique = True elif line.startswith('epicsEnvSet'): action.add_to_environment(line) st.write(line) else: st.write(line) st_base_fp.close() st.close() # Collect environment variables set in any other files self.grab_additional_env(action, st_base_path) # Make st.cmd executable. os.chmod(installSynApps.join_path(ioc_path, "st.cmd"), 0o755)
def generate_env_paths(self, ioc_top_path, ioc_boot_path, target, action): LOG.debug('Generating template envPaths based on compiled binaries...') ioc_path = installSynApps.join_path(self.ioc_template_dir, action.ioc_name) envPaths_fp = open(installSynApps.join_path(ioc_path, 'envPaths'), 'w') arch = 'linux-x86_64' if platform == 'win32': arch = 'windows-x64-static' envPaths_fp.write( '# Relative envPaths file auto-generated by installSynApps\n#\n') envPaths_fp.write( '# The BUNDLE_LOC env variable is set in st.cmd. Please edit to top bundle location\n#\n' ) envPaths_fp.write('epicsEnvSet("ARCH", "{}")\n'.format(arch)) envPaths_fp.write('epicsEnvSet("TOP", "{}")\n'.format(ioc_top_path)) base_path = installSynApps.join_path('$(BUNDLE_LOC)', 'base') envPaths_fp.write('epicsEnvSet("EPICS_BASE",{}"{}")\n'.format( (' ' * 14), base_path)) support_path = "$(BUNDLE_LOC)" support_path = installSynApps.join_path(support_path, "support") envPaths_fp.write('epicsEnvSet("SUPPORT",{}"{}")\n\n'.format( (' ' * 17), support_path)) for dir in os.listdir(self.install_config.support_path): mod_path = installSynApps.join_path( self.install_config.support_path, dir) if os.path.isdir(mod_path) and dir not in [ 'base', 'configure', 'utils', 'documentation', '.git', 'lib', 'bin' ]: mod_path = installSynApps.join_path('$(SUPPORT)', dir) envPaths_fp.write('epicsEnvSet("{}",{}"{}")\n'.format( self.get_env_paths_name(dir), ' ' * (24 - len(self.get_env_paths_name(dir))), mod_path)) envPaths_fp.write('\n') for dir in os.listdir(self.install_config.ad_path): mod_path = installSynApps.join_path(self.install_config.ad_path, dir) if os.path.isdir(mod_path) and dir not in [ 'configure', 'docs', 'documentation', 'ci', '.git', '' ]: mod_path = installSynApps.join_path('$(AREA_DETECTOR)', dir) envPaths_fp.write('epicsEnvSet("{}",{}"{}")\n'.format( self.get_env_paths_name(dir), ' ' * (24 - len(self.get_env_paths_name(dir))), mod_path)) envPaths_fp.close()
def initialize_dir(self): """Function that creates an autogenerated directory """ autogenerated_dir = installSynApps.join_path(self.install_config.install_location, "autogenerated") if os.path.exists(autogenerated_dir): LOG.debug('Removing existing autogenerated script directory') shutil.rmtree(autogenerated_dir) LOG.debug('Creating autogenerated script directory') os.mkdir(autogenerated_dir)
def initialize_logger(): """Function for initializing log-file writing in addition to stdout output """ global _LOG_FILE try: if not os.path.exists('logs'): os.mkdir('logs') _LOG_FILE = open(installSynApps.join_path('logs', _LOG_FILE_PATH), 'w') except OSError: write('Failed to initialize log file...')
def write_custom_build_scripts(self, filepath): """Helper Function for writing custom build scripts of modules Parameters ---------- filepath : str Path into which we wish to save configuration """ build_script_out = installSynApps.join_path(filepath, 'customBuildScripts') for module in self.install_config.get_module_list(): old_script = module.custom_build_script_path if old_script is not None: if os.path.exists(old_script) and not os.path.exists(installSynApps.join_path(build_script_out, os.path.basename(old_script))): LOG.debug('Copying module custom build script: {}'.format(old_script)) try: shutil.copyfile(old_script, installSynApps.join_path(build_script_out, os.path.basename(old_script))) except: LOG.debug('Encountered error copying: {}'.format(old_script)) else: LOG.debug('Could not find build script at: {}'.format(old_script))
def convert_path_abs(self, rel_path): """Function that converts a given modules relative path to an absolute path If the macro name can be found in the list of accounted for modules, replace it with that module's absolute path Parameters ---------- rel_path : str The relative installation path for the given module Returns ------- str The absolute installation path for the module. (Macros are replaced) """ temp = rel_path.split('/', 1)[-1] if "$(INSTALL)" in rel_path and self.install_location != None: return installSynApps.join_path(self.install_location, temp) elif "$(EPICS_BASE)" in rel_path and self.base_path != None: return installSynApps.join_path(self.base_path, temp) elif "$(SUPPORT)" in rel_path and self.support_path != None: return installSynApps.join_path(self.support_path, temp) elif "$(AREA_DETECTOR)" in rel_path and self.ad_path != None: return installSynApps.join_path(self.ad_path, temp) elif "$(MOTOR)" in rel_path and self.motor_path != None: return installSynApps.join_path(self.motor_path, temp) elif "$(" in rel_path: macro_part = rel_path.split(')')[0] rel_to = macro_part.split('(')[1] rel_to_module = self.get_module_by_name(rel_to) if rel_to_module is not None: return installSynApps.join_path(rel_to_module.abs_path, temp) return rel_path
def initialize_st_base_file(self, ioc_path, lib_path, executable_path): """Function responsible for handling executable path injection, and base file creation """ # Setup st.cmd to be executable, rest will be in st_base.cmd LOG.debug('Setting up executable st.cmd with library path') st_exe = open(installSynApps.join_path(ioc_path, 'st.cmd'), 'w+') executable_path_rel = '$BUNDLE_LOC/support/{}'.format( executable_path.split('support/')[1]) if platform == 'win32': st_exe.write('@echo OFF\n\n{}\n\n{} st_base.cmd\n'.format( lib_path, executable_path_rel)) else: st_exe.write('#!/bin/bash\n\n{}\n\n{} st_base.cmd\n'.format( lib_path, executable_path_rel)) st_exe.close() st = open(installSynApps.join_path(ioc_path, "st_base.cmd"), "w+") return st
def generate_license(self, bundle_path): """Function for generating license file for bundle Parameters ---------- bundle_path : str path to the temp staging location for bundle before tarring """ fp = open(installSynApps.join_path(bundle_path, 'LICENSE'), 'w') #TODO - Allow for specifying license type fp.close()
def generate_dummy_iocs(self): LOG.write('Generating dummy IOCs for included driver binaries') dummy_ioc_actions = [] for module in self.install_config.get_module_list(): if module.name.startswith('AD') and os.path.exists( installSynApps.join_path(module.abs_path, 'iocs')): dummy_ioc_actions.append( DummyIOCAction(os.path.basename(module.abs_path))) for action in dummy_ioc_actions: self.create_dummy_ioc(action) LOG.write('Done.')
def comment_non_build_macros(self): """Function that comments out any paths in the support/configure/RELEASE that are clone only and not build. """ rel_file_path = installSynApps.join_path(self.install_config.support_path, "configure", "RELEASE") rel_file_path_temp = installSynApps.join_path(self.install_config.support_path, "configure", "RELEASE_TEMP") os.rename(rel_file_path, rel_file_path_temp) rel_file_old = open(rel_file_path_temp, "r") rel_file_new = open(rel_file_path, "w") for line in rel_file_old.readlines(): if line.startswith('#') or line.startswith('-'): rel_file_new.write(line) elif '=' in line: name = line.split('=')[0] if name in self.install_config.module_map.keys() and self.install_config.get_module_by_name(name).build == 'YES': pass else: rel_file_new.write('#') LOG.debug('Commenting out non-build module {} in support/configure/RELEASE'.format(name)) rel_file_new.write(line) rel_file_new.close() rel_file_old.close() os.remove(rel_file_path_temp)
def grab_additional_env(self, action, st_base_path): """Function that collects any additional environment variables for IOC """ iocBoot_dir = os.path.dirname(st_base_path) st_file = os.path.basename(st_base_path) for file in os.listdir(iocBoot_dir): # For any file that isnt the base file, add environment variables. if file.startswith('st') and file.endswith( '.cmd') and file != st_file: fp = open(installSynApps.join_path(iocBoot_dir, file), 'r') lines = fp.readlines() for line in lines: if line.startswith('epicsEnvSet'): action.add_to_environment(line) fp.close()