Skip to content

Add RPM/DEB packaging #88

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

Closed
wants to merge 1 commit into from
Closed
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
58 changes: 58 additions & 0 deletions .github/workflows/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: DEB Packaging

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup environment
run: |
sudo sh -c "echo 'deb http://security.ubuntu.com/ubuntu xenial-security main' >> /etc/apt/sources.list"
sudo apt-get update
sudo apt-get install -y libuv1-dev openssl cmake make g++ git devscripts debhelper dh-exec libssl-dev zlib1g-dev
git clone https://github.com/scylladb/cpp-driver.git
cp -r packaging cpp-driver/

- name: Build cpp-rust
run: |
cd scylla-rust-wrapper
cargo build --release

- name: Build deb (with debug symbols)
run: |
cp scylla-rust-wrapper/target/release/libscylla_cpp_driver.so cpp-driver/packaging/debian
cd cpp-driver/packaging
./build_deb.sh

- name: Upload deb packages
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: deb-packages
path: |
cpp-driver/packaging/build/*.deb
cpp-driver/packaging/build/*.build*

- name: Build deb (without debug symbols)
run: |
strip scylla-rust-wrapper/target/release/libscylla_cpp_driver.so
cp scylla-rust-wrapper/target/release/libscylla_cpp_driver.so cpp-driver/packaging/debian
cd cpp-driver/packaging
./build_deb.sh

- name: Upload deb package without debug symbols
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: deb-packages
path: "cpp-driver/packaging/build/scylla-cpp-driver_*.deb"
66 changes: 66 additions & 0 deletions .github/workflows/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: RPM Packaging

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always

jobs:
fedora-job:
runs-on: ubuntu-latest
container: fedora:35
steps:
- uses: actions/checkout@v2

- name: Setup environment
run: |
sudo yum install -y libuv-devel openssl-devel cmake3 make g++ git curl clang rpm-build zlib-devel
sudo dnf install -y rust cargo
git clone https://github.com/scylladb/cpp-driver.git
cp -r packaging cpp-driver/

- name: Build cpp-rust
run: |
cd scylla-rust-wrapper
cargo build --release

- name: Build rpm (with debug symbols)
run: |
cp scylla-rust-wrapper/target/release/libscylla_cpp_driver.so cpp-driver/packaging
cd cpp-driver
cp licenses/apache-2.0.txt LICENSE.txt
cd packaging
./build_rpm.sh
cd build/RPMS/x86_64
for f in scylla-cpp-driver*.rpm; do
if ! [[ $f == *"devel"* ]]
then
new=`echo $f | sed -e 's/driver/driver-debuginfo/'`
mv $f $new
fi
done

- name: Upload rpm packages
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: rpm-packages
path: "cpp-driver/packaging/build/RPMS/*/*.rpm"

- name: Build rpm (without debug symbols)
run: |
strip scylla-rust-wrapper/target/release/libscylla_cpp_driver.so
cp scylla-rust-wrapper/target/release/libscylla_cpp_driver.so cpp-driver/packaging
cd cpp-driver/packaging
./build_rpm.sh

- name: Upload rpm package without debug symbols
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: rpm-packages
path: "cpp-driver/packaging/build/RPMS/*/scylla-cpp-driver-*.rpm"
31 changes: 31 additions & 0 deletions packaging/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
## On a clean CentOS 7

Set up the EPEL, install the toolchain and `libuv`:
```
wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-13.noarch.rpm
sudo rpm -Uvh epel-release*rpm
sudo yum install -y libuv-devel openssl-devel cmake3 make g++ git
```

Now clone the source code, checkout particular revision if needed:
```
git clone https://github.com/scylladb/cpp-driver.git
cd cpp-driver/
```

Packaging:
```
cat licenses/* > LICENSE.txt
cd packaging/
./build_rpm.sh
```

## On a clean Ubuntu 18

```
sudo apt-get update
sudo apt-get install -y libuv1-dev openssl cmake make g++ git devscripts debhelper dh-exec libssl-dev zlib1g-dev
git clone https://github.com/scylladb/cpp-driver.git
cd cpp-driver/packaging
./build_deb.sh
```
76 changes: 76 additions & 0 deletions packaging/build_deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

function check_command {
command=$1
package=$2
if ! type "$command" > /dev/null 2>&1; then
echo "Missing command '$command', run: apt-get install $package"
exit 1
fi
}

function header_version {
read -d '' version_script << 'EOF'
BEGIN { major="?"; minor="?"; patch="?" }
/CASS_VERSION_MAJOR/ { major=$3 }
/CASS_VERSION_MINOR/ { minor=$3 }
/CASS_VERSION_PATCH/ { patch=$3 }
/CASS_VERSION_SUFFIX/ { suffix=$3; gsub(/"/, "", suffix) }
END {
if (length(suffix) > 0)
printf "%s.%s.%s~%s", major, minor, patch, suffix
else
printf "%s.%s.%s", major, minor, patch
}
EOF
version=$(grep '#define[ \t]\+CASS_VERSION_\(MAJOR\|MINOR\|PATCH\|SUFFIX\)' $1 | awk "$version_script")
if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(~[a-zA-Z0-9_\-]+)?$ ]]; then
echo "Unable to extract version from $1"
exit 1
fi
echo "$version"
}

check_command "dch" "devscripts"
check_command "lsb_release" "lsb-release"

version=$(header_version "../include/cassandra.h")
release=1
dist=$(lsb_release -s -c)
base="scylla-cpp-driver-$version"
archive="$base.tar.gz"
files="CMakeLists.txt cmake cmake_uninstall.cmake.in driver_config.hpp.in include src"

echo "Building version $version"

libuv_version=$(dpkg -s libuv1 | grep 'Version' | awk '{ print $2 }')

if [[ -e $libuv_version ]]; then
echo "'libuv' required, but not installed"
exit 1
fi

echo "Using libuv version $libuv_version"

if [[ -d build ]]; then
read -p "Build directory exists, remove? [y|n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf build
fi
fi
mkdir -p "build/$base"

echo "Copying files"
for file in $files; do
cp -r "../$file" "build/$base"
done
cp -r debian "build/$base"

pushd "build/$base"
echo "Updating changlog"
dch -m -v "$version-$release" -D $dist "Version $version"
echo "Building package:"
nprocs=$(grep -e '^processor' -c /proc/cpuinfo)
DEB_BUILD_OPTIONS="parallel=$nprocs" debuild -i -b -uc -us
popd
83 changes: 83 additions & 0 deletions packaging/build_rpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/bash

function check_command {
command=$1
package=$2
if ! type "$command" > /dev/null 2>&1; then
echo "Missing command '$command', run: yum install $package"
exit 1
fi
}

function header_version {
read -d '' version_script << 'EOF'
BEGIN { major="?"; minor="?"; patch="?" }
/CASS_VERSION_MAJOR/ { major=$3 }
/CASS_VERSION_MINOR/ { minor=$3 }
/CASS_VERSION_PATCH/ { patch=$3 }
/CASS_VERSION_SUFFIX/ { suffix=$3; gsub(/"/, "", suffix) }
END {
if (length(suffix) > 0)
printf "%s.%s.%s%s", major, minor, patch, suffix
else
printf "%s.%s.%s", major, minor, patch
}
EOF
version=$(grep '#define[ \t]\+CASS_VERSION_\(MAJOR\|MINOR\|PATCH\|SUFFIX\)' $1 | awk "$version_script")
if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+([a-zA-Z0-9_\-]+)?$ ]]; then
echo "Unable to extract version from $1"
exit 1
fi
echo "$version"
}

# 'redhat-rpm-config' needs to be installed for the 'debuginfo' package
check_command "rpmbuild" "rpm-build"

arch="x86_64"
if [[ ! -z $1 ]]; then
arch=$1
fi

version=$(header_version "../include/cassandra.h")
base="scylla-cpp-driver-$version"
archive="$base.tar.gz"
files="CMakeLists.txt cmake cmake_uninstall.cmake.in driver_config.hpp.in include src README.md LICENSE.txt"

echo "Building version $version"

libuv_version=$(rpm -q --queryformat "%{VERSION}" libuv)

if [[ -e $libuv_version ]]; then
echo "'libuv' required, but not installed"
exit 1
fi

echo "Using libuv version $libuv_version"

if [[ -d build ]]; then
read -p "Build directory exists, remove? [y|n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf build
fi
fi
mkdir -p build/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
mkdir -p "build/SOURCES/$base"

echo "Copying files"
for file in $files; do
cp -r "../$file" "build/SOURCES/$base"
done
cp scylla-cpp-driver.pc.in build/SOURCES
cp scylla-cpp-driver_static.pc.in build/SOURCES

echo "Archiving $archive"
pushd "build/SOURCES"
tar zcf $archive $base
popd

echo "Building package:"
rpmbuild --target $arch --define "_topdir ${PWD}/build" --define "driver_version $version" --define "libuv_version $libuv_version" -ba scylla-cpp-driver.spec

exit 0
5 changes: 5 additions & 0 deletions packaging/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scylla-cpp-driver (1.0.0-1) stable; urgency=low

* Initial release

-- Michael Penick <[email protected]> Tue, 20 Jan 2015 20:20:27 -0700
1 change: 1 addition & 0 deletions packaging/debian/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9
39 changes: 39 additions & 0 deletions packaging/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Source: scylla-cpp-driver
Priority: extra
Maintainer: Juliusz Stasiewicz <[email protected]>
Build-Depends: debhelper (>= 9.0.0), dh-exec, cmake, make,
libuv1-dev (>= 1.0.0),
libssl-dev
Standards-Version: 3.9.2
Section: libs
Homepage: https://github.com/scylladb/cpp-driver
Vcs-Git: git://github.com/scylladb/cpp-driver.git
Vcs-Browser: https://github.com/scylladb/cpp-driver

Package: scylla-cpp-driver
Section: libs
Architecture: any
Pre-Depends: libc6 (>= 2.3.6-2), ${misc:Pre-Depends}
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: C/C++ client driver for Scylla, Apache Cassandra and DataStax Products - runtime library
A modern, feature-rich, shard-aware and highly tunable C/C++ client library for Scylla, Apache
Cassandra and DataStax Products using Cassandra's native protocol and Cassandra Query
Language along with extensions for DataStax Products.

Package: scylla-cpp-driver-dev
Section: libdevel
Architecture: any
Depends: scylla-cpp-driver (= ${binary:Version}), ${misc:Depends}
Description: C/C++ client driver for Scylla, Apache Cassandra and DataStax Products - development files
A modern, feature-rich, shard-aware and highly tunable C/C++ client library for Scylla, Apache
Cassandra and DataStax Products using Cassandra's native protocol and Cassandra Query
Language along with extensions for DataStax Products.

Package: scylla-cpp-driver-dbg
Section: debug
Architecture: any
Depends: scylla-cpp-driver (= ${binary:Version}), ${misc:Depends}
Description: C/C++ client driver for Scylla, Apache Cassandra and DataStax Products - debugging symbols
A modern, feature-rich, shard-aware and highly tunable C/C++ client library for Scylla, Apache
Cassandra and DataStax Products using Cassandra's native protocol and Cassandra Query
Language along with extensions for DataStax Products.
32 changes: 32 additions & 0 deletions packaging/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Format: http://dep.debian.net/deps/dep5
Upstream-Name: scylla-cpp-driver
Source: https://github.com/scylladb/cpp-driver

Files: *
Copyright: Copyright (c) DataStax, Inc.
Copyright (c) 2020 ScyllaDB
License: Apache-2.0, AGPL-3
On Debian systems, the complete text of the Apache License Version 2.0
can be found in `/usr/share/common-licenses/Apache-2.0'.

Files: src/third_party/hdr_histogram/*
Copyright: Copyright (c) 2012, 2013, 2014 Gil Tene
Copyright (c) 2014 Michael Barker
Copyright (c) 2014 Matt Warren
License: BSD-2-clause

Files: src/third_party/mt19937_64/*
Copyright: Copyright (C) 2004, Makoto Matsumoto and Takuji Nishimura
License: BSD-3-clause

Files: src/third_party/rapidjson/*
Copyright: Copyright (C) 2011 Milo Yip
License: MIT

Files: src/third_party/curl/*
Copyright: Copyright (C) 1998 - 2012, Daniel Stenberg, <[email protected]>, et al.
License: MIT

Files: src/optional/optional_akrzemi.hpp
Copyright: Copyright (C) 2011 - 2012 Andrzej Krzemienski
License: Boost Software License 1.0
Loading