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

【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.lryc.cn/news/588621.html

相关文章:

  • 1.2 vue2(组合式API)的语法结构以及外部暴露
  • 如何把手机ip地址切换到外省
  • 【深度学习优化算法】06:动量法
  • 从springcloud-gateway了解同步和异步,webflux webMvc、共享变量
  • iOS V2签名网站系统源码/IPA在线签名/全开源版本/亲测
  • iOS 抓包工具精选对比:不同调试需求下的工具适配策略
  • 项目总体框架(servlet+axios+Mybatis)
  • 【解决】联想电脑亮度调节
  • iOS高级开发工程师面试——多线程
  • Axios 和 Promise 区别对比
  • Supervisor 使用教程:进程守护的最佳实践指南
  • 【Git】详解git commit --amend用法以及使用遇到的问题
  • eVTOL分布式电推进(DEP)适航审定探究
  • Python 操作Excel工作表:添加、删除、移动、隐藏
  • redis集群的部署
  • 线性代数小述(三)
  • Pitaya 是一个简单、快速、轻量级的游戏服务器框架,它为分布式多人游戏和服务器端应用程序提供了一个基本的开发框架
  • 【橘子分布式】Thrift RPC(编程篇)
  • Vim多列操作指南
  • 028_分布式部署架构
  • 淘宝扭蛋机小程序开发:重构电商娱乐化体验的新范式
  • GaussDB 数据库架构师修炼(四) 备份容量估算
  • 【轨物洞见】光伏运维的“无人区”突围战,数据智能是唯一航标
  • Python Docker SDK库详解:从入门到实战
  • docker 方式gost代理搭建以及代理链实施
  • Linux VFS 抽象层全解析:统一接口的力量
  • JAVA学习笔记 使用notepad++开发JAVA-003
  • 微信小程序进度条cavans
  • 虚拟主机CPU占用100导致打不开的一次处理
  • [数据结构]#3 循环链表/双向链表