Commit graph

1186 commits

Author SHA1 Message Date
Debarshi Ray
afbed7a057 build: Enforce gofmt on all Go sources
Gofmt returns with an exit code of 0 even when it's not happy with the
formatting of the source files. The recommendation is to check the
emptyness of the output [1].

[1] https://github.com/golang/go/issues/24230

https://github.com/containers/toolbox/pull/983
2022-01-11 22:33:51 +01:00
Debarshi Ray
3f9ee19a66 build: Add copyright and license notice
Fallout from be2ba6d2e2

https://github.com/containers/toolbox/pull/984
2022-01-11 19:55:22 +01:00
Debarshi Ray
b1743c4927 .zuul: Trigger the tests when the post-install script changes
Fallout from be2ba6d2e2

https://github.com/containers/toolbox/pull/984
2022-01-11 19:55:18 +01:00
Debarshi Ray
4459e02e02 .zuul: Re-align
This will make the subsequent commit easier to read.

https://github.com/containers/toolbox/pull/984
2022-01-11 19:55:05 +01:00
Debarshi Ray
d2067ea688 build: Tidy up the Go dependencies with 'go mod tidy'
https://github.com/containers/toolbox/pull/982
2022-01-11 01:24:56 +01:00
Debarshi Ray
de6d587c8b build: Mark golang.org/x/term as a direct dependency
The deprecated golang.org/x/crypto/ssh/terminal API was replaced with
golang.org/x/term. Now, every invocation of 'go build' insists on
updating src/go.mod to drop the 'indirect' marker from
golang.org/x/term.

Fallout from d323143c46

https://github.com/containers/toolbox/pull/982
2022-01-11 01:23:41 +01:00
Debarshi Ray
be2ba6d2e2 build: Call 'systemd-tmpfiles --create' when installing
It's only necessary to call 'systemd-tmpfiles --create' when building
and installing from source on the host operating system.

It's not needed when using a pre-built binary downstream package,
because:

  * When 'meson install' is called as part of building the package,
    that's not when the temporary files need to be created. They need
    to be created when the binary package is later downloaded and
    installed by the user.

  * Downstream tools can sometimes handle it automatically. eg., on
    Fedora, the systemd RPM installs a trigger that tells RPM to call
    'systemd-tmpfiles --create' automatically when a tmpfiles.d snippet
    is installed.

It's also not needed when installing inside a toolbox container because
the files that 'systemd-tmpfiles --create' is supposed to create are
meant to be on the host.

Downstream distributors set the DESTDIR environment variable when
building their packages. Therefore, it's used to detect when a
downstream package is being built.

Unfortunately, environment variables are messy and, generally, Meson
doesn't support accessing them inside its scripts [1]. Therefore, this
adds a spurious build-time dependency on systemd for downstream
distributors. However, that's probably not a big problem because all
supported downstream operating systems are already expected to use
systemd for the tmpfiles.d(5) snippets to work.

[1] https://github.com/mesonbuild/meson/issues/9

https://github.com/containers/toolbox/issues/955
2022-01-10 22:14:01 +01:00
Ondřej Míchal
5d61a74b1a ci: Set full path to Containerfile
The action does not use provided context when looking for a
Containerfile[0].

[0] https://github.com/redhat-actions/buildah-build/issues/44

https://github.com/containers/toolbox/pull/981
2022-01-10 13:40:32 +02:00
Ondřej Míchal
05eef2aaa6 ci: Add manual trigger to image factory pipeline
https://github.com/containers/toolbox/pull/981
2022-01-10 13:40:32 +02:00
Ondřej Míchal
818748001c ci: Build & Publish Fedora Toolbx images with GitHub Packages
For the sake of greater control over the testing of images and for having an
infrustructure for hosting images that are not endorsed by the distirbutions.

The images are to be rebuilt every day at midnight.

https://github.com/containers/toolbox/pull/973
2022-01-09 18:16:47 +01:00
Ondřej Míchal
d323143c46 cmd: Fix issues raised by Golangci
Issues included:

- unreachable code
- unneeded type assertions
- unhandled errors
- use of deprecated API
- unused code

