makefiles/docker.inc.mk: handle building in git worktree [backport 2018.10] #10307
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #10303
Contribution description
When building from a worktree, the common git directory was not mounted in docker.
This lead to the version not being set and issues with git-cache in
ubuntu bionic that could not execute the 'git hash-object' command.
Implementation details
I just test that
.git
is a file starting withgitdir
to know it is in a worktree.Any other solution is welcomed.
I then mounted the whole
--git-common-dir
in the same location.Using the
gitdir
pointed by the.git
file was not enough to make it valid.I aslo tested overwriting the
.git
file with the.git
repository but docker did not allow that.Testing procedure
Original behavior untouched
In a normal repository, no
.git
directory is mounted when building with docker.New behavior
This must be run from a git worktree (replace
riot/master
to the upstream master branch if different)git worktree add ../git_test_worktree riot/master cd ../git_test_worktree
Testing the RIOT_VERSION calculation from git
With
riot/master
we get anUNKNOWN
version, (see the last line).With this PR the version is correctly detected (see the last line).
Testing the behavior with
ubuntu:bionic
docker imageYou must have an initialized git cache
Build a docker image from RIOT-OS/riotdocker#42
I used
docker build . -t riot/bionic
from the repository.Compiling a package using the
bionic
image fails in master asgit hash-object
tries to detect the current directory as a git directory.It works with this PR
Issues/PRs references
The RIOT_VERSION issue was detected in #9645 (comment) and the
git-cache
issue was detected when running Release compilation withbionic
image RIOT-OS/Release-Specs#76 (comment)