Skip to contentSkip to conversation

Analysis of build failures

Buildroot Ricardo Martincoski 3 participants 11 messages Jan 23, 2016

lore
Share & tools
lore
#0 lore raw
Quoted 6 lines · Thomas Petazzoni
Quoted 2 lines
        i686 |               libsoil-20080707 | NOK | http://autobuild.buildroot.net/results/8ff91ab8e52000eb34dd8f662520cf1b31490cf5/
      x86_64 |               libsoil-20080707 | NOK | http://autobuild.buildroot.net/results/ea77d6b23aca0cb1cf527e6c16ddf5eba957a69c/

These are really weird. The patch doesn't apply when the build takes place on my build server, but it does apply when I test things locally on my machine. A difference in the version of patch ?

This error occurs when applying a patch that changes a file with spaces in the name.
When applying a patch generated by diff v3.3 (the newest version [2]), the tool patch needs to be version 2.7 or any later to ensure any patch will be applied.
libsoil is the only package today that patches a file with space in the name.

Using patch v2.6:
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 23.
2 out of 2 hunks FAILED -- saving rejects to file 'projects/makefile/alternate Makefile.txt".rej' Patch failed! Please fix 0001-fix-makefile.patch!

Using patch v2.6.1:
can't find file to patch at input line 11
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------

|Various makefile fixes to allow cross compilation
|
|Partly ported from
|http://anonscm.debian.org/cgit/pkg-games/libsoil.git/tree/debian/patches/linking_correctly.patch
|
|Signed-off-by: Bernd Kuhls <[email protected]>
|
|diff -uNr "soil.org/projects/makefile/alternate Makefile.txt" "soil/projects/makefile/alternate Makefile.txt"
|--- "soil.org/projects/makefile/alternate Makefile.txt"	2008-07-07 18:13:28.000000000 +0200
|+++ "soil/projects/makefile/alternate Makefile.txt"	2015-11-07 11:15:04.140106336 +0100

--------------------------
No file to patch. Skipping patch.
2 out of 2 hunks ignored
Patch failed! Please fix 0001-fix-makefile.patch!

The output of "diff -purN" when there are spaces in the name of a changed file depends on the tool version:
diff <= v3.2 does not add double quotes to filenames diff >= v3.3 adds double quotes to filenames

The tool 'patch' can handle patches with spaces in the name of a changed file depending on the tool version:
patch >= 2.5.9 can handle unquoted filenames
patch >= 2.7 can handle both quoted and unquoted filenames

Solution 1: Add patch >= 2.7 as prerequisite to the manual (patch v2.7 is from 2012 [2]).
http://patchwork.ozlabs.org/patch/572097/

Solution 2: Add patch >= 2.5.9 as prerequisite to the manual (patch v2.5.9 is from 2004 [2]), address on the manual
'Format and licensing of the package patches' the workaround needed when a file changed by a patch has spaces in its name, apply the workaround to libsoil (either use diff 3.2 or manually remove the quotes from the filename inside the patch).

Solution 3: Create host-patch. Almost every package would depend on it. I don't known if it would be feasible since gcc has patches.

[1] http://ftp.gnu.org/gnu/diffutils/
[2] http://ftp.gnu.org/gnu/patch/

I didn't investigate other formats of patch, e.g. git patch.

Regards,
Ricardo

#1 lore raw

Ricardo,

First of all, thanks a lot for this great investigation! Definitely very useful!

Quoted 7 lines · Ricardo Martincoski

This error occurs when applying a patch that changes a file with spaces in the name.
When applying a patch generated by diff v3.3 (the newest version [2]), the tool patch needs to be version 2.7 or any later to ensure any patch will be applied.
libsoil is the only package today that patches a file with space in the name.

Aah, this explains the problem. My build server has patch version 2.6.

Quoted 3 lines

Solution 1: Add patch >= 2.7 as prerequisite to the manual (patch v2.7 is from 2012 [2]).
http://patchwork.ozlabs.org/patch/572097/

Not really acceptable, as we want to support old distros. Especially when this is really needed only for one package.

Quoted 6 lines

Solution 2: Add patch >= 2.5.9 as prerequisite to the manual (patch v2.5.9 is from 2004 [2]), address on the manual
'Format and licensing of the package patches' the workaround needed when a file changed by a patch has spaces in its name, apply the workaround to libsoil (either use diff 3.2 or manually remove the quotes from the filename inside the patch).

