Yes, git still shows the message a currently invalid alternate (one of two records), but it's able to work further (reset --hard, etc).

But I can agree that this way could be unacceptable due this error message.

четверг, 12 августа 2021 г. в 12:00:58 UTC+3, Jan Kiszka:
On 12.08.21 10:10, Uladzimir Bely wrote:
> Task adjust_git modifies git alternates by replacing DL_DIR to /downloads.
> New path is used inside buildchroot, so that working git repo
> becomes broken outside buildchroot.
>
> This causes problems with rebuilding such packages as cowsay if something
> has changed in bitbake environment since previous build:
>
> ERROR:
> mc:qemuarm64-buster:cowsay-git-r0 do_patch: Command Error: 'sh -c 'git
> --work-tree=/path/build/tmp/work/debian-buster-arm64/cowsay/git-r0/git
> reset --hard HEAD'' exited with 0
>
> The solution is to add new path to git alternates so that original path
> will work outside buildchroot, and new one will work in buildchroot.
>
> Signed-off-by: Uladzimir Bely <ub...@ilbers.de>
> ---
> meta/classes/dpkg-base.bbclass | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/classes/dpkg-base.bbclass b/meta/classes/dpkg-base.bbclass
> index ec8fbc1..4b9b782 100644
> --- a/meta/classes/dpkg-base.bbclass
> +++ b/meta/classes/dpkg-base.bbclass
> @@ -46,7 +46,7 @@ python do_adjust_git() {
>
> if os.path.exists(alternates):
> cmd = ["sed", "-i", alternates, "-e",
> - "s|{}|/downloads|".format(d.getVar("DL_DIR"))]
> + "s|\({}\(.*\)\)|\\1\\n/downloads\\2|".format(d.getVar("DL_DIR"))]
> bb.note(' '.join(cmd))
> if subprocess.call(cmd) != 0:
> bb.fatal("git alternates adjustment failed")
>

This doesn'tt work, already tried: git fails if just one record is not
working.

Jan

--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux