Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
ptrcnull | 53441cb0fb | ||
ptrcnull | 8efb7c51b1 | ||
ptrcnull | 0ca9d1c380 | ||
ptrcnull | 24a42cdb5b | ||
ptrcnull | aeae707886 |
15
apatch
15
apatch
|
@ -44,7 +44,8 @@ abuild clean fetch unpack default_prepare
|
|||
startdir="$PWD"
|
||||
srcdir="$startdir/src"
|
||||
. APKBUILD
|
||||
test -n "$builddir" || builddir="$srcdir/$pkgname-$pkgver"
|
||||
unset -f grep cut head git rm mv
|
||||
[ -n "$builddir" ] || builddir="$srcdir/$pkgname-$pkgver"
|
||||
|
||||
patchpath="$startdir/$1"
|
||||
|
||||
|
@ -67,7 +68,8 @@ if [ -f "$patchpath" ]; then
|
|||
msg "patch exists, trying to extract existing message"
|
||||
# try to extract the original header from the patch
|
||||
patch_start=$(grep -En '^(diff --git|--- )' "$patchpath" | cut -d: -f1 | head -n 1)
|
||||
header="$(head -n $(( patch_start - 1 )) "$patchpath"; echo)"
|
||||
header_file="/tmp/$(mktemp -u apatch.XXXXXX)"
|
||||
head -n $(( patch_start - 1 )) "$patchpath" > "$header_file"
|
||||
fi
|
||||
|
||||
(
|
||||
|
@ -79,7 +81,7 @@ fi
|
|||
# if file exists, try to apply
|
||||
if [ -e "$patchpath" ]; then
|
||||
git apply --reject --whitespace=fix "$patchpath" || {
|
||||
rejects="$(git status --porcelain | grep '\?\? .*\.rej$' | cut -c4-)"
|
||||
rejects="$(git status --porcelain | grep -F '??' | grep -F '.rej' | cut -c4-)"
|
||||
if [ -n "$rejects" ]; then
|
||||
warning "$1 partially applied with rejects"
|
||||
for reject in $rejects; do
|
||||
|
@ -92,7 +94,7 @@ fi
|
|||
rm "$target.porig" # left by wiggle
|
||||
done
|
||||
else
|
||||
warning "$patch failed to apply"
|
||||
warning "$1 failed to apply"
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
@ -103,7 +105,10 @@ fi
|
|||
git add .
|
||||
|
||||
msg "saving patch $1"
|
||||
echo -n "$header" > "$patchpath"
|
||||
echo -n > "$patchpath" # empty the file first
|
||||
if [ -n "$header_file" ]; then
|
||||
mv "$header_file" "$patchpath"
|
||||
fi
|
||||
git diff --cached >> "$patchpath"
|
||||
|
||||
if [ ! -s "$patchpath" ]; then
|
||||
|
|
Loading…
Reference in a new issue