Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalware-current.git;a=commitdiff;h=bf2be8e8862dde0d92d2fce8b65dfc5bc1f8a252
commit bf2be8e8862dde0d92d2fce8b65dfc5bc1f8a252 Author: Michel Hermier <herm...@frugalware.org> Date: Sat Dec 26 18:34:15 2009 +0100 util.sh * Introduce __Fpatch a private function that really does the patch work. * Make Fpatch use __Fpatch so that we can try various patch strategies. diff --git a/source/include/util.sh b/source/include/util.sh index cc8c32e..e1e2694 100644 --- a/source/include/util.sh +++ b/source/include/util.sh @@ -473,7 +473,23 @@ Fdeststrip() { } ### -# * Fpatch(): Apply a patch with -p1 (or -p0 if -p1 fails). Parameter: Patch to +# * __Fpatch(): Internal. Apply a patch with -p0 (or -p1 if -p0 fails). +# Parameter: Patch to apply. +### +__Fpatch() { + local level="0" + if ! patch -Np0 --dry-run -i "$Fsrcdir/$1" >/dev/null; then + if ! patch -Np1 --dry-run -i "$Fsrcdir/$1" >/dev/null; then + return 1 + fi + level="1" + fi + patch -Np$level --no-backup-if-mismatch -i "$Fsrcdir/$1" || Fdie + return 0 +} + +### +# * Fpatch(): Apply a patch. Parameter: Patch to # apply. A ".gz" or ".bz2" suffix will be ingored. ### Fpatch() { @@ -487,12 +503,14 @@ Fpatch() { else i=$1 fi - sed -i 's/\r$//' "$Fsrcdir/$i" - if patch -Np0 --dry-run -i "$Fsrcdir/$i" >/dev/null && \ - ! patch -Np1 --dry-run -i "$Fsrcdir/$i" >/dev/null; then - level="0" + if ! __Fpatch "$i"; then + warning "Patch $i did not apply, trying a dos2unix line ending convertion." + sed -i 's/\r$//' "$Fsrcdir/$i" + if ! __Fpatch "$i"; then + error "Patch $i did not apply at all, check your patch" + Fdie + fi fi - patch -Np$level --no-backup-if-mismatch -i "$Fsrcdir/$i" || Fdie } ### _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git