Fetching Git repositories outside GitHub

As we can see from the preceding example, we created our manifest repository for the GitHub mirror. After that, we use it to initialize our mirror repo. Then we use the repo sync command to fetch all Git repositories from GitHub to our local mirror.

How about repositories that we don't have write access to? In this book, we use a lot of projects from Android-x86. However, we don't have write permission to Android-x86 repositories. The Android-x86 project also doesn't have a mirror manifest available for use.

We can actually create a mirror manifest file from the original Android-x86 manifest. We can refer to the document at the following link for how to get Android-x86 source code:

http://www.android-x86.org/getsourcecode

The previous document mentioned that we can use the following command to initialize and sync repo from the Android-x86 repository:

$ mkdir android-x86
$ cd android-x86
$ repo init -u git://git.osdn.net/gitroot/android-x86/manifest -b $branch
$ repo sync

We can clone the preceding Android-x86 manifest repository to a folder and analyze it:

$ git clone git://git.osdn.net/gitroot/android-x86/manifest -b marshmallow-x86
$ ls
cm.xml default.xml

After we clone it, we can find the preceding two files. default.xml is used to initialize the Android-x86 repo and cm.xml is used to initialize Android-x86 for the CyanogenMod build.

If we look at the content of default.xml, we can see the following code snippet:

<?xml version="1.0" encoding="UTF-8"?> 
<manifest>

<remote name="aosp"
fetch="https://android.googlesource.com/" />
<remote name="x86"
fetch="." />
<default revision="refs/tags/android-6.0.1_r61"
remote="aosp"
sync-c="true"
sync-j="4" />

<!-- from x86 port repositories -->
<project path="build" name="platform/build" groups="pdk" remote="x86"
revision="marshmallow-x86" >
<copyfile src="core/root.mk" dest="Makefile" />
</project>
<project path="kernel" name="kernel/common" remote="x86"
revision="kernel-4.4" />
<project path="art" name="platform/art" groups="pdk" remote="x86"
revision="marshmallow-x86" />
...
<!-- from original Android repositories -->
<project path="abi/cpp" name="platform/abi/cpp" groups="pdk" />
<project path="bootable/recovery" name="platform/bootable/recovery"
groups="pdk" />
...
</manifest>

We can see that the Android-x86 manifest includes two parts. The first part is Android-x86, its own repositories, and the rest are the original AOSP repositories.

We can retrieve the first part and compose a mirror manifest for Android-x86. Where should we put this file? We can put it in a branch of the same mirror manifest repository in our GitHub.

In the working copy of our GitHub mirror repository, we can create a branch called android-x86. We can replace default.xml in our GitHub mirror with the first part in Android-x86 manifest and we get the one in the following listing:

<?xml version="1.0" encoding="UTF-8"?> 
<manifest>

<remote name="github"
fetch=".." />

<remote name="x86"
fetch=" git://git.osdn.net/gitroot/android-x86/" />

<default revision="android-x86"
remote="github"
sync-j="4" />

<!-- from x86 port repositories -->
<project name="manifest" remote="x86" />
<project name="platform/build" remote="x86" />
<project name="kernel/common" remote="x86" />
<project name="platform/art" remote="x86" />
...
<project name="platform/system/extras" remote="x86" />
<project name="platform/system/vold" remote="x86" />

</manifest>

As we can see from the preceding listing, we removed unnecessary fields such as path or groups, and so on. With this manifest for the Android-x86 mirror, we can create a local mirror for Android-x86 now as follows:

$ mkdir -p /media/aosp-mirror/android-x86
$ cd /media/aosp-mirror/android-x86
$ repo init -u https://github.com/shugaoye/mirror.git -b android_x86 --mirror
$ repo sync

After we download all Git repositories, we can see the content as follows:

Local mirror of android-x86
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.118.40