Commit Graph

44 Commits

Author SHA1 Message Date
Colin Walters
e5294829b8 Add human-readable Title to transaction, render in status
There's a lot that could be done to improve this; we're not setting a title for
`rollback` etc. But I think in practice right now the "deploy" path (which
includes upgrade/install) etc. is most important.

Re-synthesizing a human readable string here is definitely a bit fragile and
going to be a maintenance pain. One thing I debated is having the client send
its commandline as a string. But that would only work for `/usr/bin/rpm-ostree`,
not e.g. Cockpit.

Anyways for now, this is useful and we can always improve it later.

Closes: https://github.com/projectatomic/rpm-ostree/issues/454

Closes: #814
Approved by: jlebon
2017-06-02 17:27:10 +00:00
Colin Walters
95e9aa4284 Introduce ex livefs
There are a few different use cases here. First, for layering new packages,
there's no good reason for us to force a reboot. Second, we want some support
for cherry-picking security updates and allowing admins to restart services.  Finally,
at some point we should offer support for entirely replacing the running tree
if that's what the user wants.

Until now we've been very conservative, but there's a spectrum here. In
particular, this patch changes things so we push a rollback before we start
doing anything live. I think in practice, many use cases would be totally fine
with doing most changes live, and falling back to the rollback if something went
wrong.

This initial code drop *only* supports live layering of new packages.  However,
a lot of the base infrastructure is laid for future work.

For now, this will be classified as an experimental feature, hence `ex livefs`.

Part of: https://github.com/projectatomic/rpm-ostree/issues/639

Closes: #652
Approved by: jlebon
2017-05-12 15:00:59 +00:00
Colin Walters
a180a35a48 status: Do show Commit with --verbose, don't show StateRoot without it
`Commit` is useful in cases where one wants to e.g. run `rpm-ostree db diff`.
`StateRoot` however is going to be in the vast majority of cases identical
across deployments.

Closes: #743
Approved by: jlebon
2017-04-21 13:31:21 +00:00
Colin Walters
b2f9c5ed82 status: Rename OSName → StateRoot in the human-readable text
See: https://github.com/ostreedev/ostree/pull/794

I originally tried to do this ~a year ago in:
https://github.com/projectatomic/rpm-ostree/pull/295

But Micah pushed back at the time.  I'd still like to do this
though, since I personally find `OSName` *more* confusing
than `StateRoot`.

One specific rationale I have for making this change is that
I rebased a home server from CentOSAH to FAH - and I feel
it's just saner to see `StateRoot: centos-atomic-host` instead
of `OSName: centos-atomic-host` underneath the fedora refspec.

Closes: #743
Approved by: jlebon
2017-04-21 13:31:21 +00:00
Jonathan Lebon
c35622dada app: make use of new UpdateDeployment()
Add support for --install/--uninstall to upgrade/deploy/rebase by
calling out to UpdateDeployment(). Since it's not released yet, back out
the support for install-local-packages in the options variant for
PkgChange(), and make it instead use UpdateDeployment() as needed.

Closes: #711
Approved by: cgwalters
2017-03-31 14:58:38 +00:00
Jonathan Lebon
071aa93f03 app: convert many builtins to new return style
One interesting note here was that I couldn't use glnx_throw in as many
places as I wanted because EXIT_SUCCESS/EXIT_FAILURE are the exact
opposite of that semantic. It was still convenient to use though as a
short-form for g_set_error().

Closes: #704
Approved by: cgwalters
2017-03-23 21:49:50 +00:00
Colin Walters
35436827af status: Only show one of BaseCommit/Commit
Following up on the previous commit regarding timestamps - the checksum of the
derived commit isn't very useful. It's not going to be the same between any two
people's systems. What we should show instead is the rpm-md repository
timestamps.

In the short term though, I think omitting this even without the rpm-md
timestamps is better.  Less visual clutter.

Closes: #697
Approved by: jlebon
2017-03-21 20:33:24 +00:00
Colin Walters
77548d06ee status: Use the timestamp from the base, not layered
Currently we propagate the version field from the base to derived,
but the status UI shows the timestamp from the derived commit.

I found this *extremely* confusing when I was trying to reason about the
up-to-dateness of my system. The version and timestamp should be locked
together so we display them consistently.

When we generated the local commit isn't really useful information; conceptually
we have the base timestamp, plus timestamps for the rpm-md repos. We should
display the latter instead.

(This also adds `base-timestamp` and `base-verison` to the JSON; only
 the former is new information, but the latter helps us be consistent)

Closes: #697
Approved by: jlebon
2017-03-21 20:33:24 +00:00
Colin Walters
12c34bb249 Move flags into command struct, pass down through builtins
This is prep work for https://github.com/projectatomic/rpm-ostree/issues/682

