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

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

配置后使用 bitbake 时,bitbake 在尝试 clone/access 使用 SSH link 私有存储库之前失败。

$ 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'

当我尝试从 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.

我什至尝试将 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'

当我在终端而不是 bitbake 中尝试相同的操作时,它成功获得了所需的输出

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

我正在使用 Ubuntu 16.04。我知道 Yocto 构建未在 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.

但是之前使用 public 个存储库的构建成功了。那么有没有办法让这个工作?

尝试使用:

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

在你的 SRC_URI 中。

注意删除 :~

这与 Yocto 如何从 gitlab 获取源代码有关。无论存储库是 public 还是私有,git link 都不起作用。

找了很多都没有找到原因。因此,我不得不将我的存储库移至 github。它会在切换到 github.

时起作用

另一种方法是将您的来源提取到本地并编辑配方以从那里获取来源。

您可能需要一个用于您的 gitlab 存储库的部署令牌。我怀疑 github 有类似的东西。 https://docs.gitlab.com/ee/user/project/deploy_tokens/.

创建令牌后,您将拥有一个令牌名称,例如 gitlab+deploy-token-1 和令牌本身,仅在创建时显示,例如 yN_gx3zzrrgqnxzzgsZmqS.

一旦您的令牌具有这些值,请将其作为 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"

请注意,有权访问此配方的任何人都可以克隆您的私人存储库。您可以为令牌设置到期日期,或随时手动撤销它。