All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] Patching method
@ 2011-04-07  9:32 Ludovic Desroches
  2011-05-18 10:10 ` [Buildroot] [PATCH 1/1] kernel-patch.sh: script changed to support archives in a proper way Ludovic Desroches
  0 siblings, 1 reply; 22+ messages in thread
From: Ludovic Desroches @ 2011-04-07  9:32 UTC (permalink / raw)
  To: buildroot

Hello,

I was building a new file system and I have noticed something about 
patching that seems a little dangerous :

 >>> liblockfile 1.08 Patching package/liblockfile
toolchain/patch-kernel.sh 
/home/ldesroches/buildroot/output/build/liblockfile-1.08 
/home/ldesroches/buildroot/dl liblockfile_1.08-4.debian.tar.bz2

...

+ echo 'Applying liblockfile_1.08-4.debian.tar.bz2 using bzip2: '
Applying liblockfile_1.08-4.debian.tar.bz2 using bzip2:
+ echo liblockfile_1.08-4.debian.tar.bz2
+ cat
+ bunzip2 -dc 
/home/ldesroches/buildroot/dl/liblockfile_1.08-4.debian.tar.bz2
+ patch -p1 -E -d /home/ldesroches/buildroot/output/build/liblockfile-1.08
patching file dotlockfile.c
patching file lockfile.c
missing header for unified diff at line 320 of patch
patching file COPYRIGHT
patching file dotlockfile.1
patching file Makefile.in
patch unexpectedly ends in middle of line

...

As you can see, we have an archive and we don't extract it, we simply 
unzip the compressed file and send the tar file to the patch command. 
The content of this archive is a tree with files and directories (one of 
them is the patch directory) that's why I think this method is a little 
dangerous. The patches are not applied in the same order as defined into 
the series file because the patch order is not kept into the archive.

Am I wrong ? Do you think it can be a problem ?


Regards


Ludovic Desroches

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] kernel-patch.sh: script changed to support archives in a proper way
  2011-04-07  9:32 [Buildroot] Patching method Ludovic Desroches
@ 2011-05-18 10:10 ` Ludovic Desroches
       [not found]   ` <4DDBBB89.2020301@atmel.com>
  2011-06-29  9:12   ` [Buildroot] [RFC PATCH v2]kernel-patch.sh: " ludovic.desroches at atmel.com
  0 siblings, 2 replies; 22+ messages in thread
From: Ludovic Desroches @ 2011-05-18 10:10 UTC (permalink / raw)
  To: buildroot

The previous script doesn't support patching order with archives since
it didn't extract archives but simply decompressed file and piped the
result to the patch command.
This new script extracts archives in a temporary folder and then applies
patches.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 toolchain/patch-kernel.sh |  159 +++++++++++++++++++++++++++++---------------
 1 files changed, 105 insertions(+), 54 deletions(-)

diff --git a/toolchain/patch-kernel.sh b/toolchain/patch-kernel.sh
index 76cb9f7..0492e01 100755
--- a/toolchain/patch-kernel.sh
+++ b/toolchain/patch-kernel.sh
@@ -1,66 +1,117 @@
-#! /bin/bash
-# A little script I whipped up to make it easy to
-# patch source trees and have sane error handling
-# -Erik
-#
-# (c) 2002 Erik Andersen <andersen@codepoet.org>
+#!/bin/bash
 
-# Set directories from arguments, or use defaults.
-targetdir=${1-.}
-patchdir=${2-../kernel-patches}
-shift 2
-patchpattern=${@-*}
+# function apply_patch patch_file
+# this function no more deal with directory case since it is managed
+# in an upper layer
+function apply_patch {
+apply="patch -p1 -E -d"
+#if [ ! -e "${1}" ] ; then
+#	echo "${1} is not a file"
+#	exit 1
+#fi
 
-if [ ! -d "${targetdir}" ] ; then
-    echo "Aborting.  '${targetdir}' is not a directory."
-    exit 1
+case "${1}" in
+*\.tar\.gz$|*\.tgz$|*\.tar\.bz$|*\.tar\.bz2$|*\.tbz$|*\.tbz2$)
+	echo "Error with ${1}";
+	echo "Archives into a directory or another archive is not supported";
+	return 1;
+	;;
+*\.gz$)
+	type="gzip"; uncomp="gunzip -dc"; ;;
+*\.bz$)
+	type="bzip"; uncomp="bunzip -dc"; ;;
+*\.bz2$)
+	type="bzip2"; uncomp="bunzip2 -dc"; ;;
+*\.zip$)
+	type="zip"; uncomp="unzip -d"; ;;
+*\.Z$)
+	type="compress"; uncomp="uncompress -c"; ;;
+*\.diff*)
+	type="diff"; uncomp="cat"; ;;
+*\.patch*)
+	type="patch"; uncomp="cat"; ;;
+*)
+	echo "Unsupported format file for ${1}, skip it";
+	return 0;
+	;;
+esac
+
+echo ""
+echo "Applying ${1} using ${type}: "
+echo ${1} | cat >> ${builddir}/.applied_patches_list
+${uncomp} ${1} | ${apply} ${builddir}
+if [ $? != 0 ] ; then
+	echo "Patch failed! Please fix ${1}!"
+	return 1
 fi
+}
+
+
+# entry point
+builddir=${1}
+patchdir=${2}
+shift 2
+patchlist=${@}
+patchesdir="${builddir}/../$(basename $builddir)-patches"
+
+# check directories
 if [ ! -d "${patchdir}" ] ; then
-    echo "Aborting.  '${patchdir}' is not a directory."
-    exit 1
+	echo "Aborting: ${patchdir} is not a directory."
+	exit 1
 fi
-    
-for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do 
-    apply="patch -p1 -E -d"
-    uncomp_parm=""
-    if [ -d "${patchdir}/$i" ] ; then
-	type="directory overlay"
-	uncomp="tar cf - --exclude=.svn --no-anchored -C"
-	uncomp_parm="."
-	apply="tar xvf - -C"
-    else case "$i" in
-	*.gz)
-	type="gzip"; uncomp="gunzip -dc"; ;; 
-	*.bz)
-	type="bzip"; uncomp="bunzip -dc"; ;; 
-	*.bz2)
-	type="bzip2"; uncomp="bunzip2 -dc"; ;; 
-	*.zip)
-	type="zip"; uncomp="unzip -d"; ;; 
-	*.Z)
-	type="compress"; uncomp="uncompress -c"; ;; 
-	*.tgz)
-	type="tar gzip"; uncomp="gunzip -dc"; apply="tar xvf - -C"; ;; 
-	*.tar)
-	type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;; 
-	*)
-	type="plaintext"; uncomp="cat"; ;; 
-    esac fi
-    echo ""
-    echo "Applying ${i} using ${type}: " 
-	echo ${i} | cat >> ${targetdir}/.applied_patches_list
-    ${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir} 
-    if [ $? != 0 ] ; then
-        echo "Patch failed!  Please fix $i!"
+if [ ! -d "${builddir}" ] ; then
+	echo "Aborting: ${builddir} is not a directory."
 	exit 1
-    fi
+fi
+
+# parse patch list, extract archives, apply patches
+for i in $patchlist ; do
+	# for remote files, directory is buildroot dl dir
+	#if echo $i | grep -q -E "^http://|^ftp://" ; then
+	#	patchdir=$patchdir
+	#else
+	#	patchdir=$(dirname $i)
+	#fi
+	patch_path="${patchdir}/${i}"
+	# three cases: directory, archive, file patch (compressed or not)
+	# directory
+	if [ -d "${patch_path}" ] ; then
+		for p in $(ls ${patch_path}) ; do
+			apply_patch "${patch_path}/${p}" || exit 1
+		done
+	# archive
+	elif echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$|tar\.gz$|tgz$" ; then
+		mkdir "${patchesdir}"
+		# extract archive
+		if echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
+			tar_options="-xjf"
+		else
+			tar_options="-xzf"
+		fi
+		tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
+		# apply patches from the archive
+		#echo ${patchesdir}
+		#find ${patchesdir} | sort
+		for p in $(find ${patchesdir} | sort) ; do
+			apply_patch "${p}" || { rm -rf "${patchesdir}" ; exit 1; }
+		done
+		rm -rf "${patchesdir}"
+	# file which is not an archive
+	else
+		# we can have regex into patch name as package*.patch.arm that's
+		# why using ls
+		for p in $(ls -d ${patch_path} 2> /dev/null) ; do
+			apply_patch "${p}" || exit 1
+		done
+	fi
 done
 
-# Check for rejects...
-if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+# check for rejects...
+if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
     echo "Aborting.  Reject files found."
     exit 1
 fi
 
-# Remove backup files
-find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
+# remove backup files
+find ${builddir}/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
+
-- 
1.7.5

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] kernel-patch.sh: script changed to support archives in a proper way
       [not found]   ` <4DDBBB89.2020301@atmel.com>
@ 2011-05-24 14:25     ` Peter Korsgaard
  2011-05-24 14:50       ` Thomas Petazzoni
  0 siblings, 1 reply; 22+ messages in thread
From: Peter Korsgaard @ 2011-05-24 14:25 UTC (permalink / raw)
  To: buildroot

>>>>> "Nicolas" == Nicolas Ferre <nicolas.ferre@atmel.com> writes:

 Nicolas> Le 18/05/2011 12:10, Ludovic Desroches :
 >> The previous script doesn't support patching order with archives since
 >> it didn't extract archives but simply decompressed file and piped the
 >> result to the patch command.
 >> This new script extracts archives in a temporary folder and then applies
 >> patches.

 Nicolas> Hi guys,

 Nicolas> Any comment on this patch?

Sorry, haven't looked at it yet. We're just about to release
2011.05, and then I'm leaving for 1 week of holiday. I'll take a look
once I'm back.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [PATCH 1/1] kernel-patch.sh: script changed to support archives in a proper way
  2011-05-24 14:25     ` Peter Korsgaard
@ 2011-05-24 14:50       ` Thomas Petazzoni
  0 siblings, 0 replies; 22+ messages in thread
From: Thomas Petazzoni @ 2011-05-24 14:50 UTC (permalink / raw)
  To: buildroot

On Tue, 24 May 2011 16:25:59 +0200
Peter Korsgaard <jacmet@sunsite.dk> wrote:

> Sorry, haven't looked at it yet. We're just about to release
> 2011.05, and then I'm leaving for 1 week of holiday. I'll take a look
> once I'm back.

If I can, I'll try to have a look in the mean time. Sorry for the long
delay in getting back to you, I have been terribly busy the last two
months, and I'm only slowly catching up on Buildroot development.

Regards,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v2]kernel-patch.sh: script changed to support archives in a proper way
  2011-05-18 10:10 ` [Buildroot] [PATCH 1/1] kernel-patch.sh: script changed to support archives in a proper way Ludovic Desroches
       [not found]   ` <4DDBBB89.2020301@atmel.com>
@ 2011-06-29  9:12   ` ludovic.desroches at atmel.com
  2011-06-29  9:12     ` [Buildroot] [RFC PATCH v2 1/1] kernel-patch.sh: " ludovic.desroches at atmel.com
  1 sibling, 1 reply; 22+ messages in thread
From: ludovic.desroches at atmel.com @ 2011-06-29  9:12 UTC (permalink / raw)
  To: buildroot

Hello,

This is the second version of this script. Sadly the first one was not working from a from scrath build ie downloading buildroot source code, patching it andrunning the build. The first patch was tested only with a make clean and the behavior was not the same since filesystem build was ok.

So this new patch has been tested from a clean buildroot directory and corrected the errors of the previous one. It was used to compile the crosstool chain, a root file system and a kernel whose patches were into a tar.gz archive. This last point was the purpose of this patch. Without it, the patches into the archive were not applied in the right order.

I am far to be a bash guru so if you see any improvements please tell me. Thanks.

Regards,

Ludovic

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v2 1/1] kernel-patch.sh: script changed to support archives in a proper way
  2011-06-29  9:12   ` [Buildroot] [RFC PATCH v2]kernel-patch.sh: " ludovic.desroches at atmel.com
@ 2011-06-29  9:12     ` ludovic.desroches at atmel.com
  2011-06-29 10:42       ` Michael S. Zick
  0 siblings, 1 reply; 22+ messages in thread
From: ludovic.desroches at atmel.com @ 2011-06-29  9:12 UTC (permalink / raw)
  To: buildroot

From: Ludovic Desroches <ludovic.desroches@atmel.com>

The previous script doesn't support patching order with archives since
it didn't extract archives but simply decompressed file and piped the
result to the patch command.
This new script extracts archives in a temporary folder and then applies
patches.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 toolchain/patch-kernel.sh |  154 +++++++++++++++++++++++++++++----------------
 1 files changed, 100 insertions(+), 54 deletions(-)

diff --git a/toolchain/patch-kernel.sh b/toolchain/patch-kernel.sh
index 76cb9f7..408a9a7 100755
--- a/toolchain/patch-kernel.sh
+++ b/toolchain/patch-kernel.sh
@@ -1,66 +1,112 @@
-#! /bin/bash
-# A little script I whipped up to make it easy to
-# patch source trees and have sane error handling
-# -Erik
-#
-# (c) 2002 Erik Andersen <andersen@codepoet.org>
+#!/bin/bash
 