Closes: #683
Approved by: jlebon
2017-03-16 19:57:14 +00:00
Jonathan Lebon
81c43e81fb PkgChange: add support for layering local RPMs
Allow users to directly specify an RPM file on the command-line. The
"packages_added" array of the PkgChange() method can now contain
absolute paths to RPM files.

Grow the origin format to have a new "requested-local" key. This is
similar to the "requested" key, except that the packages are always
installed from cache. The "requested-local" array values also embed the
SHA-256 of the header we expect.

There is now a new "LocalPackages" line in the status. These packages
are a subset of the "packages" element (which are printed as
"LayeredPackages") and represent the packages that are explicitly marked
for installing from cache.

Interesting design choices/notes:
  - Just as before, even with foo-1.0-1.x86_64 installed from RPM, a
    user can still request "/usr/bin/foo": it will be made dormant. As
    soon as foo stops being explicitly layered from the RPM, it will try
    to fulfill the request by going to the repos. This allows users to
    "pin" a layered package to a certain RPM, and then unpin it.
  - The strings/NEVRAs in "requested" and "requested-local" are strictly
     distinct. This allows us to be able to tell what the user means
     exactly when they do "rpm-ostree uninstall".

Closes: #657
Approved by: cgwalters
2017-03-10 18:35:11 +00:00
Jonathan Lebon
051492b3e6 upgrader: switch to stateless model
This is the culmination of the work paved by the previous commits. We no
longer handle package set mutations in the upgrader, but rather let
clients modify the origin as needed for that. As such, the upgrader is
now completely memoryless. We no longer try to error out if a package is
already in the base and we no longer drop out packages previously
layered packages that are now in the base. *Which* packages actually get
layered is determined during deployment and not coded in the origin.

At an API level, the deployment variant returned (and thus what gets
printed by `status --json`) now has both "packages" and
"requested-packages". The former retains its original semantic: it's the
set of packages that are *actually* layered. The latter contains
everything from the origin, which includes the former set + dormant
packages.

Accordingly, the output of `rpm-ostree status` also now distinguishes
between "RequestedPackages" and "LayeredPackages". Extra: we now quote
provides that contain spaces.

Closes: #646
Approved by: cgwalters
2017-02-27 19:53:19 +00:00
Colin Walters
ace223acf8 Add pending-base-commit to status
One thing that's very confusing about OSTree is there are two layers -
deployments and the refs/commits. If one does an `rpm-ostree upgrade`, but then
e.g. `ostree admin undeploy 0`, you still have the new revision in the repo.

We don't do a good job of displaying this state, or helping people clean
it up.

Down the line, I also want to better support something like `rpm-ostree pull` to
cache updates explicitly *without* deploying.

This commit just adds a bit of information to the status display. We might want
to have better formatting, but I think this an OK start.

Closes: #595
Approved by: jlebon
2017-02-08 13:59:48 +00:00
Colin Walters
cac4522e5b Support "system/regenerate-initramfs=true" flag in origin
Currently we push for a model where the initramfs is
generated (in non-hostonly mode), and merely replicated.

However, to support a few unfortunate corner cases like dm-multipath which wants
to inject a config file into the initramfs, we need to support regenerating it
client side too.

Down the line, we'll need this to support overriding the kernel too.

This changes things in the core to add the concept of an "empty"
`RpmOstreeContext`. I initially tried skipping it, but that was too much
duplication. We still want all of the core ostree-related logic that lives in
that code too.

The treespec bits barfed if the spec didn't have a `tree/packages` key. It was
simplest to change that to allow it - and because that was the only case where
we errored out in parsing, I dropped the error handling.

There was another place in the upgrader that now needed to be fixed to handle
transitioning from just regenerating initramfs to not.

Closes: #574
Approved by: jlebon
2017-01-20 16:17:51 +00:00
Colin Walters
975c0703c3 [ASAN] tree-wide: Clean up gvariant-related leaks
I kept thinking `^a&s` was sufficient for allocation-free reading
of `as`, but it's not, we need to free the outer buffer.  Other
minor cases were using `s` instead of `&s`.

Closes: #533
Approved by: jlebon
2016-12-06 16:47:26 +00:00
Colin Walters
7095c313d8 [ASAN] tree-wide: Clean up leaks of option context
Not all of these were leaks, but let's be consistent and use
`g_autoptr()` for `GOptionContext` everywhere.

Closes: #533
Approved by: jlebon
2016-12-06 16:47:26 +00:00
Colin Walters
e4068c5094 tree-wide: Fix use of potentially uninitialized variables
These were caught by Clang.

Closes: #505
Approved by: jlebon
2016-10-28 20:28:35 +00:00
Jonathan Lebon
80267a423a status: handle errors from json-glib
The API for json_generator_to_stream() says:

    Return value: %TRUE if the write operation was successful, and
    %FALSE on failure. In case of error, the #GError will be filled
    accordingly

