Skip to contentSkip to conversation

apply-patches.sh: big update (new directory and archive management)

RFC PATCH New ludovic.desroches at atmel.com 2 participants 24 messages Feb 6, 2012 – Feb 16, 2012

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 apply-patches.sh: big update (new directory and archive management)

Hello,

A new update for apply-patches.sh script trying to apply Arnout advices.

This is not a final version, I have some minor changes I want to add and I have more tests/builds to do.

I mainly want to know if I take the good way!

Regards

Ludovic

#1 lore raw

RFC PATCH 1/6 apply-patches.sh: check if there are rejects before applying patches

From: Ludovic Desroches <[email protected]>

---
 support/scripts/apply-patches.sh |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
support/scripts/apply-patches.sh +6 -0
index 1aef47e..1ad7d1f 100755
@@ -19,6 +19,12 @@ if [ ! -d "${patchdir}" ] ; then
     echo "Aborting.  '${patchdir}' 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 targetdir.
+if [ "`find ${targetdir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+	echo "There are remaining reject files into ${targetdir}, please delete them."
+fi
     
 for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do 
     apply="patch -g0 -p1 -E -d"
Signature · 1 line
1.7.5.4
#2 lore raw

RFC PATCH 1/6 apply-patches.sh: check if there are rejects before applying patches

Quoted 13 lines · On Monday 06 February 2012 02:47:14 ludovic.desroches at atmel.com wrote:

From: Ludovic Desroches <[email protected]>

---
 support/scripts/apply-patches.sh |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
support/scripts/apply-patches.sh +0 -0
index 1aef47e..1ad7d1f 100755

support/scripts/apply-patches.sh if [ ! -d "${patchdir}" ] ; then · line 26

Quoted 8 lines
support/scripts/apply-patches.sh +5 -0
@@ -19,6 +19,12 @@ if [ ! -d "${patchdir}" ] ; then
     echo "Aborting.  '${patchdir}' 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 targetdir.
+if [ "`find ${targetdir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+	echo "There are remaining reject files into ${targetdir}, please delete them."

'into' should be 'in'.

Personally, I would just delete them instead of issuing a warning. If you
don't then the script should at least exit at this point, otherwise you'll still get the complaint at the end.

Regards,
Arnout

Quoted 5 lines
support/scripts/apply-patches.sh +1 -0
+fi
 
 for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do 
     apply="patch -g0 -p1 -E -d"
Signature · 9 lines
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20120210/4c10e19c/attachment-0001.html>
#3 lore raw

RFC PATCH 1/6 apply-patches.sh: check if there are rejects before applying patches

Quoted 50 lines · Arnout Vandecappelle
Quoted 10 lines · On Monday 06 February 2012 02:47:14 ludovic.desroches at atmel.com wrote:

From: Ludovic Desroches <[email protected]>

---

Review

Quoted 7 lines

support/scripts/apply-patches.sh | 6 ++++++

1 files changed, 6 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/support/scripts/apply-patches.sh

Quoted 14 lines

index 1aef47e..1ad7d1f 100755

--- a/support/scripts/apply-patches.sh

+++ b/support/scripts/apply-patches.sh

(quoted diff) +0 -0
@@ -19,6 +19,12 @@ if [ ! -d "${patchdir}" ] ; then
 

echo "Aborting. '${patchdir}' is not a directory."

exit 1

fi

support/scripts/apply-patches.sh if [ ! -d "${patchdir}" ] ; then

Quoted 3 lines
support/scripts/apply-patches.sh +2 -0
+
 
+# Check for rejects because if there are some, even if patches are

well

support/scripts/apply-patches.sh if [ ! -d "${patchdir}" ] ; then

Quoted 3 lines
support/scripts/apply-patches.sh +2 -0
+# applied, at the end it will complain about rejects into targetdir.
 
+if [ "`find ${targetdir}/ '(' -name '*.rej' -o -name '.*.rej' ')'

-print`" ] ; then

Quoted 1 line

+ echo "There are remaining reject files into ${targetdir}, please

delete them."

'into' should be 'in'.

Quoted 8 lines

Personally, I would just delete them instead of issuing a warning. If you

don't then the script should at least exit at this point, otherwise you'll

still get the complaint at the end.

Ok I'll change the behavior.

Regards

Ludovic

#4 lore raw

RFC PATCH v2 1/6 apply-patches.sh: check if there are rejects before applying patches

From: Ludovic Desroches <[email protected]>

---
 support/scripts/apply-patches.sh |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
support/scripts/apply-patches.sh +7 -0
index 1aef47e..b145b46 100755
@@ -19,6 +19,13 @@ if [ ! -d "${patchdir}" ] ; then
     echo "Aborting.  '${patchdir}' 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 targetdir.
+if [ "`find ${targetdir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+	rm -f "${targetdir}/*.rej" 2> /dev/null
+	echo "Remaining reject files in ${targetdir} have been removed"
+fi
     
 for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do 
     apply="patch -g0 -p1 -E -d"
Signature · 1 line
1.7.5.4
#5 lore raw

RFC PATCH v2 1/6 apply-patches.sh: check if there are rejects before applying patches

Quoted 3 lines · On Wednesday 15 February 2012 23:33:49 ludovic.desroches at atmel.com wrote:

From: Ludovic Desroches <[email protected]>

Signature · 6 lines
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
#6 lore raw

RFC PATCH 2/6 apply-patches.sh: rename targetdir to builddir

In reply to ludovic.desroches at atmel.com

From: Ludovic Desroches <[email protected]>

targetdir is not the output/target directory as it can suggest.

---
 support/scripts/apply-patches.sh |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
support/scripts/apply-patches.sh +10 -10
index 1ad7d1f..2667d04 100755
@@ -6,13 +6,13 @@
 # (c) 2002 Erik Andersen <[email protected]>
 
 # Set directories from arguments, or use defaults.
-targetdir=${1-.}
+builddir=${1-.}
 patchdir=${2-../kernel-patches}
 shift 2
 patchpattern=${@-*}
 
-if [ ! -d "${targetdir}" ] ; then
-    echo "Aborting.  '${targetdir}' is not a directory."
+if [ ! -d "${builddir}" ] ; then
+    echo "Aborting.  '${builddir}' is not a directory."
     exit 1
 fi
 if [ ! -d "${patchdir}" ] ; then
@@ -21,9 +21,9 @@ if [ ! -d "${patchdir}" ] ; then
 fi
 
 # Check for rejects because if there are some, even if patches are well
-# applied, at the end it will complain about rejects into targetdir.
-if [ "`find ${targetdir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
-	echo "There are remaining reject files into ${targetdir}, please delete them."
+# applied, at the end it will complain about rejects into builddir.
+if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+	echo "There are remaining reject files into ${builddir}, please delete them."
 fi
     
 for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do 
@@ -54,8 +54,8 @@ for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
     esac fi
     echo ""
     echo "Applying ${i} using ${type}: " 
-	echo ${i} | cat >> ${targetdir}/.applied_patches_list
-    ${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${targetdir} 
+	echo ${i} | cat >> ${builddir}/.applied_patches_list
+    ${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${builddir}
     if [ $? != 0 ] ; then
         echo "Patch failed!  Please fix $i!"
 	exit 1
@@ -63,10 +63,10 @@ for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
 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 {} \;
Signature · 1 line
1.7.5.4
#7 lore raw

RFC PATCH 2/6 apply-patches.sh: rename targetdir to builddir

Quoted 5 lines · On Monday 06 February 2012 02:47:15 ludovic.desroches at atmel.com wrote:

From: Ludovic Desroches <[email protected]>

targetdir is not the output/target directory as it can suggest.

Signature · 9 lines
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20120210/970c48db/attachment.html>
#8 lore raw

RFC PATCH 3/6 apply-patches.sh: cleanup

In reply to ludovic.desroches at atmel.com

From: Ludovic Desroches <[email protected]>

Add quoting and remove redundant command.

---
 support/scripts/apply-patches.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
support/scripts/apply-patches.sh +2 -2
index 2667d04..2eab05d 100755
@@ -54,8 +54,8 @@ for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
     esac fi
     echo ""
     echo "Applying ${i} using ${type}: " 
-	echo ${i} | cat >> ${builddir}/.applied_patches_list
-    ${uncomp} ${patchdir}/${i} ${uncomp_parm} | ${apply} ${builddir}
+	echo ${i} >> ${builddir}/.applied_patches_list
+    ${uncomp} "${patchdir}/${i}" ${uncomp_parm} | ${apply} "${builddir}"
     if [ $? != 0 ] ; then
         echo "Patch failed!  Please fix $i!"
 	exit 1
Signature · 1 line
1.7.5.4
#9 lore raw

RFC PATCH 3/6 apply-patches.sh: cleanup

Quoted 5 lines · On Monday 06 February 2012 02:47:16 ludovic.desroches at atmel.com wrote:

From: Ludovic Desroches <[email protected]>

Add quoting and remove redundant command.

Signature · 9 lines
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20120210/3d331b84/attachment.html>
#10 lore raw

RFC PATCH 4/6 apply-patches.sh: directories are considered as a collection of patches

In reply to ludovic.desroches at atmel.com

From: Ludovic Desroches <[email protected]>

Behaviour of directories is changed: it is no more considered as an overlay, but rather a collection of patches. Subdirectories are not supported.

---
 support/scripts/apply-patches.sh |   63 ++++++++++++++++++++-----------------
 1 files changed, 34 insertions(+), 29 deletions(-)
support/scripts/apply-patches.sh +34 -29
index 2eab05d..1fc93f6 100755
@@ -11,30 +11,10 @@ patchdir=${2-../kernel-patches}
 shift 2
 patchpattern=${@-*}
 
-if [ ! -d "${builddir}" ] ; then
-    echo "Aborting.  '${builddir}' is not a directory."
-    exit 1
-fi
-if [ ! -d "${patchdir}" ] ; then
-    echo "Aborting.  '${patchdir}' 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 builddir.
-if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
-	echo "There are remaining reject files into ${builddir}, please delete them."
-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
+function apply_patch {
+    path=$1
+    patch=$2
+    case "$patch" in
 	*.gz)
 	type="gzip"; uncomp="gunzip -dc"; ;; 
 	*.bz)
@@ -51,15 +31,40 @@ for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
 	type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;; 
 	*)
 	type="plaintext"; uncomp="cat"; ;; 
-    esac fi
+    esac
     echo ""
-    echo "Applying ${i} using ${type}: " 
-	echo ${i} >> ${builddir}/.applied_patches_list
-    ${uncomp} "${patchdir}/${i}" ${uncomp_parm} | ${apply} "${builddir}"
+    echo "Applying $patch using ${type}: "
+	echo ${1} >> ${builddir}/.applied_patches_list
+    ${uncomp} "${path}/$patch" | patch -g0 -p1 -E -d "${builddir}"
     if [ $? != 0 ] ; then
-        echo "Patch failed!  Please fix $i!"
+        echo "Patch failed!  Please fix $patch!"
 	exit 1
     fi
+}
+
+if [ ! -d "${builddir}" ] ; then
+    echo "Aborting.  '${builddir}' is not a directory."
+    exit 1
+fi
+if [ ! -d "${patchdir}" ] ; then
+    echo "Aborting.  '${patchdir}' 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 builddir.
+if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
+	echo "There are remaining reject files into ${builddir}, please delete them."
+fi
+
+for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
+    if [ -d "${patchdir}/$i" ] ; then
+        for p in `ls -d "$i"` ; do
+	    apply_patch "${patchdir}/${i}" "$p" || exit 1
+	done
+    else
+        apply_patch "$patchdir" "$i" || exit 1
+    fi
 done
 
 # Check for rejects...
Signature · 1 line
1.7.5.4
#11 lore raw

RFC PATCH 4/6 apply-patches.sh: directories are considered as a collection of patches

Quoted 4 lines · On Monday 06 February 2012 02:47:17 ludovic.desroches at atmel.com wrote:

From: Ludovic Desroches <[email protected]>

Behaviour of directories is changed: it is no more considered as an overlay, but rather a collection of patches. Subdirectories are not supported.

Actually, I think the directory feature could be removed completely. It's
not used anywhere at the moment and I don't see why anyone would want to use it.

Quoted 17 lines
---
 support/scripts/apply-patches.sh |   63 ++++++++++++++++++++-----------------
 1 files changed, 34 insertions(+), 29 deletions(-)
support/scripts/apply-patches.sh +0 -4
index 2eab05d..1fc93f6 100755
@@ -11,30 +11,10 @@ patchdir=${2-../kernel-patches}
 shift 2
 patchpattern=${@-*}
 
-if [ ! -d "${builddir}" ] ; then
-    echo "Aborting.  '${builddir}' is not a directory."
-    exit 1
-fi

support/scripts/apply-patches.sh patchdir=${2-../kernel-patches} · line 27

Quoted 10 lines
support/scripts/apply-patches.sh +0 -10
-if [ ! -d "${patchdir}" ] ; then
-    echo "Aborting.  '${patchdir}' 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 builddir.
-if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
-	echo "There are remaining reject files into ${builddir}, please delete them."
-fi

I still think it's better to keep these checks before the definition
of the apply_patch function.

Quoted 19 lines
support/scripts/apply-patches.sh +4 -10
-    
-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
+function apply_patch {
+    path=$1
+    patch=$2
+    case "$patch" in
 	*.gz)
 	type="gzip"; uncomp="gunzip -dc"; ;; 
 	*.bz)
@@ -51,15 +31,40 @@ for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
 	type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;; 

support/scripts/apply-patches.sh for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do · line 37

Quoted 10 lines
support/scripts/apply-patches.sh +3 -4
 	*)
 	type="plaintext"; uncomp="cat"; ;; 
-    esac fi
+    esac
     echo ""
-    echo "Applying ${i} using ${type}: " 
-	echo ${i} >> ${builddir}/.applied_patches_list
-    ${uncomp} "${patchdir}/${i}" ${uncomp_parm} | ${apply} "${builddir}"
+    echo "Applying $patch using ${type}: "
+	echo ${1} >> ${builddir}/.applied_patches_list

Shouldn't this be 'echo $path/$patch' ? Not that it matters that much...

Regards,
Arnout

Signature · 9 lines
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20120210/d6819abf/attachment-0001.html>
#12 lore raw

RFC PATCH 4/6 apply-patches.sh: directories are considered as a collection of patches

Hello Arnout,

Quoted 9 lines · Arnout Vandecappelle
Quoted 5 lines · On Monday 06 February 2012 02:47:17 ludovic.desroches at atmel.com wrote:

From: Ludovic Desroches <[email protected]>

Behaviour of directories is changed: it is no more considered as an

overlay,

Quoted 8 lines
Quoted 1 line

but rather a collection of patches. Subdirectories are not supported.

Actually, I think the directory feature could be removed completely. It's

not used anywhere at the moment and I don't see why anyone would want to use it.

Even if this feature is not used, I think we have to keep it. For instance, into an archive we may have several directories with patches into each of them.

Quoted 8 lines
Quoted 1 line

-# Check for rejects because if there are some, even if patches are

well

Review

Quoted 3 lines
(quoted diff) +0 -2
-# applied, at the end it will complain about rejects into builddir.
 
-if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')'

-print`" ] ; then

Quoted 9 lines
Quoted 1 line

- echo "There are remaining reject files into ${builddir}, please

delete them."

Quoted 1 line

-fi

I still think it's better to keep these checks before the definition

of the apply_patch function.

Unintentional mistake, I will keep these checks.

Quoted 8 lines
Quoted 4 lines

+ echo "Applying $patch using ${type}: "

+ echo ${1} >> ${builddir}/.applied_patches_list

Shouldn't this be 'echo $path/$patch' ? Not that it matters that much...

You're right, I have seen it after sending patches.

Regards

Ludovic

#13 lore raw

RFC PATCH v2 4/6 apply-patches.sh: directories are considered as a collection of patches

From: Ludovic Desroches <[email protected]>

Behaviour of directories is changed: it is no more considered as an overlay, but rather a collection of patches. Subdirectories are not supported.

---
 support/scripts/apply-patches.sh |   33 +++++++++++++++++++--------------
 1 files changed, 19 insertions(+), 14 deletions(-)
support/scripts/apply-patches.sh +19 -14
index 8c38007..3b43e0b 100755
@@ -27,15 +27,10 @@ if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; th
 	echo "Remaining reject files in ${buildir} have been removed"
 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
+function apply_patch {
+    path=$1
+    patch=$2
+    case "$patch" in
 	*.gz)
 	type="gzip"; uncomp="gunzip -dc"; ;; 
 	*.bz)
@@ -52,15 +47,25 @@ for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
 	type="tar"; uncomp="cat"; apply="tar xvf - -C"; ;; 
 	*)
 	type="plaintext"; uncomp="cat"; ;; 
-    esac fi
+    esac
     echo ""
-    echo "Applying ${i} using ${type}: " 
-	echo ${i} >> ${builddir}/.applied_patches_list
-    ${uncomp} "${patchdir}/${i}" ${uncomp_parm} | ${apply} "${builddir}"
+    echo "Applying $patch using ${type}: "
+	echo ${path}/$patch >> ${builddir}/.applied_patches_list
+    ${uncomp} "${path}/$patch" | patch -g0 -p1 -E -d "${builddir}"
     if [ $? != 0 ] ; then
-        echo "Patch failed!  Please fix $i!"
+        echo "Patch failed!  Please fix $patch!"
 	exit 1
     fi
+}
+
+for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
+    if [ -d "${patchdir}/$i" ] ; then
+        for p in `ls -d "$i"` ; do
+	    apply_patch "${patchdir}/${i}" "$p" || exit 1
+	done
+    else
+        apply_patch "$patchdir" "$i" || exit 1
+    fi
 done
 
 # Check for rejects...
Signature · 1 line
1.7.5.4
#14 lore raw

RFC PATCH v2 4/6 apply-patches.sh: directories are considered as a collection of patches

Quoted 4 lines · On Thursday 16 February 2012 00:06:14 ludovic.desroches at atmel.com wrote:

Behaviour of directories is changed: it is no more considered as an overlay, but rather a collection of patches. Subdirectories are not supported.

BTW, if you update a few patches out of a series, it is usually better
to repost the entire series. Otherwise there's a risk of some patches getting lost.

Regards,
Arnout

Signature · 6 lines
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
#15 lore raw

RFC PATCH v2 4/6 apply-patches.sh: directories are considered as a collection of patches

Hello Arnout,

Quoted 4 lines · Arnout Vandecappelle
Quoted 3 lines · On Thursday 16 February 2012 00:06:14 ludovic.desroches at atmel.com wrote:

Behaviour of directories is changed: it is no more considered as an overlay, but rather a collection of patches. Subdirectories are not supported.

Quoted 9 lines
Quoted 1 line

BTW, if you update a few patches out of a series, it is usually better
to repost the entire series. Otherwise there's a risk of some patches getting lost.

Agree, I will try to build more packages in order to see if nothing is broken, then I will publish again the whole series without the RFC tag.

Regards

Ludovic

#16 lore raw

RFC PATCH 4/6 apply-patches.sh: directories are considered as a collection of patches

In reply to Ludovic Desroches
Quoted 17 lines · Ludovic Desroches

Hello Arnout,

Quoted 14 lines · Arnout Vandecappelle
Quoted 5 lines · On Monday 06 February 2012 02:47:17 ludovic.desroches at atmel.com wrote:

From: Ludovic Desroches <[email protected]>

Behaviour of directories is changed: it is no more considered as an

overlay,

Quoted 1 line

but rather a collection of patches. Subdirectories are not supported.

Actually, I think the directory feature could be removed completely. It's

Quoted 6 lines
Quoted 3 lines

not used anywhere at the moment and I don't see why anyone would want to use it.

Even if this feature is not used, I think we have to keep it. For instance, into an archive we may have several directories with patches into each of them.

Reading the Buildroot Developer Day you have sent, keeping this feature may cause issues with versioned patches scheme.

I mean I don't know which parameters will be passed to apply-patches but I worry about having package/foo/ (with some version directories into it) as parameter and then explore and apply all the patches contained into this tree.

I would like to keep it because I was thinking of debian-patches like: a structure with several directories where we may find some patches. From the top of my head I think it's not the case for debian-patches because patches are located at the root level but I presume that we could face this kind of patch.

Regards

Ludovic

#17 lore raw

RFC PATCH 4/6 apply-patches.sh: directories are considered as a collection of patches

Quoted 3 lines · On Thursday 16 February 2012 09:49:53 Ludovic Desroches wrote:

I mean I don't know which parameters will be passed to apply-patches but I worry about having package/foo/ (with some version directories into it) as parameter and then explore and apply all the patches contained into this tree.

I don't think that's an issue, because apply-patches will be called with
*.patch as a pattern - the version-specific directories will not be called *.patch.

Quoted 5 lines

I would like to keep it because I was thinking of debian-patches like: a structure with several directories where we may find some patches. From the top of my head I think it's not the case for debian-patches because patches are located at the root level but I presume that we could face this kind of patch.

If you don't have a concrete use case, I would leave this feature out.
Otherwise you don't even know if it does work in practice. We can always add the feature again later if it turns out to be required.

ThomasDS (in CC) has a use case of a tar file containing patches. Maybe
he has a concrete use case.

Regards,
Arnout

Signature · 6 lines
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
#18 lore raw

RFC PATCH 5/6 apply-patches.sh: add recursivity when scanning patchdir

In reply to ludovic.desroches at atmel.com

From: Ludovic Desroches <[email protected]>

---
 support/scripts/apply-patches.sh |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)
support/scripts/apply-patches.sh +15 -9
index 1fc93f6..3a73ab9 100755
@@ -42,6 +42,20 @@ function apply_patch {
     fi
 }
 
+function scan_patchdir {
+    path=$1
+    shift 1
+    patches=${@-*}
+
+    for i in `cd $path; ls -d $patches 2> /dev/null` ; do
+        if [ -d "${path}/$i" ] ; then
+	    scan_patchdir "${path}/$i"
+        else
+            apply_patch "$path" "$i" || exit 1
+        fi
+    done
+}
+
 if [ ! -d "${builddir}" ] ; then
     echo "Aborting.  '${builddir}' is not a directory."
     exit 1
@@ -57,15 +71,7 @@ if [ "`find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; th
 	echo "There are remaining reject files into ${builddir}, please delete them."
 fi
 
-for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
-    if [ -d "${patchdir}/$i" ] ; then
-        for p in `ls -d "$i"` ; do
-	    apply_patch "${patchdir}/${i}" "$p" || exit 1
-	done
-    else
-        apply_patch "$patchdir" "$i" || exit 1
-    fi
-done
+scan_patchdir $patchdir $patchpattern
 
 # Check for rejects...
 if [ "`find $builddir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then
Signature · 1 line
1.7.5.4
#19 lore raw

RFC PATCH 6/6 apply-patches.sh: change archive management

In reply to ludovic.desroches at atmel.com

From: Ludovic Desroches <[email protected]>

The way archives were managed was incorrect because the uncompressed archives were sent directly to patch command. It means that alphabetical patch orderwas not respected.

---
 support/scripts/apply-patches.sh |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
support/scripts/apply-patches.sh +11 -4
index 3a73ab9..9c2fbb3 100755
@@ -25,10 +25,6 @@ function apply_patch {
 	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
@@ -50,6 +46,17 @@ function scan_patchdir {
     for i in `cd $path; ls -d $patches 2> /dev/null` ; do
         if [ -d "${path}/$i" ] ; then
 	    scan_patchdir "${path}/$i"
+	elif echo "$i" | grep -q -E "tar\.bz$|tbz$|tar.\bz2$|tbz2$|tar\.gz$|tgz$" ; then
+            unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked"
+	    rm -rf "$unpackedarchivedir" 2> /dev/null
+	    mkdir "$unpackedarchivedir"
+	    if echo "$i" | grep "tar\.bz$|tbz$|tar\.bz2$|.tbz2$" ; then
+	        tar_options="-xjf"
+	    else
+	        tar_options="-xzf"
+	    fi
+	    tar -C "$unpackedarchivedir" --strip-components=1 $tar_options "${path}/$i"
+	    scan_patchdir "$unpackedarchivedir"
         else
             apply_patch "$path" "$i" || exit 1
         fi
Signature · 1 line
1.7.5.4
#20 lore raw

RFC PATCH 6/6 apply-patches.sh: change archive management

Quoted 27 lines · On Monday 06 February 2012 02:47:19 ludovic.desroches at atmel.com wrote:

From: Ludovic Desroches <[email protected]>

The way archives were managed was incorrect because the uncompressed archives were sent directly to patch command. It means that alphabetical patch orderwas not respected.

---
 support/scripts/apply-patches.sh |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
support/scripts/apply-patches.sh +0 -4
index 3a73ab9..9c2fbb3 100755
@@ -25,10 +25,6 @@ function apply_patch {
 	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

support/scripts/apply-patches.sh function scan_patchdir { · line 49

Quoted 4 lines
support/scripts/apply-patches.sh +1 -0
@@ -50,6 +46,17 @@ function scan_patchdir {
     for i in `cd $path; ls -d $patches 2> /dev/null` ; do
         if [ -d "${path}/$i" ] ; then
 	    scan_patchdir "${path}/$i"
+	elif echo "$i" | grep -q -E "tar\.bz$|tbz$|tar.\bz2$|tbz2$|tar\.gz$|tgz$" ; then

Wouldn't '\.tar(\..*)?$|\.tbz2?$|\.tgz$' be a better pattern?

support/scripts/apply-patches.sh function scan_patchdir { · line 57

Quoted 8 lines
support/scripts/apply-patches.sh +8 -0
+            unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked"
+	    rm -rf "$unpackedarchivedir" 2> /dev/null
+	    mkdir "$unpackedarchivedir"
+	    if echo "$i" | grep "tar\.bz$|tbz$|tar\.bz2$|.tbz2$" ; then
+	        tar_options="-xjf"
+	    else
+	        tar_options="-xzf"
+	    fi

You can also use tar -xaf, which selects compression automatically.

support/scripts/apply-patches.sh function scan_patchdir { · line 62

Quoted 6 lines
support/scripts/apply-patches.sh +2 -0
+	    tar -C "$unpackedarchivedir" --strip-components=1 $tar_options "${path}/$i"
+	    scan_patchdir "$unpackedarchivedir"
         else
             apply_patch "$path" "$i" || exit 1
         fi

Regards,
Arnout

Signature · 9 lines
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20120210/ce0cbfda/attachment.html>
#21 lore raw

RFC PATCH 6/6 apply-patches.sh: change archive management

Quoted 9 lines · Arnout Vandecappelle
   On Monday 06 February 2012 02:47:19 ludovic.desroches at atmel.com wrote:

   > scan_patchdir "${path}/$i"

   > + elif echo "$i" | grep -q -E
   "tar\.bz$|tbz$|tar.\bz2$|tbz2$|tar\.gz$|tgz$" ; then

   Wouldn't '\.tar(\..*)?$|\.tbz2?$|\.tgz$' be a better pattern?

Of course.

Quoted 10 lines
Quoted 9 lines

+ unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked"

+ rm -rf "$unpackedarchivedir" 2> /dev/null

+ mkdir "$unpackedarchivedir"

+ if echo "$i" | grep "tar\.bz$|tbz$|tar\.bz2$|.tbz2$" ; then

+ tar_options="-xjf"

Quoted 8 lines
Quoted 5 lines

+ else

+ tar_options="-xzf"

+ fi

You can also use tar -xaf, which selects compression automatically.

Thanks for the tip.

Regards

Ludovic

#22 lore raw

RFC PATCH v2 6/6 apply-patches.sh: change archive management

From: Ludovic Desroches <[email protected]>

The way archives were managed was incorrect because the uncompressed archives were sent directly to patch command. It means that alphabetical patch orderwas not respected.

---
 support/scripts/apply-patches.sh |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
support/scripts/apply-patches.sh +6 -4
index d239943..a075afd 100755
@@ -41,10 +41,6 @@ function apply_patch {
 	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
@@ -66,6 +62,12 @@ function scan_patchdir {
     for i in `cd $path; ls -d $patches 2> /dev/null` ; do
         if [ -d "${path}/$i" ] ; then
 	    scan_patchdir "${path}/$i"
+	elif echo "$i" | grep -q -E "\.tar(\..*)?$|\.tbz2?$|\.tgz$" ; then
+            unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked"
+	    rm -rf "$unpackedarchivedir" 2> /dev/null
+	    mkdir "$unpackedarchivedir"
+	    tar -C "$unpackedarchivedir" --strip-components=1 -xaf "${path}/$i"
+	    scan_patchdir "$unpackedarchivedir"
         else
             apply_patch "$path" "$i" || exit 1
         fi
Signature · 1 line
1.7.5.4
#23 lore raw

RFC PATCH v2 6/6 apply-patches.sh: change archive management

Quoted 7 lines · On Thursday 16 February 2012 00:09:59 ludovic.desroches at atmel.com wrote:

From: Ludovic Desroches <[email protected]>

The way archives were managed was incorrect because the uncompressed archives were sent directly to patch command. It means that alphabetical patch orderwas not respected.

support/scripts/apply-patches.sh function scan_patchdir { · line 67

Quoted 3 lines
support/scripts/apply-patches.sh +3 -0
+	elif echo "$i" | grep -q -E "\.tar(\..*)?$|\.tbz2?$|\.tgz$" ; then
+            unpackedarchivedir="$builddir/.patches-$(basename $i)-unpacked"
+	    rm -rf "$unpackedarchivedir" 2> /dev/null

Inconsistent whitespace.

support/scripts/apply-patches.sh function scan_patchdir { · line 73

Quoted 6 lines
support/scripts/apply-patches.sh +3 -0
+	    mkdir "$unpackedarchivedir"
+	    tar -C "$unpackedarchivedir" --strip-components=1 -xaf "${path}/$i"
+	    scan_patchdir "$unpackedarchivedir"
         else
             apply_patch "$path" "$i" || exit 1
         fi

Regards,
Arnout

Signature · 6 lines
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