Commit Graph

817 Commits

Author SHA1 Message Date
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
799fe4d7c7 packaging: Drop hawkey BR
We're now tracking libhif master only.
2016-03-08 14:53:23 -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
50fb99ed5a Merge pull request #219 from jlebon/pr/testenv-helper
Fix up libtest.sh and add testenv helper
2016-02-26 13:21:56 -05:00
Jonathan Lebon
774c2a43ba libtest.sh: add include guard 2016-02-26 13:06:00 -05:00
Jonathan Lebon
b129df69dc Makefile-tests.am: add helper testenv target
The 'testenv' target enters an environment in which a tmpdir is created
and the daemon is set up and started. This is useful for easy testing.

$ make -j4 && make install
$ make testenv
===== ENTERING TESTENV =====
$ # now we can easily test our new code
$ # we can even make use of helper funcs
$ source ../tests/libtest.sh
$ setup_os_repository archive-z2 syslinux
$ exit
===== EXITING TESTENV =====
2016-02-26 13:06:00 -05:00
Jonathan Lebon
657f48377b setup-session.sh: use libtest.sh for setup
The libtest.sh script is aware of whether a tmpdir needs to be created
or not for the test. Make use of this in setup-session.sh so that we're
sure we're in the right directory before creating the sysroot dir.
2016-02-26 12:17:52 -05:00
Colin Walters
78d0bbbf12 Merge pull request #215 from cgwalters/unpacker-32
unpacker: Fix a 32 bit format string error
2016-02-23 21:09:25 -05:00
Colin Walters
9a0a59f7e5 Merge pull request #217 from jlebon/pr/local-test-repo
test-ucontainer.sh: use test-repo in srcdir
2016-02-23 20:54:16 -05:00
Jonathan Lebon
1c81b7f56e test-ucontainer.sh: use test-repo in srcdir
Running `make check` would fail because test-ucontainer.sh uses
test-repo, which points directly to the installed_testdir, where it is
not installed yet.

We make another processed version of test-repo.repo.in which instead
points to the repo in the srcdir and make use of that in
test-ucontainer.sh.

There are probably other ways of solving this, but this is the one that
jumped out at me.
2016-02-23 17:53:46 -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
06f5577770 tests: Use createrepo_c
It's what more components are standardizing on.
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
a09ba2c9aa Merge pull request #213 from jlebon/pr/mutable-deployments
tests: make ostree use mutable deployments
2016-02-19 12:48:16 -05:00
Jonathan Lebon
34fdcaaf50 tests: make ostree use mutable deployments
For the same reasons as described in GNOME/ostree#187. In summary: we
want to make it easy for testers to clean up after we're done by not
setting the immutable flag.

Note that I had to also add it to setup-session.sh so that the daemon
inherited the env var. The libtest.sh hunk is redundant in that case,
but still necessary if the tests are run directly.
2016-02-19 12:39:46 -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
e5ce418fe5 Merge pull request #205 from cgwalters/libarchive-builddep
build: Add `libarchive` to pkg-config deps
2016-01-12 12:39:45 -05:00
Colin Walters
04164fc025 build: Add libarchive to pkg-config deps
For some reason my CD builder didn't trigger this, but we do actually
need `-larchive` (and we want to have the dependency metadata so
packagers know to BuildDepends on it).
2016-01-12 11:22:16 -05:00
Colin Walters
5b7e34f427 Merge pull request #204 from cgwalters/unprivileged
Add testing-only `internals` subcommand, with `unpack` verb
2016-01-12 10:38:15 -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
eda6abf13d Merge pull request #192 from puiterwijk/no-comps
There is no support for comps groups at this moment
2016-01-10 09:29:40 -05:00