-# Set directories from arguments, or use defaults.
-targetdir=${1-.}
-patchdir=${2-../kernel-patches}
-shift 2
-patchpattern=${@-*}
+# function apply_patch patch_file
+# this function no more deal with directory case since it is managed
+# in an upper layer
+function apply_patch {
+apply="patch -p1 -E -d"
 
-if [ ! -d "${targetdir}" ] ; then
-    echo "Aborting.  '${targetdir}' is not a directory."
-    exit 1
+case "${1}" in
+*\.tar\.gz|*\.tgz|*\.tar\.bz|*\.tar\.bz2|*\.tbz|*\.tbz2)
+	echo "Error with ${1}";
+	echo "Archives into a directory or another archive is not supported";
+	return 1;
+	;;
+*\.gz)
+	type="gzip"; uncomp="gunzip -dc"; ;;
+*\.bz)
+	type="bzip"; uncomp="bunzip -dc"; ;;
+*\.bz2)
+	type="bzip2"; uncomp="bunzip2 -dc"; ;;
+*\.zip)
+	type="zip"; uncomp="unzip -d"; ;;
+*\.Z)
+	type="compress"; uncomp="uncompress -c"; ;;
+*\.diff*)
+	type="diff"; uncomp="cat"; ;;
+# '*' at the end is needed for patch.arm for example
+*\.patch*)
+	type="patch"; uncomp="cat"; ;;
+*)
+	echo "Unsupported format file for ${1}, skip it";
+	return 0;
+	;;
+esac
+
+echo ""
+echo "Applying ${1} using ${type}: "
+echo ${1} | cat >> ${builddir}/.applied_patches_list
+${uncomp} ${1} | ${apply} ${builddir}
+if [ $? != 0 ] ; then
+	echo "Patch failed! Please fix ${1}!"
+	return 1
 fi
+}
+
+# entry point
+builddir=${1}
+patchdir=${2}
+shift 2
+patchlist=${@}
+patchesdir="${builddir}/../$(basename $builddir)-patches"
+
+# check directories
 if [ ! -d "${patchdir}" ] ; then
-    echo "Aborting.  '${patchdir}' is not a directory."
-    exit 1
+	echo "Aborting: ${patchdir} is not a directory."
+	exit 1
 fi
-    
-for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do 
-    apply="patch -p1 -E -d"
-    uncomp_parm=""
-    if [ -d "${patchdir}/$i" ] ; then
-	type="directory overlay"
-	uncomp="tar cf - --exclude=.svn --no-anchored -C"
-	uncomp_parm="."
-	apply="tar xvf - -C"
-    else case "$i" in
-	*.gz)
-	type="gzip"; uncomp="gunzip -dc"; ;; 
-	*.bz)
-	type="bzip"; uncomp="bunzip -dc"; ;; 
-	*.bz2)
-	type="bzip2"; uncomp="bunzip2 -dc"; ;; 
-	*.zip)
-	type="zip"; uncomp="unzip -d"; ;; 
-	*.Z)
-	type="compress"; uncomp="uncompress -c"; ;; 
-	*.tgz)
-	type="tar gzip"; uncomp="gunzip -dc"; apply="tar xvf - -C"; ;; 
-	*.tar)
-	type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;; 
-	*)
-	type="plaintext"; uncomp="cat"; ;; 
-    esac fi
-    echo ""
-    echo "Applying ${i} using ${type}: " 
-	echo ${i} | cat >> ${targetdir}/.applied_patches_list
-    ${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir} 
-    if [ $? != 0 ] ; then
-        echo "Patch failed!  Please fix $i!"
+if [ ! -d "${builddir}" ] ; then
+	echo "Aborting: ${builddir} is not a directory."
 	exit 1
-    fi
+fi
+
+# go to the patch directory because $patchlist is interpreted when doing
+# for i in $patchlist
+pushd ${patchdir}
+index=0
+for i in $patchlist ; do
+	patchlist_interpreted[${index}]="$i"
+	index=`expr ${index} + 1`
+	echo patchlist_interpreted[${index}]=$i
 done
+popd
 
-# Check for rejects...
-if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+for index in "${!patchlist_interpreted[@]}" ; do
+	file="${patchlist_interpreted[${index}]}"
+	patch_path="${patchdir}/${file}"
+	# three cases: directory, archive, file patch (compressed or not)
+	# directory
+	if [ -d "${patch_path}" ] ; then
+		for p in $(ls ${patch_path}) ; do
+			apply_patch "${patch_path}/${p}" || exit 1
+		done
+	# archive
+	elif echo $file | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$|tar\.gz$|tgz$" ; then
+		mkdir "${patchesdir}"
+		# extract archive
+		if echo $file | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
+			tar_options="-xjf"
+		else
+			tar_options="-xzf"
+		fi
+		tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
+		# apply patches from the archive
+		for p in $(find ${patchesdir} | sort) ; do
+			apply_patch "${p}" || { rm -rf "${patchesdir}" ; exit 1; }
+		done
+		rm -rf "${patchesdir}"
+	# file which is not an archive
+	else
+		apply_patch "${patch_path}" || exit 1
+	fi
+done
+
+# check for rejects...
+if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
     echo "Aborting.  Reject files found."
     exit 1
 fi
 
-# Remove backup files
-find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
+# remove backup files
+find ${builddir}/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
+
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v2 1/1] kernel-patch.sh: script changed to support archives in a proper way
  2011-06-29  9:12     ` [Buildroot] [RFC PATCH v2 1/1] kernel-patch.sh: " ludovic.desroches at atmel.com
@ 2011-06-29 10:42       ` Michael S. Zick
  2011-06-29 13:21         ` Ludovic Desroches
  2012-01-06 12:47         ` [Buildroot] [RFC PATCH v3]kernel-patch.sh: " ludovic.desroches at atmel.com
  0 siblings, 2 replies; 22+ messages in thread
From: Michael S. Zick @ 2011-06-29 10:42 UTC (permalink / raw)
  To: buildroot

On Wed June 29 2011, ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> The previous script doesn't support patching order with archives since
> it didn't extract archives but simply decompressed file and piped the
> result to the patch command.
> This new script extracts archives in a temporary folder and then applies
> patches.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> ---
>  toolchain/patch-kernel.sh |  154 +++++++++++++++++++++++++++++----------------
>  1 files changed, 100 insertions(+), 54 deletions(-)
> 
> diff --git a/toolchain/patch-kernel.sh b/toolchain/patch-kernel.sh
> index 76cb9f7..408a9a7 100755
> --- a/toolchain/patch-kernel.sh
> +++ b/toolchain/patch-kernel.sh
> @@ -1,66 +1,112 @@
> -#! /bin/bash
> -# A little script I whipped up to make it easy to
> -# patch source trees and have sane error handling
> -# -Erik
> -#
> -# (c) 2002 Erik Andersen <andersen@codepoet.org>
> +#!/bin/bash
>  
> -# Set directories from arguments, or use defaults.
> -targetdir=${1-.}
> -patchdir=${2-../kernel-patches}
> -shift 2
> -patchpattern=${@-*}
> +# function apply_patch patch_file
> +# this function no more deal with directory case since it is managed
> +# in an upper layer
> +function apply_patch {
> +apply="patch -p1 -E -d"
>  
> -if [ ! -d "${targetdir}" ] ; then
> -    echo "Aborting.  '${targetdir}' is not a directory."
> -    exit 1
> +case "${1}" in
> +*\.tar\.gz|*\.tgz|*\.tar\.bz|*\.tar\.bz2|*\.tbz|*\.tbz2)
> +	echo "Error with ${1}";
> +	echo "Archives into a directory or another archive is not supported";
> +	return 1;
> +	;;
> +*\.gz)
> +	type="gzip"; uncomp="gunzip -dc"; ;;
> +*\.bz)
> +	type="bzip"; uncomp="bunzip -dc"; ;;
> +*\.bz2)
> +	type="bzip2"; uncomp="bunzip2 -dc"; ;;
> +*\.zip)
> +	type="zip"; uncomp="unzip -d"; ;;
> +*\.Z)
> +	type="compress"; uncomp="uncompress -c"; ;;
> +*\.diff*)
> +	type="diff"; uncomp="cat"; ;;
> +# '*' at the end is needed for patch.arm for example
> +*\.patch*)
> +	type="patch"; uncomp="cat"; ;;
> +*)
> +	echo "Unsupported format file for ${1}, skip it";
> +	return 0;
> +	;;
> +esac
> +
> +echo ""
> +echo "Applying ${1} using ${type}: "
> +echo ${1} | cat >> ${builddir}/.applied_patches_list
> +${uncomp} ${1} | ${apply} ${builddir}
> +if [ $? != 0 ] ; then
> +	echo "Patch failed! Please fix ${1}!"
> +	return 1
>  fi
> +}
> +
> +# entry point
> +builddir=${1}
> +patchdir=${2}
> +shift 2
> +patchlist=${@}
> +patchesdir="${builddir}/../$(basename $builddir)-patches"
> +
> +# check directories
>  if [ ! -d "${patchdir}" ] ; then
> -    echo "Aborting.  '${patchdir}' is not a directory."
> -    exit 1
> +	echo "Aborting: ${patchdir} is not a directory."
> +	exit 1
>  fi
> -    
> -for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do 
> -    apply="patch -p1 -E -d"
> -    uncomp_parm=""
> -    if [ -d "${patchdir}/$i" ] ; then
> -	type="directory overlay"
> -	uncomp="tar cf - --exclude=.svn --no-anchored -C"
> -	uncomp_parm="."
> -	apply="tar xvf - -C"
> -    else case "$i" in
> -	*.gz)
> -	type="gzip"; uncomp="gunzip -dc"; ;; 
> -	*.bz)
> -	type="bzip"; uncomp="bunzip -dc"; ;; 
> -	*.bz2)
> -	type="bzip2"; uncomp="bunzip2 -dc"; ;; 
> -	*.zip)
> -	type="zip"; uncomp="unzip -d"; ;; 
> -	*.Z)
> -	type="compress"; uncomp="uncompress -c"; ;; 
> -	*.tgz)
> -	type="tar gzip"; uncomp="gunzip -dc"; apply="tar xvf - -C"; ;; 
> -	*.tar)
> -	type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;; 
> -	*)
> -	type="plaintext"; uncomp="cat"; ;; 
> -    esac fi
> -    echo ""
> -    echo "Applying ${i} using ${type}: " 
> -	echo ${i} | cat >> ${targetdir}/.applied_patches_list
> -    ${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir} 
> -    if [ $? != 0 ] ; then
> -        echo "Patch failed!  Please fix $i!"
> +if [ ! -d "${builddir}" ] ; then
> +	echo "Aborting: ${builddir} is not a directory."
>  	exit 1
> -    fi
> +fi
> +
> +# go to the patch directory because $patchlist is interpreted when doing
> +# for i in $patchlist
> +pushd ${patchdir}
> +index=0
> +for i in $patchlist ; do
> +	patchlist_interpreted[${index}]="$i"
> +	index=`expr ${index} + 1`
> +	echo patchlist_interpreted[${index}]=$i
>  done
> +popd
>  
> -# Check for rejects...
> -if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
> +for index in "${!patchlist_interpreted[@]}" ; do
> +	file="${patchlist_interpreted[${index}]}"
> +	patch_path="${patchdir}/${file}"
> +	# three cases: directory, archive, file patch (compressed or not)
> +	# directory
> +	if [ -d "${patch_path}" ] ; then
> +		for p in $(ls ${patch_path}) ; do
> +			apply_patch "${patch_path}/${p}" || exit 1
> +		done
> +	# archive
> +	elif echo $file | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$|tar\.gz$|tgz$" ; then
> +		mkdir "${patchesdir}"
> +		# extract archive
> +		if echo $file | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
> +			tar_options="-xjf"
> +		else
> +			tar_options="-xzf"
> +		fi
> +		tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
> +		# apply patches from the archive
> +		for p in $(find ${patchesdir} | sort) ; do
> +			apply_patch "${p}" || { rm -rf "${patchesdir}" ; exit 1; }
> +		done
> +		rm -rf "${patchesdir}"
> +	# file which is not an archive
> +	else
> +		apply_patch "${patch_path}" || exit 1
> +	fi
> +done
> +
> +# check for rejects...
> +if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
>      echo "Aborting.  Reject files found."
>      exit 1
>  fi
>

It appears on a quick reading that you leave any reject files on the
file system after an attempt to apply patches.

That seems reasonable, presuming that you expect human intervention
to resolve the rejects before continuing.

But what if the second or subsequent attempt to run the patch application,
and there are rejects still on the file system from a prior attempt?
I.E: The previous human intervention did not include deleting the earlier
reject files.  

Wouldn't it make sense to be sure the file system is clean of any reject
files __before__ attempting to run the patch application?
I.E: Only checking afterward does not tell you success/fail of most 
recent attempt because the rejects might have pre-existed the patch attempt.