Seems like the best solution. Can you cook such patches (both to the manual, and the change to libsoil) ?

BTW, why would we need to require patch >= 2.5.9 ? Just to support file name with spaces ?

Quoted 2 lines

Solution 3: Create host-patch. Almost every package would depend on it. I don't known if it would be feasible since gcc has patches.

We only build gcc for the target, so we could certainly build host-patch. However, this really seems overkill to solve the problem of just one package, for which there is a separate solution (your solution 2).

Thanks again for your investigation. I'm looking forward to seeing your patches implementing solution (2).

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw
Quoted 41 lines · Thomas Petazzoni

Ricardo,

First of all, thanks a lot for this great investigation! Definitely very useful!

Quoted 7 lines · Ricardo Martincoski

This error occurs when applying a patch that changes a file with spaces in the name.
When applying a patch generated by diff v3.3 (the newest version [2]), the tool patch needs to be version 2.7 or any later to ensure any patch will be applied.
libsoil is the only package today that patches a file with space in the name.

Aah, this explains the problem. My build server has patch version 2.6.

Quoted 3 lines

Solution 1: Add patch >= 2.7 as prerequisite to the manual (patch v2.7 is from 2012 [2]).
http://patchwork.ozlabs.org/patch/572097/

Not really acceptable, as we want to support old distros. Especially when this is really needed only for one package.

Quoted 6 lines

Solution 2: Add patch >= 2.5.9 as prerequisite to the manual (patch v2.5.9 is from 2004 [2]), address on the manual
'Format and licensing of the package patches' the workaround needed when a file changed by a patch has spaces in its name, apply the workaround to libsoil (either use diff 3.2 or manually remove the quotes from the filename inside the patch).

Seems like the best solution. Can you cook such patches (both to the manual, and the change to libsoil) ?

BTW, why would we need to require patch >= 2.5.9 ? Just to support file name with spaces ?

Quoted 2 lines

Solution 3: Create host-patch. Almost every package would depend on it. I don't known if it would be feasible since gcc has patches.

Quoted 7 lines

We only build gcc for the target, so we could certainly build host-patch. However, this really seems overkill to solve the problem of just one package, for which there is a separate solution (your solution 2).

Thanks again for your investigation. I'm looking forward to seeing your patches implementing solution (2).

What happens if you first make a symlink alternate_makefile -> 'alternate makefile' and apply the patch on the link? Will patch modify the linked file?

If so it could be an alternative solution.

/Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20160123/8eb476c6/attachment.html>

#3 lore raw
Quoted 6 lines · Thomas De Schampheleire

from: Thomas De Schampheleire <[email protected]>
date: Sat, Jan 23 02:03 PM +01:00 2016
to: Thomas Petazzoni <[email protected]>
cc: buildroot at busybox.net, berndkuhls at hotmail.com, Ricardo Martincoski <[email protected]>
subject: Re: [Buildroot] Analysis of build failures

Quoted 26 lines
Quoted 24 lines · Thomas Petazzoni

Ricardo,

First of all, thanks a lot for this great investigation! Definitely very useful!

Quoted 7 lines · Ricardo Martincoski

This error occurs when applying a patch that changes a file with spaces in the name.
When applying a patch generated by diff v3.3 (the newest version [2]), the tool patch needs to be version 2.7 or any later to ensure any patch will be applied.
libsoil is the only package today that patches a file with space in the name.

Aah, this explains the problem. My build server has patch version 2.6.

Quoted 3 lines

Solution 1: Add patch >= 2.7 as prerequisite to the manual (patch v2.7 is from 2012 [2]).
http://patchwork.ozlabs.org/patch/572097/

Not really acceptable, as we want to support old distros. Especially when this is really needed only for one package.

Ok. I changed the state of this patch to Rejected.

Quoted 10 lines
Quoted 10 lines
Quoted 7 lines

Solution 2: Add patch >= 2.5.9 as prerequisite to the manual (patch v2.5.9 is from 2004 [2]), address on the manual
'Format and licensing of the package patches' the workaround needed when a file changed by a patch has spaces in its name, apply the workaround to libsoil (either use diff 3.2 or manually remove the quotes from the filename inside the patch).

Seems like the best solution. Can you cook such patches (both to the manual, and the change to libsoil) ?