https://github.com/containers/toolbox/pull/979
2022-01-09 17:48:47 +01:00
Ondřej Míchal
46ff946190 ci: Remove only-new-issues option from linter run
The option is mutually exclusive with the working-directory option that
we need to use due to Toolbx code residing in a subdirectory. The tool
itself does not work recursively.

Fallout from https://github.com/containers/toolbox/pull/974

https://github.com/containers/toolbox/pull/978
2022-01-09 17:01:40 +01:00
Ondřej Míchal
f456c173b6 pkg/utils: Use new UBI toolbox image
Red Hat has published a new UBI image made specificaly for Toolbx.
Make use of it from now on.

Fixes: https://github.com/containers/toolbox/issues/961

https://github.com/containers/toolbox/issues/976
2022-01-09 16:46:37 +01:00
Ondřej Míchal
7c86f30b77 ci: Add golangci linter
Use machines to do (at least some) of the work humans had to do!

https://github.com/containers/toolbox/pull/974
2022-01-09 16:29:32 +01:00
Jakub Steiner
7351313dc8 CONTRIBUTING: Custom graphic
Can't have right aligned images or inline css, better to just have them
on the left.

https://github.com/containers/toolbox/pull/958
2022-01-07 09:34:39 +01:00
Debarshi Ray
4dd3c89721 .zuul: Style fixes
List the jobs in the same order that they are defined.

https://github.com/containers/toolbox/pull/971
2022-01-05 02:18:15 +01:00
Debarshi Ray
12fbb2361e .zuul: Shuffle some code around
Defining the YAML anchor as part of the Rawhide tests, instead of the
Fedora 34 test, will prevent it from getting lost by mistake when
Fedora 34 reaches its End of Life.

https://github.com/containers/toolbox/pull/971
2022-01-05 02:15:38 +01:00
Debarshi Ray
53a7ac0f9e .zuul: Try to prevent the CI from timing out running the unit tests
Currently, the CI has been frequently timing out when running the unit
tests. It's possible that the current 5 minute timeout isn't enough,
because it's significantly lower than the 20 minute timeout on stable
Fedoras for the system tests.

Increase the timeout to 10 minutes to see if that makes the CI more
stable.

https://github.com/containers/toolbox/pull/970
2022-01-05 00:54:25 +01:00
Debarshi Ray
bedea6fa09 .zuul: Try to prevent the CI from timing out on Fedora Rawhide
Currently, the CI has been frequently timing out on Fedora Rawhide
nodes, and it's not clear why that is. One possibility is that this is
due to Rawhide using Linux kernels that are built with debugging
enabled, which makes it slower than released Fedoras. So it might be a
matter of just increasing the timeout.

Currently, the timeout for stable Fedoras is 20 minutes, and that for
Rawhide is 22 minutes. An attempt to increase the Rawhide timeout to 30
minutes didn't succeed, so maybe 45 minutes will be sufficient.

https://github.com/containers/toolbox/pull/964
2022-01-04 23:50:58 +01:00
Ondřej Míchal
73c53a347b src: Update dependencies with 'go get -u'
- github.com/acobaugh/osrelease v0.0.0-20181218015638-a93a0a55a249 => v0.1.0
- github.com/briandowns/spinner v1.10.0 => v1.17.0
- github.com/fsnotify/fsnotify v1.4.9 => v1.5.1
- github.com/sirupsen/logrus v1.4.2 => v1.8.1
- github.com/spf13/cobra v0.0.7 => v1.3.0
- github.com/spf13/viper v1.4.0 => v1.10.1
- golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8 => v0.0.0-20211215153901-e495a2d5b3d3
- golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 => v0.0.0-20211216021012-1d35b9e2eb4e

https://github.com/containers/toolbox/pull/917
2021-12-17 16:26:19 +01:00
Ondřej Míchal
e598e21603 cmd/root: Work around Cobra 1.1.2's handling of usage functions
In version 1.1.2 of Cobra has been included a change[0] that changes
how custom usage functions are handled.

Example of the wrong behaviour:
$ toolbox --foo
Error: unknown flag: --foo
Run 'toolbox --help' for usage.Error: Run 'toolbox --help' for usage.

Desired behaviour:
$ toolbox --foo
Error: unknown flag: --foo
Run 'toolbox --help' for usage.

A workaround is to define a template string for the usage instead. The
template uses the templating language of Go[1]. See the default
template string in version 1.2.1[2].

