Browse Source
cleanup _patch add patch upon patch warning and restore add translation strings en de .pull/16/head
gorgone
5 years ago
5 changed files with 304 additions and 255 deletions
@ -1,97 +1,138 @@ |
|||||
#!/bin/bash |
#!/bin/bash |
||||
|
|
||||
get_patch(){ _get_patch; }; |
get_patch(){ _get_patch; } |
||||
|
|
||||
_get_patch(){ |
_get_patch(){ |
||||
cd $pdir; |
cd $pdir |
||||
[ -f patch.url ] && source patch.url; |
[ -f patch.url ] && source patch.url |
||||
clear; |
clear |
||||
echo -e $C; |
printf $C |
||||
ologo; |
ologo |
||||
echo -e $WH; |
printf $WH; |
||||
[ -f $PATCHNAME ] && echo -e "$Y old patch found\n remove $P$PATCHNAME" && rm -f $PATCHNAME; |
[ -f $PATCHNAME ] && printf "$Y $PATCHNAME $txt_found\n $txt_delete $P$PATCHNAME" && rm -f $PATCHNAME |
||||
echo -e $W" load $PATCHNAME"; |
printf $W"\n $txt_load $PATCHNAME" |
||||
wget -q -O$PATCHNAME $PATCHURL; |
|
||||
[ -f $PATCHNAME ] && echo -e $G" ok$W new $PATCHNAME loaded\n" || echo -e $R" patch not found\n"$W; |
if [[ `wget -S --spider $PATCHURL 2>&1 | grep 'HTTP/1.1 200 OK'` ]] |
||||
}; |
then |
||||
|
wget -q -O$PATCHNAME $PATCHURL |
||||
|
[ -f $PATCHNAME ] && printf $G" ok$W\n\n" |
||||
|
else |
||||
|
printf $R"\n\n $PATCHURL\n\n >> $txt_not_found <<$W\n\n" |
||||
|
fi |
||||
|
} |
||||
|
|
||||
_apply_menupatch(){ |
_apply_menupatch(){ |
||||
[ -f "$workdir/SVN-IS-PATCHED" ] && quicksvnrestore $_toolchainname 2>/dev/null; |
[ -f "$workdir/SVN-IS-PATCHED" ] && quicksvnrestore $_toolchainname 2>/dev/null |
||||
cd "$pdir"; |
cd "$pdir" |
||||
(if [ "$(ls -1 "$pdir"/*.patch 2>/dev/null | wc -l)" -gt "0" ];then |
(if [ "$(ls -1 "$pdir"/*.patch 2>/dev/null | wc -l)" -gt "0" ] |
||||
cd "$pdir"; |
then |
||||
unset patchlist;patchlist=`ls *.patch | sort -st '/' -k1,1`; |
|
||||
patchlog="$(mktemp)"; |
cd "$pdir" |
||||
for e in ${patchlist[@]};do |
unset patchlist |
||||
_w="ok"; |
patchlist=`ls *.patch | sort -st '/' -k1,1` |
||||
cd "$svndir"; |
patchlog="$(mktemp)" |
||||
echo "PATCH : apply $e"; |
|
||||
patch -f -p0 < "$pdir/$e" >>"$patchlog" 2>/dev/null; |
for e in ${patchlist[@]} |
||||
hunks=$(grep -c1 '^Hunk' "$patchlog"); |
do |
||||
fails=$(grep -c1 'hunks FAILED' "$patchlog"); |
|
||||
if [ "$hunks" -gt "0" ];then |
_w="ok" |
||||
echo "PATCH : $hunks x HUNK for $e"; |
cd "$svndir" |
||||
_w="hunk"; |
printf "PATCH : apply $e" |
||||
fi; |
patch -f -p0 < "$pdir/$e" >>"$patchlog" 2>/dev/null |
||||
if [ "$fails" -gt "0" ];then |
hunks=$(grep -c1 '^Hunk' "$patchlog") |
||||
echo "PATCH : $fails x FAILS for $e"; |
fails=$(grep -c1 'hunks FAILED' "$patchlog") |
||||
_w="fail"; |
|
||||
fi; |
if [ "$hunks" -gt "0" ] |
||||
done; |
then |
||||
|
printf "PATCH : $hunks x HUNK for $e" |
||||
|
_w="hunk" |
||||
|
fi |
||||
|
|
||||
|
if [ "$fails" -gt "0" ] |
||||
|
then |
||||
|
printf "PATCH : $fails x FAILS for $e" |
||||
|
_w="fail" |
||||
|
fi |
||||
|
|
||||
|
done |
||||
|
|
||||
case $_w in |
case $_w in |
||||
ok) |
ok) |
||||
echo "PATCH : done all ok"; |
printf "PATCH : done all ok" |
||||
touch "$workdir/SVN-IS-PATCHED";; |
touch "$workdir/SVN-IS-PATCHED";; |
||||
hunk) |
hunk) |
||||
echo "PATCH : done with warnings save $e.log"; |
printf "PATCH : done with warnings save $e.log" |
||||
cat $patchlog >>"$ldir/$e.log"; |
cp -f $patchlog "$ldir/$e.log" |
||||
ln -sf "$ldir/$e.log" "$workdir/lastpatch.log"; |
ln -sf "$ldir/$e.log" "$workdir/lastpatch.log" |
||||
touch "$workdir/SVN-IS-PATCHED";; |
touch "$workdir/SVN-IS-PATCHED";; |
||||
fail) |
fail) |
||||
echo "PATCH : break build save $e.log"; |
printf "PATCH : break build save $e.log" |
||||
cat $patchlog >>"$ldir/$e.log"; |
cp -f $patchlog "$ldir/$e.log" |
||||
ln -sf "$ldir/$e.log" "$workdir/lastpatch.log"; |
ln -sf "$ldir/$e.log" "$workdir/lastpatch.log" |
||||
touch "$workdir/SVN-IS-PATCHED";; |
touch "$workdir/SVN-IS-PATCHED";; |
||||
esac; |
esac |
||||
rm -rf "$patchlog"; |
|
||||
fi;)|"$gui" "$st_" "$bt_" "$title_" "$pb_" 12 62;sleep 2; |
rm -rf "$patchlog" |
||||
}; |
fi;)|"$gui" "$st_" "$bt_" "$title_" "$pb_" 12 62 |
||||
|
sleep 2 |
||||
|
} |
||||
|
|
||||
_apply_consolepatch(){ |
_apply_consolepatch(){ |
||||
if [ ! -f "$workdir/SVN-IS-PATCHED" ];then |
if [ ! -f "$workdir/SVN-IS-PATCHED" ] |
||||
cd "$pdir"; |
then |
||||
if [ "$(ls -1 "$pdir"/*.patch 2>/dev/null | wc -l)" -gt "0" ];then |
|
||||
unset patchlist;patchlist=`ls *.patch | sort -st '/' -k1,1`; |
cd "$pdir" |
||||
patchlog="$(mktemp)"; |
if [ "$(ls -1 "$pdir"/*.patch 2>/dev/null | wc -l)" -gt "0" ] |
||||
for e in ${patchlist[@]};do |
then |
||||
_w=0;cd "$svndir"; |
|
||||
echo -e "$y_l | PATCH : apply $e"; |
unset patchlist;patchlist=`ls *.patch | sort -st '/' -k1,1` |
||||
patch -F 10 -f -p0 < "$pdir/$e" >>"$patchlog" 2>/dev/null; |
patchlog="$(mktemp)" |
||||
hunks=$(grep -c1 "^Hunk" "$patchlog"); |
for e in ${patchlist[@]} |
||||
fails=$(grep -c1 "hunks FAILED" "$patchlog"); |
do |
||||
if [ "$hunks" -gt "0" ];then |
|
||||
echo -e "$y_l | PATCH :$w_l $hunks x HUNK for $e"; |
_w=0 |
||||
_w=1; |
cd "$svndir" |
||||
fi; |
printf "$y_l\n | PATCH : apply $e\n" |
||||
if [ "$fails" -gt "0" ];then |
patch -F 10 -f -p0 < "$pdir/$e" >>"$patchlog" 2>/dev/null |
||||
echo -e "$y_l | PATCH :$r_n FAIL (breaking Build) = $fails"; |
hunks=$(grep -c1 "^Hunk" "$patchlog") |
||||
echo -en "$w_l | RESTORE :$c_w LAST SVN BACKUP in "; |
fails=$(grep -c1 "hunks FAILED" "$patchlog") |
||||
for (( i=6; i>0; i--));do |
|
||||
sleep 1 & echo -en "$i\b"; |
if [ "$hunks" -gt "0" ] |
||||
wait; |
then |
||||
done; |
printf "$y_l\n | PATCH :$w_l $hunks x HUNK for $e" |
||||
|
_w=1 |
||||
|
fi |
||||
|
|
||||
|
if [ "$fails" -gt "0" ] |
||||
|
then |
||||
|
printf "$y_l\n | PATCH :$r_n FAIL (breaking Build) = $fails" |
||||
|
printf "$w_l\n | RESTORE :$c_w LAST SVN BACKUP in " |
||||
|
for (( i=6; i>0; i--)) |
||||
|
do |
||||
|
sleep 1 & echo -en "$i\b" |
||||
|
wait |
||||
|
done |
||||
svnrestore lastsvn; |
svnrestore lastsvn; |
||||
exit; |
exit |
||||
fi; |
fi |
||||
|
|
||||
cat $patchlog >"$ldir/$e.log"; |
cat $patchlog >"$ldir/$e.log"; |
||||
ln -sf "$ldir/$e.log" "$workdir/lastpatch.log"; |
ln -sf "$ldir/$e.log" "$workdir/lastpatch.log"; |
||||
done; |
done |
||||
rm -rf "$patchlog"; |
|
||||
if [ "$_w" -gt "0" ];then echo -e "$y_l | PATCH : done with warnings"; |
rm -rf "$patchlog" |
||||
touch "$workdir/SVN-IS-PATCHED"; |
|
||||
|
if [ "$_w" -gt "0" ] |
||||
|
then |
||||
|
printf "$y_l\n | PATCH : done with warnings" |
||||
|
touch "$workdir/SVN-IS-PATCHED" |
||||
else |
else |
||||
echo -e "$y_l | PATCH :$g_l done all ok$rs_"; |
printf "$y_l\n | PATCH :$g_l done all ok$rs_" |
||||
touch "$workdir/SVN-IS-PATCHED"; |
touch "$workdir/SVN-IS-PATCHED" |
||||
fi; |
fi |
||||
|
|
||||
else |
else |
||||
echo -en "$y_l | PATCH : no patch found\n"; |
printf "$y_l\n | PATCH : no patch found\n" |
||||
fi; |
fi |
||||
fi; |
fi |
||||
}; |
} |
||||
|
Loading…
Reference in new issue