-
Notifications
You must be signed in to change notification settings - Fork 0
/
allpatch.sh
executable file
·35 lines (30 loc) · 1.07 KB
/
allpatch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# site_dir can optionally be given as argument $!
site_dir="$HOME/.local/lib/python3.10/site-packages/pywlroots.libs/"
if [ -n "$1" ]; then
site_dir=$1
fi
echo "patching site dir: $site_dir"
echo "patching .."
cd "$site_dir" && echo "found dir to patch" || echo "error"
for f in ./*; do
libname="$(basename "$f")"
version="$(echo "$libname" | grep -oP "\-[^-]*$")"
# remove version suffix from libname
general_libname="${libname%"$version"}"
# find full name of general_libname in /usr/lib64
general_libname_full="/usr/lib64/$general_libname.so"
if [ -f "$general_libname_full" ]; then
echo -n "patching $libname .."
# test if already patched
current_target="$(readlink -f "$f")"
if [ "$current_target" = "$general_libname_full" ]; then
echo "ALREADY GOOD"
continue
fi
rm "$libname" && ln -s "$general_libname_full" "$libname" && echo -e "\e[32mpatched $general_libname\033[0m" || >&2 echo -e "\e[31m## error patching $general_libname\033[0m"
else
>&2 echo -e "\e[31merror: could not find $general_libname_full\033[0m"
fi
done
echo "patch ok"