Pro tips for 'repo': list all project names and locations

9,485 views
Skip to first unread message

Greg Spencer

unread,
Mar 10, 2011, 3:18:13 PM3/10/11
to Chromium OS dev
One feature I find is sorely missing from repo (and I might add it if I get some free time to figure out how) is a way to list the locations and names of all the repo projects.

For instance, if I want to work on the code that lives in the "platform/dev" dir, I have to know to tell repo:  "repo start my_branch dev-util", which is not very intuitive.

So, until someone adds the ability to either list the mapping, or (even better) find out which project I mean from the path it resides in, here's my workaround:

You can list the mapping by typing:

repo forall -c 'echo "$REPO_PATH -- $REPO_PROJECT"'

Which will enter each repo dir and then echo the path it's in, and the name of the project according to repo.

And here's a bash function to echo which repo project the given directory belongs to, if any.  (defaults to the current dir)

--
function which_repo {
  # default to the current working directory, but take an arg if we
  # give it.
  local arg=${1:-$PWD}

  # Canonicalize the path
  arg=$(readlink -f $arg)

  repo forall -c 'arg='"$arg"'; if [[ "$arg" != "${arg%$REPO_PATH}" ]]; then echo "$REPO_PROJECT"; fi'
}
--

Hope that's helpful.  :)

-Greg.

Jonathan Kliegman

unread,
Mar 10, 2011, 3:22:21 PM3/10/11
to Greg Spencer, Chromium OS dev
What I usually do is:

'repo start my_branch .' which saves me the trouble of knowing the correct repo to use.

'repo sync .' has also worked for me.

--
Chromium OS Developers mailing list: chromiu...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-os-dev?hl=en

Anush Elangovan(அனுஷ்)

unread,
Mar 10, 2011, 3:49:01 PM3/10/11
to Jonathan Kliegman, Greg Spencer, Chromium OS dev
I usually use "." to refer to the project. 

You could also "cat .repo/manifest.xml" to get a list of all the projects and mappings. 

Thanks 

Vadim Bendebury

unread,
Mar 11, 2011, 1:11:41 AM3/11/11
to Anush Elangovan(அனுஷ்), Chromium OS dev
On Thu, Mar 10, 2011 at 12:49 PM, Anush Elangovan(அனுஷ்)
<an...@chromium.org> wrote:
> I usually use "." to refer to the project.

this of course works, after the project has been already synced at least once.

What I find less intuitive - how does one sync only the project they
just ran 'cros_workon start xxx' on. Running 'repo sync' in this case
in not a good option - first, it takes long time, and then it might
update other projects which one might want to keep intact.

It would be great to have the ability to match cros_workon and repo
projects, or even better - have cros_workon to repo sync the project
automatically?

cheers,
/v

Todd Vierling

unread,
Mar 11, 2011, 10:19:08 AM3/11/11
to Vadim Bendebury, Anush Elangovan(அனுஷ்), Chromium OS dev
2011/3/11 Vadim Bendebury <vbe...@chromium.org>:

> What I find less intuitive - how does one sync only the project they
> just ran 'cros_workon start xxx' on. Running 'repo sync' in this case
> in not a good option - first, it takes long time, and then it might
> update other projects which one might want to keep intact.

At first I thought maybe "git pull" would work, because that does work
for other projects, but when starting from minilayout and running "git
pull" from src/platform/<workonproject>, I get:

fatal: No remote repository specified. Please, specify either a URL or a
remote name from which new revisions should be fetched.

