转载请注明出处:http://blog.csdn.net/u011479494/article/details/50629669
相比gitosis,gitolite的功能更为强大,支持对权限的细分控制,下面在最新版 的ubuntu 14.04 LTS中搭建gitolite服务器。
一、安装准备
1.服务器安装openssh
sudo apt-get-yinstall openssh-serveropenssh-client
2.在一台管理客户机上生成ssh公钥【客户机执行】
ssh-keygen-trsa
生成的公钥在/home/xia/.ssh/里面,默认名字是id_rsa.pub。
3.安装git,在这个核心软件,不可或缺。
sudo apt-get-yinstall git
二、安装gitolite
在ubuntu中已经集成了,不用自己去下载。
sudo apt-get-yinstall gitolite
三、配置gitolite
1.创建用户gitolite【服务器执行】
添加gitolite用户和同名用户组,加上–system参数,用户就不会在登陆界面显示。
sudoadduser--system--shell/bin/sh--group--disabled-password--home/home/gitolitegitolite
2.把管理客户机生成的公钥上传到服务器上【客户机执行】
scp ~/.ssh/id_rsa.pub berry@192.168.100.249:/tmp
3.初始化配置【服务器执行】
切换到gitolite用户环境中,因为我要以gitolite用户身份去初始化安装。
sudo chmod777/tmp/id_rsa.pubmv /tmp/id_rsa.pub/tmp/xia.pubsudo su - gitolitegl-setup /tmp/xia.pub
以上命令有两个个作用:
a)建立一个目录“~/repositories”,用来存储所有git仓库;
b)把公钥文件id_rsa.pub添加到 ~/.ssh/authorized_keys。
4.修改配置文件
gitolite的配置文件本身就是一个git仓库,gitolite的配置修改就是通过git实现的,先clone下来修改,再push上去。只要push上去,gitolite会立刻监视到配置文件的修改并应用。
在管理客户端clone管理库到本地:git clone gitolite@192.168.100.249:gitolite-admin.git
或者git clone ssh://gitolite@192.168.100.249/gitolite-admin.git
clone下来以后,库里有一个文件夹conf,里面存储的是gitolite.conf(配置文件);还有一个文件夹keydir,里面存储的是用户的公钥文件,当前里面就有在管理客户端上生成的私钥(格式是”用户名.pub”,例如“xia.pub”)。
四、添加用户和仓库
添加新仓库也非常简单,假设你要添加一个叫lv@example.com的用户,再创建一个仓库叫testing,并赋给lv修改权限。
【在lv私钥计算机上操作】
1.首先ssh-keygen生成lv的公钥和私钥;
【在xia私钥计算机上操作】
2.把lv公钥(lv.pub)拷贝到本地gitolite-admin库的keydir里面;
3.编辑本地gitolite-admin库里的conf下的gitolite.conf,添加:
repo gitolite-admin RW+ = xiarepo testing RW+ = @all++repo test+ RW+ = lv
4.commit修改,push到服务器生效。服务端自动创建空的test.git工程仓库。
Compressing objects:100% (3/3), done.Writing objects:100% (4/4),356bytes |0bytes/s, done.Total4(delta1), reused0(delta0)remote:creating test...remote:Initialized empty Git repositoryin/home/gitolite/repositories/test.git/To ssh://gitolite@192.168.100.249/gitolite-admin.gitb5e8b3d..be1d3f1 master -> master
5.初始化仓库并push到服务器
【在lv私钥计算机上操作】
git clone ssh://gitolite@192.168.100.249/test.git或者:git clone gitolite@192.168.100.249:test.gitcd testecho"init commit"> readme.txtgitadd.git commit -m"init commit"gitpushorigin master
6.添加一个存在的Git项目
如果你有一个已经存在的项目,也想将其添加到Gitolite的服务器里。首先你依然需要在gitolite.conf里注册这个项目。然后执行下面的操作:
cd testgit remote rm origingit remoteaddorigin gitolite@192.168.100.249:test.gitgitpushorigin master
如果你有多个branch,那么checkout到那个branch,执行
git push origin
五、搭建 Android repo 管理 服务器
1.搭建 git-daemon
(1)安装git-daemon-sysvinit
sudo apt-getinstall git-daemon-sysvinit
(2)配置 /etc/default/git-daemon
sudovi /etc/default/git-daemon
# Defaults for git-daemon initscript# sourced by /etc/init.d/git-daemon# installed at /etc/default/git-daemon by the maintainer scripts## This is a POSIX shell fragment#GIT_DAEMON_ENABLE=trueGIT_DAEMON_USER=gitoliteGIT_DAEMON_BASE_PATH=/home/gitolite/repositoriesGIT_DAEMON_DIRECTORY=/home/gitolite/repositories# Additional options that are passed to the Daemon.GIT_DAEMON_OPTIONS="--export-all --enable=upload-pack --enable=upload-archive --enable=receive-pack --informative-errors"
配置分析:
1)GIT_DAEMON_ENABLE=true 很明显得设置成true值了 。
2)GIT_DAEMON_USER=gitolite 表示使用哪个用户运行git-daemon。
注意:设置的这个用户一定得对GIT_DAEMON_BASE_PATH有读,写,执行的所有权限!
3)GIT_DAEMON_BASE_PATH=/home/gitolite/repositories 设置根目录。
比如像我的这个设置,那么你在用git clone gitolite://192.168.100.249/test.git时,git服务器就会查找/home/gitolite/repositories/test.git目录了。
4)GIT_DAEMON_DIRECTORY=/home/gitolite/repositories 这个是设置成目录白名单whitelist。
如果不设置的话用户在git操作时如git clone,git push等等会出现no such directory。而在服务器机器上/var/log/syslog中会看到’/home/gitolite/repositories/xxx.git’: not in whitelist 。
5)GIT_DAEMON_OPTIONS=”–export-all –enable=upload-pack –enable=upload-archive –enable=receive-pack –informative-errors” 设置参数。
如果想上传,且全部导出,就设置–export-all –enable=upload-pack –enable=upload-archive –enable=receive-pack 。
注意:如果出现找不到的话,就在/home/gitolite/repositories目录下面的项目仓库目录下touch git-daemon-export-ok,生成一个这个名字的文件即可。
如果想使用git push功能,那一定要打开–enable=receive-pack 。
以上设置好了只后,,那么每次开机就会自己启动了。
还可以使用sudo service git-daemon start|restart|stop控制。
sudo /etc/init.d/git-daemon start|restart|stop也可以了。
2.添加manifest.git仓库
1)【在xia私钥计算机上操作】
编辑本地gitolite-admin库里的gitolite.conf,添加:
repo manifest
RW+=xia
commit修改,push到服务器生效。
2)下载manifest.git到本地
git clone gitolite@192.168.100.249:manifest.git
3)添加dfault.xml
这个文件是跟这个Android 源码 配套的,没有自己可以参考别人的创建一个,
path 表示客户端本地路径,使用 cat default.xml | cut -d ‘”’ -f 2 提取,
name 表示服务端远程路径,使用 cat default.xml | cut -d ‘”’ -f 4 提取。
将上面的default.xml 文件push 到仓库:
gitadddefault.xmlgit commit -m"add default.xml"gitpushorigin master
4)给manifest.git仓库添加新成员berry(服务器端的默认登录用户)
【在服务器上使用berry用户操作】
生成berry用户的秘钥,并将公钥拷贝到远程xia私钥计算机的/tmp目录下
ssh-keygen -t rsascp ~/.ssh/id_rsa.pub xia@192.168.100.181:/tmp
【在xia私钥计算机上操作】
将berry用户的公钥拷贝到本地gitolite-admin库里的keydir目录下:
cp/tmp/id_rsa.pub~/gitolite-admin/keydir/berry.pub
编辑本地gitolite-admin库里的gitolite.conf,修改:
repo manifest- RW+ = xia+ RW+ = xia berry
commit修改,push到服务器生效。
3.创建服务器上的android源码版本库
1)获取default.xml文件
【在服务器上使用berry用户操作】
cd ~/Download/git clone gitolite@192.168.100.249:manifest.git
【在服务器上使用gitolite用户操作】
sudosu - gitolitecd~cp /home/berry/Downloads/manifest/default.xml ./
2)生成server.txt
使用 cat default.xml | cut -d ‘”’ -f 4 > server.txt
生成server.txt,将无关的字符删除
-UTF-8--Makefile--
得到一个服务端路径的文本 server.txt
yazuo/platform/buildyazuo/platform/abi/cppyazuo/platform/artyazuo/platform/bionicyazuo/platform/bootable/bootloader/lkyazuo/platform/bootable/diskinstalleryazuo/platform/bootable/recoveryyazuo/platform/ctsyazuo/platform/dalvikyazuo/platform/developers/buildyazuo/platform/developers/samples/androidyazuo/platform/developmentyazuo/device/asus/debyazuo/device/asus/floyazuo/device/asus/flo-kernelyazuo/device/asus/grouperyazuo/device/asus/tilapiayazuo/device/commonyazuo/device/generic/armv7-a-neonyazuo/device/generic/commonyazuo/device/generic/goldfishyazuo/device/generic/mipsyazuo/device/generic/mini-emulator-armv7-a-neonyazuo/device/generic/mini-emulator-mipsyazuo/device/generic/mini-emulator-x86yazuo/device/generic/x86yazuo/device/google/accessory/arduinoyazuo/device/google/accessory/demokityazuo/device/lge/hammerheadyazuo/device/lge/hammerhead-kernelyazuo/device/lge/makoyazuo/device/lge/mako-kernelyazuo/device/sampleyazuo/device/samsung/mantayazuo/platform/docs/source.android.comyazuo/platform/external/aacyazuo/platform/external/android-clatyazuo/platform/external/android-mockyazuo/platform/external/ant-globyazuo/platform/external/antlryazuo/platform/external/apache-harmonyyazuo/platform/external/apache-httpyazuo/platform/external/apache-xmlyazuo/platform/external/arduinoyazuo/platform/external/bisonyazuo/platform/external/blktraceyazuo/platform/external/bluetooth/bluedroidyazuo/platform/external/bouncycastleyazuo/platform/external/bsdiffyazuo/platform/external/bzip2yazuo/platform/external/ceres-solveryazuo/platform/external/checkpolicyyazuo/platform/external/chromiumyazuo/platform/external/chromium-libpacyazuo/platform/external/chromium-traceyazuo/platform/external/chromium_orgyazuo/platform/external/chromium_org/sdch/open-vcdiffyazuo/platform/external/chromium_org/testing/gtestyazuo/platform/external/chromium_org/third_party/WebKityazuo/platform/external/chromium_org/third_party/angle_dx11yazuo/platform/external/chromium_org/third_party/eyesfree/src/android/java/src/com/googlecode/eyesfree/brailleyazuo/platform/external/chromium_org/third_party/freetypeyazuo/platform/external/chromium_org/third_party/icuyazuo/platform/external/chromium_org/third_party/leveldatabase/srcyazuo/platform/external/chromium_org/third_party/libjingle/source/talkyazuo/platform/external/chromium_org/third_party/libphonenumber/src/phonenumbersyazuo/platform/external/chromium_org/third_party/libphonenumber/src/resourcesyazuo/platform/external/chromium_org/third_party/mesa/srcyazuo/platform/external/chromium_org/third_party/opensslyazuo/platform/external/chromium_org/third_party/opus/srcyazuo/platform/external/chromium_org/third_party/otsyazuo/platform/external/chromium_org/third_party/skia/gypyazuo/platform/external/chromium_org/third_party/skia/includeyazuo/platform/external/chromium_org/third_party/skia/srcyazuo/platform/external/chromium_org/third_party/smhasher/srcyazuo/platform/external/chromium_org/third_party/yasm/source/patched-yasmyazuo/platform/external/chromium_org/tools/grityazuo/platform/external/chromium_org/tools/gypyazuo/platform/external/chromium_org/v8yazuo/platform/external/clangyazuo/platform/external/compiler-rtyazuo/platform/external/dexmakeryazuo/platform/external/dhcpcdyazuo/platform/external/dnsmasqyazuo/platform/external/doclavayazuo/platform/external/dropbearyazuo/platform/external/droiddriveryazuo/platform/external/e2fsprogsyazuo/platform/external/easymockyazuo/platform/external/eclipse-basebuilderyazuo/platform/external/eclipse-windowbuilderyazuo/platform/external/eigenyazuo/platform/external/elfutilsyazuo/platform/external/embunityazuo/platform/external/emmayazuo/platform/external/esdyazuo/platform/external/expatyazuo/platform/external/eyes-freeyazuo/platform/external/fdlibmyazuo/platform/external/flacyazuo/platform/external/freetypeyazuo/platform/external/fsck_msdosyazuo/platform/external/ganymed-ssh2yazuo/platform/external/gcc-demangleyazuo/platform/external/genext2fsyazuo/platform/external/giflibyazuo/platform/external/google-diff-match-patchyazuo/platform/external/grubyazuo/platform/external/gtestyazuo/platform/external/guavayazuo/platform/external/hamcrestyazuo/platform/external/harfbuzzyazuo/platform/external/harfbuzz_ngyazuo/platform/external/hyphenationyazuo/platform/external/icu4cyazuo/platform/external/iproute2yazuo/platform/external/ipsec-toolsyazuo/platform/external/iptablesyazuo/platform/external/iputilsyazuo/platform/external/LaunchPPPoeyazuo/platform/external/libifaddrsyazuo/platform/external/pppoeyazuo/platform/external/javasqliteyazuo/platform/external/javassistyazuo/platform/external/jdiffyazuo/platform/external/jheadyazuo/platform/external/jmdnsyazuo/platform/external/jmonkeyengineyazuo/platform/external/jpegyazuo/platform/external/jsilveryazuo/platform/external/jsr305yazuo/platform/external/junityazuo/platform/external/kernel-headersyazuo/platform/external/libcap-ngyazuo/platform/external/libffiyazuo/platform/external/libgsmyazuo/platform/external/liblzfyazuo/platform/external/libmtpyazuo/platform/external/libnfc-nciyazuo/platform/external/libnfc-nxpyazuo/platform/external/libnl-headersyazuo/platform/external/liboggyazuo/platform/external/libpcapyazuo/platform/external/libphonenumberyazuo/platform/external/libpngyazuo/platform/external/libpppyazuo/platform/external/libselinuxyazuo/platform/external/libsepolyazuo/platform/external/libusbyazuo/platform/external/libusb-compatyazuo/platform/external/libvorbisyazuo/platform/external/libvpxyazuo/platform/external/libxml2yazuo/platform/external/libxsltyazuo/platform/external/libyuvyazuo/platform/external/linux-tools-perfyazuo/platform/external/littlemockyazuo/platform/external/wide-dhcpv6yazuo/platform/external/llvmyazuo/platform/external/lzmayazuo/platform/external/marisa-trieyazuo/platform/external/markdownyazuo/platform/external/mdnsresponderyazuo/platform/external/mesa3dyazuo/platform/external/mkshyazuo/platform/external/mockitoyazuo/platform/external/mockwebserveryazuo/platform/external/mp4parseryazuo/platform/external/mtpdyazuo/platform/external/naver-fontsyazuo/platform/external/netcatyazuo/platform/external/netperfyazuo/platform/external/nevenyazuo/platform/external/nist-pkitsyazuo/platform/external/nist-sipyazuo/platform/external/noto-fontsyazuo/platform/external/oauthyazuo/platform/external/objenesisyazuo/platform/external/okhttpyazuo/platform/external/open-vcdiffyazuo/platform/external/opencvyazuo/platform/external/openfstyazuo/platform/external/opensshyazuo/platform/external/opensslyazuo/platform/external/oprofileyazuo/platform/external/pixmanyazuo/platform/external/pppyazuo/platform/external/proguardyazuo/platform/external/protobufyazuo/platform/external/qemuyazuo/platform/external/qemu-pc-biosyazuo/platform/external/regex-re2yazuo/platform/external/replicaislandyazuo/platform/external/robolectricyazuo/platform/external/safe-iopyazuo/platform/external/scryptyazuo/platform/external/sepolicyyazuo/platform/external/sfntlyyazuo/platform/external/sil-fontsyazuo/platform/external/skiayazuo/platform/external/smackyazuo/platform/external/smaliyazuo/platform/external/sonivoxyazuo/platform/external/speexyazuo/platform/external/sqliteyazuo/platform/external/srecyazuo/platform/external/srtpyazuo/platform/external/stlportyazuo/platform/external/straceyazuo/platform/external/stressapptestyazuo/platform/external/svoxyazuo/platform/external/tagsoupyazuo/platform/external/tcpdumpyazuo/platform/external/timezonepicker-supportyazuo/platform/external/tinyalsayazuo/platform/external/tinycompressyazuo/platform/external/tinyxmlyazuo/platform/external/tinyxml2yazuo/platform/external/tremoloyazuo/platform/external/v8yazuo/platform/external/valgrindyazuo/platform/external/webpyazuo/platform/external/webrtcyazuo/platform/external/wpa_supplicant_8yazuo/platform/external/xmlwriteryazuo/platform/external/xmp_toolkityazuo/platform/external/yaffs2yazuo/platform/external/zlibyazuo/platform/external/zxingyazuo/platform/frameworks/avyazuo/platform/frameworks/baseyazuo/platform/frameworks/compile/libbccyazuo/platform/frameworks/compile/mclinkeryazuo/platform/frameworks/compile/slangyazuo/platform/frameworks/exyazuo/platform/frameworks/mlyazuo/platform/frameworks/bluetoothyazuo/platform/frameworks/nativeyazuo/platform/frameworks/opt/calendaryazuo/platform/frameworks/opt/colorpickeryazuo/platform/frameworks/opt/datetimepickeryazuo/platform/frameworks/opt/emojiyazuo/platform/frameworks/opt/inputmethodcommonyazuo/platform/frameworks/opt/mailcommonyazuo/platform/frameworks/opt/mmsyazuo/platform/frameworks/opt/net/voipyazuo/platform/frameworks/opt/photovieweryazuo/platform/frameworks/opt/timezonepickeryazuo/platform/frameworks/opt/telephonyyazuo/platform/frameworks/opt/vcardyazuo/platform/frameworks/rsyazuo/platform/frameworks/supportyazuo/platform/frameworks/testingyazuo/platform/frameworks/uiautomatoryazuo/platform/frameworks/volleyyazuo/platform/frameworks/webviewyazuo/platform/frameworks/wilhelmyazuo/platform/hardware/akmyazuo/platform/hardware/broadcom/libbtyazuo/platform/hardware/broadcom/wlanyazuo/platform/hardware/invensenseyazuo/platform/hardware/libhardwareyazuo/platform/hardware/libhardware_legacyyazuo/platform/hardware/qcom/audioyazuo/platform/hardware/qcom/btyazuo/platform/hardware/qcom/camerayazuo/platform/hardware/qcom/displayyazuo/platform/hardware/qcom/keymasteryazuo/platform/hardware/qcom/mediayazuo/platform/hardware/qcom/msm8960yazuo/platform/hardware/qcom/msm8x74yazuo/platform/hardware/qcom/poweryazuo/platform/hardware/qcom/wlanyazuo/platform/hardware/rilyazuo/platform/hardware/samsung_slsi/exynos5yazuo/platform/hardware/ti/omap3yazuo/platform/hardware/ti/omap4xxxyazuo/platform/hardware/ti/wlanyazuo/platform/hardware/ti/wpanyazuo/platform/libcoreyazuo/platform/libnativehelperyazuo/platform/ndkyazuo/kernelyazuo/mediatekyazuo/vendoryazuo/platform/packages/providers/DrmProvideryazuo/platform/packages/apps/DeviceTestAppyazuo/platform/packages/apps/BasicSmsReceiveryazuo/platform/packages/apps/Bluetoothyazuo/platform/packages/apps/Browseryazuo/platform/packages/apps/Calculatoryazuo/platform/packages/apps/Calendaryazuo/platform/packages/apps/Camerayazuo/platform/packages/apps/Camera2yazuo/platform/packages/apps/CellBroadcastReceiveryazuo/platform/packages/apps/CertInstalleryazuo/platform/packages/apps/Contactsyazuo/platform/packages/apps/ContactsCommonyazuo/platform/packages/apps/DeskClockyazuo/platform/packages/apps/Dialeryazuo/platform/packages/apps/Emailyazuo/platform/packages/apps/Exchangeyazuo/platform/packages/apps/Galleryyazuo/platform/packages/apps/Gallery2yazuo/platform/packages/apps/HTMLVieweryazuo/platform/packages/apps/InCallUIyazuo/platform/packages/apps/KeyChainyazuo/platform/packages/apps/Launcher2yazuo/platform/packages/apps/Launcher3yazuo/platform/packages/apps/LegacyCamerayazuo/platform/packages/apps/Mmsyazuo/platform/packages/apps/Musicyazuo/platform/packages/apps/MusicFXyazuo/platform/packages/apps/Nfcyazuo/platform/packages/apps/OneTimeInitializeryazuo/platform/packages/apps/PackageInstalleryazuo/platform/packages/apps/PhoneCommonyazuo/platform/packages/apps/Protipsyazuo/platform/packages/apps/Provisionyazuo/platform/packages/apps/QuickSearchBoxyazuo/platform/packages/apps/Settingsyazuo/platform/packages/apps/SoundRecorderyazuo/platform/packages/apps/SparePartsyazuo/platform/packages/apps/SpeechRecorderyazuo/platform/packages/apps/Stkyazuo/platform/packages/apps/Tagyazuo/platform/packages/apps/UnifiedEmailyazuo/platform/packages/apps/VideoEditoryazuo/platform/packages/apps/VoiceDialeryazuo/platform/packages/experimentalyazuo/platform/packages/inputmethods/LatinIMEyazuo/platform/packages/inputmethods/OpenWnnyazuo/platform/packages/inputmethods/PinyinIMEyazuo/platform/packages/providers/ApplicationsProvideryazuo/platform/packages/providers/CalendarProvideryazuo/platform/packages/providers/ContactsProvideryazuo/platform/packages/providers/DownloadProvideryazuo/platform/packages/providers/MediaProvideryazuo/platform/packages/providers/PartnerBookmarksProvideryazuo/platform/packages/providers/TelephonyProvideryazuo/platform/packages/providers/UserDictionaryProvideryazuo/platform/packages/screensavers/Basicyazuo/platform/packages/screensavers/PhotoTableyazuo/platform/packages/screensavers/WebViewyazuo/platform/packages/services/Telephonyyazuo/platform/packages/wallpapers/Basicyazuo/platform/packages/wallpapers/Galaxy4yazuo/platform/packages/wallpapers/HoloSpiralyazuo/platform/packages/wallpapers/LivePickeryazuo/platform/packages/wallpapers/MagicSmokeyazuo/platform/packages/wallpapers/MusicVisualizationyazuo/platform/packages/wallpapers/NoiseFieldyazuo/platform/packages/wallpapers/PhaseBeamyazuo/platform/pdkyazuo/platform/prebuilts/clang/linux-x86/3.1yazuo/platform/prebuilts/devtoolsyazuo/platform/prebuilts/eclipseyazuo/platform/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6yazuo/platform/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.7yazuo/platform/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6yazuo/platform/prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.7yazuo/platform/prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1yazuo/platform/prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.6yazuo/platform/prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.7yazuo/platform/prebuilts/gcc/darwin-x86/x86/i686-linux-android-4.6yazuo/platform/prebuilts/gcc/darwin-x86/x86/i686-linux-android-4.7yazuo/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6yazuo/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7yazuo/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6yazuo/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7yazuo/platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.4.3yazuo/platform/prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6yazuo/platform/prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6yazuo/platform/prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.6yazuo/platform/prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.7yazuo/platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6yazuo/platform/prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7yazuo/platform/prebuilts/miscyazuo/platform/prebuilts/ndkyazuo/platform/prebuilts/python/darwin-x86/2.7.5yazuo/platform/prebuilts/python/linux-x86/2.7.5yazuo/platform/prebuilts/qemu-kernelyazuo/platform/prebuilts/runtimeyazuo/platform/prebuilts/sdkyazuo/platform/prebuilts/toolsyazuo/platform/sdkyazuo/platform/system/mobile_toolkityazuo/platform/system/coreyazuo/platform/system/extrasyazuo/platform/system/mediayazuo/platform/system/netdyazuo/platform/system/securityyazuo/platform/system/voldyazuo/platform/tools/external/fat32libyazuo/platform/tools/external/gradleyazuo/platform/tools/idea
3)编写初始化源码仓库脚本server_create.sh
vim server_create.sh添加
#/bin/bashset-xset-epwd=${PWD}cd/home/gitolite/repositorieswhilereadline;doif[ -z"$line"];thenechowork_dir not exist !!!1>&2continuefigit init --bare$line.gitecho====$linepwddone
4)初始化空的源码仓库
【在服务器上使用gitolite用户操作】
cat server.txt | ./server_create.sh
5)生成client.txt
使用 cat default.xml | cut -d ‘”’ -f 2 > client.txt
生成client.txt,将无关的字符删除
-1.0--yazuo-..-ssh-master-yazuo-1-core/root.mk--
得到一个本地客户端仓库路径的文本 client.txt
buildabi/cppartbionicbootable/bootloader/lkbootable/diskinstallerbootable/recoveryctsdalvikdevelopers/builddevelopers/samples/androiddevelopmentdevice/asus/debdevice/asus/flodevice/asus/flo-kerneldevice/asus/grouperdevice/asus/tilapiadevice/commondevice/generic/armv7-a-neondevice/generic/commondevice/generic/goldfishdevice/generic/mipsdevice/generic/mini-emulator-armv7-a-neondevice/generic/mini-emulator-mipsdevice/generic/mini-emulator-x86device/generic/x86device/google/accessory/arduinodevice/google/accessory/demokitdevice/lge/hammerheaddevice/lge/hammerhead-kerneldevice/lge/makodevice/lge/mako-kerneldevice/sampledevice/samsung/mantadocs/source.android.comexternal/aacexternal/android-clatexternal/android-mockexternal/ant-globexternal/antlrexternal/apache-harmonyexternal/apache-httpexternal/apache-xmlexternal/arduinoexternal/bisonexternal/blktraceexternal/bluetooth/bluedroidexternal/bouncycastleexternal/bsdiffexternal/bzip2external/ceres-solverexternal/checkpolicyexternal/chromiumexternal/chromium-libpacexternal/chromium-traceexternal/chromium_orgexternal/chromium_org/sdch/open-vcdiffexternal/chromium_org/testing/gtestexternal/chromium_org/third_party/WebKitexternal/chromium_org/third_party/angle_dx11external/chromium_org/third_party/eyesfree/src/android/java/src/com/googlecode/eyesfree/brailleexternal/chromium_org/third_party/freetypeexternal/chromium_org/third_party/icuexternal/chromium_org/third_party/leveldatabase/srcexternal/chromium_org/third_party/libjingle/source/talkexternal/chromium_org/third_party/libphonenumber/src/phonenumbersexternal/chromium_org/third_party/libphonenumber/src/resourcesexternal/chromium_org/third_party/mesa/srcexternal/chromium_org/third_party/opensslexternal/chromium_org/third_party/opus/srcexternal/chromium_org/third_party/otsexternal/chromium_org/third_party/skia/gypexternal/chromium_org/third_party/skia/includeexternal/chromium_org/third_party/skia/srcexternal/chromium_org/third_party/smhasher/srcexternal/chromium_org/third_party/yasm/source/patched-yasmexternal/chromium_org/tools/gritexternal/chromium_org/tools/gypexternal/chromium_org/v8external/clangexternal/compiler-rtexternal/dexmakerexternal/dhcpcdexternal/dnsmasqexternal/doclavaexternal/dropbearexternal/droiddriverexternal/e2fsprogsexternal/easymockexternal/eclipse-basebuilderexternal/eclipse-windowbuilderexternal/eigenexternal/elfutilsexternal/embunitexternal/emmaexternal/esdexternal/expatexternal/eyes-freeexternal/fdlibmexternal/flacexternal/freetypeexternal/fsck_msdosexternal/ganymed-ssh2external/gcc-demangleexternal/genext2fsexternal/giflibexternal/google-diff-match-patchexternal/grubexternal/gtestexternal/guavaexternal/hamcrestexternal/harfbuzzexternal/harfbuzz_ngexternal/hyphenationexternal/icu4cexternal/iproute2external/ipsec-toolsexternal/iptablesexternal/iputilsexternal/LaunchPPPoeexternal/libifaddrsexternal/pppoeexternal/javasqliteexternal/javassistexternal/jdiffexternal/jheadexternal/jmdnsexternal/jmonkeyengineexternal/jpegexternal/jsilverexternal/jsr305external/junitexternal/kernel-headersexternal/libcap-ngexternal/libffiexternal/libgsmexternal/liblzfexternal/libmtpexternal/libnfc-nciexternal/libnfc-nxpexternal/libnl-headersexternal/liboggexternal/libpcapexternal/libphonenumberexternal/libpngexternal/libpppexternal/libselinuxexternal/libsepolexternal/libusbexternal/libusb-compatexternal/libvorbisexternal/libvpxexternal/libxml2external/libxsltexternal/libyuvexternal/linux-tools-perfexternal/littlemockexternal/wide-dhcpv6external/llvmexternal/lzmaexternal/marisa-trieexternal/markdownexternal/mdnsresponderexternal/mesa3dexternal/mkshexternal/mockitoexternal/mockwebserverexternal/mp4parserexternal/mtpdexternal/naver-fontsexternal/netcatexternal/netperfexternal/nevenexternal/nist-pkitsexternal/nist-sipexternal/noto-fontsexternal/oauthexternal/objenesisexternal/okhttpexternal/open-vcdiffexternal/opencvexternal/openfstexternal/opensshexternal/opensslexternal/oprofileexternal/pixmanexternal/pppexternal/proguardexternal/protobufexternal/qemuexternal/qemu-pc-biosexternal/regex-re2external/replicaislandexternal/robolectricexternal/safe-iopexternal/scryptexternal/sepolicyexternal/sfntlyexternal/sil-fontsexternal/skiaexternal/smackexternal/smaliexternal/sonivoxexternal/speexexternal/sqliteexternal/srecexternal/srtpexternal/stlportexternal/straceexternal/stressapptestexternal/svoxexternal/tagsoupexternal/tcpdumpexternal/timezonepicker-supportexternal/tinyalsaexternal/tinycompressexternal/tinyxmlexternal/tinyxml2external/tremoloexternal/v8external/valgrindexternal/webpexternal/webrtcexternal/wpa_supplicant_8external/xmlwriterexternal/xmp_toolkitexternal/yaffs2external/zlibexternal/zxingframeworks/avframeworks/baseframeworks/compile/libbccframeworks/compile/mclinkerframeworks/compile/slangframeworks/exframeworks/mlframeworks/bluetoothframeworks/nativeframeworks/opt/calendarframeworks/opt/colorpickerframeworks/opt/datetimepickerframeworks/opt/emojiframeworks/opt/inputmethodcommonframeworks/opt/mailcommonframeworks/opt/mmsframeworks/opt/net/voipframeworks/opt/photoviewerframeworks/opt/timezonepickerframeworks/opt/telephonyframeworks/opt/vcardframeworks/rsframeworks/supportframeworks/testingframeworks/uiautomatorframeworks/volleyframeworks/webviewframeworks/wilhelmhardware/akmhardware/broadcom/libbthardware/broadcom/wlanhardware/invensensehardware/libhardwarehardware/libhardware_legacyhardware/qcom/audiohardware/qcom/bthardware/qcom/camerahardware/qcom/displayhardware/qcom/keymasterhardware/qcom/mediahardware/qcom/msm8960hardware/qcom/msm8x74hardware/qcom/powerhardware/qcom/wlanhardware/rilhardware/samsung_slsi/exynos5hardware/ti/omap3hardware/ti/omap4xxxhardware/ti/wlanhardware/ti/wpanlibcorelibnativehelperndkkernelmediatekvendorpackages/providers/DrmProviderpackages/apps/DeviceTestApppackages/apps/BasicSmsReceiverpackages/apps/Bluetoothpackages/apps/Browserpackages/apps/Calculatorpackages/apps/Calendarpackages/apps/Camerapackages/apps/Camera2packages/apps/CellBroadcastReceiverpackages/apps/CertInstallerpackages/apps/Contactspackages/apps/ContactsCommonpackages/apps/DeskClockpackages/apps/Dialerpackages/apps/Emailpackages/apps/Exchangepackages/apps/Gallerypackages/apps/Gallery2packages/apps/HTMLViewerpackages/apps/InCallUIpackages/apps/KeyChainpackages/apps/Launcher2packages/apps/Launcher3packages/apps/LegacyCamerapackages/apps/Mmspackages/apps/Musicpackages/apps/MusicFXpackages/apps/Nfcpackages/apps/OneTimeInitializerpackages/apps/PackageInstallerpackages/apps/PhoneCommonpackages/apps/Protipspackages/apps/Provisionpackages/apps/QuickSearchBoxpackages/apps/Settingspackages/apps/SoundRecorderpackages/apps/SparePartspackages/apps/SpeechRecorderpackages/apps/Stkpackages/apps/Tagpackages/apps/UnifiedEmailpackages/apps/VideoEditorpackages/apps/VoiceDialerpackages/experimentalpackages/inputmethods/LatinIMEpackages/inputmethods/OpenWnnpackages/inputmethods/PinyinIMEpackages/providers/ApplicationsProviderpackages/providers/CalendarProviderpackages/providers/ContactsProviderpackages/providers/DownloadProviderpackages/providers/MediaProviderpackages/providers/PartnerBookmarksProviderpackages/providers/TelephonyProviderpackages/providers/UserDictionaryProviderpackages/screensavers/Basicpackages/screensavers/PhotoTablepackages/screensavers/WebViewpackages/services/Telephonypackages/wallpapers/Basicpackages/wallpapers/Galaxy4packages/wallpapers/HoloSpiralpackages/wallpapers/LivePickerpackages/wallpapers/MagicSmokepackages/wallpapers/MusicVisualizationpackages/wallpapers/NoiseFieldpackages/wallpapers/PhaseBeampdkprebuilts/clang/linux-x86/3.1prebuilts/devtoolsprebuilts/eclipseprebuilts/gcc/darwin-x86/arm/arm-eabi-4.6prebuilts/gcc/darwin-x86/arm/arm-eabi-4.7prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.6prebuilts/gcc/darwin-x86/arm/arm-linux-androideabi-4.7prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.6prebuilts/gcc/darwin-x86/mips/mipsel-linux-android-4.7prebuilts/gcc/darwin-x86/x86/i686-linux-android-4.6prebuilts/gcc/darwin-x86/x86/i686-linux-android-4.7prebuilts/gcc/linux-x86/arm/arm-eabi-4.6prebuilts/gcc/linux-x86/arm/arm-eabi-4.7prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.6prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.4.3prebuilts/gcc/linux-x86/host/i686-linux-glibc2.7-4.6prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.6prebuilts/gcc/linux-x86/mips/mipsel-linux-android-4.7prebuilts/gcc/linux-x86/x86/i686-linux-android-4.6prebuilts/gcc/linux-x86/x86/i686-linux-android-4.7prebuilts/miscprebuilts/ndkprebuilts/python/darwin-x86/2.7.5prebuilts/python/linux-x86/2.7.5prebuilts/qemu-kernelprebuilts/runtimeprebuilts/sdkprebuilts/toolssdksystem/mobile_toolkitsystem/coresystem/extrassystem/mediasystem/netdsystem/securitysystem/voldtools/external/fat32libtools/external/gradletools/idea
6)编写初始化源码仓库脚本client_create.sh
vim client_create.sh 添加:
①适用于不带任何 .git 或者.svn 的纯净Android 源码
#/bin/bashset-xset-epwd=${PWD}whilereadline; doline1=${line%%/*}if[ -z"$line"];thenechowork_dir not exist !!!1>&2continuefiif[ $(ls -A$pwd/$line| wc-l)-eq0];thenechowork_dir empty !!!1>&2continuefiworkdir=$pwd/$lineecho====$workdircd$workdirrm -rf .git git init .1>&2git add .-f1>&2git commit -m"Initial commit"1>&2if["$line1"="device"];thengit push --set-upstream git://192.168.100.249/yazuo/$line.git masterelif["$line1"="kernel"];thengit push --set-upstream git://192.168.100.249/yazuo/$line.git masterelif["$line1"="mediatek"];thengit push --set-upstream git://192.168.100.249/yazuo/$line.git masterelif["$line1"="vendor"];thengit push --set-upstream git://192.168.100.249/yazuo/$line.git masterelsegit push --set-upstream git://192.168.100.249/yazuo/platform/$line.git masterficd-done
②适合本身已有.git的android源码
#/bin/bashset-xset-epwd=${PWD}whilereadline;doline1=${line%%/*}if[ -z"$line"];thenechowork_dir not exist !!!1>&2continuefiif[ $(ls -A$pwd/$line| wc-l)-eq0];thenechowork_dir empty !!!1>&2continuefiworkdir=$pwd/$lineecho====$workdircd$workdirgit checkout -B master yazuo/masterif["$line1"="device"];thengit push --set-upstream git://192.168.100.249/yazuo/$line.git masterelif["$line1"="kernel"];thengit push --set-upstream git://192.168.100.249/yazuo/$line.git masterelif["$line1"="mediatek"];thengit push --set-upstream git://192.168.100.249/yazuo/$line.git masterelif["$line1"="vendor"];thengit push --set-upstream git://192.168.100.249/yazuo/$line.git masterelsegit push --set-upstream git://192.168.100.249/yazuo/platform/$line.git masterficd-done
注意:
①之前写成了
git push --set-upstreamgitolite://192.168.100.249/yazuo/platform/$line.git master
报错:fatal: Unable to find remote helper for ‘gitolite’。犯了低级错误引以为戒!
②还有写成了
gitpush--set-upstream ssh://gitolite@192.168.100.249/yazuo/platform/$line.gitmaster
也不行,这样写需要把所有的git工程都加到gitolite-admin/gitolite.conf文件中太麻烦!
7)初始化本地源码仓库,并推送到远程服务器仓库
【在xia私钥计算机上操作】
在本地android源码目录下执行下面命令:
cat client.txt| ./client_create.sh
耐心等待半小时左右,这样就把本地Android源码推送到服务器端的仓库中了。至此,服务器上的android源码版本库已经完全OK!
4.使用repo下载服务器上的android源码
(1)下载 git-repo
【在xia私钥计算机上操作】
在/home/xia目录下执行:
git clone https://gerrit.googlesource.com/git-repo git-repo.git
如果上面的地址不行,自己就在网上搜一个可以下载的。
cdgit-repo.git vim repo
修改 repo
REPO_URL ='https://gerrit.googlesource.com/git-repo'REPO_REV ='stable'改为 REPO_URL =/home/xia/git-repo.git REPO_REV ='master'
1)REPO_URL 指的是 repo 所调用和管理引用仓库
2)REPO_REV 指的是仓库分支,进入git-repo.git, 使用命令:git branch 查看,我的是 master 分支。
(2)将 git-repo.git 目录下的 repo 拷贝到 ~/bin/
mkdir~/bin
cp repo ~/bin/
chmod 777 ~/bin/repo
(3)测试下载源码
cd~/mkdir yazuotestcdyazuotestrepo init -u git://192.168.100.249/manifest.gitrepo sync
注意:可以用 -b 参数来指定某个manifest 分支。
repo init-ugit://192.168.100.249/manifest.git -b master
等待同步完成,大功告成!!!