Because the template is set only once, the executableBase needs to be
set before the template is applied. That required the move of
setUpGlobals() into init() of the cmd package. This is a better place
for the function call as init() is called earlier than Execute()[3].

Upstream issue: https://github.com/spf13/cobra/issues/1532

[0] https://github.com/spf13/cobra/pull/1044
[1] https://pkg.go.dev/text/template
[2] https://github.com/spf13/cobra/blob/v1.2.1/command.go#L491
[3] https://golang.org/doc/effective_go#init

https://github.com/containers/toolbox/pull/917
2021-12-17 16:25:46 +01:00
Ondřej Míchal
b49149f0c5 src: Update dependencies with 'go get -u=patch'
- github.com/HarryMichal/go-version v1.0.0 => v1.0.1
- github.com/fsnotify/fsnotify v1.4.7 => v1.4.9
- github.com/godbus/dbus/v5 v5.0.3 => v5.0.6
- github.com/mattn/go-isatty v0.0.8 => v0.0.14
- github.com/spf13/cobra v0.0.5 => v0.0.7
- github.com/spf13/viper v1.3.2 => v1.4.0
- golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9 => v0.0.0-20211115234514-b4de73f9ece8
- golang.org/x/sys v0.0.0-20190422165155-953cdadca894 => v0.0.0-20211113001501-0c823b97ae02

https://github.com/containers/toolbox/pull/917
2021-12-17 15:19:46 +01:00
Debarshi Ray
708fa593e2 doc: Document the configuration file
https://github.com/containers/toolbox/pull/963
2021-12-17 13:23:37 +01:00
Debarshi Ray
0e78e4a313 build: Don't assume that all the pages are in section 1 of the manual
This will be used by the subsequent commit to add a page to document
the configuration file, which should go into section 5 of the manual.

https://github.com/containers/toolbox/pull/963
2021-12-17 13:23:33 +01:00
Anthony Wang
59d241baa1 cmd/root: Search subordinate ID files for also the UID
... and not just the username.

https://github.com/containers/toolbox/issues/954
2021-12-17 13:14:37 +01:00
Debarshi Ray
d96faf0c1e build: Be more strict when looking for a C compiler
In practice, this means that only Clang and GCC are accepted.

https://github.com/containers/toolbox/pull/960
2021-12-17 02:08:51 +01:00
Ondřej Míchal
c28d902089 .zuul: Run tests only for relevant files
Not all file are equal when it comes to testing. Unit tests are related
strictly to the source code and documentation changes do not concern it.
System tests have a wider range of influence but documentation and some
other areas also do not concern them.

I'm unsure about the effect of this change on the periodic pipeline
execution.

https://github.com/containers/toolbox/pull/948
2021-12-16 02:46:00 +02:00
Debarshi Ray
52c85b60d9 Prepare 0.0.99.3 2021-12-10 03:40:42 +01:00
Debarshi Ray
20a20bf149 doc: Refer to a newer Fedora release in the examples
Fedora 30 reached End of Life on 26th May 2020:
https://docs.fedoraproject.org/en-US/releases/eol/

https://github.com/containers/toolbox/pull/953
2021-12-10 03:03:54 +01:00
Debarshi Ray
4948106f7d doc/toolbox-create: Say that --distro & --image are mutually exclusive
https://github.com/containers/toolbox/pull/952
2021-12-10 02:49:19 +01:00
Debarshi Ray
2e99b8a57f doc/toolbox-create, doc/toolbox-run: Remove references to base images
As far as Toolbox is concerned, there are no longer base images and
user-specific customized images. They are all just images.

This should have been part of commit 6543ff6a06.

https://github.com/containers/toolbox/pull/952
2021-12-10 02:49:15 +01:00
Debarshi Ray
fa685fbdb0 doc/toolbox-create: Fix typo
Fallout from 0b41cc62f4

https://github.com/containers/toolbox/pull/952
2021-12-10 02:49:11 +01:00
Debarshi Ray
e58992066f cmd: Suggest a way forward if coreos/toolbox was used
github.com/coreos/toolbox bind mounts the entire /run from the host
operating system into the toolbox container. Due to this, when run
rootful, the /run/.containerenv created by Podman inside the container
is also seen on the host. This confuses Toolbox into thinking that it's
running inside a container, even when it's running on the host.