When in fact, because it just gives back what g_output_stream_write(),

    1. it doesn't strictly return TRUE/FALSE, but a full-range uint, and
    2. it will return -1 (which is as good as anything > 0 for success
       checks) when an error occurs.

Although a simple <= 0 would fix it, let's just be extra strict and also
check for an error.

Closes: #468

Closes: #469
Approved by: miabbott
2016-09-26 14:49:51 +00:00
Colin Walters
436a8116f2 status: Sort the output package list
I am thinking of indenting into multiple lines if it gets long too,
but this is a small visual improvement.

Closes: #440
Approved by: jlebon
2016-08-30 20:09:24 +00:00
Colin Walters
4ccee066a0 Add gpg-enabled to DBus data, hide GpgSignature field if disabled
It's really in-your-face for admins to see `(unsigned)` which originally
was intentional, but in practice right now at least several major
users (Fedora, RHEL) don't enable GPG signatures.

So let's just hide it if not enabled.

Perhaps in the future we should add a `-v` option or something which
would show all of the fields even if not enabled.

Closes: #399

Closes: #402
Approved by: jlebon
2016-07-21 20:52:28 +00:00
Jonathan Lebon
225be81c40 RPMOSTreeSysroot: add "booted" entry to deployment variant
Now that the `status` command learned a `--json` option, we can pretty
much avoid parsing human-readable output. The only piece of information
that is missing from the JSON output compared to the output for humans
is *which* deployment we're currently booted in.

This patch fixes that shortcoming by adding a "booted" boolean variant
to the deployment variant.

Closes: #350
Approved by: cgwalters
2016-06-25 12:23:04 +00:00
Colin Walters
90cae512a8 status: Print active transaction
I really want a command to cancel the running transaction, but as a
preparatory step, let's display what's going on in `status`.

The text output here is really a demonstration - I'll improve it but I
want to rework the internals first.

Closes: #320
Approved by: jlebon
2016-06-20 14:38:33 +00:00
Colin Walters
63ee7d0a9a status: Make JSON an object with "deployments" subkey
In the future I want to add more content in the status such
as active operations, so let's make the "deployments" just
one entry in an object.

Closes: #320
Approved by: jlebon
2016-06-20 14:38:33 +00:00
Colin Walters
b7d1b827b7 status: Support --json option
It's really simple to reflect the DBus API into JSON, which tools like
Ansible or `jq` from the command line or whatever can parse to find
interesting things like the current version.

Closes: #301

Closes: #315
Approved by: jlebon
2016-06-13 14:54:25 +00:00
Jonathan Lebon
b243ac1b70 status: print version string in bold
I think 99% of the time, that's the only thing users are interested in.
Make it bold to make it easier to see.

Closes: #314
Approved by: miabbott
2016-06-09 20:34:11 +00:00
Colin Walters
c756d55127 status: Print unlocked state
For obvious reasons it's data we'd like to show.

Closes: #295
Approved by: jlebon
2016-06-09 19:33:19 +00:00
Colin Walters
0724240092 status: Replace status with key-value output
With the end goal in mind that I want to optimize for the case
of 1-2 deployments, it's actually a lot simpler to just
nuke the whole current column base.

It just really doesn't make sense with layered packages, and even
before then, I usually found the timestamp and osname columns
redundant.

Closes: #295
Approved by: jlebon
2016-06-09 19:33:19 +00:00
Colin Walters
b82405d17b status: Move current status display into function
Pure code motion, no real functional changes.  Preparation for having
multiple statuses.

Closes: #295
Approved by: jlebon
2016-06-09 19:33:19 +00:00
Colin Walters
20e69a9692 status: Import systemd bits to use UTF-8 circle
It's slightly prettier, but this is just laying some
groundwork/precedent for importing more systemd code and using it for
our formatting.

Closes: #295
Approved by: jlebon
2016-06-09 19:33:19 +00:00
Jonathan Lebon
2a036cf8b4 package-layering fixups
This patch fixes up errors in the parent commit which added pkg-add.
Some of them are due to the rebase on top of the unprivileged
infrastructure.

- fix compile errors (due to libhif changes after rebase)
- delete duplicate prototype for rpmostree_sysroot_upgrader_deploy
- include allow-older in flags type
- fix change_upgrader_refspec to use g_strdup() (this was causing the
  wrong old refspec to be registered)
- in builtin-status.c, check for NULL before joining the packages array
- sysroot-upgrader: fix gtype function names
- roc_context_prepare_for_root(): delete unused param
- assemble_commit(): delete unused param
- RpmOstreeSysrootUpgraderFlags: fix docs
- Fix sysroot property name and add reboot opt

