简体   繁体   English

在 Ubuntu 16.04 中使用 bitbake 构建 yocto 时如何使用私有 git repo?

[英]How to use a private git repo while building yocto using bitbake in Ubuntu 16.04?

While using bitbake after configuring , bitbake failed before trying to clone/access a private repository using an SSH link .在配置后使用 bitbake 时,bitbake 在尝试使用 SSH 链接克隆/访问私有存储库之前失败。

$ bitbake linux-imx
git -c core.fsyncobjectfiles=0 ls-remote ssh://git@gitlab.com:~/some-project/some-repo.git
| DEBUG: Python function base_do_fetch finished
| DEBUG: Python function do_fetch finished
| ERROR: Function failed: Fetcher failure: Fetch command failed with exit code 128, output:
| ssh: Could not resolve hostname gitlab.com:~: Name or service not known
| fatal: Could not read from remote repository.
| 
| Please make sure you have the correct access rights
| and the repository exists.
| 
ERROR: Task 4 (/home/user/Projects/some_project/some-project-release-bsp/sources/meta-fsl-bsp-release/imx/meta-bsp/recipes-kernel/linux/linux-imx_4.1.15.bb, do_fetch) failed with exit code '1'

When i try to remove the ~/ from the URL i get a similar error .当我尝试从 URL 中删除~/时,我收到类似的错误。

| DEBUG: Python function base_do_fetch finished
| DEBUG: Python function do_fetch finished
| ERROR: Function failed: Fetcher failure: Fetch command failed with exit code 128, output:
| ssh: Could not resolve hostname gitlab.com:some-project: Name or service not known
| fatal: Could not read from remote repository.

I even tried modifying the URL to https: , on which it gave me another error我什至尝试将 URL 修改为 https: ,它给了我另一个错误

git -c core.fsyncobjectfiles=0 ls-remote http://gitlab.com/some-project/some-repo.git
| DEBUG: Python function base_do_fetch finished
| DEBUG: Python function do_fetch finished
| ERROR: Function failed: Fetcher failure: Fetch command failed with exit code 128, output:
| fatal: could not read Username for 'https://gitlab.com': No such device or address
| 
ERROR: Task 4 (/home/user/Projects/some-project/some-project-release-bsp/sources/meta-fsl-bsp-release/imx/meta-bsp/recipes-kernel/linux/linux-imx_4.1.15.bb, do_fetch) failed with exit code '1'

When i tried the same in the terminal instead of bitbake , It succeeded with the desired output当我在终端中尝试相同而不是 bitbake 时,它​​成功了所需的输出

git -c core.fsyncobjectfiles=0 ls-remote git@gitlab.com:some-project/some-repo.git

I am using Ubuntu 16.04 .我正在使用 Ubuntu 16.04 。 I know that Yocto build is not tested in Ubuntu 16.04 .我知道 Yocto build 未在 Ubuntu 16.04 中进行测试。

WARNING: Host distribution "Ubuntu-16.04" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.

But a previous build with public repositories succeeded .但是以前的公共存储库构建成功了。 So is there a way to make this work ?那么有没有办法使这项工作?

Try using: 尝试使用:

git://git@gitlab.com/some-project/some-repo.git;protocol=‌​ssh;branch=${SRCBRAN‌​CH}

in your SRC_URI. 在您的SRC_URI中。

Note the removal of :~ . 注意删除:~

It is something to do with how Yocto fetch the source code from gitlab . 这与Yocto如何从gitlab获取源代码gitlab No matter the repository is public or private, the git link will not work. 无论存储库是公共的还是私有的,git链接都将不起作用。

I have search a lot but do not find a reason. 我进行了很多搜索,但找不到原因。 So, I had to move my repository to github. 因此,我不得不将存储库移至github。 It will work when it switches to github. 当它切换到github时它将工作。

An alternative way is to fetch your source to local and edit the recipe to source it from there. 另一种方法是将源获取到本地,然后编辑配方以从本地获取源。

What you may want is a deploy token for your gitlab repo.您可能需要的是 gitlab 存储库的部署令牌。 I suspect github has something similar.我怀疑 github 有类似的东西。 https://docs.gitlab.com/ee/user/project/deploy_tokens/ . https://docs.gitlab.com/ee/user/project/deploy_tokens/

Once you have created the token, you will have a token name, such as gitlab+deploy-token-1 and the token itself, which is only displayed upon creation, such as yN_gx3zzrrgqnxzzgsZmqS .创建令牌后,您将拥有一个令牌名称,例如gitlab+deploy-token-1和令牌本身,该名称仅在创建时显示,例如yN_gx3zzrrgqnxzzgsZmqS

Once you a have these values for your token, add it to your SRC_URI as a user:pass like so:一旦您为您的令牌获得了这些值,请将其作为user:pass添加到您的 SRC_URI 中,如下所示:

SRC_URI = "git://gitlab.com/my_username/my_repo.git;protocol=https;user=gitlab+deploy-token-1:yN_gx3zzrrgqnxzzgsZmqS;branch=master"

Note that anyone with access to this recipe will be able to clone your private repo.请注意,任何有权访问此配方的人都可以克隆您的私人存储库。 You can set an expiration date for the token, or manually revoke it at any time.您可以为令牌设置到期日期,也可以随时手动撤销它。

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

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