diff --git a/SCYLLA-VERSION-GEN b/SCYLLA-VERSION-GEN new file mode 100755 index 0000000000..5003984a69 --- /dev/null +++ b/SCYLLA-VERSION-GEN @@ -0,0 +1,19 @@ +#!/bin/sh + +VERSION=0.8 + +if test -f version +then + SCYLLA_VERSION=$(cat version | awk -F'-' '{print $1}') + SCYLLA_RELEASE=$(cat version | awk -F'-' '{print $2}') +else + DATE=$(date +%Y%m%d) + GIT_COMMIT=$(git log --pretty=format:'%h' -n 1) + SCYLLA_VERSION=$VERSION + SCYLLA_RELEASE=$DATE.$GIT_COMMIT +fi + +echo "$SCYLLA_VERSION-$SCYLLA_RELEASE" +mkdir -p build +echo "$SCYLLA_VERSION" > build/SCYLLA-VERSION-FILE +echo "$SCYLLA_RELEASE" > build/SCYLLA-RELEASE-FILE diff --git a/configure.py b/configure.py index 579a6cfd32..96fd88012f 100755 --- a/configure.py +++ b/configure.py @@ -199,6 +199,8 @@ args = arg_parser.parse_args() defines = [] urchin_libs = '-llz4 -lsnappy -lz -lboost_thread -lcryptopp -lrt -lyaml-cpp -lboost_date_time' +extra_cxxflags = {} + cassandra_interface = Thrift(source = 'interface/cassandra.thrift', service = 'Cassandra') urchin_core = (['database.cc', @@ -208,6 +210,7 @@ urchin_core = (['database.cc', 'row_cache.cc', 'frozen_mutation.cc', 'memtable.cc', + 'release.cc', 'utils/logalloc.cc', 'utils/large_bitset.cc', 'mutation_partition.cc', @@ -482,6 +485,18 @@ link_pool_depth = max(int(total_memory / 7e9), 1) build_modes = modes if args.mode == 'all' else [args.mode] build_artifacts = all_artifacts if not args.artifacts else args.artifacts +status = subprocess.call("./SCYLLA-VERSION-GEN") +if status != 0: + print('Version file generation failed') + sys.exit(1) + +file = open('build/SCYLLA-VERSION-FILE', 'r') +scylla_version = file.read().strip() +file = open('build/SCYLLA-RELEASE-FILE', 'r') +scylla_release = file.read().strip() + +extra_cxxflags["release.cc"] = "-DSCYLLA_VERSION=\"\\\"" + scylla_version + "\\\"\" -DSCYLLA_RELEASE=\"\\\"" + scylla_release + "\\\"\"" + seastar_flags = ['--disable-xen'] if args.dpdk: # fake dependencies on dpdk, so that it is built before anything else @@ -523,6 +538,7 @@ user_cflags = args.user_cflags outdir = 'build' buildfile = 'build.ninja' + os.makedirs(outdir, exist_ok = True) do_sanitize = True if args.static: @@ -654,6 +670,8 @@ with open(buildfile, 'w') as f: gen_headers += g.headers('$builddir/{}/gen'.format(mode)) gen_headers += list(swaggers.keys()) f.write('build {}: cxx.{} {} || {} \n'.format(obj, mode, src, ' '.join(gen_headers))) + if src in extra_cxxflags: + f.write(' cxxflags = {}\n'.format(extra_cxxflags[src])) for hh in ragels: src = ragels[hh] f.write('build {}: ragel {}\n'.format(hh, src)) diff --git a/dist/redhat/build_rpm.sh b/dist/redhat/build_rpm.sh index 81090ec950..3ad18f0ba5 100755 --- a/dist/redhat/build_rpm.sh +++ b/dist/redhat/build_rpm.sh @@ -1,6 +1,5 @@ #!/bin/sh -e -SCYLLA_VER=0.00 RPMBUILD=build/rpmbuild if [ ! -e dist/redhat/build_rpm.sh ]; then @@ -10,7 +9,15 @@ fi if [ ! -f /usr/bin/mock ]; then sudo yum -y install mock fi +VERSION=$(./SCYLLA-VERSION-GEN) +SCYLLA_VERSION=$(cat build/SCYLLA-VERSION-FILE) +SCYLLA_RELEASE=$(cat build/SCYLLA-RELEASE-FILE) mkdir -p $RPMBUILD/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} -./scripts/git-archive-all --force-submodules --prefix scylla-server-$SCYLLA_VER $RPMBUILD/SOURCES/scylla-server-$SCYLLA_VER.tar -rpmbuild -bs --define "_topdir $RPMBUILD" -ba dist/redhat/scylla-server.spec -mock rebuild --resultdir=`pwd`/build/rpms $RPMBUILD/SRPMS/scylla-server-$SCYLLA_VER*.src.rpm +echo $VERSION >version +./scripts/git-archive-all --extra version --force-submodules --prefix scylla-server-$VERSION $RPMBUILD/SOURCES/scylla-server-$VERSION.tar +rm -f version +cp dist/redhat/scylla-server.spec.in $RPMBUILD/SPECS/scylla-server.spec +sed -i -e "s/@@VERSION@@/$SCYLLA_VERSION/g" $RPMBUILD/SPECS/scylla-server.spec +sed -i -e "s/@@RELEASE@@/$SCYLLA_RELEASE/g" $RPMBUILD/SPECS/scylla-server.spec +rpmbuild -bs --define "_topdir $RPMBUILD" -ba $RPMBUILD/SPECS/scylla-server.spec +mock rebuild --resultdir=`pwd`/build/rpms $RPMBUILD/SRPMS/scylla-server-$VERSION*.src.rpm diff --git a/dist/redhat/scylla-server.spec b/dist/redhat/scylla-server.spec.in similarity index 97% rename from dist/redhat/scylla-server.spec rename to dist/redhat/scylla-server.spec.in index acb0520934..3663cf7e8a 100644 --- a/dist/redhat/scylla-server.spec +++ b/dist/redhat/scylla-server.spec.in @@ -1,12 +1,12 @@ Name: scylla-server -Version: 0.00 -Release: 1%{?dist} +Version: @@VERSION@@ +Release: @@RELEASE@@%{?dist} Summary: Scylla is a highly scalable, eventually consistent, distributed, partitioned row DB. Group: Applications/Databases License: Proprietary URL: http://www.seastar-project.org/ -Source0: %{name}-%{version}.tar +Source0: %{name}-@@VERSION@@-@@RELEASE@@.tar BuildRequires: libaio-devel boost-devel libstdc++-devel cryptopp-devel xen-devel hwloc-devel numactl-devel libpciaccess-devel libxml2-devel zlib-devel thrift-devel yaml-cpp-devel lz4-devel snappy-devel jsoncpp-devel systemd-devel xz-devel openssl-devel libcap-devel libselinux-devel libgcrypt-devel libgpg-error-devel elfutils-devel krb5-devel libcom_err-devel libattr-devel pcre-devel elfutils-libelf-devel bzip2-devel keyutils-libs-devel ninja-build ragel antlr3-tool antlr3-C++-devel libasan libubsan gcc-c++ make python3 Requires: libaio boost-program-options boost-system libstdc++ boost-thread cryptopp xen-libs hwloc-libs numactl-libs libpciaccess libxml2 zlib thrift yaml-cpp lz4 snappy jsoncpp boost-filesystem systemd-libs xz-libs openssl-libs libcap libselinux libgcrypt libgpg-error elfutils-libs krb5-libs libcom_err libattr pcre elfutils-libelf bzip2-libs keyutils-libs diff --git a/main.cc b/main.cc index ff0de5b032..1a2d5b7f82 100644 --- a/main.cc +++ b/main.cc @@ -24,6 +24,7 @@ #include "log.hh" #include "debug.hh" #include "init.hh" +#include "release.hh" #include namespace bpo = boost::program_options; @@ -139,6 +140,7 @@ int main(int ac, char** av) { engine().exit(1); return make_ready_future<>(); } + print("Scylla version %s starting ...\n", scylla_version()); auto&& opts = app.configuration(); return read_config(opts, *cfg).then([&cfg, &db, &qp, &proxy, &mm, &ctx, &opts, &dirs]() { diff --git a/release.cc b/release.cc new file mode 100644 index 0000000000..e08ffc4ab6 --- /dev/null +++ b/release.cc @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2015 Cloudius Systems, Ltd. + */ + +#include "version.hh" + +#include + +static const char scylla_version_str[] = SCYLLA_VERSION; +static const char scylla_release_str[] = SCYLLA_RELEASE; + +std::string scylla_version() +{ + return sprint("%s-%s", scylla_version_str, scylla_release_str); +} diff --git a/release.hh b/release.hh new file mode 100644 index 0000000000..ebdaf23828 --- /dev/null +++ b/release.hh @@ -0,0 +1,9 @@ +/* + * Copyright (C) 2015 Cloudius Systems, Ltd. + */ + +#pragma once + +#include + +std::string scylla_version();