Mike
> -# Remove backup files
> -find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
> +# remove backup files
> +find ${builddir}/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
> +

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v2 1/1] kernel-patch.sh: script changed to support archives in a proper way
  2011-06-29 10:42       ` Michael S. Zick
@ 2011-06-29 13:21         ` Ludovic Desroches
  2012-01-06 12:47         ` [Buildroot] [RFC PATCH v3]kernel-patch.sh: " ludovic.desroches at atmel.com
  1 sibling, 0 replies; 22+ messages in thread
From: Ludovic Desroches @ 2011-06-29 13:21 UTC (permalink / raw)
  To: buildroot

Hello Michael,

Thanks for your feedback.

On 6/29/2011 12:42 PM, Michael S. Zick wrote:
> On Wed June 29 2011, ludovic.desroches at atmel.com wrote:
>> From: Ludovic Desroches<ludovic.desroches@atmel.com>
>>
>> The previous script doesn't support patching order with archives since
>> it didn't extract archives but simply decompressed file and piped the
>> result to the patch command.
>> This new script extracts archives in a temporary folder and then applies
>> patches.
>>
>> Signed-off-by: Ludovic Desroches<ludovic.desroches@atmel.com>
>> ---
>>   toolchain/patch-kernel.sh |  154 +++++++++++++++++++++++++++++----------------
>>   1 files changed, 100 insertions(+), 54 deletions(-)
>>
>> diff --git a/toolchain/patch-kernel.sh b/toolchain/patch-kernel.sh
>> index 76cb9f7..408a9a7 100755
>> --- a/toolchain/patch-kernel.sh
>> +++ b/toolchain/patch-kernel.sh
>> @@ -1,66 +1,112 @@
>> -#! /bin/bash
>> -# A little script I whipped up to make it easy to
>> -# patch source trees and have sane error handling
>> -# -Erik
>> -#
>> -# (c) 2002 Erik Andersen<andersen@codepoet.org>
>> +#!/bin/bash
>>
>> -# Set directories from arguments, or use defaults.
>> -targetdir=${1-.}
>> -patchdir=${2-../kernel-patches}
>> -shift 2
>> -patchpattern=${@-*}
>> +# function apply_patch patch_file
>> +# this function no more deal with directory case since it is managed
>> +# in an upper layer
>> +function apply_patch {
>> +apply="patch -p1 -E -d"
>>
>> -if [ ! -d "${targetdir}" ] ; then
>> -    echo "Aborting.  '${targetdir}' is not a directory."
>> -    exit 1
>> +case "${1}" in
>> +*\.tar\.gz|*\.tgz|*\.tar\.bz|*\.tar\.bz2|*\.tbz|*\.tbz2)
>> +	echo "Error with ${1}";
>> +	echo "Archives into a directory or another archive is not supported";
>> +	return 1;
>> +	;;
>> +*\.gz)
>> +	type="gzip"; uncomp="gunzip -dc"; ;;
>> +*\.bz)
>> +	type="bzip"; uncomp="bunzip -dc"; ;;
>> +*\.bz2)
>> +	type="bzip2"; uncomp="bunzip2 -dc"; ;;
>> +*\.zip)
>> +	type="zip"; uncomp="unzip -d"; ;;
>> +*\.Z)
>> +	type="compress"; uncomp="uncompress -c"; ;;
>> +*\.diff*)
>> +	type="diff"; uncomp="cat"; ;;
>> +# '*' at the end is needed for patch.arm for example
>> +*\.patch*)
>> +	type="patch"; uncomp="cat"; ;;
>> +*)
>> +	echo "Unsupported format file for ${1}, skip it";
>> +	return 0;
>> +	;;
>> +esac
>> +
>> +echo ""
>> +echo "Applying ${1} using ${type}: "
>> +echo ${1} | cat>>  ${builddir}/.applied_patches_list
>> +${uncomp} ${1} | ${apply} ${builddir}
>> +if [ $? != 0 ] ; then
>> +	echo "Patch failed! Please fix ${1}!"
>> +	return 1
>>   fi
>> +}
>> +
>> +# entry point
>> +builddir=${1}
>> +patchdir=${2}
>> +shift 2
>> +patchlist=${@}
>> +patchesdir="${builddir}/../$(basename $builddir)-patches"
>> +
>> +# check directories
>>   if [ ! -d "${patchdir}" ] ; then
>> -    echo "Aborting.  '${patchdir}' is not a directory."
>> -    exit 1
>> +	echo "Aborting: ${patchdir} is not a directory."
>> +	exit 1
>>   fi
>> -
>> -for i in `cd ${patchdir}; ls -d ${patchpattern} 2>  /dev/null` ; do
>> -    apply="patch -p1 -E -d"
>> -    uncomp_parm=""
>> -    if [ -d "${patchdir}/$i" ] ; then
>> -	type="directory overlay"
>> -	uncomp="tar cf - --exclude=.svn --no-anchored -C"
>> -	uncomp_parm="."
>> -	apply="tar xvf - -C"
>> -    else case "$i" in
>> -	*.gz)
>> -	type="gzip"; uncomp="gunzip -dc"; ;;
>> -	*.bz)
>> -	type="bzip"; uncomp="bunzip -dc"; ;;
>> -	*.bz2)
>> -	type="bzip2"; uncomp="bunzip2 -dc"; ;;
>> -	*.zip)
>> -	type="zip"; uncomp="unzip -d"; ;;
>> -	*.Z)
>> -	type="compress"; uncomp="uncompress -c"; ;;
>> -	*.tgz)
>> -	type="tar gzip"; uncomp="gunzip -dc"; apply="tar xvf - -C"; ;;
>> -	*.tar)
>> -	type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;;
>> -	*)
>> -	type="plaintext"; uncomp="cat"; ;;
>> -    esac fi
>> -    echo ""
>> -    echo "Applying ${i} using ${type}: "
>> -	echo ${i} | cat>>  ${targetdir}/.applied_patches_list
>> -    ${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir}
>> -    if [ $? != 0 ] ; then
>> -        echo "Patch failed!  Please fix $i!"
>> +if [ ! -d "${builddir}" ] ; then
>> +	echo "Aborting: ${builddir} is not a directory."
>>   	exit 1
>> -    fi
>> +fi
>> +
>> +# go to the patch directory because $patchlist is interpreted when doing
>> +# for i in $patchlist
>> +pushd ${patchdir}
>> +index=0
>> +for i in $patchlist ; do
>> +	patchlist_interpreted[${index}]="$i"
>> +	index=`expr ${index} + 1`
>> +	echo patchlist_interpreted[${index}]=$i
>>   done
>> +popd
>>
>> -# Check for rejects...
>> -if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
>> +for index in "${!patchlist_interpreted[@]}" ; do
>> +	file="${patchlist_interpreted[${index}]}"
>> +	patch_path="${patchdir}/${file}"
>> +	# three cases: directory, archive, file patch (compressed or not)
>> +	# directory
>> +	if [ -d "${patch_path}" ] ; then
>> +		for p in $(ls ${patch_path}) ; do
>> +			apply_patch "${patch_path}/${p}" || exit 1
>> +		done
>> +	# archive
>> +	elif echo $file | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$|tar\.gz$|tgz$" ; then
>> +		mkdir "${patchesdir}"
>> +		# extract archive
>> +		if echo $file | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
>> +			tar_options="-xjf"
>> +		else
>> +			tar_options="-xzf"
>> +		fi
>> +		tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
>> +		# apply patches from the archive
>> +		for p in $(find ${patchesdir} | sort) ; do
>> +			apply_patch "${p}" || { rm -rf "${patchesdir}" ; exit 1; }
>> +		done
>> +		rm -rf "${patchesdir}"
>> +	# file which is not an archive
>> +	else
>> +		apply_patch "${patch_path}" || exit 1
>> +	fi
>> +done
>> +
>> +# check for rejects...
>> +if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
>>       echo "Aborting.  Reject files found."
>>       exit 1
>>   fi
>>
> It appears on a quick reading that you leave any reject files on the
> file system after an attempt to apply patches.
>
> That seems reasonable, presuming that you expect human intervention
> to resolve the rejects before continuing.
>
> But what if the second or subsequent attempt to run the patch application,
> and there are rejects still on the file system from a prior attempt?
> I.E: The previous human intervention did not include deleting the earlier
> reject files.
In fact, it was done likte this into the previous script so I was not 
focused on this but you are right: even if the patches are applied 
without errors the filesystem build will be aborted.

>
> Wouldn't it make sense to be sure the file system is clean of any reject
> files __before__ attempting to run the patch application?
> I.E: Only checking afterward does not tell you success/fail of most
> recent attempt because the rejects might have pre-existed the patch attempt.
>
> Mike
I agree, I keep in mind your suggestion for v3 version.

>> -# Remove backup files
>> -find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
>> +# remove backup files
>> +find ${builddir}/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
>> +
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Regards,

Ludovic

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v3]kernel-patch.sh: script changed to support archives in a proper way
  2011-06-29 10:42       ` Michael S. Zick
  2011-06-29 13:21         ` Ludovic Desroches
@ 2012-01-06 12:47         ` ludovic.desroches at atmel.com
  2012-01-06 12:47           ` [Buildroot] [RFC PATCH v3 1/2] apply-patches.sh: " ludovic.desroches at atmel.com
  2012-01-06 12:47           ` [Buildroot] [RFC PATCH v3 " ludovic.desroches at atmel.com
  1 sibling, 2 replies; 22+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-01-06 12:47 UTC (permalink / raw)
  To: buildroot

Hello,

This is an update of the previous patch, it is based on BuildRoot 2011.11.

In addition the presency of rejected files is checked before applying patches.

Regards

Ludovic

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v3 1/2] apply-patches.sh: script changed to support archives in a proper way
  2012-01-06 12:47         ` [Buildroot] [RFC PATCH v3]kernel-patch.sh: " ludovic.desroches at atmel.com
@ 2012-01-06 12:47           ` ludovic.desroches at atmel.com
  2012-01-09  9:45             ` Thomas De Schampheleire
  2012-01-06 12:47           ` [Buildroot] [RFC PATCH v3 " ludovic.desroches at atmel.com
  1 sibling, 1 reply; 22+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-01-06 12:47 UTC (permalink / raw)
  To: buildroot

From: Ludovic Desroches <ludovic.desroches@atmel.com>

The previous script doesn't support patching order with archives since
it didn't extract archives but simply decompressed file and piped the
result to the patch command.
This new script extracts archives in a temporary folder and then applies
patches.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Conflicts:

	support/scripts/apply-patches.sh
---
 support/scripts/apply-patches.sh |  159 +++++++++++++++++++++++++-------------
 1 files changed, 105 insertions(+), 54 deletions(-)

diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
index 1aef47e..0492e01 100755
--- a/support/scripts/apply-patches.sh
+++ b/support/scripts/apply-patches.sh
@@ -1,66 +1,117 @@
-#! /bin/bash
-# A little script I whipped up to make it easy to
-# patch source trees and have sane error handling
-# -Erik
-#
-# (c) 2002 Erik Andersen <andersen@codepoet.org>
+#!/bin/bash
 
-# Set directories from arguments, or use defaults.
-targetdir=${1-.}
-patchdir=${2-../kernel-patches}
-shift 2
-patchpattern=${@-*}
+# function apply_patch patch_file
+# this function no more deal with directory case since it is managed
+# in an upper layer
+function apply_patch {
+apply="patch -p1 -E -d"
+#if [ ! -e "${1}" ] ; then
+#	echo "${1} is not a file"
+#	exit 1
+#fi
 
-if [ ! -d "${targetdir}" ] ; then
-    echo "Aborting.  '${targetdir}' is not a directory."
-    exit 1
+case "${1}" in
+*\.tar\.gz$|*\.tgz$|*\.tar\.bz$|*\.tar\.bz2$|*\.tbz$|*\.tbz2$)
+	echo "Error with ${1}";
+	echo "Archives into a directory or another archive is not supported";
+	return 1;
+	;;
+*\.gz$)
+	type="gzip"; uncomp="gunzip -dc"; ;;
+*\.bz$)
+	type="bzip"; uncomp="bunzip -dc"; ;;
+*\.bz2$)
+	type="bzip2"; uncomp="bunzip2 -dc"; ;;
+*\.zip$)
+	type="zip"; uncomp="unzip -d"; ;;
+*\.Z$)
+	type="compress"; uncomp="uncompress -c"; ;;
+*\.diff*)
+	type="diff"; uncomp="cat"; ;;
+*\.patch*)
+	type="patch"; uncomp="cat"; ;;
+*)
+	echo "Unsupported format file for ${1}, skip it";
+	return 0;
+	;;
+esac
+
+echo ""
+echo "Applying ${1} using ${type}: "
+echo ${1} | cat >> ${builddir}/.applied_patches_list
+${uncomp} ${1} | ${apply} ${builddir}
+if [ $? != 0 ] ; then
+	echo "Patch failed! Please fix ${1}!"
+	return 1
 fi
+}
+
+
+# entry point
+builddir=${1}
+patchdir=${2}
+shift 2
+patchlist=${@}
+patchesdir="${builddir}/../$(basename $builddir)-patches"
+
+# check directories
 if [ ! -d "${patchdir}" ] ; then
-    echo "Aborting.  '${patchdir}' is not a directory."
-    exit 1
+	echo "Aborting: ${patchdir} is not a directory."
+	exit 1
 fi
-    
-for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do 
-    apply="patch -g0 -p1 -E -d"
-    uncomp_parm=""
-    if [ -d "${patchdir}/$i" ] ; then
-	type="directory overlay"
-	uncomp="tar cf - --exclude=.svn --no-anchored -C"
-	uncomp_parm="."
-	apply="tar xvf - -C"
-    else case "$i" in
-	*.gz)
-	type="gzip"; uncomp="gunzip -dc"; ;; 
-	*.bz)
-	type="bzip"; uncomp="bunzip -dc"; ;; 
-	*.bz2)
-	type="bzip2"; uncomp="bunzip2 -dc"; ;; 
-	*.zip)
-	type="zip"; uncomp="unzip -d"; ;; 
-	*.Z)
-	type="compress"; uncomp="uncompress -c"; ;; 
-	*.tgz)
-	type="tar gzip"; uncomp="gunzip -dc"; apply="tar xvf - -C"; ;; 
-	*.tar)
-	type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;; 
-	*)
-	type="plaintext"; uncomp="cat"; ;; 
-    esac fi
-    echo ""
-    echo "Applying ${i} using ${type}: " 
-	echo ${i} | cat >> ${targetdir}/.applied_patches_list
-    ${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir} 
-    if [ $? != 0 ] ; then
-        echo "Patch failed!  Please fix $i!"
+if [ ! -d "${builddir}" ] ; then
+	echo "Aborting: ${builddir} is not a directory."
 	exit 1
-    fi
+fi
+
+# parse patch list, extract archives, apply patches
+for i in $patchlist ; do
+	# for remote files, directory is buildroot dl dir
+	#if echo $i | grep -q -E "^http://|^ftp://" ; then
+	#	patchdir=$patchdir
+	#else
+	#	patchdir=$(dirname $i)
+	#fi
+	patch_path="${patchdir}/${i}"
+	# three cases: directory, archive, file patch (compressed or not)
+	# directory
+	if [ -d "${patch_path}" ] ; then
+		for p in $(ls ${patch_path}) ; do
+			apply_patch "${patch_path}/${p}" || exit 1
+		done
+	# archive
+	elif echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$|tar\.gz$|tgz$" ; then
+		mkdir "${patchesdir}"
+		# extract archive
+		if echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
+			tar_options="-xjf"
+		else
+			tar_options="-xzf"
+		fi
+		tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
+		# apply patches from the archive
+		#echo ${patchesdir}
+		#find ${patchesdir} | sort
+		for p in $(find ${patchesdir} | sort) ; do
+			apply_patch "${p}" || { rm -rf "${patchesdir}" ; exit 1; }
+		done
+		rm -rf "${patchesdir}"
+	# file which is not an archive
+	else
+		# we can have regex into patch name as package*.patch.arm that's
+		# why using ls
+		for p in $(ls -d ${patch_path} 2> /dev/null) ; do
+			apply_patch "${p}" || exit 1
+		done
+	fi
 done
 
