Commit Graph

718 Commits

Author SHA1 Message Date
Jonathan Lebon
66daf13d68 rpm-ostree-1.pc.in: fix cflags
Closes: #308
Approved by: cgwalters
2016-06-08 13:19:45 +00:00
Jonathan Lebon
6b07755d68 add RPMOSTREE_UNINSTALLED_PKGLIBDIR
Since we now run everything uninstalled, we can't expect the tmpfiles
conf file to be installed. We add an env var that will allow us to tell
rpm-ostree to look elsewhere. This is then used in test-compose.sh.

Closes: #304
Approved by: cgwalters
2016-06-06 21:14:07 +00:00
Colin Walters
3a93fc162f core: Checksum package checksums, not just NEVRA for change detection
GPG signing an RPM doesn't change its NEVRA, and we need to support
detecting the case when RPMs change from unsigned to signed (or vice
versa).

It's also quite common for local developers to rev RPMs without
bumping the release or whatever, so this will fix that too.

Closes: #291

Closes: #296
Approved by: jlebon
2016-06-02 18:40:32 +00:00
Colin Walters
6472b75a69 daemon: Fix regression in --preview/--check
Some code changes in the package layering broke this to always
error out with `refs are equal`.

Reading the code I was confused for a bit until it dawned on
me that `self->refspec` was the input, and we extracted the current
one in a different way.  I ended up modeling it back on the last
working commit I saw (`9eabc1ba`).

That said the logic here could be cleaned up more...it feels like we
should just have a "dry run" flag for the rebase transaction core or
something.  Anyways, going for a surgical fix now.

Closes: #299
Approved by: jlebon
2016-06-02 15:02:06 +00:00
Colin Walters
93e4039f60 core: Dedup hardlink/tempfile code
I wanted to avoid yet another copy of the "generate tempfile name"
code, so moved it to libglnx:

  https://github.com/GNOME/libglnx/pull/14

This also closes the TODO about deduping the "break one hardlink" code
with the "break all links in one dir" code.  The core observation here
is that it's simpler to copy to a tempfile and rename over the
existing, rather than rename, create, unlink.

Closes: #293
Approved by: jlebon
2016-06-01 15:15:11 +00:00
Jonathan Lebon
ead1ecdd23 package layering: major rework
- Move the package layering logic away from pkg-add and into the
  upgrader
- Add pkg-delete
- Add dry-run option

Closes: #289
Approved by: cgwalters
2016-05-27 22:18:44 +00:00
Jonathan Lebon
a25cdde25c core: major rework
This patch prepares RpmOstreeContext for supporting package layering. A
relabel operation is added as well to support relabeling imported
packages if the sepolicy of the rootfs we're overlaying onto is
different from during import.

Closes: #289
Approved by: cgwalters
2016-05-27 22:18:44 +00:00
Jonathan Lebon
1ccc560c26 output: support printf type usage
Closes: #289
Approved by: cgwalters
2016-05-27 22:18:44 +00:00
Jonathan Lebon
ca162dece2 unpacker: major rework
- Delete unpack_to_dfd path
- Get rid of copynpaste stuff and use the newly reworked ostree
  libarchive API which now supports the callbacks we need

Closes: #289
Approved by: cgwalters
2016-05-27 22:18:44 +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
d9e8535bcf treecompose: fix crash when "remove-from-packages" used
This works around a potential issue with libsolv if we go down the
rpmostree_get_pkglist_for_root() path. Though rpm has been using the
/usr/share/rpm location (since the RpmOstreeContext set the _dbpath
macro), the /var/lib/rpm directory will still exist, but be empty.
libsolv gets confused because it sees the /var/lib/rpm dir and doesn't
even try the /usr/share/rpm location, and eventually dies when it tries
to load the data.

So we set the symlink now. This is also what we do on boot anyway for
compatibility reasons using tmpfiles.

This also means we don't have to do the /var/lib/rpm --> /usr/share/rpm
transition during the rootfs postprocess (but we still have to clean up
db and lock files).

Also get rid of the unused pkglist variable.

NB: I used the GFile & gs APIs to mesh with the surrounding code.

Closes: #290
Approved by: cgwalters
2016-05-27 17:06:08 +00:00
Colin Walters
2cab8216b4 core: Adapt to libhif API query change
We'll track git master.

Closes: #286
Approved by: jlebon
2016-05-19 17:44:34 +00:00
Colin Walters
cbadc9bdaa libpriv: Print repository name for each package too
I'm trying to debug why I'm getting an older version of `docker`,
and it's useful to see the repository name we're getting something
from.  Yum does this by default.

(Though we should probably consider column formatted output too
 on a tty)

Closes: #282
Approved by: jlebon
2016-05-11 16:07:50 +00:00
Jonathan Lebon
582650e9c7 daemon: add TaskBegin, TaskEnd, and PercentProgress
Closes: #260
Approved by: cgwalters
2016-05-11 15:03:38 +00:00
Colin Walters
b718e28d79 postprocess: Add --add ostree to dracut invocation
Right now the `ostree.rpm` package always configures dracut to inject
the ostree setup via a conf file.  But it's actually simpler and
cleaner to just have callers specify it explicitly.

https://bugzilla.redhat.com/show_bug.cgi?id=1331369

Closes: #276
Approved by: jlebon
2016-05-06 14:50:42 +00:00
Colin Walters
4fc25d74a3 compose: Introduce variable substitution for ${basearch}
This comes from the tradition of yum repo files.  It's significantly
easier for rpm-ostree users building multiple architectures if some
core templating for the treefiles is built in.

Otherwise, everyone needs to learn about a new wrapper tool for
rpm-ostree, and said tool would need to re-do the same "basearch"
evaluation that is already occuring inside libhif.

This commit also paves the way for introducing `${releasever}`
substitution.

NOTE: This depends on pending changes to libhif git.

Closes: #274
Approved by: jlebon
2016-04-28 15:38:53 +00:00
Colin Walters
e2e754e94c compose: Reuse previous commit lookup in passwd checking
A future commit is going to change our parsing of the "ref" member in
treefiles, so ensure we only load it once early on in compose-tree.
We already looked up the previous commit there, so just pass it down
rather than reloading the ref.

Closes: #274
Approved by: jlebon
2016-04-28 15:38:53 +00:00
Giuseppe Scrivano
91ba02924f compose: add cache for added files
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #253
Approved by: cgwalters
2016-04-27 20:21:12 +00:00
Giuseppe Scrivano
94a2804b0a compose: support adding external files
This will allow to copy arbitrary files into the rootfs, specifying something like:

"add-files": [["service.template", "/exports/service.template"],
              ["config.json.template", "/exports/config.json.template"]]

It is quite useful when building a container image.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #253
Approved by: cgwalters
2016-04-27 20:21:12 +00:00
Colin Walters
d935767c0e Error for unknown subcommands overrides unknown option
If one does `rpm-ostree foo --bar`, one would expect to see
`Unknown subcommand foo`, not `Unknown option --bar`.

Closes: #267

Closes: #270
Approved by: jlebon
2016-04-27 13:50:36 +00:00
Colin Walters
24c923444c main: Consistently set exit code as failure in option processing
Otherwise we `exit(0)`, but trip an internal warning.

We have so much copy/paste going on here, but let's fix the
bug first.

Closes: #261

Closes: #262
Approved by: giuseppe
2016-04-12 08:05:36 +00:00
Colin Walters
63761e5127 core: Skip over local packages for downloads
Because `hif_source_get_location()` is actually a reference to the
upstream repo, we shouldn't create a cache directory there.

This is just a two line fix, but I changed some things so that we keep
track of the number of local packages, in order to make the "Need to
download" print accurate.

We still need to add them (confusingly) to the `packages_to_download`
because that's also used for the container path which imports them.

Closes: #255

Closes: #256
Approved by: jlebon
2016-03-31 17:56:19 +00:00
Colin Walters
4342c92082 main: Hide the container builtin for now
It's not really baked, totally undocumented etc.  Let's leave it in as
a tech demonstration for people who saw my Devconf.cz talk, but that's
it for now.

