Commit graph

210 commits

Author SHA1 Message Date
Debarshi Ray
3c4c439f69 Prepare 0.0.9 2019-04-30 12:29:09 +02:00
Debarshi Ray
05da8023b4 doc/toolbox-enter: Mention the 'initial setup' and fallback behaviour
https://github.com/debarshiray/toolbox/issues/128
2019-04-30 12:19:36 +02:00
Debarshi Ray
97f4e072d5 Make profile.d/toolbox.sh available inside the toolbox container
This is a continuation of abb2ac6fd4
2019-04-29 21:04:28 +02:00
Debarshi Ray
c7b7fa1867 Set TOOLBOX_CONTAINER in the environment to identify as a toolbox
This is a lot more clear and explicit than TOOLBOX_PATH, which is more
of an implementation detail to bind mount the toolbox script inside the
toolbox container.

https://github.com/debarshiray/toolbox/pull/142
2019-04-29 20:39:23 +02:00
Debarshi Ray
55f26aff98 Make 'toolbox enter' create or fall back to a container when possible
When there aren't any toolbox containers, 'toolbox enter' will offer to
create a new container matching the same parameters passed to the
command.

If 'toolbox enter' was invoked with the default parameters, and
there's just one toolbox container available, then it will fall back
to it.

https://github.com/debarshiray/toolbox/issues/128
2019-04-29 20:09:47 +02:00
Debarshi Ray
611594675c Make the 'toolbox enter' suggestion in create() optional
A subsequent commit will make 'toolbox enter' smarter. It will suggest
creating a new toolbox container if none is present, or fallback to an
existing container if only one is present.

There's won't be any need for the command suggestion when a toolbox
container gets created by the 'toolbox enter' command itself. The
suggested command would be the same as the one the user would have had
entered.

https://github.com/debarshiray/toolbox/issues/128
2019-04-29 20:01:47 +02:00
Debarshi Ray
193a453972 Split out the code to ask the user for confirmation
A subsequent commit will leverage this to make 'toolbox enter' smarter.
It will suggest creating a new toolbox container if none is present,
or fallback to an existing container if only one is present.

https://github.com/debarshiray/toolbox/issues/128
2019-04-29 20:01:47 +02:00
Debarshi Ray
1c9a626357 Split out the code to list the names of all toolbox containers
A subsequent commit will leverage this to make 'toolbox enter'
smarter. It will suggest creating a new toolbox container if none is
present, or fallback to an existing container if only one is present.

https://github.com/debarshiray/toolbox/issues/128
2019-04-29 20:01:47 +02:00
Debarshi Ray
f552bcb6c8 Return a code to the caller instead of exiting directly
This reduces the side-effects of functions, and makes them more modular
and flexible.

A subsequent commit will leverage this to make 'toolbox enter' smarter
by automatically offering to create a new toolbox if none is present.

https://github.com/debarshiray/toolbox/issues/128
2019-04-29 20:01:47 +02:00
Debarshi Ray
d3a0ec590a Quote a few variables to avoid triggering SC2086 in future
See: https://github.com/koalaman/shellcheck/wiki/SC2086

https://github.com/debarshiray/toolbox/pull/141
2019-04-29 20:00:28 +02:00
Debarshi Ray
a0dc55c87e Return a code to the caller instead of exiting directly
This reduces the side-effects of functions, and makes them more modular
and flexible.
2019-04-29 19:28:42 +02:00
Debarshi Ray
2f5e8a53cd Make the return code explicit
It makes things more obvious. Especially since the return codes for the
error paths are also explicit.
2019-04-29 19:26:27 +02:00
Debarshi Ray
99f8652b15 Don't prompt for localhost and cached base images
Fallout from b718fbdcda

https://github.com/debarshiray/toolbox/issues/134
2019-04-29 17:43:11 +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
Andre Moreira Magalhaes
ca9ca9a3de Set default release to 29 when running on non-fedora hosts
https://github.com/debarshiray/toolbox/issues/131
2019-04-26 13:38:28 +02:00
Debarshi Ray
abb2ac6fd4 Show a welcome text on interactive shells running inside a toolbox
The welcome text uses the OSC 8 [1] escape sequence to add a hyperlink
to the Silverblue documentation [2].