(Outside chroot, with an older git, I get "fatal: Where do you want to
fetch from today?")

That's weird.

Vadim Bendebury

unread,
Mar 11, 2011, 11:07:59 AM3/11/11
to Todd Vierling, Anush Elangovan(அனுஷ்), Chromium OS dev

But each project is a separate git repo, and unless you git cloned it
first, indeed, how does git know what to do?

the sequence

cros_workon start <ebuild name>
repo sync <project name>

works for me, it's just not obvious which <project name> matches a
particular <ebuild name>.

cheers,
/v

Doug Anderson

unread,
Mar 11, 2011, 11:35:54 AM3/11/11
to Vadim Bendebury, Todd Vierling, Anush Elangovan(அனுஷ்), Chromium OS dev
Vadim,

This might help you (from the dev guide: Figure out where the ebuild / source code for the project is located)... 

I will completely agree that this is non-obvious (I need to look it up each time I do it):

Figure out where the ebuild / source code for the project is located

It can be a little tricky to figure out where the source code and ebuild for your project is located. Luckily, some magic portage commands can help you.

To find out where the ebuild lives:

equery-${BOARD} which ${PACKAGE_NAME}

As an example, for PACKAGE_NAME=chromeos-wm, the above command might display:
    /home/.../trunk/src/third_party/chromiumos-overlay/chromeos-base/chromeos-wm/chromeos-wm-9999.ebuild

SIDE NOTE: If you run the same command without running cros_workon first, you can see the difference:
    /home/.../trunk/src/third_party/chromiumos-overlay/chromeos-base/chromeos-wm/chromeos-wm-0.0.1-r134.ebuild

To find out where the source code lives (and what git repo it's under):

ebuild-${BOARD} `equery-${BOARD} which ${PACKAGE_NAME}` info

Trying this command with PACKAGE_NAME=chromeos-wm, you might see something like:
    CROS_WORKON_SRCDIR="/home/.../trunk/src/platform/window_manager"
    CROS_WORKON_PROJECT="window_manager"

SIDE NOTE: The shell script below can be interesting/useful if you want to see info about all packages (it's a little slow, though):

ALL_PACKAGES=`./cros_workon --board=${BOARD} list --all`
for package in ${ALL_PACKAGES}; do
  ebuildPath=`equery-${BOARD} which ${package}`
  eval `ebuild-${BOARD} "${ebuildPath}" info`
  echo "${package} - $CROS_WORKON_PROJECT - $CROS_WORKON_SRCDIR"
done

---

NOTE: One downside of doing a 'repo sync' of just the project that you started to work on is that it is probably going to be a different version than the rest of your source code (since you synced everything else a while ago and you synced this package now).  I don't know of any good way offhand to sync a single project to the same time that the last "repo sync" happened...


-Doug

---

Vadim Bendebury

unread,
Mar 11, 2011, 11:42:13 AM3/11/11
to Doug Anderson, Todd Vierling, Anush Elangovan(அனுஷ்), Chromium OS dev

Doug, this is a great hint, thank you.

> ---
> NOTE: One downside of doing a 'repo sync' of just the project that you
> started to work on is that it is probably going to be a different version
> than the rest of your source code (since you synced everything else a while
> ago and you synced this package now).

Of course, one is supposed to know what he is doing, and how much
ahead the new package might be.

The downside of repo sync across the board is that in case one has a
few other projects checked out and with pending changes, the sync
fails, or if the changes in those other projects have been committed
but not finalized yet, the unwanted sync messes up the changes.

So, there is a fine line here.

cheers,
/v

Doug Anderson

unread,
Mar 11, 2011, 11:46:19 AM3/11/11
to Greg Spencer, Chromium OS dev
Greg,

I have almsot exactly the same: 
    repo forall -c 'echo ...'

...in my notes.  Maybe I will see if I can convince Shawn to accept a patch to add a top-level repo command that does this (just to make it more discoverable).


As people mentioned, the 'which_repo' function shouldn't be needed as much since you can use '.'.  Maybe that needs to be solved in documentation / help.  Does that sound reasonable?  Are there other use cases you see for which_repo?

-Doug

---

--

Mandeep Singh Baines

unread,
Mar 11, 2011, 1:14:44 PM3/11/11
to Greg Spencer, Chromium OS dev
Greg Spencer (gspe...@chromium.org) wrote:
> One feature I find is sorely missing from repo (and I might add it if I get
> some free time to figure out how) is a way to list the locations and names
> of all the repo projects.
>
> For instance, if I want to work on the code that lives in the "platform/dev"
> dir, I have to know to tell repo: "repo start my_branch *dev-util*", which

> is not very intuitive.
>
> So, until someone adds the ability to either list the mapping, or (even
> better) find out which project I mean from the path it resides in, here's my
> workaround:
>
> You can list the mapping by typing:
>
> repo forall -c 'echo "$REPO_PATH -- $REPO_PROJECT"'
>
> Which will enter each repo dir and then echo the path it's in, and the name
> of the project according to repo.
>
> And here's a bash function to echo which repo project the given directory
> belongs to, if any. (defaults to the current dir)
>
> --
> function which_repo {
> # default to the current working directory, but take an arg if we
> # give it.
> local arg=${1:-$PWD}
>
> # Canonicalize the path
> arg=$(readlink -f $arg)
>
> repo forall -c 'arg='"$arg"'; if [[ "$arg" != "${arg%$REPO_PATH}" ]]; then
> echo "$REPO_PROJECT"; fi'
> }
> --
>
> Hope that's helpful. :)
>
> -Greg.
>

Just wanted to point out that here is a repo-discuss mailing list.
Feel free to crosspost.

http://groups.google.com/group/repo-discuss

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages