本地 Android repo 仓库迁移、恢复源码树

前言

本篇记录如何迁移本地 Android repo 仓库,对此过程做以记录,谨防备份。
此迁移的基础是本地 repo 仓库是正常使用、并git管理各子项目,在迁移前把
子项目 commit 完成。

第一步 压缩本地 repo 仓库

tar -zcvf repo.tar.gz .repo/*

第二步 拷贝压缩文件到开发服务器虚拟机并解压

scp repo.tar.gz robox@192.168.88.253:/home/robox/android_build
tar -zxvf repo.tar.gz

#第三步 搭建 repo 参考环境
在 home/robox 路径下,创建环境

$ mkdir bin && cd bin
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ export PATH=${
    
    PATH}:~/bin

验证 repo 环境

robox@robox-Vostro-3681:~/android_build$ repo help
usage: repo COMMAND [ARGS]
The most commonly used repo commands are:
  abandon        Permanently abandon a development branch
  branch         View current topic branches
  branches       View current topic branches
  checkout       Checkout a branch for development
  cherry-pick    Cherry-pick a change.
  diff           Show changes between commit and working tree
  diffmanifests  Manifest diff utility
  download       Download and checkout a change
  gitc-delete    Delete a GITC Client.
  gitc-init      Initialize a GITC Client.
  grep           Print lines matching a pattern
  info           Get info on the manifest branch, current branch or unmerged branches
  init           Initialize a repo client checkout in the current directory
  list           List projects and their associated directories
  overview       Display overview of unmerged project branches
  prune          Prune (delete) already merged topics
  rebase         Rebase local branches on upstream branch
  smartsync      Update working tree to the latest known good revision
  stage          Stage file(s) for commit
  start          Start a new branch for development
  status         Show the working tree status
  sync           Update working tree to the latest revision
  upload         Upload changes for code review
See 'repo help <command>' for more information on a specific command.
See 'repo help --all' for a complete list of recognized commands.
Bug reports: https://bugs.chromium.org/p/gerrit/issues/entry?template=Repo+tool+issue

repo环境正常。

第四步 恢复 repo 仓库源码

在 home/robox/android_build 路径下还原源码

$ repo sync -l

源码还原后、验证代码分支

robox@robox-Vostro-3681:~/android_build$ repo branch
   virtualMachine            | in all projects

第五步 安装android编译环境依赖包、并编译android镜像

#sudo apt-get install flex bison gperf build-essential tofrodos python-markdown libxml2-utils xsltproc
# sudo apt-get install zlib1g-dev lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z1-dev libgl1-mesa-dev
# sudo apt-get install uuid-dev:i386 liblzo2-dev:i386 uuid uuid-dev
# sudo apt-get install gcc-multilib g++-multilib
# sudo apt-get install openssh-server openssh-client
# sudo apt-get install liblzo2-2 liblzo2-dev lzop zlib1g-dev liblz-dev
# sudo apt-get install git-core curl subversion
# sudo apt-get install u-boot-tools mtd-utils device-tree-compiler
# sudo apt-get install android-tools-fsutils
# sudo apt-get install openjdk-8-jdk
# sudo apt-get install aptitude
# sudo aptitude install libcurl4-openssl-dev nss-updatedb

编译 android 镜像

解决错误

由于 androoi 源码是 nxp 开源代码,早期搭建环境时,其中 vendor/nxp 目录闭源的 *.bin 文件内容
并没有在repo仓库中,需要手工压缩此部分内容,覆盖 home/robox/android_build/vendor/nxp 文件夹
内容。
再次编译 android 源码成功,本次 repo 仓库迁移成功,更换性能更强悍的服务器.

附录: 如何节约 ssd 固态盘、并管理多版本镜像

如果你的计算机全是 ssd 硬盘、那你是土豪、下面内容可以略过了。

在编译镜像前、android_build 路径下的 out 文件夹删除,在机械盘空间里创建 如 hikey960/out 的文件夹,
把此文件夹软连接到 android_build 路径下,在编译镜像、编译输出内容就输出到机械硬盘中,
当管理多个版本android镜像时、还是比较实用的哦。
你的点赞就是作者分享的动力 V_V.

猜你喜欢

转载自blog.csdn.net/weixin_38387929/article/details/125414583