Use of the Android source code repository and Repo Tool

Source: Internet
Author: User

Use of the Android source code repository and Repo Tool
Preface I haven't had a weekend off for a long time. Alas, I don't have to talk about it anymore. I have to learn more and enrich myself at any time. ROM Porting is very tedious and involves a lot of knowledge points. Here we will introduce the terms that ROM Porting often hear and the use of Repo tools.
AOSP, AOKP, and cm I believe many Android enthusiasts are familiar with these words. Here I will give them a general introduction to the meanings behind these words. AOSP is the abbreviation of "Android Open-Source Project". The Chinese name is Android Open Source Project. Everyone knows that Android is an open-source operating system. Therefore, Every time Google releases an Android version, it will issue the source code of the corresponding version to the open-source community, that is, the aosp rom we call, this can be called the purest Android system. The analogy can be used to make everyone more clear. For example, most Pirated Windows systems in China are basically created based on Microsoft's MSDN, and aosp rom is equivalent to Microsoft's MSDN master disk. AOKP is an "Android Open-Source Kang Project", which has a "Kang" higher than AOSP ". In the Android community, Kang indicates that this is a custom ROM and a non-governmental ROM. CM is short for CyanogenMod. the Cyanogen team is the world's largest third-party ROM compilation team, covering a wide range of models. Among the well-known domestic ROM such as MIUI and hammer ROM are implemented based on CM. Strictly speaking, cm rom belongs to the category of AOKP. Although cm rom has always followed the native Android, it is only known as Google's official AOSP.
Why is the use of Repo the AOSP described above composed of many projects managed by Git? For example, in Android4.2, it contains 329 projects, each of which is an independent Git repository. This means that if we want to create an AOSP branch for new feature development, we need to create the corresponding branch in each sub-project. Obviously, you cannot manually create branches in each sub-project. You must use an automatic method to process them. These automated processing tasks are completed by the Repo tool. Of course, the Repo tool is not only responsible for creating branches. Repo can be used to replace basic Git operations such as viewing branch status, submitting code, and updating code.
The ReopoRepo tool is composed of a series of Python scripts that call Git commands to complete their functions. Interestingly, the Python scripts that constitute the Repo tool are also a Git repository. This Git repository is called a Repo repository in AOSP. Every time we execute the Repo command, the Repo repository will update itself once. We discussed the Repo repository above, but we actually want to operate on AOSP by executing the Repo command. This requires the Repo command to know which sub-projects are included in the AOSP and what the sub-project name and repository address are. In other words, the Repo Command needs to know the Git repository metadata of all the sub-items of the AOSP. Because AOSP is constantly iterated, the sub-projects contained in each version may be different. This means that you need to use another Git repository to manage the metadata of all the sub-items of the AOSP. This Git repository is called the Manifest repository in AOSP. So far, we have mentioned three types of Git repositories: Repo repository, Manifest repository, and AOSP sub-project repository. The Repo warehouse uses the Manifest warehouse to obtain metadata of all the AOSP sub-project warehouse. With this metadata, we can use the Python script in the Repo repository to operate the sub-projects of AOSP. So how did the Repo warehouse and Manifest warehouse come from? The answer is to get it through an independent Repo script, which is located on an official website of AOSP. We can download it through the HTTP protocol. Now, we will outline the Picture of the entire AOSP through a graph, which consists of the Repo script, Repo repository, Manifest repository, and AOSP sub-project repository, as shown in 1: vcWxvqO6CjxwcmUgY2xhc3M9 "brush: java; "> $ curl https://storage.googleapis.com/git-repo-downloads/repo> ~ /Bin/repo $ chmod a + x ~ /Bin/repoRepo command

repo init -u 
 
   [OPTIONS]
 
When repo is initialized in the current directory, A. repo directory is generated under the current directory, just like. Git In the git Project directory. -U: Specifies a URL from which the manifest file of repository is obtained. Put the obtained manifest file in the. repo directory and name it manifest. xml. The content of this file is actually a list Of all repositories managed by git. [OPTIONS]-m: select to obtain a specific manifest file in repository. If not specified, it is represented as the default manifest file (default. xml ). [OPTIONS]-B: specify a manifest branch. If the-B parameter is not specified, the master branch is used by default.
repo sync [project-list]
Synchronize the code and download the latest local working file. If the update is successful, the local file is consistent with the Code in repository. You can specify the project to be updated. If no parameter is specified, all git projects in the Manifest file are synchronized. If you run repo sync for the first time, this command is equivalent to git clone, and all the content in repository will be copied to the local device. If you do not run repo sync for the first time, it is equivalent to running git remote update & git rebase original/branch
repo update [project-list]
Upload the modified Code. If your local code has been modified, you will be prompted to upload the modified Code when running repo sync, all modified code branches are uploaded to Gerrit (web-based code review system ). Gerrit receives the uploaded code and converts it to one by one. This allows others to compare and review the submitted code.
repo diff [project-list]
Displays the differences between the modified Code of the current Project and the current working code.
repo start new_branch_name [specified-project]
Create a new branch on the specified Project.
repo branch
View All Branches
repo abandon 
 
Deletes a specified branch, whether merged or not.
repo forall [project-list] -c COMMAND
Run the COMMAND on the specified Project list or all projects.
repo status
Displays the status of each Project in the Repo repository.
repo download target revision
Download a specific version to your local device.

My understanding is that the AOSP project consists of many Git repositories. If one git clone is too time-consuming, you need to use the Repo tool to download the Git repository collection to your local device. Once the Project is downloaded locally, you can directly use the Git command to operate a single Project. Because I am more familiar with Git commands, I don't need to memorize other commands except Repo init. Just use the corresponding Git command.







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.