export: support exporting of system flatpaks and document it, Fix #171

This commit is contained in:
89luca89
2022-03-17 19:14:31 +00:00
parent ad100631f1
commit bf89f72708
2 changed files with 95 additions and 78 deletions
+3 -2
View File
@@ -307,8 +307,8 @@ export_application() {
fi
# Find desktop file for the application to export
desktop_files=$(grep -ril "${exported_app}" /usr/share/applications/* || :)
icon_files=$(find /usr/share/icons /usr/share/pixmaps -iname "*${exported_app}*" 2>/dev/null || :)
desktop_files=$(grep -ril "${exported_app}" /usr/share/applications/* /var/lib/flatpak/exports/share/applications/* || :)
icon_files=$(find /usr/share/icons /usr/share/pixmaps /var/lib/flatpak/exports/share/icons -iname "*${exported_app}*" 2>/dev/null || :)
# Check that we found some desktop files first.
if [ -z "${desktop_files}" ]; then
printf >&2 "Error: cannot find any desktop files.\n"
@@ -326,6 +326,7 @@ export_application() {
icon_home_directory="$(dirname "${icon_file}" |
sed "s|/usr/share/|\/run\/host\/${host_home}/.local/share/|g" |
sed "s|/var/lib/flatpak/exports/share|\/run\/host\/${host_home}/.local/share/|g" |
sed "s|pixmaps|icons|g")"
# check if we're exporting or deleting
+92 -76
View File
@@ -1,15 +1,17 @@
- [Distrobox](README.md)
* [Execute complex commands directly from distrobox-enter](#execute-complex-commands-directly-from-distrobox-enter)
* [Improve distrobox-enter performance](#improve-distrobox-enter-performance)
* [Slow creation on podman and image size getting bigger with distrobox-create](#slow-creation-on-podman-and-image-size-getting-bigger-with-distrobox-create)
* [Container save and restore](#container-save-and-restore)
* [Check used resources](#check-used-resources)
* [Using podman inside a distrobox](#using-podman-inside-a-distrobox)
* [Using docker inside a distrobox](#using-docker-inside-a-distrobox)
* [Using init system inside a distrobox](#using-init-system-inside-a-distrobox)
* [Using distrobox as main cli](#using-distrobox-as-main-cli)
* [Build a Gentoo distrobox container](distrobox_gentoo.md)
* [Build a Dedicated distrobox container](distrobox_custom.md)
- [Execute complex commands directly from distrobox-enter](#execute-complex-commands-directly-from-distrobox-enter)
- [Enable SSH X-Forwarding when SSH-ing in a distrobox](#enable-ssh-x-forwarding-when-ssh-ing-in-a-distrobox)
- [Use distrobox to install different flatpaks from the host](#use-distrobox-to-install-different-flatpaks-from-the-host)
- [Using podman inside a distrobox](#using-podman-inside-a-distrobox)
- [Using docker inside a distrobox](#using-docker-inside-a-distrobox)
- [Using init system inside a distrobox](#using-init-system-inside-a-distrobox)
- [Using distrobox as main cli](#using-distrobox-as-main-cli)
- [Improve distrobox-enter performance](#improve-distrobox-enter-performance)
- [Slow creation on podman and image size getting bigger with distrobox-create](#slow-creation-on-podman-and-image-size-getting-bigger-with-distrobox-create)
- [Container save and restore](#container-save-and-restore)
- [Check used resources](#check-used-resources)
- [Build a Gentoo distrobox container](distrobox_gentoo.md)
- [Build a Dedicated distrobox container](distrobox_custom.md)
---
@@ -34,12 +36,90 @@ SSH X-forwarding by default will not work because the container hostname is diff
You can create a distrobox with will have the same hostname as the host by creating it with the following
init-hook:
`distrobox-create --name test --image your-choosen-image:tag --init-hooks "$(uname -n)" > /etc/hostname`
`distrobox-create --name test --image your-choosen-image:tag --init-hooks '"$(uname -n)" > /etc/hostname'`
This will ensure SSH X-Forwarding will work when SSH-ing inside the distrobox:
`ssh -X myhost distrobox-enter test -- xclock`
## Use distrobox to install different flatpaks from the host
By default distrobox will integrate with host's flatpak directory if present: `/var/lib/flatpak` and obviously
with the $HOME one.
If you want to have a separate system remote between host and container, you can create your distrobox with
the followint init-hook:
`distrobox-create --name test --image your-choosen-image:tag --init-hooks 'umount /var/lib/flatpak'`
After that you'll be able to have separate flatpaks between host and distrobox.
You can procede to export them using `distrobox-export` (for distrobox 1.2.14+)
## Using podman inside a distrobox
If `distrobox` is using `podman` as the container engine, you can use `podman socket` to
control host's podman from inside a `distrobox`, just use:
`podman --remote`
inside the `distrobox` to use it.
It may be necessary to enable the socket on your host system by using:
`systemctl --user enable --now podman.socket`
## Using docker inside a distrobox
You can use `docker` to control host's podman from inside a `distrobox`,
by default if `distrobox` is using docker as a container engine, it will mount the
docker.sock into the container.
So in the container just install `docker`, add yourself to the `docker` group, and
you should be good to go.
## Using init system inside a distrobox
You can use an init system inside the container on supported images. Example of such images are:
- docker.io/almalinux/8-init
- registry.access.redhat.com/ubi7/ubi-init
- registry.access.redhat.com/ubi8/ubi-init
You can use such feature using:
`distrobox create -i docker.io/almalinux/8-init --init --name test`
Note however that in this mode, you'll not be able to access host's processes from within the container.
Example use:
```shell
~$ distrobox create -i docker.io/almalinux/8-init --init --name test
user@test:~$ sudo systemctl enable --now sshd
user@test:~$ sudo systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-01-28 22:54:50 CET; 17s ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 291 (sshd)
```
## Using distrobox as main cli
In case you want (like me) to use your container as the main CLI environment, it comes
handy to use `gnome-terminal` profiles to create a dedicated setup for it:
![Screenshot from 2021-12-19 22-29-08](https://user-images.githubusercontent.com/598882/146691460-b8a5bb0a-a83d-4e32-abd0-4a0ff9f50eb7.png)
Personally, I just bind `Ctrl-Alt-T` to the Distrobox profile and `Super+Enter` to the Host profile.
For other terminals, there are similar features (profiles) or you can set up a dedicated shortcut to
launch a terminal directly in the distrobox
## Improve distrobox-enter performance
If you are experiencing a bit slow performance using `podman` you should enable
@@ -119,67 +199,3 @@ in simple (and scriptable) steps.
`podman system df -v` or `docker system df -v`
## Using podman inside a distrobox
If `distrobox` is using `podman` as the container engine, you can use `podman socket` to
control host's podman from inside a `distrobox`, just use:
`podman --remote`
inside the `distrobox` to use it.
It may be necessary to enable the socket on your host system by using:
`systemctl --user enable --now podman.socket`
## Using docker inside a distrobox
You can use `docker` to control host's podman from inside a `distrobox`,
by default if `distrobox` is using docker as a container engine, it will mount the
docker.sock into the container.
So in the container just install `docker`, add yourself to the `docker` group, and
you should be good to go.
## Using init system inside a distrobox
You can use an init system inside the container on supported images. Example of such images are:
- docker.io/almalinux/8-init
- registry.access.redhat.com/ubi7/ubi-init
- registry.access.redhat.com/ubi8/ubi-init
You can use such feature using:
`distrobox create -i docker.io/almalinux/8-init --init --name test`
Note however that in this mode, you'll not be able to access host's processes from within the container.
Example use:
```shell
~$ distrobox create -i docker.io/almalinux/8-init --init --name test
user@test:~$ sudo systemctl enable --now sshd
user@test:~$ sudo systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2022-01-28 22:54:50 CET; 17s ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 291 (sshd)
```
## Using distrobox as main cli
In case you want (like me) to use your container as the main CLI environment, it comes
handy to use `gnome-terminal` profiles to create a dedicated setup for it:
![Screenshot from 2021-12-19 22-29-08](https://user-images.githubusercontent.com/598882/146691460-b8a5bb0a-a83d-4e32-abd0-4a0ff9f50eb7.png)
Personally, I just bind `Ctrl-Alt-T` to the Distrobox profile and `Super+Enter` to the Host profile.
For other terminals, there are similar features (profiles) or you can set up a dedicated shortcut to
launch a terminal directly in the distrobox