Software management: Difference between revisions

From Alpine Linux
m (rephrased sentence)
(1. →‎Bubblewrap + Chroot: Enhanced cli illustration for Electron packages; 2. Style/grammar amendments)
 
(24 intermediate revisions by 4 users not shown)
Line 1: Line 1:
This page documents various ways to manage software in Alpine Linux. The official package manager i.e [[Alpine Package Keeper|apk]], a CLI tool can be supplemented by graphical tools like [[#Gnome software|Gnome software]], [[#KDE Discover|KDE Discover]] to manage official software packages and [[#Flatpak|Flatpaks]]. This page also documents ways to [[#Running glibc programs|run software compiled with glibc]].
This page documents various ways to [[#Running glibc programs|run software compiled with glibc]] and to manage software using [[#Graphical software manager|graphical software managers]] in Alpine Linux. There are pages elsewhere regarding compiling [[Compile software from source|software from source]] and for creating a [[Custom Kernel|custom kernel]].


== Alpine package keeper ==
== Alpine package keeper ==
{{Main|Alpine Package Keeper}}
{{Main|Alpine Package Keeper}}
The official package manager in Alpine Linux [[Alpine Package Keeper|Alpine Package Keeper(apk)]] is a cli tool. [[Comparison_with_other_distros#Comparison_chart/Rosetta_Stone|Rosetta stone]] shows how standard package management tasks are done in Alpine Linux compared to other popular distributions.  
The official package manager in Alpine Linux, [[Alpine Package Keeper|Alpine Package Keeper(apk)]], is a ''cli'' tool. [[Comparison_with_other_distros#Comparison_chart/Rosetta_Stone|Rosetta stone]] shows how standard package management tasks are done in Alpine Linux compared to other popular distributions.  


== Graphical software manager ==
== Graphical software manager ==


=== Gnome software ===
The following graphical tools are available to manage official software packages from Alpine Linux [[Repositories|repositories]] and [[#Flatpak|flatpaks]] instead of using the [[#Alpine Package Keeper|cli-based apk tool]].


Gnome [[GNOME#Configuration|Software]] can be used as a GUI front end for Alpine Package Keeper and flatpaks.
=== GNOME software ===
 
[[GNOME#Configuration|GNOME software]] can be used as a GUI front end for apk to manage official software packages and flatpaks.


=== KDE Discover ===
=== KDE Discover ===


KDE [[KDE#Discover|Discover]] can be used as a GUI front end for Alpine Package Keeper and flatpaks.
[[KDE#Discover|KDE Discover]] can be used as a GUI front end for apk to manage official software packages and flatpaks.
 
== AppImage ==
{{Main|AppImage}}
 
AppImages are by far the easiest method for running programs that are not available in the official Alpine Linux [[Repositories|repositories]]. Refer to the [[AppImage]] page for prerequisites and for detailed instructions to run them in Alpine Linux.  


== Flatpak ==
== Flatpak ==
{{Main|Flatpak}}
{{Main|Flatpak}}


[[Flatpak#Installing_Flatpak|Flatpak]] is by far the easiest method for running programs not available in the official Alpine Linux [[Repositories|repositories]]. To use flatpaks, ensure that [[Flatpak#Installing_Flatpak|Flathub repository]] is enabled.
[[Flatpak#Installing_Flatpak|Flatpak]] is an alternative to [[AppImage|AppImages]] for running programs that are not available in the official Alpine Linux [[Repositories|repositories]]. To use flatpaks, ensure that the [[Flatpak#Installing_Flatpak|Flathub repository]] is enabled.


== Running glibc programs ==
== Running glibc programs ==


If you want to run [https://www.gnu.org/software/libc/ glibc] programs in Alpine Linux, there are a few ways of doing so. You can install [[#gcompat|gcompat]] a compatibility layer, or you can install glibc manually alongside [[Musl]], as it isn't packaged, or you could do it the easy way and use [[#Flatpak|Flatpak]] or use [[#Containers|containers]] or do a [[#Chroot|chroot]].
If you want to run [https://www.gnu.org/software/libc/ glibc] programs in Alpine Linux, there are a few ways of doing so.  
 
For simpler binaries, you can install [[#gcompat|gcompat]], which is a compatibility layeror you could do it the easy way and use [[#Flatpak|Flatpaks]] or [[#AppImage|AppImages]]. See [[#Containers|containers]] or the [[#Chroot|chroot]] section for ways to run glibc programs, including graphical ones such as {{ic|VSCode}}, {{ic|google-chrome}}, {{ic|obsidian}}, etc.


=== gcompat ===
=== gcompat ===


[https://git.adelielinux.org/adelie/gcompat gcompat] is a library which provides glibc-compatible APIs for use on musl libc systems like Alpine Linux. To install issue the command: {{cmd|apk add {{pkg|gcompat}}}}
[https://git.adelielinux.org/adelie/gcompat gcompat] is a library that provides glibc-compatible APIs for use on musl libc systems such as Alpine Linux. To install, issue the command: {{cmd|$ doas apk add {{pkg|gcompat}}}}
After that you run your binaries as normal.
After that, you run your binaries as normally.


Refer [[Firefox#DRM_content_using_Widevine_workaround|Firefox]] page for an usage example.
For an usage example, refer to the [[Firefox#DRM_content_using_Widevine_workaround|Firefox]] page where gcompat is used to run the glibc-compiled Widevine binary.


== Chroot ==
== Chroot ==
{{Main|Chroot}}
{{Main|Chroot}}
An option that's easier to generalize to other glibc applications is installing a glibc-based distribution into a chroot. You can then either chroot into it, or use a symlink and some configuration to make its glibc (and associated libraries) usable from Alpine.


After setting up a chroot using any of the methods described below, the loader can be set up in Alpine like so (these instructions are for a Debian chroot in /var/chroots/debian, on x86_64, but can be adapted to other systems by using the appropriate paths):
An option that is easier to generalize to other glibc applications is to install a glibc-based distribution into a chroot. You can then either chroot into it, or use a symlink and some configuration to make its glibc (and associated libraries) usable from Alpine.


{{cmd|mkdir -p /lib64
{{Tip|The most reliable way to enter a chroot is to use the [[Chroot#Enter_chroot|start-chroot]] script.}}
ln -s /var/chroots/debian/lib/x86_64-linux-gnu/ld-2.33.so /lib64
 
printf '/var/chroots/debian/lib/x86_64-linux-gnu\n/var/chroots/debian/usr/lib/x86_64-linux-gnu\n' > /etc/ld.so.conf
After setting up a chroot using any of the methods described below, the loader can be set up in Alpine as follows (these instructions are for a Debian chroot in {{Path|/var/chroots/debian}}, on x86_64, but can be adapted to other systems by using the appropriate paths):
/var/chroots/debian/sbin/ldconfig}}
 
{{cmd|$ doas mkdir -p /lib64
$ doas ln -s /var/chroots/debian/lib/x86_64-linux-gnu/ld-2.33.so /lib64
$ doas printf '/var/chroots/debian/lib/x86_64-linux-gnu\n/var/chroots/debian/usr/lib/x86_64-linux-gnu\n' > /etc/ld.so.conf
$ doas /var/chroots/debian/sbin/ldconfig}}


=== Gentoo Linux ===
=== Gentoo Linux ===


Select a stage3 from [https://www.gentoo.org/downloads/ here] and portage latest from [https://www.gentoo.org/downloads/mirrors/ here] at gentoo/snapshots/portage-latest.tar.xz.
Select a ''stage3'' from [https://www.gentoo.org/downloads/ here] and the ''portage'' latest from [https://www.gentoo.org/downloads/mirrors/ here] at gentoo/snapshots/portage-latest.tar.xz.


First,{{cmd|doas apk add {{pkg|xz}}}}
First,{{cmd|$ doas apk add {{pkg|xz}}}}


Enter the chroot:
Enter the chroot:
{{cmd|mkdir ~/chroot
{{cmd|$ doas mkdir ~/chroot
cd ~/chroot
$ doas cd ~/chroot
tar -xvf stage3-*.tar.xz
$ doas tar -xvf stage3-*.tar.xz
tar -xvf portage-latest.tar.xz
$ doas tar -xvf portage-latest.tar.xz
mv portage usr
$ doas mv portage usr
doas mount --bind /dev dev
$ doas mount --bind /dev dev
doas mount --bind /sys sys
$ doas mount --bind /sys sys
doas mount -t proc proc proc
$ doas mount -t proc proc proc
cp /etc/resolv.conf etc
$ doas cp /etc/resolv.conf etc
doas chroot . /bin/bash}}
$ doas chroot . /bin/bash}}


And voilà, you have your working Gentoo chroot!<br>
And voilà, you have your working Gentoo chroot!<br>


You can now take a look at [https://wiki.gentoo.org/wiki/Handbook:Main_Page Gentoo's Handbook] to find out how you can configure and install your system, or simply extract/copy the program you need to run in your chroot enviroment and execute it.
You can now take a look at [https://wiki.gentoo.org/wiki/Handbook:Main_Page Gentoo's Handbook] to find out how you can configure and install your system, or simply extract/copy the program that you need to run in your chroot enviroment, and then execute it.
 
Here is a wrapper script that is similar to <code>arch-chroot</code> when you frequently reuse this chroot:


Also, create an account with the same user name as host current user to the chroot or make changes to the userspec option to chroot line.
Here is a wrapper script that is similar to {{ic|arch-chroot}} when you frequently reuse this chroot.  Also, create an account with the same username as host current user to the chroot, or make changes to the {{ic|userspec}} option to chroot line:


{{Cat|gentoo-chroot.sh|<nowiki>!/bin/bash
{{Cat|gentoo-chroot.sh|<nowiki>#!/bin/bash
CHROOT_PATH="/home/$USER/chroot"
CHROOT_PATH="/home/$USER/chroot"
cd $CHROOT_PATH
cd $CHROOT_PATH
Line 80: Line 90:
}}
}}


Do at <code>chmod +x gentoo-chroot.sh</code> to get it to work.
Do {{ic|$ chmod +x gentoo-chroot.sh}} to make it executable.


=== Arch Linux ===
=== Arch Linux ===
{{Seealso|Installing ArchLinux inside an Alpine chroot}}
{{Seealso|Installing ArchLinux inside an Alpine chroot}}
Either use '''pacstrap''' (included with the arch-install-scripts package) or an Arch bootstrap image:
Either use '''pacstrap''' (included with the arch-install-scripts package) or an Arch bootstrap image:


{{cmd|doas apk add {{pkg|arch-install-scripts}}
{{cmd|$ doas apk add {{pkg|arch-install-scripts}}
mkdir ~/chroot && cd ~/chroot
$ mkdir ~/chroot && cd ~/chroot
curl -O https://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz
$ curl -O https://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.zst
doas tar xzf archlinux-bootstrap-x86_64.tar.gz && rm archlinux-bootstrap-x86_64.tar.gz
$ doas tar -x --zstd -f archlinux-bootstrap-x86_64.tar.zst && rm archlinux-bootstrap-x86_64.tar.zst
doas sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist
$ doas sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist
doas sed -i '/CheckSpace/s/^/#/' root.x86_64/etc/pacman.conf
$ doas sed -i '/CheckSpace/s/^/#/' root.x86_64/etc/pacman.conf
doas arch-chroot root.x86_64
$ doas arch-chroot root.x86_64
[chroot]# pacman-key --init
[chroot]# pacman-key --init
[chroot]# pacman-key --populate archlinux}}
[chroot]# pacman-key --populate archlinux}}
Line 98: Line 109:
Once that is done, update the system and install the desired package(s) (denoted by ''"foo"'' in this example):
Once that is done, update the system and install the desired package(s) (denoted by ''"foo"'' in this example):
    
    
{{cmd|[chroot]# pacman -Syu ''foo''}}
{{cmd|[chroot]# pacman -Syu <var>foo</var>}}


=== Debian ===
=== Debian ===
{{todo|gresec referencs need to be cleanly removed from this section.}}
Use the provided debootstrap package to create the Debian chroot. <code>--arch</code> is optional, depending of your needs.


On the '''linux-grsec''' kernel, you will need to relax chroot limitations:
Alpine Linux provides the {{pkg|debootstrap}} package to create the Debian chroot. Here are the steps: {{cmd|$ doas apk add debootstrap
$ doas mkdir -p /var/chroots/debian
$ doas debootstrap --arch amd64 stable /var/chroots/debian/ https://deb.debian.org/debian}}


  sudo apk add debootstrap
The {{ic|--arch}} is optional, depending on your needs.
  for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 0 | sudo tee $i; done
  mkdir ~/chroot
  sudo debootstrap --arch=i386 wheezy ~/chroot https://deb.debian.org/debian/
  for i in /proc/sys/kernel/grsecurity/chroot_*; do echo 1 | sudo tee $i; done
  sudo chroot ~/chroot /bin/bash


You can now use <code>apt-get</code> to install needed packages.
For updating the chroot, or for installing packages and their dependencies using {{ic|apt-get}}, mount it, and then login as root:
{{cmd|$ doas mount --bind /dev /var/chroots/debian/dev
$ doas mount --bind /proc /var/chroots/debian/proc
$ doas mount --bind /dev/pts /var/chroots/debian/dev/pts
$ doas chroot /var/chroots/debian /bin/bash
[chroot]# apt update && apt upgrade}}


== Chroot + Bubblewrap ==
After installing the necessary applications and whatever else you might do, exit the chroot:
{{cmd|[chroot]# exit}}


It's also possible to use a Debian system chroot with Bubblewrap. This allows running programs without root.
Then, unmount the binds for /dev/pts, dev and proc to avoid issues:
{{cmd|$ doas umount /var/chroots/debian/dev/pts
$ doas umount /var/chroots/debian/dev
$ doas umount /var/chroots/debian/proc}}


{{cmd|# apk add bubblewrap debootstrap
== Containers ==
&#35; mkdir -p /var/chroots/debian
&#35; debootstrap --arch amd64 stable /var/chroots/debian/ https://deb.debian.org/debian}}


Finally we can make an alias for bwrap.
=== Distrobox + Podman ===


{{cmd|$ alias glibc{{=}}"LANG{{=}}en_US.UTF-8 bwrap --bind /var/chroots/debian / --dev-bind /dev /dev --proc /proc --bind /sys /sys --bind /run /run --bind /home /home --ro-bind /etc/resolv.conf /etc/resolv.conf --ro-bind /etc/passwd /etc/passwd --ro-bind /etc/group /etc/group"}}
[[Distrobox]], combined with [[Podman|podman]] container running in rootless mode, allows to easily run [[Distrobox#Running_graphical_programs|glibc-compiled graphical programs]]. This will not require root privileges once set up.


To run programs that use X11/Xorg you can use:
=== Bubblewrap + Chroot ===
{{cmd|$ alias glibcX11{{=}}"LANG{{=}}en_US.UTF-8 bwrap --bind /var/chroots/debian / --dev-bind /dev /dev --proc /proc --bind /sys /sys --bind /run /run --bind /home /home --ro-bind /etc/resolv.conf /etc/resolv.conf --ro-bind /etc/passwd /etc/passwd --ro-bind /etc/group /etc/group --bind /tmp/.X11-unix/X0 /tmp/.X11-unix/X0 --setenv DISPLAY :0"}}


In this case you might need to use xhost to allow local connections, e.g.:
{{ic|glibc}} and {{ic|glibcX11}} shell aliases are defined interactively using bwrap to create a container with [[Bubblewrap]], using a [[#Debian|Debian chroot]] as its content. It's not just a chroot anymore: it's a bubblewrap-powered isolated environment. This allows for easily running graphical programs and does not require root privileges once installed.
{{cmd|# xhost + local:}}


Now we can invoke glibc-built binaries like so:
[[Install]] the {{pkg|bubblewrap}} package.
{{cmd|$ glibc ./binary}} or {{cmd|$ glibcX11 ./binary}}


For updating the Chroot or installing dependencies we can mount it and then login as root:
Set up [[#Debian|Debian chroot]] at {{path|/var/chroots/debian}} and install necessary glibc applications using {{ic|apt-get}}.
{{cmd|# mount --bind /dev /var/chroots/debian/dev
&#35; mount --bind /proc /var/chroots/debian/proc
&#35; chroot /var/chroots/debian /bin/bash
&#35; apt update && apt upgrade}}


After installing what you might want to umount the binds for dev and proc to avoid issues.
Create a {{ic|glibc}} alias using bwrap in the Alpine Linux host in order to start applications from the [[#Debian|Debian chroot]]:
{{cmd|# umount /var/chroots/debian/dev}}
{{cmd|$ alias glibc{{=}}"LANG{{=}}en_US.UTF-8 bwrap --bind /var/chroots/debian / --dev-bind /dev /dev --proc /proc --bind /sys /sys --bind /run /run --bind /home /home --ro-bind /etc/resolv.conf /etc/resolv.conf --ro-bind /etc/passwd /etc/passwd --ro-bind /etc/group /etc/group"}}
{{cmd|# umount /var/chroots/debian/proc}}


== Containers ==
To run programs that use X11/Xorg, you can use:
{{cmd|$ alias glibcX11{{=}}"LANG{{=}}en_US.UTF-8 bwrap --bind /var/chroots/debian / --dev-bind /dev /dev --proc /proc --bind /sys /sys --bind /run /run --bind /home /home --ro-bind /etc/resolv.conf /etc/resolv.conf --ro-bind /etc/passwd /etc/passwd --ro-bind /etc/group /etc/group --bind /tmp/.X11-unix/X0 /tmp/.X11-unix/X0 --setenv DISPLAY :0"}}


It's also possible to use Docker or Podman containers with a helper like Distrobox. This allows using graphical programs easily and doesn't require root privileges once set up.
In this case, you might need to use {{ic|xhost}} on the Alpine Linux host in order to allow local connections. For example:{{cmd|# xhost + local:}}


{{cmd|# apk add {{pkg|distrobox}}}}
Now we can invoke glibc-built binaries using the alias from the Alpine Linux host, as follows:
{{cmd|$ glibc ./binary}} or {{cmd|$ glibcX11 ./binary}}  


=== Distrobox + Podman ===
When a [[Wayland]] desktop such as [[Sway]] runs without XWayland on the Alpine Linux host, Electron apps need to be started with Ozone Wayland support:


{{cmd|# apk add {{pkg|podman}}}}
* For VS Code (note the use of the {{ic|code}} command):
{{cmd|<nowiki>glibc code --enable-features=UseOzonePlatform --ozone-platform=wayland</nowiki>}}


Then set up rootless Podman by following [[Podman#Running in rootless mode|these steps]].
* For Google Chrome, etc:
{{cmd|<nowiki>glibc google-chrome --enable-features=UseOzonePlatform --ozone-platform=wayland</nowiki>}}


You'll need to mount your root as shared for Distrobox to function.
The flags enforce Wayland rendering, thus avoiding XWayland and improving display, particularly if fractional scaling is also used.


Fill in the file {{path|/etc/local.d/mount-rshared.start}} as follows:{{Cat|/etc/local.d/mount-rshared.start|<nowiki>#!/bin/sh
== See also ==
mount --make-rshared /</nowiki>}}


Mark it as executable:  {{cmd|# chmod +x /etc/local.d/mount-rshared.start}}
Then autostart its service.
{{cmd|# rc-update add local default
&#35; rc-service local start}}
Finally you can create a container using your chosen image.
{{cmd|$ distrobox create --image debian --name debian
$ distrobox enter debian}}
It may also be necessary to allow X authorization for GUI programs to work: {{cmd|$ xhost +si:localuser:$USER}}
== See also ==
* [[Alpine Package Keeper]]
* [[Alpine Package Keeper]]
* [[Installing ArchLinux inside an Alpine chroot]]
* [[Installing ArchLinux inside an Alpine chroot]]
* [[Compile software from source]]
* [[Compile software from source]]
* [[Kernels]]


[[Category:Package Manager]]
[[Category:Package Manager]] [[Category:Development]]
[[Category:Development]]
[[Category:Installation]]

Latest revision as of 16:33, 28 December 2025

This page documents various ways to run software compiled with glibc and to manage software using graphical software managers in Alpine Linux. There are pages elsewhere regarding compiling software from source and for creating a custom kernel.

Alpine package keeper

The official package manager in Alpine Linux, Alpine Package Keeper(apk), is a cli tool. Rosetta stone shows how standard package management tasks are done in Alpine Linux compared to other popular distributions.

Graphical software manager

The following graphical tools are available to manage official software packages from Alpine Linux repositories and flatpaks instead of using the cli-based apk tool.

GNOME software

GNOME software can be used as a GUI front end for apk to manage official software packages and flatpaks.

KDE Discover

KDE Discover can be used as a GUI front end for apk to manage official software packages and flatpaks.

AppImage

AppImages are by far the easiest method for running programs that are not available in the official Alpine Linux repositories. Refer to the AppImage page for prerequisites and for detailed instructions to run them in Alpine Linux.

Flatpak

Flatpak is an alternative to AppImages for running programs that are not available in the official Alpine Linux repositories. To use flatpaks, ensure that the Flathub repository is enabled.

Running glibc programs

If you want to run glibc programs in Alpine Linux, there are a few ways of doing so.

For simpler binaries, you can install gcompat, which is a compatibility layer; or you could do it the easy way and use Flatpaks or AppImages. See containers or the chroot section for ways to run glibc programs, including graphical ones such as VSCode, google-chrome, obsidian, etc.

gcompat

gcompat is a library that provides glibc-compatible APIs for use on musl libc systems such as Alpine Linux. To install, issue the command:

$ doas apk add gcompat

After that, you run your binaries as normally.

For an usage example, refer to the Firefox page where gcompat is used to run the glibc-compiled Widevine binary.

Chroot

An option that is easier to generalize to other glibc applications is to install a glibc-based distribution into a chroot. You can then either chroot into it, or use a symlink and some configuration to make its glibc (and associated libraries) usable from Alpine.

Tip: The most reliable way to enter a chroot is to use the start-chroot script.

After setting up a chroot using any of the methods described below, the loader can be set up in Alpine as follows (these instructions are for a Debian chroot in /var/chroots/debian, on x86_64, but can be adapted to other systems by using the appropriate paths):

$ doas mkdir -p /lib64 $ doas ln -s /var/chroots/debian/lib/x86_64-linux-gnu/ld-2.33.so /lib64 $ doas printf '/var/chroots/debian/lib/x86_64-linux-gnu\n/var/chroots/debian/usr/lib/x86_64-linux-gnu\n' > /etc/ld.so.conf $ doas /var/chroots/debian/sbin/ldconfig

Gentoo Linux

Select a stage3 from here and the portage latest from here at gentoo/snapshots/portage-latest.tar.xz.

First,

$ doas apk add xz

Enter the chroot:

$ doas mkdir ~/chroot $ doas cd ~/chroot $ doas tar -xvf stage3-*.tar.xz $ doas tar -xvf portage-latest.tar.xz $ doas mv portage usr $ doas mount --bind /dev dev $ doas mount --bind /sys sys $ doas mount -t proc proc proc $ doas cp /etc/resolv.conf etc $ doas chroot . /bin/bash

And voilà, you have your working Gentoo chroot!

You can now take a look at Gentoo's Handbook to find out how you can configure and install your system, or simply extract/copy the program that you need to run in your chroot enviroment, and then execute it.

Here is a wrapper script that is similar to arch-chroot when you frequently reuse this chroot. Also, create an account with the same username as host current user to the chroot, or make changes to the userspec option to chroot line:

Contents of gentoo-chroot.sh

#!/bin/bash CHROOT_PATH="/home/$USER/chroot" cd $CHROOT_PATH mount | grep $CHROOT_PATH/dev || doas mount --bind /dev dev mount | grep $CHROOT_PATH/sys || doas mount --bind /sys sys mount | grep $CHROOT_PATH/proc || doas mount -t proc proc proc cp /etc/resolv.conf etc doas chroot --userspec=$USER:users . /bin/bash echo "You must manually unmount $CHROOT_PATH/dev, $CHROOT_PATH/sys, $CHROOT_PATH/proc."

Do $ chmod +x gentoo-chroot.sh to make it executable.

Arch Linux

Either use pacstrap (included with the arch-install-scripts package) or an Arch bootstrap image:

$ doas apk add arch-install-scripts $ mkdir ~/chroot && cd ~/chroot $ curl -O https://mirrors.edge.kernel.org/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.zst $ doas tar -x --zstd -f archlinux-bootstrap-x86_64.tar.zst && rm archlinux-bootstrap-x86_64.tar.zst $ doas sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist $ doas sed -i '/CheckSpace/s/^/#/' root.x86_64/etc/pacman.conf $ doas arch-chroot root.x86_64 [chroot]# pacman-key --init [chroot]# pacman-key --populate archlinux

Once that is done, update the system and install the desired package(s) (denoted by "foo" in this example):

[chroot]# pacman -Syu foo

Debian

Alpine Linux provides the debootstrap package to create the Debian chroot. Here are the steps:

$ doas apk add debootstrap $ doas mkdir -p /var/chroots/debian $ doas debootstrap --arch amd64 stable /var/chroots/debian/ https://deb.debian.org/debian

The --arch is optional, depending on your needs.

For updating the chroot, or for installing packages and their dependencies using apt-get, mount it, and then login as root:

$ doas mount --bind /dev /var/chroots/debian/dev $ doas mount --bind /proc /var/chroots/debian/proc $ doas mount --bind /dev/pts /var/chroots/debian/dev/pts $ doas chroot /var/chroots/debian /bin/bash [chroot]# apt update && apt upgrade

After installing the necessary applications and whatever else you might do, exit the chroot:

[chroot]# exit

Then, unmount the binds for /dev/pts, dev and proc to avoid issues:

$ doas umount /var/chroots/debian/dev/pts $ doas umount /var/chroots/debian/dev $ doas umount /var/chroots/debian/proc

Containers

Distrobox + Podman

Distrobox, combined with podman container running in rootless mode, allows to easily run glibc-compiled graphical programs. This will not require root privileges once set up.

Bubblewrap + Chroot

glibc and glibcX11 shell aliases are defined interactively using bwrap to create a container with Bubblewrap, using a Debian chroot as its content. It's not just a chroot anymore: it's a bubblewrap-powered isolated environment. This allows for easily running graphical programs and does not require root privileges once installed.

Install the bubblewrap package.

Set up Debian chroot at /var/chroots/debian and install necessary glibc applications using apt-get.

Create a glibc alias using bwrap in the Alpine Linux host in order to start applications from the Debian chroot:

$ alias glibc="LANG=en_US.UTF-8 bwrap --bind /var/chroots/debian / --dev-bind /dev /dev --proc /proc --bind /sys /sys --bind /run /run --bind /home /home --ro-bind /etc/resolv.conf /etc/resolv.conf --ro-bind /etc/passwd /etc/passwd --ro-bind /etc/group /etc/group"

To run programs that use X11/Xorg, you can use:

$ alias glibcX11="LANG=en_US.UTF-8 bwrap --bind /var/chroots/debian / --dev-bind /dev /dev --proc /proc --bind /sys /sys --bind /run /run --bind /home /home --ro-bind /etc/resolv.conf /etc/resolv.conf --ro-bind /etc/passwd /etc/passwd --ro-bind /etc/group /etc/group --bind /tmp/.X11-unix/X0 /tmp/.X11-unix/X0 --setenv DISPLAY :0"

In this case, you might need to use xhost on the Alpine Linux host in order to allow local connections. For example:

# xhost + local:

Now we can invoke glibc-built binaries using the alias from the Alpine Linux host, as follows:

$ glibc ./binary

or

$ glibcX11 ./binary

When a Wayland desktop such as Sway runs without XWayland on the Alpine Linux host, Electron apps need to be started with Ozone Wayland support:

  • For VS Code (note the use of the code command):

glibc code --enable-features=UseOzonePlatform --ozone-platform=wayland

  • For Google Chrome, etc:

glibc google-chrome --enable-features=UseOzonePlatform --ozone-platform=wayland

The flags enforce Wayland rendering, thus avoiding XWayland and improving display, particularly if fractional scaling is also used.

See also