I am opening this topic to discuss distrobox support in Mageia.
There was an earlier thread https://forums.mageia.org/en/viewtopic.php?f=29&t=15591 but it is closed saying https://wiki.mageia.org/en/Distrobox is updated. There is also an open bug https://bugs.mageia.org/show_bug.cgi?id=32435 for this topic.
Installation of distrobox via official script works and we are able to create containers, but it is only for officially supported distributions. With default setup, we cannot use a Mageia container; container gets 'created' but we cannot 'enter' it. It fails with 'An error has occured' message.
I wanted to be able to use Mageia containers esp Cauldron. So, I have cooked up some potion and it fixes both the issues (availability of package as well as ability to login to Mageia containers). I need your help to refine it.
Please see below the,
- spec file, to build the package (not yet Mageianized)
- Code: Select all
%global debug_package %{nil}
# https://github.com/89luca89/distrobox/issues/127
%global __brp_mangle_shebangs_exclude_from %{_bindir}/distrobox-(export|init|host-exec)$
Name: distrobox
Version: 1.8.2.0
Release: 1
Summary: Another tool for containerized command line environments on Linux
# Automatically converted from old format: GPLv3 - review is highly recommended.
License: GPL-3.0-only
URL: https://github.com/89luca89/distrobox
Source: https://github.com/89luca89/%{name}/archive/refs/tags/%{version}.tar.gz
Patch0: distrobox-init-mga.patch
BuildArch: noarch
Requires: (podman or docker)
Requires: coreutils
Requires: findutils
Requires: grep
Requires: sed
Requires: hicolor-icon-theme
Suggests: bash-completions
%description
Use any linux distribution inside your terminal. Distrobox uses podman
or docker to create containers using the linux distribution of your
choice. Created container will be tightly integrated with the host,
allowing to share the HOME directory of the user, external storage,
external usb devices and graphical apps (X11/Wayland) and audio.
%prep
%autosetup -p1
%build
%install
./install -P %{buildroot}/%{_prefix}
%check
%{buildroot}%{_bindir}/%{name} list -V
for i in create enter export init list rm stop host-exec; do
%{buildroot}%{_bindir}/%{name}-$i -V
done
%files
%license COPYING.md
%{_mandir}/man1/%{name}*
%{_bindir}/%{name}
%{_bindir}/%{name}-create
%{_bindir}/%{name}-enter
%{_bindir}/%{name}-export
%{_bindir}/%{name}-init
%{_bindir}/%{name}-list
%{_bindir}/%{name}-rm
%{_bindir}/%{name}-stop
%{_bindir}/%{name}-host-exec
%{_bindir}/%{name}-ephemeral
%{_bindir}/%{name}-generate-entry
%{_bindir}/%{name}-upgrade
%{_bindir}/%{name}-assemble
%{_datadir}/icons/hicolor/*/apps/terminal-distrobox-icon.png
%{_datadir}/icons/hicolor/scalable/apps/terminal-distrobox-icon.svg
%dir %{_datadir}/bash-completion/completions
%{_datadir}/bash-completion/completions/%{name}*
%{_datadir}/zsh/site-functions
%changelog
- patch to 'distrobox-init' file, to let us login to Mageia containers
- Code: Select all
--- distrobox-init 2025-11-04 16:29:26.965000000 +0000
+++ distrobox-init-sv 2025-11-07 06:22:46.756597025 +0000
@@ -995,6 +995,92 @@
fi
}
+function setup_mga() {
+ # Some packages are named differently in Mageia
+ deps_mga="
+ bash-completion
+ bc
+ bzip2
+ cracklib-dicts
+ curl
+ diffutils
+ dnf-plugins-core
+ findutils
+ glibc
+ glibc-i18ndata
+ gnupg2
+ hostname
+ iproute2
+ iputils
+ keyutils
+ krb5
+ less
+ lib64krb53
+ lib64mesavulkan-drivers
+ lib64nss-mdns2
+ lsof
+ man-db
+ man-pages
+ mesa
+ mtr
+ ncurses
+ openssh-clients
+ pam
+ passwd
+ pigz
+ pinentry
+ procps-ng
+ rsync
+ shadow-utils
+ sudo
+ tcpdump
+ time
+ timezone
+ traceroute
+ tree
+ unzip
+ util-linux
+ vte-profile
+ wget
+ which
+ whois
+ words
+ xauth
+ xz
+ zip
+ "
+
+ # shellcheck disable=SC2086,2046,2248
+ ${manager} install ${flags} -y $(${manager} list -q ${deps_mga} |
+ grep -v "Packages" |
+ grep "$(uname -m)" |
+ cut -d' ' -f1)
+
+ # Following packages need 'reinstall' for Mageia containers to work
+ # - glibc-i18ndata: missing '/usr/share/i18n/charmaps'
+ # - glibc: missing '/usr/bin/localedef' binary and '/usr/lib64/gconv' directory
+ # - cracklibs-dict: missing '/usr/share/cracklib/pw_dict.pwd'
+
+ if [ ! -d /usr/lib64/gconv ]; then
+ mkdir /usr/lib64/gconv
+ fi
+ if [ ! -e /usr/lib64/gconv/gconv-modules.cache ]; then
+ touch /usr/lib64/gconv/gconv-modules.cache
+ fi
+ ( ${manager} reinstall -y glibc 2> /dev/null )
+ ${manager} reinstall -y cracklib-dicts glibc-i18ndata
+ # Following is required as the 'gconv-modules.cache' file is not automatically generated
+ /usr/sbin/iconvconfig
+ if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "$(echo "${HOST_LOCALE}" | tr -d '-')"; then
+ LANG="${HOST_LOCALE}" localedef -i "${HOST_LOCALE_LANG}" -f "${HOST_LOCALE_ENCODING}" "${HOST_LOCALE}"
+ fi
+
+ # Package 'tzdata' is named 'timezone' in Mageia
+ if [ ! -e /usr/share/zoneinfo/UTC ]; then
+ ${manager} reinstall -y timezone
+ fi
+}
+
# setup_dnf will upgrade or setup all packages for dnf/yum based systems.
# Arguments:
# manager: yum or dnf
@@ -1085,26 +1171,31 @@
mesa-vulkan-drivers
vulkan
"
- # shellcheck disable=SC2086,2046,2248
- ${manager} install ${flags} -y $(${manager} list -q ${deps} |
- grep -v "Packages" |
- grep "$(uname -m)" |
- cut -d' ' -f1)
-
- # In case the locale is not available, install it
- # will ensure we don't fallback to C.UTF-8
- if [ ! -e /usr/share/i18n/charmaps ]; then
- ${manager} reinstall -y glibc-common
- fi
- if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "$(echo "${HOST_LOCALE}" | tr -d '-')"; then
- LANG="${HOST_LOCALE}" localedef -i "${HOST_LOCALE_LANG}" -f "${HOST_LOCALE_ENCODING}" "${HOST_LOCALE}"
- fi
- # Ensure we have tzdata installed and populated, sometimes container
- # images blank the zoneinfo directory, so we reinstall the package to
- # ensure population
- if [ ! -e /usr/share/zoneinfo/UTC ]; then
- ${manager} reinstall -y tzdata
+ if [ "$(awk -F'=' 'NR==3 {print $2}' /etc/os-release)" == "mageia" ]; then
+ setup_mga
+ else
+ # shellcheck disable=SC2086,2046,2248
+ ${manager} install ${flags} -y $(${manager} list -q ${deps} |
+ grep -v "Packages" |
+ grep "$(uname -m)" |
+ cut -d' ' -f1)
+
+ # In case the locale is not available, install it
+ # will ensure we don't fallback to C.UTF-8
+ if [ ! -e /usr/share/i18n/charmaps ]; then
+ ${manager} reinstall -y glibc-common
+ fi
+ if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "$(echo "${HOST_LOCALE}" | tr -d '-')"; then
+ LANG="${HOST_LOCALE}" localedef -i "${HOST_LOCALE_LANG}" -f "${HOST_LOCALE_ENCODING}" "${HOST_LOCALE}"
+ fi
+
+ # Ensure we have tzdata installed and populated, sometimes container
+ # images blank the zoneinfo directory, so we reinstall the package to
+ # ensure population
+ if [ ! -e /usr/share/zoneinfo/UTC ]; then
+ ${manager} reinstall -y tzdata
+ fi
fi
# Install additional packages passed at distrbox-create time
I'm neither a programmer nor a packager. All I have done for spec file is to adopt Fedora's and as for the patch file, that was an almost infinte 'check-the-code->adopt->test' cycle.
In the patch file,
a) I have made a custom 'setup_mga' function so that all the Mageia-specific changes are in one place
b) In the 'setup_dnf' section (for dnf based distros) I have put a conditional checking if the distro is 'Mageia' or not
c) In the custom function,
i) I have copied the 'deps' list with changes to package names as used in Mageia. e.g., we do not have glibc-common but glibc-i18ndata, tzdata is timezone etc.
ii) I have put the following code
- Code: Select all
# Reinstalls required for Mageia:
# - glibc-i18ndata - for missing '/usr/share/i18n/charmaps'
# - glibc - for missing '/usr/bin/localedef' and missing dir '/usr/lib64/gconv'
# - cracklibs-dict - for missing '/usr/share/cracklib/pw_dict.pwd'
if [ ! -d /usr/lib64/gconv ]; then
mkdir /usr/lib64/gconv
fi
if [ ! -e /usr/lib64/gconv/gconv-modules.cache ]; then
touch /usr/lib64/gconv/gconv-modules.cache
fi
( ${manager} reinstall -y glibc 2> /dev/null )
${manager} reinstall -y cracklib-dicts glibc-i18ndata
/usr/sbin/iconvconfig
The first two if conditions are required because the 'glibc' inside the container does not have `localedef` binary and there is no `/usr/lib64/gconv` directory. They get created when we reinstall the `glibc` package. However, before it is done, we get error saying `/usr/lib64/gconv/gconv-modules.cache` file is missing and in the script file any error gets trapped and the script EXITs.
You can try creating mageia container and try to login with `distrobox enter -v <container_name>` to see the error messages in detail for each of the changes I have made. Then use the patch to confirm it fixes the issue.
With this custom package, I am able to create Mageia and Cauldron containers, along with Fedora-43 (because I made changes to `setup_dnf` fucntion), Ubuntu, Arch and Alpine.