Pull request: #248
Approved by: jlebon
2016-03-24 19:34:35 +00:00
Colin Walters
3350c0e062 postprocess: Fix "compose tree" regression with /etc
The fact that we didn't notice this is a testament to the state of
testing =(

I think I want to change the container build path to also only
grab /usr and /etc rather than having the paths be different,
but for now - the quick fix.

Pull request: #243
Approved by: jlebon
2016-03-22 18:35:33 +00:00
Colin Walters
ed7fc02b04 postprocess: Ensure we error out if selinux is enabled, but no policy found
I was tracking another regression where we seem to have lost
`/usr/etc` contents which manifested as `Labeling with... (null)`
which was clearly wrong.

Now this change actually impacts the test suite - we now (again IMO
correctly) error out if `selinux: true`.  The `no-selinux-tag` test
no longer makes sense, so delete it.

We do need more "real" tests that use selinux on and off.

Pull request: #243
Approved by: jlebon
2016-03-22 18:35:33 +00:00
Jonathan Lebon
f8b87efc1f RpmOstreeContext: add set_repo()
The new context methods recently added for unprivileged infrastructure
would set the ostreerepo member when calling new_unprivileged(). Since
here we will be using the sysroot repo, we need the ability to set the
repo. Just add a new set function for now, maybe move it into
new_system() later.

Also, make sure we dereference the repo on finalize.

Pull request: #240
Approved by: cgwalters
2016-03-21 19:57:06 +00:00
Jonathan Lebon
224e4b31d8 RpmOstreeTreespec: allow missing ref element
There will be cases where we don't actually want to tag a ref on the
final assembled commit. This will be true for package layering.

Pull request: #240
Approved by: cgwalters
2016-03-21 19:57:06 +00:00
Jonathan Lebon
bf44928f40 RpmOstreeContext: remove unused params
Pull request: #240
Approved by: cgwalters
2016-03-21 19:57:06 +00:00
Jonathan Lebon
8594931c67 RpmOstreeTreespec: allow missing repos element
We allow the "repos" key to be missing, which just means that we let
libhif do its job, i.e. automatically use the repos in repodir that are
enabled.

We still do a check in rpmostree_context_setup() to make sure that at
least one repo is functional.

Pull request: #240
Approved by: cgwalters
2016-03-21 19:57:06 +00:00
Colin Walters
ad92d7e0ec daemon: Ignore unconfigured-state for rebase
It's expected to be able to switch to something different when
rebasing, even if the current origin has unconfigured-state.

Closes #232

Pull request: #238
Approved by: jlebon
2016-03-21 18:17:38 +00:00
Jonathan Lebon
ca61d0dcad rpm_ostree_db_diff: fix bad pointer
This was causing `rollback` to SEGV.

Pull request: #239
Approved by: cgwalters
2016-03-21 14:40:53 +00:00
Colin Walters
3947538932 app: Use libglnx console API
libgsystem has long been deprecated, so this is a small step for man,
and not really a gigantic leap at all for anyone but hey, at least I
changed something in git today.
2016-03-10 19:18:24 -05:00
Colin Walters
d5efcc5a26 daemon: Honor RPMOSTREE_USE_SESSION_BUS for startup too
While I was debugging the tests, I wanted to run the daemon
interactively under gdb but still on the session.  In our previous
logic this was only possible if we were exec'd by dbus-daemon which
made attaching gdb annoying.

Let's honor the environment variable consistently on client and
server.
2016-03-08 14:54:22 -05:00
Colin Walters
c3f1e7c85a upgrade: Only exit 77 with explicit option
This was a semantic change could potentially impact a lot of users who
weren't aware of the new '77 == unchanged' status and would treat it
as an error.

We retain the 77 for `--check` as I feel it's likely fewer people were
scripting that, and the ones that were would more quickly adapt to the
change.

As part of this, change the logic for detecting a change to be more
explicit by comparing the defaults.  I think this will fix a potential
bug where we could get a property change notification even if nothing
changed.
2016-03-08 14:54:22 -05:00
Colin Walters
3e289ffab0 daemon: Drop internal mutexes for sysroot
Now that the internal reading methods operate on the mainloop, and we
know there can only be one write transaction at a time, it should be
safe to drop the internal mutexes (and multithreading).

Updates to the `OstreeSysroot` instance and DBus API all happen off
the mainloop now.  The write transactions now use a separate
`OstreeSysroot` instance, and do not perform any changes to process
state on their own.  We always reload state from disk.

I think this is a lot simpler to reason about from a correctness point
of view, at a likely negligble loss in performance for read
transactions.
2016-03-08 14:54:22 -05:00
Colin Walters
467ecf268d daemon: Delete some now-dead code
This was only used by the threading API calls.
2016-03-08 14:54:22 -05:00
Colin Walters
769841fc9c daemon: De-thread os_handle_get_deployments_rpm_diff()
See the previous commits; this is a read-only task that doesn't
download any data, so we can run it from the main loop easily enough.
2016-03-08 14:54:22 -05:00
Colin Walters
3f60c317d3 daemon: De-thread os_handle_get_cached_deploy_rpm_diff()
See the previous commits; this is a read-only task that doesn't
download any data, so we can run it from the main loop easily enough.
2016-03-08 14:54:22 -05:00
Colin Walters
94600b7b83 daemon: De-thread os_handle_get_cached_update_rpm_diff()
See the previous commit; this is a read-only task that doesn't
download any data, so we can run it from the main loop easily enough.
2016-03-08 14:54:22 -05:00
Colin Walters
67142078c4 daemon: De-thread get_rebase_diff_variant()
I'd like to move towards a model where internal worker threads don't
touch the "main context data", i.e. we only use message passing (via
main contexts).  This means we wouldn't use a mutex.

I find this model to be significantly simpler to reason about.
2016-03-08 14:54:22 -05:00
Colin Walters
6f13c39aba transaction: Hoist main context wrapper creation up
Every transaction runs in a thread now, and there's no real drawback
to consistently creating a main context to go with it always.  Most
of the transaction types now do a pull, which needs it.
2016-03-08 14:54:22 -05:00
Colin Walters
7c970e3860 daemon: Maintain sysroot/repo persistently, close race in change updates
Now that we have `ostree_sysroot_load_if_changed()`, we know more
precisely (and cheaply) when things change.  Use inotify to detect
changes as before, but we don't need a timeout because all we do is
call `fstatat()` which is basically free; the inode is going to be in
memory.

This will hopefully help with
https://github.com/projectatomic/rpm-ostree/issues/220
but more investigation is needed.
2016-03-08 14:54:22 -05:00
Colin Walters
4619ee04cf sysroot: Use new ostree_sysroot_init_osname() API
Dumps a lot of duplicate code.
2016-03-08 14:54:22 -05:00
Colin Walters
1785cf825e sysroot: Inline basename check
Avoids a `malloc()` and I think is cleaner.
2016-03-08 14:54:22 -05:00
Colin Walters
3eb085c8f8 daemon: Clean up sysroot loading
We were loading the list of osnames by walking the FS, but it's a lot
simpler to just extract the set of known osnames from the deployment
array.

This is part of an effort to unify the "sync cached state with disk"
code in order to address race conditions.
2016-03-03 10:49:12 -05:00
Colin Walters
6b4becaef3 daemon: Generate more predictable "id" variables for deployments
We can't rely on the the GLib hash functions not changing (or being
stable across host systems).  Basically here we have a "stringified"
deployment...it might be simpler to just declare this stable.
2016-03-03 10:49:12 -05:00
Colin Walters
18b9da97ab compose: Add a --dry-run option
This way it's easier for people to inspect the next system state.
2016-03-02 18:39:13 -05: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
Colin Walters
f46302c2ab unpacker: Fix a 32 bit format string error 2016-02-23 13:44:14 -05:00
Colin Walters
a2c052bee5 Merge pull request #214 from jlebon/pr/no-daemon-dump
daemon: don't dump core on error
2016-02-22 18:06:28 -05:00
Jonathan Lebon
6a4df91cc4 daemon: don't dump core on error
There are many reasons why the daemon may not be able to start up. An
initialization error doesn't/shouldn't reflect a programming mistake,
but instead a runtime issue in the environment.

Thus, if we fail to start the daemon, we shouldn't use g_error(), which
dumps core. We should instead print the GError and clean up as nicely as
we can.

Resolves https://github.com/projectatomic/rpm-ostree/issues/194.
2016-02-22 17:00:24 -05:00
Colin Walters
397fdd8d33 Use a dummy install root for unprivileged composes
Sadly, libhif keeps trying to auto-create it.  It'll need patching
there, and possibly in librpm.
2016-02-22 14:27:46 -05:00
Colin Walters
f577279fac libpriv: Unify /usr/local, /etc -> /usr/etc, rpmdb handling
Right now we're doing the /etc -> /usr/etc inside the RPM import, but
we might as well do the /usr/local bits in both.  Also, use
/usr/share/rpm by default for treecompose too so that is unified.

