[RFC,1/2] dpkg-base: Add new git alternates record instead of replace old one

Message ID 20210812081030.4505-2-ubely@ilbers.de
State RFC
Headers show
Series Fixes for dpkg-gdb packages rebuild | expand

Commit Message

Uladzimir Bely Aug. 12, 2021, 12:10 a.m. UTC
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 <ubely@ilbers.de>
---
 meta/classes/dpkg-base.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Kiszka Aug. 12, 2021, 1 a.m. UTC | #1
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 <ubely@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
Uladzimir Bely Aug. 12, 2021, 1:18 a.m. UTC | #2
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
>
Jan Kiszka Aug. 12, 2021, 1:24 a.m. UTC | #3
On 12.08.21 11:18, Uladzimir Bely wrote:
> 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.
> 

Interesting - it actually failed in the past, not only complained.
Anyway, just sent my patches.

Jan

> четверг, 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
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "isar-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to isar-users+unsubscribe@googlegroups.com
> <mailto:isar-users+unsubscribe@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/isar-users/81c0fa46-a359-47bd-bed7-866671649c96n%40googlegroups.com
> <https://groups.google.com/d/msgid/isar-users/81c0fa46-a359-47bd-bed7-866671649c96n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Patch

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")