-# Check for rejects...
-if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+# check for rejects...
+if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
     echo "Aborting.  Reject files found."
     exit 1
 fi
 
-# Remove backup files
-find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
+# remove backup files
+find ${builddir}/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
+
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v3 2/2] apply-patches.sh check if they are rejects before applying patches
  2012-01-06 12:47         ` [Buildroot] [RFC PATCH v3]kernel-patch.sh: " ludovic.desroches at atmel.com
  2012-01-06 12:47           ` [Buildroot] [RFC PATCH v3 1/2] apply-patches.sh: " ludovic.desroches at atmel.com
@ 2012-01-06 12:47           ` ludovic.desroches at atmel.com
  1 sibling, 0 replies; 22+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-01-06 12:47 UTC (permalink / raw)
  To: buildroot

From: Ludovic Desroches <ludovic.desroches@atmel.com>

If we don't do it, the rejects' check at the end of the script can complain
about rejects not deleted by the user from a previous try.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 support/scripts/apply-patches.sh |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
index 0492e01..4dafacb 100755
--- a/support/scripts/apply-patches.sh
+++ b/support/scripts/apply-patches.sh
@@ -63,6 +63,13 @@ if [ ! -d "${builddir}" ] ; then
 	echo "Aborting: ${builddir} is not a directory."
 	exit 1
 fi
+# check for rejects because if there are some, even if patches are well
+# applied, at the end it will complain about rejects into buildir
+if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+    echo "There are remaining rejecting file into ${buildir}, please delete them"
+    exit 1
+fi
+
 
 # parse patch list, extract archives, apply patches
 for i in $patchlist ; do
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v3 1/2] apply-patches.sh: script changed to support archives in a proper way
  2012-01-06 12:47           ` [Buildroot] [RFC PATCH v3 1/2] apply-patches.sh: " ludovic.desroches at atmel.com
@ 2012-01-09  9:45             ` Thomas De Schampheleire
  2012-01-10 10:31               ` Ludovic Desroches
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas De Schampheleire @ 2012-01-09  9:45 UTC (permalink / raw)
  To: buildroot

On Fri, Jan 6, 2012 at 1:47 PM,  <ludovic.desroches@atmel.com> wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
>
> The previous script doesn't support patching order with archives since
> it didn't extract archives but simply decompressed file and piped the
> result to the patch command.
> This new script extracts archives in a temporary folder and then applies
> patches.
>
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
>
> Conflicts:
>
> ? ? ? ?support/scripts/apply-patches.sh
> ---
> ?support/scripts/apply-patches.sh | ?159 +++++++++++++++++++++++++-------------
> ?1 files changed, 105 insertions(+), 54 deletions(-)
>
> diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
> index 1aef47e..0492e01 100755
> --- a/support/scripts/apply-patches.sh
> +++ b/support/scripts/apply-patches.sh
> @@ -1,66 +1,117 @@
> -#! /bin/bash
> -# A little script I whipped up to make it easy to
> -# patch source trees and have sane error handling
> -# -Erik
> -#
> -# (c) 2002 Erik Andersen <andersen@codepoet.org>
> +#!/bin/bash

I wonder why you removed the original copyright. I'd say you should
keep it, possibly together with a description of the changes and your
name.
Although it may not be the convention of adding explicit copyrights to
scripts in buildroot, removing an existing one seems wrong IMO.

>
> -# Set directories from arguments, or use defaults.
> -targetdir=${1-.}
> -patchdir=${2-../kernel-patches}
> -shift 2
> -patchpattern=${@-*}
> +# function apply_patch patch_file
> +# this function no more deal with directory case since it is managed
> +# in an upper layer
> +function apply_patch {
> +apply="patch -p1 -E -d"
> +#if [ ! -e "${1}" ] ; then
> +# ? ? ?echo "${1} is not a file"
> +# ? ? ?exit 1
> +#fi
>
> -if [ ! -d "${targetdir}" ] ; then
> - ? ?echo "Aborting. ?'${targetdir}' is not a directory."
> - ? ?exit 1
> +case "${1}" in
> +*\.tar\.gz$|*\.tgz$|*\.tar\.bz$|*\.tar\.bz2$|*\.tbz$|*\.tbz2$)
> + ? ? ? echo "Error with ${1}";
> + ? ? ? echo "Archives into a directory or another archive is not supported";
> + ? ? ? return 1;
> + ? ? ? ;;
> +*\.gz$)
> + ? ? ? type="gzip"; uncomp="gunzip -dc"; ;;
> +*\.bz$)
> + ? ? ? type="bzip"; uncomp="bunzip -dc"; ;;
> +*\.bz2$)
> + ? ? ? type="bzip2"; uncomp="bunzip2 -dc"; ;;
> +*\.zip$)
> + ? ? ? type="zip"; uncomp="unzip -d"; ;;
> +*\.Z$)
> + ? ? ? type="compress"; uncomp="uncompress -c"; ;;
> +*\.diff*)
> + ? ? ? type="diff"; uncomp="cat"; ;;
> +*\.patch*)
> + ? ? ? type="patch"; uncomp="cat"; ;;
> +*)
> + ? ? ? echo "Unsupported format file for ${1}, skip it";
> + ? ? ? return 0;
> + ? ? ? ;;
> +esac
> +
> +echo ""
> +echo "Applying ${1} using ${type}: "
> +echo ${1} | cat >> ${builddir}/.applied_patches_list
> +${uncomp} ${1} | ${apply} ${builddir}
> +if [ $? != 0 ] ; then
> + ? ? ? echo "Patch failed! Please fix ${1}!"
> + ? ? ? return 1
> ?fi
> +}
> +
> +
> +# entry point
> +builddir=${1}
> +patchdir=${2}
> +shift 2
> +patchlist=${@}
> +patchesdir="${builddir}/../$(basename $builddir)-patches"
> +
> +# check directories
> ?if [ ! -d "${patchdir}" ] ; then
> - ? ?echo "Aborting. ?'${patchdir}' is not a directory."
> - ? ?exit 1
> + ? ? ? echo "Aborting: ${patchdir} is not a directory."
> + ? ? ? exit 1
> ?fi
> -
> -for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
> - ? ?apply="patch -g0 -p1 -E -d"
> - ? ?uncomp_parm=""
> - ? ?if [ -d "${patchdir}/$i" ] ; then
> - ? ? ? type="directory overlay"
> - ? ? ? uncomp="tar cf - --exclude=.svn --no-anchored -C"
> - ? ? ? uncomp_parm="."
> - ? ? ? apply="tar xvf - -C"
> - ? ?else case "$i" in
> - ? ? ? *.gz)
> - ? ? ? type="gzip"; uncomp="gunzip -dc"; ;;
> - ? ? ? *.bz)
> - ? ? ? type="bzip"; uncomp="bunzip -dc"; ;;
> - ? ? ? *.bz2)
> - ? ? ? type="bzip2"; uncomp="bunzip2 -dc"; ;;
> - ? ? ? *.zip)
> - ? ? ? type="zip"; uncomp="unzip -d"; ;;
> - ? ? ? *.Z)
> - ? ? ? type="compress"; uncomp="uncompress -c"; ;;
> - ? ? ? *.tgz)
> - ? ? ? type="tar gzip"; uncomp="gunzip -dc"; apply="tar xvf - -C"; ;;
> - ? ? ? *.tar)
> - ? ? ? type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;;
> - ? ? ? *)
> - ? ? ? type="plaintext"; uncomp="cat"; ;;
> - ? ?esac fi
> - ? ?echo ""
> - ? ?echo "Applying ${i} using ${type}: "
> - ? ? ? echo ${i} | cat >> ${targetdir}/.applied_patches_list
> - ? ?${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir}
> - ? ?if [ $? != 0 ] ; then
> - ? ? ? ?echo "Patch failed! ?Please fix $i!"
> +if [ ! -d "${builddir}" ] ; then
> + ? ? ? echo "Aborting: ${builddir} is not a directory."
> ? ? ? ?exit 1
> - ? ?fi
> +fi
> +
> +# parse patch list, extract archives, apply patches
> +for i in $patchlist ; do
> + ? ? ? # for remote files, directory is buildroot dl dir
> + ? ? ? #if echo $i | grep -q -E "^http://|^ftp://" ; then
> + ? ? ? # ? ? ? patchdir=$patchdir
> + ? ? ? #else
> + ? ? ? # ? ? ? patchdir=$(dirname $i)
> + ? ? ? #fi
> + ? ? ? patch_path="${patchdir}/${i}"
> + ? ? ? # three cases: directory, archive, file patch (compressed or not)
> + ? ? ? # directory
> + ? ? ? if [ -d "${patch_path}" ] ; then
> + ? ? ? ? ? ? ? for p in $(ls ${patch_path}) ; do
> + ? ? ? ? ? ? ? ? ? ? ? apply_patch "${patch_path}/${p}" || exit 1
> + ? ? ? ? ? ? ? done
> + ? ? ? # archive
> + ? ? ? elif echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$|tar\.gz$|tgz$" ; then
> + ? ? ? ? ? ? ? mkdir "${patchesdir}"
> + ? ? ? ? ? ? ? # extract archive
> + ? ? ? ? ? ? ? if echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
> + ? ? ? ? ? ? ? ? ? ? ? tar_options="-xjf"
> + ? ? ? ? ? ? ? else
> + ? ? ? ? ? ? ? ? ? ? ? tar_options="-xzf"
> + ? ? ? ? ? ? ? fi
> + ? ? ? ? ? ? ? tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
> + ? ? ? ? ? ? ? # apply patches from the archive
> + ? ? ? ? ? ? ? #echo ${patchesdir}
> + ? ? ? ? ? ? ? #find ${patchesdir} | sort
> + ? ? ? ? ? ? ? for p in $(find ${patchesdir} | sort) ; do
> + ? ? ? ? ? ? ? ? ? ? ? apply_patch "${p}" || { rm -rf "${patchesdir}" ; exit 1; }
> + ? ? ? ? ? ? ? done
> + ? ? ? ? ? ? ? rm -rf "${patchesdir}"
> + ? ? ? # file which is not an archive
> + ? ? ? else
> + ? ? ? ? ? ? ? # we can have regex into patch name as package*.patch.arm that's
> + ? ? ? ? ? ? ? # why using ls
> + ? ? ? ? ? ? ? for p in $(ls -d ${patch_path} 2> /dev/null) ; do
> + ? ? ? ? ? ? ? ? ? ? ? apply_patch "${p}" || exit 1
> + ? ? ? ? ? ? ? done
> + ? ? ? fi
> ?done
>
> -# Check for rejects...
> -if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
> +# check for rejects...
> +if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
> ? ? echo "Aborting. ?Reject files found."
> ? ? exit 1
> ?fi
>
> -# Remove backup files
> -find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
> +# remove backup files
> +find ${builddir}/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
> +
> --
> 1.7.5.4
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v3 1/2] apply-patches.sh: script changed to support archives in a proper way
  2012-01-09  9:45             ` Thomas De Schampheleire
@ 2012-01-10 10:31               ` Ludovic Desroches
  2012-01-10 11:46                 ` Thomas De Schampheleire
  0 siblings, 1 reply; 22+ messages in thread
From: Ludovic Desroches @ 2012-01-10 10:31 UTC (permalink / raw)
  To: buildroot

On Mon, Jan 09, 2012 at 10:45:51AM +0100, Thomas De Schampheleire wrote:
> On Fri, Jan 6, 2012 at 1:47 PM,  <ludovic.desroches@atmel.com> wrote:
> > From: Ludovic Desroches <ludovic.desroches@atmel.com>
> >
> > The previous script doesn't support patching order with archives since
> > it didn't extract archives but simply decompressed file and piped the
> > result to the patch command.
> > This new script extracts archives in a temporary folder and then applies
> > patches.
> >
> > Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> >
> > Conflicts:
> >
> > ? ? ? ?support/scripts/apply-patches.sh
> > ---
> > ?support/scripts/apply-patches.sh | ?159 +++++++++++++++++++++++++-------------
> > ?1 files changed, 105 insertions(+), 54 deletions(-)
> >
> > diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
> > index 1aef47e..0492e01 100755
> > --- a/support/scripts/apply-patches.sh
> > +++ b/support/scripts/apply-patches.sh
> > @@ -1,66 +1,117 @@
> > -#! /bin/bash
> > -# A little script I whipped up to make it easy to
> > -# patch source trees and have sane error handling
> > -# -Erik
> > -#
> > -# (c) 2002 Erik Andersen <andersen@codepoet.org>
> > +#!/bin/bash
> 
> I wonder why you removed the original copyright. I'd say you should
> keep it, possibly together with a description of the changes and your
> name.
> Although it may not be the convention of adding explicit copyrights to
> scripts in buildroot, removing an existing one seems wrong IMO.
> 

I removed it because I see it as a new script. The major part of the script
has changed, I mainly kept the switch case but with some changes too.

Anyway it's not a problem for me to keep this copyright if needed.

> >
> > -# Set directories from arguments, or use defaults.
> > -targetdir=${1-.}
> > -patchdir=${2-../kernel-patches}
> > -shift 2
> > -patchpattern=${@-*}
> > +# function apply_patch patch_file
> > +# this function no more deal with directory case since it is managed
> > +# in an upper layer
> > +function apply_patch {
> > +apply="patch -p1 -E -d"
> > +#if [ ! -e "${1}" ] ; then
> > +# ? ? ?echo "${1} is not a file"
> > +# ? ? ?exit 1
> > +#fi
> >
> > -if [ ! -d "${targetdir}" ] ; then
> > - ? ?echo "Aborting. ?'${targetdir}' is not a directory."
> > - ? ?exit 1
> > +case "${1}" in
> > +*\.tar\.gz$|*\.tgz$|*\.tar\.bz$|*\.tar\.bz2$|*\.tbz$|*\.tbz2$)
> > + ? ? ? echo "Error with ${1}";
> > + ? ? ? echo "Archives into a directory or another archive is not supported";
> > + ? ? ? return 1;
> > + ? ? ? ;;
> > +*\.gz$)
> > + ? ? ? type="gzip"; uncomp="gunzip -dc"; ;;
> > +*\.bz$)
> > + ? ? ? type="bzip"; uncomp="bunzip -dc"; ;;
> > +*\.bz2$)
> > + ? ? ? type="bzip2"; uncomp="bunzip2 -dc"; ;;
> > +*\.zip$)
> > + ? ? ? type="zip"; uncomp="unzip -d"; ;;
> > +*\.Z$)
> > + ? ? ? type="compress"; uncomp="uncompress -c"; ;;
> > +*\.diff*)
> > + ? ? ? type="diff"; uncomp="cat"; ;;
> > +*\.patch*)
> > + ? ? ? type="patch"; uncomp="cat"; ;;
> > +*)
> > + ? ? ? echo "Unsupported format file for ${1}, skip it";
> > + ? ? ? return 0;
> > + ? ? ? ;;
> > +esac
> > +
> > +echo ""
> > +echo "Applying ${1} using ${type}: "
> > +echo ${1} | cat >> ${builddir}/.applied_patches_list
> > +${uncomp} ${1} | ${apply} ${builddir}
> > +if [ $? != 0 ] ; then
> > + ? ? ? echo "Patch failed! Please fix ${1}!"
> > + ? ? ? return 1
> > ?fi
> > +}
> > +
> > +
> > +# entry point
> > +builddir=${1}
> > +patchdir=${2}
> > +shift 2
> > +patchlist=${@}
> > +patchesdir="${builddir}/../$(basename $builddir)-patches"
> > +
> > +# check directories
> > ?if [ ! -d "${patchdir}" ] ; then
> > - ? ?echo "Aborting. ?'${patchdir}' is not a directory."
> > - ? ?exit 1
> > + ? ? ? echo "Aborting: ${patchdir} is not a directory."
> > + ? ? ? exit 1
> > ?fi
> > -
> > -for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
> > - ? ?apply="patch -g0 -p1 -E -d"
> > - ? ?uncomp_parm=""
> > - ? ?if [ -d "${patchdir}/$i" ] ; then
> > - ? ? ? type="directory overlay"
> > - ? ? ? uncomp="tar cf - --exclude=.svn --no-anchored -C"
> > - ? ? ? uncomp_parm="."
> > - ? ? ? apply="tar xvf - -C"
> > - ? ?else case "$i" in
> > - ? ? ? *.gz)
> > - ? ? ? type="gzip"; uncomp="gunzip -dc"; ;;
> > - ? ? ? *.bz)
> > - ? ? ? type="bzip"; uncomp="bunzip -dc"; ;;
> > - ? ? ? *.bz2)
> > - ? ? ? type="bzip2"; uncomp="bunzip2 -dc"; ;;
> > - ? ? ? *.zip)
> > - ? ? ? type="zip"; uncomp="unzip -d"; ;;
> > - ? ? ? *.Z)
> > - ? ? ? type="compress"; uncomp="uncompress -c"; ;;
> > - ? ? ? *.tgz)
> > - ? ? ? type="tar gzip"; uncomp="gunzip -dc"; apply="tar xvf - -C"; ;;
> > - ? ? ? *.tar)
> > - ? ? ? type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;;
> > - ? ? ? *)
> > - ? ? ? type="plaintext"; uncomp="cat"; ;;
> > - ? ?esac fi
> > - ? ?echo ""
> > - ? ?echo "Applying ${i} using ${type}: "
> > - ? ? ? echo ${i} | cat >> ${targetdir}/.applied_patches_list
> > - ? ?${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir}
> > - ? ?if [ $? != 0 ] ; then
> > - ? ? ? ?echo "Patch failed! ?Please fix $i!"
> > +if [ ! -d "${builddir}" ] ; then
> > + ? ? ? echo "Aborting: ${builddir} is not a directory."
> > ? ? ? ?exit 1
> > - ? ?fi
> > +fi
> > +
> > +# parse patch list, extract archives, apply patches
> > +for i in $patchlist ; do
> > + ? ? ? # for remote files, directory is buildroot dl dir
> > + ? ? ? #if echo $i | grep -q -E "^http://|^ftp://" ; then
> > + ? ? ? # ? ? ? patchdir=$patchdir
> > + ? ? ? #else
> > + ? ? ? # ? ? ? patchdir=$(dirname $i)
> > + ? ? ? #fi
> > + ? ? ? patch_path="${patchdir}/${i}"
> > + ? ? ? # three cases: directory, archive, file patch (compressed or not)
> > + ? ? ? # directory
> > + ? ? ? if [ -d "${patch_path}" ] ; then
> > + ? ? ? ? ? ? ? for p in $(ls ${patch_path}) ; do
> > + ? ? ? ? ? ? ? ? ? ? ? apply_patch "${patch_path}/${p}" || exit 1
> > + ? ? ? ? ? ? ? done
> > + ? ? ? # archive
> > + ? ? ? elif echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$|tar\.gz$|tgz$" ; then
> > + ? ? ? ? ? ? ? mkdir "${patchesdir}"
> > + ? ? ? ? ? ? ? # extract archive
> > + ? ? ? ? ? ? ? if echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
> > + ? ? ? ? ? ? ? ? ? ? ? tar_options="-xjf"
> > + ? ? ? ? ? ? ? else
> > + ? ? ? ? ? ? ? ? ? ? ? tar_options="-xzf"
> > + ? ? ? ? ? ? ? fi
> > + ? ? ? ? ? ? ? tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
> > + ? ? ? ? ? ? ? # apply patches from the archive
> > + ? ? ? ? ? ? ? #echo ${patchesdir}
> > + ? ? ? ? ? ? ? #find ${patchesdir} | sort
> > + ? ? ? ? ? ? ? for p in $(find ${patchesdir} | sort) ; do
> > + ? ? ? ? ? ? ? ? ? ? ? apply_patch "${p}" || { rm -rf "${patchesdir}" ; exit 1; }
> > + ? ? ? ? ? ? ? done
> > + ? ? ? ? ? ? ? rm -rf "${patchesdir}"
> > + ? ? ? # file which is not an archive
> > + ? ? ? else
> > + ? ? ? ? ? ? ? # we can have regex into patch name as package*.patch.arm that's
> > + ? ? ? ? ? ? ? # why using ls
> > + ? ? ? ? ? ? ? for p in $(ls -d ${patch_path} 2> /dev/null) ; do
> > + ? ? ? ? ? ? ? ? ? ? ? apply_patch "${p}" || exit 1
> > + ? ? ? ? ? ? ? done
> > + ? ? ? fi
> > ?done
> >
> > -# Check for rejects...
> > -if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
> > +# check for rejects...
> > +if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
> > ? ? echo "Aborting. ?Reject files found."
> > ? ? exit 1
> > ?fi
> >
> > -# Remove backup files
> > -find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
> > +# remove backup files
> > +find ${builddir}/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
> > +
> > --
> > 1.7.5.4
> >
> > _______________________________________________
> > buildroot mailing list
> > buildroot at busybox.net
> > http://lists.busybox.net/mailman/listinfo/buildroot
> 

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v3 1/2] apply-patches.sh: script changed to support archives in a proper way
  2012-01-10 10:31               ` Ludovic Desroches
