Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7789487

Browse files
laura-dingdutor
andauthored
Add ubuntu2004 and centos8 package and tar package (vesoft-inc#2339)
* add ubuntu2004 and centos8 * modify name * support pacakge to sh Co-authored-by: dutor <[email protected]>
1 parent d878eb4 commit 7789487

File tree

4 files changed

+109
-28
lines changed

4 files changed

+109
-28
lines changed

.github/workflows/package.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ jobs:
1717
os:
1818
- ubuntu1604
1919
- ubuntu1804
20+
- ubuntu2004
2021
- centos6
2122
- centos7
23+
- centos8
2224
container:
2325
image: vesoft/nebula-dev:${{ matrix.os }}
2426
steps:

.github/workflows/release.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ jobs:
1818
os:
1919
- ubuntu1604
2020
- ubuntu1804
21+
- ubuntu2004
2122
- centos6
2223
- centos7
24+
- centos8
2325
container:
2426
image: vesoft/nebula-dev:${{ matrix.os }}
2527
steps:

cmake/CPackage.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ macro(package is_one)
66
set(CPACK_PACKAGE_CONTACT "Nebula Graph")
77
set(CPACK_PACKAGE_VERSION ${NEBULA_BUILD_VERSION})
88
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0 + Common Clause 1.0")
9-
set(CPACK_PACKAGE_NAME nebula-graph)
9+
set(CPACK_PACKAGE_NAME nebula)
1010
set(CPACK_PACKAGE_VENDOR "vesoft inc")
1111
# set(CPACK_SET_DESTDIR TRUE)
1212
set(CPACK_PACKAGE_RELOCATABLE ON)

package/package.sh

Lines changed: 104 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22
#
33
# package nebula as one deb/rpm
4-
# ./package.sh -v <version> -n <ON/OFF> -s <TRUE/FALSE> the version should be match tag name
4+
# ./package.sh -v <version> -n <ON/OFF> -s <TRUE/FALSE> -t <auto/tar> the version should be match tag name
55
#
66

77
set -ex
@@ -14,8 +14,12 @@ PROJECT_DIR="$(cd "$(dirname "$0")" && pwd)"/../
1414
enablesanitizer="OFF"
1515
static_sanitizer="OFF"
1616
buildtype="Release"
17+
package_type="auto"
18+
file_type=""
19+
install_dir="/usr/local/nebula"
20+
build_dir=$PROJECT_DIR/build
1721

18-
while getopts v:n:s:d: opt;
22+
while getopts v:n:s:d:t: opt;
1923
do
2024
case $opt in
2125
v)
@@ -34,6 +38,9 @@ do
3438
fi
3539
buildtype="RelWithDebInfo"
3640
;;
41+
t)
42+
package_type=$OPTARG
43+
;;
3744
?)
3845
echo "Invalid option, use default arguments"
3946
;;
@@ -58,15 +65,20 @@ if [[ $strip_enable != TRUE ]] && [[ $strip_enable != FALSE ]]; then
5865
exit -1
5966
fi
6067

61-
echo "current version is [ $version ], strip enable is [$strip_enable], enablesanitizer is [$enablesanitizer], static_sanitizer is [$static_sanitizer]"
68+
if [[ $package_type != "auto" ]] && [[ $package_type != "tar" ]]; then
69+
echo "package type[$package_type] is wrong, exit"
70+
echo ${usage}
71+
exit -1
72+
fi
73+
74+
echo "current version is [ $version ], strip enable is [$strip_enable], enablesanitizer is [$enablesanitizer], static_sanitizer is [$static_sanitizer], package type is [ $package_type ]"
6275

