Downloading Android source with repo - android

When I give these commands then the 2.3.7 branch gets initialized in current directory and source gets downloaded.
repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.7_r1
repo sync
Thereafter if I give following command what exactly happens
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
or
repo init -u https://android.googlesource.com/platform/manifest
My Questions
Will my earlier branch be deleted which I have downloaded with great difficulty? Cant I have multiple branches existing simultaneously?
If I can have more than one branch then how to access them? I dont see any directory called 2.3.7 or 4.0.1.
The repo directory structure is very confusing. Can anybody guide?

You should start a new repo branch within the same source code branch
repo start BRANCH_NAME [PROJECT_LIST]
Also refer to the following book on how to switch and make use to features in git
Look at section on branching and merging. Create branch using repo and then git commands to move around

You should do a repo init in a different directory. repo init clones the git structure specified by the manifest file
e.g
android/gingerbread/repo init
android/eclair/repo init

I see that you want to sync a new branch while using the files downloaded at previous sync to save download time.
create a new directory
copy the .repo file (hidden) from the old branch_folder (gingerbread in your case) to a new directory
cd into that directory
Finally you can do:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
repo sync

Related

CM Source takes long time to download.Is there any way to reduce it?

I'm trying to build custom rom for my device from CM source.I'm following this guide to build:
https://wiki.cyanogenmod.org/w/Build_for_quark
I'm using this command to sync the source.
repo init -u https://github.com/CyanogenMod/android.git -b cm-12.1
During download i can see other branches like 7,8,9,10,11,12.Is there any way to download only current branch (12.1)?
The repo sync command is same as git clone when used without any flags, that means you are simply downloading all the branches from all the repositories defined in the manifest file (visit this and see the default.xml file).
To download only the current branch that is cm-12.1, use the -c flag while using the repo sync command. Note that the Android source is made from many projects and is a huge download when you are syncing for the first time.
So your commands should be:
repo init -u https://github.com/CyanogenMod/android.git -b cm-12.1
repo sync -c
For a better understanding of how repo tool works just read this article.
I hope this helps.

How to download only a working directory of the AOSP source code without the entire repo history?

The size of the latest AOSP source code is rather large (around 30-35 Gb for the .repo directory and another 15 Gb or so for the working directory). Is there a way to download only a snapshot of the latest version of the source code (official marshmallow release) without the entire repo history? That would save me a lot in bandwidth and storage.
You can specify --depth 1 to git clone command. It will only get the latest snapshot.
Step to download android source code(AOSP) in Ubuntu
First create one folder like "aosp-m" to copy AOSP code in your machine.
Open terminal(Ctrl+Alt+T) and change your Dir to latest created Dir let say "aosp-m"
After that Run the following command in terminal :-
git clone git://gitz01/cm/download/android/manifest
if this link not work then try this one
repo init -u https://android.googlesource.com/platform/manifest
Run Following command in terminal one by one
git config --global user.name "Your Name"
git config --global user.email "you#example.com"
then run following command for repo init
repo init -u git://gitz01/cm/download/android/manifest -b master -m identifiedmanifest.xml
if this link not work then try this one
repo init --depth=1 -u https://android.googlesource.com/platform/manifest -b identifiedmanifest.xml
here you can replace identifiedmanifest.xml to your desired AOSP source code , Let Say "android-6.0.1_r10.xml" marshmellow.
and in the last run "repo sync" command. This command start downloading your desired AOSP code in your machine. This opertation take more than 1 hours(depending on your internet connection speed) to download source code.
Thats it... Happy Coding.......
Since git version 2.19 (released in 2018), we can utilize git's --partial-clone flag via the repo tool like the following:
repo init -u https://android.googlesource.com/platform/manifest -b master --partial-clone --clone-filter=blob:limit=10M
For readers of this question and answer in 2020, be warned that the AOSP repositories have gotten bigger and the above command still results in around 73 gigabytes of source code and related files.

How to switch android version in local repo?

I have downloaded whole working tree with the following command:
repo init -u https://android.googlesource.com/platform/manifest
repo sync -j8
After syncing successfully, I want to switch working tree to android 2.3.7.
You see I didn't specify branch with "-b" parameter when "repo init".
So I guess all tag info should be downloaded and I can easily switch to android 2.3.7 with the following command:
repo forall -c git checkout android-2.3.7_r1
But it produces many errors like:
error: pathspec 'android-2.3.7_r1' did not match any file(s) known to git.
So how can I switch to android 2.3.7 without "repo init -b android-2.3.7_r1" and "repo sync" again?
You cannot solve this problem using repo forall.
Lets assume for certainty that your current Android tree is clean - no local changes or commits, i.e. repo status shows nothing.
To properly switch Android version, all you need to change is branch for your manifest repository. First determine the available branches with manifests for the different Android versions:
cd $ANDROID_ROOT
cd .repo/manifests
git branch -av # see all available branches on origin
Select a version and
cd $ANDROID_ROOT
repo init -b <my_selected_android_version>
Such selective repo init with -b (without -u) will only update manifest branch and will not otherwise touch your tree.
Now, simply sync it:
repo sync -j8
and some time later, your Android tree will switch to another version.
Speed of this operation is mostly determined by how much default.xml manifest file differs between old and new Android versions - because if some git repository was added in new manifest, it will spend time cloning it. And if some repository was removed, if will actually blow it away.
But, by and large, this method is still much faster than initializing brand new Android tree from scratch.
if the branch you are in and the branch you will switch to has the same manifest.xml file, then you can use the following commands to do that.
repo forall -c git fetch aosp --tags
repo forall -c git checkout -b john5.1.1_r14_api22 android-5.1.1_r14
also see details in
http://johnliao52.github.io/2016/03/27/git-repo-skills.html

Android source code - Copying downloaded code to mirror

I have already downloaded Android source code using
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
Now I want to create a mirror for other people to access over LAN
repo init -u https://android.googlesource.com/mirror/manifest --mirror
Can I copy already downloaded source inside mirror dir so that download usage will be low?
I think yes, you can. The only thing that you should do is to correct manifest file. For instance, you can read here how to do this.

Android repo command and switching branches

I feel I have a pretty good understanding of git, but when it comes to the repo command, I get lost. I've read about the repo command, but I'm still not sure how it ties everything together.
My biggest question is can I change my current branches from gingerbread to ICS and possibly back?
I see the command:
repo init -u https://android.googlesource.com/platform/manifest
From my understanding, this will create a repo with the master branch. If I want to specify the branch, I can do:
repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
The download is about 8GB, I believe, so I don't want to have to blow my repo away if they share code. is there a way to switch branches in repo?
If you run repo init a second time with a different branch, you can simply repo sync and it will not download the entire source code again.
The second time you run repo init, just run it as
repo init -b different_branch
You don't need to provide the -u parameter again.
The repo -b parameter specifies the branch of the .repo/manifests git repository that should be checked out. The default.xml file in this repository defines which branch each of the other git repositiories (projects) should be on.
It seems that repo is written in such a way that if you check out another manifest branch are repo sync again it will pull all the code again over the network.
You can run repo forall -c 'git checkout branch_name' which will checkout the specified branch for all projects that are declared in your current manifest but if there are projects added/removed between gingerbread and ics (which there are), then you won't get the code for these projects.
Running git checkout branchname in the .repo/manifests repository then running repo sync may enable you to save some network overhead.
Otherwise, due to the limitations of repo, the only real way to do it is to maintain two working copies of the aosp or be prepared to re-sync.

Categories

Resources