From 26ebd4fddcc94b548fecb838f6ca04763afb16ed Mon Sep 17 00:00:00 2001 From: Israel Fruchter Date: Thu, 27 Jun 2024 12:25:38 +0300 Subject: [PATCH] remove cassandra from the shiv package so we can use the scylla-python3 driver version the only problem now, we depend on new dbuild version for using newr version of scylla-driver with cqlsh. it's really slow down the ability to update new feature that depends on new driver chnages (not too many of those) Fixes: #95 --- dist/debian/control.template | 1 + dist/redhat/scylla-cqlsh.spec | 2 +- scripts/create-relocatable-package.py | 31 ++++++++++++++++++++++++--- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/dist/debian/control.template b/dist/debian/control.template index e46667a..87580dc 100644 --- a/dist/debian/control.template +++ b/dist/debian/control.template @@ -9,6 +9,7 @@ Rules-Requires-Root: no Package: %{product}-cqlsh Architecture: any Depends: python3 +Depends: %{product}-python3 (= ${binary:Version}) Conflicts: cassandra Description: cqlsh is a Python-based command-line client for running CQL commands on a cassandra cluster. Replaces: scylla-tools (<< 5.2~rc0) diff --git a/dist/redhat/scylla-cqlsh.spec b/dist/redhat/scylla-cqlsh.spec index 4d2a052..a114290 100644 --- a/dist/redhat/scylla-cqlsh.spec +++ b/dist/redhat/scylla-cqlsh.spec @@ -8,7 +8,7 @@ Obsoletes: %{product}-tools < 5.2 License: Apache URL: http://www.scylladb.com/ Source0: %{reloc_pkg} -Requires: python3 +Requires: %{product}-python3 = %{version}-%{release} AutoReqProv: no Conflicts: cassandra diff --git a/scripts/create-relocatable-package.py b/scripts/create-relocatable-package.py index a6b9aac..b17beed 100755 --- a/scripts/create-relocatable-package.py +++ b/scripts/create-relocatable-package.py @@ -22,11 +22,11 @@ # import argparse -import io -import os +import subprocess import tarfile import pathlib + def erase_uid(tarinfo): tarinfo.uid = tarinfo.gid = 0 tarinfo.uname = tarinfo.gname = 'root' @@ -41,6 +41,24 @@ def reloc_add(self, name, arcname=None): tarfile.TarFile.reloc_add = reloc_add + +def fix_binary(path, libpath): + '''Makes one binary or shared library relocatable. To do that, we need to set RUNPATH to $ORIGIN/../lib64 so we get libraries + from the relocatable directory and not from the system during runtime. We also want to copy the interpreter used so + we can launch with it later. + ''' + # it's a pity patchelf have to patch an actual binary. + + subprocess.check_call(['patchelf', + '--set-rpath', + libpath, + path]) + + +def fix_sharedlib(binpath): + fix_binary(binpath, '$ORIGIN/lib64') + + ap = argparse.ArgumentParser(description='Create a relocatable scylla package.') ap.add_argument('--version', required=True, help='Tools version') @@ -65,7 +83,14 @@ def reloc_add(self, name, arcname=None): ar.reloc_add('build/SCYLLA-PRODUCT-FILE', arcname='SCYLLA-PRODUCT-FILE') ar.reloc_add('dist/debian') ar.reloc_add('dist/redhat') -ar.reloc_add('bin') +ar.reloc_add('bin/cqlsh.py') ar.reloc_add('pylib') ar.reloc_add('install.sh') ar.reloc_add('build/debian/debian', arcname='debian') + +cqlsh_bin = pathlib.Path('bin/cqlsh').resolve() +subprocess.check_call(["mv", cqlsh_bin, f'{cqlsh_bin}.zip']) +subprocess.run(["zip", "--delete", cqlsh_bin, "site-packages/cassandra/*"]) +subprocess.check_call(["mv", f'{cqlsh_bin}.zip', cqlsh_bin]) + +ar.reloc_add('bin/cqlsh') \ No newline at end of file