Other things like systemd unit files and kernel handling are only
going to be used for host side composes.
2016-02-22 14:27:46 -05:00
Colin Walters
592f889a10 treecompose: Make use of cachedir again (just for metadata)
We need to do selinux first.
2016-02-22 14:27:46 -05:00
Colin Walters
58cf2c9403 tests: Add test coverage for rpm-ostree container 2016-02-22 14:27:46 -05:00
Colin Walters
961a036c5b Introduce "treespec" concept as GKeyFile
I debated config file formats a lot.  JSON is fairly awkward for
humans to write, and really painful to parse from C.  YAML is nice,
but also painful from C.

Both are fairly overpowered for what we really need.  Keyfiles
(desktop spec, `GKeyFile`) have a lot of limitations, but at least
it's used by systemd and `.desktop` files, and we already have a
parser.

We still parse the JSON treefiles, but internally convert them to
`GKeyFile` (which is in turn converted to `GVariant` for a canonical
form).
2016-02-22 14:27:46 -05:00
Colin Walters
20170cba4f libpriv: Make the OSTree repo implicit
It's the default for unprivileged composes if it exists.  This is an
incremental step towards always using the ostree repo.
2016-02-22 14:27:46 -05:00
Colin Walters
1eda3a022c Introduce RpmOstreeContext as an object
This helps unify some code more initially between the treecompose and
container bits.
2016-02-22 14:27:46 -05:00
Colin Walters
b3a7b4e218 Rename rpmostree-hif.[ch] -> core
This is really going to be the heart of rpm-ostree, so let's give it a
better name.
2016-02-22 14:27:46 -05:00
Colin Walters
f14d1a3536 build: Port to master libhif
This is a work-in-progress port against the libhif master + some
outstanding PRs.
2016-02-22 14:27:46 -05:00
Colin Walters
8de4f9be27 Add a container builtin
This is just a tech demo.  Example usage:

```
mkdir -p ~/.cache/rpmostree-containers
cd ~/.cache/rpmostree-containers
rpm-ostree container init
cp /etc/yum.repos.d/CentOS-Core.repo rpmmd.repos.d
rpm-ostree container assemble bash
rpm-ostree container assemble httpd
```
2016-02-22 14:27:45 -05:00
Colin Walters
b716959252 Major revamp/extension of libhif/unpacker code
This is in preparation for `rpm-ostree container`, which handles
unpacking RPMs as non-root.

