#!/bin/bash

version=4.4.0_1

#get version of glibc
glibc_ver="$(ldd --version | head -n1 | awk '{print $NF}')" # example value: 2.30
maj="$(awk -F. '{print $1}' <<<"$glibc_ver")"
min="$(awk -F. '{print $2}' <<<"$glibc_ver")"

#only use bullseye deb if glibc is 2.30 or greater
if [ $maj -eq 2 ] && [ $min -ge 30 ] || [ $maj -gt 2 ];then
  install_packages https://sonic-pi.net/files/releases/v${version%_*}/sonic-pi_${version}_bullseye.arm64.deb libconfig9 || exit 1
else
  error "User error: Sonic Pi is not available for 64-bit Debian Buster. Either switch to 32-bit Buster, or upgrade to 64-bit Bullseye."
fi
