Colin Walters [Thu, 23 Jun 2016 00:12:31 +0000 (20:12 -0400)]
Final excision of libgsystem dependency
Lots and lots of preparation led to this moment - when nothing
apparent changes for users! Woo!
But seriously, having the extra dependency is a minor annoyance, and
in the big picture I think the libgsystem idea was wrong - we need to
land things in GLib, and use git submodules for API-unstable or
Linux-specific sharing. For a lot of OSTree, the libgsystem `GFile*`
orientation was also wrong, we really want fd-relative.
Colin Walters [Mon, 8 Aug 2016 19:41:09 +0000 (15:41 -0400)]
prune: Retain the tip of each ref even with date pruning
I hit an error with [CAHC](https://wiki.centos.org/SpecialInterestGroup/Atomic/Devel)
where we were doing time-based pruning. `ostree summary -u` started failing,
and it took me a bit to realize it was because we were pruning
even the tip of old branches, which I was not at all expecting,
and I don't think users will too.
Perhaps in the future we could add some sort of --prune-ref-tips or
something if people wanted it, but I doubt it.
Colin Walters [Thu, 4 Aug 2016 13:37:26 +0000 (09:37 -0400)]
deploy: Use internal recursive copy rather than libgsystem
Since we already had a "recursive copy" implementation here, let's
reuse it rather than the libgsystem `gs_shutil_cp_a()`. Part of the
libglnx porting.
Colin Walters [Fri, 5 Aug 2016 11:08:14 +0000 (07:08 -0400)]
repo: Drop more internally unused GFile members
I forgot to actually remove `config_file` in the previous
commit, the txn lock hasn't been used in a long time, and
for the uncompressed cache, everything uses the fd already.
Simon McVittie [Fri, 5 Aug 2016 21:12:55 +0000 (22:12 +0100)]
travis: run the test suite on various distributions
.travis.yml is obviously still Travis-specific, but tests/ci-* are
designed to be shareable with other CI environments if there is interest
in doing so.
At the moment I'm only testing on Debian and Ubuntu. In principle we
could try a non-Debian-derived Docker container such as Fedora or CentOS
inside travis-ci's Ubuntu environment, similar to what I'm doing
for Debian, but I don't know the correct setup commands to use there.
Simon McVittie [Fri, 5 Aug 2016 19:41:05 +0000 (20:41 +0100)]
Skip tests that use whiteouts under Docker/aufs
ostree's naming convention for whiteouts is similar to what is
done in aufs, which means we can't compose the trees to test this
feature under Docker with the aufs storage driver, as used on
travis-ci.
Signed-off-by: Simon McVittie <smcv@debian.org> Closes: #437
Approved by: cgwalters
Colin Walters [Thu, 4 Aug 2016 20:35:49 +0000 (16:35 -0400)]
lib: Fix a compiler warning introduced from earlier patch
I think we'd end up closing stdin...yuck. Need to investigate
having this be fatal, but CentOS 7 `gcc-4.8.5` doesn't understand
`-Werror=int-conversion`.
Colin Walters [Thu, 4 Aug 2016 11:22:41 +0000 (07:22 -0400)]
lib: Add padding booleans to OstreeRepoCheckoutAtOptions
Since this is a new API, and adding booleans is the most likely thing
we'll do, let's stick some explicit padding for them in here now.
We could use the `unused_ints[]` but it'd be out of order, and this
will more clearly remind people about the padding. The efficiency hit
versus bitfields is annoying, but oh well, not a real world problem.
Colin Walters [Wed, 3 Aug 2016 14:55:35 +0000 (10:55 -0400)]
repo: Flip the fsync default to off for new checkout API
Since we're adding a new API, we have the opportunity to fix
the defaults. We expect clients to do a `syncfs()` or equivalent
on their own now, since it's way more efficient.
Colin Walters [Tue, 2 Aug 2016 18:49:42 +0000 (14:49 -0400)]
deltas: Port compilation to libglnx/fd-relative
This was the last use of libgsystem tmpfile APIs. The change here is
a bit uglier than it needs to be because we support creating the delta
in place as well as in the repo, so we needed to abstract over
locations.
William Manley [Tue, 19 Jul 2016 18:48:23 +0000 (19:48 +0100)]
ostree-prepare-root: Use pivot_root if real sysroot is already mounted at /
This allows ostree-prepare-root outside of the initramfs context where the
real rootfs is already mounted at /. We can't use `mount --move` in this
case because we would be trying to move / into a subdirectory of itself.
William Manley [Mon, 18 Jul 2016 17:09:10 +0000 (18:09 +0100)]
Refactor ostree-prepare-root: Perform chdir to deploy directory earlier
...for simplicity. This way we don't need to keep concatenating
deploy_path to everything. We can just refer relative to the current
working directory.
We need to do this after bind-mounting it over itself otherwise our cwd
is still on the non-bind-mounted filesystem below.
William Manley [Mon, 18 Jul 2016 17:02:12 +0000 (18:02 +0100)]
ostree-prepare-root: Refactor: Create /sysroot.tmp much later
Typically we have our ready made-up up root at
`/sysroot/ostree/deploy/.../` (`deploy_path`) and the real rootfs at
`/sysroot` (`root_mountpoint`). We want to end up with our made-up root
at `/sysroot/` and the real rootfs under `/sysroot/sysroot` as systemd
will be responsible for moving `/sysroot` to `/`.
We need to do this in 3 moves to avoid trying to move `/sysroot` under
itself:
William Manley [Mon, 18 Jul 2016 16:03:11 +0000 (17:03 +0100)]
ostree-prepare-root as init: exec init from deployment if run as PID1
This supports running ostree on embedded platforms without an initrd.
Specificially I'm trying to do bringup on an NVidia Tegra based Jetson TK1
dev board.
William Manley [Wed, 27 Jul 2016 15:40:05 +0000 (16:40 +0100)]
tests: Add basic tests for ostree-prepare-root
These tests use unshare and mount to prepare a fake initrd/early boot
directory structure so we can then test ostree-prepare-root.
Things that are tested:
* Running in an initrd environment
* Running without initrd
* /var and /sysroot being mounted correctly
* /usr being mounted read-only
Things not tested (yet):
* Running as init - this could be accomplished by unsharing the pid
namespace too.
* mounting/unmounting `/proc` if `/proc/cmdline` isn't available
* Persistent overlayfs for `/usr`
* Probably other things
The tests are basic but can be extended in the future as we do more work
on `ostree-prepare-root`.
These tests must be run as root as they require the ability to `mount`
and to `unshare` the mount namespace. Perhaps in the future we can use
user namespaces for this test once they are more widely available.
Colin Walters [Mon, 1 Aug 2016 14:43:49 +0000 (10:43 -0400)]
repo: Make ostree_repo_create() nonfatal on existing repos
In general we want to support "idempotentcy" or "state
synchronization" across interruption. If a repo is only partially
created due to a crash or whatever, it's hard for a user to know that.
Let's just make `ostree_repo_create()` idempotent. Since all we're
doing is a set of `mkdirat()` invocations, it's quite simple.
This also involved porting to fd-relative, which IMO makes the
code a lot clearer.
Dan Nicholson [Sat, 30 Jul 2016 15:14:17 +0000 (10:14 -0500)]
deltas: Allow processing of empty delta parts
If a static delta is generated between 2 commits with the same content,
then the delta will contain 1 part with no checksums. While useless,
this is a valid delta that shouldn't raise an assertion. If the delta
part has no checksums, then there are no objects to recreate and the
processing can be skipped.
Colin Walters [Mon, 27 Jun 2016 01:59:12 +0000 (21:59 -0400)]
libglnx porting: Migrate to new tempfile code
In general this is even cleaner now, though it was better after I
extracted a helper function for the "write tempfile with contents"
bits that were shared between metadata and regular file codepaths.
Colin Walters [Mon, 11 Jul 2016 13:29:18 +0000 (09:29 -0400)]
deltas: Handle untrusted checksums faster and more robustly
When reworking the ostree core [to use O_TMPFILE](https://github.com/ostreedev/ostree/pull/369),
I hit an issue in the way the untrusted delta codepath ends up trying
to re-open the file to checksum it. That's not possible with
`O_TMPFILE` since the fd (which we opened `O_WRONLY`) is the only
accessible reference to the content.
Fix this by changing the delta processing code to update a checksum as
we're doing writes, which is also faster, and ends up simplifying the
code as well.
What would be an even larger simplification here is if we e.g. used a
separate thread calling `write_object()` or something like that; the
main issue I see there is somehow bridging the fact that function
wants a `GInputStream*` but the delta code is generating stream of
writes.
Colin Walters [Sun, 24 Jul 2016 19:26:11 +0000 (15:26 -0400)]
glib.supp: Suppress g_task -> thread leaks
There are variants of this, but right now because `GTask` has its
own pool which isn't necessarily cleaned up on exit, we need
to suppress all of this.
Colin Walters [Sun, 24 Jul 2016 19:00:02 +0000 (15:00 -0400)]
pull-local: Explicitly unref variant rather than relying on floating
This shows up as a leak in valgrind; the callee isn't sinking. In
general through the power of cleanup attributes we can do explicit
cleanup rather than relying on floating refs.
Colin Walters [Sun, 24 Jul 2016 18:54:07 +0000 (14:54 -0400)]
trivial-httpd: Fix leak of option context
Right now our valgrind runs also end up valgrinding the
`trivial-httpd` code, so while it doesn't matter, let's fix this leak
anyways. We need to avoid calling `_exit()` since that won't run the
cleanup functions.
Colin Walters [Fri, 22 Jul 2016 20:58:26 +0000 (16:58 -0400)]
pull: Don't execute static deltas when mirroring
We don't presently support this, since the static delta code assumes
it can just `mmap()` file objects. We could at some point implement
this, but for now just skip executing deltas when doing
`archive -> archive` mirroring.
I noticed this when trying to mirror a repo in Jenkins in
[CAHC](https://wiki.centos.org/SpecialInterestGroup/Atomic/Devel).
Dan Nicholson [Thu, 14 Jul 2016 16:09:12 +0000 (09:09 -0700)]
core: Add allocating b64 checksum functions
The checksum_b64_inplace variants can't be used in bindings. Provide
versions that allocate and return the output rather than working on a
passed in buffer. These can then be used in GI bindings to get the
ostree modified base64 encodings.
Dan Nicholson [Thu, 14 Jul 2016 19:45:39 +0000 (12:45 -0700)]
lib: Fix version script node ordering
The order of the VERSION nodes is such that the new node name goes first
and the one it depends on goes after the commands. See
https://sourceware.org/binutils/docs/ld/VERSION.html.
Makefile-tests.am: make check uses the built binaries
The tests suite was failing locally as it was using the installed
version of rofiles-fuse, instead of the built one. Create the needed
symlinks in tests/ as we are already doing for the "ostree" binary.
ostree-prepare-root and ostree-remount added for completeness.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #395
Approved by: cgwalters
Colin Walters [Wed, 13 Jul 2016 15:46:16 +0000 (11:46 -0400)]
builtins/commit: Switch to using ostree_repo_write_dfd_to_mtree()
Where we're referencing local files. It's what
ostree_repo_write_directory_to_mtree() is doing internally anyways,
and I consider the `GFile*` based APIs to be generally deprecated for
the most part.
Colin Walters [Tue, 12 Jul 2016 13:43:32 +0000 (09:43 -0400)]
repo: Ensure we set mode for bare-user files before xattrs
When trying to switch ostree to `O_TMPFILE`, I hit the fact that
by default it uses mode `000`. It still works to write to the
open fd of course, but it *doesn't* work to set xattrs because
that code path for some reason in the kernel checks the mode bits.
This only broke for bare-user repos where we tried to set the xattr
before calling `fchmod()`, so just invert those two operations.
Colin Walters [Fri, 8 Jul 2016 14:54:11 +0000 (10:54 -0400)]
tests: Fix karg tests on ostree-booted system
https://github.com/ostreedev/ostree/pull/372 caused these tests to
start failing when the host system is managed using ostree - since the
tests *do* replace the `ostree=` kernel argument.
Colin Walters [Fri, 8 Jul 2016 14:15:47 +0000 (10:15 -0400)]
fetcher: Clear all data for session in session thread
Conceptually the session thread owns the session, so let's clear out
everything predictably there, rather than sometimes having it happen
on the main thread.
Also, this moves up clearing the pending/outstanding queues *before*
we unreference the session, since conceptually they need to reference
it as well.
Based on a patch from: Matthew Barnes <mbarnes@redhat.com>
Colin Walters [Fri, 8 Jul 2016 14:01:47 +0000 (10:01 -0400)]
fetcher: Hold a ref to main context for lifetime of thread
I don't think this fixes the bug I was seeing, but it makes me more
comfortable to know we have a strong ref to the main context across
the thread lifetime, and we only unset the default right before
we go away.
If something in `thread_closure_unref()` used
`g_main_context_get_thread_default()` for example it'd be wrong
before.
Colin Walters [Thu, 7 Jul 2016 21:39:07 +0000 (17:39 -0400)]
tests: Add some test coverage of repeated pulls w/HTTP 500s
Systems like pulp may want to keep retrying in a loop if the server
throws a (hopefully transient) 500, and we need test coverage of
handling these errors versus our existing 404 and 206 coverage.
G_DEFINE_AUTOPTR_CLEANUP_FUNC is a new function in GLib 2.44, but
libglnx contains a backported version of it. A few source files were
however using G_DEFINE_AUTOPTR_CLEANUP_FUNC either without including
libglnx.h, or without including it early enough.
Colin Walters [Fri, 1 Jul 2016 18:39:49 +0000 (14:39 -0400)]
delta: Add --if-not-exists option
I often want to have "idempotent" systems that iterate to a known
state. If after generating a commit, the system is interrupted, I'd
like the next run to still generate a delta. But we don't want to
regenerate if one exists, hence this option.
Dan Nicholson [Mon, 27 Jun 2016 20:06:23 +0000 (13:06 -0700)]
build: Override systemd unit directory for distcheck
distcheck tests that all the files are installed under $prefix. That
doesn't work with the systemd unit directory since the path comes from
pkg-config. Override the setting to be under $prefix in that case.
Dan Nicholson [Fri, 13 May 2016 19:53:01 +0000 (12:53 -0700)]
tests: Improve check for /proc/cmdline kargs
On some systems there may be no root= argument, so the tests for
appending /proc/cmdline arguments will fail. Instead, loop over each of
the arguments in the host's /proc/cmdline and test that they're in the
constructed config file. That will actually test if ostree added all of
the system's /proc/cmdline args correctly. The regex isn't perfect here,
but it's probably good enough for this test.
Dan Nicholson [Fri, 13 May 2016 17:22:02 +0000 (10:22 -0700)]
tests: Ensure mutable deployments from libostreetest
When creating sysroots with libostreetest, we don't get the benefit of
the OSTREE_SYSROOT_DEBUG setting in libtest.sh. That means we'll get
immutable deployments that can't be easily cleaned up.
Ensure the environment variable is set before creating new sysroots. It
would be nice to set the debug flags directly, but that's private API
that isn't currently pulled into libostreetest.
Colin Walters [Sun, 26 Jun 2016 14:25:03 +0000 (10:25 -0400)]
checkout: Add an option to require hardlinks
I've seen a few people hit this and wonder why checkouts are slow/take
space. Really, ensuring this happens is the *point* of OSTree.
Physical copies should be a last resort fallback for very unusual
situations (one of those is rpm-ostree checking out the db since
librpm doesn't know how to read from libostree).
Even I hit the fact that `/var` is a mountpoint disallowing hardlinks
with `/ostree` once and was confused. =)
Add this to the rofiles-fuse test case because it creates a mount
point.
Simon McVittie [Sun, 26 Jun 2016 12:56:05 +0000 (13:56 +0100)]
tests: use our own generated libtool, not the one in $PATH
libtoolize creates a version of libtool for the right architecture
in $(top_builddir), which is guaranteed to be present, and is
guaranteed to match what we are compiling (even during
cross-compilation).
Packaging systems sometimes separate /usr/bin/libtool, which is
specific to one architecture, from the libtool development files
such as libtoolize and ltmain.sh, which are architecture-independent.
For example, in Debian, libtool_*_all.deb contains the files necessary
to libtoolize a package and is depended on by the dh-autoreconf package,
but libtool-bin_*_amd64.deb (or whatever architecture) contains
/usr/bin/libtool and is not normally necessary to depend on.
Signed-off-by: Simon McVittie <smcv@debian.org> Closes: #367
Approved by: cgwalters