This is an attempt to differentiate between a toolbox container and
the host by looking at the 'container' environment variable, so that
the user can be presented with a more helpful error message.

https://bugzilla.redhat.com/show_bug.cgi?id=1998191
https://github.com/containers/toolbox/pull/951
2021-12-10 01:48:28 +01:00
Debarshi Ray
411147988b cmd, test/system: Make the behaviour of 'toolbox' conditional
Commit 6c86cabbe5 changed the command line interface to behave
a lot similar to that of github.com/coreos/toolbox, which makes things
easier for those switching over from it. Make it conditional so that
only those OS distributors who truly need it may enable it, and
restore the previous behaviour as the default.

The tests were updated to test the default behaviour that the vast
majority of users would be seeing. Ideally, the test suite would be run
twice with the migration path turned off and on. However, that would
require a more intrusive surgery of the test suite and likely make it
slower. It might not be worth the hassle because of the small number
of users who should be using the migration path.

Note that the copyright and license notices really must use C++-style
// line comments, because build constraints can only be preceded by
blank lines and other line comments. C-style /* */ block comments can't
precede the build constraints.

This reverts commit ca899c8a56 and parts
of commit 3aeb7cf288.

[1] go help buildconstraint
    https://pkg.go.dev/cmd/go#hdr-Build_constraints

https://github.com/containers/toolbox/pull/951
2021-12-10 01:33:24 +01:00
Debarshi Ray
063bdf965f cmd/utils: Split out the code to list the common commands
This will be used by the subsequent commit to highlight some of the
more common commands that new user is likely to be interested in, when
none has been specified.

https://github.com/containers/toolbox/pull/951
2021-12-10 00:57:36 +01:00
Debarshi Ray
04426a04e5 build: Add an option for the migration path for coreos/toolbox users
Commit 6c86cabbe5 changed the command line interface to behave
a lot similar to that of github.com/coreos/toolbox, which makes things
easier for those switching over from it.

However, it makes things confusing for the vast majority of users who
have never used coreos/toolbox. The Toolbox CLI aims to be friendly to
new users by being self-documenting and offering a smooth onboarding
experience. It's jarring to new users when 'toolbox', without any
commands specified, suggests that it needs to perform a big download.

It's difficult to document two different sets of CLIs, and if the
manuals don't mention the second behaviour, then it just leaves the
users even more confused.

Hence, it will be good to keep the migration path for coreos/toolbox
behind a build-time option, so that only those OS distributors who
truly need it may enable it without impacting others. Fortunately,
coreos/toolbox doesn't have any manuals, which means that there's no
need to conditionalize the documentation.

This commit merely adds the build-time option. Subsequent commits will
use this to actually conditionalize the code.

https://github.com/containers/toolbox/pull/951
2021-12-10 00:35:13 +01:00
Debarshi Ray
d27cfb4586 build: Style fixes
https://github.com/containers/toolbox/pull/951
2021-12-10 00:34:21 +01:00
Debarshi Ray
8dd7ee47c5 build: Drop the use of patchelf(1)
Some downstream distributors like RHEL don't have patchelf(1). Relying
on patchelf(1) during the build will make it difficult for such
downstreams to distribute Toolbox.

Fortunately, the path of the dynamic linker (ie., PT_INTERP) is
hardcoded in the ABI specification of each architecture [1]. This means
that Toolbox's build system can keep it's own architecture to dynamic
linker mapping, and specify it during the build through the GNU ld
linker's --dynamic-linker flag, as opposed to using a tool like
patchelf(1) to change the path of the dynamic linker in the built
binary to the one inside /run/host. Currently, the list of
architectures covers the ones that Fedora builds for.

[1] https://sourceware.org/glibc/wiki/ABIList

https://github.com/containers/toolbox/pull/942
2021-12-09 13:16:27 +01:00
Debarshi Ray
e28a306a7f build: Bump minimum Meson version to 0.56.0
The subsequent commit will further bump the minimum Meson version to
0.58.0. This will make it easier to read.