@ 2012-01-10 11:46                 ` Thomas De Schampheleire
  2012-01-10 18:01                   ` [Buildroot] [RFC PATCH v4]kernel-patch.sh: " ludovic.desroches at atmel.com
  0 siblings, 1 reply; 22+ messages in thread
From: Thomas De Schampheleire @ 2012-01-10 11:46 UTC (permalink / raw)
  To: buildroot

On Tue, Jan 10, 2012 at 11:31 AM, Ludovic Desroches
<ludovic.desroches@atmel.com> wrote:
> On Mon, Jan 09, 2012 at 10:45:51AM +0100, Thomas De Schampheleire wrote:
>> On Fri, Jan 6, 2012 at 1:47 PM, ?<ludovic.desroches@atmel.com> wrote:
>> > From: Ludovic Desroches <ludovic.desroches@atmel.com>
>> >
>> > The previous script doesn't support patching order with archives since
>> > it didn't extract archives but simply decompressed file and piped the
>> > result to the patch command.
>> > This new script extracts archives in a temporary folder and then applies
>> > patches.
>> >
>> > Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
>> >
>> > Conflicts:
>> >
>> > ? ? ? ?support/scripts/apply-patches.sh
>> > ---
>> > ?support/scripts/apply-patches.sh | ?159 +++++++++++++++++++++++++-------------
>> > ?1 files changed, 105 insertions(+), 54 deletions(-)
>> >
>> > diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
>> > index 1aef47e..0492e01 100755
>> > --- a/support/scripts/apply-patches.sh
>> > +++ b/support/scripts/apply-patches.sh
>> > @@ -1,66 +1,117 @@
>> > -#! /bin/bash
>> > -# A little script I whipped up to make it easy to
>> > -# patch source trees and have sane error handling
>> > -# -Erik
>> > -#
>> > -# (c) 2002 Erik Andersen <andersen@codepoet.org>
>> > +#!/bin/bash
>>
>> I wonder why you removed the original copyright. I'd say you should
>> keep it, possibly together with a description of the changes and your
>> name.
>> Although it may not be the convention of adding explicit copyrights to
>> scripts in buildroot, removing an existing one seems wrong IMO.
>>
>
> I removed it because I see it as a new script. The major part of the script
> has changed, I mainly kept the switch case but with some changes too.

If I compare the original and the adapted script, I feel that the
original code continues to live in the new one. As you say, the switch
statement, but also the code that applies the patches below the
switch, the checking for rejects, and the removal of backup files.

So, the way I see it, you improved and extended the script, but did
not rewrite it from scratch.

