Search code examples
gitgit-cloneyoctobitbakeopenembedded

How to clone a private git repo from within a BitBake recipe?


I'm interested in cloning contents of a private git repo so they can be used by a custom BitBake recipe. I've tried adapting this technique from the Yocto Project mailing lists, and produced the following:

SRC_URI = "git://www.example.com/path/to/repo;protocol=https;branch=master;name=commit;user=<username>:<password>
SRCREV_commit = "9f8309bbdf0632191bec21fada2cb61a30bcf53e"

The password I'm using contains a left parentheses. I get this error:

/bin/sh: -c: line 0: syntax error near unexpected token `)'

Can I escape this special character in some way or perhaps use some other way to clone the repo?


Solution

  • As stated in another comment, you can also use git+ssh:

    SRC_URI = "git://[email protected]/path/to/repo;protocol=ssh"
    

    Then you need to add the public key of the user that runs bitbake to the git server. A good way of debugging why a fetch does not work is to actually use ssh -v to connect:

    ssh -v [email protected]
    

    Beware of weird path differences between git server implementations (like GitLab), for instance, we need to use something like this (note the tilde) to make these URI work from both Bitbake and Google Repo:

    SRC_URI = "git://[email protected]:~/groupname/repo.git;protocol=ssh;branch=${BRANCH}"