ublue-os / toolboxes

Centralized repository of containers designed for Toolbox/Distrobox
Apache License 2.0
42 stars 10 forks source link

Distrobox update error when running ujust update #73

Closed d1on closed 2 months ago

d1on commented 3 months ago

When running ujust update, the following error occurs:

── 09:44:39 - Distrobox ────────────────────────────────────────────────────────
 Upgrading ubuntu...
distrobox: Installing basic packages...
/usr/bin/apt-get
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://security.ubuntu.com/ubuntu jammy-security InRelease
Hit:4 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  ubuntu-advantage-tools ubuntu-pro-client-l10n
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
 Upgrading bluefin-cli...
/sbin/su-exec
distrobox: Installing basic packages...
/usr/local/bin/xdg-open
BusyBox v1.36.1 (2024-02-08 15:48:36 UTC) multi-call binary.

Usage: su [-lmp] [-s SH] [-] [USER [FILE ARGS | -c 'CMD' [ARG0 ARGS]]]

Run shell under USER (by default, root)

    -,-l    Clear environment, go to home dir, run shell as login shell
    -p,-m   Do not set new $HOME, $SHELL, $USER, $LOGNAME
    -c CMD  Command to pass to 'sh -c'
    -s SH   Shell to use instead of user's default
distrobox: Setting up devpts mounts...
distrobox: Setting up read-only mounts...
distrobox: Setting up read-write mounts...
/usr/bin/entrypoint: line 1459: container_user_name: parameter not set
Error: An error occurred
su-exec: -S: No such file or directory
── 09:44:57 - Summary ──────────────────────────────────────────────────────────
System update: OK
distrobox: IGNORED
Firmware upgrades: OK
Flatpak: OK
Brew: OK
Visual Studio Code extensions: OK
evanphilip commented 2 months ago

I am facing the same issue too.

❯ distrobox-upgrade bluefin-cli 
 Upgrading bluefin-cli...
/sbin/su-exec
distrobox: Installing basic packages...
/usr/local/bin/xdg-open
BusyBox v1.36.1 (2024-03-27 13:51:06 UTC) multi-call binary.

Usage: su [-lmp] [-s SH] [-] [USER [FILE ARGS | -c 'CMD' [ARG0 ARGS]]]

Run shell under USER (by default, root)

    -,-l    Clear environment, go to home dir, run shell as login shell
    -p,-m   Do not set new $HOME, $SHELL, $USER, $LOGNAME
    -c CMD  Command to pass to 'sh -c'
    -s SH   Shell to use instead of user's default
distrobox: Setting up devpts mounts...
distrobox: Setting up read-only mounts...
distrobox: Setting up read-write mounts...
/usr/bin/entrypoint: line 1465: container_user_name: parameter not set
Error: An error occurred
su-exec: -S: No such file or directory

The cause of the issue seems to be the following: Via pull request https://github.com/ublue-os/toolboxes/pull/34 (and subsequent minor edits), the following lines were introduced to Containerfile.bluefin-cli

# Patch /usr/bin/entrypoint
RUN sed -i '/missing_packages=0/,/# Set SHELL to the install path inside the container/ s/^/#/' /usr/bin/entrypoint && \
    sed -i '/# Set SHELL to the install path inside the container/a touch /.containersetupdone' /usr/bin/entrypoint

As a consequence of this, the script entrypoint loses the ability to perform entrypoint --upgrade, since the relevant lines are now commented out. Since distrobox-upgrade calls entrypoint --upgrade under the hood, this lead to the above problem.

evanphilip commented 2 months ago

I don't fully understand the scope of pull request https://github.com/ublue-os/toolboxes/pull/34, so I will need some clarification from @castrojo who initiated that pull request.

As far as I can tell, a container fails to start without internet only if you provide --additional-packages to install. Perhaps we can provide a strong warning if --additional-packages is provided, rather than comment the whole block out? I'd be happy to make a pull request.

castrojo commented 2 months ago

Yeah that might work, or just skip it if there's additional packages.

(Thought this would be ublue-update related but it's not moving back lol)

m2Giles commented 2 months ago

Yeah, we can remove the additional packages from our quadlets.

m2Giles commented 2 months ago

74

evanphilip commented 2 months ago

Thank you for the quick pull request to resolve this issue! Sadly, @m2Giles https://github.com/ublue-os/toolboxes/pull/74 is breaking the ability to start the container without internet.

I had previously assumed the only thing preventing the container from starting without internet was --additional-packages. However, I was wrong. The bluefin-cli image does not have the packages man and pinentry. When /usr/bin/entrypoint executes the following lines

for dep in ${dependencies}; do
        ! command -v "${dep}" > /dev/null && missing_packages=1 && break
done

missing_packages causes all the dependencies to be reinstalled, even if we don't provide any --additional-packages. This prevents the container from starting without internet.

I propose we create a patch in /toolboxes/bluefin-cli/Containerfile.bluefin-cli like before to prevent checking for missing packages (see https://github.com/ublue-os/toolboxes/pull/75).

An alternative fix would be to include all the dependencies listed by distrobox-init in the bluefin-cli image. Most of them are already present, only man and pinentry are missing at the moment.

m2Giles commented 2 months ago

If the packages are available in Wolfi we can add them to the Wolfi toolbox.

If they are not available, the check is just seeing if a command of that name exists so maybe a dummy command will work instead.

evanphilip commented 2 months ago

The package man is available as man-db in Wolfi, so it can be added to the toolbox. pinentry is not available in Wolfi. Creating the dummy command sounds like a great idea! I am hesitant to submit a pull request since I can't (easily) generate images from my fork, so I can't test changes directly to the toolbox image.

castrojo commented 2 months ago

OK try now!