Adding new git into AOSP repo

Issue

I created a new device mydevice/ under $AOSP_ROOT/device/. I am trying to add the git into $AOSP_ROOT/.repo for local tracking purpose, I found it extremely useful if I can see the changes when performing a repo status or repo diff. These are the steps I tried:

  1. perform git init at mydevice folder, leave changes uncommitted
  2. Add the project into $AOSP_ROOT/.repo/manifest.xml

Unfortunately, when I performs repo status my project is not reflected in the output. What did I do wrong?

Solution

Let’s say $HOME is /home/consy/ and $AOSP_ROOT is /home/consy/aosp/.

#init a local bare repo as the remote repo of `mydevice`
cd $AOSP_ROOT/device/
git init mydevice
git commit --allow-empty -m 'init repository'
cd $HOME
git clone $AOSP_ROOT/device --bare -- mydevice.git
cd $AOSP_ROOT/device
rm -rf mydevice

#create .repo/local_manifests (this is a feature of repo)
mkdir -p $AOSP_ROOT/.repo/local_manifests

#create a manifest under `local_manifests`.
#You can name it whatever you like except that the manifest's content should be like:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
  <remote fetch="file:///home/consy/" name="this"/>
  <!-- it allows only one "default" in the manifests that take effect -->
  <!-- so, do not define the "default" element here -->
  <project name="mydevice" path="device/mydevice"/>
</manifest>

Now when you run repo sync, the project(s) defined in the local manifest will be added into $AOSP_ROOT as extra projects. You can use repo commands like repo status to manipulate these extra projects. The repository will be cloned from /home/consy/mydevice.git and be checked out to $AOSP_ROOT/device/mydevice. After you make new commits under $AOSP_ROOT/device/mydevice, you can run git push this <ref>:<ref> to upload the commits to /home/consy/mydevice.git. Later, when you think it’s ready to publish this new repository to a real host like Github or your own Gerrit, you can add a new remote pointing to Github or Gerrit and push through it. Then add the project definition <project name="mydevice" path="device/mydevice"/> into the main manifest you use when repo init, commit the change, and push to the remote manifest repository. After that, you can remove the local manifest under $AOSP_ROOT/.repo/local_manifests in order to avoid a duplicate-project error.

As to the the local manifest feature, see Local Manifests at https://gerrit.googlesource.com/git-repo/+/master/docs/manifest-format.md. If the link can’t be accessed to, google repo manifest format. The doc is also available under .repo/repo/docs.

Answered By – ElpieKay

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published