Yes. No problem.

Quoted 3 lines
Quoted 3 lines

BTW, why would we need to require patch >= 2.5.9 ? Just to support file name with spaces ?

Yes.

Quoted 9 lines
Quoted 9 lines
Quoted 3 lines

Solution 3: Create host-patch. Almost every package would depend on it. I don't known if it would be feasible since gcc has patches.

We only build gcc for the target, so we could certainly build host-patch. However, this really seems overkill to solve the problem of just one package, for which there is a separate solution (your solution 2).

Quoted 6 lines
Quoted 2 lines

Thanks again for your investigation. I'm looking forward to seeing your patches implementing solution (2).

What happens if you first make a symlink alternate_makefile -> 'alternate makefile' and apply the patch on the link? Will patch modify the linked file?

I tested using patch 2.6.
Unfortunately patch breaks the symlink, so I end up with alternate_makefile patched but 'alternate makefile' remains unpatched.

Quoted 4 lines

If so it could be an alternative solution.

/Thomas

Regards,
Ricardo

#4 lore raw
Quoted 2 lines · Ricardo Martincoski

On Sat, Jan 23, 2016 at 11:03 AM, Thomas De Schampheleire <

Quoted 5 lines · [email protected]> wrote:
Quoted 5 lines

from: Thomas De Schampheleire <[email protected]>
date: Sat, Jan 23 02:03 PM +01:00 2016
to: Thomas Petazzoni <[email protected]>
cc: buildroot at busybox.net, berndkuhls at hotmail.com, Ricardo Martincoski <

[email protected]>

Quoted 5 lines
Quoted 5 lines

subject: Re: [Buildroot] Analysis of build failures

Quoted 1 line · Thomas Petazzoni
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

Ricardo,

First of all, thanks a lot for this great investigation! Definitely very useful!

Quoted 1 line · Ricardo Martincoski

This error occurs when applying a patch that changes a file with

spaces

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

in the name.
When applying a patch generated by diff v3.3 (the newest version

[2]),

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

the tool patch needs to be version 2.7 or any later to ensure any

patch

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

will be applied.
libsoil is the only package today that patches a file with space in

the

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

name.

Aah, this explains the problem. My build server has patch version 2.6.

Quoted 1 line

Solution 1: Add patch >= 2.7 as prerequisite to the manual (patch

v2.7

Quoted 11 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

is from 2012 [2]).
http://patchwork.ozlabs.org/patch/572097/

Not really acceptable, as we want to support old distros. Especially when this is really needed only for one package.

Ok. I changed the state of this patch to Rejected.

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Solution 2: Add patch >= 2.5.9 as prerequisite to the manual (patch v2.5.9 is from 2004 [2]), address on the manual
'Format and licensing of the package patches' the workaround needed

when

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

a file changed by a patch has spaces in its name, apply the

workaround

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

to libsoil (either use diff 3.2 or manually remove the quotes from

the

Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line

filename inside the patch).

Seems like the best solution. Can you cook such patches (both to the manual, and the change to libsoil) ?

Quoted 8 lines

Yes. No problem.

Quoted 3 lines
Quoted 3 lines

BTW, why would we need to require patch >= 2.5.9 ? Just to support file name with spaces ?

Yes.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Solution 3: Create host-patch. Almost every package would depend on

it.

Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 1 line

I don't known if it would be feasible since gcc has patches.

We only build gcc for the target, so we could certainly build host-patch. However, this really seems overkill to solve the problem of just one package, for which there is a separate solution (your solution 2).

Thanks again for your investigation. I'm looking forward to seeing your patches implementing solution (2).

What happens if you first make a symlink alternate_makefile ->

'alternate

Quoted 5 lines
Quoted 2 lines

makefile' and apply the patch on the link? Will patch modify the linked file?

I tested using patch 2.6.
Unfortunately patch breaks the symlink, so I end up with

alternate_makefile

Quoted 1 line

patched but 'alternate makefile' remains unpatched.

I guess a hard link would work here, then. Care to try?

Thanks,
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20160123/b3b10ee8/attachment.html>

#5 lore raw

Thomas,

Quoted 1 line · Thomas De Schampheleire

I guess a hard link would work here, then. Care to try?

But why would we do that? If I understood Ricardo's e-mail, a simple change to the patch (remove the double quotes) would make it just work.