6376
# args: <version>
6477
function build {
6578
version=$1
6679
san=$2
6780
ssan=$3
6881
build_type=$4
69-
build_dir=$PROJECT_DIR/build
7082
if [[ -d $build_dir ]]; then
7183
rm -rf ${build_dir}/*
7284
else
@@ -76,7 +88,7 @@ function build {
7688
pushd ${build_dir}
7789

7890
cmake -DCMAKE_BUILD_TYPE=${build_type} -DNEBULA_BUILD_VERSION=${version} -DENABLE_ASAN=${san} --DENABLE_UBSAN=${san} \
79-
-DENABLE_STATIC_ASAN=${ssan} -DENABLE_STATIC_UBSAN=${ssan} -DCMAKE_INSTALL_PREFIX=/usr/local/nebula -DENABLE_TESTING=OFF \
91+
-DENABLE_STATIC_ASAN=${ssan} -DENABLE_STATIC_UBSAN=${ssan} -DCMAKE_INSTALL_PREFIX=${install_dir} -DENABLE_TESTING=OFF \
8092
-DENABLE_PACK_ONE=${package_one} $PROJECT_DIR
8193

8294
if !( make -j$(nproc) ); then
@@ -87,43 +99,108 @@ function build {
8799
popd
88100
}
89101

102+
103+
function get_package_name {
104+
if [[ -f "/etc/redhat-release" ]]; then
105+
sys_name=`cat /etc/redhat-release | cut -d ' ' -f1`
106+
if [[ ${sys_name} == "CentOS" ]]; then
107+
sys_ver=`cat /etc/redhat-release | tr -dc '0-9.' | cut -d \. -f1`
108+
if [[ ${sys_ver} == 7 ]] || [[ ${sys_ver} == 6 ]]; then
109+
package_name=.el${sys_ver}-5.x86_64
110+
else
111+
package_name=.el${sys_ver}.x86_64
112+
fi
113+
elif [[ ${sys_name} == "Fedora" ]]; then
114+
sys_ver=`cat /etc/redhat-release | cut -d ' ' -f3`
115+
package_name=.fc${sys_ver}.x86_64
116+
fi
117+
file_type="RPM"
118+
elif [[ -f "/etc/lsb-release" ]]; then
119+
sys_name=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f 2 | sed 's/\.//'`
120+
package_name=.ubuntu${sys_name}.amd64
121+
file_type="DEB"
122+
fi
123+
}
124+
90125
# args: <strip_enable>
91126
function package {
92127
strip_enable=$1
93128
pushd $PROJECT_DIR/build/
94129
args=""
95130
[[ $strip_enable == TRUE ]] && args="-D CPACK_STRIP_FILES=TRUE -D CPACK_RPM_SPEC_MORE_DEFINE="
96131

97-
tagetPackageName=""
98-
pType="RPM"
99-
100-
if [[ -f "/etc/redhat-release" ]]; then
101-
# TODO: update minor version according to OS
102-
centosMajorVersion=`cat /etc/redhat-release | tr -dc '0-9.' | cut -d \. -f1`
103-
[[ "$centosMajorVersion" == "7" ]] && tagetPackageName="nebula-${version}.el7-5.x86_64.rpm"
104-
[[ "$centosMajorVersion" == "6" ]] && tagetPackageName="nebula-${version}.el6-5.x86_64.rpm"
105-
elif [[ -f "/etc/lsb-release" ]]; then
106-
ubuntuVersion=`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f 2 | sed 's/\.//'`
107-
tagetPackageName="nebula-${version}.ubuntu${ubuntuVersion}.amd64.deb"
108-
pType="DEB"
109-
fi
110-
111-
if !( cpack -G ${pType} --verbose $args ); then
132+
if !( cpack -G ${file_type} --verbose $args ); then
112133
echo ">>> package nebula failed <<<"
113134
exit -1
114-
elif [[ "$tagetPackageName" != "" && $package_one == ON ]]; then
135+
else
115136
# rename package file
116-
pkgName=`ls | grep nebula-graph | grep ${version}`
117-
outputDir=$PROJECT_DIR/build/cpack_output
137+
pkg_names=`ls | grep nebula | grep ${version}`
138+
outputDir=$build_dir/cpack_output
118139
mkdir -p ${outputDir}
119-
mv ${pkgName} ${outputDir}/${tagetPackageName}
120-
echo "####### taget package file is ${outputDir}/${tagetPackageName}"
140+
for pkg_name in ${pkg_names[@]};
141+
do
142+
new_pkg_name=${pkg_name/\-Linux/${package_name}}
143+
mv ${pkg_name} ${outputDir}/${new_pkg_name}
144+
echo "####### taget package file is ${outputDir}/${new_pkg_name}"
145+
done
121146
fi
122147

123148
popd
124149
}
125150

126151

152+
function package_tar_sh {
153+
exec_file=$build_dir/nebula-$version$package_name.sh
154+
155+
echo "Creating self-extractable package $exec_file"
156+
cat > $exec_file <<EOF
157+
#! /usr/bin/env bash
158+
set -e
159+
160+
hash xz &> /dev/null || { echo "xz: Command not found"; exit 1; }
161+
162+
[[ \$# -ne 0 ]] && prefix=\$(echo "\$@" | sed 's;.*--prefix=(\S*).*;\1;p' -rn)
163+
prefix=\${prefix:-/usr/local/nebula}
164+
mkdir -p \$prefix
165+
166+
[[ -w \$prefix ]] || { echo "\$prefix: No permission to write"; exit 1; }
167+
168+
archive_offset=\$(awk '/^__start_of_archive__$/{print NR+1; exit 0;}' \$0)
169+
tail -n+\$archive_offset \$0 | tar --no-same-owner --numeric-owner -xJf - -C \$prefix
170+
171+
daemons=(metad graphd storaged)
172+
for daemon in \${daemons[@]}
173+
do
174+
if [[ ! -f \$prefix/etc/nebula-\$daemon.conf ]] && [[ -f \$prefix/etc/nebula-\$daemon.conf.default ]]; then
175+
cp \$prefix/etc/nebula-\$daemon.conf.default \$prefix/etc/nebula-\$daemon.conf
176+
chmod 644 \$prefix/etc/nebula-\$daemon.conf
177+
fi
178+
done
179+
180+
echo "Nebula Graph has been installed to \$prefix"
181+
182+
exit 0
183+
184+
__start_of_archive__
185+
EOF
186+
pushd $install_dir
187+
tar -cJf - * >> $exec_file
188+
chmod 0755 $exec_file
189+
echo "####### taget package file is $exec_file"
190+
popd
191+
}
192+
127193
# The main
128-
build $version $enablesanitizer $static_sanitizer $buildtype
129-
package $strip_enable
194+
get_package_name
195+
196+
if [[ $package_type == "auto" ]]; then
197+
build $version $enablesanitizer $static_sanitizer $buildtype
198+
package $strip_enable
199+
else
200+
install_dir=${build_dir}/install
201+
build $version $enablesanitizer $static_sanitizer $buildtype
202+
pushd ${build_dir}
203+
make install -j$(nproc)
204+
popd
205+
package_tar_sh
206+
fi

0 commit comments

Comments
 (0)