Commit Graph

3491 Commits

Author SHA1 Message Date
Jonathan Lebon
f5fde004dc Makefiles: Drop unnecessary cd rust/ and CARGO_TARGET_DIR
We can simplify these now that Rust is at the root dir.
2021-02-04 17:00:33 -05:00
Jonathan Lebon
df7adbb5f0 Makefile-rpm-ostree: Fix setting of cargo_target_dir
We don't want tabs here otherwise it doesn't work.
2021-02-04 17:00:33 -05:00
Jonathan Lebon
dd6b805fce Makefile-rpm-ostree: Drop hardcoded release path
And actually, we can just use `rpm-ostree` here, which symlinks to the
correct one (and `install` follows links).
2021-02-04 17:00:33 -05:00
Colin Walters
5060cdf7fc ci: Drop clang and unit tests from here
We're running them in Prow now and we're hitting capacity
issues in CentOS CI.  Bigger picture, the "just build and unit test"
stuff runs in any cluster, so let's save our bare metal capacity
for our compose/VM testing.
2021-02-04 15:19:36 -05:00
Luca BRUNO
1932979059 make/rust-test: fix linking and loading
This fixes link dependencies and build-libraries path, in order to
make Rust tests work.
It also introduces an additional wildcard target to allow specifying
a test filter to cargo.
2021-02-04 13:55:00 -05:00
Colin Walters
ae3392ffaf build-sys: Cleanly split up deps of public shlib vs internals
First, the public shared library only depends on a few
things (not the libdnf dependencies) so let's ensure we
only link it to those libraries.

And then, I realized we don't actually need the libdnf
dependencies here - I think I only added those back here
when trying vainly to keep the C unit tests working.  But
we don't have those anymore!  So we can delete the duplication
and fully rely on Cargo taking care of libdnf.

Conceptually for a static library we don't "link" it against
anything in Automake, that happens at the final stage with
the Rust linker.
2021-02-04 10:59:20 -05:00
Colin Walters
19c7fbb7c9 build-sys: Delete duplicate Rust pkg-config dependencies
We didn't need this after switching to a Rust main.
2021-02-04 10:59:20 -05:00
Colin Walters
c383c9511f build-sys: Drop Fedora 25+ rpm version check
I think we can just assume this nowadays.
2021-02-04 10:59:20 -05:00
Colin Walters
588541c60d Move libdnf build over to Cargo
This is now further migration towards Cargo/Rust possible
because we switched our main binary.  We've had an internal
`libdnf-sys` crate for a while, but now it can take over
the build of the underlying library too (like many `-sys`
crates support).

This itself is just an incremental step towards migrating
the main rpm-ostree build system to e.g. cmake too (or
perhaps directly with the `cc` crate, not sure yet) and
driving it via `cargo` too.
2021-02-04 10:59:20 -05:00
Colin Walters
2128f5784a build-sys: Explicit workspace, move libdnf deps to crate
First explicitly state that we're a workspace.  AIUI
this is actually implicit today via our use of a `path`
dependency, but in the future we may have other sub-crates.
So let's make it explicit now.

Also move the libdnf dependencies directly to that sub-crate.
2021-02-04 10:59:20 -05:00
Colin Walters
0a05e467e6 ci: Propagate make jobs to clang build too
Otherwise we try to run 40 processes.
2021-02-03 19:25:26 -05:00
Colin Walters
7268ac9875 ci: Consistently source libbuild
Since we need to set HOME and PATH, let's do that in a central
place rather than scattering it around by having all of
our entrypoint scripts source the `libbuild.sh` shell "library".

Move the CoreOS CI entrypoint into a script like the others.
2021-02-03 19:25:26 -05:00
Colin Walters
6fcfaee948 ci: Don't assume HEAD exists
For some reason the way Prow clones the repo it doesn't exist;
the git default of `..` should work though.
2021-02-03 19:25:26 -05:00
Luca BRUNO
9c3864b97e libpriv/passwd: move entries deduplication logic to Rust
This moves `group` and `passwd` merging/deduplication to Rust.
2021-02-03 15:59:38 -05:00
Colin Walters
fe342c30ed ci: Also test for HOME being writable
Actually it seems OpenShift sets HOME=/ for some reason; probably
related to the non-root uid default.