>
> Anyway it's not a problem for me to keep this copyright if needed.
>
>> >
>> > -# Set directories from arguments, or use defaults.
>> > -targetdir=${1-.}
>> > -patchdir=${2-../kernel-patches}
>> > -shift 2
>> > -patchpattern=${@-*}
>> > +# function apply_patch patch_file
>> > +# this function no more deal with directory case since it is managed
>> > +# in an upper layer
>> > +function apply_patch {
>> > +apply="patch -p1 -E -d"
>> > +#if [ ! -e "${1}" ] ; then
>> > +# ? ? ?echo "${1} is not a file"
>> > +# ? ? ?exit 1
>> > +#fi
>> >
>> > -if [ ! -d "${targetdir}" ] ; then
>> > - ? ?echo "Aborting. ?'${targetdir}' is not a directory."
>> > - ? ?exit 1
>> > +case "${1}" in
>> > +*\.tar\.gz$|*\.tgz$|*\.tar\.bz$|*\.tar\.bz2$|*\.tbz$|*\.tbz2$)
>> > + ? ? ? echo "Error with ${1}";
>> > + ? ? ? echo "Archives into a directory or another archive is not supported";
>> > + ? ? ? return 1;
>> > + ? ? ? ;;
>> > +*\.gz$)
>> > + ? ? ? type="gzip"; uncomp="gunzip -dc"; ;;
>> > +*\.bz$)
>> > + ? ? ? type="bzip"; uncomp="bunzip -dc"; ;;
>> > +*\.bz2$)
>> > + ? ? ? type="bzip2"; uncomp="bunzip2 -dc"; ;;
>> > +*\.zip$)
>> > + ? ? ? type="zip"; uncomp="unzip -d"; ;;
>> > +*\.Z$)
>> > + ? ? ? type="compress"; uncomp="uncompress -c"; ;;
>> > +*\.diff*)
>> > + ? ? ? type="diff"; uncomp="cat"; ;;
>> > +*\.patch*)
>> > + ? ? ? type="patch"; uncomp="cat"; ;;
>> > +*)
>> > + ? ? ? echo "Unsupported format file for ${1}, skip it";
>> > + ? ? ? return 0;
>> > + ? ? ? ;;
>> > +esac
>> > +
>> > +echo ""
>> > +echo "Applying ${1} using ${type}: "
>> > +echo ${1} | cat >> ${builddir}/.applied_patches_list
>> > +${uncomp} ${1} | ${apply} ${builddir}
>> > +if [ $? != 0 ] ; then
>> > + ? ? ? echo "Patch failed! Please fix ${1}!"
>> > + ? ? ? return 1
>> > ?fi
>> > +}
>> > +
>> > +
>> > +# entry point
>> > +builddir=${1}
>> > +patchdir=${2}
>> > +shift 2
>> > +patchlist=${@}
>> > +patchesdir="${builddir}/../$(basename $builddir)-patches"
>> > +
>> > +# check directories
>> > ?if [ ! -d "${patchdir}" ] ; then
>> > - ? ?echo "Aborting. ?'${patchdir}' is not a directory."
>> > - ? ?exit 1
>> > + ? ? ? echo "Aborting: ${patchdir} is not a directory."
>> > + ? ? ? exit 1
>> > ?fi
>> > -
>> > -for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
>> > - ? ?apply="patch -g0 -p1 -E -d"
>> > - ? ?uncomp_parm=""
>> > - ? ?if [ -d "${patchdir}/$i" ] ; then
>> > - ? ? ? type="directory overlay"
>> > - ? ? ? uncomp="tar cf - --exclude=.svn --no-anchored -C"
>> > - ? ? ? uncomp_parm="."
>> > - ? ? ? apply="tar xvf - -C"
>> > - ? ?else case "$i" in
>> > - ? ? ? *.gz)
>> > - ? ? ? type="gzip"; uncomp="gunzip -dc"; ;;
>> > - ? ? ? *.bz)
>> > - ? ? ? type="bzip"; uncomp="bunzip -dc"; ;;
>> > - ? ? ? *.bz2)
>> > - ? ? ? type="bzip2"; uncomp="bunzip2 -dc"; ;;
>> > - ? ? ? *.zip)
>> > - ? ? ? type="zip"; uncomp="unzip -d"; ;;
>> > - ? ? ? *.Z)
>> > - ? ? ? type="compress"; uncomp="uncompress -c"; ;;
>> > - ? ? ? *.tgz)
>> > - ? ? ? type="tar gzip"; uncomp="gunzip -dc"; apply="tar xvf - -C"; ;;
>> > - ? ? ? *.tar)
>> > - ? ? ? type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;;
>> > - ? ? ? *)
>> > - ? ? ? type="plaintext"; uncomp="cat"; ;;
>> > - ? ?esac fi
>> > - ? ?echo ""
>> > - ? ?echo "Applying ${i} using ${type}: "
>> > - ? ? ? echo ${i} | cat >> ${targetdir}/.applied_patches_list
>> > - ? ?${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir}
>> > - ? ?if [ $? != 0 ] ; then
>> > - ? ? ? ?echo "Patch failed! ?Please fix $i!"
>> > +if [ ! -d "${builddir}" ] ; then
>> > + ? ? ? echo "Aborting: ${builddir} is not a directory."
>> > ? ? ? ?exit 1
>> > - ? ?fi
>> > +fi
>> > +
>> > +# parse patch list, extract archives, apply patches
>> > +for i in $patchlist ; do
>> > + ? ? ? # for remote files, directory is buildroot dl dir
>> > + ? ? ? #if echo $i | grep -q -E "^http://|^ftp://" ; then
>> > + ? ? ? # ? ? ? patchdir=$patchdir
>> > + ? ? ? #else
>> > + ? ? ? # ? ? ? patchdir=$(dirname $i)
>> > + ? ? ? #fi
>> > + ? ? ? patch_path="${patchdir}/${i}"
>> > + ? ? ? # three cases: directory, archive, file patch (compressed or not)
>> > + ? ? ? # directory
>> > + ? ? ? if [ -d "${patch_path}" ] ; then
>> > + ? ? ? ? ? ? ? for p in $(ls ${patch_path}) ; do
>> > + ? ? ? ? ? ? ? ? ? ? ? apply_patch "${patch_path}/${p}" || exit 1
>> > + ? ? ? ? ? ? ? done
>> > + ? ? ? # archive
>> > + ? ? ? elif echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$|tar\.gz$|tgz$" ; then
>> > + ? ? ? ? ? ? ? mkdir "${patchesdir}"
>> > + ? ? ? ? ? ? ? # extract archive
>> > + ? ? ? ? ? ? ? if echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
>> > + ? ? ? ? ? ? ? ? ? ? ? tar_options="-xjf"
>> > + ? ? ? ? ? ? ? else
>> > + ? ? ? ? ? ? ? ? ? ? ? tar_options="-xzf"
>> > + ? ? ? ? ? ? ? fi
>> > + ? ? ? ? ? ? ? tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
>> > + ? ? ? ? ? ? ? # apply patches from the archive
>> > + ? ? ? ? ? ? ? #echo ${patchesdir}
>> > + ? ? ? ? ? ? ? #find ${patchesdir} | sort
>> > + ? ? ? ? ? ? ? for p in $(find ${patchesdir} | sort) ; do
>> > + ? ? ? ? ? ? ? ? ? ? ? apply_patch "${p}" || { rm -rf "${patchesdir}" ; exit 1; }
>> > + ? ? ? ? ? ? ? done
>> > + ? ? ? ? ? ? ? rm -rf "${patchesdir}"
>> > + ? ? ? # file which is not an archive
>> > + ? ? ? else
>> > + ? ? ? ? ? ? ? # we can have regex into patch name as package*.patch.arm that's
>> > + ? ? ? ? ? ? ? # why using ls
>> > + ? ? ? ? ? ? ? for p in $(ls -d ${patch_path} 2> /dev/null) ; do
>> > + ? ? ? ? ? ? ? ? ? ? ? apply_patch "${p}" || exit 1
>> > + ? ? ? ? ? ? ? done
>> > + ? ? ? fi
>> > ?done
>> >
>> > -# Check for rejects...
>> > -if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
>> > +# check for rejects...
>> > +if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
>> > ? ? echo "Aborting. ?Reject files found."
>> > ? ? exit 1
>> > ?fi
>> >
>> > -# Remove backup files
>> > -find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
>> > +# remove backup files
>> > +find ${builddir}/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
>> > +
>> > --
>> > 1.7.5.4
>> >

Best regards,
Thomas

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v4]kernel-patch.sh: script changed to support archives in a proper way
  2012-01-10 11:46                 ` Thomas De Schampheleire
@ 2012-01-10 18:01                   ` ludovic.desroches at atmel.com
  2012-01-10 18:01                     ` [Buildroot] [RFC PATCH v4 1/2] apply-patches.sh: " ludovic.desroches at atmel.com
  2012-01-10 18:01                     ` [Buildroot] [RFC PATCH v4 2/2] apply-patches.sh check if they are rejects before applying patches ludovic.desroches at atmel.com
  0 siblings, 2 replies; 22+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-01-10 18:01 UTC (permalink / raw)
  To: buildroot

v4 changes:

- keep copyright
- remove dead code

Regards

Ludovic

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v4 1/2] apply-patches.sh: script changed to support archives in a proper way
  2012-01-10 18:01                   ` [Buildroot] [RFC PATCH v4]kernel-patch.sh: " ludovic.desroches at atmel.com
@ 2012-01-10 18:01                     ` ludovic.desroches at atmel.com
  2012-01-19 22:21                       ` Arnout Vandecappelle
  2012-01-10 18:01                     ` [Buildroot] [RFC PATCH v4 2/2] apply-patches.sh check if they are rejects before applying patches ludovic.desroches at atmel.com
  1 sibling, 1 reply; 22+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-01-10 18:01 UTC (permalink / raw)
  To: buildroot

From: Ludovic Desroches <ludovic.desroches@atmel.com>

The previous script doesn't support patching order with archives since
it didn't extract archives but simply decompressed file and piped the
result to the patch command.
This new script extracts archives in a temporary folder and then applies
patches.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>

Conflicts:

	support/scripts/apply-patches.sh
---
 support/scripts/apply-patches.sh |  135 +++++++++++++++++++++++++-------------
 1 files changed, 89 insertions(+), 46 deletions(-)

diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
index 1aef47e..2a25606 100755
--- a/support/scripts/apply-patches.sh
+++ b/support/scripts/apply-patches.sh
@@ -5,62 +5,105 @@
 #
 # (c) 2002 Erik Andersen <andersen@codepoet.org>
 
-# Set directories from arguments, or use defaults.
-targetdir=${1-.}
-patchdir=${2-../kernel-patches}
-shift 2
-patchpattern=${@-*}
+# function apply_patch patch_file
+# This function no more deals with directory case since it is managed
+# in an upper layer
+function apply_patch {
+apply="patch -p1 -E -d"
 
-if [ ! -d "${targetdir}" ] ; then
-    echo "Aborting.  '${targetdir}' is not a directory."
-    exit 1
+case "${1}" in
+*\.tar\.gz$|*\.tgz$|*\.tar\.bz$|*\.tar\.bz2$|*\.tbz$|*\.tbz2$)
+	echo "Error with ${1}";
+	echo "Archives into a directory or another archive is not supported";
+	return 1;
+	;;
+*\.gz$)
+	type="gzip"; uncomp="gunzip -dc"; ;;
+*\.bz$)
+	type="bzip"; uncomp="bunzip -dc"; ;;
+*\.bz2$)
+	type="bzip2"; uncomp="bunzip2 -dc"; ;;
+*\.zip$)
+	type="zip"; uncomp="unzip -d"; ;;
+*\.Z$)
+	type="compress"; uncomp="uncompress -c"; ;;
+*\.diff*)
+	type="diff"; uncomp="cat"; ;;
+*\.patch*)
+	type="patch"; uncomp="cat"; ;;
+*)
+	echo "Unsupported format file for ${1}, skip it";
+	return 0;
+	;;
+esac
+
+echo ""
+echo "Applying ${1} using ${type}: "
+echo ${1} | cat >> ${builddir}/.applied_patches_list
+${uncomp} ${1} | ${apply} ${builddir}
+if [ $? != 0 ] ; then
+	echo "Patch failed! Please fix ${1}!"
+	return 1
 fi
+}
+
+
+# Entry point
+builddir=${1}
+patchdir=${2}
+shift 2
+patchlist=${@}
+patchesdir="${builddir}/../$(basename $builddir)-patches"
+
+# Check directories
 if [ ! -d "${patchdir}" ] ; then
-    echo "Aborting.  '${patchdir}' is not a directory."
-    exit 1
+	echo "Aborting: ${patchdir} is not a directory."
+	exit 1
 fi
-    
-for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do 
-    apply="patch -g0 -p1 -E -d"
-    uncomp_parm=""
-    if [ -d "${patchdir}/$i" ] ; then
-	type="directory overlay"
-	uncomp="tar cf - --exclude=.svn --no-anchored -C"
-	uncomp_parm="."
-	apply="tar xvf - -C"
-    else case "$i" in
-	*.gz)
-	type="gzip"; uncomp="gunzip -dc"; ;; 
-	*.bz)
-	type="bzip"; uncomp="bunzip -dc"; ;; 
-	*.bz2)
-	type="bzip2"; uncomp="bunzip2 -dc"; ;; 
-	*.zip)
-	type="zip"; uncomp="unzip -d"; ;; 
-	*.Z)
-	type="compress"; uncomp="uncompress -c"; ;; 
-	*.tgz)
-	type="tar gzip"; uncomp="gunzip -dc"; apply="tar xvf - -C"; ;; 
-	*.tar)
-	type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;; 
-	*)
-	type="plaintext"; uncomp="cat"; ;; 
-    esac fi
-    echo ""
-    echo "Applying ${i} using ${type}: " 
-	echo ${i} | cat >> ${targetdir}/.applied_patches_list
-    ${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir} 
-    if [ $? != 0 ] ; then
-        echo "Patch failed!  Please fix $i!"
+if [ ! -d "${builddir}" ] ; then
+	echo "Aborting: ${builddir} is not a directory."
 	exit 1
-    fi
+fi
+
+# Parse patch list, extract archives, apply patches
+for i in $patchlist ; do
+	patch_path="${patchdir}/${i}"
+	# three cases: directory, archive, file patch (compressed or not)
+	# directory
+	if [ -d "${patch_path}" ] ; then
+		for p in $(ls ${patch_path}) ; do
+			apply_patch "${patch_path}/${p}" || exit 1
+		done
+	# archive
+	elif echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$|tar\.gz$|tgz$" ; then
+		mkdir "${patchesdir}"
+		# extract archive
+		if echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
+			tar_options="-xjf"
+		else
+			tar_options="-xzf"
+		fi
+		tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
+		# apply patches from the archive
+		for p in $(find ${patchesdir} | sort) ; do
+			apply_patch "${p}" || { rm -rf "${patchesdir}" ; exit 1; }
+		done
+		rm -rf "${patchesdir}"
+	# file which is not an archive
+	else
+		# we can have regex into patch name as package*.patch.arm that's
+		# why using ls
+		for p in $(ls -d ${patch_path} 2> /dev/null) ; do
+			apply_patch "${p}" || exit 1
+		done
+	fi
 done
 
 # Check for rejects...
-if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
     echo "Aborting.  Reject files found."
     exit 1
 fi
 
 # Remove backup files
-find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
+find ${builddir}/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v4 2/2] apply-patches.sh check if they are rejects before applying patches
  2012-01-10 18:01                   ` [Buildroot] [RFC PATCH v4]kernel-patch.sh: " ludovic.desroches at atmel.com
  2012-01-10 18:01                     ` [Buildroot] [RFC PATCH v4 1/2] apply-patches.sh: " ludovic.desroches at atmel.com
@ 2012-01-10 18:01                     ` ludovic.desroches at atmel.com
  2012-01-19 22:26                       ` Arnout Vandecappelle
  1 sibling, 1 reply; 22+ messages in thread
From: ludovic.desroches at atmel.com @ 2012-01-10 18:01 UTC (permalink / raw)
  To: buildroot

From: Ludovic Desroches <ludovic.desroches@atmel.com>

If we don't do it, the rejects' check at the end of the script can complain
about rejects not deleted by the user from a previous try.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 support/scripts/apply-patches.sh |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
index 2a25606..a15b5c1 100755
--- a/support/scripts/apply-patches.sh
+++ b/support/scripts/apply-patches.sh
@@ -64,6 +64,13 @@ if [ ! -d "${builddir}" ] ; then
 	echo "Aborting: ${builddir} is not a directory."
 	exit 1
 fi
+# check for rejects because if there are some, even if patches are well
+# applied, at the end it will complain about rejects into buildir
+if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+    echo "There are remaining rejecting file into ${buildir}, please delete them"
+    exit 1
+fi
+
 
 # Parse patch list, extract archives, apply patches
 for i in $patchlist ; do
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v4 1/2] apply-patches.sh: script changed to support archives in a proper way
  2012-01-10 18:01                     ` [Buildroot] [RFC PATCH v4 1/2] apply-patches.sh: " ludovic.desroches at atmel.com
@ 2012-01-19 22:21                       ` Arnout Vandecappelle
  2012-01-23  8:22                         ` Ludovic Desroches
  2012-01-29 16:28                         ` Ludovic Desroches
  0 siblings, 2 replies; 22+ messages in thread
From: Arnout Vandecappelle @ 2012-01-19 22:21 UTC (permalink / raw)
  To: buildroot

On Tuesday 10 January 2012 19:01:55 ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> The previous script doesn't support patching order with archives since
> it didn't extract archives but simply decompressed file and piped the
> result to the patch command.
> This new script extracts archives in a temporary folder and then applies
> patches.

 You need to document the API changes clearly.

- Uncompressed patches must match *.diff* or *.patch*; else they are skipped.

- The defaults are removed; three or more arguments must be supplied.

- Behaviour of directories is changed: it is not considered an overlay, but
rather a collection of patches.

 Since these changes actually have nothing to do with supporting archives
