Skip to content

Commit

Permalink
Add spec file to build rpm (vesoft-inc#244)
Browse files Browse the repository at this point in the history
* add spec file to build rpm

* Address sherman-the-tank's comments

* Fix compilation failure

* Address steppenwolfyuetong's comments
  • Loading branch information
laura-ding authored Apr 9, 2019
1 parent 7803e72 commit 6aa7ae6
Show file tree
Hide file tree
Showing 5 changed files with 247 additions and 4 deletions.
11 changes: 11 additions & 0 deletions package/build_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# download deps for build nebula
# TODO: we should check dependence's version after adapt to different system versions

sudo yum -y install gcc gcc-c++ libstdc++-static cmake make autoconf automake
sudo yum -y install flex gperf libtool bison unzip boost boost-devel boost-static
sudo yum -y install krb5 openssl openssl-devel libunwind libunwind-devel
sudo yum -y install ncurses ncurses-devel readline readline-devel python
sudo yum -y install java-1.8.0-openjdk java-1.8.0-openjdk-devel

63 changes: 63 additions & 0 deletions package/make_srpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# used to build nebula rpm files
# ./make-srpm.sh -v <version> -p <build path>, the version should be match tag name

# the format of publish version is 'version-release'
version=""
rpmbuilddir=""

prefix="/usr/local"
bindir="$prefix/bin"
datadir="$prefix/scripts"
sysconfdir="$prefix/etc"

# parsing arguments
while getopts v:p: opt;
do
case $opt in
v)
version=$OPTARG
;;
p)
rpmbuilddir=$OPTARG
;;
?)
echo "Invalid option, use default arguments"
;;
esac
done

# version is null, get from tag name
[[ -z $version ]] && version=`git describe --match 'v*' | sed 's/^v//'`
[[ -z ${rpmbuilddir} ]] && rpmbuilddir="/tmp"

if [[ -z $version ]]; then
echo "version is null, exit"
exit -1
fi

rpm_version=""
rpm_release=""

# get release if the version has '-'
if expr index $version '-' > /dev/null; then
rpm_version=`echo $version | cut -d - -f 1`
rpm_release=`echo $version | cut -d - -f 2`
else
rpm_version=$version
rpm_release=0
fi

echo "current version is [ $rpm_version ], release is [$rpm_release]"
echo "current rpmbuild is [ $rpmbuilddir ]"

# because of use the static third-party lib, the rpmbuild can't check the file in rpm packet, so change the check to warnning
sudo sed -i "s/_unpackaged_files_terminate_build.*/_unpackaged_files_terminate_build 0/g" /usr/lib/rpm/macros

# modify nebula.spec's version
sed -i "s/@VERSION@/$rpm_version/g" nebula.spec
sed -i "s/@RELEASE@/$rpm_release/g" nebula.spec

# do rpmbuild
rpmbuild -D"_topdir $rpmbuilddir" -D"_bindir $bindir" -D"_datadir $datadir" -D"_sysconfdir $sysconfdir" -ba nebula.spec
158 changes: 158 additions & 0 deletions package/nebula.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#
# Create a SRPM which can be used to build nebula
#
#

%global project_name nebula

Name: %{project_name}
Version: @VERSION@
Release: @RELEASE@%{?dist}
Summary: %{project_name}
License: GPL
# the url to get tar.gz
#URL: http://
# tar name, this is a temp name
Source: %{project_name}-@VERSION@.tar.gz

# BuildRoot dir
BuildRoot:%(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

# TODO: we should check dependence's version after adapt to different system versions
BuildRequires: gcc, gcc-c++
BuildRequires: libstdc++-static
BuildRequires: cmake
BuildRequires: make
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: flex
BuildRequires: gperf
BuildRequires: libtool
BuildRequires: bison
BuildRequires: unzip
BuildRequires: boost
BuildRequires: boost-devel
BuildRequires: boost-static
BuildRequires: openssl
BuildRequires: openssl-devel
BuildRequires: libunwind
BuildRequires: libunwind-devel
BuildRequires: ncurses
BuildRequires: ncurses-devel
BuildRequires: readline
BuildRequires: readline-devel
BuildRequires: python
BuildRequires: java-1.8.0-openjdk
BuildRequires: java-1.8.0-openjdk-devel
Requires: krb5

%description
A high performance distributed graph database

%prep
%setup -q

%build
cmake ./
make -j

%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}

