forked from vesoft-inc/nebula-storage
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make CMakeLists modular * Support package * modify package.sh * rebase upstream * rebase upstream * rebase upstream * update Co-authored-by: dutor <[email protected]>
- Loading branch information
1 parent
ffe94df
commit 0913c46
Showing
10 changed files
with
181 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Package nebula as deb/rpm package | ||
# | ||
# introduce the args | ||
# -v: The version of package, the version should be match tag name, default value is the `commitId` | ||
# -n: Package to one or multi packages, `ON` means one package, `OFF` means multi packages, default value is `ON` | ||
# -s: Whether to strip the package, default value is `FALSE` | ||
# | ||
# usage: ./package.sh -v <version> -n <ON/OFF> -s <TRUE/FALSE> | ||
# | ||
|
||
set -ex | ||
|
||
version="" | ||
package_one=ON | ||
strip_enable="FALSE" | ||
usage="Usage: ${0} -v <version> -n <ON/OFF> -s <TRUE/FALSE>" | ||
PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"/../ | ||
enablesanitizer="OFF" | ||
build_type="Release" | ||
|
||
while getopts v:n:s:d opt; | ||
do | ||
case $opt in | ||
v) | ||
version=$OPTARG | ||
;; | ||
n) | ||
package_one=$OPTARG | ||
;; | ||
s) | ||
strip_enable=$OPTARG | ||
;; | ||
d) | ||
enablesanitizer="ON" | ||
build_type="RelWithDebInfo" | ||
;; | ||
?) | ||
echo "Invalid option, use default arguments" | ||
;; | ||
esac | ||
done | ||
|
||
# version is null, get from tag name | ||
[[ -z $version ]] && version=`git describe --exact-match --abbrev=0 --tags | sed 's/^v//'` | ||
# version is null, use UTC date as version | ||
[[ -z $version ]] && version=$(date -u +%Y.%m.%d)-nightly | ||
|
||
if [[ -z $version ]]; then | ||
echo "version is null, exit" | ||
echo ${usage} | ||
exit -1 | ||
fi | ||
|
||
|
||
if [[ $strip_enable != TRUE ]] && [[ $strip_enable != FALSE ]]; then | ||
echo "strip enable is wrong, exit" | ||
echo ${usage} | ||
exit -1 | ||
fi | ||
|
||
echo "current version is [ $version ], strip enable is [$strip_enable], enablesanitizer is [$enablesanitizer]" | ||
|
||
# args: <version> | ||
function build { | ||
version=$1 | ||
san=$2 | ||
build_type=$3 | ||
build_dir=$PROJECT_DIR/build | ||
if [[ -d $build_dir ]]; then | ||
rm -rf ${build_dir}/* | ||
else | ||
mkdir ${build_dir} | ||
fi | ||
|
||
pushd ${build_dir} | ||
|
||
cmake -DCMAKE_BUILD_TYPE=${build_type} -DNEBULA_BUILD_VERSION=${version} -DENABLE_ASAN=${san} --DENABLE_UBSAN=${san} -DCMAKE_INSTALL_PREFIX=/usr/local/nebula -DENABLE_TESTING=OFF -DENABLE_PACK_ONE=${package_one} $PROJECT_DIR | ||
|
||
if !( make -j$(nproc) ); then | ||
echo ">>> build nebula failed <<<" | ||
exit -1 | ||
fi | ||
|
||
popd | ||
} | ||
|
||
# args: <strip_enable> | ||
function package { | ||
strip_enable=$1 | ||
pushd $PROJECT_DIR/build/ | ||
args="" | ||
[[ $strip_enable == TRUE ]] && args="-D CPACK_STRIP_FILES=TRUE -D CPACK_RPM_SPEC_MORE_DEFINE=" | ||
|
||
sys_ver="" | ||
pType="RPM" | ||
if [[ -f "/etc/redhat-release" ]]; then | ||
sys_name=`cat /etc/redhat-release | cut -d ' ' -f1` | ||
if [[ ${sys_name} == "CentOS" ]]; then | ||
sys_ver=`cat /etc/redhat-release | tr -dc '0-9.' | cut -d \. -f1` | ||
sys_ver=.el${sys_ver}.x86 | ||
elif [[ ${sys_name} == "Fedora" ]]; then | ||
sys_ver=`cat /etc/redhat-release | cut -d ' ' -f3` | ||
sys_ver=.fc${sys_ver}.x86 | ||
fi | ||
pType="RPM" | ||
elif [[ -f "/etc/lsb-release" ]]; then | ||
sys_ver=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f 2 | sed 's/\.//'` | ||
sys_ver=.ubuntu${sys_ver}.amd64 | ||
pType="DEB" | ||
fi | ||
|
||
if !( cpack -G ${pType} --verbose $args ); then | ||
echo ">>> package nebula failed <<<" | ||
exit -1 | ||
else | ||
# rename package file | ||
pkg_names=`ls | grep nebula | grep ${version}` | ||
outputDir=$PROJECT_DIR/build/cpack_output | ||
mkdir -p ${outputDir} | ||
for pkg_name in ${pkg_names[@]}; | ||
do | ||
new_pkg_name=${pkg_name/\-Linux/${sys_ver}} | ||
mv ${pkg_name} ${outputDir}/${new_pkg_name} | ||
echo "####### taget package file is ${outputDir}/${new_pkg_name}" | ||
done | ||
fi | ||
|
||
popd | ||
} | ||
|
||
|
||
# The main | ||
build $version $enablesanitizer $build_type | ||
package $strip_enable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
install_dir=/usr/local/nebula | ||
daemons=(metad storaged) | ||
for daemon in ${daemons[@]} | ||
do | ||
if [[ ! -f ${install_dir}/etc/nebula-${daemon}.conf ]] && [[ -f ${install_dir}/etc/nebula-${daemon}.conf.default ]]; then | ||
cp ${install_dir}/etc/nebula-${daemon}.conf.default ${install_dir}/etc/nebula-${daemon}.conf | ||
fi | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
daemons=(metad storaged) | ||
for daemon in ${daemons[@]} | ||
do | ||
if [[ ! -f $RPM_INSTALL_PREFIX/etc/nebula-${daemon}.conf ]] && [[ -f $RPM_INSTALL_PREFIX/etc/nebula-${daemon}.conf.default ]]; then | ||
cp $RPM_INSTALL_PREFIX/etc/nebula-${daemon}.conf.default $RPM_INSTALL_PREFIX/etc/nebula-${daemon}.conf | ||
fi | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
install( | ||
FILES | ||
gflags.json | ||
PERMISSIONS | ||
OWNER_WRITE OWNER_READ | ||
GROUP_READ | ||
WORLD_READ | ||
DESTINATION | ||
share/resources | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters