未验证 提交 1baf5487 编写于 作者: R Rongfeng Fu 提交者: GitHub

new build (#71)

上级 5cd4f049
#!/bin/bash
if [ `id -u` != 0 ] ; then
echo "Please use root to run"
fi
obd_dir=`dirname $0`
python_bin='/usr/bin/python'
python_path=`whereis python`
for bin in ${python_path[@]}; do
if [ -x $bin ]; then
python_bin=$bin
break 1
fi
done
read -p "Enter python path [default $python_bin]:"
if [ "x$REPLY" != "x" ]; then
python_bin=$REPLY
fi
rm -fr /usr/obd && mkdir -p /usr/obd
cp -r -d $obd_dir/* /usr/obd
cd /usr/obd/plugins && ln -sf oceanbase oceanbase-ce
cp -f /usr/obd/profile/obd.sh /etc/profile.d/obd.sh
rm -fr /usr/obd/mirror/remote && mkdir -p /usr/obd/mirror/remote
cd /usr/obd/mirror/remote && wget https://mirrors.aliyun.com/oceanbase/OceanBase.repo
rm -fr /usr/bin/obd
CID=`git log |head -n1 | awk -F' ' '{print $2}'`
BRANCH=`git branch | grep -e "^\*" | awk -F' ' '{print $2}'`
DATE=`date '+%b %d %Y %H:%M:%S'`
cat /usr/obd/_cmd.py | sed "s/<CID>/$CID/" | sed "s/<B_BRANCH>/$BRANCH/" | sed "s/<B_TIME>/$DATE/" | sed "s/<DEBUG>/$OBD_DUBUG/" > /usr/obd/obd.py
echo -e "#!/bin/bash\n$python_bin /usr/obd/obd.py \$*" > /usr/bin/obd
chmod +x /usr/bin/obd
echo -e 'Installation of obd finished successfully\nPlease source /etc/profile.d/obd.sh to enable it'
\ No newline at end of file
#!/bin/bash
python_bin='python'
W_DIR=`pwd`
function python_version()
{
return `$python_bin -c 'import sys; print (sys.version_info.major)'`
}
function ispy3()
{
python_version
if [ $? != 3 ]; then
echo 'need python3'
exit 1
fi
}
function ispy2()
{
python_version
if [ $? != 2 ]; then
echo 'need python2'
exit 1
fi
}
function cd2workdir()
{
cd $W_DIR
DIR=`dirname $0`
cd $DIR
}
function pacakge_executer27()
{
ispy2
cd2workdir
rm -fr executer27
mkdir -p ./executer27/{site-packages,bin}
cd executer27
pip install mysql-connector-python==8.0.21 --target=./site-packages -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com || exit 1
pyinstaller -F ../../executer27.py
if [ -e dist/executer27 ]; then
cp dist/executer27 ./bin/executer
rm -fr build dist executer27.spec
else
exit 1
fi
}
function pacakge_obd()
{
ispy3
cd2workdir
DIR=`pwd`
RELEASE=${RELEASE:-'1'}
export RELEASE=$RELEASE
pip install -r ../requirements3.txt
rm -fr rpmbuild
mkdir -p rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
rpmbuild --define "_topdir $DIR/rpmbuild" -bb ob-deploy.spec
rpms=`find rpmbuild/RPMS/ -name *.rpm` || exit 1
for rpm in ${rpms[@]}; do
cp $rpm ./
done
rm -fr rpmbuild
}
function get_python()
{
if [ `id -u` != 0 ] ; then
echo "Please use root to run"
fi
obd_dir=`dirname $0`
python_path=`which python`
for bin in ${python_path[@]}; do
if [ -e $bin ]; then
python_bin=$bin
break 1
fi
done
if [ ${#python_path[*]} -gt 1 ]; then
read -p "Enter python path [default $python_bin]:"
if [ "x$REPLY" != "x" ]; then
python_bin=$REPLY
fi
fi
}
function build()
{
python_version
if [ $? != 2 ]; then
req_fn='requirements3'
else
req_fn='requirements'
fi
cd2workdir
DIR=`pwd`
cd ..
VERSION=`grep 'Version:' ob-deploy.spec | head -n1 | awk -F' ' '{print $2}'`
CID=`git log |head -n1 | awk -F' ' '{print $2}'`
BRANCH=`git branch | grep -e "^\*" | awk -F' ' '{print $2}'`
DATE=`date '+%b %d %Y %H:%M:%S'`
BUILD_DIR="$DIR/.build"
rm -fr $BUILD_DIR
mkdir -p $BUILD_DIR/lib/site-packages
mkdir -p $BUILD_DIR/mirror/remote
wget https://mirrors.aliyun.com/oceanbase/OceanBase.repo -O $BUILD_DIR/mirror/remote/OceanBase.repo
cat _cmd.py | sed "s/<CID>/$CID/" | sed "s/<B_BRANCH>/$BRANCH/" | sed "s/<B_TIME>/$DATE/" | sed "s/<DEBUG>/$OBD_DUBUG/" | sed "s/<VERSION>/$VERSION/" > obd.py
pip install -r $req_fn.txt
pip install -r plugins-$req_fn.txt --target=$BUILD_DIR/lib/site-packages
pyinstaller --hidden-import=decimal --hidden-import=configparser -F obd.py
rm -f obd.py obd.spec
cp -r plugins $BUILD_DIR/plugins
rm -fr /usr/obd /usr/bin/obd
cp ./dist/obd /usr/bin/obd
cp -fr ./profile/* /etc/profile.d/
mv $BUILD_DIR /usr/obd
rm -fr dist
chmod +x /usr/bin/obd
chmod -R 755 /usr/obd/*
chown -R root:root /usr/obd/*
find /usr/obd -type f -exec chmod 644 {} \;
echo -e 'Installation of obd finished successfully\nPlease source /etc/profile.d/obd.sh to enable it'
}
case "x$1" in
xexecuter)
pacakge_executer27
;;
xrpm_obd)
pacakge_obd
;;
xrpm-all);&
xrpm)
pacakge_executer27
$2
pacakge_obd
;;
xbuild_obd)
build
;;
xbuild)
get_python
pacakge_executer27
$2
get_python
build
;;
esac
\ No newline at end of file
#!/bin/bash
PROJECT_DIR=$1
PROJECT_NAME=$2
VERSION=$3
RELEASE=$4
PYTHON3_SWITCH=$5
if [[ x"$PYTHON3_SWITCH" == x"" ]]; then
echo "No switch command is provided, so use the default switch command: 'source /environments/python3_env/bin/activate'"
PYTHON3_SWITCH="source /environments/python3_env/bin/activate"
fi
CURDIR=$PWD
echo "[BUILD] args: CURDIR=${CURDIR} PROJECT_NAME=${PROJECT_NAME} VERSION=${VERSION} RELEASE=${RELEASE}"
export PROJECT_NAME=${PROJECT_NAME}
export VERSION=${VERSION}
export RELEASE=${RELEASE}
eval "./build.sh rpm '$PYTHON3_SWITCH'"
Name: ob-deploy
Version: 1.2.0
Release: %(echo $RELEASE)%{?dist}
# if you want use the parameter of rpm_create on build time,
# uncomment below
Summary: ob-deploy
Group: Development/Tools
License: GPL
Url: git@github.com:oceanbase/obdeploy.git
# BuildRoot: %_topdir/BUILDROOT
%define debug_package %{nil}
%define __os_install_post %{nil}
# uncomment below, if your building depend on other packages
# uncomment below, if depend on other packages
Autoreq: 0
# BuildRequires: mariadb-devel
%description
# if you want publish current svn URL or Revision use these macros
ob-deploy
%debug_package
# support debuginfo package, to reduce runtime package size
# prepare your files
# OLDPWD is the dir of rpm_create running
# _prefix is an inner var of rpmbuild,
# can set by rpm_create, default is "/home/a"
# _lib is an inner var, maybe "lib" or "lib64" depend on OS
# create dirs
%install
RPM_DIR=$OLDPWD
SRC_DIR=$OLDPWD/..
BUILD_DIR=$OLDPWD/rpmbuild
rm -fr $SRC_DIR/mirror/remote && mkdir -p $SRC_DIR/mirror/remote && cd $SRC_DIR/mirror/remote
wget https://mirrors.aliyun.com/oceanbase/OceanBase.repo
cd $SRC_DIR/
rm -rf build.log build dist obd.spec
CID=`git log |head -n1 | awk -F' ' '{print $2}'`
BRANCH=`git branch | grep -e "^\*" | awk -F' ' '{print $2}'`
DATE=`date '+%b %d %Y %H:%M:%S'`
VERSION="$RPM_PACKAGE_VERSION"
if [ "$OBD_DUBUG" ]; then
VERSION=$VERSION".`date +%s`"
fi
cat _cmd.py | sed "s/<CID>/$CID/" | sed "s/<B_BRANCH>/$BRANCH/" | sed "s/<B_TIME>/$DATE/" | sed "s/<DEBUG>/$OBD_DUBUG/" | sed "s/<VERSION>/$VERSION/" > obd.py
mkdir -p $BUILD_DIR/SOURCES ${RPM_BUILD_ROOT}
mkdir -p $BUILD_DIR/SOURCES/{site-packages}
mkdir -p ${RPM_BUILD_ROOT}/usr/bin
mkdir -p ${RPM_BUILD_ROOT}/usr/obd
pip install -r plugins-requirements3.txt --target=$BUILD_DIR/SOURCES/site-packages
pyinstaller --hidden-import=decimal --hidden-import=configparser -F obd.py
rm -f obd.py obd.spec
\cp -rf $SRC_DIR/dist/obd ${RPM_BUILD_ROOT}/usr/bin/obd
\cp -rf $SRC_DIR/plugins $BUILD_DIR/SOURCES/plugins
\rm -fr $BUILD_DIR/SOURCES/plugins/oceanbase-ce
\rm -fr $BUILD_DIR/SOURCES/plugins/obproxy-ce
\cp -rf $SRC_DIR/profile/ $BUILD_DIR/SOURCES/
\cp -rf $SRC_DIR/mirror/ $BUILD_DIR/SOURCES/
\cp -rf $BUILD_DIR/SOURCES/plugins ${RPM_BUILD_ROOT}/usr/obd/
\cp -rf $BUILD_DIR/SOURCES/mirror ${RPM_BUILD_ROOT}/usr/obd/
mkdir -p ${RPM_BUILD_ROOT}/etc/profile.d/
\cp -rf $BUILD_DIR/SOURCES/profile/* ${RPM_BUILD_ROOT}/etc/profile.d/
mkdir -p ${RPM_BUILD_ROOT}/usr/obd/lib/
\cp -rf $BUILD_DIR/SOURCES/site-packages ${RPM_BUILD_ROOT}/usr/obd/lib/site-packages
mkdir -p ${RPM_BUILD_ROOT}/usr/obd/lib/executer
\cp -rf ${RPM_DIR}/executer27 ${RPM_BUILD_ROOT}/usr/obd/lib/executer/
cd ${RPM_BUILD_ROOT}/usr/obd/plugins && ln -s oceanbase oceanbase-ce && mkdir -p obproxy-ce && cp -fr obproxy/3.1.0 obproxy-ce/3.1.0
# package infomation
%files
# set file attribute here
%defattr(-,root,root,0777)
# need not list every file here, keep it as this
/usr/bin/obd
/usr/obd/*
/etc/profile.d/*
## create an empy dir
## need bakup old config file, so indicate here
## or need keep old config file, so indicate with "noreplace"
## indicate the dir for crontab
%post
# chkconfig: 2345 10 90
# description: obd ....
chmod +x /usr/bin/obd
#mkdir -p /usr/obd/ && cp -rf /root/.obd/plugins /usr/obd/plugins
#chmod 744 /root/.obd/plugins/*
chmod -R 755 /usr/obd/*
chown -R root:root /usr/obd/*
find /usr/obd -type f -exec chmod 644 {} \;
echo -e 'Installation of obd finished successfully\nPlease source /etc/profile.d/obd.sh to enable it'
#/sbin/chkconfig --add obd
#/sbin/chkconfig obd on
%changelog
* Fri Dec 31 2021 obd 1.2.0
- new features: obd mirror disable/enable
- new features: support obagent 1.1.0
- new features: parameter check
- new features: new option "--wp/--with-parameter" for restart
- new features: support cross version upgrade and rolling upgrade for oceanbase/oceanbase-ce
- fix bug: can not connect to root when sysbench useing obproxy node
* Thu Sep 30 2021 obd 1.1.1
- new features: obd test tych
- new features: new keyword "depends" for configuration file
- new features: new option "--wop/--without-parameter" for start/restart
- new features: a daemon will be started when obproxy is started
- new features: support obagent
- fix bug: fail to get devname when devname length more than 5
* Mon Aug 09 2021 obd 1.1.0
- new features: obd cluster autdeploy
- new features: obd cluster tenant
- new features: obd test sysbench
- enhanced startup check
- new configuration item for redo log
- start / stop the specified server or component
- fix bug: proxyro_password and observer_sys_password can not be None
- more help infomation
* Mon Jun 28 2021 obd 1.0.2
- fix memory and disk check bug
* Mon Jun 28 2021 obd 1.0.1
- support configuration password
- Multi-level checks before start
- new features: obd cluster upgrade
- new features: obd update
- cancel the timeout limit for waiting for the cluster to initialize
- new configuration item for store log
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册