At the moment, I'm copying code in from both ostree's libarchive bits
(fixable...may need to export some utility functions) and some
functions from libhif (harder, see:
http://lists.rpm.org/pipermail/rpm-ecosystem/2016-January/000297.html )

There's lots more cleanup to do here, but I don't want to block on the
resolution of the libhif changes.
2016-02-22 14:27:45 -05:00
Colin Walters
3ca0f1bcd8 Merge pull request #206 from mbarnes/dbus-policy
Update D-Bus security policy for rpm-ostreed
2016-01-12 21:24:12 -05:00
Matthew Barnes
134dd2bf44 daemon: Update D-Bus security policy
Poke some holes in the policy so normal users can introspect paths,
peek at properties, and run "rpm-ostree status".
2016-01-12 16:03:33 -05:00
Colin Walters
ec4387afba internals: New unpack verb
This is part of taking over from librpm.  The most important high
level goal is fully unprivilged operation.

Right now we're basically starting to do what
http://libguestfs.org/supermin.1.html does, except in C, and
faster.

There's no reason that `compose tree` should require privileges.
However right now, things like `%post` scripts will want to run in the
target root - so we'd have to require `linux-user-chroot`.

Regardless of unprivileged operation though, another major thing we
can do is use our control over the unpacking process to do a lot more
sophisticated caching.  We can build up a precise mapping of (rpm
ENVR, file path, selinux label) -> object and avoid rechecksumming
each time.

And even for files that aren't known, we can parallelize commit with
unpacking, etc.  (Ok assuming treecompose-post won't mutate anything).
2016-01-12 10:22:43 -05:00
Colin Walters
b456badba3 Add testing-only internals subcommand
I'd like to experiment with different things that end up
reusing chunks of the rpm-ostree internals, such as libhif, the
helpers we already have around RPM, etc.

In this particular case I'm experimenting with unpacking/committing
RPM packages as non-root.  Eventually most of this should end up as
internal private shared library, but it's convenient to have an
ABI-unstable and hidden "internals" command to run things directly.

This commit though just adds the scaffolding for "internals".
2016-01-11 23:06:27 -05:00
Colin Walters
5a530b9c85 Honor --proxy again, tweak internal libhif API
Two nits noticed in review that I accidentally ignored before pushing.

https://github.com/projectatomic/rpm-ostree/pull/202
2016-01-10 09:11:04 -05:00
Colin Walters
236a3c46cd Extract a shared internal rpmostree-hif.[ch]
As we start to do more package things, extract common helper functions
around HifContext * that by default operates on the system root.

Some of these bits should go in libhif, but the immediate plan is to
iterate here, then push downwards later.
2016-01-09 11:07:12 -05:00
Colin Walters
163f50214b postprocess: Delete dead code relating to yumdb
This has been long useless because we now disable history writing in
libhif.
2016-01-04 16:23:54 -05:00
Colin Walters
5cd40e6d86 postprocess: Cleanup more /var -> tmpfiles code to fd relative
Besides porting GFile -> fd, I specifically want it to operate in an
append mode for package layering.  Then given an existing tree, we
ensure we're not deleting the underlying tree's autovar files.
2016-01-04 12:47:31 -05:00
Colin Walters
cca057d24b postprocess: Convert some of the /var -> tmpfiles to fd relative
Part of an ongoing effort to port away from `GFile`.

Conflicts:
	src/libpriv/rpmostree-postprocess.c
2016-01-04 12:47:14 -05:00
Colin Walters
8de94004df libpriv: Change internal API to prepare SELinux
This function will be made public for use in package layering.
2016-01-03 09:45:14 -05:00
Colin Walters
e2fa1675f8 libpriv: Convert some SELinux labeling code to dirfd-relative
This is preparatory work for the package layering branch, which
will also reuse this code.
2016-01-03 08:00:10 -05:00
Colin Walters
2adf0fce47 daemon: Treat local deployments as gpg-verify=false
Otherwise we trip an assertion.  In the future I think we should
likely encourage `file:///ostree/repo` or so, and thus support
`gpg-verify`.
2015-12-29 08:20:05 -05:00
Jonathan Lebon
033830e0c0 postprocess.c: be more verbose when running script
We should tell the user that we will run the postprocess script *before*
we run it to help them diagnose issues if things go wrong.

Resolves: #188
2015-12-10 14:49:57 -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
Colin Walters
5d4c173a9e app: Handle progress when not being connected to a tty
`rpm-ostree deploy X.Y.Z | cat` was aborting on the client side.  I
noticed this when using it via Ansible.
2015-11-23 16:53:24 -05:00
Colin Walters
b82f7338ea src: Quiet a few gcc -Wmaybe-uninitialized warnings
GCC (at least 5.2.1) isn't smart enough to figure out these are always
initialized.
2015-11-23 12:08:37 -05:00
Micah Abbott
25ae79bc98 Use PACKAGE_STRING for version output
We are currently using PACKAGE_NAME for version output, which returns
exactly what it says it does: the package name.  Not very useful when
looking for version information.

PACKAGE_STRING, on the the other hand, returns the package name and the
version.  Much better!

This is nicely documented in the autoconf manual [1].

[1] http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Initializing-configure.html#Initializing-configure

Signed-off-by: Micah Abbott <miabbott@redhat.com>
2015-11-19 14:22:48 -05:00
Matthew Barnes
6c197455e1 daemon: Don't fail during rebase cleanup
Ignore errors during cleanup after a successful rebase.  The source
origin ref may not actually exist.  The issue linked below describes
one such case.

Fixes https://github.com/projectatomic/rpm-ostree/issues/179
2015-11-16 15:35:39 -05:00
Matthew Barnes
63d7ff8d5f daemon: Add rpmostreed_parse_revision()
Determines a revision argument to either be a SHA256 checksum or a version
metadata value.

The revision string may have a "revision=" prefix to denote a SHA256
checksum, or a "version=" prefix to denote a version metadata value.  If
the revision string lacks either prefix, the function attempts to infer
the type of revision.  The prefixes are case-insensitive.
2015-11-06 09:10:48 -05:00
Matthew Barnes
6114255b8e app: Split upgrade --check-diff into separate options
rpm-ostree upgrade --preview   - Just preview package differences,
                                 like deploy --preview
rpm-ostree upgrade --check     - Just check if an upgrade is available

In both cases, the exit codes are 0 (upgrade available), 77 (no upgrade
available) and 1 (error).

The --check-diff option still works but is deprecated and not shown in
the --help option listing.
2015-11-06 09:10:48 -05:00
Matthew Barnes
1c01141e0c app: Define a special exit code for no changes (77)
Used by upgrade and deploy to allow scripts to test for changes.
2015-11-06 09:10:48 -05:00
Matthew Barnes
a555af0050 app: Redo "update --check-diff" implementation
Don't remember why we're not using the daemon for this, but I already
went to the trouble of writing rpmostree_print_package_diffs() for the
"deploy" command.  Use it here as well.
2015-11-06 09:10:48 -05:00
Matthew Barnes
6f184d6072 daemon: Remove equivalence check for details variant
rpmostreed_commit_generate_cached_details_variant() returns NULL if the
origin checksum of an OstreeDeployment matches the checksum of a refspec,
which may also be the OstreeDeployment's origin.

I don't understand the reasoning for that, especially since none of the
callers are prepared to deal with a NULL return.  Nor is there a comment,
so remove the check.

This was making the daemon crash on

  rpm-ostree deploy --preview <current-deployment-checksum>

which should just indicate no package differences.
2015-11-06 09:10:48 -05:00
Matthew Barnes
56d28a76f3 app: Add "deploy" command
Command-line interface for new D-Bus "Deploy" methods.
2015-11-06 09:10:48 -05:00
Matthew Barnes
de7b750728 app: Add rpmostree_print_package_diffs()
Takes a GVariant returned by the daemon's various "PkgDiff" methods.
2015-11-06 09:10:48 -05:00
Matthew Barnes
0a7706c241 daemon: Strip override-commit when upgrading
Deploy method locks the deployment at a particular commit by adding an
"override-commit" line to the origin file.

Upgrade method must undo the override so we always upgrade to the latest
available commit.
2015-11-06 09:10:48 -05:00
Matthew Barnes
9eabc1ba3c daemon: Add "RpmDiff" methods to supplement Deploy
DownloadDeployRpmDiff and GetCachedDeployRpmDiff, which take the same
revision argument as Deploy.
2015-11-06 09:10:48 -05:00
Matthew Barnes
9a13d39a25 daemon: Add Deploy() method
Deploy(revision) pulls and deploys a particular revision on the
branch of the currently booted deployment.  The revision can be
expressed as a SHA256 checksum or as a version metadata value.
2015-11-06 09:10:48 -05:00
Matthew Barnes
316f927aef daemon: Add rpmostreed_repo_lookup_cached_version()
Similar to rpmostreed_repo_lookup_version(), except without pulling from
a remote repository.  It traverses whatever commits are available in the
local repository.
2015-11-06 09:10:48 -05:00
Matthew Barnes
b3ecdd10b6 daemon: Add primitives for version lookup
rpmostreed_repo_pull_ancestry() downloads an ancestry of commit objects
starting from a given refspec.  An optional visitor function is called
for each commit object.  The visitor function can stop the recursion,
such as when looking for a particular commit.

rpmostreed_repo_lookup_version() builds on this by supplying a visitor
function that examines commit metadata for a particular version value.
When the version value is found, the commit's checksum is returned to
the caller.
2015-11-06 09:10:48 -05:00
Matthew Barnes
a5dd7d1a1a daemon: Miscellaneous diff operation cleanups 2015-11-06 09:10:48 -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
554a631ca7 app: Add rpmostree_usage_error()
Convenience function for missing or invalid command-line arguments.
2015-11-06 09:10:48 -05:00
Matthew Barnes
9b5cc4af9a app: Frivolous GError cleanup 2015-11-06 09:10:48 -05:00
Colin Walters
f84ad5d954 Merge pull request #181 from giuseppe/giuseppe/dracut-reproducible
postprocess: provide --gzip and --reproducible to dracut if supported
2015-11-05 21:32:35 -05:00
Giuseppe Scrivano
bb2f32502b postprocess: provide --gzip and --reproducible to dracut if supported
This should help to generate the same initrd when the files didn't
change.

Newer versions of gzip (or pigz when available) can generate rsync
friendly files and if present, Dracut already takes advantage of it.

Also use --reproducible, to instruct Dracut to generate CPIO
reproducible files.  It is required a version of GNU CPIO that
has support for it.

Check that Dracut has --reproducible in its --help output before
setting it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-11-04 12:33:55 +01:00
Colin Walters
b7e8c7bdc5 compose: Ensure we've cleaned up references to tmpfs workdir before umount
Otherwise the `umount()` will always fail.  This hasn't been a problem
so far while running in a external container (docker/systemd-nspawn),
but is when running in `mock` because it doesn't set its namespace to
be private.

This should help Fedora's Bodhi, which uses rpm-ostree inside mock.
2015-10-30 21:40:14 -04:00
Colin Walters
054ceebb76 Merge pull request #175 from giuseppe/giuseppe/reboot-after-upgrade
giuseppe/reboot-after-upgrade
2015-10-08 13:37:57 -04:00
Giuseppe Scrivano
4b0b2b94f1 rebase,rollback,upgrade: use rpm-ostreed to reboot
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-10-07 08:46:30 +02:00
Giuseppe Scrivano
aa6415bb9c upgrade: reject --reboot and --check-diff used together
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-10-07 08:42:11 +02:00
Giuseppe Scrivano
f140f33d4d rpm-ostree: support 'reboot' immediately after a rebase
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-10-07 08:33:06 +02:00
Giuseppe Scrivano
b5cd3f2d1e rpmostreed: refactor common code in the new function rpmostreed_reboot
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-10-07 08:22:36 +02: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
Giuseppe Scrivano
f8cc2e05a8 fixup! rpm-ostree: support 'reboot' immediately after a rollback 2015-10-06 08:35:10 +02:00
Giuseppe Scrivano
fad97b901c fixup! rpm-ostree: support 'reboot' immediately after an upgrade 2015-10-06 08:32:15 +02:00
Giuseppe Scrivano
1bc2029173 rpm-ostree: support 'reboot' immediately after a rollback
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-10-05 09:18:50 +02:00
Giuseppe Scrivano
391522ecdb rpm-ostree: support 'reboot' immediately after an upgrade
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-10-05 09:14:51 +02:00
petervo
85c82816b6 daemon: Add detail variant to rpm diff methods
Allows clients to see version, timestamp
and other detailed information along with
the rpm diffs for cached updates and rebases.

This will be used by the Cockpit interface.
2015-09-29 17:39:15 -07:00
petervo
cb6ed53fec daemon: Expose details for cached updates
Adds a CachedUpdate property that allows clients
to see version, timestamp and other detailed
information for pending updates. Additionally
changes to this property signal clients that a
new rpm-diff can be fetched with GetCachedUpdateRpmDiff.

This will be used by the Cockpit interface.
2015-09-29 17:38:51 -07:00
petervo
8ed604ef2d daemon: Expose the path that started a transaction 2015-09-28 17:25:25 -07:00
Matthew Barnes
73f2a7f058 daemon: Make "diff" methods safer
Various OS "diff" methods can run concurrently with whatever else is
going on since they don't have to obtain the system root lock.

Just to make sure there's no conflicts when writing deployments or
downloading RPM package details, use an internal reader/writer lock
to protect the critical sections of upgrade, rebase, rollback, etc.
2015-09-09 22:00:06 -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
7b7f13697f daemon: Remove fallback PATH setting
To the best of my knowledge, the daemon does not rely on PATH anywhere.
This chunk of code is uncommented and seems unnecessary so remove it.
2015-09-09 22:00:05 -04:00
Matthew Barnes
d32a4b9f6a daemon: Update deployments on "updated" signal
Also, renamed the signal from "sysroot-updated" since it originates
from RpmostreedSysroot.
2015-09-09 22:00:05 -04:00
Matthew Barnes
a388f986bb daemon: Don't keep persistent OstreeSysroot instance
Create and load a new OstreeSysroot and OstreeRepo instance as needed.
This ensures its internal state is up-to-date, since several ostree
commands can alter stored state without the daemon's knowledge.

I would prefer keeping persistent instances if these issues can be
addressed, as it would eliminate some inconvenient error handling.
But this way is safer for now.
2015-09-09 22:00:05 -04:00
Matthew Barnes
22c5d5a654 daemon: Add rpmostreed_sysroot_load_state()
Replaces rpmostreed_load_sysroot_and_repo() with a slightly more
convenient API.
2015-09-09 22:00:05 -04:00
Matthew Barnes
82702c295b daemon: Fix OS.Rebase() method
Having the OS.Upgrade() and OS.Rebase() logic flows conflated in the
daemon had me nervous.  A day's worth of debugging a failing test case
proved that nervousness well-founded.  Split them into distinct backend
operations.
2015-09-09 22:00:05 -04:00
Matthew Barnes
7aed790da5 app: Fix local operations with non-default sysroot paths
Some vestigial option parsing cruft revealed the need for the Sysroot
interface to grow a "Path" property.
2015-09-09 22:00:05 -04:00
Matthew Barnes
8d2713e0f2 daemon: Add a Sysroot.Path property
So the client side can read it back.

This replaces the GObject "sysroot-path" property in the wrapper class,
which created some additional daemon refactoring.
2015-09-09 22:00:05 -04:00
Matthew Barnes
0326568a4a tests: Adapt to rpm-ostree daemon
No doubt better ways are possible but this is the least messy thing
I could come up on a deadline.
2015-09-09 22:00:05 -04:00
Matthew Barnes
a1b7ed5f9c daemon: Remove "on-message-bus" property
Wasn't used for anything.
2015-09-09 22:00:05 -04:00
Colin Walters
41d74abaf8 daemon: Bind DBus service <-> systemd service configs
Using this flag tells DBus to activate using systemd, which gives
tighter integration.
2015-09-09 22:00:05 -04:00
Colin Walters
da81156d81 daemon: Export objects on bus (not name) acquision
This closes a race condition where the objects might not be exported
by the time clients call methods.

Also delete the code in the "on name lost" handler - it's not going to
happen in practice (we don't allow replacement), and causes issues as
it may be run first before we get the notification that the name is
owned.  github.com/cockpit-project/storaged has some better code here
which we could copy later.

This then in turn allows us to delete the "hold"/"release"
infrastructure.  Basically the daemon will live forever in the
process.
2015-09-09 22:00:05 -04:00
Matthew Barnes
9c0e87bc75 daemon: Share Transaction address for identical requests
If a client makes a request that is identical (that is, same method name
and same parameters) to an ongoing transaction, return the bus address of
that transaction.  The client can then "tune in" to the progress messages.
(Remember the Transaction.Start() method returns a boolean to distinguish
a newly-started transaction from an ongoing transaction.)

The driving use case for this is a dropped ssh connection during a long
running transaction -- like "upgrade" -- and being able to reattach to
the transaction's progress messages mid-stream.
2015-09-09 22:00:05 -04:00
Matthew Barnes
b3189b6ae4 daemon: Support multiple Transaction connections
Few things to note:

 - Cancelling a transaction no longer immediately destroys it.

 - Transaction is destroyed when finished (or cancelled) and has
   no client connections.

 - If a client attaches to a finished transaction and calls Start(),
   the transaction will re-emit the Finished signal to that client.

 - The transaction bus address is not yet shared across multiple
   clients, so multiple connections doesn't actually work from the
   outside yet.  It's just supported internally.
2015-09-09 22:00:05 -04:00
Matthew Barnes
24f01556a0 daemon: Make the Transaction.Start() method idempotent
Add a boolean return so callers can distinguish between actually starting
the transaction or reattaching to an in-progress transaction.
2015-09-09 22:00:05 -04:00
Matthew Barnes
6e28454e6d daemon: Change bus name watching semantics
Only watch the caller's bus name until the transaction is started.
Thereafter the transaction proceeds independently of the calling
process.
2015-09-09 22:00:05 -04:00
Matthew Barnes
aaadcba77b daemon: Rename all the things!
Use 'rpmostreed' as the symbol prefix.
2015-09-09 22:00:05 -04:00
Matthew Barnes
188be0cd58 daemon: Change ActiveTransaction value
Change the ActiveTransaction property from the bus address of the active
transaction to a string tuple: (method name, sender name)

The bus address was only a placeholder, and not very useful since each
transaction only accepts one connection (presumably the method caller).
2015-09-09 22:00:05 -04:00
Matthew Barnes
495bf4c3f3 daemon: Simplify authorization policy
The current policy is to only allow the root user access to the Sysroot
and OS interfaces, but this can be expressed in the static bus config.

The long-term intention is to integrate with PolicyKit.  Leave comments
in the code stating so but remove the unnecessary authorization handler
for the time being, just so there's less code to review.
2015-09-09 22:00:05 -04:00
Matthew Barnes
d051794a88 daemon: Add debug messages for transactions 2015-09-09 22:00:05 -04:00
Matthew Barnes
7917c89890 daemon: More transaction API churn
Since the daemon can detect when the client closes its peer-to-peer
connection, simplify the API by converting the Finish() method to a
Finished signal that is only emitted once.

Internally, add a "closed" signal to transactions (triggered by a
closed GDBusConnection), and have the transaction monitor use that
instead of "finished" to know when to dispose of the transaction.
2015-09-09 22:00:05 -04:00
Matthew Barnes
ebc48d0158 daemon: Remove owner checks on Transaction methods
Because peer-to-peer endpoints don't get assigned unique names, the
sender == owner check is rendered useless.  But I'm not sure we even
need a check since the transaction *is* peer-to-peer now.

One way to secure the returned bus address from prying eyes would be
to employ GcrSecretExchange, but this would only complicate the hand-
shake further and (imo) necessitate a public client-side function to
implement the handshake correctly.
2015-09-09 22:00:05 -04:00
Matthew Barnes
19e626c087 daemon: Use a peer-to-peer connection for transactions
Transaction progress and message signals are really only intended for
one recipient: the client that invoked the method.  Use a peer-to-peer
connection for transactions so we're not spamming the system bus.

This entails returning a bus address rather than an object path in
methods that use transactions.  The client opens a connection to the
bus address, connects handlers to the Transaction interface (on path
"/"), and then invokes the Start() method.

To finish a transaction, the client need only close the connection,
either explicitly or by terminating.  The server will detect this
and clean up resources for that transaction.
2015-09-09 22:00:05 -04:00
Matthew Barnes
d69cb7d7c1 daemon: Convert transactions to subclasses
Implementing a template pattern for transactions.

The TransactionClass is now abstract, and transaction_new() is replaced
with various method-specific functions like transaction_new_upgrade().
These custom subclasses live in a new file transaction-types.[ch].

Further, transaction_monitor_new_transaction() is replaced with
transaction_monitor_add().  So the handlers for "OS" interface methods
need only create an appropriate transaction instance and hand it off to
the transaction monitor.
2015-09-09 22:00:05 -04:00
Matthew Barnes
434a967ab1 daemon: Add "invocation" property to TransactionClass
Move as much as possible out of transaction_new() for the benefit of
subclasses.  The GDBusMethodInvocation property for setting up D-Bus
properties and name watching in the constructed() method.
2015-09-09 22:00:05 -04:00
Matthew Barnes
36c87fb483 daemon: Add a Start() method to transactions
Turns out we do still need a Start() method after all.  Not for lack
of trying, but I can't get away from the client and server doing some
sort of handshake at the beginning to avoid either raciness on the
client side or artificial delays on the server side.

I don't particularly like the "start" signal I've added -- I'd much
prefer subclassing -- but I'm trying to keep the changes incremental.
2015-09-09 22:00:05 -04:00
Matthew Barnes
029a3e5924 daemon: Prepare TransactionClass for subclassing
Expose the instance and class structures, move instance members to a
private structure.  This is also towards having the TransactionClass
follow a template pattern.
2015-09-09 22:00:05 -04:00
Matthew Barnes
a0db1c705f daemon: Have Transaction objects handle sysroot locking
Also, the Transaction holds an OstreeSysroot reference for its duration,
which is convenient for callbacks.
2015-09-09 22:00:05 -04:00
Matthew Barnes
1934d631c0 daemon: Implement GInitableIface in transactions
Towards having the Transaction wrapper class follow a template pattern.
2015-09-09 22:00:05 -04:00
Matthew Barnes
cfc52adfea daemon: Catch systemd journal messages by redirecting stdout
libostree logs messages to systemd's journal and also to stdout.
Redirect our own stdout back to ourselves so we can capture those
messages and pass them on to clients.  Admittedly hokey but avoids
hacking libostree directly (for now).
2015-09-09 22:00:05 -04:00
Matthew Barnes
f1973d7557 daemon: Add ProgressEnd signal to Transaction interface
The ProgressEnd signal indicates to clients there will be no more
DownloadProgress or SignatureProgress signals in the transaction,
and any further Message signals should be output as separate lines
instead of replacing the previous progress message.

In other words, it's just a way of driving GSConsole remotely.
2015-09-09 22:00:05 -04:00
Matthew Barnes
7b8c67fc6a app: Tweak transaction DBus helper function
Take an RPMOSTreeSysroot object instead of a GDBusConnection in
rpmostree_transaction_get_response_sync().  Makes the API slightly
more convenient.
2015-09-09 22:00:05 -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
b6691cbdca daemon: Rework transactions
A few changes:

- Modify the D-Bus API to include a Finish() method instead of a Start()
  method, the idea being the client calls Finish() to obtain the final
  status and optional message once the transaction indicates it's done.
  Calling Finish() also removes the transaction object from the bus.

- Introduce Transaction class as a thin wrapper for RPMOSTreeTransaction.
  Stores the status info for Finish(), detects when the caller's bus name
  vanishes, and emits various status signals to TransactionMonitor.

- Introduce TransactionMonitor as a factory class for Transactions that
  also handles book keeping chores like tracking the active Transaction.
  The Sysroot and OS interfaces share a TransactionMonitor instance.
2015-09-09 22:00:05 -04:00
Matthew Barnes
463d3676ea daemon: Miscellaneous cleanups 2015-09-09 22:00:05 -04:00
Matthew Barnes
915b78e2aa daemon: Startup modifications 2015-09-09 22:00:04 -04:00
petervo
23cfdf29b6 daemon: Track active transaction 2015-09-09 22:00:04 -04:00
petervo
f525730187 daemon: Make parts of cli use the daemon 2015-09-09 22:00:04 -04:00
petervo
0114507865 daemon: Start implementing transaction methods 2015-09-09 22:00:04 -04:00
petervo
075d6bdad0 daemon: Implement package diff methods 2015-09-09 22:00:04 -04:00
petervo
a140c26200 daemon: OS properties and property updates 2015-09-09 22:00:04 -04:00
Matthew Barnes
c6548ace61 daemon: Half-implement the Upgrade() command
This isn't finished yet but it shows the direction I'm going and some
issues I'm encountering.

The CLI layer has 3 different versions of upgrade now:

  1) If --check-diff is given, execute it locally regardless of sysroot.
     I'm not convinced this variation needs to be executed in the daemon,
     but if it does we need a separate D-Bus method since it produces
     different results.

  2) Else if --sysroot is not "/", execute it locally.  I don't think
     the daemon currently indicates what sysroot it's operating on, and
     even if it did I'm not sure the CLI should be talking to anything
     but the "/" daemon.

  3) Else if --sysroot is "/", defer to the daemon.

