Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # This script removes the Electron copy of the C++ library so the system copy
- # can be used instead, but only if doing so is safe.
- lib="libstdc++.so.6"
- if [[ ! -e $lib || ! `which ldd` ]]; then
- # Electron libstdc++ already removed, or ldd not available
- exit 0
- fi
- sys_lib_dir=""
- # Find 64 bit version of system libstdc++
- for dir in /lib64 /usr/lib64 /lib /usr/lib; do
- file="$dir/$lib"
- if [[ -e $file ]]; then
- sys_lib_dir="$dir"
- break
- fi
- done
- if [[ -z "$sys_lib_dir" ]]; then
- # Can't find system libstdc++
- exit 0
- fi
- #########################################################################
- # LD_LIBRAY_PATH env var is used before an ELF file's RUNPATH, so ldd will try
- # linking against the system copy of libstdc++ and report any missing versions.
- export LD_LIBRAY_PATH=$sys_lib_dir
- # libdiscord-rpc.so and the Node.Js files are the ones that link against
- # libstdc++.so
- for file in libdiscord-rpc.so *.node; do
- err=$(ldd $file | grep "version \`GLIBCXX_.* not found")
- if [[ -n "$err" ]] ; then
- exit 0
- fi
- done
- # System copy of lib has all C++ versions we need, so get rid of Electron copy
- # of the library
- mkdir -p UNNEEDED
- mv -f $lib UNNEEDED
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement