Yatopia/scripts/getUpstream.sh
Ivan Pekov 6866737d61
Cleanup scripts
Also added a few more commands and a new script.
2020-09-02 12:45:06 +03:00

50 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
patchdir="$1/patches"
searchtxts=(server api)
i=0
echo "Starting Upstream Patching!"
cd $patchdir
for D in */; do
if [ -d "${D}" ]; then
dnoslash=${D%/*}
if [[ $dnoslash != "server" ]]; then
if [[ $dnoslash != "api" ]]; then
echo "Found $dnoslash directory!"
for file in ${searchtxts[@]}; do
if [ -f "$1/patches/$dnoslash/$file.txt" ]; then
i=0
rm -rf -f "$1/patches/$dnoslash/$file/"
echo "Looking for $file file!"
IFS='&'
read -ra ADDR <<<$(cat $patchdir/$dnoslash/$file.txt)
for patch in ${ADDR[@]}; do
echo "Found $patch in $file!"
echo $1/$dnoslash/patches/$file
for filename in $1/$dnoslash/patches/$file/*.patch; do
filenamend="${filename##*/}"
filenamens=${filenamend%/*}
filenameedited=${filenamens::-6}
filenameedited=${filenameedited:5} # retain the part after the frist slash
if [[ $filenameedited == $patch ]]; then
echo "Found Matching file!"
if [[ $i == 0 ]]; then
echo "Making $file dir in $dnoslash patch dir"
mkdir $1/patches/$dnoslash/$file
fi
((i = i + 1))
printf -v num "%04d" $i
echo "Making ${num}-${patch}.patch file for Yatopia"
cp $1/$dnoslash/patches/$file/$filenamens $1/patches/$dnoslash/$file/"${num}-${patch}.patch"
fi
done
done
IFS=' '
fi
done
$1/scripts/applyUpstream.sh $1 $dnoslash || exit 1
fi
fi
fi
done