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 grab_configuration_used(self, top_location, module, readme_fp): """Function that includes the install configuration into the bundle for reuse. Parameters ---------- top : str resulting location - __temp__ """ try: isa_version, isa_commit_hash = installSynApps.find_isa_version() self.generate_build_config(top_location, module, readme_fp) readme_fp.write('Build configuration:\n\n') readme_fp.write( 'installSynApps Version: {}\n\n'.format(isa_version)) readme_fp.write( 'To grab this version:\n\n git clone https://github.com/epicsNSLS2-deploy/installSynApps\n' ) if isa_commit_hash is not None: readme_fp.write( ' git checkout {}\n'.format(isa_commit_hash)) else: readme_fp.write(' git checkout -q {}\n'.format(isa_version)) readme_fp.write( 'To regenerate sources for this bundle, grab installSynApps, and run:\n\n' ) readme_fp.write( ' ./installCLI.py -c $BUILD_CONFIG -i $INSTALL_LOCATION -p\n\n' ) readme_fp.write( 'where $BUILD_CONFIG is the path to the build-config directory,\n' ) readme_fp.write( 'and $INSTALL_LOCATION is your target install path.\n\n{}\n'. format('-' * 64)) readme_fp.write('{:<20}{}\n'.format('Python 3 Version:', sys.version.split()[0])) readme_fp.write('{:<20}{}\n'.format('OS Class:', self.OS)) readme_fp.write('{:<20}{}\n'.format('Build Date:', datetime.datetime.now())) except: LOG.debug('Failed to copy install configuration into bundle.')
def generate_readme(self, installation_name, installation_type='source', readme_path=None, module=None, flat_grab=False): """Function used to generate a README file that includes version/build information Parameters ---------- installation_name : str Name of the output source/binary bundle installation_type : str Type of installation that a README file is generated for readme_path : str Non-standard readme path. Standard is install_location/README module : installSynApps.DataModel.install_module.InstallModule Default none. If not None, module that is being packaged as add-on """ # Open the correct readme file path in write mode, set the top location if readme_path is None: if os.path.exists(installSynApps.join_path(self.install_config.install_location, 'README')): os.remove(installSynApps.join_path(self.install_config.install_location, 'README')) readme_fp = open(installSynApps.join_path(self.install_config.install_location, 'README'), 'w') top_location = self.install_config.install_location else: readme_fp = open(readme_path, 'w') top_location = installSynApps.join_path('__temp__', installation_name) # Write heading based on type of installation if installation_type == 'source': self.write_readme_heading('Source Package - {}'.format(installation_name), readme_fp) elif installation_type == 'bundle': self.write_readme_heading('Bundle - {}'.format(installation_name), readme_fp) elif installation_type == 'addon': self.write_readme_heading('Add-On - {}'.format(installation_name), readme_fp) # Grab some basic version info isa_version, _ = installSynApps.find_isa_version() config_name, config_repo, config_version = self.find_config_info() readme_fp.write('Package generated using installSynApps version: {}\n\n'.format(isa_version)) if config_version is not None: readme_fp.write('Configuration repository: {}\nConfiguration directory: {}\nConfiguration commit hash: {}\n'.format(config_repo, config_name, config_version)) if installation_type == 'source': readme_fp.write('NOTE: To perform development using this bundle, run the repoint_bundle.sh script to edit RELEASE file locations.\n') readme_fp.write('\nModule versions used in this deployment:\n') if module is not None: readme_fp.write('\nAdd-On should be located here: {}.\n\n'.format(module.rel_path)) readme_fp.write('[module name] - [git tag]\n\n') # Get included modules + versions self.write_included_modules_to_readme(installation_type, module, readme_fp) # If it is an add-on-package, list what modules it was built against if module is not None: readme_fp.write('\nThe module was built against:\n\n') self.write_included_modules_to_readme('source', None, readme_fp) readme_fp.write('\n\n') # Grab some final build configuration information, and close the file. self.grab_configuration_used(top_location, module, readme_fp, flat_grab) readme_fp.close()