repo安装

标签: 

杂谈

分类: Android

问题1:找不到命令:repo

方法:

在下载android源码的时候用repo时提示找不到命令,可以用如下方法解决,在命令行中输入如下两行:
echo 'export PATH=$PATH:$Home/bin' >> ~/.bashrc
export PATH=$PATH:$HOME/bin


问题2:

/home/xxxxxx/bin/repo: line 1: 在未预料的“newline”附近出现语法错误
/home/xxxxxx/bin/repo: line 1: `<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN

方法【转】:

1.安装git

sudo apt-get install git-core

2.安装curl

sudo apt-get install git-core curl

3.安装repo, 通过curl下载repo

网上或者很多书籍上都是这样写的:

curl http://android.git.kernel.org/repo > ~/bin/repo

结果得到的repo不能用,什么301重定向的,唉!悲催啊!后来在csdn上发了个贴子,大牛给解决啦!

http://code.google.com/p/git-repo/downloads/detail?name=repo-1.12 这个链接提供下载repo!

也可以通过下面命令得到:

curl http://git-repo.googlecode.com/files/repo-1.12 > ~/bin/repo

4.修改执行权限

chmod a+x ~/bin/repo

5.修改~/bin/repo文件将第五行

这一步又是容易出错啊,哥就死在这里很久啊!很多书籍或网站上都是这样命令:

~/bin/repo init -u git://android.git.kernel.org/platform/manifest.git

执行以后,等n久,结果出现让你喜出望外的结果啊

error:Failed connect to code.google.com:443; Operation now in progress while accessing https://code.google.com/p/git-repo//info/refs

网上大牛解决:修改~/bin/repo文件将第五行

REPO_URL='https://code.google.com/p/git-repo/'

改为

REPO_URL='http://code.google.com/p/git-repo/'

6.然后向PATH中添加bin路径:

export PATH=$PATH:~/bin

7.新建一个目录,然后进入该目录。

mkdir source

cd source

8.执行repo init -u git://Androidgit.linaro.org/platform/manifest.git -b android-2.3.4_r1

这一步大概有一分多钟就完成了。

9.修改.repo文件

找到source目录中的.repo下面的manifest.xml文件,这是个隐藏文件 ls -a才能看到

cd .repo

gedit manifest.xml

将fetch="git://Android.git.kernel.org/"

改为

fetch="git://Android.git.linaro.org/"

10.执行repo sync

To make edits to changes after they have been uploaded, you should use a tool like git rebase -i or git commit --amend to update your local commits. After your edits are complete: Make sure the updated branch is the currently checked out branch. For each commit in the series, enter the Gerrit change ID inside the brackets: # Replacing from branch foo [ 3021 ] 35f2596c Refactor part of GetUploadableBranches to lookup one specific... [ 2829 ] ec18b4ba Update proto client to support patch set replacments # Insert change numbers in the brackets to add a new patch set. # To create a new change record, leave the brackets empty. After the upload is complete the changes will have an additional Patch Set. If you only want to upload the currently checked out Git branch, you can use the flag --current-branch (or --cbr for short). diff repo diff [<PROJECT_LIST>] Shows outstanding changes between commit and working tree using git diff. download repo download <TARGET> <CHANGE> Downloads the specified change from the review system and makes it available in your project's local working directory. For example, to download change 23823 into your platform/build directory: repo download platform/build 23823 A repo sync should effectively remove any commits retrieved via repo download. Or, you can check out the remote branch; e.g., git checkout m/master. Note: There is a slight mirroring lag between when a change is visible on the web in Gerrit and when repo download will be able to find it for all users, because of replication delays to all servers worldwide. forall repo forall [<PROJECT_LIST>] -c <COMMAND> Executes the given shell command in each project. The following additional environment variables are made available by repo forall: REPO_PROJECT is set to the unique name of the project. REPO_PATH is the path relative to the root of the client. REPO_REMOTE is the name of the remote system from the manifest. REPO_LREV is the name of the revision from the manifest, translated to a local tracking branch. Used if you need to pass the manifest revision to a locally executed git command. REPO_RREV is the name of the revision from the manifest, exactly as written in the manifest. Options: -c: command and arguments to execute. The command is evaluated through /bin/sh and any arguments after it are passed through as shell positional parameters. -p: show project headers before output of the specified command. This is achieved by binding pipes to the command's stdin, stdout, and sterr streams, and piping all output into a continuous stream that is displayed in a single pager session. -v: show messages the command writes to stderr. prune repo prune [<PROJECT_LIST>] Prunes (deletes) topics that are already merged. start repo start <BRANCH_NAME> [<PROJECT_LIST>] Begins a new branch for development, starting from the revision specified in the manifest. The <BRANCH_NAME> argument should provide a short description of the change you are trying to make to the projects.If you don't know, consider using the name default. The <PROJECT_LIST> specifies which projects will participate in this topic branch. Note: "." is a useful shorthand for the project in the current working directory. status repo status [<PROJECT_LIST>] Compares the working tree to the staging area (index) and the most recent commit on this branch (HEAD) in each project specified. Displays a summary line for each file where there is a difference between these three states. To see the status for only the current branch, run repo status. The status information will be listed by project. For each file in the project, a two-letter code is used: In the first column, an uppercase letter indicates how the staging area differs from the last committed state. letter meaning description - no change same in HEAD and index A added not in HEAD, in index M modified in HEAD, modified in index D deleted in HEAD, not in index R renamed not in HEAD, path changed in index C copied not in HEAD, copied from another in index T mode changed same content in HEAD and index, mode changed U unmerged conflict between HEAD and index; resolution required In the second column, a lowercase letter indicates how the working directory differs from the index. letter meaning description - new/unknown not in index, in work tree m modified in index, in work tree, modified d deleted in index, not in work tree Was this page helpful? Let us know how we did:
<think>嗯,用户想在Linux系统下安装Git和Repo工具,我得先理清楚步骤。首先,安装Git应该是基础,因为Repo是基于Git的。常见的Linux发行版如Ubuntu或CentOS,可能用不同的包管理器,比如apt或者yum。记得要更新软件源,然后安装Git。这部分应该没问题。 接下来是Repo工具的安装。根据引用[3],用户需要先创建~/.bin目录,然后下载Repo脚本放到里面,并添加执行权限。同时,还要把路径添加到环境变量里,这样就能在终端直接用了。不过要注意curl命令是否正确,可能需要用https的链接,确保下载成功。另外,检查权限是否正确,否则执行的时候会报权限错误。 还有引用[5]提到的阿里巴巴的repo-go,是用Go语言写的,可能性能更好,支持多平台。用户可能需要这个替代原生的Repo工具,但需要说明两者的区别,比如命令可能不完全一样,但大部分相同。安装的话,可能需要从GitHub克隆项目然后编译,或者直接下载二进制文件,这部分可能需要补充步骤。 用户可能遇到的问题包括环境变量配置不正确,导致repo命令找不到,或者下载Repo脚本时网络问题。这时候需要提示用户检查PATH变量,或者换镜像源下载。另外,Repo本身需要Python环境,不过大多数Linux系统应该已经预装了,但最好确认一下Python的版本是否符合要求。 还有,Repo初始化的时候需要指定manifest仓库的URL,用户如果不知道具体的项目仓库,可能无法继续,所以需要提醒用户替换成实际项目的URL。比如Android开发常用的那个manifest,或者其他项目的。 另外,引用[2]提到清理Git和Repo无效代码的问题,可能用户在后续使用中会遇到存储库过大的情况,所以安装完成后,可以建议用户定期清理,但暂时先专注于安装步骤。 总结步骤应该是:安装Git -> 创建目录并下载Repo -> 设置权限和环境变量 -> 验证安装 -> 初始化Repo工作区。同时,提供repo-go的替代安装方法作为选项,满足不同需求。需要注意命令的正确性,比如curl的地址是否正确,mkdir的参数是否正确,还有chmod的权限设置。可能还要提醒用户如果.bin目录不在PATH中,需要重新登录或者source配置文件。</think>### 分步指南:Linux系统安装Git和Repo工具 #### 一、安装Git 1. **更新软件包列表** ```bash sudo apt update # Debian/Ubuntu系统 # 或 sudo yum check-update # CentOS/RHEL系统 ``` 2. **安装Git核心程序** ```bash sudo apt install git # Debian/Ubuntu # 或 sudo yum install git # CentOS/RHEL ``` 3. **验证安装** ```bash git --version ``` 成功显示版本号如$git version 2.25.1$即安装完成[^3]。 --- #### 二、安装Repo工具 1. **创建专用目录** ```bash mkdir -p ~/.bin ``` 2. **下载Repo脚本** ```bash curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo ``` 3. **设置执行权限** ```bash chmod a+rx ~/.bin/repo ``` 4. **配置环境变量** 将以下内容添加到$~/.bashrc$或$~/.zshrc$: ```bash export PATH="${HOME}/.bin:${PATH}" ``` 执行命令立即生效: ```bash source ~/.bashrc ``` 5. **验证Repo安装** ```bash repo --version ``` 应显示类似$repo launcher version 2.15$的版本信息[^5]。 --- #### 三、初始化Repo工作区 1. **创建项目目录** ```bash mkdir my-project && cd my-project ``` 2. **初始化仓库** ```bash repo init -u https://android.googlesource.com/platform/manifest ``` (替换为实际manifest仓库地址) 3. **同步代码** ```bash repo sync ``` --- #### 四、替代方案:安装repo-go(可选) 阿里巴巴开发的Go语言版本: ```bash git clone https://github.com/alibaba/git-repo-go cd git-repo-go go build -o ~/.bin/repo-go # 设置别名 echo 'alias repo="repo-go"' >> ~/.bashrc ``` 注意:该版本命令参数与标准repo存在部分差异。 --- ### 常见问题解决 1. **提示"repo: command not found"** - 检查$~/.bin$是否在$PATH$中 - 确认执行过$source ~/.bashrc$ 2. **证书验证失败** 尝试使用镜像源: ```bash curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo -o ~/.bin/repo ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值