#!/bin/bash LATEST_GCC_WORKING_VERSION=14 PATH_TO_BUILD_CONFIG=~/.local/share/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/librocksdb-sys-0.11.0+8.1.1/build.rs GCC_MAJOR=$(gcc -dumpversion | cut -d. -f1) if [ "$GCC_MAJOR" -gt "$LATEST_GCC_WORKING_VERSION" ]; then if grep -q "config.flag(\"-include\").flag(\"cstdint\");" "$PATH_TO_BUILD_CONFIG"; then echo "[+] patch-3 already applied: no need to change build config of librocksdb" else sed -i "/$(printf '%s' "config.compile(\"librocksdb.a\");" | sed 's/[].[*^$\/]/\\&/g')/i \ if !target.contains(\"windows\") {\n config.flag(\"-include\").flag(\"cstdint\");\n }" "$PATH_TO_BUILD_CONFIG" echo "[+] patch-3 will be applied: cstdint included for build config of librocksdb" fi else echo "[+] patch-3 not needed: gcc version is good to compile without patch" fi