Obviously there's a lot of unwanted code duplication going on here.
I'd like to factor out the common parts and put them in libpriv for
reuse, but I'm also trying to preserve the CLI behavior and all the
various g_print() calls are causing a problem.

I was toying with the idea of adding a "message" signal to
OstreeAsyncProgress for miscellanous status messages.  Those signals
could then be handled by either printing the message to stdout or
transmitting it over D-Bus via the Transaction object.

Some of those g_print() messages could then be moved directly into
the common libpriv functions and handed off to OstreeAsyncProgress.
2015-09-09 22:00:04 -04:00
Matthew Barnes
0b89d54bb0 daemon: Add GetOS() method to Sysroot interface
Returns the object path for the given OS name.

This can be done entirely client side, but it requires connecting to
the object manager interface, requesting all the objects and sifting
through them to find the one with a matching Name property.

For some use cases this method is just more convenient.
2015-09-09 22:00:04 -04:00
Matthew Barnes
b4db4a1621 daemon: Some D-Bus API tweaks
Trying to get the Update() method working end-to-end, and figuring out
all the status reporting around it.
2015-09-09 22:00:04 -04:00
Matthew Barnes
89e41eb8db daemon: Integrate download progress into new_transaction() 2015-09-09 22:00:04 -04:00
Matthew Barnes
84dbd934b5 daemon: Add callback stubs for OS methods 2015-09-09 22:00:04 -04:00
petervo
d332175bb3 daemon: Ensure os names are relative to deploy dir 2015-09-09 22:00:04 -04:00
petervo
19fde3a50a daemon: Start of sysroot interface implementation 2015-09-09 22:00:04 -04:00
petervo
8b283656b6 daemon: Dbus setup
Brings in auth, errors and path building functions
2015-09-09 22:00:04 -04:00
petervo
94efc7bb77 daemon: Publishing and unpublishing interfaces 2015-09-09 22:00:04 -04:00
petervo
950fcf7a99 daemon: deployment utils
Adds a gvariant representation of a deployment
2015-09-09 22:00:04 -04:00
Matthew Barnes
c2e19fb39e daemon: Add deployment_generate_id() to utils 2015-09-09 22:00:04 -04:00
Matthew Barnes
8f5993e220 daemon: Add factory function for Transaction objects
Creates, configures and exports an RPMOSTreeTransaction object from a
GDBusMethodInvocation.  The interface is exported relative to the object
path on which the D-Bus method was called.
2015-09-09 22:00:04 -04:00
Matthew Barnes
0774249b81 daemon: Add "Method" property to Transaction object 2015-09-09 22:00:04 -04:00
Matthew Barnes
d6a48feb7a daemon: Handle bus name acquisition in main.c 2015-09-09 22:00:04 -04:00
Matthew Barnes
2f5057a022 daemon: Make the Daemon instance global in main.c
Just easier than passing it around to callbacks.
2015-09-09 22:00:04 -04:00
Colin Walters
a435dea27a daemon: Flesh out new API
Peter, Matthew and I talked for a while and came up with this.
2015-09-09 22:00:04 -04:00
petervo
c0d15a66ad daemon: Start of work on daemon 2015-09-09 22:00:04 -04:00
Colin Walters
60ed86228f compose: Don't do container stuff if we're in a container already
This helps avoid some failures.  See:
fbdb15cd95
2015-08-24 16:16:52 -04:00
Colin Walters
07310f4f1d Merge pull request #164 from cgwalters/composetree-requires-root
compose: Require being run as root
2015-08-03 16:11:12 -04:00
Colin Walters
6daf713d8e compose: Fix "too old" error for "old" file:/// repos
Bodhi points rpm-ostree at the "gold" Fedora repo via `file:///`, and
libhif is brokenly checking the mtime on `file://` repos.

