当前位置: 首页 > java >正文

【Ubuntu22.04】repo安装方法

背景

repo是Google开发的用于基于git管理Android版本库的一个工具,管理多个Git仓库的工具,它可以帮助您在一个代码库中管理多个Git仓库的代码。其在鸿蒙操作系统中大量使用。下面我们就介绍repo在wsl中的安装部署。

安装方法

  1. 使用中国科技大学资源

脚本install_repo.sh:

mkdir -p ~/.bin/repo
git clone https://gerrit-googlesource.lug.ustc.edu.cn/git-repo ~/.bin/repo
chmod +x ~/.bin/repo/repo
echo 'export PATH=~/.bin/repo:$PATH' >> /root/.bashrc
source ~/.bashrc

脚本执行后重开终端。验证:

root@DESKTOP-UKR8O1E:~# repo --version
<repo not installed>
repo launcher version 2.54(from /root/.bin/repo/repo)
git 2.34.1
Python 3.10.12 (main, Feb  4 2025, 14:57:36) [GCC 11.4.0]
OS Linux 5.10.16.3-microsoft-standard-WSL2 (#1 SMP Fri Apr 2 22:23:49 UTC 2021)
CPU x86_64 (x86_64)
Bug reports: https://issues.gerritcodereview.com/issues/new?component=1370071
  1. 使用清华大学资源

脚本install_repo.sh:

mkdir -p ~/.bin/repo
git clone https://mirrors.tuna.tsinghua.edu.cn/git/git-repo ~/.bin/repo
chmod +x ~/.bin/repo/repo
echo 'export PATH=~/.bin/repo:$PATH' >> /root/.bashrc
source ~/.bashrc

脚本执行后重开终端。验证省略。

使用问题集锦

  • repo init 提示“fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle“
root@DESKTOP-R500S71:/home/work# repo init -u https://gitee.com/ark-standalone-build/manifest.git -b master
Downloading Repo source from https://gerrit.googlesource.com/git-repo
fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 110] Connection timed out
fatal: cloning the git-repo repository failed, will remove '.repo/repo'

原因:国内网络限制,无法访问https://gerrit.googlesource.com/git-repo/clone.bundle
解决方法:
替换脚本replace_repo_url.sh,替换REPO_URL 内容为:https://mirrors.tuna.tsinghua.edu.cn/git/git-rep

#!/bin/bash# 查找repo路径
REPO_PATH=$(which repo)if [ -z "$REPO_PATH" ]; thenecho "错误:未找到repo命令"exit 1
fi# 备份原始文件
BACKUP_PATH="${REPO_PATH}.bak"
echo "备份原始文件到 ${BACKUP_PATH}..."
sudo cp "$REPO_PATH" "$BACKUP_PATH"# 执行替换操作
echo "执行URL替换..."
sudo sed -i 's|https://gerrit.googlesource.com/git-repo|https://mirrors.tuna.tsinghua.edu.cn/git/git-repo|g' "$REPO_PATH"if [ $? -eq 0 ]; thenecho "替换成功完成!"
elseecho "替换过程中出现错误,已恢复备份"sudo mv "$BACKUP_PATH" "$REPO_PATH"exit 1
fi
http://www.xdnf.cn/news/15417.html

相关文章:

  • 基于STM32的智能火灾报警系统设计
  • AI|大模型入门(六):GPT→盘古,国内外大模型矩阵速览
  • kotlin布局交互
  • 响应式编程入门教程第三节:ReactiveCommand 与 UI 交互
  • 【PTA数据结构 | C语言版】创建哈夫曼树
  • 医疗数据分析中标准化的作用
  • Java项目:基于SSM框架实现的学生档案管理系统【ssm+B/S架构+源码+数据库+毕业论文+开题报告】
  • 剑指offer62_骰子的点数
  • Vue3入门-指令
  • brupsuite使用中遇到的一些问题(bp启动后浏览器无法连接)/如何导入证书
  • 智能体技术深度解析:从概念到企业级搭建指南
  • 安全参綉25暑假第一次作业
  • Student后台管理系统查询接口
  • CentOS服务器安装Supervisor使队列可以在后台运行
  • GAMES101 lec2-数学基础1(线性代数)
  • 为何说分布式 AI 推理已成为下一代计算方式
  • 特殊的整数-水仙花数
  • 【c++】c++11新特性(右值引用和移动语义)
  • Java报表导出框架
  • 详解BIO,NIO,AIO
  • 【git fetch submodule报错】Errors during submodule fetch 如何解决?
  • 【Java EE】多线程-初阶 认识线程(Thread)
  • urlencode、html实体编码、unicode
  • 进程---基础知识+命令+函数(fork+getpid+exit+wait+exec)
  • ACL流量控制实验
  • 12.如何判断字符串是否为空?
  • 记字节前端面试一道简单的算法题
  • 游戏玩法的专利博弈
  • 大话数据结构之 <链表>(C语言)
  • 使用 keytool 在服务器上导入证书操作指南(SSL 证书验证错误处理)