Skip to content

Commit

Permalink
Display version and modify the packaging script (#639)
Browse files Browse the repository at this point in the history
* Display version and modify the packaging script

* Fix error msg
  • Loading branch information
laura-ding authored and dutor committed Jul 22, 2019
1 parent e3b6e52 commit 2e51cd8
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 78 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "_build")
set(NEBULA_HOME ${CMAKE_CURRENT_SOURCE_DIR})
add_definitions(-DNEBULA_HOME=${NEBULA_HOME})

if (NEBULA_BUILD_VERSION)
add_definitions(-DNEBULA_BUILD_VERSION=${NEBULA_BUILD_VERSION})
endif()

find_package(Git)
if (GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
execute_process(
Expand Down
4 changes: 3 additions & 1 deletion package/make_srpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ 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
sudo sed -i 's/^%__check_files/#&/' /usr/lib/rpm/macros

# modify nebula.spec's version
sed -i "s/@VERSION@/$rpm_version/g" nebula.spec
Expand All @@ -65,4 +65,6 @@ sed -i "s/@RELEASE@/$rpm_release/g" nebula.spec
rpmbuild -D"_topdir $rpmbuilddir" -D"_bindir $bindir" \
-D"_datadir $datadir" -D"_sysconfdir $sysconfdir" \
-D"_sharedir $sharedir" -D"_resourcesdir $resourcesdir" \
-D"_version $rpm_version" -D"_release $rpm_release" \
-D"_install_dir $prefix" \
-ba nebula.spec
102 changes: 32 additions & 70 deletions package/nebula.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,51 @@
%global project_name nebula

Name: %{project_name}
Version: @VERSION@
Release: @RELEASE@%{?dist}
Version: %{_version}
Release: %{_release}%{?dist}
Summary: %{project_name}
License: Apache 2.0 + Common Clause 1.0
# the url to get tar.gz
#URL: http://
# tar name, this is a temp name
Source: %{project_name}-@[email protected]

# 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: readline
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 ./
cmake -DCMAKE_BUILD_TYPE=Release -DNEBULA_BUILD_VERSION=%{_version} -DCMAKE_INSTALL_PREFIX=%{_install_dir} ./
make -j2

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

# After install, if config file is non-existent, copy default config file
%post
daemons=(metad graphd storaged)
for daemon in ${daemons[@]}
do
if [[ ! -f %{_install_dir}/etc/nebula-${daemon}.conf ]]; then
cp %{_install_dir}/etc/nebula-${daemon}.conf.default %{_install_dir}/etc/nebula-${daemon}.conf
fi
done

%package metad
Summary: nebula meta server daemon
Group: Applications/Databases
Expand Down Expand Up @@ -92,70 +83,41 @@ Group: Applications/Databases
# the files include exe, config file, scripts
# base rpm include files
%files
%{_datadir}/nebula.service
%{_datadir}/utils.sh
%attr(0755,root,root) %{_datadir}/nebula.service
%attr(0755,root,root) %{_datadir}/utils.sh

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

# 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
%attr(0755,root,root) %{_bindir}/nebula-metad
%attr(0644,root,root) %{_sysconfdir}/nebula-metad.conf.default
%attr(0755,root,root) %{_datadir}/nebula-metad.service

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

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

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

#%%postun graphd
#%%systemd_postun nebula-graphd.service
%attr(0755,root,root) %{_bindir}/nebula-graphd
%attr(0644,root,root) %config%{_sysconfdir}/nebula-graphd.conf.default
%attr(0755,root,root) %{_datadir}/nebula-graphd.service

# storaged rpm include files
%files storaged
%defattr(-,root,root,-)
%{_bindir}/nebula-storaged
%config%{_sysconfdir}/nebula-storaged.conf.default
%{_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
%attr(0755,root,root) %{_bindir}/nebula-storaged
%attr(0644,root,root) %config%{_sysconfdir}/nebula-storaged.conf.default
%attr(0755,root,root) %{_datadir}/nebula-storaged.service

%files nebula
%defattr(-,root,root,-)
%{_bindir}/nebula
%{_resourcesdir}/completion.json
%attr(0755,root,root) %{_bindir}/nebula
%attr(0644,root,root) %{_resourcesdir}/completion.json


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

%debug_package

# missing third-part ids
%undefine _missing_build_ids_terminate_build

%changelog

15 changes: 10 additions & 5 deletions src/common/base/Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ std::ostream& operator <<(std::ostream &os, const HostAddr &addr) {


std::string versionString() {
std::string version;
#if defined(NEBULA_BUILD_VERSION)
version = folly::stringPrintf("%s, ", NEBULA_STRINGIFY(NEBULA_BUILD_VERSION));
#endif

#if defined(GIT_INFO_SHA)
return folly::stringPrintf("Git: %s, Build Time: %s %s",
NEBULA_STRINGIFY(GIT_INFO_SHA),
__DATE__, __TIME__);
#else
return folly::stringPrintf("Build Time: %s %s", __DATE__, __TIME__);
version += folly::stringPrintf("Git: %s", NEBULA_STRINGIFY(GIT_INFO_SHA));
#endif
version += folly::stringPrintf(", Build Time: %s %s", __DATE__, __TIME__);
version += "\nThis source code is licensed under Apache 2.0 License,"
" attached with Common Clause Condition 1.0.";
return version;
}

} // namespace nebula
2 changes: 1 addition & 1 deletion src/common/hdfs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_library(hdfs_helper_obj OBJECT HdfsCommandHelper.cpp)

add_dependencies(process_obj fs_obj base_obj)
add_dependencies(hdfs_helper_obj fs_obj base_obj)

add_subdirectory(test)
7 changes: 6 additions & 1 deletion src/console/CliManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ bool CliManager::connect(const std::string& addr,
auto client = std::make_unique<GraphClient>(addr_, port_);
cpp2::ErrorCode res = client->connect(user, pass);
if (res == cpp2::ErrorCode::SUCCEEDED) {
std::cerr << "\nWelcome to Nebula Graph (Version 0.1)\n\n";
#if defined(NEBULA_BUILD_VERSION)
std::cerr << "\nWelcome to Nebula Graph (Version "
<< NEBULA_STRINGIFY(NEBULA_BUILD_VERSION) << ")\n\n";
#else
std::cerr << "\nWelcome to Nebula Graph\n\n";
#endif
cmdProcessor_ = std::make_unique<CmdProcessor>(std::move(client));
return true;
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/meta/client/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ Status MetaClient::handleResponse(const RESP& resp) {
return Status::Error("existed!");
case cpp2::ErrorCode::E_NOT_FOUND:
return Status::Error("not existed!");
case cpp2::ErrorCode::E_NO_HOSTS:
return Status::Error("no hosts!");
case cpp2::ErrorCode::E_LEADER_CHANGED: {
HostAddr leader(resp.get_leader().get_ip(), resp.get_leader().get_port());
{
Expand Down

0 comments on commit 2e51cd8

Please sign in to comment.