And whole lot of the Prow jobs do `export HOME=$(mktemp -d)` today.

I am tempted to add a `cosa entrypoint` command or something
that sanitizes the environment setup.
2021-02-03 15:21:42 -05:00
Colin Walters
79f07957f5 ci: Ensure HOME is set
Prow doesn't set this and it breaks our `cargo install`.
2021-02-03 14:07:39 -05:00
Jonathan Lebon
57edf7e638 tests/compose.sh: Always rebuild supermin appliance
We always want the latest rpm-ostree binaries tested, so we need to
always rerun supermin.

Patch better viewed with whitespace ignored.
2021-02-03 12:22:38 -05:00
Jonathan Lebon
317b920667 extensions: Add support for development extensions
In RHCOS, we ship kernel development-related packages as an extension.
Those aren't really extensions that are meant to be layered onto the
host.  They're meant to be used in a build environment somewhere to
compile kernel modules.

This makes it very different from "OS extensions" in at least two
drastic ways:
1. we don't want to do any depsolving (e.g. we don't want to pull in
   `gcc` or something)
2. some of those packages may be present in the base already, but we
   still want to redownload them

Hesitated putting this functionality in rpm-ostree, but I think in the
end it cuts from the benefit of moving this code to rpm-ostree if we
can't entirely get rid of the Python script it obsoletes. Plus, being
able to use the `match-base-evr` is still really useful for this use
case.

Let's add a new `kind` key to support this. The traditional extensions
are called "OS extensions" and these new extensions are called
"development extensions".

The latter is not yet part of the state checksum, so change detection
doesn't work there. I think that's fine for now though because the
primary use case is the kernel, and there we want to match the base
version. So if the kernel changes, the base would change too. (Though
there's the corner case of adding a new package to the list while at the
same version...)
2021-02-03 12:22:38 -05:00
Jonathan Lebon
20ab52adaa rust/treefile: Drop unnecessary #[serde(rename)]
The key is already called `rpmdb`.
2021-02-03 12:22:38 -05:00
Jonathan Lebon
f4bee1352d app/compose: Add comment about pkgcache
Gives a bit more info about how the extensions path is different from
the base treecompose.
2021-02-03 12:22:38 -05:00
Jonathan Lebon
9d07286f3d extensions: Fix missing CxxResult 2021-02-03 12:22:38 -05:00
Jonathan Lebon
f7090358be extensions: Support enabling additional repos
We want to be able to enable more repos than those in the treefile when
downloading extensions. In RHCOS for example, the `kernel-rt` packages
come from a separate repo.

But also, once we support "development" extensions, we want to support
the case where devel packages come from another repo.
2021-02-03 12:22:38 -05:00
Jonathan Lebon
bbc72cbf6b core: Fix handling of local packages when downloading
In the core context, this is redundant with `sort_packages` because it
won't put local packages in the `pkgs_to_download` array anyway, but we
want this check even if we call `rpmostree_download_packages` directly
and pass some packages which may be local.
2021-02-03 12:22:38 -05:00
Jonathan Lebon
90c546c5dc core: Factor out function to download pkgs
I want to be able to use this function without an `RpmOstreeContext`.

Prep for future patch.
2021-02-03 12:22:38 -05:00
Jonathan Lebon
e85c86be79 core: Factor out function to set repos on pkgs
And use a hash table to make it more efficient.

