Install mailmaster via distrobox on other Linux distributions

NetEase Mailmaster(网易邮箱大师 in Chinese) is a mail integrated management platform developed by Netease. It provides a .deb package for Ubuntu 22.04. However, for other distributions and versions, installing it with correct dependencies is a bit toublesome. Using containers is a common way to handle this issue. Distrobox provides fantastic device compatibility between the container and the host, and thus is extremely suitable for GUI application containers.

Installing distrobox

To install distrobox, see the official installation guide.

Create a Ubuntu 22.04 container for mailmaster

Firstly, we shall notice that, mailmaster will be installed in the container under the directory /opt/mailmaster/. However, the /opt directory will not be shared by default distrobox configuration. Hence we add an extra volume command to map the host's /opt directory to the container's /opt, as shown below. This helps ensuring that mailmaster runs normally (otherwise, some functionalities, such as opening the associated file, will not work).

1
2
3
4
5
(host)$ distrobox create \
-n mailmaster-u22 \
--no-entry \
--volume /opt/mailmaster:/opt/mailmaster:ro \
-i ubuntu:22.04

Install the .deb

After that, enter the container, and install the downloaded package from NetEase mailmaster official website.

1
2
3
4
5
(host)$ distrobox enter mailmaster-u22
(mailmaster-u22)$ ls
mail.deb
(mailmaster-u22)$ sudo dpkg -i mail.deb
Error: Read-only file system

However, we find it goes wrong, since /opt/mailmaster is read-only. Even if we use :rw flag above to make it writable, we have not enough permissions to write to /opt/mailmaster.

This is because, podman, the default container runtime of distrobox, runs in rootless mode by default, and the sudo inside the container is a disguised one. We cannot use sudo in the container to get root permissions on the host.

A workaround

A workaround is to use another directory with full permission to "replace" /opt for a while. For example, we could use mount to let ~/tmpdir mounted to /opt:

1
2
(mailmaster-u22)$ mkdir ~/tmpdir
(mailmaster-u22)$ sudo mount --bind ~/tmpdir /opt

Then we can install the package:

1
2
3
(mailmaster-u22)$ sudo dpkg -i mail.deb
(mailmaster-u22)$ sudo apt-get install -f
(mailmaster-u22)$ sudo apt-get install lsb-release zenity qtbase5-dev

And now mailmaster could be run normally:

1
(mailmaster-u22)$ /opt/mailmaster/launch.sh

However, we do not want a strange ~/tmpdir in our home directory, and we shall make use of the mapping /opt/mailmaster/:/opt/mailmaster/:ro we added before. This can be achieved by moving the directory with true sudo on the host, and then we umount the original binding in the container.

1
2
3
4
5
(mailmaster-u22)$ exit
(host)$ sudo mv ~/tmpdir/mailmaster /opt/
(host)$ distrobox enter mailmaster-u22
(mailmaster-u22)$ sudo umount /opt
(mailmaster-u22)$ rmdir ~/tmpdir

Now everything works well!

Export the app

And finally, we use distrobox-export to export our app to host:

1
(mailmaster-u22)$ distrobox-export -el none --app mailmaster

Then a desktop file is generated at ~/.local/share/applications/ and we can run mailmaster from your desktop menu!

Further Reading

Distrobox is quite useful and powerful, not only for exporting GUI applications, but also for developing and testing. For example, if you want to use archlinux without the risk of breaking the system when updating, it is a good choice to create a archlinux container and install the latest packages you like by using distrobox.

For more advanced usage, you can check out the official documentation. I also write another blog here to show my advanced usage of distrobox.