Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
ptrcnull | 53441cb0fb | ||
ptrcnull | 8efb7c51b1 | ||
ptrcnull | 0ca9d1c380 | ||
ptrcnull | 24a42cdb5b | ||
ptrcnull | aeae707886 | ||
ptrcnull | 4c668b6c04 |
21
apatch
21
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"
|
||||
|
||||
|
@ -63,11 +64,12 @@ for patch in $source; do
|
|||
done
|
||||
|
||||
header=""
|
||||
if [ -f "$patch" ]; then
|
||||
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,9 +81,9 @@ 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 "$patch partially applied with rejects"
|
||||
warning "$1 partially applied with rejects"
|
||||
for reject in $rejects; do
|
||||
target="${reject%.rej}"
|
||||
msg "trying to wiggle $target"
|
||||
|
@ -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
|
||||
|
@ -102,8 +104,11 @@ fi
|
|||
|
||||
git add .
|
||||
|
||||
msg "saving patch $patch"
|
||||
echo -n "$header" > "$patchpath"
|
||||
msg "saving patch $1"
|
||||
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