Commit graph

19 commits

Author SHA1 Message Date
Ondřej Míchal
7fafcd271e completion/bash: Update completion
Following patches were made:

  - Use toolbox for listing containers/images (assumes the existence of
    cut and tail)
  - Suggest containers for cmd enter
  - Don't suggest --container option
  - Update global options
  - Don't suggest cmd if already specified

The preferred way to provide of a container in commands enter & create
is via an argument.

Since the rewrite in Go, Toolbox provides the --log-level & --log-podman
options. These options deprecate the --verbose & --very-verbose options.

The completion script with this pops already used global options from
the list, handles better cases with different options and suggests log
levels for the --log-level option.

Toolbox can't be used with multiple commands.
2021-05-24 12:35:46 +02:00
Debarshi Ray
120eea449e Remove the deprecated reset command
The Go implementation had deprecated the reset command, right from the
beginning, in favour of 'podman system reset'. It's time to finally
remove it.

https://github.com/containers/toolbox/pull/668
2021-01-12 03:21:35 +01:00
Ondřej Míchal
21d25f88e3 Support RHEL hosts by creating containers based on UBI
https://github.com/containers/toolbox/pull/667
2021-01-12 02:37:47 +01:00
Ondřej Míchal
32d711cc64 Add a --distro option
This is meant to allow the user to create toolbox containers of
operating system distributions that are different from that of the
host and isn't Fedora.

https://github.com/containers/toolbox/pull/667
2021-01-12 02:37:47 +01:00
Debarshi Ray
7c02f93d68 completion, pkg/utils: Update the range of supported Fedora releases
Rawhide currently points to Fedora 34, and Fedora 30 reached End of
Life on 24th November:
https://fedoraproject.org/wiki/End_of_life

https://github.com/containers/toolbox/pull/663
2021-01-08 01:54:08 +01:00
Ondřej Míchal
af87ede1db completion, doc/toolbox-create: Remove --candidate-registry
The --candidate-registry is a lesser known option only supported by
the POSIX shell implementation. The Go never implementation never
offered it, and nobody has felt its absence so far. So, it's safe to
assume that there's no urgent need to port it to Go, and it's better to
not confuse users by mentioning it.

https://github.com/containers/toolbox/pull/662
2021-01-07 21:11:25 +01:00
Harry Míchal
1625ad319f Add a --very-verbose or -vv option
Currently, toolbox(1) offers a --verbose option that only shows debug
information from toolbox(1) itself and the error stream of internal
commands. There's no way to further increase the log level of the
internal commands. It's sometimes very useful to be able to get more
detailed logs from Podman.

This adds a new --very-verbose or -vv option that makes this possible.

This should have been implemented as '--verbose --verbose', which
could be conveniently shortened to '-vv'. This is what flatpak(1)
does. However, due to the lack of built-in command line parsing
facilities in POSIX shell, there's no support for multiple short
options expressed as one single argument. eg., '-vy' doesn't expand to
'-v -y'.

Therefore, a separate --very-verbose or -vv option was added to make
things convenient for the user. It's expected that most people will
refer to this as -vv.

If this option is used, every Podman command in the code is run with
'--log-level debug'. Use wisely, Podman can be 'very verbose'.

https://github.com/containers/toolbox/pull/289
2019-11-19 13:38:41 +01:00
Debarshi Ray
2a099e8049 Add a reset command
The 'reset' command is meant to factory reset the local Podman and
Toolbox installations. Every now and then early adopters and testers of
Toolbox have to do this when their local Podman state has gotten
irrecoverably broken due to some Podman bug.

It's useful to have a command that encapsulates all the steps to do a
factory reset, as opposed to having to spell them out separately. It's
easier to document, helps with user support, and can enable less opaque
error messages that suggest a way forward when nothing is working.

Since this command is meant to be used when the Podman installation is
completely broken, it must avoid using any Podman commands at all
costs. This is why it cannot use 'podman stop' to stop any running
containers, nor can it use 'podman unshare' to delete
~/.local/share/containers when running rootless. Instead, it relies on
the user rebooting the machine for the former, and uses newgidmap(1),
newuidmap(1) and unshare(1) to reimplement 'podman unshare' for the
latter.

Note that when running as root, some care has been taken to avoid
removing directories that might be owned by the operating system. eg.,
on Fedora /var/lib/containers/sigstore is owned by the
containers-common RPM.

https://github.com/containers/toolbox/pull/295
2019-10-21 16:27:41 +02:00
Harry Míchal
a2b1baf43b completion: Make it work with short options
Using the shorter variant of an option was breaking the state machine.
It would stop suggesting accompanying arguments, commands and other
options.

https://github.com/containers/toolbox/pull/292
2019-10-11 17:02:23 +02:00
Harry Míchal
75a513bf10 completion: Offer all commands after --verbose
This fixes an old remnant of the past. Even though the '--verbose'
option may not do anything for the command, it is compatible with all
of them.

https://github.com/containers/toolbox/pull/292
2019-10-11 17:02:21 +02:00
Harry Míchal
7565f96808 completion: Update Fedora Rawhide version
Fedora 31 has already been branched from Rawhide. F32 is the current
Rawhide.

https://github.com/containers/toolbox/pull/292
2019-10-11 16:55:23 +02:00
Harry Míchal
5e63e9ec9b Improve the help or usage output
A new help command has been added which either shows the toolbox(1)
manual or a manual page for a specific command. The '--help' flag is
now identical to the help command and can be placed after the COMMAND
segment in the list of command line arguments.

