簡體   English   中英

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

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

在配置后使用 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'

當我嘗試從 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 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.

但是以前的公共存儲庫構建成功了。 那么有沒有辦法使這項工作?

嘗試使用:

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

在您的SRC_URI中。

注意刪除:~

這與Yocto如何從gitlab獲取源代碼gitlab 無論存儲庫是公共的還是私有的,git鏈接都將不起作用。

我進行了很多搜索,但找不到原因。 因此,我不得不將存儲庫移至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"

請注意,任何有權訪問此配方的人都可以克隆您的私人存儲庫。 您可以為令牌設置到期日期,也可以隨時手動撤銷它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM