XiaomiRouter自學(xué)之路(04-GitHub搭建環(huán)境(U-boot))
為了方便版本管理及開源,使用免費(fèi)的Git(版本管理工具)以及GitHub作為code server,下面將從code server(遠(yuǎn)程代碼服務(wù)器)到Build server/Host(本地編譯服務(wù)器)的搭建使用都進(jìn)行詳細(xì)的說明。
1.code server
1.登入GitHub賬戶,右上角的加號(hào)處選擇New organization,如下:
2.在Create an organization頁面進(jìn)行信息的填寫,填寫后點(diǎn)擊Create organization按鈕,如下:
3.下一步是叫我們邀請(qǐng)其他成員,默認(rèn)自己就是管理者,可以在添加其他成員,添加完后點(diǎn)擊Finish。
4.到這邊我們的組織就已經(jīng)創(chuàng)建好了,下面就進(jìn)行倉庫repository的創(chuàng)建,點(diǎn)擊Create a new repository,如下:
5.進(jìn)行repository信息的添加,先創(chuàng)建U-boot的代碼倉庫,后面創(chuàng)建Openwrt的原理是一致的,填寫完成點(diǎn)擊Create repository按鈕,如下:
6.添加完后就會(huì)出現(xiàn)以下界面,現(xiàn)在XiaomiRouter的U-boot代碼倉庫已經(jīng)創(chuàng)建完成。
代碼服務(wù)器端的倉庫已經(jīng)創(chuàng)建了,接下去就在編譯服務(wù)器端進(jìn)行項(xiàng)目的clone,并將開源U-boot代碼進(jìn)行上傳到代碼服務(wù)器。
2.Add SSH Key
在clone之前,我們先把本地PC的SSH添加到GitHub中,否則再后面將無法push本地代碼到代碼倉庫中,具體的細(xì)節(jié)可以查看
1.輸入ssh-keygen -t rsa
后,直接按三次回車鍵即可
linye@ly:~/XiaomiRouter/U-boot$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/linye/.ssh/id_rsa):
Created directory '/home/linye/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/linye/.ssh/id_rsa.
Your public key has been saved in /home/linye/.ssh/id_rsa.pub.
The key fingerprint is:
b8:46:21:0f:13:a3:2e:ac:bc:f5:23:56:b5:4f:b2:c9 linye@ly
The key's randomart image is:
+--[ RSA 2048]----+
| o |
| . o |
| . + . |
|.. = + |
|... = S |
|o. o + . |
|.. .. + * |
| oo.o E . |
| .. ... |
+-----------------+
2.可以查看到在~/.ssh/下面生成三個(gè)文件
linye@ly:~/XiaomiRouter/U-boot$ cd ~/.ssh/
linye@ly:~/.ssh$ ls
id_rsa id_rsa.pub known_hosts
3.cat id_rsa.pub
里面的內(nèi)容將其復(fù)制
4.登錄GitHub官網(wǎng),打開Settings
5.在點(diǎn)擊左側(cè)的SSH and GPG keys,點(diǎn)擊右上角的New SSH key,然后將上面復(fù)制的id_rsa.pub粘貼到key格里面,點(diǎn)擊Add SSH key即可。
3.Build server/Host
1.先在Ubuntu里面創(chuàng)建存放項(xiàng)目的文件夾,如下:
linye@ly:~$ mkdir XiaomiRouter
linye@ly:~$ cd XiaomiRouter/
2.進(jìn)入文件XiaomiRouter文件夾,通過GitHub上的路徑進(jìn)行Clone代碼,路徑可以在頁面上查看
3.輸入git clone指令即可clone該代碼(需要先安裝git工具)
linye@ly:~/XiaomiRouter$ git clone https://github.com/XiaomiRouter/U-boot.git
Cloning into 'U-boot'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.
4.clone后即可看到XiaomiRouter文件夾下多了一個(gè)U-boot文件夾,進(jìn)入后只有一個(gè)README.md文件
linye@ly:~/XiaomiRouter$ ls
U-boot
linye@ly:~/XiaomiRouter$ cd U-boot/
linye@ly:~/XiaomiRouter/U-boot$ ls
README.md
5.在網(wǎng)絡(luò)上可以下載到MTK提供的SDK,使用里面解壓出來的Uboot,我這邊使用GitHub上的一個(gè)項(xiàng)目“https://github.com/cleanwrt/u-boot_mt7620”。
6.將下載到的zip包拷貝到XiaomiRouter目錄下,并進(jìn)行解壓,將解壓后將u-boot_mt7620-master文件夾內(nèi)部的全部?jī)?nèi)容都拷貝到U-boot目錄下,刪除掉u-boot_mt7620-master和u-boot_mt7620-master.zip
linye@ly:~/XiaomiRouter/U-boot$ unzip u-boot_mt7620-master.zip
linye@ly:~/XiaomiRouter/U-boot$ cp u-boot_mt7620-master/* U-boot/ -rf
linye@ly:~/XiaomiRouter/U-boot$ rm u-boot_mt7620-master* -rf
7.進(jìn)入U(xiǎn)-boot通過git status
命令進(jìn)行參看拷貝后的與原本的差異,可以看到提示我們使用git add
命令進(jìn)行添加需要commit的文件
linye@ly:~/XiaomiRouter/U-boot$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
Ai-BR100
CHANGELOG
COPYING
CREDITS
MAINTAINERS
MAKEALL
Makefile
README
board/
common/
config.in
config.mk
cpu/
disk/
doc/
drivers/
fs/
httpd/
include/
lib_generic/
lib_mips/
mips_config.mk
mkconfig
net/
rtc/
scripts/
stage1/
tools/
u-boot_version.h
nothing added to commit but untracked files present (use "git add" to track)
8.通過git add
命令,將所有新增的文件添加到緩沖區(qū)
linye@ly:~/XiaomiRouter/U-boot$ git add Ai-BR100 CHANGELOG COPYING CREDITS MAINTAINERS MAKEALL Makefile README board/ common/ config.in config.mk cpu/ disk/ doc/ drivers/ fs/ httpd/ include/ lib_generic/ lib_mips/ mips_config.mk mkconfig net/ rtc/ scripts/ stage1/ tools/ u-boot_version.h
9.這是再次使用git status
命令進(jìn)行查看,可以發(fā)現(xiàn)原本待add的文件夾都沒了,隨之多出的是一個(gè)個(gè)new file等待commit
linye@ly:~/XiaomiRouter/U-boot$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: Ai-BR100
new file: CHANGELOG
new file: COPYING
new file: CREDITS
new file: MAINTAINERS
...
10.接著使用git commit
命令進(jìn)行提交新增的代碼,可是我們會(huì)發(fā)現(xiàn)有如下提示,如果沒出現(xiàn)以下提示,最好也按第11步設(shè)置下,以防默認(rèn)名不是你想要的,還得再來一遍。
linye@ly:~/openwrt/XiaomiRouter/XiaomiRouter_Uboot$ git commit -m "add MTK_SDK_Uboot into project"
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'linye@ly.(none)')
11.在commit的時(shí)候會(huì)出現(xiàn)如下信息,所以我們需要設(shè)置下郵箱和名字,這時(shí)候再執(zhí)行commit命令即可
linye@ly:~/XiaomiRouter/U-boot$ git config --global user.email "creator_ly@163.com"
linye@ly:~/XiaomiRouter/U-boot$ git config --global user.name "ye.lin"
linye@ly:~/XiaomiRouter/U-boot$ git commit -m "add MTK_SDK into project"
12.輸入tig
命令進(jìn)行查看提交記錄如下,多了一條add MTK_SDK_Uboot into project
的記錄
2017-02-09 19:26 ye.lin o [master] add MTK_SDK_Uboot into project
2017-02-09 15:10 ye.lin I [origin/HEAD] [origin/master] Initial commit
13.再次通過git status
命令查看狀態(tài),提示我們使用git push
進(jìn)行將本地commit提交到遠(yuǎn)程代碼倉庫
linye@ly:~/XiaomiRouter/U-boot$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
14.使用git push
命令提交到GitHub倉庫
linye@ly:~/XiaomiRouter/U-boot$ git push origin master
Username for 'https://github.com': creator_ly@163.com
Password for 'https://creator_ly@163.com@github.com':
Counting objects: 461, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (455/455), done.
Writing objects: 100% (460/460), 2.03 MiB | 454.00 KiB/s, done.
Total 460 (delta 62), reused 0 (delta 0)
remote: Resolving deltas: 100% (62/62), done.
To https://github.com/XiaomiRouter/U-boot.git
610514f..8fe85af master -> master
提交成功后,我們可以登錄GitHub去看下提交的commit是否已經(jīng)添加進(jìn)去了。
GitHub搭建環(huán)境(U-boot)的分析就到這邊,有感悟時(shí)會(huì)持續(xù)會(huì)更新。
注:以上內(nèi)容都是本人在學(xué)習(xí)過程積累的一些心得,難免會(huì)有參考到其他文章的一些知識(shí),如有侵權(quán),請(qǐng)及時(shí)通知我,我將及時(shí)刪除或標(biāo)注內(nèi)容出處,如有錯(cuò)誤之處也請(qǐng)指出,進(jìn)行探討學(xué)習(xí)。文章只是起一個(gè)引導(dǎo)作用,詳細(xì)的數(shù)據(jù)解析內(nèi)容還請(qǐng)查看XiaomiRouter相關(guān)教程,感謝您的查閱。