So why are we looking for a complicated solution here ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#6 lore raw
Quoted 3 lines · Thomas Petazzoni
Quoted 1 line · Thomas De Schampheleire

I guess a hard link would work here, then. Care to try?

Between the 2 e-mails I tested using hard link.
Using patch v2.6, the hardlinks get unlinked too.

patch v2.7.1 has --follow-symlinks but its use is discouraged in the man page.

Quoted 5 lines

But why would we do that? If I understood Ricardo's e-mail, a simple change to the patch (remove the double quotes) would make it just work.

So why are we looking for a complicated solution here ?

Just to be clear, removing the double quotes makes it work with patch 2.5.9 or later.
Patch 2.5.4 can't handle spaces in filenames.
(I tested using only the versions with tarballs available, that's the cause of the gap 2.5.9 -> 2.5.4, see http://ftp.gnu.org/gnu/patch/)

I am sending the first version of the patch series.
Probably it will need some rewording, since it's my first patch to the manual.

Regards,
Ricardo

#7 lore raw

Hello,

Quoted 5 lines · Ricardo Martincoski

Just to be clear, removing the double quotes makes it work with patch 2.5.9 or later.
Patch 2.5.4 can't handle spaces in filenames.
(I tested using only the versions with tarballs available, that's the cause of the gap 2.5.9 -> 2.5.4, see http://ftp.gnu.org/gnu/patch/)

RHEL4 uses patch 2.5.4
(http://ftp.redhat.com/pub/redhat/linux/enterprise/4/en/os/i386/SRPMS/).
RHEL4 was released January 2005

RHEL5 also seems to be using patch 2.5.4
(http://ftp.redhat.com/pub/redhat/linux/enterprise/5Client/en/os/SRPMS/).
RHEL5 was released March 2007.

It's only starting at RHEL6 that patch 2.6 starts to be used
(http://ftp.redhat.com/pub/redhat/linux/enterprise/6Client/en/os/SRPMS/).
RHEL6 was released November 2010.

Thomas DS, you are one of our users relying on very old enterprise distros. Are you still on RHEL 4/5 ?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#8 lore raw
Quoted 9 lines · Thomas Petazzoni

Hello,

Quoted 4 lines · Ricardo Martincoski

Just to be clear, removing the double quotes makes it work with patch 2.5.9 or later.
Patch 2.5.4 can't handle spaces in filenames.
(I tested using only the versions with tarballs available, that's the

cause of

Quoted 10 lines
Quoted 1 line

the gap 2.5.9 -> 2.5.4, see http://ftp.gnu.org/gnu/patch/)

RHEL4 uses patch 2.5.4
(http://ftp.redhat.com/pub/redhat/linux/enterprise/4/en/os/i386/SRPMS/).
RHEL4 was released January 2005

RHEL5 also seems to be using patch 2.5.4
(http://ftp.redhat.com/pub/redhat/linux/enterprise/5Client/en/os/SRPMS/).
RHEL5 was released March 2007.

Quoted 6 lines

It's only starting at RHEL6 that patch 2.6 starts to be used
(http://ftp.redhat.com/pub/redhat/linux/enterprise/6Client/en/os/SRPMS/).
RHEL6 was released November 2010.

Thomas DS, you are one of our users relying on very old enterprise distros. Are you still on RHEL 4/5 ?

There are some of our users still on RHEL4 (hopefully not too much anymore) and RHEL5 (not negligible yet).

That said, libsoil is not something we use, so if the problem is limited to that we're fine.

/Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20160123/0bcc064b/attachment.html>

#9 lore raw

Hello,

Quoted 29 lines · Thomas De Schampheleire
Quoted 9 lines · Thomas Petazzoni

Hello,

Quoted 4 lines · Ricardo Martincoski

Just to be clear, removing the double quotes makes it work with patch 2.5.9 or later.
Patch 2.5.4 can't handle spaces in filenames.
(I tested using only the versions with tarballs available, that's the

cause of

Quoted 10 lines
Quoted 1 line

the gap 2.5.9 -> 2.5.4, see http://ftp.gnu.org/gnu/patch/)

RHEL4 uses patch 2.5.4
(http://ftp.redhat.com/pub/redhat/linux/enterprise/4/en/os/i386/SRPMS/).
RHEL4 was released January 2005

RHEL5 also seems to be using patch 2.5.4
(http://ftp.redhat.com/pub/redhat/linux/enterprise/5Client/en/os/SRPMS/).
RHEL5 was released March 2007.

Quoted 6 lines

It's only starting at RHEL6 that patch 2.6 starts to be used
(http://ftp.redhat.com/pub/redhat/linux/enterprise/6Client/en/os/SRPMS/).
RHEL6 was released November 2010.

Thomas DS, you are one of our users relying on very old enterprise distros. Are you still on RHEL 4/5 ?

Quoted 7 lines

There are some of our users still on RHEL4 (hopefully not too much anymore) and RHEL5 (not negligible yet).

That said, libsoil is not something we use, so if the problem is limited to that we're fine.

/Thomas

Maybe there is a solution that does not limit the version of patch, following the idea of symlinks or hardlinks.
It still needs more tests, but it seems to work with patch 2.5.4. I created 2 hooks, one before patching to rename the file, and other after to rename it back.

See example below. I used POST_EXTRACT instead of PRE_PATCH because some developer could use 'make package-extract', create a copy of the extracted directory, edit the needed files and then use diff to create the patch. This way hand-editing the patch would not be needed.

Please let me know if you agree with this approach.

Regards,
Ricardo

libsoil/0001-fix-makefile.patch +3 -3
index 3b80048..310d264 100644
@@ -5,9 +5,9 @@ http://anonscm.debian.org/cgit/pkg-games/libsoil.git/tree/debian/patches/linking
 
 Signed-off-by: Bernd Kuhls <[email protected]>
 
-diff -uNr "soil.org/projects/makefile/alternate Makefile.txt" "soil/projects/makefile/alternate Makefile.txt"
---- "soil.org/projects/makefile/alternate Makefile.txt"	2008-07-07 18:13:28.000000000 +0200
-+++ "soil/projects/makefile/alternate Makefile.txt"	2015-11-07 11:15:04.140106336 +0100
+diff -uNr soil.org/projects/makefile/alternate_Makefile.txt soil/projects/makefile/alternate_Makefile.txt
+--- soil.org/projects/makefile/alternate_Makefile.txt	2008-07-07 18:13:28.000000000 +0200
++++ soil/projects/makefile/alternate_Makefile.txt	2015-11-07 11:15:04.140106336 +0100
 @@ -1,8 +1,8 @@
  MAKE = make
 -CC = gcc
libsoil/libsoil.mk +12 -0
index eb8c2ce..1aca345 100644
@@ -18,6 +18,18 @@ define LIBSOIL_EXTRACT_CMDS
 	mv $(@D)/Simple\ OpenGL\ Image\ Library/* $(@D)
 endef
 
+define REMOVE_SPACE_FROM_FILENAME
+	cd $(@D)/projects/makefile/ && \
+		mv alternate\ Makefile.txt alternate_Makefile.txt
+endef
+LIBSOIL_POST_EXTRACT_HOOKS += REMOVE_SPACE_FROM_FILENAME
+
+define ADD_SPACE_BACK_TO_FILENAME
+	cd $(@D)/projects/makefile/ && \
+		mv alternate_Makefile.txt alternate\ Makefile.txt
+endef
+LIBSOIL_POST_PATCH_HOOKS += ADD_SPACE_BACK_TO_FILENAME
+
 define LIBSOIL_BUILD_CMDS
 	$(MAKE) $(TARGET_CONFIGURE_OPTS) -f $(LIBSOIL_MAKEFILE) \
 		-C $(@D)/src
#10 lore raw

Ricardo,

Quoted 6 lines · Ricardo Martincoski

Maybe there is a solution that does not limit the version of patch, following the idea of symlinks or hardlinks.
It still needs more tests, but it seems to work with patch 2.5.4. I created 2 hooks, one before patching to rename the file, and other after to rename it back.

Quoted 6 lines

See example below. I used POST_EXTRACT instead of PRE_PATCH because some developer could use 'make package-extract', create a copy of the extracted directory, edit the needed files and then use diff to create the patch. This way hand-editing the patch would not be needed.

Please let me know if you agree with this approach.

I think you can remove the post patch hook, i.e keep the file named with the _, and simply adjust:

LIBSOIL_MAKEFILE = "../projects/makefile/alternate Makefile.txt"

to:

LIBSOIL_MAKEFILE = ../projects/makefile/alternate_Makefile.txt

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com