Due to a bizarre quirk in less(1) [1], the default pager used to render
manuals on most systems, the man(1) invocations need the standard error
stream to point to the controlling terminal, if any, to work. This
interferes with the global redirection of standard error to /dev/null
in the absence of the '--verbose' flag, and is worked around by
redirecting to standard output instead.

[1] It turns out that less(1) tries to open the controlling terminal
    device /dev/tty to get to the keyboard for accepting input.
    However, it doesn't have a controlling terminal when invoked via
    D-Bus to render a manual on the host. It then strangely falls back
    to using the standard error stream to get to the keyboard.

https://github.com/debarshiray/toolbox/pull/200
2019-09-04 20:54:13 +02:00
Casey Jao
c2e41553db Unbreak setting up /home as a symbolic link
The whole idea behind commit 66e982af72 was to set up $HOME and
/home to match the host. Therefore, it's pointless to check if /home
is a symbolic link or not inside the toolbox container. The state of
/home needs to be checked on the host, and then the toolbox container
adjusted accordingly.

One crucial difference is that the toolbox container is created before
its /home can be adjusted. Earlier, there was the user-specific
customized image, whose /home was adjusted first, and then the toolbox
container created from that. This boils down to the following
invocation happening before the symbolic link can be set up:
  podman create --volume "$HOME":$HOME":rslave --workdir "$HOME" ...

As a result, on host operating systems like Fedora 29 where /home is a
symbolic link with $HOME pointing inside it, Podman populates /home
with the user's sub-directory inside the toolbox container. This
prevents the subsequent 'rmdir $HOME' from working, and consequently
kills the container's entry point.

Compare that to Fedora 30 and newer where this problem doesn't occur
because /home is a symbolic link but $HOME points inside the target
/var/home directory.

This is why $HOME is canonicalized before bind mounting it into the
container and the container's working directory is reverted back to the
default (ie. /).

Fallout from 8b84b5e460

https://github.com/debarshiray/toolbox/issues/185
2019-06-17 23:28:34 +02:00
Debarshi Ray
8b84b5e460 Drop the Buildah dependency and the user-specific customized image
This works by configuring the toolbox container after it has been
created, instead of before. The toolbox script itself is mentioned as
the entry point of the container, which does 'exec sleep +Inf' once the
initialization is done.

A new command 'init-container' was added to perform the initialization.
It is primarily meant to be used as the entry point for all toolbox
containers, and must be run inside the container that's to be
initialized. It is not expected to be directly invoked by humans, and
cannot be used on the host.

As a result, the default name for the toolbox containers is now
fedora-toolbox-<version-id>, not fedora-toolbox-<user>-<version-id>.
For backwards compatibility, 'toolbox enter' and 'toolbox run' will
continue to work with containers using the old naming scheme.

https://github.com/debarshiray/toolbox/pull/160
2019-05-16 15:47:33 +02:00
Toni Schmidbauer
2da4cc4634 Add a run command
This makes 'toolbox enter' similar to 'toolbox run $SHELL'.

The 'run' command is meant to spawn arbitrary binaries present inside
the toolbox container. Therefore it doesn't make sense for it to fall
back to /bin/bash, like it does for 'enter' if $SHELL is absent.

It's expected that users might use 'run' to create ad-hoc *.desktop
files. That's why it neither offers to create nor falls back to an
existing container like 'enter' does, because such interactions can't
happen when used in a *.desktop file. It's also a more advanced command
that new users are less likely to be interested in. Hence, this
shouldn't affect usability.

Some changes by Debarshi Ray.

https://github.com/debarshiray/toolbox/pull/76
2019-05-06 15:23:58 +02:00
Debarshi Ray
22b2d40830 completion: Silence SC2207
Otherwise https://www.shellcheck.net/ would complain:
  Line 29:
  COMPREPLY=($(compgen -W "--help --verbose $commands" -- "$2"))
             ^-- SC2207: Prefer mapfile or read -a to split command
               output (or quote to avoid splitting).

See: https://github.com/koalaman/shellcheck/wiki/SC2207
2019-05-02 16:41:25 +02:00
Debarshi Ray
e6c4167ed8 completion: Silence SC2086
Otherwise https://www.shellcheck.net/ would complain:
  Line 28:
  if [ ${COMP_CWORD} -eq 1 ]; then
       ^-- SC2086: Double quote to prevent globbing and word splitting.

See: https://github.com/koalaman/shellcheck/wiki/SC2086
2019-04-26 18:48:20 +02:00
Debarshi Ray
b718fbdcda Ask for confirmation before downloading the base image
Currently, there's no easy way to get the size of the impending
download. Skopeo doesn't offer the size of the OCI image [1] and it's
debatable whether another 23 MB binary ought to be pulled in as a
dependency just for this.

Given that the default fedora-toolbox images are the only base images
available via a public repository, the size of the download is hard
coded to reflect the approximate size of the fedora-toolbox images.
These images are between 451 MB and 483 MB, so 500 MB should be a
reasonably suggestive approximate that shouldn't negatively surprise
users.

[1] https://github.com/containers/skopeo/issues/641

https://github.com/debarshiray/toolbox/issues/134
2019-04-26 18:41:04 +02:00
Florian Müllner
01274dc6a6 completion: Add Bash completion
Make using toolbox a bit more convenient by properly completing its
options. The completions should be complete (that is, there are
completions for all the commands and options shown in --help),
but no attempt is made to filter out conflicting options (for
example "toolbox rm --all my-container").

https://github.com/debarshiray/toolbox/pull/133
2019-04-26 15:44:27 +02:00