Skip to content

Commit

Permalink
remove cassandra from the shiv package
Browse files Browse the repository at this point in the history
so we can use the scylla-python3 driver version
the only problem now, we depend on new dbuild version
for using newer version of scylla-driver with cqlsh.

it's really slow down the ability to update new feature
that depends on new driver chanages (not too many of those)

Depends: scylladb/scylla-python3#40
Fixes: #95
  • Loading branch information
fruch committed Jul 1, 2024
1 parent 73bdbeb commit deffe4f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/debian/control.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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)
Expand Down
2 changes: 1 addition & 1 deletion dist/redhat/scylla-cqlsh.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
35 changes: 32 additions & 3 deletions scripts/create-relocatable-package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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')
Expand All @@ -65,7 +83,18 @@ 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')


# clear scylla-driver out of the package
# we assume that scylla-python3 already have it (and all it's .so are relocatable,
# and pointing the correct lib folder)
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')

0 comments on commit deffe4f

Please sign in to comment.