Skip to content

Commit 3480658

Browse files
charlypaabose
authored andcommitted
feat: gate linux installer on GLIBC version and disable auto-update for old systems
The new AppImage is built on ubuntu-22.04 (GLIBC 2.35) and cannot run on older systems like Ubuntu 20.04 (GLIBC 2.31). When the installer detects an incompatible GLIBC, it sets "autoUpdate": false in phcode.json to prevent the old version from repeatedly attempting an upgrade that will never succeed. Tested on ubuntu20 (2.31, refused), ubuntu26 (2.43, passed), fedora-44 (2.43, passed).
1 parent 43ca9bd commit 3480658

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

docs/linux/installer-latest-experimental-build.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ DESKTOP_ENTRY="$DESKTOP_DIR/$DESKTOP_ENTRY_NAME"
3535
SCRIPT_NAME="phcode"
3636
BINARY_NAME="phoenix-code"
3737
APPIMAGE_NAME="phoenix-code.AppImage"
38+
MIN_GLIBC_VERSION="2.35"
3839

3940
declare -a MIME_TYPES=(
4041
"text/html"
@@ -488,12 +489,62 @@ downloadAndInstall() {
488489
ensure_runtime_dependencies "$TMP_DIR/$APPIMAGE_NAME"
489490
}
490491

492+
# Returns 0 if the system GLIBC is >= MIN_GLIBC_VERSION, 1 otherwise.
493+
# Uses the same ldd + awk pattern the old GLIBC-matched installer used.
494+
glibc_compatible() {
495+
local cur_ver
496+
cur_ver=$(ldd --version | grep "ldd" | awk '{print $NF}')
497+
echo "Current GLIBC version: $cur_ver"
498+
awk -v min="$MIN_GLIBC_VERSION" -v cur="$cur_ver" \
499+
'BEGIN { min += 0; cur += 0; exit !(min <= cur) }'
500+
}
501+
502+
# On systems whose GLIBC is too old for the new AppImage, disable auto-update
503+
# in the old installation's config so it stops trying to upgrade to a binary
504+
# that cannot run here.
505+
disable_auto_update_old_version() {
506+
local config_path=""
507+
local primary="$HOME/.local/share/io.phcode/phcode.json"
508+
local xdg="${XDG_DATA_HOME:-$HOME/.local/share}/io.phcode/phcode.json"
509+
510+
if [ -f "$primary" ]; then
511+
config_path="$primary"
512+
elif [ "$xdg" != "$primary" ] && [ -f "$xdg" ]; then
513+
config_path="$xdg"
514+
fi
515+
516+
if [ -z "$config_path" ]; then
517+
config_path="$primary"
518+
echo "Creating $config_path..."
519+
mkdir -p "$(dirname "$config_path")"
520+
echo '{"autoUpdate": false}' > "$config_path"
521+
echo -e "${GREEN}Auto-update disabled in $config_path${RESET}"
522+
return 0
523+
fi
524+
525+
echo "Disabling auto-update in $config_path..."
526+
if grep -q '"autoUpdate"' "$config_path"; then
527+
sed -i 's/"autoUpdate"[[:space:]]*:[[:space:]]*[^,}]*/"autoUpdate": false/' "$config_path"
528+
elif grep -q '"' "$config_path"; then
529+
sed -i '0,/{/ s/{/{\n "autoUpdate": false,/' "$config_path"
530+
else
531+
echo '{"autoUpdate": false}' > "$config_path"
532+
fi
533+
echo -e "${GREEN}Auto-update disabled in $config_path${RESET}"
534+
}
535+
491536
# Temporary cleanup for files from older installer versions.
492537
uninstallBetaAppImage() {
493538
rm -f "$LINK_DIR"/phoenix_icon.png
494539
}
495540

496541
install() {
542+
if ! glibc_compatible; then
543+
echo -e "${RED}This system's GLIBC is older than $MIN_GLIBC_VERSION. The new AppImage cannot run here.${RESET}"
544+
disable_auto_update_old_version
545+
exit 1
546+
fi
547+
497548
if [ -f "$LINK_DIR/$SCRIPT_NAME" ] || [ -d "$INSTALL_DIR" ]; then
498549
echo -e "${YELLOW}Phoenix Code appears to be already installed.${RESET}"
499550
if [ ! -t 0 ]; then
@@ -525,6 +576,12 @@ install() {
525576
upgrade() {
526577
echo -e "${YELLOW}Checking for upgrades to Phoenix Code...${RESET}"
527578

579+
if ! glibc_compatible; then
580+
echo -e "${RED}This system's GLIBC is older than $MIN_GLIBC_VERSION. The new AppImage cannot run here.${RESET}"
581+
disable_auto_update_old_version
582+
exit 1
583+
fi
584+
528585
if [ ! -f "$LINK_DIR/$SCRIPT_NAME" ] && [ ! -d "$INSTALL_DIR" ]; then
529586
echo -e "${RED}Phoenix Code is not installed. Please install it first.${RESET}"
530587
exit 1

0 commit comments

Comments
 (0)