Closes: #289
Approved by: cgwalters
2016-05-27 22:18:44 +00:00
Colin Walters
beb026f701 pkg-add: New builtin to layer additional packages
This builds upon the earlier prototype in
https://github.com/cgwalters/atomic-pkglayer

The `.origin` file says for a replicated installation:

    [origin]
    refspec=local:rhel-atomic-host/7/x86_64/standard

If you then run `rpm-ostree pkg-add strace`, it will result in a new tree with:

    [origin]
    baserefspec=local:rhel-atomic-host/7/x86_64/standard

    [packages]
    requested=strace;

Work still remaining here is to teach `rpm-ostree status` and
`rpm-ostree upgrade` about this.

Closes: #289
Approved by: cgwalters
2016-05-27 22:18:44 +00:00
Jonathan Lebon
dbaade3c4f status.c: don't print trailing spaces for last field
This will allow users' terminals to be 5 columns thinner without
seemingly printing a blank line between each row.
2016-03-02 13:55:11 -05:00
Jonathan Lebon
170ad1946d status.c: fix case where header is longer than fields
For the columns that can vary in width, check that the minimum width of
the column is at least the length of the column header. Otherwise, we
can run in a situation where some columns are stuck to each other. The
trivial strlen() should be optimized to a constant by the compiler.
2016-03-02 13:55:11 -05:00
Matthew Barnes
fa83724187 status: Fix some crashes
Encountered a couple crash scenarios:

1) A commit with an invalid timestamp trips an assertion.  Instead
   show the timestamp as "invalid".

2) If a deployed commit is unsigned, the daemon will not include a
   "signatures" array in the deployment's GVariant representation.
   The logic for --pretty was assuming the "signatures" array is
   always present.
2015-12-01 12:11:40 -05:00
Matthew Barnes
1af2a08e54 app: Allow for custom exit status codes
Change the command callback return type to integer, so commands can
return a custom exit status.  Usually it should be EXIT_SUCCESS (0)
or EXIT_FAILURE (1).
2015-11-06 09:10:48 -05:00
Matthew Barnes
58e826f76c status: Fix the asterisk
Asterisk next to the booted deployment broke at some point during
daemon development.
2015-10-06 17:04:04 -04:00
Matthew Barnes
a22c592a78 daemon: Use GVariantDict ("a{sv}") for deployments
Allows for future extensibility.  Also some of the optional attributes
can actually be optional.  See the XML interface spec for the key names.
2015-09-09 22:00:06 -04:00
Matthew Barnes
d54f25a9e4 app: Collect D-Bus CLI options into main.c
In the style of ostree's CLI, add some option parsing flags

    RPM_OSTREE_BUILTIN_FLAG_NONE
    RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD

and extend rpmostree_option_context_parse() to handle the --sysroot and
--peer options and return an OstreeSysroot proxy object (unless the flag
RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD is passed).
2015-09-09 22:00:05 -04:00
Matthew Barnes
c57cc38c6e app: Extract GDBusConnection from GDBusProxy
Remove another redundant "out" parameter from DBus helper functions.
Use g_dbus_proxy_get_connection() if the connection object is needed.
2015-09-09 22:00:05 -04:00
Matthew Barnes
7190f7b351 app: Detect peer connection from GDBusConnection
If g_dbus_connection_get_unique_name() returns a name, we're connected
to a message bus.  Otherwise we're connected directly to a peer.

Remove redundant "out" parameters from DBus helper functions.
2015-09-09 22:00:05 -04:00
Matthew Barnes
463d3676ea daemon: Miscellaneous cleanups 2015-09-09 22:00:05 -04:00
petervo
f525730187 daemon: Make parts of cli use the daemon 2015-09-09 22:00:04 -04:00
Colin Walters
c16058b66a libpriv: Move rpm/hawkey util functions into -rpm-util
`treepkgdiff` no longer describes the function of the file; as a baby
step towards unifying the db and hawkey code, move the functions into
that file.
2015-04-23 16:30:18 -04:00
Matthew Barnes
347a5003e0 status: Print any GPG signatures for deployments
In pretty mode (--pretty), print signatures for each listed deployment.

Otherwise, just print signatures for the booted deployment at the end to
preserve the tabular formatting of the deployment list.
2015-04-17 12:32:35 -04:00
Colin Walters
a8a2049443 build: Split up src into app/ and libpriv/
We currently have an internal-only library, but the sources for it are
in the same dir as the app.  For future work on a public shared
library, we'll need a clearer source structure.

Start by just renaming the app files into `src/app/`, and the internal
private library into `src/libpriv/`, with the appropriate
`Makefile.am` changes.

Closes: https://github.com/projectatomic/rpm-ostree/pull/123
2015-04-08 16:17:06 -04:00