I have the following file structure:
----- STRUCTURE
main/
├── recipes/
├── folder1/
├── folder2/
| └── files/
| ├── file1.json
| └── file2.json
└── recipe.bb
----- ORIGINAL_RECIPE
SRC_URI = "<git-repo1>;protocol=ssh;branch=master; \
file://folder2/files
"
SRCREV = "<commit-hash>"
PV = "0.1.2+git${SRCPV}"
recipe.bb does a checkout of a repository into folder1, configures that repo's project and this project uses the *.json files shown there. This currently works, no problem.
Now I want to move everything under and including the files/ folder into a new repository and also do a checkout with bitbake, I have tried the two following methods:
1: Edit the recipe.bb to checkout both repositories and try to use subdir parameter in SRC_URI:
----- STRUCTURE
main/
├── recipes/
├── folder1/
├── folder2/
└── recipe.bb
----- EDITED_RECIPE
SRC_URI = "<git-repo1>;protocol=ssh;branch=master;name=repo1 \
<git-repo2>;protocol=ssh;branch=main;name=repo2;subdir=folder2/ \
"
SRCREV_FORMAT = "repo1_repo2"
SRCREV_repo1 = "<commit-hash>"
SRCREV_repo2 = "<commit-hash>"
PV = "0.1.2+git${SRCPV}"
2 Create a new recipe inside folder2 that only does a checkout of the new repo
----- STRUCTURE
main/
├── recipes/
├── folder1/
├── folder2/
| └── newrecipe.bb
└── recipe.bb
----- NEW_RECIPE
SRC_URI = "<git-repo2>;protocol=ssh;branch=main;"
SRCREV = "<commit-hash>"
PV = "1"
Funny enough, with both approaches I have basically the same result, with a few differences:
Error in approach 1: ERROR: project-0.1.2<git-repo1hash_repo2hash>-r1 do_configure: Execution of '/workdir/../project/0.1.2<git-repo1hash_repo2hash>-r1/temp/run.do_configure.835' failed with exit code 1: CMake Error: The source directory "/workdir/.../project/0.1.2<git-repo1hash_repo2hash>-r1/git" does not appear to contain CMakeLists.txt.
Error in approach 2: ERROR: project-1-r1 do_configure: Execution of '/workdir/.../project/1-r1/temp/run.do_configure.835' failed with exit code 1: CMake Error: The source directory "/workdir/.../project/1-r1/git" does not appear to contain CMakeLists.txt.
The CMake file should come from the original repo1 but for whatever reason it seems to me that the checkout of repo2 after is overwriting repo1. Because when I go into the workdir/.../temp folder, in both approaches, this path contains only what was checked out from repo2, and nothing from repo1.
Maybe I'm going completely wrong about this and there is an actual easy way to achieve what I'm trying to do? Any feedback would be appreciated, thanks!
After much reading, searching and testing I found a way to achieve this, I'm posting my final recipe just in case somebody faces the same use case of checking out multiple repositories, you can use the "destsuffix" parameter in the SRC_URI to achieve this:
----- EDITED_RECIPE
SRC_URI = "git://<git-repo1>;protocol=ssh;branch=master;name=repo1 \
git://<git-repo2>;protocol=ssh;branch=main;name=repo2;destsuffix=files \
"
SRCREV_repo1 = "<commit-hash>"
SRCREV_repo2 = "<commit-hash>"
SRCREV_FORMAT = "repo1_repo2"
PV = "0.1.2+git${SRCPV}"
S = "${WORKDIR}/git"
With this, under WORKDIR there will be:
${WORKDIR}/git <- With the content of git-repo1
and
${WORKDIR}/files <- With the content of git-repo2