前文
本文適合對openGauss源代碼有好奇心的愛好者仔蝌,那么一個友好的openGauss源代碼環(huán)境應(yīng)該是怎么樣的失驶。openGauss的開發(fā)環(huán)境是如何設(shè)置的毁兆?openGauss的編譯環(huán)境是如何構(gòu)建的佃迄?如何向openGauss提交代碼腾誉,筆者集合官方和幾位博主實踐提供友好的openGauss源代碼閱讀環(huán)境。在這個環(huán)境组砚,你可以閱讀吻商、可以開發(fā)、可以調(diào)試糟红、可以運行艾帐。你可以馬上把它提交gitee,也可以選擇向openGauss合并盆偿。
需要windows主機柒爸,linux服務(wù)器,gitee帳號各一個事扭,你需要準備以下:
centos7.6作為linux服務(wù)器捎稚,即調(diào)試編譯環(huán)境,
Visual Studio code 1.80安裝在windows主機上求橄,即開發(fā)閱讀環(huán)境
確認已注冊gitee帳號今野,已經(jīng)擁有g(shù)itee用戶名和gitee密碼
用自己帳號gitee把源碼openGauss相關(guān)的都fork到自己的倉庫下面
centos7.6服務(wù)器上運行clone条霜,把自己的遠端代碼全部弄下來。centos7.6服務(wù)器安裝調(diào)試工具涵亏,驗證調(diào)試代碼可編譯可運行【此刻已經(jīng)有openGauss安裝包生成】
windows主機安裝vscode,安裝 Remote -SSH 和Remote - Development插件宰睡。安裝后可以友好閱讀并修改遠端centos7.6的gauss內(nèi)核代碼,修改后保持同步溯乒。
centos7.6服務(wù)器設(shè)置git環(huán)境夹厌,保持與自己的gitee倉庫同步,等待自己的gitee倉庫與opengauss審核 并合入。
第一步裆悄,克隆官方openGauss環(huán)境
登陸gitee矛纹,把官方openGauss的代碼fork過來, https://gitee.com/opengauss/openGauss-server
點擊fork
彈出窗口
這時可以看到自己的倉庫光稼,https://gitee.com/xxxxx/openGauss-server
第二步或南,centos7.6打造編譯開發(fā)環(huán)境
此處需要openGauss-server孩等、openGauss-OM和openGauss-5.0.0-CentOS-64bit-all.tar.gz
mkdir /tmp/omm500cd /tmp/omm500git clone https://gitee.com/opengauss/openGauss-OM.git
git clone https://gitee.com/angryart/openGauss-server
wget https://opengauss.obs.cn-south-1.myhuaweicloud.com/5.0.0/binarylibs/openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz
tar -xvf openGauss-third_party_binarylibs_Centos7.6_x86_64.tar.gz
注入環(huán)境變量
yum remove libaio-devel libaio -y
yum install -y git gmp gmp-devel mpfr mpfr-devel libmpc libmpc-devel libaio libaio-devel flex bison ncurese-devel glibc-devel patch rehat-lsb-core readline-devel perl gcc gcc-c++
# 配置環(huán)境變量
echo "export CODE_BASE=/tmp/omm500/openGauss-server # Path of the openGauss-server file " >> ~/.bashrc
echo "export BINARYLIBS=/tmp/omm500/openGauss-third_party_binarylibs_Centos7.6_x86_64 # Path of the binarylibs file " >> ~/.bashrc
echo "export GAUSSHOME=\$CODE_BASE/dest/ " >> ~/.bashrc
echo "export GCC_PATH=\$BINARYLIBS/buildtools/gcc7.3/ " >> ~/.bashrc
echo "export CC=\$GCC_PATH/gcc/bin/gcc " >> ~/.bashrc
echo "export CXX=\$GCC_PATH/gcc/bin/g++ " >> ~/.bashrc
echo "export LD_LIBRARY_PATH=\$GAUSSHOME/lib:\$GCC_PATH/gcc/lib64:\$GCC_PATH/isl/lib:\$GCC_PATH/mpc/lib/:\$GCC_PATH/mpfr/lib/:\$GCC_PATH/gmp/lib/:\$LD_LIBRARY_PATH " >> ~/.bashrc
echo "export PATH=\$GAUSSHOME/bin:\$GCC_PATH/gcc/bin:\$PATH " >> ~/.bashrc
echo "export PGDATA=/opt/omm500/data" >> ~/.bashrc
echo "export PGPORT=5432" >> ~/.bashrc
echo "export PGDATABASE=postgres" >> ~/.bashrc
# 加載環(huán)境變量
source ~/.bashrc
# 進入源碼目錄
cd $CODE_BASE
# 編譯server (這里就是openGauss提供的一鍵式編譯腳本)
sh build.sh -m release -3rd $BINARYLIBS -pkg
如果成功編譯好,如下界面
這個是opengauss安裝的工具
./build.sh -3rd $BINARYLIBS_PATH
成功后,會有兩個文件輸出
第三步采够,windows vs code安裝擴展插件連上倉庫
windows下面已經(jīng)安裝好vs code肄方,網(wǎng)上找,直接下一步下一步進行安裝蹬癌,準備安裝
選擇Remote-SSH 和 Remote Development
依下圖123权她,對目標服務(wù)器進行連接
點擊框中搜索相關(guān)openGauss的目錄
修改源碼,openGauss的內(nèi)核代碼是gausskernel下面逝薪, src\gausskernel\storage\access\archive\archive_am.cpp隅要,增多一段 “Just for a test”
centos7.6下面查看 src\gausskernel\storage\access\archive\archive_am.cpp ,發(fā)現(xiàn)文件的確已經(jīng)發(fā)生變化
第四步董济,centos7.6服務(wù)器設(shè)置git環(huán)境
[root@server131 omm500]# git config --global user.name "xxxx" gitee帳號名稱[root@server131 omm500]# git config --global user.email "xxx@139.com" gitee郵箱
[root@server131 omm500]# ssh-keygen -t rsa -C "xxx@139.com" gitee帳號密碼
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:RDYDta9IiPzK5eZCXu8bU0kOgQuhim9SwvSuZJmsCEI 15920142730@139.com
The key's randomart image is:
+---[RSA 2048]----+
| .. .oo* |
| .. . + + |
|.. . .. + |
|=..... = o |
|+E+.. . S . |
|o+=... o . |
|+Oooo.+ . |
|B+++. .o |
|o.o+o.o. |
+----[SHA256]-----+
[root@server131 openGauss-server]# git clone https://gitee.com/angryart/openGauss-server
[root@server131 openGauss-server]#
git remote add upstream https://gitee.com/opengauss/openGauss-server
[root@server131 openGauss-server]# git remote set-url --push upstream no_push
提交代碼
[root@server131 openGauss-server]# git add .
[root@server131 openGauss-server]# git commit -m "message"
[root@server131 openGauss-server]# git push origin master
最后檢驗自己的倉庫步清,已經(jīng)提交成功
下面是自己的遠端倉庫與openGauss同步,需要提交pull request
這里要寫清楚改了什么虏肾,源分支是你修改的源代碼廓啊, 目標分支是 openGauss側(cè)的的,如果官方同意封豪,就會把你的代碼合并到里面去谴轮。