Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Arch Linux toolbox image #710

Closed
wants to merge 1 commit into from
Closed

Add Arch Linux toolbox image #710

wants to merge 1 commit into from

Conversation

erazemk
Copy link
Contributor

@erazemk erazemk commented Feb 25, 2021

This PR builds on the previous tries (#328 and #520) of including an Arch Linux image in toolbox.

The PR adds an Arch Linux image, created from the upstream base-devel branch.

It includes most of the packages that the Fedora-based images do, but currently excludes flatpak (required for flatpak-spawn), since it adds ~690 MB of extra packages/dependencies.

The base-devel image (without any extra packages) is 729 MB, when syncing repositories 741 MB and with all the packages (excluding flatpak) 831 MB, which should be the minimum if based on archlinux:base-devel.

If the final size is very important I can try and base it off of archlinux:latest (which includes only the base packages, not base-devel), but that would still require adding some of the missing packages - although the base image size is 416 MB, which is quite an improvement..

Another option could be to separate latest and base-devel versions into separate images, similarly to what is done with Fedora versions.

I can also add the yay AUR helper if there is a need for it.

This commit adds an Arch Linux image, created from the upstream
base-devel branch.

It includes most of the packages that the Fedora-based images do, but
currently excludes flatpak (required for flatpak-spawn), since it adds
~690 MB of extra packages/dependencies.

The base-devel image (without any extra packages) is 729 MB, when syncing
repositories 741 MB and with all the packages (excluding flatpak) 831
MB, which should be the minimum if based on archlinux:base-devel.
@softwarefactory-project-zuul
Copy link

Build succeeded.

@HarryMichal HarryMichal added 2. Images Images for creating toolbox containers 3. New Feature New feature labels Feb 25, 2021
@xPMo
Copy link
Contributor

xPMo commented Feb 27, 2021

Didn't work for me, but I figured it out.
I saw that a mount was failing by manually starting the container: podman container start --interactive --attach archlinux-toolbox

Adding this line to the Dockerfile fixed that.

RUN touch /etc/machine-id

I also added a sudoers entry for the %wheel group for my own purposes, and swapped to plocate since it's faster.

@erazemk
Copy link
Contributor Author

erazemk commented Feb 27, 2021

I just now realized that the proper way to create and test custom images is by building them and using toolbox create --image to use them with toolbox.

I tried running the container that way, but got the error Error: invalid entry point PID of container, which was fixed by adding /etc/machine-id to the image, like you recommended, but I got the following error:

bash: PROMPT_COMMAND: line 0: syntax error near unexpected token `;'
bash: PROMPT_COMMAND: line 0: ` ; printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'

Do you not get this error and if so, which OS are you using?

@xPMo
Copy link
Contributor

xPMo commented Feb 27, 2021

I'm not getting that error; I'm not sure where that is coming from (it doesn't match any code in toolbox afaik). Maybe that's coming from your ~/.bashrc? That may still be something that can be fixed in the container config, but more likely is just some bad assumption that your bashrc is making. What do you get from grep -A5 PROMPT_COMMAND ~/.bash*?

which OS are you using?

Latest packaged toolbox on an Arch host.

xPMo added a commit to xPMo/toolbox that referenced this pull request Feb 27, 2021
@erazemk
Copy link
Contributor Author

erazemk commented Feb 27, 2021

Maybe that's coming from your ~/.bashrc?

It seems the problem was indeed with this, I use the fish shell, so I don't have a local bashrc file, just the system one (which I haven't changed). This is weird though, since I based the Dockerfile off of the Fedora files, which work normally with toolbox. Copying the root user's bashrc doesn't help either, I still get the same error (even after removing the part that sources /etc/bashrc).

That may still be something that can be fixed in the container config, but more likely is just some bad assumption that your bashrc is making. What do you get from grep -A5 PROMPT_COMMAND ~/.bash*?

When replacing ~/.bash* with /etc/bashrc I get the following output:

   if [ -z "$PROMPT_COMMAND" ]; then
      case $TERM in
      xterm*|vte*)
        if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
            PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
        elif [ "${VTE_VERSION:-0}" -ge 3405 ]; then
            PROMPT_COMMAND="__vte_prompt_command"
        else
            PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
        fi
        ;;
      screen*)
        if [ -e /etc/sysconfig/bash-prompt-screen ]; then
            PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
        else
            PROMPT_COMMAND='printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
        fi
        ;;
      *)
        [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
        ;;
      esac
    fi
    # Turn on parallel history
    shopt -s histappend

@xPMo
Copy link
Contributor

xPMo commented Feb 27, 2021

I use the fish shell, so I don't have a local bashrc file

Yeah, I use Zsh. This tells me that the error is in Arch's bash config. It has this construct in /etc/bash.bashrc:

case ${TERM} in
  xterm*|rxvt*|Eterm|aterm|kterm|gnome*)
    PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'

    ;;
  screen*)
    PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033_%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'
    ;;
