Salta al contenuto principale

Running glibc programs

Arch Linux: use cmd template.

← Older revision Revision as of 16:34, 15 August 2023
(4 intermediate revisions by the same user not shown)
Line 2: Line 2:


Because there are different use cases, this is just a slight overview about what's possible and what's sensible.<br>
Because there are different use cases, this is just a slight overview about what's possible and what's sensible.<br>


= Your options =
= Your options =
Line 8: Line 7:
== gcompat ==
== gcompat ==


[https://git.adelielinux.org/adelie/gcompat gcompat] is the go-to compatibility layer for Alpine users.
gcompat is the go-to compatibility layer for Alpine users.


  {{cmd|apk add gcompat}}
  {{cmd|apk add {{pkg|gcompat}}}}


After that you run your binaries as normal.
After that you run your binaries as normal.
Line 19: Line 18:
Firstly install it.
Firstly install it.


  {{cmd|apk add flatpak}}
  {{cmd|apk add {{pkg|flatpak}}}}


Then you can run any Flatpak application:
Then you can run any Flatpak application:
Line 88: Line 87:
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:


  sudo apk add arch-install-scripts
{{cmd|sudo apk add arch-install-scripts
  mkdir ~/chroot && cd ~/chroot
mkdir ~/chroot && cd ~/chroot
  sudo tar xzf archlinux-bootstrap-x86_64.tar.gz && rm archlinux-bootstrap-x86_64.tar.gz
sudo tar xzf archlinux-bootstrap-x86_64.tar.gz && rm archlinux-bootstrap-x86_64.tar.gz
  sudo sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist
sudo sed -i '/evowise/s/^#//' root.x86_64/etc/pacman.d/mirrorlist
  sudo sed -i '/CheckSpace/s/^/#/' root.x86_64/etc/pacman.conf
sudo sed -i '/CheckSpace/s/^/#/' root.x86_64/etc/pacman.conf
  sudo arch-chroot root.x86_64
sudo arch-chroot root.x86_64
  [chroot]# pacman-key --init
[chroot]# pacman-key --init
  [chroot]# pacman-key --populate archlinux
[chroot]# pacman-key --populate archlinux}}


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):
    
    
  [chroot]# pacman -Syu ''foo''
{{cmd|[chroot]# pacman -Syu ''foo''}}


=== 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.
Use the provided debootstrap package to create the Debian chroot. <code>--arch</code> is optional, depending of your needs.


Line 121: Line 120:
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.
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.


  # apk add distrobox
{{cmd|# apk add {{pkg|distrobox}}}}


=== Distrobox + Podman ===
=== Distrobox + Podman ===


  # apk add podman
{{cmd|# apk add {{pkg|podman}}}}


Then set up rootless Podman, following [https://wiki.alpinelinux.org/wiki/Podman these steps].
Then set up rootless Podman, following [[Podman|these steps]].
You'll need to mount your root as shared for Distrobox to function.
You'll need to mount your root as shared for Distrobox to function.


Fill in <code>/etc/local.d/mount-rshared.start</code> like so:
Fill in {{path|/etc/local.d/mount-rshared.start}} like so:


  #!/bin/sh
{{cmd|#!/bin/sh
  mount --make-rshared /
mount --make-rshared /}}


Mark it as executable.
Mark it as executable.


  # chmod +x /etc/local.d/mount-rshared.start
{{cmd|# chmod +x /etc/local.d/mount-rshared.start}}


Then autostart its service.
Then autostart its service.


  # rc-update add local default
{{cmd|# rc-update add local default
  # rc-service local start
&#35; rc-service local start}}


Finally you can create a container using your chosen image.
Finally you can create a container using your chosen image.


  $ distrobox create --image debian --name debian
{{cmd|$ distrobox create --image debian --name debian
  $ distrobox enter debian
$ distrobox enter debian}}


It may also be necessary to allow X authorization for GUI programs to work.
It may also be necessary to allow X authorization for GUI programs to work.


  $ xhost +si:localuser:$USER
{{cmd|$ xhost +si:localuser:$USER}}


== Chroot + Bubblewrap ==
== Chroot + Bubblewrap ==
Line 157: Line 156:
It's also possible to use a Debian system chroot with Bubblewrap. This allows running programs without root.
It's also possible to use a Debian system chroot with Bubblewrap. This allows running programs without root.


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


Finally we can make an alias for bwrap.
Finally we can make an alias for bwrap.


  $ 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|$ 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"}}


Now we can invoke glibc-built binaries like so:
Now we can invoke glibc-built binaries like so:
  $ glibc ./binary
{{cmd|$ glibc ./binary}}


For updating the Chroot or installing dependencies we can mount it and then login as root:
For updating the Chroot or installing dependencies we can mount it and then login as root:
  # mount --bind /dev /var/chroots/debian/dev
{{cmd|# mount --bind /dev /var/chroots/debian/dev
  # mount --bind /proc /var/chroots/debian/proc
&#35; mount --bind /proc /var/chroots/debian/proc
  # chroot /var/chroots/debian /bin/bash
&#35; chroot /var/chroots/debian /bin/bash
  # apt update && apt upgrade
&#35; apt update && apt upgrade}}


[[Category:Development]]
[[Category:Development]]
[[Category:Installation]]
[[Category:Installation]]
Distro