Snowcaps Mountains with milkyway glaxy visible on the sky

GlibC on Alpine, Chroot it!

Cut to the code

Introduction

Hard

Introduction

Have you ever faced this

User@Host:~$ application
Error relocating /usr/bin/application/libfoo.so.1: foosymbol: symbol not found

Well that is because applications compiled in Glib-C can’t be ran on Musl-C. So what’s the solution? Many!

  • Recompile the application in Musl-C
  • Somehow get Glib-C support in Musl-C

In this article we we’ll look at Getting Glib-C support. for Glib-C support over Recompiling. First of all you should try this simple solution sudo apk add gcompat. This may just solve your problem, if not then there are multiple other ways to run Glib-C application.

  • Flatpak (Easiest solution, but not every application is on flathub)
  • Docker Container
  • GlibMus-HQ
  • Nix-pkg (maybe)
  • Fake Mounts
  • Chroot that has Glib-C

Each of these solutions will eat a few GBs. Yikes! In this article we will look at the last solution

Glib-C Chroot

Alpine wiki has a guide on running Glib-C applications. Among Gentoo and Debian chroots, it has an option to use Arch-chroot, but the guide to it is a little outdated and incomplete, here’s the steps. to use Arch over Gentoo and Debian

sudo apk add arch-install-scripts
mkdir ~/Chroots && cd ~/Chroots # I like to keep my chroots here
# this link was outdated on the wiki
curl -o "https://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-bootstrap-2024.10.01-x86_64.tar.zst"
tar --zstd -xf archlinux-bootstrap-2024.10.01-x86_64.tar.zst
sudo sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist # Commenting out all mirrors
sudo sed -i '/CheckSpace/s/^/#/' root.x86_64/etc/pacman.conf
sudo arch-chroot root.x86_64

then in the chroot Run

pacman-key --init
pacman-key --populate archlinux

Now go inside root.x86_64/etc/pacman.d/mirrorlist (using nano) and uncomment one mirror then run pacman -Syu for system update. Now run pacman -Syu package to install any package.

Important

There is one problem tho, pacman will install from core and extra repos have 265 and ~15000 packages respectively, whereas the AUR (Arch User Repository) has ~94,000 packages! (Source: Arch Package Search) So let’s setup the AUR helper

Setting up AUR (Arch User Repository)

You first need to create a user

useradd -m user
passwd user

Next give the neccesary permissions

  1. edit /etc/sudoers (using nano) and uncomment this line %wheel ALL=(ALL:ALL) NOPASSWD: ALL
  2. then run groupmod -aU user wheel

Now install yay

git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

Now you can install a package yay -S package_name

Caution

Any user can upload any package on AUR, theoretically one could upload malware, disguised as a software, see this forum post and reddit post