0
0
mirror of https://github.com/cucumber-sp/yandex-music-linux.git synced 2024-12-25 06:44:38 +03:00

Add option to disable patches

Additionally try to fix bash regex issues.

Change-Id: I529ae66c323ba1ee489f8cca5af96cc9ffc61cbc
This commit is contained in:
Yury Shvedov 2024-02-11 15:11:59 +03:00
parent fc008fe50c
commit d53f330413

View File

@ -8,16 +8,19 @@ usage() {
echo " Options:" echo " Options:"
echo " -o DIR Path to destination folder" echo " -o DIR Path to destination folder"
echo " -x Extract and fix only to destination folder" echo " -x Extract and fix only to destination folder"
echo " -p Do not apply patches"
echo " -h Show this help and exit" echo " -h Show this help and exit"
} }
exe_location= exe_location=
dst="$PWD/app" dst="$PWD/app"
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
while getopts :xo:h name; do nopatch=0
while getopts :xo:ph name; do
case $name in case $name in
x) extract_only=1 ;; x) extract_only=1 ;;
o) dst="$OPTARG" ;; o) dst="$OPTARG" ;;
p) nopatch=1 ;;
h) h)
usage usage
exit 0 exit 0
@ -81,19 +84,25 @@ done
echo "Title Fixed" echo "Title Fixed"
# applying patches # applying patches
# This function accepts patch file. If it names starts with `XXXX-optional`,
# then this function check is there the variable with tail name of patch and
# prefix patch_ defined to 1 and apply conditionally the patch. So, if the passed
# file has name `0003-optional-some-magic-feature.patch` the function will apply
# it only when the variable `patch_some_magic_feature` defined to `1`.
apply_patch() apply_patch()
{ {
local patchfile patchname local patchfile patchname re
patchfile="$(realpath "$1")" patchfile="$(realpath "$1")"
patchname="$(basename "$patchfile")" patchname="$(basename "$patchfile")"
patchname="${patchname,,}" patchname="${patchname,,}"
re='[[:digit:]]+\-optional\-(.+).patch ]]'
if [[ $patchname =~ [[:digit:]]+\-optional\-(.+).patch ]]; then if [[ $patchname =~ $re ]]; then
patchname="${BASH_REMATCH[1]}" patchname="${BASH_REMATCH[1]}"
patchname="${patchname//[- ]/_}" patchname="${patchname//[- ]/_}"
if eval [ \"\$"patch_$patchname"\" != 1 ]; then if eval [ \"\$"patch_$patchname"\" != 1 ]; then
echo "Shipping patch '$patchfile'" echo "Skipping patch '$patchfile'"
return 0 return 0
fi fi
fi fi
@ -101,20 +110,19 @@ apply_patch()
(cd "$TEMPDIR/app" && patch -p1 < "$patchfile") (cd "$TEMPDIR/app" && patch -p1 < "$patchfile")
} }
for f in $(eval echo "$SCRIPT_DIR"/patches/*); do if [ "$nopatch" != "1" ]; then
apply_patch "$f" for f in $(eval echo "$SCRIPT_DIR"/patches/*.patch); do
done apply_patch "$f"
done
fi
mkdir -p "$dst"
if [ -n "$extract_only" ]; then if [ -n "$extract_only" ]; then
mkdir -p "$dst"
eval cp -r "$TEMPDIR/app/*" "$dst" eval cp -r "$TEMPDIR/app/*" "$dst"
exit 0 exit 0
fi fi
mkdir -p "$dst"
echo "Packing" echo "Packing"
cd "$curdir" cd "$curdir"
asar pack "$TEMPDIR/app" "$dst/yandexmusic.asar" asar pack "$TEMPDIR/app" "$dst/yandexmusic.asar"