def set_runpaths(self) -> NoReturn: if not self.runpath_util.tool_state: return l = logging.getLogger(__name__) # noqa: VNE001,E741 self.context.status(l, '-- Setting RUNPATHs') libs_res = self.runpath_util.set_rpath_dispatch( self.prepared_libs.values(), '$ORIGIN') bins_runpath = os.path.relpath(self.pkg_lib_dir, start=self.pkg_bin_dir) if bins_runpath == '.': bins_runpath = '$ORIGIN' else: bins_runpath = path.join('$ORIGIN', bins_runpath) bins_res = self.runpath_util.set_rpath_dispatch( self.icommand_binaries.values(), bins_runpath) plugs_runpath = os.path.relpath(self.pkg_lib_dir, start=self.pkg_plugs_dir) if plugs_runpath == '.': plugs_runpath = '$ORIGIN' else: plugs_runpath = path.join('$ORIGIN', plugs_runpath) plugs_res = self.runpath_util.set_rpath_dispatch( self.irods_runtime_plugs, plugs_runpath) res_all = script_common.CollectionCompoundView( [libs_res, bins_res, plugs_res]) script_common.futures_wait(res_all)
def prepare_irods_runtime(self) -> NoReturn: l = logging.getLogger(__name__) # noqa: VNE001,E741 self.context.status( l, '-- Gathering iRODS runtime libraries and plugins') dest_lib = self.pkg_lib_dir dest_plugins = self.pkg_plugs_dir # for now, assume irods package prefix will always be specified if path.isabs(self.options.irods_plugsdir): src_plugins = self.options.irods_plugsdir else: src_plugins = path.join(self.options.irods_package_prefix, self.options.irods_plugsdir) # for now, assume all we need are auth and network plugins plugsdnames = ['auth', 'network', 'api'] plugsdirs = [] for plugsdname in plugsdnames: src_plugsdir = path.join(src_plugins, plugsdname) dest_plugsdir = path.join(dest_plugins, plugsdname) if not path.exists(dest_plugsdir): os.mkdir(dest_plugsdir) plugsdirs.append((src_plugsdir, dest_plugsdir)) soname_map = {} plugs = [] runtime_bins = {} # for now, assume everything passed through --irods-externals-lib is in $/lib # and that the filenames match the sonames # and that there's no symlinking shenanigans for lib_in in self.options.irods_runtime_libs: soname = path.basename(lib_in) dest_libpath = path.join(dest_lib, soname) soname_map[soname] = dest_libpath runtime_bins[lib_in] = dest_libpath # continue assuming there's no symlinking shenanigans for src_plugsdir, dest_plugsdir in plugsdirs: for plugfname in os.listdir(src_plugsdir): if self._should_skip_plugin(plugfname): continue dest_plugpath = path.join(dest_plugsdir, plugfname) plugs.append(dest_plugpath) runtime_bins[path.join(src_plugsdir, plugfname)] = dest_plugpath results = self.strip_util.strip_and_clean_dispatch( runtime_bins.items()) script_common.futures_wait(results) self.irods_runtime_libs.update(soname_map) self.irods_runtime_plugs.update(plugs) self.prepared_libs.update(soname_map)
def prepare_icommands(self) -> NoReturn: l = logging.getLogger(__name__) # noqa: VNE001,E741 ilib = self.ilib self.context.status(l, '-- Gathering iCommands.') cmake_pfx = path.join(self.options.work_dir, 'cmake_pfx') if path.exists(cmake_pfx): shutil.rmtree(cmake_pfx) os.mkdir(cmake_pfx) cmake_env = self.fill_out_envdict(self.context.envdict) cmake_env.pop('DESTDIR', '') for install_component in self.options.install_components: # cmake --install not introduced until CMake 3.15 cmake_args = [ self.runpath_util.tool_state.cmake.path, '-DCMAKE_INSTALL_PREFIX=' + cmake_pfx, '-DCMAKE_INSTALL_COMPONENT=' + install_component, '-P', path.join(self.options.build_dir, 'cmake_install.cmake') ] ilib.execute_command(cmake_args, env=cmake_env) # for now, assume everything we want is in $/bin dest_bin = self.pkg_bin_dir if path.isabs(self.options.install_bindir): cmake_pfx_bin = path.join(cmake_pfx, self.options.install_bindir[1:]) #elif path.isabs(self.options.cmake_install_prefix): # cmake_pfx_bin = path.join(cmake_pfx, self.options.cmake_install_prefix[1:], self.options.install_bindir) #else: # cmake_pfx_bin = path.join(cmake_pfx, self.options.cmake_install_prefix, self.options.install_bindir) else: cmake_pfx_bin = path.join(cmake_pfx, self.options.install_bindir) icommand_names = list(os.listdir(cmake_pfx_bin)) for icommand_script in self.options.script_icommands: if icommand_script in icommand_names: icommand_path_in = path.join(cmake_pfx_bin, icommand_script) icommand_path_out = path.join(dest_bin, icommand_script) shutil.copyfile(icommand_path_in, icommand_path_out) os.chmod( icommand_path_out, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | # noqa: E222,W504 stat.S_IRGRP | stat.S_IXGRP | # noqa: E127,E222,W504 stat.S_IROTH | stat.S_IXOTH) # noqa: E127,E222 icommand_names.remove(icommand_script) self.icommand_scripts[icommand_script] = icommand_path_out icommand_binaries = { path.join(cmake_pfx_bin, icb): path.join(dest_bin, icb) for icb in icommand_names } results = self.strip_util.strip_and_clean_dispatch( icommand_binaries.items()) script_common.futures_wait(results) icommand_binaries = { icb: path.join(dest_bin, icb) for icb in icommand_names } self.icommand_binaries.update(icommand_binaries)