https://github.com/containers/toolbox/pull/942
2021-12-08 18:01:35 +01:00
Debarshi Ray
677dda64f3 README.md: Link to the website instead of the code repository
Now that there's a website at https://containertoolbx.org/ it makes
more sense to link to it instead of linking back to the same location
where the README.md resides.
2021-12-08 17:19:47 +01:00
Debarshi Ray
f0dfb8f3c1 README.md: Shorten it by linking to the website wherever possible
https://github.com/containers/toolbox/pull/949
2021-12-08 16:16:18 +01:00
Ondřej Míchal
582c999ecd cmd/create: Drop redundant label when creating a container
The Toolbox repository was moved to the 'containers' organization some
time ago already[0]. Containers marked with the label:

  com.github.debarshiray.toolbox=true

will remain supported but new containers will not be created with it.

https://github.com/containers/toolbox/pull/510

[0] de5e5df9b7
2021-12-06 19:37:58 +02:00
Ondřej Míchal
ae43560d45 test/system: Test startup on Rawhide with supported versions
We need to know if the latest changes in the libc (that is dynamically
linked to the binary) causes problems in containers based on older
releases of Fedora.

The estimate of the version numbers is very crude and does not follow
the upstream schedule. That should not be a problem, though.

A part of an existing test has been reused and made into a helper
function to implement this.

This increases the run time of the test suite on Rawhide which already
takes longer than the same test suite on released versions of Fedora.
Make up for it by increasing the timeout by 2 minutes.

https://github.com/containers/toolbox/pull/899
2021-12-04 17:37:40 +02:00
Ondřej Míchal
ae8bd1a9c9 test/system: Properly bail-out if failed to cache images
The 'die' function is a remnant from times before the system tests
rewrite. It served for writing an error message and then failing
the test. Since the rewrite it is no longer present. Instead, simply
use 'false' in case a caching step fails.

Fallout from da6b6a7c5a6e5e284e6642c29159a872ceec94e2

https://github.com/containers/toolbox/pull/899
2021-12-04 17:37:40 +02:00
Ondřej Míchal
b14d623f21 CONTRIBUTING: Update content
GitHub generates a table of content[0] for markdown documents using the
headings so there's no need to maintain it manually anymore.

There is a new Matrix chat room[1] for getting in touch with the Toolbx
developers. Advertise it instead of the alternatives.

We have new gifs from jimmac, let's use them!

https://github.com/containers/toolbox/pull/939

[0] https://github.blog/changelog/2021-04-13-table-of-contents-support-in-markdown-files
[1] https://matrix.to/#/#toolbx:matrix.org
2021-12-03 18:09:41 +02:00
Ondřej Míchal
6e47e1f4f7 CONTRIBUTING: Fix typos
https://github.com/containers/toolbox/pull/939
2021-12-03 18:09:41 +02:00
Colin Walters
186affcf47 cmd/initContainer: Include execution error in message
This will pair with a future change to `shell.Run()` so that we capture
the child process stderr.

But actually this change on its own is enough since `shell.Run()`
provides an error message when the invoked command was not found or when
some other unknown error has happened.

Before:
  Error: failed to remove password for user walters`
After:
  Error: failed to remove password for user walters: passwd(1) not found`

which helps immediately pinpoint the problem.

I didn't try to go through and change *all* the `shell.Run()`
invocations, but if accepted I may do it (or someone else can).

https://github.com/containers/toolbox/pull/945
2021-12-03 18:01:26 +02:00
Colin Walters
d0104d227e pkg/shell: Simplify code flow
We only need to check against `err != nil` once, not twice.

https://github.com/containers/toolbox/pull/943
2021-12-03 17:32:40 +02:00
Timothée Ravier
fd6510c940 images: Make locate(1) opt-in by default
Currently, the entry point of a Toolbox container runs updatedb(8) on
start-up, which can be very I/O intensive. This might be a hindrance
when troubleshooting performance problems on a host, or when
re-creating containers somewhat more frequently.

Users can install the mlocate RPM and restart their containers to
enable locate(1).

Only the images for currently maintained Fedoras (ie., 34, 35 and 36)
were updated.

https://github.com/containers/toolbox/pull/938
2021-12-01 16:21:42 +01:00
Debarshi Ray
2d56a8a084 README.md: Say Containerfile, not Dockerfile
Fallout from 66c49e0926

https://github.com/containers/toolbox/pull/940
2021-12-01 01:08:56 +01:00