def ensure_makefile(src_path): mkfile = join(src_path, 'Makefile') if not os.path.isfile(mkfile): resource = resource_filename(Requirement.parse(enot.APPNAME), 'enot/resources/CMakefile') debug('copy ' + resource + ' to ' + mkfile) copy_file(resource, mkfile)
def __ensure_resource(self, resource, path): resource_path = join(self.package.path, path, resource) if not os.path.isfile(resource_path): resource = resource_filename(Requirement.parse(enot.APPNAME), join('enot/resources', resource)) debug('copy ' + resource + ' to ' + resource_path) copy_file(resource, resource_path) return resource_path
def unpackage( self, package: Package ): # TODO move me to package? use current dir + <something> instead of temp unpack_dir = join(self.temp_dir, package.fullname) enotpack = join(package.path, package.name + '.ep') ensure_empty(unpack_dir) info('Extract ' + enotpack) with tarfile.open(enotpack) as pack: pack.extractall(unpack_dir) package.path = unpack_dir # update path pointer copy_file(enotpack, join(unpack_dir, package.name + '.ep'))
def test_add_from_package(self, mock_conf): mock_conf.return_value = self.conf_file pack_path = join(self.test_dir, 'test_app') set_git_url(pack_path, 'http://github/comtihon/test_app') set_git_tag(pack_path, '1.0.0') builder = Builder.init_from_path(pack_path) self.assertEqual(True, builder.build()) builder.package() new_package_path = join(self.test_dir, 'test_app.ep') # remove source project, test should work only with enot package copy_file(join(pack_path, 'test_app.ep'), new_package_path) remove_dir(pack_path) package = Package.from_package(new_package_path) self.assertEqual(False, builder.system_config.cache.exists_local(package)) # local cache is used here to determine tmp dir local_cache = builder.system_config.cache.local_cache builder.system_config.cache.add_fetched(local_cache, package) self.assertEqual(True, builder.system_config.cache.exists_local(package))
def add_package(self, package: Package, rewrite=False) -> bool: full_dir = join(self.path, self.get_package_path(package, True)) ensure_dir(full_dir) info('add ' + package.fullname) path = package.path LocalCache.__copy_data(rewrite, full_dir, path, 'ebin') LocalCache.__copy_include(rewrite, full_dir, path) if package.config.with_source: LocalCache.__copy_data(rewrite, full_dir, path, 'src') if package.config.with_source and package.has_nifs: LocalCache.__copy_data(rewrite, full_dir, path, 'c_src') if os.path.exists(join(path, 'priv')): LocalCache.__copy_data(rewrite, full_dir, path, 'priv') enot_package = join(path, package.name + '.ep') if not os.path.isfile(enot_package): debug('generate missing package') package.generate_package() copy_file(join(path, 'enot_config.json'), join(full_dir, 'enot_config.json')) copy_file(enot_package, join(full_dir, package.name + '.ep')) resource = resource_filename(Requirement.parse(enot.APPNAME), 'enot/resources/EmptyMakefile') debug('copy ' + resource + ' to ' + join(full_dir, 'Makefile')) copy_file(resource, join(full_dir, 'Makefile')) package.path = full_dir # update package's dir to point to cache return True
def add_tool(self, toolname: str, toolpath: str): info('add ' + toolname) tool_dst = join(self.tool_dir, toolname) copy_file(toolpath, tool_dst) st = os.stat(tool_dst) os.chmod(tool_dst, st.st_mode | stat.S_IEXEC)