【Linux】【开发环境】【RHEL】开发环境搭建系列之五——安装git-repo环境

简介: 【Linux】【开发环境】【RHEL】开发环境搭建系列之五——安装git-repo环境

git-repo简介


  • git-repo简称Repo,是google为了方便管理多个git库而开发的Python脚本;


  • repo本身依赖git(建议1.9以上)和python(3.5以上版本);


  • 实际在Android开发或高通芯片sdk开发中,经常使用这种机制来下载源代码。


安装过程


下载repo


[qxhgd@localhost git-repo]$ curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 43050  100 43050    0     0   7213      0  0:00:05  0:00:05 --:--:-- 12471


增加x权限


[qxhgd@localhost git-repo]$ chmod +x repo


修改repo更新自己的git源


[qxhgd@localhost git-repo]$ vi ~/.bashrc
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
[qxhgd@localhost git-repo]$ source ~/.bashrc


也可以加入到~/.profile文件中,效果一样。


不修改该环境变量,则需要FQ。


安装python3.8.0


从源码安装python的时候,需要额外安装或替换zlib、ssl等几个库。


具体看后面的详细命令。


一定要安装openssl、openssl-devel两个库。


使用git-repo下载代码


[qxhgd@localhost repo]$ sudo repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/lineageOS/LineageOS/android.git -b cm-14.1 --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo
[qxhgd@localhost repo]$ repo sync


在实际的工作当中,上述命令的具体格式和参数都是由提供产品或服务的厂商提供的。


命令汇总


## 1、repo环境安装
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o repo
vi ~/.bashrc 
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
source ~/.bashrc
## 2、repo下载git代码库
repo init #初始化库
repo sycn #下代码包
## 3、python卸载(卸载有风险)
yum remove python #yum卸载python
rpm -qa | grep python|xargs rpm -ev --allmatches --nodeps  ##强制删除已安装程序及其关联
whereis python | xargs rm -frv #删除所有残余文件
whereis python #确认下
## 4、python源码安装,如安装python3.8为例:
yum install openssl       #后续git repo依赖于ssl库,非常重要
yum install openssl-devel #后续git repo依赖于ssl库,非常重要 
# 以上两条可避免repo init的时候,报“fatal: error unknown url type: https repo”这个错误
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz #下tar包
tar -zxvf Python-3.8.0.tgz #解压
./configure --with-zlib --with-ssl #配置
make #编译
make install #安装
ln -sf /usr/bin/python3 /usr/local/bin/python3 #建软链接


注意事项


虽然git-repo要求python版本不低于3.5,但yum默认的python版本为2.7.5,所以升级python版本容易出问题。


如果yum和repo并存,则需要两个版本的python并存,具体由:


/usr/bin/yum
/usr/bin/repo


两个脚本中的首行“#!/usr/bin/python”来选择使用的python版本。


常用git-repo库镜像及repo命令说明


清华镜像


码云


google原装(需要FQ)


repo命令参考

相关文章
|
2天前
|
Linux 开发工具 C语言
Linux 安装 gcc 编译运行 C程序
Linux 安装 gcc 编译运行 C程序
20 0
|
2天前
|
Ubuntu Linux Python
Linux(15)Ubuntu安装ninja构建工具
Linux(15)Ubuntu安装ninja构建工具
12 0
|
5天前
|
NoSQL Linux 测试技术
Redis的安装(Linux版)
Redis的安装(Linux版)
105 1
|
15天前
|
缓存 Linux 测试技术
安装【银河麒麟V10】linux系统--并挂载镜像
安装【银河麒麟V10】linux系统--并挂载镜像
78 0
|
15天前
|
Linux C语言
linux yum安装ffmpeg 图文详解
linux yum安装ffmpeg 图文详解
35 0
|
15天前
|
NoSQL Linux Redis
linux 下和win下安装redis 并添加开机自启 图文详解
linux 下和win下安装redis 并添加开机自启 图文详解
17 0
|
15天前
|
Linux
linux yum 安装rar和unrar
linux yum 安装rar和unrar
50 0
|
13天前
|
存储 算法 Linux
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
【实战项目】网络编程:在Linux环境下基于opencv和socket的人脸识别系统--C++实现
37 6
|
1天前
|
监控 安全 Linux
Linux系统之安装ServerBee服务器监控工具
【4月更文挑战第22天】Linux系统之安装ServerBee服务器监控工具
33 2
|
1天前
|
Linux 开发工具 C语言
【linux基础(七)】Linux中的开发工具(下)--make/makefile和git
【linux基础(七)】Linux中的开发工具(下)--make/makefile和git