Skip to content

Instantly share code, notes, and snippets.

@steve-todorov
Last active August 22, 2022 21:14
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steve-todorov/f4985c63595438b8f44a684e32a8c4b9 to your computer and use it in GitHub Desktop.
Save steve-todorov/f4985c63595438b8f44a684e32a8c4b9 to your computer and use it in GitHub Desktop.

README

After the 1948278201th time of having to apply this patch manually after a CSGO update I decided it's time for a script. In essense this script will:

  1. Detect the distribution
  2. Install the respective libtcmalloc via the disto's package manager.
  3. Search the lib paths to find the location of libtcmalloc_minimal.so.4
  4. Copy it into the GAMEROOT/bin/linux64 path.

Install

Put the contents of patch-gh-issue-2815.sh in the CounterStricke Global Offensive folder (where csgo.sh and csgo_linux64 are). You can easily find the correct path by going to Steam -> Right click on CS:GO -> Manage -> Browse Local Files.

Run

  • Open a terminal, navigate to the CSGO path (i.e. cd "CSGOPATH")
  • ./patch-gh-issue-2815.sh and hit enter.
  • Open CSGO and have fun after a long day of work.

Supported distros

  • Debian / Ubuntu (I'm using Ubuntu 21.10 and it works for me)
  • Fedora / Centos / RHEL
  • Arch linux
  • On all other distors - the script will try to find libtcmalloc_minimal.so.4 in the OS library paths such as /lib, /lib64, /usr/lib, /usr/lib64 and so on. First match wins.

Disclamer

I'm using this on my personal machine and it works for me. In general it should work for most of you guys, but you never know so use at own risk.

Issues

I don't have much time to look into issues with this script, but if you report I might fix.

See also

#!/bin/sh
set -e
# Copied from csgo.sh script.
GAMEROOT=$(cd "${0%/*}" && echo $PWD)
GAMEROOT_LIB_FILE="$GAMEROOT/bin/linux64/libtcmalloc_minimal.so.0"
echo ""
echo "Auto-patch checklist https://github.com/ValveSoftware/csgo-osx-linux/issues/2815"
echo ""
echo "- Detected GAMEROOT is: ${GAMEROOT}"
[ -f "/etc/os-release" ] || { echo "- Cannot find file /etc/os-release or not readable!"; exit 1; }
. /etc/os-release
echo "- Detected distribution is: ${NAME} ${VERSION_ID}"
# in some cases the ID_LIKE might be missing (i.e. fedora doesn't have it)
[ -z "$ID_LIKE" ] && ID_LIKE="$ID"
# lowercase.
ID_LIKE=`echo "$ID_LIKE" | sed 's/./\L&/g'`
SHOULD_RETURN=false
case "$ID_LIKE" in
debian)
PACKAGES="libtcmalloc-minimal4"
(set -ex; sudo apt update && sudo apt install -y $PACKAGES)
;;
rhel|fedora|centos)
PACKAGES="gperftools"
(set -ex; sudo yum install -y $PACKAGES)
;;
arch)
PACKAGES="gperftools"
(set -ex; sudo pacman -Sy --noconfirm $PACKAGES)
;;
*)
echo "- Unknown distribution - will try to guess!"
SHOULD_RETURN=true
;;
esac
if [ ! -f "${GAMEROOT_LIB_FILE}.orig" ] && [ -f "${GAMEROOT_LIB_FILE}" ]; then
echo "Backing up the original CSGO libtcmalloc_minimal.so.0 file.."
(set -x; cp "${GAMEROOT_LIB_FILE}" "${GAMEROOT_LIB_FILE}.orig")
fi
echo ""
echo "Searching for installed libmtcalloc..."
echo ""
FOUND=false
LIB_DIRS="/lib /lib64 /usr/lib /usr/lib64"
for LIB_DIR in $LIB_DIRS; do
FILE=`find $LIB_DIR/* -name libtcmalloc_minimal.so.4 | head -n 1`
if [ ! -z "${FILE}" ] && [ -f "${FILE}" ]; then
FOUND=true;
echo " Found $FILE"
echo " Copying into $GAMEROOT_LIB_FILE"
cp "$FILE" "$GAMEROOT_LIB_FILE"
break
fi
done
if ! $FOUND; then
echo "Could not find libtcmalloc_minimal.so.4 in none of these locations: $LIB_DIRS"
echo ""
exit 1
fi
echo ""
echo "Done - things should work now."
echo ""
@steve-todorov
Copy link
Author

steve-todorov commented Jan 19, 2022

To avoid noise in my email -- please don't comment unless the script doesn't work.
If it doesn't work - write your distribution, version and the entire log of what happened after you ran the script.

If everything just works and you feel like it - give a star. Thanks!

@zawy12
Copy link

zawy12 commented Feb 13, 2022

I got an error on line 48 due to spaces in the directory name, so I changed it to this to remove the error.
if [ ! -f "${GAMEROOT_LIB_FILE}.orig" ] && [ -f "${GAMEROOT_LIB_FILE}" ]; then

@steve-todorov
Copy link
Author

Thanks for reporting this! I updated the script. :)

@yuntai
Copy link

yuntai commented Mar 20, 2022

good bless you

@steve-todorov
Copy link
Author

@yuntai You too! :)

@ToRRent1812
Copy link

Would You mind adding nobara to this script since it's popular gaming distro based of fedora?

@steve-todorov
Copy link
Author

steve-todorov commented Aug 22, 2022

Hey! I'm currently on a holiday and it might take a while for me to have time to check out nobara distribution. My script checks /etc/os-release and ID_LIKE (or sometimes just ID) to detect if the distribution is Fedora/Centos/Ubuntu/etc. It's highly likely it will already detect nobora (or any other distribution that's forking ubuntu/centos/rhel/fedora). If you do cat /etc/os-release and the ID_LIKE is Fedora then it should work without any changes necessary. Otherwise I could check it out in a few weeks. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment