-
Notifications
You must be signed in to change notification settings - Fork 12
Support rpm and deb packaging #122
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ scylla-rust-wrapper/target/ | |
.idea/ | ||
cmake-build-debug/ | ||
.cache/ | ||
|
||
version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#!/bin/bash -e | ||
|
||
USAGE="$(cat <<-END | ||
Usage: $(basename "$0") [-h|--help] [-o|--output-dir PATH] [--date-stamp DATE] -- generate Scylla version and build information files. | ||
|
||
Options: | ||
-h|--help show this help message. | ||
-o|--output-dir PATH specify destination path at which the version files are to be created. | ||
-d|--date-stamp DATE manually set date for release parameter | ||
-v|--verbose also print out the version number | ||
|
||
By default, the script will attempt to parse 'version' file | ||
in the current directory, which should contain a string of | ||
'\$version-\$release' form. | ||
|
||
Otherwise, it will call 'git log' on the source tree (the | ||
directory, which contains the script) to obtain current | ||
commit hash and use it for building the version and release | ||
strings. | ||
|
||
The script assumes that it's called from the Scylla source | ||
tree. | ||
|
||
The files created are: | ||
SCYLLA-VERSION-FILE | ||
SCYLLA-RELEASE-FILE | ||
|
||
By default, these files are created in the 'build' | ||
subdirectory under the directory containing the script. | ||
The destination directory can be overridden by | ||
using '-o PATH' option. | ||
END | ||
)" | ||
|
||
DATE="" | ||
PRINT_VERSION=0 | ||
|
||
while [[ $# -gt 0 ]]; do | ||
opt="$1" | ||
case "${opt}" in | ||
-h|--help) | ||
echo "${USAGE}" | ||
exit 0 | ||
;; | ||
-o|--output-dir) | ||
OUTPUT_DIR="$2" | ||
shift 2 | ||
;; | ||
--date-stamp) | ||
DATE="$2" | ||
shift 2 | ||
;; | ||
-v|--verbose) | ||
PRINT_VERSION=1 | ||
shift 1 | ||
;; | ||
*) | ||
echo "Unexpected argument found: $1" | ||
echo | ||
echo "${USAGE}" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
SCRIPT_DIR="$(dirname "$0")" | ||
|
||
if [[ -z "${OUTPUT_DIR}" ]]; then | ||
OUTPUT_DIR="${SCRIPT_DIR}/build" | ||
fi | ||
|
||
if [[ -z "${DATE}" ]]; then | ||
DATE="$(date --utc +%Y%m%d)" | ||
fi | ||
|
||
# Default scylla version tags | ||
VERSION="$(sed -n -e 's/^version = \"\(.*\)\"$/\1/p' scylla-rust-wrapper/Cargo.toml)" | ||
|
||
if [[ -f version ]]; then | ||
SCYLLA_VERSION="$(cat version | awk -F'-' '{print $1}')" | ||
SCYLLA_RELEASE="$(cat version | awk -F'-' '{print $2}')" | ||
else | ||
SCYLLA_VERSION="${VERSION}" | ||
if [[ -z "${SCYLLA_RELEASE}" ]]; then | ||
GIT_COMMIT="$(git -C "${SCRIPT_DIR}" log --pretty=format:'%h' -n 1 --abbrev=12)" | ||
# For custom package builds, replace "0" with "counter.your_name", | ||
# where counter starts at 1 and increments for successive versions. | ||
# This ensures that the package manager will select your custom | ||
# package over the standard release. | ||
SCYLLA_BUILD=0 | ||
SCYLLA_RELEASE="${SCYLLA_BUILD}.${DATE}.${GIT_COMMIT}" | ||
elif [[ -f "${OUTPUT_DIR}/SCYLLA-RELEASE-FILE" ]]; then | ||
echo "setting SCYLLA_RELEASE only makes sense in clean builds" 1>&2 | ||
exit 1 | ||
fi | ||
fi | ||
|
||
if [[ -f "${OUTPUT_DIR}/SCYLLA-RELEASE-FILE" ]]; then | ||
GIT_COMMIT_FILE=$(cat "${OUTPUT_DIR}/SCYLLA-RELEASE-FILE" |cut -d . -f 3) | ||
if [[ "${GIT_COMMIT}" = "${GIT_COMMIT_FILE}" ]]; then | ||
exit 0 | ||
fi | ||
fi | ||
|
||
if [[ ${PRINT_VERSION} -eq 1 ]]; then | ||
echo "${SCYLLA_VERSION}-${SCYLLA_RELEASE}" | ||
fi | ||
mkdir -p "${OUTPUT_DIR}" | ||
echo "${SCYLLA_VERSION}" > "${OUTPUT_DIR}/SCYLLA-VERSION-FILE" | ||
echo "${SCYLLA_RELEASE}" > "${OUTPUT_DIR}/SCYLLA-RELEASE-FILE" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
prefix=@prefix@ | ||
exec_prefix=@exec_prefix@ | ||
libdir=@libdir@ | ||
includedir=@includedir@ | ||
|
||
Name: scylla-cpp-rust-driver | ||
Description: ScyllaDB Cpp-Rust Driver | ||
Version: @version@ | ||
Libs: -L${libdir} -lscylla-cpp-driver | ||
Cflags: -I${includedir} | ||
URL: https://github.com/scylladb/cpp-rust-driver/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
prefix=@prefix@ | ||
exec_prefix=@exec_prefix@ | ||
libdir=@libdir@ | ||
includedir=@includedir@ | ||
|
||
Name: scylla-cpp-rust-driver | ||
Description: ScyllaDB Cpp-Rust Driver | ||
Version: @version@ | ||
Requires: openssl | ||
Libs: -L${libdir} -lscylla-cpp-driver_static | ||
Cflags: -I${includedir} | ||
URL: https://github.com/scylladb/cpp-rust-driver/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
#!/bin/bash -e | ||
|
||
. /etc/os-release | ||
print_usage() { | ||
echo "build_deb.sh --jobs 2 --target jammy" | ||
echo " --target target distribution codename" | ||
echo " --no-clean don't rebuild pbuilder tgz" | ||
echo " --jobs specify number of jobs" | ||
exit 1 | ||
} | ||
|
||
TARGET= | ||
NO_CLEAN=0 | ||
JOBS="$(nproc)" | ||
while [ $# -gt 0 ]; do | ||
case "$1" in | ||
"--target") | ||
TARGET=$2 | ||
shift 2 | ||
;; | ||
"--no-clean") | ||
NO_CLEAN=1 | ||
shift 1 | ||
;; | ||
"--jobs") | ||
JOBS=$2 | ||
shift 2 | ||
;; | ||
*) | ||
print_usage | ||
;; | ||
esac | ||
done | ||
|
||
is_redhat_variant() { | ||
[[ -f /etc/redhat-release ]] | ||
} | ||
is_debian_variant() { | ||
[[ -f /etc/debian_version ]] | ||
} | ||
is_debian() { | ||
case "$1" in | ||
buster|bullseye|bookworm|trixie|sid) return 0;; | ||
*) return 1;; | ||
esac | ||
} | ||
is_ubuntu() { | ||
case "$1" in | ||
bionic|focal|jammy|mantic|noble) return 0;; | ||
*) return 1;; | ||
esac | ||
} | ||
|
||
|
||
APT_UPDATED=0 | ||
declare -A DEB_PKG=( | ||
["debian-keyring"]="debian-archive-keyring" | ||
["ubu-keyring"]="ubuntu-keyring" | ||
) | ||
pkg_install() { | ||
if is_redhat_variant; then | ||
sudo yum install -y "$1" | ||
elif is_debian_variant; then | ||
if [[ "${APT_UPDATED}" -eq 0 ]]; then | ||
sudo apt-get -y update | ||
APT_UPDATED=1 | ||
fi | ||
if [[ -n "${DEB_PKG[$1]}" ]]; then | ||
pkg="${DEB_PKG[$1]}" | ||
else | ||
pkg="$1" | ||
fi | ||
sudo apt-get install -y "$pkg" | ||
else | ||
echo "Requires to install following command: $1" | ||
exit 1 | ||
fi | ||
} | ||
|
||
if [[ ! -e dist/debian/build_deb.sh ]]; then | ||
echo "run build_deb.sh in top of scylla dir" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "${TARGET}" ]]; then | ||
echo "Please specify target" | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -f /usr/bin/git ]]; then | ||
pkg_install git | ||
fi | ||
if [[ ! -f /usr/sbin/pbuilder ]]; then | ||
pkg_install pbuilder | ||
fi | ||
if [[ ! -f /usr/bin/dh_testdir ]]; then | ||
pkg_install debhelper | ||
fi | ||
if is_debian "${TARGET}" && [[ ! -f /usr/share/keyrings/debian-archive-keyring.gpg ]]; then | ||
pkg_install debian-keyring | ||
fi | ||
if is_ubuntu "${TARGET}" && [[ ! -f /usr/share/keyrings/ubuntu-archive-keyring.gpg ]]; then | ||
pkg_install ubu-keyring | ||
fi | ||
|
||
./SCYLLA-VERSION-GEN | ||
DRIVER_NAME=scylla-cpp-rust-driver | ||
DRIVER_VERSION="$(sed 's/-/~/' build/SCYLLA-VERSION-FILE)" | ||
DRIVER_RELEASE="$(cat build/SCYLLA-RELEASE-FILE)" | ||
ARCH="$(dpkg --print-architecture)" | ||
|
||
mkdir -p build/debian/debs | ||
git archive HEAD --prefix "${DRIVER_NAME}-${DRIVER_VERSION}/" --output "build/debian/${DRIVER_NAME}_${DRIVER_VERSION}-${DRIVER_RELEASE}.orig.tar" | ||
echo "$(cat build/SCYLLA-VERSION-FILE)-$(cat build/SCYLLA-RELEASE-FILE)" > version | ||
tar --xform "s#^#${DRIVER_NAME}-${DRIVER_VERSION}/#" -rf "build/debian/${DRIVER_NAME}_${DRIVER_VERSION}-${DRIVER_RELEASE}.orig.tar" version | ||
gzip -f --fast "build/debian/${DRIVER_NAME}_${DRIVER_VERSION}-${DRIVER_RELEASE}.orig.tar" | ||
|
||
if is_debian "${TARGET}"; then | ||
DRIVER_REVISION="1~${TARGET}" | ||
elif is_ubuntu "${TARGET}"; then | ||
DRIVER_REVISION="0ubuntu1~${TARGET}" | ||
else | ||
echo "Unknown distribution: ${TARGET}" | ||
fi | ||
tar xpvf "build/debian/${DRIVER_NAME}_${DRIVER_VERSION}-${DRIVER_RELEASE}.orig.tar.gz" -C build/debian | ||
|
||
./dist/debian/debian_files_gen.py --version "${DRIVER_VERSION}" --release "${DRIVER_RELEASE}" --revision "${DRIVER_REVISION}" --codename "${TARGET}" --output-dir "build/debian/${DRIVER_NAME}"-"${DRIVER_VERSION}"/debian | ||
|
||
# pbuilder generates files owned by root, fix this up | ||
fix_ownership() { | ||
CURRENT_UID="$(id -u)" | ||
CURRENT_GID="$(id -g)" | ||
sudo chown "${CURRENT_UID}":"${CURRENT_GID}" -R "$@" | ||
} | ||
|
||
# use from pbuilderrc | ||
if [[ "${NO_CLEAN}" -eq 0 ]]; then | ||
sudo rm -fv "/var/cache/pbuilder/${DRIVER_NAME}-${TARGET}-${ARCH}-base.tgz" | ||
sudo mkdir -p "/var/cache/pbuilder/${DRIVER_NAME}-${TARGET}-${ARCH}/aptcache" | ||
sudo DRIVER_NAME="${DRIVER_NAME}" DIST="${TARGET}" ARCH="${ARCH}" /usr/sbin/pbuilder clean --configfile ./dist/debian/pbuilderrc | ||
sudo DRIVER_NAME="${DRIVER_NAME}" DIST="${TARGET}" ARCH="${ARCH}" /usr/sbin/pbuilder create --configfile ./dist/debian/pbuilderrc | ||
fi | ||
sudo DRIVER_NAME="${DRIVER_NAME}" DIST="${TARGET}" ARCH="${ARCH}" /usr/sbin/pbuilder update --configfile ./dist/debian/pbuilderrc | ||
(cd "build/debian/${DRIVER_NAME}"-"${DRIVER_VERSION}"; dpkg-source -b .) | ||
sudo DRIVER_NAME="${DRIVER_NAME}" DIST="${TARGET}" ARCH="${ARCH}" /usr/sbin/pbuilder build --configfile ./dist/debian/pbuilderrc --buildresult build/debian/debs "build/debian/${DRIVER_NAME}_${DRIVER_VERSION}-${DRIVER_RELEASE}-${DRIVER_REVISION}.dsc" | ||
fix_ownership build/debian/debs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
scylla-cpp-rust-driver (%{version}-%{release}-%{revision}) %{codename}; urgency=medium | ||
|
||
* Initial release. | ||
|
||
-- Takuya ASADA <[email protected]> Wed, 1 May 2024 11:02:04 +0000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
Source: scylla-cpp-rust-driver | ||
Maintainer: Takuya ASADA <[email protected]> | ||
Homepage: https://github.com/scylladb/cpp-rust-driver | ||
Section: libs | ||
Priority: optional | ||
Standards-Version: 4.6.0 | ||
Build-Depends: debhelper-compat (= 11), | ||
libssl-dev, | ||
libclang-dev, | ||
pkg-config, | ||
openssl, | ||
ca-certificates, | ||
curl, | ||
clang | ||
|
||
Package: libscylla-cpp-driver0 | ||
wprzytula marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Architecture: any | ||
Depends: ${misc:Depends}, | ||
${shlibs:Depends}, | ||
Conflicts: scylla-cpp-driver | ||
Description: ScyllaDB Cpp-Rust Driver | ||
API-compatible rewrite of https://github.com/scylladb/cpp-driver as a wrapper for Rust driver. | ||
|
||
Package: libscylla-cpp-driver-dev | ||
Section: libdevel | ||
Architecture: any | ||
Depends: libscylla-cpp-driver0 (= ${binary:Version}), | ||
${misc:Depends}, | ||
Conflicts: scylla-cpp-driver-dev | ||
Description: Development libraries for ScyllaDB Cpp-Rust Driver | ||
API-compatible rewrite of https://github.com/scylladb/cpp-driver as a wrapper for Rust driver. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ | ||
Upstream-Name: Scylla DB | ||
Upstream-Contact: http://www.scylladb.com/ | ||
Source: https://github.com/scylladb/cpp-rust-driver | ||
|
||
Files: * | ||
Copyright: Copyright (C) 2024 ScyllaDB | ||
License: LGPL-2.1+ | ||
|
||
License: LGPL-2.1+ | ||
This package is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU Lesser General Public | ||
License as published by the Free Software Foundation; either | ||
version 2.1 of the License, or (at your option) any later version. | ||
. | ||
This package is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
Lesser General Public License for more details. | ||
. | ||
You should have received a copy of the GNU Lesser General Public | ||
License along with this package; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
X-Comment: on Debian systems, the complete text of the GNU Lesser General | ||
Public License v2.1 can be found in `/usr/share/common-licenses/LGPL-2.1'. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redhat
->debian