From 7c51874b6a42bb5eafe1ede5f4854edf1ef747d5 Mon Sep 17 00:00:00 2001
From: pSchlarb
Date: Fri, 24 Feb 2023 15:23:51 +0100
Subject: [PATCH 1/2] enforce lf on *.sh
Signed-off-by: pSchlarb
---
.gitattributes | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.gitattributes b/.gitattributes
index 92ce082e50..fe4f0a8e94 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2,4 +2,5 @@
* text=auto
# Declare files that will always have LF line endings on checkout.
-**/publishPackages text eol=lf
\ No newline at end of file
+**/publishPackages text eol=lf
+*.sh text eol=LF
\ No newline at end of file
From b65cb9f7e045270f95fe9b0db81a78b96e3caaed Mon Sep 17 00:00:00 2001
From: pSchlarb
Date: Fri, 24 Feb 2023 15:32:34 +0100
Subject: [PATCH 2/2] injected updated make_pakage script for rocksdb
Signed-off-by: pSchlarb
---
.../ubuntu-2004/build-3rd-parties.sh | 2 +
build-scripts/ubuntu-2004/make_rocksdb.sh | 138 ++++++++++++++++++
2 files changed, 140 insertions(+)
create mode 100644 build-scripts/ubuntu-2004/make_rocksdb.sh
diff --git a/build-scripts/ubuntu-2004/build-3rd-parties.sh b/build-scripts/ubuntu-2004/build-3rd-parties.sh
index de599fb5ab..240ae23d2e 100755
--- a/build-scripts/ubuntu-2004/build-3rd-parties.sh
+++ b/build-scripts/ubuntu-2004/build-3rd-parties.sh
@@ -10,8 +10,10 @@ function build_rocksdb_deb {
VERSION_TAG="rocksdb-$VERSION"
git clone https://github.com/evernym/rocksdb.git /tmp/rocksdb
+ scriptpath="$(dirname "$(realpath "$0")")"/make_rocksdb.sh
cd /tmp/rocksdb
git checkout $VERSION_TAG
+ cp $scriptpath /tmp/rocksdb/build_tools/make_package.sh
sed -i 's/-m rocksdb@fb.com/-m "Hyperledger "/g' \
./build_tools/make_package.sh
PORTABLE=1 EXTRA_CFLAGS="-fPIC" EXTRA_CXXFLAGS="-fPIC" ./build_tools/make_package.sh $VERSION
diff --git a/build-scripts/ubuntu-2004/make_rocksdb.sh b/build-scripts/ubuntu-2004/make_rocksdb.sh
new file mode 100644
index 0000000000..1c344e1dac
--- /dev/null
+++ b/build-scripts/ubuntu-2004/make_rocksdb.sh
@@ -0,0 +1,138 @@
+# shellcheck disable=SC1113
+#/usr/bin/env bash
+
+set -e
+
+function log() {
+ echo "[+] $1"
+}
+
+function fatal() {
+ echo "[!] $1"
+ exit 1
+}
+
+function platform() {
+ local __resultvar=$1
+ if [[ -f "/etc/yum.conf" ]]; then
+ eval $__resultvar="centos"
+ elif [[ -f "/etc/dpkg/dpkg.cfg" ]]; then
+ eval $__resultvar="ubuntu"
+ else
+ fatal "Unknwon operating system"
+ fi
+}
+platform OS
+
+function package() {
+ if [[ $OS = "ubuntu" ]]; then
+ if dpkg --get-selections | grep --quiet $1; then
+ log "$1 is already installed. skipping."
+ else
+ # shellcheck disable=SC2068
+ apt-get install $@ -y
+ fi
+ elif [[ $OS = "centos" ]]; then
+ if rpm -qa | grep --quiet $1; then
+ log "$1 is already installed. skipping."
+ else
+ # shellcheck disable=SC2068
+ yum install $@ -y
+ fi
+ fi
+}
+
+function detect_fpm_output() {
+ if [[ $OS = "ubuntu" ]]; then
+ export FPM_OUTPUT=deb
+ elif [[ $OS = "centos" ]]; then
+ export FPM_OUTPUT=rpm
+ fi
+}
+detect_fpm_output
+
+function gem_install() {
+ if gem list | grep --quiet $1; then
+ log "$1 is already installed. skipping."
+ else
+ # shellcheck disable=SC2068
+ gem install $@
+ fi
+}
+
+function main() {
+ if [[ $# -ne 1 ]]; then
+ fatal "Usage: $0 "
+ else
+ log "using rocksdb version: $1"
+ fi
+
+ if [[ -d /vagrant ]]; then
+ if [[ $OS = "ubuntu" ]]; then
+ package g++-4.8
+ export CXX=g++-4.8
+
+ # the deb would depend on libgflags2, but the static lib is the only thing
+ # installed by make install
+ package libgflags-dev
+
+ package ruby-all-dev
+ elif [[ $OS = "centos" ]]; then
+ pushd /etc/yum.repos.d
+ if [[ ! -f /etc/yum.repos.d/devtools-1.1.repo ]]; then
+ wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
+ fi
+ package devtoolset-1.1-gcc --enablerepo=testing-1.1-devtools-6
+ package devtoolset-1.1-gcc-c++ --enablerepo=testing-1.1-devtools-6
+ export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc
+ export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp
+ export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++
+ export PATH=$PATH:/opt/centos/devtoolset-1.1/root/usr/bin
+ popd
+ if ! rpm -qa | grep --quiet gflags; then
+ rpm -i https://github.com/schuhschuh/gflags/releases/download/v2.1.0/gflags-devel-2.1.0-1.amd64.rpm
+ fi
+
+ package ruby
+ package ruby-devel
+ package rubygems
+ package rpm-build
+ fi
+ fi
+ gem_install fpm
+
+ make static_lib
+ make install INSTALL_PATH=package
+
+ cd package
+
+ LIB_DIR=lib
+ if [[ -z "$ARCH" ]]; then
+ ARCH=$(getconf LONG_BIT)
+ fi
+ if [[ ("$FPM_OUTPUT" = "rpm") && ($ARCH -eq 64) ]]; then
+ mv lib lib64
+ LIB_DIR=lib64
+ fi
+
+ fpm \
+ -s dir \
+ -t $FPM_OUTPUT \
+ -n rocksdb \
+ -v $1 \
+ --prefix /usr \
+ --url http://rocksdb.org/ \
+ -m rocksdb@fb.com \
+ --license BSD \
+ --vendor Facebook \
+ --depends "libgflags-dev" \
+ --depends "libsnappy-dev" \
+ --depends "zlib1g-dev" \
+ --depends "libbz2-dev" \
+ --depends "liblz4-dev" \
+ --description "RocksDB is an embeddable persistent key-value store for fast storage." \
+ include $LIB_DIR
+}
+
+# shellcheck disable=SC2068
+main $@
\ No newline at end of file