apply-patches.sh: change archive management

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

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Tested-by: Ludovic Desroches <ludovic.desroches@atmel.com>
with an armadeus_apf9328_defconfig build
Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
This commit is contained in:
Ludovic Desroches 2012-03-14 16:33:56 +01:00 committed by Peter Korsgaard
parent 1b58957a96
commit 4f9e82da2a

View File

@ -26,12 +26,10 @@ fi
find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print0 | \ find ${builddir}/ '(' -name '*.rej' -o -name '.*.rej' ')' -print0 | \
xargs -0 -r rm -f xargs -0 -r rm -f
for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do function apply_patch {
apply="patch -g0 -p1 -E -d" path=$1
uncomp_parm="" patch=$2
if [ -d "${patchdir}/$i" ] ; then case "$patch" in
echo "${patchdir}/$i skipped"
else case "$i" in
*.gz) *.gz)
type="gzip"; uncomp="gunzip -dc"; ;; type="gzip"; uncomp="gunzip -dc"; ;;
*.bz) *.bz)
@ -42,22 +40,40 @@ for i in `cd ${patchdir}; ls -d ${patchpattern} 2> /dev/null` ; do
type="zip"; uncomp="unzip -d"; ;; type="zip"; uncomp="unzip -d"; ;;
*.Z) *.Z)
type="compress"; uncomp="uncompress -c"; ;; 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"; ;; type="plaintext"; uncomp="cat"; ;;
esac fi esac
echo "" echo ""
echo "Applying ${i} using ${type}: " echo "Applying $patch using ${type}: "
echo ${i} >> ${builddir}/.applied_patches_list echo $patch >> ${builddir}/.applied_patches_list
${uncomp} "${patchdir}/${i}" ${uncomp_parm} | ${apply} "${builddir}" ${uncomp} "${path}/$patch" | patch -g0 -p1 -E -d "${builddir}"
if [ $? != 0 ] ; then if [ $? != 0 ] ; then
echo "Patch failed! Please fix $i!" echo "Patch failed! Please fix ${patch}!"
exit 1 exit 1
fi 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
echo "${path}/$i skipped"
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
done done
}
scan_patchdir $patchdir $patchpattern
# Check for rejects... # Check for rejects...
if [ "`find $builddir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then if [ "`find $builddir/ '(' -name '*.rej' -o -name '.*.rej' ')' -print`" ] ; then