Prep for future patch.
2021-02-03 12:22:38 -05:00
Colin Walters
9248668d35 Also export PATH here
Prow job is running this one directly.
We really need to clean this up...
2021-02-03 12:00:08 -05:00
Colin Walters
9b2e78ed05 ci: Add a commit validation entrypoint 2021-02-03 12:00:08 -05:00
Kelvin Fan
4dd80a8b9c app/status: Use AutomaticUpdatesDriver if updates driven by external driver
When automatic updates are driven by an external driver like Zincati,
display e.g. `AutomaticUpdatesDriver: Zincati` instead of
`AutomaticUpdates: driven by Zincati`, since the latter might suggest it
is rpm-ostree's own built-in support for automatic updates.
2021-02-03 09:52:43 -05:00
Kelvin Fan
1e79e5abde app/status: Show update driver's state and status
Display update driver's systemd unit's `ActiveState` property.
Also display `StatusText` property if unit is a service unit and
property is available.
2021-02-03 09:52:43 -05:00
Colin Walters
d616f73539 scripts: Fix a stack use-after-free
I think this changed in a recent refactoring; basically since
we're passing this stack-allocated value to the child spawn
function we need to keep it alive.  This of course would
have been caught by Rust...

```
==672376==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffc290d9440 at pc 0x55c88c318946 bp 0x7ffc290d8b10 sp 0x7ffc290d8b08
    #0 0x55c88c318945 in script_child_setup src/libpriv/rpmostree-scripts.cxx:272
    #1 0x7f92089da902  (/lib64/libglib-2.0.so.0+0x9f902)
    #2 0x7f92089de20f  (/lib64/libglib-2.0.so.0+0xa320f)
    #3 0x7f92089de52e  (/lib64/libglib-2.0.so.0+0xa352e)
    #4 0x7f92089def02 in g_spawn_async_with_pipes (/lib64/libglib-2.0.so.0+0xa3f02)
    #5 0x7f9208b7445f  (/lib64/libgio-2.0.so.0+0xab45f)
    #6 0x7f9208b736d8 in g_subprocess_launcher_spawnv (/lib64/libgio-2.0.so.0+0xaa6d8)
    #7 0x55c88c3831b9 in rpmostree_bwrap_execute src/libpriv/rpmostree-bwrap.cxx:504
    #8 0x55c88c3836df in rpmostree_bwrap_run_captured src/libpriv/rpmostree-bwrap.cxx:450
    #9 0x55c88c31b5f1 in rpmostree_run_script_in_bwrap_container src/libpriv/rpmostree-scripts.cxx:469
    #10 0x55c88c31ca9d in impl_run_rpm_script src/libpriv/rpmostree-scripts.cxx:588
    #11 0x55c88c31d22b in run_script src/libpriv/rpmostree-scripts.cxx:637
    #12 0x55c88c31d22b in rpmostree_script_run_sync src/libpriv/rpmostree-scripts.cxx:778
    #13 0x55c88c2ef830 in run_script_sync src/libpriv/rpmostree-core.cxx:3661
    #14 0x55c88c30afa6 in rpmostree_context_assemble src/libpriv/rpmostree-core.cxx:4422
    #15 0x55c88c34a9af in install_packages src/app/rpmostree-compose-builtin-tree.cxx:451
    #16 0x55c88c34c174 in impl_install_tree src/app/rpmostree-compose-builtin-tree.cxx:925
    #17 0x55c88c350f84 in rpmostree_compose_builtin_tree src/app/rpmostree-compose-builtin-tree.cxx:1421
    #18 0x55c88c276ec8 in rpmostree_handle_subcommand src/app/libmain.cxx:405
    #19 0x55c88c27827c in rpmostree_main_inner src/app/libmain.cxx:521
    #20 0x55c88c27827c in rpmostreecxx::rpmostree_main(rust::cxxbridge1::Slice<rust::cxxbridge1::Str const>) src/app/libmain.cxx:546
    #21 0x55c88c271c25 in operator() /var/srv/walters/src/github/coreos/rpm-ostree/rpmostree-cxxrs.cxx:1257
    #22 0x55c88c271c25 in trycatch<rpmostreecxx::rpmostreecxx$cxxbridge1$rpmostree_main(rust::cxxbridge1::Slice<const rust::cxxbridge1::Str>)::<lambda()>, rpmostreecxx::rpmostreecxx$cxxbridge1$rpmostree_main(rust::cxxbridge1::Slice<const rust::cxxbridge1::Str>)::<lambda(char const*)> > /var/srv/walters/src/github/coreos/rpm-ostree/rpmostree-cxxrs.cxx:997
    #23 0x55c88c271c25 in rpmostreecxx$cxxbridge1$rpmostree_main /var/srv/walters/src/github/coreos/rpm-ostree/rpmostree-cxxrs.cxx:1255
    #24 0x55c88c0468f7 in rpmostree_rust::ffi::rpmostree_main::hfedda48c684245ce rust/src/lib.rs:25
    #25 0x55c88c0468f7 in rpm_ostree::inner_main::hf078b99ca4b270aa rust/src/main.rs:9
    #26 0x55c88c0468f7 in rpm_ostree::main::hc0ca527cfaa3f556 rust/src/main.rs:28
    #27 0x55c88c046b22 in core::ops::function::FnOnce::call_once::h8567110dac55274e /var/home/walters/.rustup/toolchains/1.48-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227
    #28 0x55c88c046b22 in std::sys_common::backtrace::__rust_begin_short_backtrace::h1c67f2f52d05cfa0 /var/home/walters/.rustup/toolchains/1.48-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:137
    #29 0x55c88c045fd7 in main (/usr/bin/rpm-ostree+0xc9fd7)
    #30 0x7f92076091e1 in __libc_start_main (/lib64/libc.so.6+0x281e1)
    #31 0x55c88c045b9d in _start (/usr/bin/rpm-ostree+0xc9b9d)

Address 0x7ffc290d9440 is located in stack of thread T0 at offset 272 in frame
    #0 0x55c88c31a1af in rpmostree_run_script_in_bwrap_container src/libpriv/rpmostree-scripts.cxx:349
```
2021-02-03 04:30:23 -05:00
Colin Walters
058178680f ci: Skip installing deps if non-root
Assume in the pet/dev container case the user already has
deps.  And for Prow we're using the buildroot container which
should have them.
2021-02-02 19:34:22 -05:00
Colin Walters
57978fe099 ci/build-check: Don't make install
We may be running unprivileged (e.g. Prow), and `make install` needs to
be a uid 0 task.
2021-02-02 19:34:22 -05:00
Colin Walters
61a50e3d0e build-sys: Rebuild on C++ changes
Not running the code you think you are is an evil trap.
Fixes fallout from b122579222
2021-02-02 05:38:15 -05:00
Colin Walters
ded61a472f build-sys: Move some linkage purely to Rust
Now that we are generating solely a Rust binary, we can
have the canonical list of things to link on the Rust side.
2021-02-02 04:13:14 -05:00
dependabot[bot]
5b91ac6a3c build(deps): bump cxx from 1.0.28 to 1.0.29
Bumps [cxx](https://github.com/dtolnay/cxx) from 1.0.28 to 1.0.29.
- [Release notes](https://github.com/dtolnay/cxx/releases)
- [Commits](https://github.com/dtolnay/cxx/compare/1.0.28...1.0.29)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-01 12:20:49 -05:00
Colin Walters
d218f27188 Change main entrypoint to be Rust
We now have bidirectional calling between Rust and C++,
but we are generating two static libraries that we then
link together with a tiny C++ `main.cxx`.
Let's make another huge leap towards oxdiation by
having Rust be the entrypoint.  This way cargo natively
takes care of linking the internal Rust library, and
our C++ internals become the library.

In other words, we've now fully inverted from
"C app with internal Rust library"
to "Rust binary with internal C++ library".

In order to make this work though we have to finally
kill the C unit tests.  But mostly everything covered
there is either being converted to Rust, or covered
elsewhere anyways.

Now as the doc comments in `main.rs` say...this is
a bit awkward because all the CLI code is still in C++.
Porting stuff to use e.g. `structopt` natively would
be a bit of a slog.  For now, we basically rely on
the fact that the Rust-native CLIs are all hidden
commands.

Update submodule: libdnf
2021-02-01 08:17:52 -05:00
Colin Walters
e3375626d5 ci: Drop custom msrv checking
The way this tries to replace the system Rust is hacky and
actually I realized belatedly I may have broken it recently; basically
`installdeps.sh` re-adds the system one, and it's hard to be sure
with our current buildsystem we're using the newer one from `$PATH`.

What we really want to do here is use a CentOS8 buildroot,
which will automatically enforce this in a better way along
with solving other problems.  But right now we've broken
that because libdnf requires a too-new libmodulemd.

So let's just rely on the Fedora rust for now.
2021-02-01 04:54:52 -05:00
Colin Walters
14f75f94ef ci: Split clang into separate script, run it in CoreOS CI
Let's do a build with clang as a cleanly separate context
instead of serially; and also do it unconditionally.  This
is prep for turning on more `-Werror` flow in both cases,
and also using clang `scan-build` in CI.
2021-02-01 04:54:52 -05:00
Colin Walters
4b1120d57e ci: Drop testuser creation
Nothing is using this; our unit tests don't change uids and
most of our testing is in VMs.

Dropping this makes it easier to run the scripts outside of CI.
2021-02-01 04:54:52 -05:00
Colin Walters
83c7c90b83 tree-wide: Convert g_return.*if_fail to g_assert
See https://github.com/rpm-software-management/libdnf/pull/1127

Basically IMO the "return if fail" pattern is a carry-over
from C GTK+ apps where the idea is it's better to try to stumble
forward than have the app crash for the user.

In our case though, IMO we absolutely should just crash
if our assertions trip, because we're maintaining the user's
root filesystem.
2021-02-01 04:02:52 -05:00
dependabot[bot]
d9cd07f92b build(deps): bump libc from 0.2.82 to 0.2.84
Bumps [libc](https://github.com/rust-lang/libc) from 0.2.82 to 0.2.84.
- [Release notes](https://github.com/rust-lang/libc/releases)
- [Commits](https://github.com/rust-lang/libc/compare/0.2.82...0.2.84)

Signed-off-by: dependabot[bot] <support@github.com>
2021-02-01 03:37:52 -05:00
Colin Walters
ba9a17d861 build: Use -std=c++17
Notably this includes [std::optional](https://en.cppreference.com/w/cpp/utility/optional)
which I'd like to use.

The dnf-5-devel branch uses this too, and C++-17 is now well
supported in current GCC, which is available in RHEL8 DTS too.
2021-01-29 14:28:21 -05:00
Luca BRUNO
140357d549 rust/passwd: minor cleanup, use write_file_with_sync 2021-01-29 12:41:20 -05:00
Luca BRUNO
536bfc62eb libpriv/passwd-util: move migration logic to Rust
This moves passwd/group splitting logic to Rust, also decoupling
the two implementations in order to reduce overall complexity.
2021-01-29 08:15:48 -05:00
Colin Walters
e87a64576c Bridge "next version" API to Rust, use it for unit tests
This demonstrates well the strength of the cxx-rs approach;
we can keep an API in C++ but add unit tests in Rust which
just works much more nicely.

Prep for https://github.com/coreos/rpm-ostree/pull/2502
which wants to drop the C++ unit tests.
2021-01-29 05:29:47 -05:00
Colin Walters
7ab1936814 cliwrap: Fix indentation
We need to trim the starting whitespace, otherwise
it ends up in the script.
2021-01-28 21:26:47 -05:00
Colin Walters
bbaab4c1ff scripts: Remove, not used
The correct place for this would be...something like ostree-releng-tools
or coreos-assembler.  Or perhaps in the future a Rust ostree-ext-tools repository.
2021-01-28 15:58:24 -05:00
Colin Walters
47f6d9850e vagrant: Remove this
The default dev workflow is coreos-assembler based.
2021-01-28 15:58:24 -05:00
Colin Walters
1cef69cf8a lib: Don't link to libdnf
Prep for "Rust-as-main", where I want to build libdnf statically.
And this really completes the "library thinout" story because
now we avoid dragging our *private* `libdnf.so` into the caller's
address space, which can cause potential conflicts if they're
also linking the system one. (Which could easily occur with
something like gnome-software)

All we were using libdnf for (indirectly via libsolv) is comparing
version strings but librpm can already do that for us.
2021-01-28 11:15:44 -05:00
Colin Walters
e88a736e55 lockfile: Note that comment is JSON
Otherwise rustc tries compile and run it as a doctest.
2021-01-27 19:36:34 -05:00