def import_bin_files(self): bin_dir = os.path.join(self.get_cassandra_dir(), 'bin') for name in os.listdir(bin_dir): filename = os.path.join(bin_dir, name) if os.path.isfile(filename): shutil.copy(filename, self.get_bin_dir()) common.add_exec_permission(bin_dir, name)
def import_bin_files(self): bin_dir = os.path.join(self.get_cassandra_dir(), "bin") for name in os.listdir(bin_dir): filename = os.path.join(bin_dir, name) if os.path.isfile(filename): shutil.copy(filename, self.get_bin_dir()) common.add_exec_permission(bin_dir, name)
def import_bin_files(self): # selectively copying files to reduce risk of using unintended items files = ['cassandra.in.sh', 'nodetool'] os.makedirs(os.path.join(self.get_path(), 'resources', 'cassandra', 'bin')) for name in files: self.hard_link_or_copy(os.path.join(self.get_install_dir(), 'resources', 'cassandra', 'bin', name), os.path.join(self.get_path(), 'resources', 'cassandra', 'bin', name)) # selectively copying files to reduce risk of using unintended items files = ['sstabledump', 'sstablelevelreset', 'sstablemetadata', 'sstablerepairedset', 'sstablesplit'] os.makedirs(os.path.join(self.get_path(), 'resources', 'cassandra', 'tools', 'bin')) for name in files: self.hard_link_or_copy(os.path.join(self.get_install_dir(), 'resources', 'cassandra', 'tools', 'bin', name), os.path.join(self.get_path(), 'resources', 'cassandra', 'tools', 'bin', name)) # TODO: - currently no scripts only executable - copying exec scylla_mode = self.cluster.get_scylla_mode() self.hard_link_or_copy(os.path.join(self.get_install_dir(), 'build', scylla_mode, 'scylla'), os.path.join(self.get_bin_dir(), 'scylla')) self.hard_link_or_copy(os.path.join(self.get_install_dir(), '..', 'scylla-jmx', 'target', 'scylla-jmx-1.0.jar'), os.path.join(self.get_bin_dir(), 'scylla-jmx-1.0.jar')) self.hard_link_or_copy(os.path.join(self.get_install_dir(), '..', 'scylla-jmx', 'scripts', 'scylla-jmx'), os.path.join(self.get_bin_dir(), 'scylla-jmx')) os.makedirs(os.path.join(self.get_bin_dir(), 'symlinks')) os.symlink('/usr/bin/java', os.path.join(self.get_bin_dir(), 'symlinks', 'scylla-jmx')) parent_dir = os.path.dirname(os.path.realpath(__file__)) resources_bin_dir = os.path.join(parent_dir, '..', 'resources', 'bin') for name in os.listdir(resources_bin_dir): filename = os.path.join(resources_bin_dir, name) if os.path.isfile(filename): shutil.copy(filename, self.get_bin_dir()) common.add_exec_permission(self.get_bin_dir(), name)
def import_bin_files(self): # selectively copying files to reduce risk of using unintended items files = ['cassandra.in.sh', 'nodetool'] os.makedirs( os.path.join(self.get_path(), 'resources', 'cassandra', 'bin')) for name in files: self.hard_link_or_copy( os.path.join(self.get_tools_java_dir(), 'bin', name), os.path.join(self.get_path(), 'resources', 'cassandra', 'bin', name)) # selectively copying files to reduce risk of using unintended items files = [ 'sstabledump', 'sstablelevelreset', 'sstablemetadata', 'sstablerepairedset', 'sstablesplit' ] os.makedirs( os.path.join(self.get_path(), 'resources', 'cassandra', 'tools', 'bin')) for name in files: self.hard_link_or_copy( os.path.join(self.get_tools_java_dir(), 'tools', 'bin', name), os.path.join(self.get_path(), 'resources', 'cassandra', 'tools', 'bin', name)) # TODO: - currently no scripts only executable - copying exec if self.is_scylla_reloc(): relative_repos_root = '../..' self.hard_link_or_copy( os.path.join(self.get_install_dir(), 'bin', 'scylla'), os.path.join(self.get_bin_dir(), 'scylla'), stat.S_IEXEC) os.environ['GNUTLS_SYSTEM_PRIORITY_FILE'] = os.path.join( self.get_install_dir(), 'scylla-core-package/libreloc/gnutls.config') else: relative_repos_root = '..' src = os.path.join(self.get_install_dir(), 'build', self.scylla_mode(), 'scylla') dst = os.path.join(self.get_bin_dir(), 'scylla') dbuild_so_dir = os.environ.get('SCYLLA_DBUILD_SO_DIR') if not dbuild_so_dir: self.hard_link_or_copy(src, dst, stat.S_IEXEC) else: self.hard_link_or_copy(src, dst, stat.S_IEXEC, always_copy=True) search_pattern = os.path.join(dbuild_so_dir, 'ld-linux-x86-64.so.*') res = glob.glob(search_pattern) if not res: raise RuntimeError('{} not found'.format(search_pattern)) if len(res) > 1: raise RuntimeError('{}: found too make matches: {}'.format( search_pattern, res)) loader = res[0] self._launch_env = dict(os.environ) self._launch_env['LD_LIBRARY_PATH'] = dbuild_so_dir patchelf_cmd = [ loader, os.path.join(dbuild_so_dir, 'patchelf'), '--set-interpreter', loader, dst ] def run_patchelf(patchelf_cmd): p = subprocess.Popen(patchelf_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=self._launch_env) (stdout, stderr) = p.communicate() return (p.returncode, stdout, stderr) (returncode, stdout, stderr) = run_patchelf(patchelf_cmd) if returncode != 0: # Retry after stripping binary if hit # https://github.com/scylladb/scylla/issues/5245 if stderr == 'read\n': cmd = ['strip', dst] subprocess.check_call(cmd) (returncode, stdout, stderr) = run_patchelf(patchelf_cmd) if returncode != 0: raise RuntimeError( '{} exited with status {}.\nstdout:{}\nstderr:\n{}'. format(patchelf_cmd, returncode, stdout, stderr)) if 'scylla-repository' in self.get_install_dir(): self.hard_link_or_copy( os.path.join(self.get_install_dir(), 'scylla-jmx', 'scylla-jmx-1.0.jar'), os.path.join(self.get_bin_dir(), 'scylla-jmx-1.0.jar')) self.hard_link_or_copy( os.path.join(self.get_install_dir(), 'scylla-jmx', 'scylla-jmx'), os.path.join(self.get_bin_dir(), 'scylla-jmx')) else: self.hard_link_or_copy( os.path.join(self.get_jmx_dir(relative_repos_root), 'target', 'scylla-jmx-1.0.jar'), os.path.join(self.get_bin_dir(), 'scylla-jmx-1.0.jar')) self.hard_link_or_copy( os.path.join(self.get_jmx_dir(relative_repos_root), 'scripts', 'scylla-jmx'), os.path.join(self.get_bin_dir(), 'scylla-jmx')) os.makedirs(os.path.join(self.get_bin_dir(), 'symlinks')) os.symlink('/usr/bin/java', os.path.join(self.get_bin_dir(), 'symlinks', 'scylla-jmx')) parent_dir = os.path.dirname(os.path.realpath(__file__)) resources_bin_dir = os.path.join(parent_dir, 'resources', 'bin') for name in os.listdir(resources_bin_dir): filename = os.path.join(resources_bin_dir, name) if os.path.isfile(filename): shutil.copy(filename, self.get_bin_dir()) common.add_exec_permission(self.get_bin_dir(), name)