Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove cassandra from the shiv package #96

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
Loading