From f3a016b67486c66d8aac3683e9a1bd7f6eae753c Mon Sep 17 00:00:00 2001 From: CapCreeperGR Date: Wed, 17 Jul 2024 13:18:31 +0300 Subject: [PATCH] Added Libc information --- config/fetch_script.sh | 1 + main.go | 1 + utils.go | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/config/fetch_script.sh b/config/fetch_script.sh index 67b90f7..ab44e51 100644 --- a/config/fetch_script.sh +++ b/config/fetch_script.sh @@ -5,6 +5,7 @@ echo -e "${C3}Hostname: ${C4}$(cat /etc/hostname)" echo -e "${C3}Kernel: ${C4}$(uname -s) $(uname -r)" echo -e "${C3}Packages: ${C4}$(get_packages)" echo -e "${C3}Shell: ${C4}${USER_SHELL}" +echo -e "${C3}Libc: ${C4}${LIBC}" if [ ! -z "$CPU_MODEL" ]; then echo -e "${C3}CPU: ${C4}${CPU_MODEL} (${CPU_THREADS} threads)"; fi for i in $(seq ${CONNECTED_GPUS}); do gpu="GPU$i" diff --git a/main.go b/main.go index 9070e16..e7f5799 100644 --- a/main.go +++ b/main.go @@ -143,6 +143,7 @@ func SetupFetchEnv() []string { env["DE_WM"] = GetDEWM() env["USER_SHELL"] = GetShell() env["DISPLAY_PROTOCOL"] = GetDisplayProtocol() + env["LIBC"] = GetLibc() monitors := getMonitorResolution() if len(monitors) != 0 { env["CONNECTED_MONITORS"] = strconv.Itoa(len(monitors)) diff --git a/utils.go b/utils.go index 08ab5e4..07cbef6 100644 --- a/utils.go +++ b/utils.go @@ -394,6 +394,24 @@ func getMountedPartitions() []partition { return partitions } +func GetLibc() string { + cmd := exec.Command("/bin/bash", "-c", "find /usr/lib64/ -maxdepth 1 -name 'ld-*' | grep musl") + if err := cmd.Run(); err != nil { + cmd = exec.Command("/bin/bash", "-c", "ldd --version | head -1 | cut -d' ' -f4") + bytes, err := cmd.Output() + if err != nil { + return "Glibc" + } + return "Glibc " + strings.TrimSpace(string(bytes)) + } + cmd = exec.Command("/bin/bash", "-c", "ldd 2>&1 | grep 'Version' | cut -d' ' -f2") + bytes, err := cmd.Output() + if err != nil { + return "Musl" + } + return "Musl " + strings.TrimSpace(string(bytes)) +} + func FormatBytes(bytes uint64) string { var suffixes [6]string suffixes[0] = "B"