Work around that here by just ignoring cache ages, because at present
we don't actually cache really - we drop the RPMs in the tempdir.

(Long term having actual caching of the RPMs would be nice, but
 we can revisit this when we get there)

Closes #156
2015-07-24 16:28:52 -04:00
Colin Walters
5f8fdc7940 compose: Require being run as root
Someday we'll enhance RPM; see
https://github.com/rpm-software-management/rpm/issues/8

But anyways right now at least a few people have tried,
and we get all the way past downloading packages and then bomb
out when doing the actual transaction with a useless error
message.

So let's be up front about this.
2015-07-23 22:14:54 -04:00
Colin Walters
536cec3a53 compose: Error out if specified repositories aren't found
This is being friendly for configuration errors.  The failure mode
here of not finding repos and silently continuing was quite bad.
2015-07-22 16:46:09 -04:00
Micah Abbott
a5a2b90dad Sort subcommands alphabetically
This change causes the subcommands to be sorted alphabetically when
'rpm-ostree' is invoked without an argument or with '--help'.  This
matches the behavior of the 'ostree' command.
2015-07-15 14:57:39 -04:00
Colin Walters
84d2d51576 postprocess: Don't use absolute paths for helpers like dracut
It moved from `/usr/sbin` -> `/usr/bin`, which obviously broke
rpm-ostree.

No reason to hardcode absolute paths here.
2015-06-15 13:44:52 -04:00
Dusty Mabe
4d6985c92c Fix version number output on upgrade/rollback.
Resolves #153
2015-06-02 10:34:24 -04:00
Colin Walters
385303e3f8 compose: Disable yumdb by default
This API was added to libhif a while ago.  I'm adding this now because
libhif was changed recently to write the dnf copy of the yumdb, and we
didn't have code to remove it explicitly.

It's better not to write it in the first place.
2015-05-30 15:48:17 -04:00
Colin Walters
370c5e5b63 compose: Make use of hif_source_set_required()
We noticed that tree composes failed with a missing `atomic` package,
when really what happend is Fedora 22 was released and the repo
metadata moved from `development/` to `released/`.

See https://github.com/hughsie/libhif/pull/47
2015-05-26 10:43:33 -04:00
Colin Walters
b8ac0f7caf libpriv: Introduce an rpmostree_mkdtemp()
- Can also give you a file descriptor
 - Takes a constant string as input, returning a mutated string as a
   separate variable which means that one can check whether the variable
   is `NULL` to know whether or not one needs to `rm -rf` it on error
   paths.
2015-05-23 09:32:28 -04:00
Colin Walters
bfe801b77e libpriv: Fix memory leak 2015-05-23 09:32:23 -04:00
Colin Walters
1aa0e37cc9 libpriv: Teach RpmRevisionData to use new RefTs API
More code de-duplication.
2015-05-23 09:30:57 -04:00
Colin Walters
70f5b535e4 libpriv: Add RpmOstreeRefTs and API to create one from a commit
This API is intended for use by the caching framework to hold open an
rpmdb for the previous commit.
2015-05-23 09:30:57 -04:00
Colin Walters
b378386e98 Prefer rpmostree_ for internal API over _rpm_ostree
The refsack code was using the latter, and it stood out.  Now that
we're making use of explicit export markers, there's no need to uglify
internal APIs with a leading `_`.
2015-05-22 09:38:55 -04:00
Colin Walters
07871a08fd libpriv: Further centralize (commit | root) -> (sack | rpmdb) code
While `rpm-util.c` may not best describe this, it's where most
of this code is ending up.  Let's further centralize things.

We more consistently return an `RpmOstreeRefSack` instead of a
`HySack`, where the former supports refcounting and knows how to clean
up its temporary directory if it was allocated from a commit.
2015-05-22 09:32:03 -04:00
Colin Walters
3c3947564d db: Use internal rpmdb-in-tempdir API
And now, finally the actual goal is achieved.  \o/

Only one code path dealing with extracting the rpm database from an
OSTree commit.

An astute reader would notice that the `root` member of the struct was
actually only necessary as of a few commits ago.  But said astute
reader would also realize it's kind of late in the evening and not
worth rebasing it to where it would properly go.
2015-05-21 21:27:38 -04:00
Colin Walters
0756708f24 db: Create var/lib/rpm -> ../../usr/share/rpm in tempdir
hawkey and libsolv are both patched to look in `usr/share/rpm` if the
db can't be found in `/var/lib/rpm`.  However, librpm itself isn't.
One *can* override it with a macro...which is process global.  Yuck.
Needs fixing.

Anyways, we can just make a symlink.  That's a lot easier than writing
a patch for librpm and waiting a billion years to be able to use it
everywhere we care about.

This will help unify the librpm tempdir code with the hawkey tempdir
code.
2015-05-21 21:25:27 -04:00
Colin Walters
60d68f6e24 db: Make RpmRevisionData an opaque struct
This allows us to more cleanly encapsulate things.
2015-05-21 21:16:21 -04:00
Colin Walters
349dd45679 db: Remove --rpmdbdir option
As far as I can tell, this is basically a way to specify the temporary
directory.  That significantly complicates the code as it now
needs to keep track of whether or not it owns the temporary directory.

This hinders unifying this code with the hawkey query path.

Because of this, and since I'm not aware of a use case for specifying
this tempdir, let's remove it.
2015-05-21 21:16:21 -04:00
Colin Walters
bd9b9eac0a Drop root arguments from internal rpmdb API
It was only used to access the yumdb, which we don't use because:

 - It badly exacerbates the OSTree one-HTTP-request-per-object issue
 - We're assembling multiple repos on the server side, so things like
   who took the action aren't relevant.

But the reason I did this patch at the moment is because I want to
unify the code that's creating tempdirs from commits so we can feed
real files to librpm.
2015-05-21 20:34:01 -04:00
Colin Walters
5de58aae9c libpriv: Split out an internal API to get a tempdir with just the rpmdb
For a future patch, I want to add an API to get an rpmts for a commit,
instead of a hawkey Sack, because libsolv doesn't expose some
optimized queries that we can get by just going directly to librpm,
such as package file owners.
2015-05-21 20:15:08 -04:00
Alexander Larsson
79cdcd1817 Support container: true in treefile
If this is set we don't do anything special for kernel or /boot, as
such things are not needed when running in a container.
2015-05-21 12:00:20 +02:00
Colin Walters
cf89acb74c (cleanup): Move the refsack and root loading code into libpriv
We had `src/lib` having its own little private library; I wanted to
use some of it inside `src/libpriv`, so let's consistently have all
private utility code in `src/libpriv`.

Closes: https://github.com/projectatomic/rpm-ostree/pull/147
2015-05-20 20:51:42 -04:00
Matthew Barnes
03b886dae0 lib: Add rpm_ostree_package_cmp()
Equivalent to hy_package_cmp(), but works for comparing packages from
different memory pools.

This a stop gap measure in light of
https://github.com/rpm-software-management/hawkey/pull/90

If and when that pull request gets merged, then this function could at
some later point simply call hy_package_cmp().
2015-05-13 11:31:30 -04:00
Colin Walters
1c3a549ef9 postprocess: Handle Fedora rawhide kernel installation
The vmlinuz binary has moved to /usr/lib/modules, which is a change
mostly for the better, but we need to adapt.

Closes: https://github.com/projectatomic/rpm-ostree/pull/143
2015-05-12 13:51:12 -04:00
Colin Walters
f115d0276f db: Remove query parameter to diff
Matthew argues we can add this at a later time.
2015-04-23 16:30:18 -04:00
Colin Walters
8bf8d71f99 db: Remove query argument, rename to query_all()
Matthew argues that we can add this later.

https://github.com/projectatomic/rpm-ostree/pull/139#issuecomment-95327428
2015-04-23 16:30:18 -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
Colin Walters
e414be8ae2 Move diff printing code into client
This is a step forward to deduplicating; the client tooling now calls
into the public API for diffs, rather than using the older internal
function.

Note: this patch also links the client against the public library.
2015-04-23 16:30:18 -04:00
Colin Walters
3326e13481 lib: Add diff API
This is a *third* implementation of rpm database diffs in the code,
but it is now a public introspectable shared library API.

Further commits will change the command line tools to use this, and
then after that we'll further deduplicate the `db diff` from this
code.
2015-04-23 16:30:18 -04:00
Colin Walters
28ab27caf7 db: Refactor internal helpers in preparation for diff API
This will make it easier to query two commits at once.  Note that
`RpmOstreeRefSack` now can hold a reference to a temporary directory.
2015-04-23 16:30:18 -04:00
Colin Walters
7b45f13a62 Link lib/ against libpriv/, use it to share sack loading function
On the plus side, we share some code between the library and the
binary now.  On the downside, because `librpmostreepriv.la` is a
noinst library, its code text is duplicated between the shared library
and binary, at least until we either:

 - Have the binary solely use the public shared library (like ostree does)
 - Install `librpmostreepriv.so` to e.g. `/usr/lib64/rpm-ostree/librpmostreepriv.so`
   without the headers being public
2015-04-23 16:30:17 -04:00
Colin Walters
f3600e922e libpriv: Adjust internal package diff API to be fd-relative
We presently have 3 internal code paths that are doing rpmdb
inspection.  This conversion to fd-relative for one of them is a
generic cleanup preparatory to de-duplicating.

Note this bumps libglnx to include
381ca54ee3
2015-04-23 16:30:17 -04:00
Giuseppe Scrivano
3bf7926adc postprocess: do not hardcode /etc/machine-id
The file is automatically populated by systemd when it is empty.

Apparently it doesn't work when the file is missing (as of
systemd-219-9.fc22).

https://bugzilla.redhat.com/show_bug.cgi?id=1198700

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-04-23 11:37:50 +02: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
Matthew Barnes
750a8889f0 upgrade: Print any GPG signatures while upgrading 2015-04-17 12:30:04 -04:00
Colin Walters
3e6f877282 lib: Add RpmOstreePackage
The `QueryResult` class ended up being too awkward; having NEVRA
strings meant for example that clients would have to parse them.  It
would be harder to present something like the current `rpm-ostree
upgrade` package diff output.

Now...I debated quite a while before doing this patch.  The thing
that's really awful about creating this library is there are *SO MANY*
layers.  rpm-ostree → libhif → hawkey → libsolv → librpm.  It's enough
to make one question whether one is actually accomplishing anything or
just contributing to a collective insanity...