esac

Somehow the expansion ${PROMPT_COMMAND:+$PROMPT_COMMAND; } isn't working as intended. It should only happen if PROMPT_COMMAND is already non-empty. Meanwhile toolbox has this:

    if ! [ -f /etc/profile.d/vte.sh ] && [ -z "$PROMPT_COMMAND" ] && [ "${VTE_VERSION:-0}" -ge 3405 ]; then
        case "$TERM" in
            xterm*|vte*)
                [ -n "${BASH_VERSION:-}" ] && PROMPT_COMMAND=" "
                ;;
        esac
    fi

To play nice with Arch, this should be PROMPT_COMMAND=':' instead of a space, OR shouldn't set it at all.

EDIT: The root cause is __vte_prompt_command , defined in /etc/profile.d/vte.sh (in pkg vte-profile) and used in /etc/bashrc (in setup). Conversation and fix here. This fix is recent, so the workaround here is still necessary for Fedora versions <= 33 afaik.

xPMo added a commit to xPMo/toolbox that referenced this pull request Feb 27, 2021
See discussion on containers#710. Other users may also append a prompt command in a similar way.
Making this a `:` instead ensures that an appended command will not cause an error.
Base automatically changed from master to main March 25, 2021 22:25
HarryMichal pushed a commit that referenced this pull request May 24, 2021
@xPMo
Copy link
Contributor

xPMo commented May 24, 2021

debarshiray added a commit to debarshiray/toolbox that referenced this pull request Jun 21, 2021
A subsequent commit will handle a missing containerPath when bind
mounting a regular file like /etc/machine-id. Therefore, it's better to
explicitly state that this code is dealing with a directory.

containers#710
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Jun 21, 2021
Errors thrown from 'toolbox init-container' are usually not shown to
the user. One has to use 'podman start --attach ...' to see them.
Therefore, it's worth adding the extra bit of information to the error.

containers#710
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Jun 21, 2021
Since, /etc/machine-id is bind mounted into the toolbox container from
the host operating system, it doesn't make sense to make it mandatory
for images to have that file. Apparently, (some?) Arch Linux images
don't have /etc/machine-id.

Since a missing containerPath for a directory is handled the same way,
there's no reason not to do the same for regular files. It will make
life a bit easier for those creating toolbox images for different
distributions.

containers#710
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Jun 21, 2021
Since /etc/machine-id is bind mounted into the toolbox container from
the host operating system, it doesn't make sense to make it mandatory
for images to have that file. Apparently, (some?) Arch Linux images
don't have /etc/machine-id.

Since a missing containerPath for a directory is handled the same way,
there's no reason not to do the same for regular files. It will make
life a bit easier for those creating toolbox images for different
distributions.

containers#710
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Jun 22, 2021
A subsequent commit will handle a missing containerPath when bind
mounting a regular file like /etc/machine-id. Therefore, it's better to
explicitly state that this code is dealing with a directory.

containers#710
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Jun 22, 2021
Errors thrown from 'toolbox init-container' are usually not shown to
the user. One has to use 'podman start --attach ...' to see them.
Therefore, it's worth adding the extra bit of information to the error.

containers#710
debarshiray added a commit to debarshiray/toolbox that referenced this pull request Jun 22, 2021
Since /etc/machine-id is bind mounted into the toolbox container from
the host operating system, it doesn't make sense to make it mandatory
for images to have that file. Apparently, (some?) Arch Linux images
don't have /etc/machine-id.

Since a missing containerPath for a directory is handled the same way,
there's no reason not to do the same for regular files. It will make
life a bit easier for those creating toolbox images for different
distributions.

containers#710
@xPMo
Copy link
Contributor

xPMo commented Jul 2, 2021

@erazemk: I closed #716 about the profile errors, Arch's image should add the vte-common package to support VTE terminals on hosts. I updated my arch-img branch to include it.

Additionally, /etc/machine-id being absent is no longer an issue. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. Images Images for creating toolbox containers 3. New Feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants