Commit graph

130 commits

Author SHA1 Message Date
Ondřej Zoder
dde1fa0734 images: Restore documentation removed from the base Fedora images
https://github.com/debarshiray/toolbox/pull/55
2019-03-05 18:01:27 +01:00
Debarshi Ray
c9a061c7b9 doc/toolbox-enter: Mention the underlying podman commands
It's useful to know things like a running toolbox container has to be
stopped before removal or 'rm --force' needs to be used, etc.. This is
implicitly tied to the fact that entering a toolbox container is
equivalent to a 'podman start' followed by a 'podman exec'.
2019-03-05 16:32:53 +01:00
Debarshi Ray
517c77a0d6 doc: Grammar fixes 2019-03-05 16:32:53 +01:00
Ondřej Zoder
7acc9936cf Add rm and rmi commands
https://github.com/debarshiray/toolbox/pull/45
2019-03-05 16:17:46 +01:00
Debarshi Ray
40cb8caf46 Rename a variable
It's obvious that this is a container ID, so there's no need for the
"container" prefix.
2019-03-01 18:44:41 +01:00
Debarshi Ray
0a972dfccc Add manuals
https://github.com/debarshiray/toolbox/pull/66
2019-03-01 10:27:09 +01:00
Debarshi Ray
c65e656966 README.md: Add missing comma 2019-03-01 10:26:58 +01:00
Debarshi Ray
c219ac1882 README.md: Tweak
The word 'tool' sounds a bit less vague than 'project'.
2019-03-01 10:13:46 +01:00
Debarshi Ray
554fac08b0 Don't create volumes in the image for bind mounts from the host
Otherwise, it breaks 'podman start ...' in Podman commit
52df1fa7e054d577 [1]. Even though the podman regression was fixed in
commit 21bc766ee3829776 [2], it's prudent to also fix the toolbox
script to be more correct.

This problem isn't localized to a single command, but spans across
'create' and 'enter'. If a customized toolbox image created by the
'create' command has volumes for host bind mounts, then it will break
'podman start ...' in the 'enter' command. Therefore, users need to be
encouraged to recreate both their customized toolbox images. This is
currently done through the --verbose debug logs to avoid needless
noise because the regression was restricted to development snapshots
of podman.

Toolbox containers created from images built by broken Podman versions
between commits 52df1fa7e054d577 and 21bc766ee3829776, and broken
toolbox scripts prior to this commit, will continue to not start.
Those toolboxes and their corresponding customized images need to be
re-created with at least one of the components, either podman or this
script, fixed.

Note that 'podman inspect --type container ...' doesn't have a Go
template field for "Image". However, "ImageName" gracefully falls back
to the ID for images without a human-readable name, which is arguably
better than always using an ID.

As suggested by Daniel J Walsh and Giuseppe Scrivano.

[1] https://github.com/containers/libpod/commit/52df1fa7e054d577
[2] https://github.com/containers/libpod/commit/21bc766ee3829776

https://github.com/containers/libpod/issues/2441
https://github.com/debarshiray/toolbox/issues/62
2019-02-26 20:47:24 +01:00
Debarshi Ray
10ee2d44b7 Clarify the error message if the toolbox container is not found
https://github.com/debarshiray/toolbox/issues/59
2019-02-26 19:47:38 +01:00
Debarshi Ray
ad75d97b50 images: Add fedora-toolbox image definition for Fedora 31 2019-02-25 14:45:46 +01:00
Debarshi Ray
acad65cd41 extra-packages: Style fixes 2019-02-25 14:37:58 +01:00
Debarshi Ray
a82261f30a extra-packages: Add flatpak-xdg-utils to Fedoras 29 and 30
This is necessary for the toolbox script to work inside the toolbox
container [1]. Having the flatpak-spawn command, provided by the
flatpak-xdg-utils package, readily available in the base image makes
for a better out of the box experience.

The flatpak-xdg-utils package is not available on Fedora 28. Given
that Fedora 28 is getting close to the end of its life cycle, it's
probably not worth doing all the paperwork to offer the package there.

[1] Commit 5b3d234c9e
    https://github.com/debarshiray/toolbox/pull/54
2019-02-25 14:04:46 +01:00
Debarshi Ray
04a91d5189 Prepare 0.0.6 2019-02-21 19:47:56 +01:00
Debarshi Ray
0af7be08a9 Don't write to standard output if any of the list functions fail
Currently, 'toolbox list' doesn't handle errors thrown by any of the
functions used by it. If something fails, it will send the error
message to the standard error output and continue trying to list other
things.

Instead, it's better to ensure that all the internal functions have
succeeded before listing anything. If there's an error, print the error
message but don't mix it with attempts to list other things so that
the failure mode is cleaner and it's more obvious that something went
wrong.
2019-02-20 19:54:37 +01:00
Debarshi Ray
d8294628c2 Use the standard error output for error messages 2019-02-20 19:52:06 +01:00
Debarshi Ray
8ae0645c80 Handle errors in command pipeline when listing containers
Listing toolbox containers involves parsing the output of 'podman ps'
and rearranging the columns into a table. Parsing and rearranging
output is inherently brittle, and there's no guarantee that podman
itself won't fail. Therefore, it's prudent to sprinkle some error
handling.
2019-02-20 19:52:06 +01:00
Debarshi Ray
5a67dec0e8 Handle errors in command pipeline when listing images
Listing toolbox images involves parsing the output of 'podman images'
and rearranging the columns into a table. Parsing and rearranging
output is inherently brittle, and there's no guarantee that podman
itself won't fail. Therefore, it's prudent to sprinkle some error
handling.
2019-02-20 19:52:06 +01:00
Debarshi Ray
85c319274f Add missing --verbose option to --help
Fallout from 5e4e63a11b
2019-02-20 19:52:06 +01:00
Debarshi Ray
de09605583 Remove redundant code
Unsetting the IFS variable doesn't disable field splitting. It makes
the shell behave as if the default field separators (ie. <space>,
<tab> and <newline>) are in play. See:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html

The original reason for unsetting IFS was to disable field splitting,
which was clearly wrong. Moreover, there was no need to worry about it
in the first place, because none of the command substitutions being
performed involve multiline output where field splitting would have
become relevant.

Fallout from 5e4e63a11b
2019-02-20 14:16:10 +01:00
Debarshi Ray
10d1f5962f README.md: Add a hyperlink for OCI 2019-02-19 15:16:28 +01:00
Debarshi Ray
a0f169c1ce README.md: Add missing whitespace 2019-02-19 15:14:26 +01:00
Debarshi Ray
ecc76f39ac Silence SC1091
Otherwise https://www.shellcheck.net/ would complain:
  Line 44:
  . /etc/os-release
    ^-- SC1091: Not following: /etc/os-release was not specified as
      input (see shellcheck -x).

See: https://github.com/koalaman/shellcheck/wiki/SC1091
2019-02-19 14:57:14 +01:00
Emiel Wiedijk
26a285a7e0 POSIX only supports single digit file descriptors
See: https://wiki.ubuntu.com/DashAsBinSh

Detected by the checkbashisms [1] tool.

[1] https://packages.debian.org/sid/devscripts

https://github.com/debarshiray/toolbox/issues/53
2019-02-19 14:30:11 +01:00
Debarshi Ray
9315f6cbbf Fix typos
... detected by https://www.shellcheck.net/.

The opening solid bracket (ie. [) is actually a command like any other.
It expects it's final argument to be the closing bracket (ie. ]). Thus,
the redirection needs to be after the trailing bracket.

Fallout from 80f25c6924
2019-02-19 14:08:52 +01:00
Debarshi Ray
5b3d234c9e Make it work inside the toolbox container itself
A truly seamless developer experience requires erasing the divide
between the host and the toolbox container as much as possible.
Currently, various tools don't work at all when used from inside the
toolbox because they expect to be run on the host. eg., flatpak,
podman, and the toolbox script itself. This puts a significant enough
cognitive burden on the developer. At the very least, the human
operator needs to keep track of the context in which those commands
are being issued.

To make things better, the toolbox script has been made aware of the
context in which it is running. If it detects that it's running inside
the toolbox container, denoted by a 'podman exec ...' parent process
and the presence of /run/.containerenv, then it tries to forward its
own invocation to the host over D-Bus using 'flatpak-spawn --host' [1].
This uses the HostCommand method on the org.freedesktop.Flatpak D-Bus
service underneath to do the forwarding.

The process offering the org.freedesktop.Flatpak service doesn't have
some variables, like COLORTERM and TERM, set in its environment, and
their absence hinders the use of interactive shells. This is addressed
by tunneling the same set of environment variables that are also passed
to podman.

[1] http://docs.flatpak.org/en/latest/flatpak-command-reference.html#flatpak-spawn

https://github.com/debarshiray/toolbox/pull/54
2019-02-19 13:22:18 +01:00
Debarshi Ray
a09692aa8b Split out the code to set environment variables in the toolbox
A subsequent commit will leverage this to tunnel the same environment
variables over D-Bus when the toolbox script forwards its own
invocation over 'flatpak-spawn --host'. This is necessary because the
process offering the underlying org.freedesktop.Flatpak D-Bus service
used by 'flatpak-spawn --host' doesn't have some variables, like
COLORTERM and TERM, set in its environment, and their absence hinders
the use of interactive shells.

Instead of keeping two separate hard coded lists, one for
flatpak-spawn and another for podman, it's better to use the same set
for both to avoid silly and weird bugs.

https://github.com/debarshiray/toolbox/pull/54
2019-02-19 13:22:18 +01:00
Debarshi Ray
b3a6578cc9 Avoid a Bash-ism (ie. source) and stick to POSIX (ie. .)
https://github.com/debarshiray/toolbox/issues/53
2019-02-18 18:31:04 +01:00
Debarshi Ray
dcb0fdacb0 Simplify code
Fallout from 5e4e63a11b
2019-02-18 18:16:35 +01:00
Debarshi Ray
9e0182e0a1 Use sed(1) instead of tr(1) for consistency
Shell scripts are archaic enough by themselves. For the sake of
readability it's better to stick to a smaller subset of features
that's already being widely used, instead of introducing slightly
different ways of doing the same thing.

Unless there's a pressing user-visible reason to introduce tr(1), it's
better to keep using sed(1).
2019-02-18 18:14:44 +01:00
Debarshi Ray
4d9a4bc22f Make --release a command-specific option
It's irrelevant for the list command, and it's more intuitive if it
behaves like the somewhat similar --container and --image options.
2019-02-18 13:18:12 +01:00
Debarshi Ray
e45ac66afe Refactor common code into a function 2019-02-18 11:53:34 +01:00
Debarshi Ray
403c4af508 Make --container a command-specific option
It's irrelevant for the list command, and it's more intuitive if it
behaves like the somewhat similar --image option.
2019-02-18 11:32:41 +01:00
Debarshi Ray
9d686a82dd Refactor common code into a function 2019-02-18 11:29:25 +01:00
Debarshi Ray
67522f0ad7 Use the host's PID namespace for the toolbox container
It's common practice to track down a process while developing. This
could be a process that's repeatedly crashing, or something that's
misbehaving by using up too many resources. Being able to seamlessly
look at what's happening on the host makes for a better developer
experience.

The toolbox doesn't intend to provide a segregated security domains,
so this is fine.
2019-02-18 10:49:08 +01:00
Debarshi Ray
e1898c0cc6 Style fix 2019-02-15 18:59:51 +01:00
Debarshi Ray
6d2c1f7e95 Hide the error output from column(1) unless --verbose is used
Fallout from 5e4e63a11b
2019-02-15 18:59:06 +01:00
Debarshi Ray
4cf58d5b72 Factor out the template for temporary directories into a variable 2019-02-15 17:23:40 +01:00
Debarshi Ray
c6b5a4836f Drop the "fedora" prefix and rename the project as just "toolbox"
The "fedora" prefix was used because this project was specifically
incubated to make it easier to hack on Fedora Silverblue. That and the
mix of upstream technologies (ie., Buildah and Podman) made it uniquely
"Fedora".

However, over time it has gotten clear that other groups, currently
Fedora downstreams like RHEL, are interested in it too. It won't be
surprising if in future it transcends the Fedora universe altogether.
Moreover, this project was inspired by coreos/toolbox [1]. There are
good reasons and enough interest to have a unified toolbox project
that addresses the needs of both Fedora CoreOS and Silverblue.

Therefore, it is best to drop the "fedora" prefix and call the whole
thing just "toolbox".

No extra effort was made to retain compatibility with the older name
due to the project's young age. Its userbase is limited to the earliest
of early adopters, and the benefits of a clean break outweigh the
loss of compatibility.

The OCI images and the toolbox container still retain the "fedora"
prefix to disambiguate them from their counterparts from other
operating systems.

[1] https://github.com/coreos/toolbox

https://github.com/debarshiray/toolbox/issues/8
2019-02-15 16:36:30 +01:00
Debarshi Ray
05f3530421 Shorten the prefix for debug and error messages
Using "$0" leads to printing the entire path to the fedora-toolbox
script, which adds visual noise to the output. Command line tools like
GNU Coreutils and Git remove any leading directory components from
the path, which seems like a reasonable trade-off between aesthetics
and verbosity.

https://github.com/debarshiray/fedora-toolbox/pull/50
2019-02-14 12:21:54 +01:00
Ondřej Zoder
5e4e63a11b Add a list command
https://github.com/debarshiray/fedora-toolbox/pull/39
2019-02-12 19:13:43 +01:00
Debarshi Ray
2aded000ec Avoid using a Bash-ism (ie. [[...]) for prefix matching 2019-02-11 18:32:33 +00:00
Debarshi Ray
1c18fa6d4f Avoid a Bash-ism (ie. [[...]) and stick to POSIX (ie. [...])
Fallout from 66e982af72
2019-02-11 18:08:29 +00:00
Debarshi Ray
2b6faa26f9 Prepare 0.0.5 2019-02-11 14:17:47 +00:00
Daniel J Walsh
4a2a15f2eb Give access to mounts under $HOME, and make autofs work 2019-01-28 11:45:25 +01:00
Debarshi Ray
4ff281b5ed Show a spinner while creating the toolbox image using buildah 2019-01-28 11:45:25 +01:00
Debarshi Ray
00eeeae6c4 Show a spinner while configuring the working container using buildah 2019-01-28 11:45:25 +01:00
Debarshi Ray
f10d8e7495 Split out the code to configure the working directory
A subsequent commit will leverage this to show a spinner.
2019-01-28 11:45:25 +01:00
Debarshi Ray
f976ba0fc3 Style fixes 2019-01-28 11:45:25 +01:00
Debarshi Ray
e32a8d3d03 Show a spinner while creating the toolbox container using podman 2019-01-28 11:45:25 +01:00