Silence a SC1003 [3] because the intention is to print the 'ESC \'
string terminator (or ST), and not escape a single quote.

[1] https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
[2] https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/
[3] https://github.com/koalaman/shellcheck/wiki/SC1003

https://github.com/debarshiray/toolbox/pull/130
2019-04-25 16:21:13 +02:00
Debarshi Ray
79f59b667b Show a welcome text on interactive shells running on Silverblue hosts
The welcome text uses the OSC 8 [1] escape sequence to add a hyperlink
to the Silverblue documentation [2].

Silence a SC1003 [3] because the intention is to print the 'ESC \'
string terminator (or ST), and not escape a single quote.

[1] https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
[2] https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/
[3] https://github.com/koalaman/shellcheck/wiki/SC1003

https://github.com/debarshiray/toolbox/pull/127
2019-04-25 15:52:23 +02:00
Debarshi Ray
5d78707a21 Make it available inside the toolbox container
Commit 5b3d234c9e had made the toolbox script work inside a
toolbox container, but most people didn't get to use it because it
needed extra effort to get access to the script inside the container.
One either had to grab the Toolbox sources or had to install the RPM.
Both options were inconvenient - the former needed knowing too many
technical details, while the latter would drag in dependencies like
Buildah and Podman that don't work inside the toolbox container.

This makes it easier to use the toolbox script inside a toolbox
container by bind mounting the script from the host inside the
container and keeping track of the path using the TOOLBOX_PATH
environment variable. The environment variable ensures that running
'toolbox create' from inside a toolbox container would continue to
bind mount the same script from the host that was used to create the
current container and is available inside it.

Compatibility with existing toolbox containers is broken when using
the script within a container because it insists on the TOOLBOX_PATH
environment variable being set inside. This might not be that big of a
deal because using the toolbox script inside a toolbox container wasn't
very convenient, and hence likely not used widely. In case of
complaints, this can be relaxed by falling back to "$0" when forwarding
the command to the host, but unless that happens it's better to keep
things simple to avoid a larger test matrix.

Based on an idea from Colin Walters.

https://github.com/debarshiray/toolbox/pull/126
2019-04-24 14:50:56 +02:00
Debarshi Ray
c0f476e2f2 Use more appropriate API to check if the container already exists
https://github.com/debarshiray/toolbox/pull/122
2019-04-17 13:27:21 +02:00
Debarshi Ray
8db3317807 Use more appropriate API to check the cache for the customized image
https://github.com/debarshiray/toolbox/pull/122
2019-04-17 13:27:18 +02:00
Debarshi Ray
97254b65bb Use more appropriate API to check the cache for the base image
https://github.com/debarshiray/toolbox/pull/122
2019-04-17 13:27:15 +02:00
Debarshi Ray
73980079ff Suggest a way forward if the requested container is already present
This should smoothen the onboarding experience by making the commands
self-documenting.

https://github.com/debarshiray/toolbox/issues/59
2019-04-17 12:11:06 +02:00
Debarshi Ray
6e9dc4ad89 Split out the code to create the command string to enter a container
A subsequent commit will leverage this to suggest how to enter a
toolbox container that's already present.

https://github.com/debarshiray/toolbox/issues/59
2019-04-17 12:10:56 +02:00
Debarshi Ray
c6772f0f11 images: Avoid losing useradd(8) by accident
The shadow-utils package was added to the base toolbox images to ensure
the presence of the useradd(8) command. Currently the package is
already pulled in by various dependencies. Therefore, it doesn't
increase the size of the base image, but serves as a safeguard against
any inadvertent changes.
2019-04-17 11:38:49 +02:00
Debarshi Ray
a4fcb81f24 Don't use a separate code path to forward DBUS_SYSTEM_BUS_ADDRESS
https://github.com/debarshiray/toolbox/issues/104
2019-04-16 17:08:11 +02:00
Debarshi Ray
cfcb5e74dd Allow connecting to Wayland displays other than "wayland-0"
https://github.com/debarshiray/toolbox/issues/104
2019-04-16 17:04:30 +02:00
Debarshi Ray
acbc68e1cd Skip environment variables that aren't set
This removes the need for separate code paths for environment
variables that are likely to be absent from the environment. eg.,
DBUS_SYSTEM_BUS_ADDRESS.