Let's pretend for now it's the former.

Closes: https://github.com/projectatomic/rpm-ostree/pull/136
2015-04-16 13:26:58 -04:00
Colin Walters
be9de3a7df Merge pull request #130 from cgwalters/lib
build: Use -fvisibility=hidden and explicit exports
2015-04-14 16:28:40 -04:00
Giuseppe Scrivano
cab58e37ea compose: honor --proxy again
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-04-14 14:57:14 +02:00
Colin Walters
792da457db build: Use -fvisibility=hidden and explicit exports
This avoids symbol leakage.  Previously we were at risk of exporting
other random API from libpriv, as well as libglnx.
2015-04-13 21:25:05 -04:00
Colin Walters
de47c23450 doc: Add gtk-doc for new library 2015-04-13 14:39:06 -04:00
Colin Walters
8a5730525e Add a public shared library, with "rpm -qa" for commit functionality
This will help build release engineering and other types of tools;
for example, rather than parsing the output of `db diff`, one
should be able to call an API.

Initially, this adds the generic infrastructure for a public shared
library, with a new function call to do the equivalent of `rpm -qa` on
a particular OSTree commit.

Closes: https://github.com/projectatomic/rpm-ostree/issues/117
Closes: https://github.com/projectatomic/rpm-ostree/pull/124
2015-04-13 14:39:06 -04:00
Giuseppe Scrivano
7d86f72c79 do not crash when no selinux tag is present
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-04-13 10:43:24 +02:00
Colin Walters
f051d8f2b8 compose: Drop internal containerization for now
It breaks at least `/etc/resolv.conf` inside Docker.  The right thing
here is to run all things involving networking (librepo) as an
unprivileged process with different constraints than the rpm installs.
2015-04-10 16:48:36 -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
devop-mmcgrath
b93c64a7d5 rollback: Fix spelling of 'successfully'
Closes: https://github.com/projectatomic/rpm-ostree/pull/125
2015-04-07 17:35:47 -04:00
Colin Walters
e79c73de20 build: Remove last vestiges of hawkey/libsolv compat
We can assume the versions we care about have propagated everywhere
that supports the libhif version we support.
2015-03-20 14:55:32 -04:00
Colin Walters
ddf2227ae9 compose: Optionally make use of rpmsqSetInterruptSafety
See http://lists.rpm.org/pipermail/rpm-maint/2015-February/003863.html
2015-03-19 22:25:04 -04:00
Colin Walters
fc7483b7bc rpmutil: Make use of libglnx console APIs
Less code duplication.
2015-03-19 21:57:00 -04:00
Colin Walters
79a89f90d5 rebase: Also end status line after pull is complete
This is what `upgrade` does.  Otherwise we end up not printing a
newline, and the next line gets glommed on, and we look silly.
2015-03-16 21:22:26 -04:00
Colin Walters
c7e437a281 postprocess: Drop the version checking code
This breaks things when I add automatic_version_prefix and am using a
local repository - it's not buying me anything, and makes it harder to
hack.
2015-03-12 21:45:11 -04:00
Giuseppe Scrivano
38d34e757a configure.ac: improve detection of hy_sack_create ABI change
Fedora 21 seems to use the old ABI with the version 0.5.3.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-03-06 14:30:02 +01:00
Colin Walters
4b19dd1266 Move the little "libcontainer" code into libglnx
I want to share it with ostree, and potentially xdg-app.
2015-03-04 18:29:55 -05:00
Matthew Barnes
deef74e7a0 compose: Sort the goal before printing 2015-02-24 10:15:20 -05:00
Colin Walters
f50e19dfd1 compose: Print the goal
It's useful to see what's going to be installed before we do it.
2015-02-19 18:42:53 -05:00
Colin Walters
392acdf963 Move console code to libglnx
The main goal is to be able to share this with OSTree.
2015-02-17 16:54:54 -05:00
Colin Walters
3190eff276 Start using libglnx
The high level goal is to deprecate libgsystem.  I was trying to share
code between ostree/rpm-ostree, but it was too painful to commit to
forver frozen ABI for new utility APIs.

The git submodule approach will much more easily allow breaking
API/ABI, and iterate on APIs until they either land in GLib or not.

Note that libglnx will not use GFile*, so a full port to it will
involve also not using that.  Thus, it will be necessarily
incremental; in the meantime we'll link to both libgsystem and
libglnx.
2015-02-15 14:01:13 -05:00
Colin Walters
5268cdf776 treepkgdiff: Adapt to Hawkey 0.5.3 API break
We will work on both old and new versions.

See 8ce3ce754f
2015-02-05 09:21:07 -05:00
Giuseppe Scrivano
6547fbc84f build: replace libhif/hif-context-private.h with libhif/hif-utils.h
The header was renamed in newer versions of libhif.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-02-03 11:07:54 +01:00
Colin Walters
fcd1b43249 compose-tree: Add --touch-if-changed
This is a convenient way for external tools to integrate rpm-ostree
better into automation.  With the caching, it's now cheaper to
just rerun rpm-ostree if you know an input yum repository changed,
or just on a timer.

Then one can use this flag to determine whether or not to launch any
further processes after rpm-ostree, such as disk image generation,
test suites, etc.
2015-02-02 16:39:26 -05:00
Colin Walters
9c8dcbe98c [libhif] Update to support "documentation" flag 2015-02-02 16:39:26 -05:00
Colin Walters
5f61945302 [libhif] Actually honor --force-nocache option 2015-02-02 16:39:26 -05:00
Colin Walters
172ff5712b [libhif] Port to new hif_error_set_from_hawkey()
And drop our internal copy.
2015-02-02 16:39:26 -05:00
Colin Walters
53f0c191ac [libhif]: Use the new proxy API to honor http_proxy
For the obvious reasons, this helps avoid redownloading packages
continuously.
2015-02-02 16:39:26 -05:00
Colin Walters
aa190edfbf [libhif] Rework compose caching with new packaging APIs
With yum, we would have had to make a custom Python app to cleanly
separate the fetch metadata/depsolve phases from installation.

Now that libhif/hawkey gives us that, make use of it by exiting after
depsolve if the previous compose has the same package set, and the
treefile is the same.  This saves a fairly substantial amount of time
and I/O, and makes it much more palatable to simply run the compose
tool on demand in response to say repo regeneration notifications.

A further important note; --cachedir is no longer used; we store the
inputhash in the OSTree commit metadata itself.
2015-02-02 16:39:26 -05:00
Colin Walters
0ff3d1de33 [libhif] Exit again on SIGINT/SIGTERM
A major (if not the biggest) point of this endeavor is to support
atomic/idempotent operation.
2015-02-02 16:39:26 -05:00
Colin Walters
7e0a55cd64 [libhif]: Add initial progress reporting
This requires open-coding the 3 steps that hif_context_run() was
doing.  Which is fine, because ultimately we want to have more control
over that.
2015-02-02 16:39:26 -05:00
Colin Walters
01772d67ad [libhif] Implement support for install-langs 2015-02-02 16:39:25 -05:00
Colin Walters
2263bb35f6 [libhif] compose: Initial port to libhif instead of yum
There are a lot of advantages to this.  See the linked issue
for more details, but briefly:

 - Lays the groundwork for package layering
 - Better caching (exit compose after depsolve if no changes)
 - Better error handling
 - Potential for unprivileged package downloads
 - Potential to better containerize installs

TODO:
 - langs handling
 - progress output

Closes: https://github.com/projectatomic/rpm-ostree/issues/53
2015-02-02 16:39:25 -05:00
Colin Walters
4511a1d8ac consoleprogress: New class for writing to the console
Some influence from both systemd and packagekit-glib2.
2015-02-02 16:39:25 -05:00
James Antill
e120675b82 passwd: Use check-* file json config. entries to migrate data across commits 2015-01-22 15:13:50 -05:00
James Antill
834e62826d compose: Add documentation json config. for nodocs yum/rpm transaction flag 2015-01-16 00:33:22 -05:00
James Antill
b49a489f9f Merge pull request #94 from james-antill/master
compose: Add automatic_version_prefix to json config.
2015-01-12 15:14:49 -05:00
Colin Walters
dca6e9b1e8 passwd-util: Drop unnecessary #include
This was breaking the

    make -C packaging -f Makefile.dist-packaging dist-snapshot-without-compose-tooling

build.
2015-01-12 11:40:30 -05:00