in a proper way, I suggest you make separate patches for them.

> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

> 
> Conflicts:
> 
> 	support/scripts/apply-patches.sh

 Please remove this piece from the comment.

> ---
>  support/scripts/apply-patches.sh |  135 +++++++++++++++++++++++++-------------
>  1 files changed, 89 insertions(+), 46 deletions(-)
> 
> diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
> index 1aef47e..2a25606 100755
> --- a/support/scripts/apply-patches.sh
> +++ b/support/scripts/apply-patches.sh
> @@ -5,62 +5,105 @@
>  #
>  # (c) 2002 Erik Andersen <andersen@codepoet.org>
>  
> -# Set directories from arguments, or use defaults.
> -targetdir=${1-.}
> -patchdir=${2-../kernel-patches}
> -shift 2
> -patchpattern=${@-*}
> +# function apply_patch patch_file
> +# This function no more deals with directory case since it is managed
> +# in an upper layer
 This comment isn't very helpful, since the reader can't see how it was before.
Actually, no comment is needed here (it's pretty obvious that it applies a single
patch).

> +function apply_patch {
 Please indent the body of the function.  And preferably keep the same
whitespace convention as the original (4 spaces).  That makes the diff 
smaller.  Do feel free to get rid of the original's mixed tabs-and-spaces,
though...

> +apply="patch -p1 -E -d"
 Since apply is used only once it is no longer necessary to make it a variable.

 Why did the -g0 option get dropped?

> -if [ ! -d "${targetdir}" ] ; then
> -    echo "Aborting.  '${targetdir}' is not a directory."
> -    exit 1
> +case "${1}" in
> +*\.tar\.gz$|*\.tgz$|*\.tar\.bz$|*\.tar\.bz2$|*\.tbz$|*\.tbz2$)
> +	echo "Error with ${1}";
> +	echo "Archives into a directory or another archive is not supported";
> +	return 1;
 I think this piece is a bit redundant, but it doesn't hurt.

> +	;;
> +*\.gz$)
> +	type="gzip"; uncomp="gunzip -dc"; ;;
> +*\.bz$)
> +	type="bzip"; uncomp="bunzip -dc"; ;;
> +*\.bz2$)
> +	type="bzip2"; uncomp="bunzip2 -dc"; ;;
> +*\.zip$)
> +	type="zip"; uncomp="unzip -d"; ;;
> +*\.Z$)
> +	type="compress"; uncomp="uncompress -c"; ;;
> +*\.diff*)
> +	type="diff"; uncomp="cat"; ;;
> +*\.patch*)
> +	type="patch"; uncomp="cat"; ;;
> +*)
> +	echo "Unsupported format file for ${1}, skip it";
> +	return 0;
> +	;;
> +esac
> +
> +echo ""
> +echo "Applying ${1} using ${type}: "
> +echo ${1} | cat >> ${builddir}/.applied_patches_list
 The 'cat' here is completely redundant AFAICS.  (I realize this was
already present in the original.)

> +${uncomp} ${1} | ${apply} ${builddir}
 If you use "$1" and "$builddir", you also support names with spaces and
other shell-interpreted stuff.

> +if [ $? != 0 ] ; then
> +	echo "Patch failed! Please fix ${1}!"
> +	return 1
>  fi
> +}
> +
> +
> +# Entry point
> +builddir=${1}
> +patchdir=${2}
 Any particular reason why you renamed 'targetdir' to 'builddir'?  Also,
keep this in the beginning of the file so the diff becomes clearer.

 Again, quoting would be useful.

> +shift 2
> +patchlist=${@}
 Note that $@ implies the quotes already, so they're not required here.

> +patchesdir="${builddir}/../$(basename $builddir)-patches"
 I would make the patchesdir a subdirectory of the builddir, so it does
get cleaned up with a -dirclean.  E.g. 
$builddir/.patches-$(basename $tarfile)-unpacked

> +
> +# Check directories
>  if [ ! -d "${patchdir}" ] ; then
> -    echo "Aborting.  '${patchdir}' is not a directory."
> -    exit 1
> +	echo "Aborting: ${patchdir} is not a directory."
> +	exit 1
 Preferably, don't modify things unnecessarily.

>  fi
> -    
> -for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do 
> -    apply="patch -g0 -p1 -E -d"
> -    uncomp_parm=""
> -    if [ -d "${patchdir}/$i" ] ; then
> -	type="directory overlay"
> -	uncomp="tar cf - --exclude=.svn --no-anchored -C"
> -	uncomp_parm="."
> -	apply="tar xvf - -C"
> -    else case "$i" in
> -	*.gz)
> -	type="gzip"; uncomp="gunzip -dc"; ;; 
> -	*.bz)
> -	type="bzip"; uncomp="bunzip -dc"; ;; 
> -	*.bz2)
> -	type="bzip2"; uncomp="bunzip2 -dc"; ;; 
> -	*.zip)
> -	type="zip"; uncomp="unzip -d"; ;; 
> -	*.Z)
> -	type="compress"; uncomp="uncompress -c"; ;; 
> -	*.tgz)
> -	type="tar gzip"; uncomp="gunzip -dc"; apply="tar xvf - -C"; ;; 
> -	*.tar)
> -	type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;; 
> -	*)
> -	type="plaintext"; uncomp="cat"; ;; 
> -    esac fi
> -    echo ""
> -    echo "Applying ${i} using ${type}: " 
> -	echo ${i} | cat >> ${targetdir}/.applied_patches_list
> -    ${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir} 
> -    if [ $? != 0 ] ; then
> -        echo "Patch failed!  Please fix $i!"
> +if [ ! -d "${builddir}" ] ; then
> +	echo "Aborting: ${builddir} is not a directory."
>  	exit 1
> -    fi
> +fi
> +
> +# Parse patch list, extract archives, apply patches
> +for i in $patchlist ; do
> +	patch_path="${patchdir}/${i}"
> +	# three cases: directory, archive, file patch (compressed or not)
> +	# directory
> +	if [ -d "${patch_path}" ] ; then
> +		for p in $(ls ${patch_path}) ; do
> +			apply_patch "${patch_path}/${p}" || exit 1
> +		done
> +	# archive
> +	elif echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$|tar\.gz$|tgz$" ; then
> +		mkdir "${patchesdir}"
 Remove the patchesdir first, in case it got left behind by an interrupted
previous run.

> +		# extract archive
> +		if echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
> +			tar_options="-xjf"
> +		else
> +			tar_options="-xzf"
> +		fi
> +		tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
 This will give problems on CentOS 5 IIRC - the issue with host-tar, which 
ThomasDS solved recently.

 Actually it is probably a better idea to handle the tar case in the 
Makefiles...

> +		# apply patches from the archive
> +		for p in $(find ${patchesdir} | sort) ; do
> +			apply_patch "${p}" || { rm -rf "${patchesdir}" ; exit 1; }
> +		done
> +		rm -rf "${patchesdir}"
 I would not remove the patchesdir; makes it easier for a developer to read
and/or unapply the patches.

> +	# file which is not an archive
> +	else
> +		# we can have regex into patch name as package*.patch.arm that's
 Actually, it's not a regex but a glob pattern.

> +		# why using ls
> +		for p in $(ls -d ${patch_path} 2> /dev/null) ; do
> +			apply_patch "${p}" || exit 1
> +		done
> +	fi
>  done
>  
>  # Check for rejects...
> -if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
> +if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
>      echo "Aborting.  Reject files found."
>      exit 1
>  fi
>  
>  # Remove backup files
> -find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
> +find ${builddir}/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
> 

 Regards,
 Arnout

-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v4 2/2] apply-patches.sh check if they are rejects before applying patches
  2012-01-10 18:01                     ` [Buildroot] [RFC PATCH v4 2/2] apply-patches.sh check if they are rejects before applying patches ludovic.desroches at atmel.com
@ 2012-01-19 22:26                       ` Arnout Vandecappelle
  0 siblings, 0 replies; 22+ messages in thread
From: Arnout Vandecappelle @ 2012-01-19 22:26 UTC (permalink / raw)
  To: buildroot

 Short commit message should be:
apply-patches.sh: check if there are rejects before applying patches

On Tuesday 10 January 2012 19:01:56 ludovic.desroches at atmel.com wrote:
> From: Ludovic Desroches <ludovic.desroches@atmel.com>
> 
> If we don't do it, the rejects' check at the end of the script can complain
> about rejects not deleted by the user from a previous try.
> 
> Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

 Since this patch is much more likely to go in on the short term, I would
reverse the order of the patches.  That means: revert builddir to targetdir.

> ---
>  support/scripts/apply-patches.sh |    7 +++++++
>  1 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
> index 2a25606..a15b5c1 100755
> --- a/support/scripts/apply-patches.sh
> +++ b/support/scripts/apply-patches.sh
> @@ -64,6 +64,13 @@ if [ ! -d "${builddir}" ] ; then
>  	echo "Aborting: ${builddir} is not a directory."
>  	exit 1
>  fi
> +# check for rejects because if there are some, even if patches are well
> +# applied, at the end it will complain about rejects into buildir
> +if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
> +    echo "There are remaining rejecting file into ${buildir}, please delete them"
 Should be:
echo "There are remaining reject files in '${buildir}', please delete them."

 Otherwise, looks perfect.

 Regards,
 Arnout