In theory, any environment variable can be unset from the environment,
and a variable that's set to the null or empty string (ie., "") is
different from one that's completely absent. Therefore, this is a
positive change regardless of whether the code path is used for
DBUS_SYSTEM_BUS_ADDRESS or not.

https://github.com/debarshiray/toolbox/issues/104
2019-04-16 16:49:01 +02:00
Debarshi Ray
a5f00c0d26 Prepare 0.0.8 2019-04-12 16:44:16 +02:00
Toni Schmidbauer
08d1caf3c1 Add short variants for various options in 'create' and 'enter'
https://github.com/debarshiray/toolbox/pull/75
2019-04-12 16:22:42 +02:00
Debarshi Ray
be3530fe9c Ensure that names of toolbox containers don't have a colon
Unlike OCI images, OCI containers can't be tagged and their names
can't have colons in them [1]. Therefore, from now on the version
suffix will be separated by a hyphen.

For backwards compatibility, 'toolbox enter' will continue to work with
containers using the old naming scheme.

Silence a SC2030 [2] because falling back to toolbox_container_old is
only relevant for the enter() function, and silence a spurious
SC2031 [3].

[1] Podman commit 449b8ab7b14fcc0d
    https://github.com/containers/libpod/pull/2793
[2] https://github.com/koalaman/shellcheck/wiki/SC2030
[3] https://github.com/koalaman/shellcheck/wiki/SC2031

https://github.com/debarshiray/toolbox/issues/106
2019-04-12 15:52:36 +02:00
Debarshi Ray
0b0c1e3a2c Always use a tag for the user-specific customized image
A subsequent commit will generate the name of the toolbox container
from that of the user-specific customize image, instead of just using
the same exact string. This is necessary because, unlike OCI images,
names of OCI containers can't have a colon in them [1]. Knowing that
the user-specific customized image always has a tag will make things
simpler.

Buildah and Podman are going to use 'latest' as the placeholder when no
tag is specified, and this what is explicitly mentioned when the base
toolbox image is referred to by its non-human-readable ID.

Fallout from 56c3cfc27c

[1] Podman commit 449b8ab7b14fcc0d
    https://github.com/containers/libpod/pull/2793

https://github.com/debarshiray/toolbox/issues/106
2019-04-12 14:55:36 +02:00
Debarshi Ray
4575c862cd Tweak a user-visible string to say "container", not "toolbox container"
... because that's what's used elsewhere.
2019-04-12 13:40:02 +02:00
Debarshi Ray
3afb2bc4c7 Suggest a way forward if no command has been specified
Instead of overwhelming the user with the entire reference
documentation, highlight some of the more common commands that a new
user is likely to be interested in. This is concise enough to not annoy
seasoned users who might have just committed a typo.

This should smoothen the onboarding experience by making the commands
self-documenting.

https://github.com/debarshiray/toolbox/issues/59
2019-04-11 16:26:44 +02:00
Debarshi Ray
adb8e03d26 Mention the name of the created toolbox container and how to enter it
This should smoothen the onboarding experience by making the commands
self-documenting.

https://github.com/debarshiray/toolbox/issues/59
2019-04-11 16:10:26 +02:00
Debarshi Ray
5f1716b28b Simplify code
Fallout from 1e0564d66c
2019-04-11 16:10:22 +02:00
Debarshi Ray
0b06e51273 Fix typo
Fallout from 7acc9936cf
2019-04-11 15:27:39 +02:00
Tomas Popela
9316d0f284 Include images tagged with c.gh.debarshiray.toolbox in 'rmi'
When '--all' is applied then first query the images with an old label,
then with the new label, combine them and process them.

When the exact image name is specified, then we need to check
whether the image has the new or old label and only then remove it.

