简体   繁体   English

如何从BitBake食谱中克隆私人git repo?

[英]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. 我对克隆私有git repo的内容感兴趣,因此它们可以被自定义BitBake食谱使用。 I've tried adapting this technique from the Yocto Project mailing lists, and produced the following: 我尝试从Yocto Project邮件列表中采用这种技术 ,并产生了以下内容:

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? 我可以以某种方式转义此特殊字符还是使用其他方式来克隆存储库?

As stated in another comment, you can also use git+ssh: 如另一条评论所述,您还可以使用git + ssh:

SRC_URI = "git://git@some.private.url/path/to/repo;protocol=ssh"

Then you need to add the public key of the user that runs bitbake to the git server. 然后,您需要将运行bitbake的用户的公钥添加到git服务器。 A good way of debugging why a fetch does not work is to actually use ssh -v to connect: 调试为什么提取不起作用的一种好方法是实际使用ssh -v连接:

ssh -v git@some.private.url

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: 例如,要提防git服务器实现(例如GitLab)之间奇怪的路径差异,我们需要使用类似的东西(注意波浪号)来使这些URI在Bitbake和Google Repo中都可以使用:

SRC_URI = "git://git@some.private.url:~/groupname/repo.git;protocol=ssh;branch=${BRANCH}"

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 ; 通常,我使用的是ssh-authentications,因此我只在SRC_URI使用用户名; then ssh-agent takes care of the authenticaton part. 然后ssh-agent负责身份验证部分。 This can rather easily also be set up on an autobuilder. 这也可以很容易地在自动构建器上进行设置。

Another approach would be to add the credentials to .netrc . 另一种方法是将凭据添加到.netrc In this case, add a file .netrc to you home directory, with contents as follows: 在这种情况下,请将文件.netrc添加到您的主目录中,其内容如下:

machine stash1.mycompany.com
login myusername 
password mypassword

This should allow you to omit the username and password from SRC_URI . 这应该允许您从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). (这是完全未经测试的,而且我还没有受密码保护的git存储库可以使用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM