Very long once out of curiosity and meticulous understanding of the next repo and the principle of server, but today suddenly found some forget. So I wanted to write it down.
Repomechanism
Repo is a software that Google officially developed to manage Android projects.
Let's first look at the official description of the software.
Repo is a tool thatwe built on top of Git. Repo helps us manage the many Git repositories, doesthe uploads to our revision control system, and automates parts of the Androiddevelopment Workflow. Repo is not meant to replace Git, and only to make it easierto work with git in the context of Android. The repo command is a Executablepython script that can put anywhere in your path |
as can be seen from the above, repo itself is not responsible for project management (recording project updates, fallback updates, etc.). It's just a handy tool for managing multiple Git projects, based on Git. It is implemented in Python.
We know that every module in Android is managed with Git, and there are a lot of these modules in Android, up to 200 more. Assuming that the user is using Git pull/fetch to update each GIT project one by one, the task is too large and the user must know the corresponding branch information for each git at the same time. The repo tool solves the problem by using a Manifest.git project that lists all the managed git information, including the folder structure, branch. Get the address and so on.
repo, what did you do?
When we run repo, we usually use the following command, for example:
Repo Init–u/media/itleaks/git/repositories/platform/manifest.git
The number of references after-U is the focus. When the user runs this command, the Repo tool is equivalent to running the
mkdir. Repocd. Repogit clone/media/itleaks/git/repositories/platform/manifest.git
Let's look at the contents of the next Android Repo Project Manifest.git:
[Email protected]:/media/itleaks/source/4.4$ cat. Repo/manifests/.git/config |more[core]repositoryformatversion = 0filemode = True[remote "origin"]url =/media/itleaks/git/repositories/platform/manifest.gitfetch = +refs/heads/*: Refs/remotes/origin/*[repo]reference =/media/itleaks/git/mirror/android.googlesource.com/[branch "Default"] Remote = Originmerge = Master[email protected]:/media/itleaks/source/4.4$ cat. Repo/manifests/default.xml |more<? XML version= "1.0" encoding= "UTF-8"?><manifest>//ability to define multiple remote <remote name= "AOSP" review= "review.source.android.com"//This is is to get the server address of git, here is a relative folder: Just now we mentioned that manifests itself is also a git project, it naturally has the address//this. The root folder of all the following GIT projects is indicated in the upper folder of the manifests project folder, i.e.///media/itleaks/git/repositories/fetch= ":"/>//default R Emote is the above aosp <default revision= "refs/tags/android-4.4_r1" remote= "Aosp" sync-j= "4"/>//project path , project name//This descriptive narrative runs after the equivalent user runs such as the following two commands//CD Rootdir/art//Git Clone/media/itleaks/git/repositories/platform/platform/art <project path= "Art" name= "Platform/art"/> <project path= "bionic" name= "Platform/bionic" groups= "PDK"/> & Lt;project path= "bootable/bootloader/legacy" name= "platform/bootable/bootloader/legacy"/> <project path= " Bootable/diskinstaller "name=" Platform/bootable/diskinstaller "/> <project path=" bootable/recovery "Name=" Platform/bootable/recovery "groups=" PDK "/> <project path=" CTS "Name= "Platform/cts" groups= "cts"/> <project path= "Dalvik" name= "Platform/dalvik"/>
The user then runs repo sync before starting to actually download all the code items according to the rules described above. That is, running Git clone/media/itleaks/git/repositories/platform/xx in a loop
Establish Repo server
build Reposerver from scratch
As can be seen from the above, the core of establishing repo server is to build Manifest.git project.
Create a folder mkdir/tmp/git/repositories/platform-pcd/tmp/git/repositories/platform//build a test git testmkdir test;git init; Touch 1.txt;git Add.; Git commit–asm "initial version"//build test git test1mkdir test1;git init;touch 2.txt;git Add.; Git commit–asm "initial version"//Build manifest Gitmkdir manifest;git init;touch default.xml;git Add.; Git commit–asm "initial version" and then change Default.xml, enter for example the following information <?xml version= "1.0" encoding= "UTF-8"? ><manifest > <remote name= "test" fetch= "." review= "https://android-review.googlesource.com/"/> <default revision= "master" remote= "test" sync-j= "4"/> <project path= "test" name= "test"/> <project path= "test1" name= "Test1"/> </ The manifest> is built so well. Submit git commit–asm "add real content"
After you have finished running the above operation. We'll be able to use this repo server.
Local users only need to run: repo–u/tmp/git/repositories/platform/manifest can download this reposerver project code.
Remote machine via: Repo–u ssh:ip:/tmp/git/repositories/platform/manifest
optimize repo server data content
One of the worst ways to do this is to have redundant information for every GIT project under this server.
Since Reposerver does not need to directly manipulate the contents of the Git project, it is often repo the client changes the code to commit to change the server's data. So git provides a-bare parameter to optimize the data for Git server. That is, the GIT server side of the entire content is binary management. So the build of repo server above should be like this.
Take test git for example:
The following command
Cd/tmp/git/repositories/platform;mkdir Test;gitinit;touch 1.txt;git Add.; Git commit–asm "initial version"
To be changed to:
Build client git cd/tmp;mkdir test;git init;touch 1.txt;git Add.; Gitcommit–asm "initial version"//build server git cd/tmp/git/repositories/platform;git clone/tmp/test–bare;
This way, all of the GIT data under the server folder/tmp/git/repositories/platform is optimized.
build your own repo server with existing repo
This approach is very useful, for example, for a company to develop Android projects. The first thing you must do is download the base code for AOSP and make some changes on it. The company built an internal repo sever, and all the other employees downloaded the code directly from the company's repo server. Instead of downloading from Google official. This is the first to improve the download speed, local area network download is certainly faster than remote download.
in fact, no matter what an existing repo after a simple change can become a reposerver. For example, imagine a user completing the Android download by running the following command.
CD /media/itleaks/source/4.4repo Init–u/media/itleaks/git/repositories/platform/manifest.gitrepo sync
Then he just needs to build a manifest project under the root folder. and copy the file. Repo/manifest/default.xml and changes will change this repo project to Reposerver.
use repo mirror to build your own repo server
In fact repo provides a better reference for building repo server, or Repo–mirror. For example, if you want to build an Android repo server, you just need to run the following command 'll be :
Repo Init–u/media/itleaks/git/repositories/platform/manifest.git–mirrorrepo Sync
/********************************
* This article from the blog "Love Kick Door"
* Reprint Please indicate the source : Http://blog.csdn.net/itleaks
******************************************/
To create your own repo Server