https://github.com/debarshiray/toolbox/pull/101
2019-04-11 15:05:58 +02:00
Tomas Popela
a2a1836773 Include containers tagged with c.gh.debarshiray.toolbox in 'rm'
When '--all' is applied then first query the containers with an old label,
then with the new label, combine them and process them.

When the exact container name is specified, then we need to check
whether the container has the new or old label and only then remove it.

https://github.com/debarshiray/toolbox/pull/101
2019-04-11 14:50:18 +02:00
Debarshi Ray
248e218183 Fix typo
Fallout from ea5558cab0
2019-04-11 14:50:12 +02:00
Tomas Popela
ea5558cab0 Include containers tagged with c.gh.debarshiray.toolbox in 'list'
First we need to get the containers with an old label and then with the
new label. We have to change the format of the query to only include the
name of the containers and not the other informations like 'created' as
they could make a problem when removing the duplicates with uniq. When
we have the final list of containers we pass them to
containers_get_details() where we obtain the final details for them.

https://github.com/debarshiray/toolbox/pull/101
2019-04-11 13:28:06 +02:00
Owen W. Taylor
92cc1a15d6 Use a lighter entry point than /bin/sh
Now that toolbox containers no longer use a separate PID namespace [1],
the entry point specified in 'podman create ...' doesn't act as PID 1
inside the toolbox container. It's just a process that's spawned by
'podman start' to denote the state of the container. This opens the
possibility of using something even more lightweight, such as
'sleep +Inf'.

sleep(1) takes 64 kB compared to the 432 kB taken by /bin/sh.

This wouldn't have been possible with a separate PID namespace. In that
case, the entry point would also become PID 1, and since the only
signals that can be sent to a PID 1 are those for which it has
explicitly installed handlers, this would cause various problems.

[1] Commit 67522f0ad7

https://github.com/debarshiray/toolbox/pull/108
2019-04-10 16:10:46 +02:00
Tomas Popela
d69300b072 Enable Travis
https://github.com/debarshiray/toolbox/pull/83
2019-04-10 15:18:06 +02:00
Debarshi Ray
d0cd536bc2 build: Add a test that runs shellcheck on the toolbox script
https://github.com/debarshiray/toolbox/pull/83
2019-04-10 15:18:06 +02:00
Tomas Popela
fdafbdf360 Silence SC2086
Otherwise https://www.shellcheck.net/ would complain:
  Line 678:
  $kcm_socket_bind \
  ^-- SC2086: Double quote to prevent globbing and word splitting.

See: https://github.com/koalaman/shellcheck/wiki/SC2086

These variables can't be double quoted. They contain command line
arguments and should expand as either null or separate argument
strings. Quoting them would cause them to expand as arguments that are
either the empty string (ie., "") or all the individual arguments would
get clubbed into a single argument (ie. "--env=COLORTERM=truecolor
--env=DBUS_SESSION_BUS_ADDRESS=...").

https://github.com/debarshiray/toolbox/pull/83
2019-04-10 15:17:54 +02:00
Debarshi Ray
b2f03ab8f0 README.md: Add the landscape variant of the logo as a banner
https://github.com/debarshiray/toolbox/pull/103
2019-04-04 16:47:07 +02:00
Jakub Steiner
d92a0826fc logo: Convert text to shapes
... to not rely on the Overpass font being present.

https://github.com/debarshiray/toolbox/pull/102
2019-04-04 16:19:52 +02:00
Jakub Steiner
1643c3ea6d data: Add logo
https://github.com/debarshiray/toolbox/issues/81
2019-04-04 15:31:32 +02:00
Tomas Popela
89dd3b5896 Silence SC2016
Otherwise https://www.shellcheck.net/ would complain:
  Line 754:
  capsh --caps="" -- -c 'cd "$1"; export PS1="$2"; shift 2; exec "$@"'
                        ^-- SC2016: Expressions don't expand in single
                          quotes, use double quotes for that.

See: https://github.com/koalaman/shellcheck/wiki/SC2016

The entire command string argument is meant to be passed as is,
without any variable expansion, to the shell started by capsh(1) inside
the toolbox container.

https://github.com/debarshiray/toolbox/pull/83
2019-03-29 15:02:42 +01:00