-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v4 1/2] apply-patches.sh: script changed to support archives in a proper way
  2012-01-19 22:21                       ` Arnout Vandecappelle
@ 2012-01-23  8:22                         ` Ludovic Desroches
  2012-01-29 16:28                         ` Ludovic Desroches
  1 sibling, 0 replies; 22+ messages in thread
From: Ludovic Desroches @ 2012-01-23  8:22 UTC (permalink / raw)
  To: buildroot

Hello Arnout,

Thanks for your comments, I will rework this patch and send a new one.

Regards

Ludovic

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v4 1/2] apply-patches.sh: script changed to support archives in a proper way
  2012-01-19 22:21                       ` Arnout Vandecappelle
  2012-01-23  8:22                         ` Ludovic Desroches
@ 2012-01-29 16:28                         ` Ludovic Desroches
  2012-01-31  6:59                           ` Arnout Vandecappelle
  1 sibling, 1 reply; 22+ messages in thread
From: Ludovic Desroches @ 2012-01-29 16:28 UTC (permalink / raw)
  To: buildroot

Hello Arnout,

First sorry for some mistakes, I wanted to quickly send this patch for the
upstream version and I forgot to do some basic checks. I thought this file
was only moved from toolchain/patch-kernel.sh to 
support/scripts/apply-patches.sh. It explains some errors as dropping -g0
option.

I wanted to send a new version but I am facing some issues in relation
with your advices:

On Thu, Jan 19, 2012 at 11:21:43PM +0100, Arnout Vandecappelle wrote:
> On Tuesday 10 January 2012 19:01:55 ludovic.desroches at atmel.com wrote:
> > From: Ludovic Desroches <ludovic.desroches@atmel.com>
> > 
> > The previous script doesn't support patching order with archives since
> > it didn't extract archives but simply decompressed file and piped the
> > result to the patch command.
> > This new script extracts archives in a temporary folder and then applies
> > patches.
> 
>  You need to document the API changes clearly.
> 
> - Uncompressed patches must match *.diff* or *.patch*; else they are skipped.
> 
> - The defaults are removed; three or more arguments must be supplied.
> 
> - Behaviour of directories is changed: it is not considered an overlay, but
> rather a collection of patches.

Ok I will do it.
> 
>  Since these changes actually have nothing to do with supporting archives
> in a proper way, I suggest you make separate patches for them.

It is my main issue splitting the patch into archive management and the change
of the behaviour of directories.
I may have to split we apply_patch function: one part to compute type, uncomp,
etc. and one other for the command to apply the patch

> 
> > 
> > Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
> Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> 
> > 
> > Conflicts:
> > 
> > 	support/scripts/apply-patches.sh
> 
>  Please remove this piece from the comment.
> 
> > ---
> >  support/scripts/apply-patches.sh |  135 +++++++++++++++++++++++++-------------
> >  1 files changed, 89 insertions(+), 46 deletions(-)
> > 
> > diff --git a/support/scripts/apply-patches.sh b/support/scripts/apply-patches.sh
> > index 1aef47e..2a25606 100755
> > --- a/support/scripts/apply-patches.sh
> > +++ b/support/scripts/apply-patches.sh
> > @@ -5,62 +5,105 @@
> >  #
> >  # (c) 2002 Erik Andersen <andersen@codepoet.org>
> >  
> > -# Set directories from arguments, or use defaults.
> > -targetdir=${1-.}
> > -patchdir=${2-../kernel-patches}
> > -shift 2
> > -patchpattern=${@-*}
> > +# function apply_patch patch_file
> > +# This function no more deals with directory case since it is managed
> > +# in an upper layer
>  This comment isn't very helpful, since the reader can't see how it was before.
> Actually, no comment is needed here (it's pretty obvious that it applies a single
> patch).

Yes you're right.

> 
> > +function apply_patch {
>  Please indent the body of the function.  And preferably keep the same
> whitespace convention as the original (4 spaces).  That makes the diff 
> smaller.  Do feel free to get rid of the original's mixed tabs-and-spaces,
> though...
> 
> > +apply="patch -p1 -E -d"
>  Since apply is used only once it is no longer necessary to make it a variable.
> 
>  Why did the -g0 option get dropped?

As I told a mistake on my side...

> 
> > -if [ ! -d "${targetdir}" ] ; then
> > -    echo "Aborting.  '${targetdir}' is not a directory."
> > -    exit 1
> > +case "${1}" in
> > +*\.tar\.gz$|*\.tgz$|*\.tar\.bz$|*\.tar\.bz2$|*\.tbz$|*\.tbz2$)
> > +	echo "Error with ${1}";
> > +	echo "Archives into a directory or another archive is not supported";
> > +	return 1;
>  I think this piece is a bit redundant, but it doesn't hurt.

I don't see why. If we have an archive here we will have the old behavior
which can cause isssues when applying patches since the patch order may not be
kept.

> 
> > +	;;
> > +*\.gz$)
> > +	type="gzip"; uncomp="gunzip -dc"; ;;
> > +*\.bz$)
> > +	type="bzip"; uncomp="bunzip -dc"; ;;
> > +*\.bz2$)
> > +	type="bzip2"; uncomp="bunzip2 -dc"; ;;
> > +*\.zip$)
> > +	type="zip"; uncomp="unzip -d"; ;;
> > +*\.Z$)
> > +	type="compress"; uncomp="uncompress -c"; ;;
> > +*\.diff*)
> > +	type="diff"; uncomp="cat"; ;;
> > +*\.patch*)
> > +	type="patch"; uncomp="cat"; ;;
> > +*)
> > +	echo "Unsupported format file for ${1}, skip it";
> > +	return 0;
> > +	;;
> > +esac
> > +
> > +echo ""
> > +echo "Applying ${1} using ${type}: "
> > +echo ${1} | cat >> ${builddir}/.applied_patches_list
>  The 'cat' here is completely redundant AFAICS.  (I realize this was
> already present in the original.)

Yes I will remove it.

> 
> > +${uncomp} ${1} | ${apply} ${builddir}
>  If you use "$1" and "$builddir", you also support names with spaces and
> other shell-interpreted stuff.
> 
> > +if [ $? != 0 ] ; then
> > +	echo "Patch failed! Please fix ${1}!"
> > +	return 1
> >  fi
> > +}
> > +
> > +
> > +# Entry point
> > +builddir=${1}
> > +patchdir=${2}
>  Any particular reason why you renamed 'targetdir' to 'builddir'?  Also,
> keep this in the beginning of the file so the diff becomes clearer.

I thought builddir was a better name since targetdir is not output/target as
it can suggest. It can be a separated patch and maybe this change is not
useful.

> 
>  Again, quoting would be useful.

Ok.

> 
> > +shift 2
> > +patchlist=${@}
>  Note that $@ implies the quotes already, so they're not required here.
> 
> > +patchesdir="${builddir}/../$(basename $builddir)-patches"
>  I would make the patchesdir a subdirectory of the builddir, so it does
> get cleaned up with a -dirclean.  E.g. 
> $builddir/.patches-$(basename $tarfile)-unpacked
> 

Good idea, thanks.

> > +
> > +# Check directories
> >  if [ ! -d "${patchdir}" ] ; then
> > -    echo "Aborting.  '${patchdir}' is not a directory."
> > -    exit 1
> > +	echo "Aborting: ${patchdir} is not a directory."
> > +	exit 1
>  Preferably, don't modify things unnecessarily.
> 
> >  fi
> > -    
> > -for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do 
> > -    apply="patch -g0 -p1 -E -d"
> > -    uncomp_parm=""
> > -    if [ -d "${patchdir}/$i" ] ; then
> > -	type="directory overlay"
> > -	uncomp="tar cf - --exclude=.svn --no-anchored -C"
> > -	uncomp_parm="."
> > -	apply="tar xvf - -C"
> > -    else case "$i" in
> > -	*.gz)
> > -	type="gzip"; uncomp="gunzip -dc"; ;; 
> > -	*.bz)
> > -	type="bzip"; uncomp="bunzip -dc"; ;; 
> > -	*.bz2)
> > -	type="bzip2"; uncomp="bunzip2 -dc"; ;; 
> > -	*.zip)
> > -	type="zip"; uncomp="unzip -d"; ;; 
> > -	*.Z)
> > -	type="compress"; uncomp="uncompress -c"; ;; 
> > -	*.tgz)
> > -	type="tar gzip"; uncomp="gunzip -dc"; apply="tar xvf - -C"; ;; 
> > -	*.tar)
> > -	type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;; 
> > -	*)
> > -	type="plaintext"; uncomp="cat"; ;; 
> > -    esac fi
> > -    echo ""
> > -    echo "Applying ${i} using ${type}: " 
> > -	echo ${i} | cat >> ${targetdir}/.applied_patches_list
> > -    ${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir} 
> > -    if [ $? != 0 ] ; then
> > -        echo "Patch failed!  Please fix $i!"
> > +if [ ! -d "${builddir}" ] ; then
> > +	echo "Aborting: ${builddir} is not a directory."
> >  	exit 1
> > -    fi
> > +fi
> > +
> > +# Parse patch list, extract archives, apply patches
> > +for i in $patchlist ; do
> > +	patch_path="${patchdir}/${i}"
> > +	# three cases: directory, archive, file patch (compressed or not)
> > +	# directory
> > +	if [ -d "${patch_path}" ] ; then
> > +		for p in $(ls ${patch_path}) ; do
> > +			apply_patch "${patch_path}/${p}" || exit 1
> > +		done
> > +	# archive
> > +	elif echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$|tar\.gz$|tgz$" ; then
> > +		mkdir "${patchesdir}"
>  Remove the patchesdir first, in case it got left behind by an interrupted
> previous run.

Thanks I forgot this case.

> 
> > +		# extract archive
> > +		if echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
> > +			tar_options="-xjf"
> > +		else
> > +			tar_options="-xzf"
> > +		fi
> > +		tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
>  This will give problems on CentOS 5 IIRC - the issue with host-tar, which 
> ThomasDS solved recently.

Ok I have to checked what is this issue and how it has been solved.

> 
>  Actually it is probably a better idea to handle the tar case in the 
> Makefiles...

Isn't better here? It will involve changing many files, isn't it?

> 
> > +		# apply patches from the archive
> > +		for p in $(find ${patchesdir} | sort) ; do
> > +			apply_patch "${p}" || { rm -rf "${patchesdir}" ; exit 1; }
> > +		done
> > +		rm -rf "${patchesdir}"
>  I would not remove the patchesdir; makes it easier for a developer to read
> and/or unapply the patches.

Ok, why not.

> 
> > +	# file which is not an archive
> > +	else
> > +		# we can have regex into patch name as package*.patch.arm that's
>  Actually, it's not a regex but a glob pattern.
> 
> > +		# why using ls
> > +		for p in $(ls -d ${patch_path} 2> /dev/null) ; do
> > +			apply_patch "${p}" || exit 1
> > +		done
> > +	fi
> >  done
> >  
> >  # Check for rejects...
> > -if [ "`find $targetdir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
> > +if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
> >      echo "Aborting.  Reject files found."
> >      exit 1
> >  fi
> >  
> >  # Remove backup files
> > -find $targetdir/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
> > +find ${builddir}/ '(' -name '*.orig' -o -name '.*.orig' ')' -exec rm -f {} \;
> > 
> 
>  Regards,
>  Arnout
> 
> -- 
> Arnout Vandecappelle                               arnout at mind be
> Senior Embedded Software Architect                 +32-16-286540
> Essensium/Mind                                     http://www.mind.be
> G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
> LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
> GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
> 

Thanks for your help.

Regards

Ludovic

^ permalink raw reply	[flat|nested] 22+ messages in thread

* [Buildroot] [RFC PATCH v4 1/2] apply-patches.sh: script changed to support archives in a proper way
  2012-01-29 16:28                         ` Ludovic Desroches
@ 2012-01-31  6:59                           ` Arnout Vandecappelle
  0 siblings, 0 replies; 22+ messages in thread
From: Arnout Vandecappelle @ 2012-01-31  6:59 UTC (permalink / raw)
  To: buildroot

On Sunday 29 January 2012 17:28:25 Ludovic Desroches wrote:
> Hello Arnout,
> 
> First sorry for some mistakes, I wanted to quickly send this patch for the
> upstream version and I forgot to do some basic checks. I thought this file
> was only moved from toolchain/patch-kernel.sh to 
> support/scripts/apply-patches.sh. It explains some errors as dropping -g0
> option.
> 
> I wanted to send a new version but I am facing some issues in relation
> with your advices:
> 
> On Thu, Jan 19, 2012 at 11:21:43PM +0100, Arnout Vandecappelle wrote:
> > On Tuesday 10 January 2012 19:01:55 ludovic.desroches at atmel.com wrote:
> > > From: Ludovic Desroches <ludovic.desroches@atmel.com>
> > > 
> > > The previous script doesn't support patching order with archives since
> > > it didn't extract archives but simply decompressed file and piped the
> > > result to the patch command.
> > > This new script extracts archives in a temporary folder and then applies
> > > patches.
> > 
> >  You need to document the API changes clearly.
> > 
> > - Uncompressed patches must match *.diff* or *.patch*; else they are skipped.
> > 
> > - The defaults are removed; three or more arguments must be supplied.
> > 
> > - Behaviour of directories is changed: it is not considered an overlay, but
> > rather a collection of patches.
> 
> Ok I will do it.
> > 
> >  Since these changes actually have nothing to do with supporting archives
> > in a proper way, I suggest you make separate patches for them.
> 
> It is my main issue splitting the patch into archive management and the change
> of the behaviour of directories.
> I may have to split we apply_patch function: one part to compute type, uncomp,
> etc. and one other for the command to apply the patch

 You misunderstand my point.  You now have one patch (i.e. one git commit)
that fixes the support for patch archives.  This patch also changes the API
of apply-patches.sh.  There may be good reasons for that - AFAICS currently
the only way apply-patches.sh is used in existing buildroot packages, is
for *.patch files.  So it makes sense to simplify the script and remove the
redundant features.  However, such a thing should be done in a separate patch,
with a separate git commit, so it is easier to trace back afterwards when the
feature got removed.  So you'd have a first patch that removes redundant features,
and a second patch that fixes the support for archives.

[snip]
> > > -if [ ! -d "${targetdir}" ] ; then
> > > -    echo "Aborting.  '${targetdir}' is not a directory."
> > > -    exit 1
> > > +case "${1}" in
> > > +*\.tar\.gz$|*\.tgz$|*\.tar\.bz$|*\.tar\.bz2$|*\.tbz$|*\.tbz2$)
> > > +	echo "Error with ${1}";
> > > +	echo "Archives into a directory or another archive is not supported";
> > > +	return 1;
> >  I think this piece is a bit redundant, but it doesn't hurt.
> 
> I don't see why. If we have an archive here we will have the old behavior
> which can cause isssues when applying patches since the patch order may not be
> kept.
 You're right, my mistake, I had just considered the .tgz case, which 
doesn't match any of the case branches and will fall into the default
"Unsupported file format..." branch.

 BTW, just noticed now: the \. is redundant.  The case branches match
glob patterns, not regular expressions, so . isn't anything special.
Same for the $.

[snip]
> > > +# Entry point
> > > +builddir=${1}
> > > +patchdir=${2}
> >  Any particular reason why you renamed 'targetdir' to 'builddir'?  Also,
> > keep this in the beginning of the file so the diff becomes clearer.
> 
> I thought builddir was a better name since targetdir is not output/target as
> it can suggest. It can be a separated patch and maybe this change is not
> useful.
 This could be part of that first cleanup patch.

[snip]
> > > +		# extract archive
> > > +		if echo $i | grep -q -E "tar\.bz$|tar\.bz2$|tbz$|tbz2$" ; then
> > > +			tar_options="-xjf"
> > > +		else
> > > +			tar_options="-xzf"
> > > +		fi
> > > +		tar -C ${patchesdir} --strip-components=1 ${tar_options} ${patch_path}
> >  This will give problems on CentOS 5 IIRC - the issue with host-tar, which 
> > ThomasDS solved recently.

 Actually, it's probably a good idea to export HOST_PATH from the Makefile.
This issue probably occurs in other places as well.  But that's not for you
to take care of, Ludovic.

> 
> Ok I have to checked what is this issue and how it has been solved.
> 
> > 
> >  Actually it is probably a better idea to handle the tar case in the 
> > Makefiles...
> 
> Isn't better here? It will involve changing many files, isn't it?
 You're right, I wasn't thinking.

[snip]

 Regards,
 Arnout

-- 
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2012-01-31  6:59 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-07  9:32 [Buildroot] Patching method Ludovic Desroches
2011-05-18 10:10 ` [Buildroot] [PATCH 1/1] kernel-patch.sh: script changed to support archives in a proper way Ludovic Desroches
     [not found]   ` <4DDBBB89.2020301@atmel.com>
2011-05-24 14:25     ` Peter Korsgaard
2011-05-24 14:50       ` Thomas Petazzoni
2011-06-29  9:12   ` [Buildroot] [RFC PATCH v2]kernel-patch.sh: " ludovic.desroches at atmel.com
2011-06-29  9:12     ` [Buildroot] [RFC PATCH v2 1/1] kernel-patch.sh: " ludovic.desroches at atmel.com
2011-06-29 10:42       ` Michael S. Zick
2011-06-29 13:21         ` Ludovic Desroches
2012-01-06 12:47         ` [Buildroot] [RFC PATCH v3]kernel-patch.sh: " ludovic.desroches at atmel.com
2012-01-06 12:47           ` [Buildroot] [RFC PATCH v3 1/2] apply-patches.sh: " ludovic.desroches at atmel.com
2012-01-09  9:45             ` Thomas De Schampheleire
2012-01-10 10:31               ` Ludovic Desroches
2012-01-10 11:46                 ` Thomas De Schampheleire
2012-01-10 18:01                   ` [Buildroot] [RFC PATCH v4]kernel-patch.sh: " ludovic.desroches at atmel.com
2012-01-10 18:01                     ` [Buildroot] [RFC PATCH v4 1/2] apply-patches.sh: " ludovic.desroches at atmel.com
2012-01-19 22:21                       ` Arnout Vandecappelle
2012-01-23  8:22                         ` Ludovic Desroches
2012-01-29 16:28                         ` Ludovic Desroches
2012-01-31  6:59                           ` Arnout Vandecappelle
2012-01-10 18:01                     ` [Buildroot] [RFC PATCH v4 2/2] apply-patches.sh check if they are rejects before applying patches ludovic.desroches at atmel.com
2012-01-19 22:26                       ` Arnout Vandecappelle
2012-01-06 12:47           ` [Buildroot] [RFC PATCH v3 " ludovic.desroches at atmel.com

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.