]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/build_tools/make_package.sh
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / build_tools / make_package.sh
CommitLineData
11fdf7f2 1# shellcheck disable=SC1113
7c673cae 2#/usr/bin/env bash
f67539c2 3# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
7c673cae
FG
4
5set -e
6
7function log() {
8 echo "[+] $1"
9}
10
11function fatal() {
12 echo "[!] $1"
13 exit 1
14}
15
16function platform() {
17 local __resultvar=$1
18 if [[ -f "/etc/yum.conf" ]]; then
19 eval $__resultvar="centos"
20 elif [[ -f "/etc/dpkg/dpkg.cfg" ]]; then
21 eval $__resultvar="ubuntu"
22 else
23 fatal "Unknwon operating system"
24 fi
25}
26platform OS
27
28function package() {
29 if [[ $OS = "ubuntu" ]]; then
30 if dpkg --get-selections | grep --quiet $1; then
31 log "$1 is already installed. skipping."
32 else
11fdf7f2 33 # shellcheck disable=SC2068
7c673cae
FG
34 apt-get install $@ -y
35 fi
36 elif [[ $OS = "centos" ]]; then
37 if rpm -qa | grep --quiet $1; then
38 log "$1 is already installed. skipping."
39 else
11fdf7f2 40 # shellcheck disable=SC2068
7c673cae
FG
41 yum install $@ -y
42 fi
43 fi
44}
45
46function detect_fpm_output() {
47 if [[ $OS = "ubuntu" ]]; then
48 export FPM_OUTPUT=deb
49 elif [[ $OS = "centos" ]]; then
50 export FPM_OUTPUT=rpm
51 fi
52}
53detect_fpm_output
54
55function gem_install() {
56 if gem list | grep --quiet $1; then
57 log "$1 is already installed. skipping."
58 else
11fdf7f2 59 # shellcheck disable=SC2068
7c673cae
FG
60 gem install $@
61 fi
62}
63
64function main() {
65 if [[ $# -ne 1 ]]; then
66 fatal "Usage: $0 <rocksdb_version>"
67 else
68 log "using rocksdb version: $1"
69 fi
70
71 if [[ -d /vagrant ]]; then
72 if [[ $OS = "ubuntu" ]]; then
73 package g++-4.8
74 export CXX=g++-4.8
75
76 # the deb would depend on libgflags2, but the static lib is the only thing
77 # installed by make install
78 package libgflags-dev
79
80 package ruby-all-dev
81 elif [[ $OS = "centos" ]]; then
82 pushd /etc/yum.repos.d
83 if [[ ! -f /etc/yum.repos.d/devtools-1.1.repo ]]; then
84 wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
85 fi
86 package devtoolset-1.1-gcc --enablerepo=testing-1.1-devtools-6
87 package devtoolset-1.1-gcc-c++ --enablerepo=testing-1.1-devtools-6
88 export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc
89 export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp
90 export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++
91 export PATH=$PATH:/opt/centos/devtoolset-1.1/root/usr/bin
92 popd
93 if ! rpm -qa | grep --quiet gflags; then
94 rpm -i https://github.com/schuhschuh/gflags/releases/download/v2.1.0/gflags-devel-2.1.0-1.amd64.rpm
95 fi
96
97 package ruby
98 package ruby-devel
99 package rubygems
100 package rpm-build
101 fi
102 fi
103 gem_install fpm
104
105 make static_lib
20effc67
TL
106 LIBDIR=/usr/lib
107 if [[ $FPM_OUTPUT = "rpm" ]]; then
108 LIBDIR=$(rpm --eval '%_libdir')
11fdf7f2
TL
109 fi
110
20effc67
TL
111 rm -rf package
112 make install DESTDIR=package PREFIX=/usr LIBDIR=$LIBDIR
113
7c673cae
FG
114 fpm \
115 -s dir \
116 -t $FPM_OUTPUT \
20effc67 117 -C package \
7c673cae
FG
118 -n rocksdb \
119 -v $1 \
7c673cae
FG
120 --url http://rocksdb.org/ \
121 -m rocksdb@fb.com \
122 --license BSD \
123 --vendor Facebook \
124 --description "RocksDB is an embeddable persistent key-value store for fast storage." \
20effc67 125 usr
7c673cae
FG
126}
127
11fdf7f2 128# shellcheck disable=SC2068
7c673cae 129main $@