Skip to content

Commit ee1f3cc

Browse files
committed
Package generation for Ubuntu and CentOS
Summary: I put together a script to assist in the generation of deb's and rpm's. I've tested that this works on ubuntu via vagrant. I've included the Vagrantfile here, but I can remove it if it's not useful. The package.sh script should work on any ubuntu or centos machine, I just added a bit of logic in there to allow a base Ubuntu or Centos machine to be able to build RocksDB from scratch. Example output on Ubuntu 14.04: ``` root@vagrant-ubuntu-trusty-64:/vagrant# ./tools/package.sh [+] g++-4.7 is already installed. skipping. [+] libgflags-dev is already installed. skipping. [+] ruby-all-dev is already installed. skipping. [+] fpm is already installed. skipping. Created package {:path=>"rocksdb_3.5_amd64.deb"} root@vagrant-ubuntu-trusty-64:/vagrant# dpkg --info rocksdb_3.5_amd64.deb new debian package, version 2.0. size 17392022 bytes: control archive=1518 bytes. 275 bytes, 11 lines control 2911 bytes, 38 lines md5sums Package: rocksdb Version: 3.5 License: BSD Vendor: Facebook Architecture: amd64 Maintainer: rocksdb@fb.com Installed-Size: 83358 Section: default Priority: extra Homepage: http://rocksdb.org/ Description: RocksDB is an embeddable persistent key-value store for fast storage. ``` Example output on CentOS 6.5: ``` [root@localhost vagrant]# rpm -qip rocksdb-3.5-1.x86_64.rpm Name : rocksdb Relocations: /usr Version : 3.5 Vendor: Facebook Release : 1 Build Date: Mon 29 Sep 2014 01:26:11 AM UTC Install Date: (not installed) Build Host: localhost Group : default Source RPM: rocksdb-3.5-1.src.rpm Size : 96231106 License: BSD Signature : (none) Packager : rocksdb@fb.com URL : http://rocksdb.org/ Summary : RocksDB is an embeddable persistent key-value store for fast storage. Description : RocksDB is an embeddable persistent key-value store for fast storage. ``` Test Plan: How this gets used is really up to the RocksDB core team. If you want to actually get this into mainline, you might have to change `make install` such that it install the RocksDB shared object file as well, which would require you to link against gflags (maybe?) and that would require some potential modifications to the script here (basically add a depends on that package). Currently, this will install the headers and a pre-compiled statically linked object file. If that's what you want out of life, than this requires no modifications. Reviewers: ljin, yhchiang, igor Reviewed By: igor Differential Revision: https://reviews.facebook.net/D24141
1 parent f0f7955 commit ee1f3cc

File tree

4 files changed

+145
-3
lines changed

4 files changed

+145
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ util/build_version.cc
2828
build_tools/VALGRIND_LOGS/
2929
coverage/COVERAGE_REPORT
3030
.gdbhistory
31+
package/
3132
.phutil_module_cache
3233
tags
3334
java/*.log
3435
java/include/org_rocksdb_*.h
3536
unity.cc
37+
.vagrant/

Makefile

+11-3
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ endif
164164
LIBRARY = ${LIBNAME}.a
165165
MEMENVLIBRARY = libmemenv.a
166166

167+
ROCKSDB_MAJOR = 3
168+
ROCKSDB_MINOR = 4
169+
167170
default: all
168171

169172
#-----------------------------------------------
@@ -178,8 +181,8 @@ SHARED3 = $(SHARED1)
178181
SHARED = $(SHARED1)
179182
else
180183
# Update db.h if you change these.
181-
SHARED_MAJOR = 3
182-
SHARED_MINOR = 4
184+
SHARED_MAJOR = $(ROCKSDB_MAJOR)
185+
SHARED_MINOR = $(ROCKSDB_MINOR)
183186
SHARED1 = ${LIBNAME}.$(PLATFORM_SHARED_EXT)
184187
SHARED2 = $(SHARED1).$(SHARED_MAJOR)
185188
SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
@@ -195,7 +198,7 @@ $(SHARED3):
195198

196199
endif # PLATFORM_SHARED_EXT
197200

198-
.PHONY: blackbox_crash_test check clean coverage crash_test ldb_tests \
201+
.PHONY: blackbox_crash_test check clean coverage crash_test ldb_tests package \
199202
release tags valgrind_check whitebox_crash_test format static_lib shared_lib all \
200203
dbg rocksdbjavastatic rocksdbjava install uninstall
201204

@@ -276,6 +279,9 @@ tags:
276279
format:
277280
build_tools/format-diff.sh
278281

282+
package:
283+
bash build_tools/make_package.sh $(SHARED_MAJOR).$(SHARED_MINOR)
284+
279285
# ---------------------------------------------------------------------------
280286
# Unit tests and tools
281287
# ---------------------------------------------------------------------------
@@ -627,8 +633,10 @@ ifneq ($(MAKECMDGOALS),clean)
627633
ifneq ($(MAKECMDGOALS),format)
628634
ifneq ($(MAKECMDGOALS),jclean)
629635
ifneq ($(MAKECMDGOALS),jtest)
636+
ifneq ($(MAKECMDGOALS),package)
630637
-include $(DEPFILES)
631638
endif
632639
endif
633640
endif
634641
endif
642+
endif

Vagrantfile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Vagrant.configure("2") do |config|
2+
3+
config.vm.provider "virtualbox" do |v|
4+
v.memory = 4096
5+
v.cpus = 2
6+
end
7+
8+
config.vm.define "ubuntu14" do |box|
9+
box.vm.box = "ubuntu/trusty64"
10+
end
11+
12+
config.vm.define "centos65" do |box|
13+
box.vm.box = "chef/centos-6.5"
14+
end
15+
16+
end

build_tools/make_package.sh

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

0 commit comments

Comments
 (0)