Skip to content

Commit

Permalink
Auto-Detect patches (Normal and streamboard)
Browse files Browse the repository at this point in the history
Normal patches (-p1) and streamboard-style patches (-p0) are now automatically detected and applied accordingly.

Co-Authored-By: Schimmelreiter <[email protected]>
Co-Authored-By: cojo11 <[email protected]>
  • Loading branch information
3 people committed Jan 26, 2023
1 parent fc06878 commit d66fc76
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
30 changes: 26 additions & 4 deletions support/functions/_patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ _get_patch(){
fi
}

_streamboard_patch(){
if [ -e $1 ]; then
PATCHEDFILES=$(grep -e '^\(---\|+++\) ' -i $1 | grep -v /dev/null | awk '{print $2}' | sort | uniq)
for f in ${PATCHEDFILES[@]}; do
[[ -e "$svndir/$f" ]] && return 0
done
fi
return 1
}

_apply_menupatch(){
[ -f "$workdir/SVN-IS-PATCHED" ] && quicksvnrestore $_toolchainname 2>/dev/null
cd "$pdir"
Expand All @@ -37,8 +47,14 @@ _apply_menupatch(){

_w="ok"
cd "$svndir"
printf "PATCH : apply $e"
patch -f -p1 < "$pdir/$e" >>"$patchlog" 2>/dev/null
if _streamboard_patch "$pdir/$e"; then
SKIPPATHS=-p0
printf "PATCH : apply streamboard-style patch $e"
else
SKIPPATHS=-p1
printf "PATCH : apply regular patch $e"
fi
patch -f $SKIPPATHS < "$pdir/$e" >>"$patchlog" 2>/dev/null
hunks=$(grep -c1 '^Hunk' "$patchlog")
fails=$(grep -c1 'hunks FAILED' "$patchlog")

Expand Down Expand Up @@ -92,8 +108,14 @@ _apply_consolepatch(){

_w=0
cd "$svndir"
printf "$y_l\n | PATCH : apply $e"
patch -F 10 -f -p1 < "$pdir/$e" >>"$patchlog" 2>/dev/null
if _streamboard_patch "$pdir/$e"; then
SKIPPATHS=-p0
printf "$y_l\n | PATCH : apply streamboard-style patch $e\n"
else
SKIPPATHS=-p1
printf "$y_l\n | PATCH : apply regular patch $e\n"
fi
patch -F 10 -f $SKIPPATHS < "$pdir/$e" >>"$patchlog" 2>/dev/null
hunks=$(grep -c1 "^Hunk" "$patchlog")
fails=$(grep -c1 "hunks FAILED" "$patchlog")

Expand Down
7 changes: 6 additions & 1 deletion support/functions/_subversion
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,13 @@ svnpatch(){
for p in "${patchlist[@]}"
do
echo -e $WH"\n -> $p <-"$W
if _streamboard_patch "$pdir/$p"; then
SKIPPATHS=-p0
else
SKIPPATHS=-p1
fi
sleep .5
patch -d$svndir/ -p0 < "$pdir/$p" |sed -e "s/^patching file/$G patching > $WH/g;s/^Hunk/$P Hunk > $Y/g;s/FAILED/$R FAILED/g; ;s/-- saving/$Y -- saving/g;"
patch -d$svndir/ $SKIPPATHS < "$pdir/$p" |sed -e "s/^patching file/$G patching > $WH/g;s/^Hunk/$P Hunk > $Y/g;s/FAILED/$R FAILED/g; ;s/-- saving/$Y -- saving/g;"
done
else
printf $WH" $txt_no patch $txt_found"
Expand Down

0 comments on commit d66fc76

Please sign in to comment.