Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 355
karobar Avatar asked Sep 13 '25 18:09

karobar


2 Answers

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}"
like image 144
jubr Avatar answered Sep 16 '25 07:09

jubr


Well, maybe not the answer you're looking for...

Usually, I'm using ssh-authentications, and thus I just use the username in the SRC_URI; then ssh-agent takes care of the authenticaton part. This can rather easily also be set up on an autobuilder.

Another approach would be to add the credentials to .netrc. In this case, add a file .netrc to you home directory, with contents as follows:

machine stash1.mycompany.com
login myusername 
password mypassword

This should allow you to omit the username and password from SRC_URI.

Depending on you situation, it might be considered a benefit to not store the credentials in the recipe itself. Or it might not...

If you want to store the password (with the ')') in your recipe, you'll need to find a way to escape it, or maybe surround it with "'". (This is completely untested, and I haven't got a password protected git repository to play around with).

like image 22
Anders Avatar answered Sep 16 '25 08:09

Anders