The operation steps of installing Repo to pull the Android source code in the remote warehouse (actually feasible, Ubuntu server)

Recently, a bastion host was used during development. What is a bastion host? The bastion host is actually an ubuntu operating system, and you need to use linux commands on it. As for the bastion host, it is to play a role in asset management. 
So to figure out this bastion machine, it is actually very convenient to operate. If you need to pull the source code, you must first configure a series of environments. 
Here, let’s first understand the simple linux commands. Before that, I was still a novice in linux 
cd.. Go back to the upper level directory 
ls -a Folders under the current directory, including hidden files 
pwd Display the path of the current directory 
df -h Display the disk usage of system files 
ll Display the attributes of other files in the directory 
cd ~ Return to the main directory 
mkdir Create a new directory 
cat to view the file name 
su user name switch to a normal user         
 
. These simplest commands are useful when I pull the source code. I must be familiar with it and operate it. 
Of course, I also encountered many problems when pulling the source code. It was stepped on step by step. For the first time Xiaobai pulls the source code on Ubuntu, you must first know where your large-capacity disk is, otherwise it is very likely that after all configurations are completed, the synchronization code will be disconnected halfway. Prompt that the disk space is insufficient, it is very big. 
Another special thing to note is that if the company has given you root permissions, do not use root to pull directly. You must pull the source code in ordinary users or your own users. If the company does not create users for you in the system You also need to create a common user name with root privileges 
The following command operation: 
After connecting to the host, use the sudo su command to enter the root authority 
and execute # adduser user 
        #passwd user 
After entering your password, you can use su user to switch users ( note here!!! Entering the password will not be displayed , Be careful! There are two confirmations) 
 
Then after creating your own user name and knowing the disk path, you can install a Repo on Ubuntu. We usually pull the source code on git through Repo 1. Pull the 
repo Boot environment (must be a common user, look at the command symbol $ is a normal user, # is the super administrator root) 
2. Create a blank folder (must be under the large disk directory) 
$ mkdir ~/.bin 
 
3. Pull the boot file, Name it repo 
$ cd ~/.bin 
$ curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
$ chmod a+x ~/.bin/repo


4. Pull Tsinghua's mirror library
$ git clone https://mirrors.tuna.tsinghua.edu.cn/git/git-repo


5. Then configure the relevant environment
$ export PATH=$PATH:~/.bin
$ export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'


6. Verify that the repo is installed successfully. If
the repo version
is successful, the version will generally be displayed. If the following
repo not installed>
is prompted, don’t worry about this problem. For python support problems, you can try to pull the code from the warehouse first, and re-download the repo and fix


7. You can use repo init to pull the existing manifest. Generally, the source code provides manifest files, such as
$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest


8. If you can’t pull it down in step 7, you will be prompted as follows: Permission denied (publickey,keyboard-interactive) 
manifests: 
fatal: Could not read from remote repository. 

The reason is because there is no SSH key configured. 
Solution: 
1. First, check whether there is a key in the current directory through the command 
$ cat ~/.ssh/id_rsa.pub 
If it prompts No such file or directory 
, then you need to recreate a ssh key, and copy and paste this key Go to gitLab and 
use the command as follows 
$ ssh-keygen -t rsa -C "[email protected]"   and press Enter until 
The key's randomart image is: 
+---[RSA 3072]----+ 
|. .oo=oo+ . ... | 
| o..+.*++. .. . | 
|oE . = = =.+ . | 
|o + O =.. o | | 
o +S=. + . | 
| = ... o. . | 
| . o .. . | 
| ..o | 
| .. o.. | 
+----[SHA256]-----+ 
means that it has been created, and then execute cat ~/.ssh/id_rsa.pub to display the key Copy it to gitlab to complete the key configuration 
 
9. Use repo init again to pull the existing manifest 
$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest 
if prompted error.GitError: manifests var:  
*** Please tell me who you are.Run 

  git config --global user.email "[email protected]
  git config --global user.name "Your Name"
 
Then you need to execute, configure Under the git user name and email 
$ git config --global user.email "[email protected]
$ git config --global user.name "Your Name" 
 

10. Use repo init again to pull the existing manifest 
$ repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest 
Prompt: 
Enable color display in this user account (y/N)? y 
repo has been initialized in your directory This means 

that the repo has been initialized and the code can be pulled at any time. 
 
11. If you feel that pulling the code is very slow, you also need to configure the relevant network speed-up agent.  Insert the company
through 
$ vi ~/.gitconfig
$ vi ~/.netrc

Provided proxy url


12. You can synchronize the code, execute
$ repo sync -j4


13. Then wait for the code to be synchronized. The process is very slow, and it will take several hours.
The above is summed up by groping and crawling pits step by step during the development process. I can’t take screenshots, so if you don’t understand anything, you can leave a message to discuss it. In general From linux novice to knowing how to use commands to pull source code to create user names, etc., there is still a lot of progress

Guess you like

Origin blog.csdn.net/qq_37870139/article/details/131115484