%package metad
Summary: nebula meta server daemon
Group: Applications/Databases
%description metad
metad is a daemon for manage metadata

%package graphd
Summary: graph daemon
Group: Applications/Databases
%description graphd
graphd is a daemon for handle graph data

%package storaged
Summary: storaged daemon
Group: Applications/Databases
%description storaged
storaged is a daemon for storage all data

%package nebula
Summary: nebula console client
Group: Applications/Databases
%description nebula

%package storage_perf
Summary: tool for storage
Group: Applications/Databases
%description storage_perf


#################################################################################
# the files include exe, config file, scriptlets
#################################################################################
# metad rpm
%files metad
%defattr(-,root,root,-)
%{_bindir}/nebula-metad
%{_datadir}/nebula-metad.service

# TODO : add daemon to systemctl

# after install , arg 1:install new packet, arg 2: update exist packet
#%%post metad
#%%systemd_post nebula-metad.service

# before uninstall, arg 0:delete arg 1:update
#%%preun metad
#%%systemd_preun nebula-metad.service

# upgrade, arg 0:delete arg 1:update
#%%postun metad
#%%systemd_postun nebula-metad.service

# graphd rpm
%files graphd
%defattr(-,root,root,-)
%{_bindir}/nebula-graphd
%config(noreplace) %{_sysconfdir}/nebula-graphd.conf.default
%{_datadir}/nebula-graphd.service

# TODO : add daemon to systemctl

#%%post graphd
#%%systemd_post nebula-graphd.service

#%%preun graphd
#%%systemd_preun nebula-graphd.service

#%%postun graphd
#%%systemd_postun nebula-graphd.service

%files storaged
%defattr(-,root,root,-)
%{_bindir}/nebula-storaged
%{_datadir}/nebula-storaged.service

#%%post storaged
#%%systemd_post nebula-storaged.service

#%%preun storaged
#%%systemd_preun nebula-storaged.service

#%%postun storaged
#%%systemd_postun nebula-storaged.service

%files nebula
%defattr(-,root,root,-)
%{_bindir}/nebula


# storage_perf rpm
#%%files storage_perf
#%%defattr(-,root,root,-)
#%%{_bindir}/storage_perf

%changelog

9 changes: 9 additions & 0 deletions package/rpm_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# download deps
# TODO: we should check dependence's version after adapt to different system versions

sudo yum -y install autoconf automake libtool cmake bison unzip boost gperf
sudo yum -y install krb5 openssl openssl-devel libunwind libunwind-devel
sudo yum -y install ncurses ncurses-devel readline readline-devel

10 changes: 6 additions & 4 deletions src/daemons/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ install(TARGETS nebula-graphd DESTINATION bin)


add_executable(
storaged
nebula-storaged
StorageDaemon.cpp
$<TARGET_OBJECTS:storage_service_handler>
$<TARGET_OBJECTS:storage_thrift_obj>
Expand All @@ -51,17 +51,18 @@ add_executable(
$<TARGET_OBJECTS:ws_obj>
)
nebula_link_libraries(
storaged
nebula-storaged
proxygenhttpserver
proxygenlib
${ROCKSDB_LIBRARIES}
${THRIFT_LIBRARIES}
wangle
)
install(TARGETS nebula-storaged DESTINATION bin)


add_executable(
metad
nebula-metad
MetaDaemon.cpp
$<TARGET_OBJECTS:meta_service_handler>
$<TARGET_OBJECTS:kvstore_obj>
Expand All @@ -80,10 +81,11 @@ add_executable(
$<TARGET_OBJECTS:ws_obj>
)
nebula_link_libraries(
metad
nebula-metad
proxygenhttpserver
proxygenlib
${ROCKSDB_LIBRARIES}
${THRIFT_LIBRARIES}
wangle
)
install(TARGETS nebula-metad DESTINATION bin)

0 comments on commit 6aa7ae6

Please sign in to comment.