Commit Graph

2073 Commits

Author SHA1 Message Date
Colin Walters 18a576c390 lib: Drop GFiles for self->{objects_dir,state_dir}
Everything that used to reference these is now fd-relative.

Closes: #432
Approved by: giuseppe
2016-08-05 08:26:07 +00:00
Colin Walters 308c75e281 repo: Port metadata writing code to fd-relative
It was the last thing referencing `self->objects_dir`.

Closes: #432
Approved by: giuseppe
2016-08-05 08:26:07 +00:00
Colin Walters cfd402e5f7 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`.

Closes: #430
Approved by: giuseppe
2016-08-05 07:38:09 +00:00
Colin Walters 30aa1ec668 lib: Use libglnx file replace API more consistently
We have a better API now, drop use of the internal helper, which also
depended on libgsystem.

This required bumping libglnx to pull in a fix.

Closes: #429
Approved by: giuseppe
2016-08-04 21:27:32 +00:00
Colin Walters 593effe2fb 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.

Closes: #427
Approved by: giuseppe
2016-08-04 12:18:28 +00:00
Colin Walters 18d826e3a5 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.

Flip the checkout fsync default to off.

Closes: #425
Approved by: giuseppe
2016-08-04 07:33:31 +00:00
Colin Walters f66906c401 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.

Closes: #424
Approved by: giuseppe
2016-08-03 08:10:27 +00:00
Colin Walters a843d16de2 grub2: Port away from gs_file_sync_data()
Inlining this is uglier, but this code kind of sucks anyways =( We're
going to need to do some fd-relative porting in here at some point.

Closes: #424
Approved by: giuseppe
2016-08-03 08:10:27 +00:00
Colin Walters c671c1dd3e lib: Port away from gs_file_rename()
In one case, we already had relative fds and hence this was
nicer.  Unfortunately the other areas got uglier.  More fd-relative
porting to do later.

Closes: #424
Approved by: giuseppe
2016-08-03 08:10:27 +00:00
William Manley 78f99d4780 ostree-prepare-root: Fix typo in error message
Closes: #403
Approved by: cgwalters
2016-08-02 19:07:25 +00:00
William Manley 6356edaaba ostree-prepare-root: Make error message capitalisation consistent
There seemed to be more lower case first letters so I've standardised
on that.

Closes: #403
Approved by: cgwalters
2016-08-02 19:07:25 +00:00
William Manley 485a374b21 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.

Closes: #403
Approved by: cgwalters
2016-08-02 19:07:25 +00:00
William Manley 83c0fdc352 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.

Closes: #403
Approved by: cgwalters
2016-08-02 19:07:25 +00:00
William Manley 47e7afab27 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:

1. `/sysroot/ostree/deploy/...` -> `/sysroot.tmp`
2. `/sysroot` -> `/sysroot.tmp/sysroot`
3. `/sysroot.tmp` -> `/sysroot`

This is a refactoring to group all these operations together so I can
implement an alternative in terms of `pivot_root`.

Closes: #403
Approved by: cgwalters
2016-08-02 19:07:25 +00:00
William Manley a0a4052365 ostree-prepare-root: Cope with /proc not being mounted
When trying to read kernel command-line.

Closes: #403
Approved by: cgwalters
2016-08-02 19:07:25 +00:00
William Manley c9551dc231 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.

Closes: #403
Approved by: cgwalters
2016-08-02 19:07:25 +00:00
William Manley 1364e6e30d ostree-prepare-root: Refactor code to resolve deploy_path
I'll reuse this for a new ostree-init.

Closes: #403
Approved by: cgwalters
2016-08-02 19:07:25 +00:00
Colin Walters 24671f7d25 repo: Port to g_autoptr() rather than old style cleanup macros
This notably kills a few libgsystem uses here.

Closes: #423
Approved by: giuseppe
2016-08-01 21:00:12 +00:00
Colin Walters 421c902125 repo: Port sign_data() to libglnx tmpfile APIs
Part of dropping libgsystem.

Closes: #423
Approved by: giuseppe
2016-08-01 21:00:12 +00:00
Colin Walters 6f17237849 deploy: Replace a use of gs_file_enumerator with compat wrapper
More libglnx/glib porting.

Closes: #423
Approved by: giuseppe
2016-08-01 21:00:12 +00:00
Colin Walters 5334758ba7 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.

Closes: #422
Approved by: 14rcole
2016-08-01 15:12:14 +00:00
Dan Nicholson 512090785e 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.

Closes: #420
Approved by: cgwalters
2016-07-31 00:01:52 +00:00
Giuseppe Scrivano edecae06ab libostree, ostree: fix usage of ostree_repo_checkout_tree_at
it was deprecated, use ostree_repo_checkout_at.

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

Closes: #417
Approved by: cgwalters
2016-07-30 11:24:52 +00:00
Giuseppe Scrivano 0bac88e132 libostree: skip introspection for two functions
These two functions are not safe for gobject introspection, so annotate
them to be skipped:

1) ostree_repo_import_archive_to_mtree
2) ostree_repo_export_tree_to_archive

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

Closes: #417
Approved by: cgwalters
2016-07-30 11:24:52 +00:00
Giuseppe Scrivano 8867693240 libostree: mark ostree_repo_checkout_tree_at as deprecated
and move its definition to a separate file.

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

Closes: #417
Approved by: cgwalters
2016-07-30 11:24:52 +00:00
Giuseppe Scrivano 30963766c7 libostree: new function ostree_repo_checkout_at
Provide a gobject introspection safe version for
`ostree_repo_checkout_tree_at'.

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

Closes: #417
Approved by: cgwalters
2016-07-30 11:24:52 +00:00
Colin Walters 6d310db1e7 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.

Closes: #369
Approved by: jlebon
2016-07-29 19:02:41 +00:00
Jonathan Lebon 1db0c8dcd6 static-delta: remove unused struct
Closes: #418
Approved by: cgwalters
2016-07-29 16:38:19 +00:00
Jonathan Lebon e9f08d45f7 static-delta: fix command contexts
Closes: #418
Approved by: cgwalters
2016-07-29 16:38:19 +00:00
Colin Walters 6ffcb24d22 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.

Closes: #392
Approved by: jlebon
2016-07-29 16:03:28 +00:00
Colin Walters fc25fa16e1 lib: Fix compiler warning from previous patch
I had this in a `fixup!` I thought.

Closes: #414
Approved by: giuseppe
2016-07-28 14:46:17 +00:00
Colin Walters a38f2f41b2 lib: Fix leak in bootconfig parser
Pretty simple.

Closes: #410
Approved by: giuseppe
2016-07-28 10:10:17 +00:00
Colin Walters 27559c58a9 deploy: Fix leaks in parsing /etc/os-release
This one is a bit subtle; we're generating a hash that contains
pointers to the strings we parsed, so we need to carefully track
ownership.

Closes: #410
Approved by: giuseppe
2016-07-28 10:10:17 +00:00
Colin Walters 707ef93097 sysroot: Fix a leak in deployment dirpath API
This one is pretty obvious in retrospect.

Closes: #410
Approved by: giuseppe
2016-07-28 10:10:17 +00:00
Colin Walters ba21023d6c fetcher: Explicitly join thread if it's not self
This fixes a valgrind leak; see [this StackOverflow thread](http://stackoverflow.com/questions/17642433/why-pthread-causes-a-memory-leak).

Closes: #410
Approved by: giuseppe
2016-07-28 10:10:17 +00:00
Colin Walters 35008ead77 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.

Closes: #410
Approved by: giuseppe
2016-07-28 10:10:17 +00:00
Colin Walters 7f335a8437 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.

Closes: #410
Approved by: giuseppe
2016-07-28 10:10:17 +00:00
Colin Walters bac1fa1839 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).

Closes: #408
Approved by: giuseppe
2016-07-25 06:50:51 +00:00
Colin Walters a6aeacede6 repo: Fix leak with ostree_repo_commit_traverse_iter_init_commit()
I noticed this using `OT_TEST_VALGRIND=1` on `test-basic.sh`.

Closes: #385
Approved by: jlebon
2016-07-22 14:01:07 +00:00
Dan Nicholson db974b0596 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.

Closes: #398
Approved by: cgwalters
2016-07-15 02:18:27 +00:00
Dan Nicholson 2e97e72123 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.

Closes: #398
Approved by: cgwalters
2016-07-15 02:18:27 +00:00
Colin Walters efa1fa6534 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.

Closes: #394
Approved by: giuseppe
2016-07-14 08:08:53 +00:00
Colin Walters f45eca948c 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.

Closes: #391
Approved by: jlebon
2016-07-12 14:09:37 +00:00
Dan Nicholson 4ebcd57fec repo: Fix annotation for ostree_repo_add_gpg_signature_summary
GI needs to know this is a NULL terminated array of gchar or you'll
segfault using it from a binding.

Closes: #387
Approved by: cgwalters
2016-07-08 22:22:28 +00:00
Colin Walters c31cf75552 Release 2016.7
Closes: #386
Approved by: jlebon
2016-07-08 19:40:55 +00:00
Colin Walters 972ed3e54e fetcher: Remove unused GTask structure member
Spotted by mbarnes.

Closes: #383
Approved by: mbarnes
2016-07-08 18:38:11 +00:00
Colin Walters 5d21650ea5 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>

Closes: #383
Approved by: mbarnes
2016-07-08 18:38:11 +00:00
Colin Walters b4c15209e8 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.

Closes: #383
Approved by: mbarnes
2016-07-08 18:38:11 +00:00
Colin Walters d7629d33a4 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.

Closes: #383
Approved by: mbarnes
2016-07-08 18:38:11 +00:00
Mathnerd314 b0bfb92831 pull: Free fetch_data by default
This should fix the memory leaks in #352

This is a subset of the changes, the other part is in my pull code rewrite

Closes: #382
Approved by: cgwalters
2016-07-06 20:57:40 +00:00
Jonathan Lebon d371aec217 static-delta-core.c: squash unused var warning
Closes: #379
Approved by: cgwalters
2016-07-05 00:34:33 +00:00
Bastien Nocera 9df846559a libostree: Fix build failure with glib 2.42
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.

This fix is similar to the one in commit d368624.

Closes #376

Closes: #377
Approved by: smcv
2016-07-04 15:25:20 +00:00
Colin Walters 0d07c7ecde 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.

Closes: #375
Approved by: jlebon
2016-07-04 13:27:06 +00:00
Jonathan Lebon f4e92a1e06 ostree admin switch: fix short summary
Closes: #371
Approved by: cgwalters
2016-06-27 18:06:25 +00:00
Colin Walters 439069b2bb 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.

Closes: #368
Approved by: jlebon
2016-06-27 13:08:46 +00:00
Colin Walters da989b473d rofiles-fuse: Do allow fchmod/fchown on directories
The program is called ro*files* and ostree creates physical
copies of directories, so changing them is fine.

I hit this when trying to do a copy checkout onto an rofiles-fuse
mount.

Closes: #368
Approved by: jlebon
2016-06-27 13:08:46 +00:00
Colin Walters 073c34ca08 pull: Write commitpartial files for local imports too
Just like HTTP fetches, these can be interrupted, so we need to write
the commitpartial files.

Closes: #324
Approved by: yuqi-zhang
2016-06-24 15:21:38 +00:00
Yu Qi Zhang 02a2b689dd refs: resolve conflict between local/remote repos
Add the functionality to use the same name for refs in local and remote
repos. This helps users keep track of local refs of remote origin, much
like local and remote git branches.

Previously, when a local ref is specified, resolve_refspec would fall
back to searching through remote repos if the ref is not found locally.
This function now takes an extra flag to specify whether it should
search through remote repos. Additionally, ostree_repo_resove_rev_ext
was added to call resolve_refspec with fallback_remote being false, so
refs --create would no longer complain when trying to create a local
ref of the same name as a remote one.

Fix remote repo parsing not being handled correctly on refs --create.

Closes: #363
Approved by: jlebon
2016-06-23 19:52:26 +00:00
Alexander Larsson fc4a7ec35e pull: Correctly handle repo->parent_repo when applying static deltas
In flatpak i was using a parent repo, and it failed to update
with ENOENT when dispatching an set-read-source opcode, because the
object it referenced was in the parent repo.

This fixes that by making _ostree_repo_read_bare_fd look
at parent_repo.

Closes: #362
Approved by: cgwalters
2016-06-23 11:36:33 +00:00
Mathnerd314 9a779563bb refs: Fix a logic error
I encountered the Opening remotes/ dir error with some broken pull code, and this fixes it.

Closes: #358
Approved by: cgwalters
2016-06-22 20:15:42 +00:00
Mathnerd314 23049bbd01 core: Add OSTREE_OBJECT_TYPE_COMMIT_META
This is cleaner than the loose_path_with_suffix approach

Closes: #359
Approved by: cgwalters
2016-06-22 16:10:01 +00:00
Mathnerd314 4cb77c51db core: Use OSTREE_SHA256_STRING_LEN instead of 64
Closes: #359
Approved by: cgwalters
2016-06-22 16:10:01 +00:00
Krzesimir Nowak 91ccaff197 core: Fix wrong return value docs
ostree_commit_get_parent() returns a string form of a checksum, not a
binary form.

Closes: #360
Approved by: cgwalters
2016-06-22 12:45:12 +00:00
Yu Qi Zhang 744543110e refs: allow overwrite of empty folders
We noticed that once a ref folder is created, there is no existing
command that can remove it. For example, once "foo/bar" is created,
even if the user deletes foo or all the refs under foo, the folder
will persist.

Now when the user attempts to create a ref "foo" either through commit
or refs --create, if a folder "foo" exists but is empty of refs, the
folder is removed and the new ref "foo" is created.

New unit tests in tests-ref.sh verify this functionality.

Closes: #354
Approved by: cgwalters
2016-06-21 20:20:15 +00:00
Colin Walters f6ce04e480 libglnx porting: Drop uses of gs_file_openat_noatime
We're not really doing the "noatime" thing anymore.

Closes: #341
Approved by: jlebon
2016-06-21 18:24:17 +00:00
Colin Walters 90b9a06277 lib: Use g_file_enumerator_iterate() if available, with fallback
Import `gs_file_enumerator_iterate()` for the next six months or
so...after RHEL 7.3 is released I'm strongly considering hard
requiring 2.46 or so.

Likely at some point we should figure out how to share more "glib
backport" code with NetworkManager at least.

Closes: #341
Approved by: jlebon
2016-06-21 18:24:17 +00:00
Colin Walters 9e2763106b lib: Use sd_journal directly (optionally)
This was the last caller of libgsystem that isn't
`gs_file_get_path_cached()`.  I think the use case ostree has where
the same code can be called via command line and via a shared library
*and* via a daemon is rather unusual, so let's just copy the code for
logging from libgsystem into here.

For example rpm-ostree hard depends on a daemon mode, so it'll just
use `sd_journal` directly.

Closes: #341
Approved by: jlebon
2016-06-21 18:24:17 +00:00
Colin Walters 4819b44189 libglnx porting: Use of GSDirFdIterator
This one was pretty simple.  One of the uses in `repo.c` was just a
leftover variable.

Closes: #341
Approved by: jlebon
2016-06-21 18:24:17 +00:00
Colin Walters 0134c62157 libostree.sym: Fix test-symbols
The test isn't smart enough to ignore comments, so change the prefix.

Closes: #356
Approved by: jlebon
2016-06-20 22:59:27 +00:00
Colin Walters 6c7e191147 Release 2016.6 2016-06-20 11:51:32 -04:00
Colin Walters 535033a4f0 pull: Ensure we always process queue only from main thread
I was easily reproducing a hang on pulls with thousands of requests on
current git master.  The initial symptom seemed to be that there are
multiple code paths where we don't invoke
`session_thread_process_pending_queue()`.  We really need to do
that any time we remove something from the outstanding queue,
to ensure it gets filled again.

A further issue is that we were tying the lifecycle of the pending
object to the `GTask`, but the task could be unref'd from the main
thread (via a `GSource` on the main thread), and that introduced
threadsafety issues, because the hash table and other data suddenly
could be concurrently modified.

Both of these need to be fixed together.  First, we introduce
`Arc<Pending>`, and ensure that both the main and worker threads hold
references.

Second, we ensure that we re-process the queue *immediately* whenever
a task is done, inside the worker thread, rather than doing it
incidentally via an unref.  This architecture is quite similar to what
the outside pull code is doing.

Closes: #350
Approved by: jlebon
2016-06-17 18:19:23 +00:00
Colin Walters 651f4bc3b9 repo: Avoid a possible divide by zero in progress
The previous code was subject to a divide by zero if less than a
second had passed.  Rework it so we only do the divide if more than a
second has passed.

Closes: #349
Approved by: Mathnerd314
2016-06-17 02:30:13 +00:00
Colin Walters ab47a8a030 Add "archive" as an alias for "archive-z2"
I find the "-z2" is really a long ago relic of the past when I changed
the format.  We no longer have anything to do with the original
`archive`, so let's start allowing people to type `--mode=archive`
which just looks saner.

At some point later I'll update the docs too, but it'll be an annoying
transition period as we'll have to say "On older OSTree, use -z2" etc.

Closes: #346
Approved by: giuseppe
2016-06-16 14:34:23 +00:00
Yu Qi Zhang f8fcdba0a5 refs: add "ostree refs --create" and unit tests
Added the ability to create a ref (much like a git tag) for an
existing commit through "ostree refs EXISTING --create=NEWREF".
Previously the only way to create a new ref was by creating a new commit,
but refs --create allows multiple refs to point to the same commit.

The command will fail if:
 - None/more than one existing ref is specified
 - The specified EXISTING tag does not exist, or was not specified
 - The specified NEWREF already exists, or is the name of a folder

Add unit tests in tests-ref.sh to verify above functionality

Closes: #340
Approved by: jlebon
2016-06-15 20:42:30 +00:00
Colin Walters 7847bc7394 lib: Port some manual close() cleanups to be glnx_fd_close
Just noticed this while reading some code, we didn't have many manual
`out: close()` bits left, this pushes us over the edge to autocleanup
almost everywhere.

Closes: #332
Approved by: jlebon
2016-06-13 14:58:55 +00:00
Alexander Larsson f6b70a32e6 pull: Fix leak of refs_to_fetch
Closes: #333
Approved by: giuseppe
2016-06-10 11:12:59 +00:00
Alexander Larsson c9c4ab851e pull: Fix leaked uri in request_static_delta_superblock_sync
Closes: #333
Approved by: giuseppe
2016-06-10 11:12:59 +00:00
Alexander Larsson 785f894de1 pull: Fix leak of FetchObjectData in some cases
Closes: #333
Approved by: giuseppe
2016-06-10 11:12:59 +00:00
Alexander Larsson bd4e250e93 pull: Fix leak of debug temporary strings
Closes: #333
Approved by: giuseppe
2016-06-10 11:12:59 +00:00
Alexander Larsson 8e3d558f23 libotutil: Fix leak of VariantMapData
Closes: #333
Approved by: giuseppe
2016-06-10 11:12:59 +00:00
Colin Walters 70af1d26b1 tests: Modernize valgrind infrastructure
The recent memleak fixes motivated me to look at the bitrotted code to
run invocations of `ostree` in the test suite underneath valgrind.

There are a few things here.  First, update suppressions file from
libhif, since I recently worked on it.

When running *uninstalled* as we now support, we need
`libtool --mode=execute` in the mix so it expands out to
the uninstalled binary and we don't valgrind the intermediate shell.

However, it's harder than that because we chdir into a tmpdir,
which defeats the libtool logic.  AFAICS, the only fix for this
is to determine the realbin path before we chdir, and then unfortunately
we need to change every use of `ostree` to `${OSTREE}` =(

Then this immediately breaks for me on RHEL7 because my ancient
copy of `valgrind-3.10.0-16.el7.x86_64` is unaware of syscall 306, i.e.
`syncfs`.

But let's do this first before I dive into that.

Closes: #292
Approved by: krnowak
2016-06-09 21:10:35 +00:00
Colin Walters c015fe13fb lib: Add OSTREE_SUPPRESS_SYNCFS environment variable
Just to work around valgrind not understanding the `syncfs()` syscall
in EL7 right now.

Closes: #292
Approved by: krnowak
2016-06-09 21:10:35 +00:00
Colin Walters 0f7bf7be95 lib: Fix a leak in remote parsing
As the docs say, `g_regex_match()` still allocates a match even if it
returns `FALSE`.  Using `g_autoptr` is just plain better.

Closes: #292
Approved by: krnowak
2016-06-09 21:10:35 +00:00
Mathnerd314 1b88dc7f90 docs: Get API docs working again
This changes around a few things that didn't work for me:
* Section names seem to be ostree-* instead of libostree-*
* Also XML files are ostree-* (they didn't show up at all)
- gtk-doc doesn't seem to parse const _OSTREE_PUBLIC correctly
* pull documentation is now on the actual functions rather than stubs
* Update gitignore with some more files

And there some changes to make gtk-doc give fewer warnings (not finished)

Closes: #327
Approved by: cgwalters
2016-06-09 18:15:49 +00:00
Mathnerd314 693b4ec4be pull: Move pull and pull_onedir back into ostree-repo.c
They call pull_with_options, which will fail anyway.

Closes: #327
Approved by: cgwalters
2016-06-09 18:15:49 +00:00
Mathnerd314 da5cb099a6 pull: Move libsoup-related code from ostree-repo.c to ostree-repo-pull.c
This centralizes the ifdef's in one file, which will make it
easier to write new pull backends.

ostree-repo-pull.c is now built unconditionally

Closes: #327
Approved by: cgwalters
2016-06-09 18:15:49 +00:00
Mathnerd314 0e9a875393 repo: use OSTREE_TIMESTAMP (=1) for checked-out files
1 is a better choice than 0 because some programs use 0
as a special value; for example, GNU Tar warns of an
"implausibly old timestamp" with 0.

Closes: #330
Approved by: cgwalters
2016-06-09 18:04:55 +00:00
Colin Walters f94b191ae5 repo: (minor) Drop a GFile usage in signature creation
Just one user of hundreds but, the rest of the function was ported
now.

Closes: #319
Approved by: jlebon
2016-06-09 14:39:09 +00:00
Colin Walters 70e5489258 lib: Add a helper for mmap->bytes with openat(), use it in repo
This kills another GSystem consumer...I think down the line I'd like
to do something like "detect whether file is > 1k if so, mmap,
otherwise just readall()" so we can use this helper in more places.

Closes: #319
Approved by: jlebon
2016-06-09 14:39:09 +00:00
Colin Walters 3a03a35071 lib: Add `_ALLOW_NOENT` flag to internal variant mapping API
We have a lot of "allow_noent" type wrapper functions since
a common pattern is to allow files to not exist, but still
throw cleanly on other issues.

This is another instance of that, and cleans up duplicated error
handling code.

Part of this is prep for moving away from `GFile` consumers.

Closes: #319
Approved by: jlebon
2016-06-09 14:39:09 +00:00
Colin Walters 5a996c04de glnx porting: Drop use of gs_file_openat_noatime
As noted previously the "noatime" thing is mostly obsoleted by
relatime.

Closes: #319
Approved by: jlebon
2016-06-09 14:39:09 +00:00
Colin Walters 882561b01c libglnx porting: Drop last use of gs_transfer_out_value()
Closes: #319
Approved by: jlebon
2016-06-09 14:39:09 +00:00
Colin Walters a79c47415a glnx porting: Drop last uses of gs_file_get_basename_cached()
I apparently missed a few uses in the previous porting.

Closes: #319
Approved by: jlebon
2016-06-09 14:39:09 +00:00
Krzesimir Nowak b5da2f524c repo: Fix build on 32-bit systems
On 32-bit systems the modifier for printing 64bit values should be
%llu instead of %lu. Just use appriopriate macros that do the right
thing.

Closes: #329
Approved by: giuseppe
2016-06-09 11:25:29 +00:00
Jonathan Lebon 2240d1108e ostree_repo_write_commit: add missing docstring arg
Closes: #325
Approved by: cgwalters
2016-06-07 19:47:58 +00:00
Krzesimir Nowak d78e12fc39 summary: Fix a typo
The --gpg-sign parameter will be used for signing the summary, not the
commit. This probably was copy-pasted from the ostree commit command.

Closes: #320
Approved by: cgwalters
2016-06-03 19:39:40 +00:00
Colin Walters eaea07fe43 glnx porting: Port away from gs_file_get_basename_cached()
In some cases we use glnx_basename(), in others we already had a
`GFileInfo` around with the name.

Closes: #316
Approved by: jlebon
2016-06-02 14:52:40 +00:00
Colin Walters 900c085f21 libglnx porting: Port away from gs_file_map_noatime()
The "no atime" thing was mostly useful only before "relative atime"
updates landed.  Users who care about performance will turn it off
entirely anyways.

Closes: #316
Approved by: jlebon
2016-06-02 14:52:40 +00:00
Colin Walters c148631a98 lib: Drop GFile variant mapping API for fd-relative
In addition to generic fd relative porting,
this is a necessary preparatory step for libglnx porting, because
when I tried to use `g_mapped_file_new` I hit an issue with
it using a different error domain from GIO.

Thankfully libglnx consistently uses the GIO error domain, and here
we're now using it for the `open()` call.

Closes: #317
Approved by: jlebon
2016-06-01 15:02:41 +00:00
Colin Walters f725d39f11 lib: Change ot_util_variant_map helpers to consistently sink refs
This is similar to changes Krzesimir has been doing recently - we
really don't need the ergonomics of floating refs since we have
autocleanups.

We should continue to change most of our code to sink refs.

Specifically here it was pretty broken that the `_map()` API was
sinking but the other two weren't, and this broke some refactoring I
was trying to do later.

Closes: #317
Approved by: jlebon
2016-06-01 15:02:41 +00:00
Sam Spilsbury a189b19fd0 repo: Display estimated time remaining when pulling
Bug 765429 said that not having a time estimate can be annoying
when working with large pulls.

There isn't any complex time estimation logic here - we just take
the number of bytes remaining and do a linear projection of
the bytes per second rate at the current point in time.

Closes: #318
Approved by: cgwalters
2016-06-01 14:09:41 +00:00
Colin Walters 24cb0ffc6a core: Port to new libglnx tempname API
Drops another libgsystem use, and as bonus we malloc less too.

Closes: #311
Approved by: jlebon
2016-05-31 18:08:46 +00:00
Colin Walters 7748c361ef sysroot: Correct error handling path in previous libglnx port
I happened to have the github page open with my commit after it was
merged, and then noticed a bug.

We still need to throw if we hit a non-`ENOENT` error.

Closes: #315
Approved by: giuseppe
2016-05-30 15:40:47 +00:00
Colin Walters 6e57987c7c libglnx porting: Port away from gs_file_ensure_directory()
The init-fs code in particular gets (IMO) a lot cleaner being fd
relative.

Closes: #312
Approved by: giuseppe
2016-05-30 11:33:28 +00:00
Colin Walters e5eb6f3a22 libglnx porting: Port callers of gs_file_unlink to just unlink()
In the second case it's actually less code too.

Closes: #312
Approved by: giuseppe
2016-05-30 11:33:28 +00:00
Colin Walters 9d39d3af85 repo: Port uncompressed cache GC to libglnx
- Kills a user of `gs_file_unlink`
 - Is fd-relative
 - Is way less malloc-y.

Closes: #312
Approved by: giuseppe
2016-05-30 11:33:28 +00:00
Colin Walters 33047d5d4f libglnx porting: Port "load utf8 file" contents API callers
Closes: #312
Approved by: giuseppe
2016-05-30 11:33:28 +00:00
Krzesimir Nowak 4929ab4033 repo: Add functions for verifying any data in repository
This can be useful for validating the 3rd party data that is put in
the extensions directory and is signed with the same keys as commits
or the summary file.

Closes: #310
Approved by: cgwalters
2016-05-27 11:20:00 +00:00
Krzesimir Nowak 27f0c6980a repo: Factor out setting up a GPG verifier
Moved out setting up a GPG verifier to a separate function, as I would
like to use it for the any data verification function in the following
commit.

Closes: #310
Approved by: cgwalters
2016-05-27 11:20:00 +00:00
Krzesimir Nowak 582169f83e repo: Add a missing Returns paragraph
Closes: #310
Approved by: cgwalters
2016-05-27 11:20:00 +00:00
Krzesimir Nowak 89bfb1d503 repo: Factor out the check of gpg result to a separate function
I plan to add a function for verifying any data which may return the
error about lack of trusted signatures, so let's avoid the redundancy
and put the check in the separate function.

Closes: #310
Approved by: cgwalters
2016-05-27 11:20:00 +00:00
Krzesimir Nowak 569e43c280 core: Add a function creating an archive-z2 content stream
It is quite similar to the already existing
ostree_raw_file_to_content_stream function, so I factored the common
part to a separate function. The difference is that we cannot report
the size of the resulting stream.

Can be useful for serving a "bare" repository as a faked "archive-z2"
repository.

Closes: #308
Approved by: cgwalters
2016-05-26 16:53:08 +00:00
Mathnerd314 c82f15201a log: Display "(no subject)" for commits without a subject
This resolves the ambiguity for a message with a body but no subject,
and also hints that OSTree is using two bytes to store the empty
commit subject/body (when instead they could be stored, or rather,
not stored, as part of the metadata)

Closes: #305
Approved by: cgwalters
2016-05-25 18:37:47 +00:00
Mathnerd314 80774680e8 commit: Don't require a subject
In practice, a lot of subjects are empty, because the commit date
and branch are sufficient identification. For example, rpm-ostree
does not use subjects. It also doesn't use the command-line ostree
commit tool, so this was not a problem there, but this makes the
behavior consistent.

Also adds a test that empty subjects and omitting the subject
are equivalent. The --timestamp is so that the commits do not
have different timestamps.

Closes: #305
Approved by: cgwalters
2016-05-25 18:37:47 +00:00
Mathnerd314 5e336333f3 commit: Display subject/body in commit editor
This allows automation to prefill the subject/body for the editor.

It could also be useful if some kind of "amend commit" functionality
was implemented.

Closes: #305
Approved by: cgwalters
2016-05-25 18:37:47 +00:00
Mathnerd314 b5bd28adae commit: Add --editor / -e command line argument
Previously, the behavior was to run the editor if no subject or body was specified.
This led to using commit -s '' in scripts, to avoid running the editor.
In practice, manually editing commit messages is rare, whereas automated scripting
is common, so instead default to not running the editor and only run it when -e
is given.

Closes: #305
Approved by: cgwalters
2016-05-25 18:37:47 +00:00
Mathnerd314 dfa1d190b6 commit: accept NULL subject argument
When given a NULL subject, use "" instead, like for the body argument

Closes: #305
Approved by: cgwalters
2016-05-25 18:37:47 +00:00
Alexander Larsson d368624798 Build on older versions of glib
Various places need to include libglnx.h for the autoptr backport
fallbacks to be there before ostree-autocleanups.h is included.

This fixes the build on centos7·

Closes: #309
Approved by: giuseppe
2016-05-25 14:01:39 +00:00
Krzesimir Nowak 2f2af9252d libotutil: Plug a leak
There's no need to allocate the variant builder on a heap, so allocate
it on the stack and avoid a memory leak at the same time.

Closes: #307
Approved by: cgwalters
2016-05-24 11:36:15 +00:00
Krzesimir Nowak d5f6104335 build: Allow ostree to use g_autoptr on its types internally
As an example, I g_autoptred one OstreeRepo in the "ostree init"
command.

Closes: #295
Approved by: cgwalters
2016-05-17 21:13:20 +00:00
Krzesimir Nowak 51e4e3b364 libostree: Add g_autoptr() support for the public types
To avoid breaking the ostree users we hide the autoptr setup behind an
OSTREE_WITH_AUTOCLEANUPS variable. The variable is set to 0 by
default, so users that want to start using them, have to define the
variable themselves to 1.

Probably after some transition period, the variable will be set 1 by
default.

This is conditional on GLib >= 2.44.0 being available. It does not
bump ostree's dependency on GLib.

Closes: #295
Approved by: cgwalters
2016-05-17 21:13:19 +00:00
Gatis Paeglis 441c03ba9e Fix build when have_libsoup_client_certs=no
This fixes a build failure with older libsoup versions
that do not have the client certificates feature.

Closes: #294
Approved by: cgwalters
2016-05-13 14:33:08 +00:00
Krzesimir Nowak cb45456708 libostree: Fix bracket-missing warnings
Apparently I got the bracketing wrong in
862e6ecdcc58f025696b1394adfc0fcf7322df23:

src/libostree/ostree-repo.c: In function 'ostree_repo_delete_object':
src/libostree/ostree-repo.c:3538:11: warning: missing braces around
initializer [-Wmissing-braces]
           g_auto(GVariantBuilder) builder = {0,};

Closes: #298
Approved by: cgwalters
2016-05-13 12:22:59 +00:00
Colin Walters 817060e772 build: Don't run glib-mkenums if there's nothing to do
This fixes the build without libsoup.

Closes: #296
Approved by: gatispaeglis
2016-05-12 17:15:50 +00:00
Colin Walters a5f703799f Make enum generation private by default, export stub symbol
When we added enum type generation, the generated symbols used
the `ostree_` prefix, and at the time that implied they were public.

So we started (if built with libsoup) exporting
`ostree_fetcher_config_flags_get_type`.

I think it's not worth confusing ABI checkers, so let's export the
dummy symbol forever, and switch enums to be private by default.

We should revisit this and also export some auto-generated enum
types for public enums, but that's a separate patch.

Closes: #296
Approved by: gatispaeglis
2016-05-12 17:15:50 +00:00
Krzesimir Nowak 862e6ecdcc libostree: Variant-related leak plugs and fixes
This tries to avoid leaking GVariantBuilders and GVariants in some
situations. The leaks were usually happening when some error occurred
or because of unclear variant ownership situation.

The former is mostly about making sure that g_variant_builder_clear is
called on builders that didn't finish their variant building process.

The latter is surely more work - sometimes the result of
g_variant_builder_end() should not be passed directly to a function,
but rather stored in a g_autoptr(GVariant), sunk and then passed to a
function. IMO, with an advent of g_autoptr, GVariants should be always
sunk instead of relying on some receiver function sinking it. This
would make an easy-to-follow policy of always sinking your
variants. Functions could then assume that the passed variant is
already sunk. These leaks are still happenning in commands, but they
are less harmful, since that code will not be used by some daemon as a
library routine.

Closes: #291
Approved by: cgwalters
2016-05-12 11:17:09 +00:00
Krzesimir Nowak aa946cc136 repo: Allow using options for fetching summary
This adds a _with_options variant of the
ostree_repo_remote_fetch_summary function, so we can tell the fetcher
to use a specific URL instead taking it from the remote config.

Closes: #290
Approved by: cgwalters
2016-05-10 13:47:36 +00:00
Krzesimir Nowak bdd73913fb repo: Plug a leak
The base URI created in this line was always (sans erroneous
situations) overwritten in the code block below without freeing it
previously, so it leaked.

Closes: #290
Approved by: cgwalters
2016-05-10 13:47:36 +00:00
Krzesimir Nowak 3ae87e3f9e core: Improve variant format docs
Use markdown to actually format the tuple member descriptions as a
list. Currently they are hardly legible as gtk-doc formats them into a
single sentence.

Also update the additional metadata docs in the summary objects.

Closes: #289
Approved by: cgwalters
2016-05-10 13:30:50 +00:00
Jonathan Lebon 65e7969b0b OstreeRepo: add extensions directory
It's very useful for third-party applications to have someplace to store
their data guaranteed to be on the same device as the repo (thus
ensuring hardlinks) while still being shielded away from any of OSTree's
timely garbage collections.

We create a new "extensions/" subdirectory where apps can include
whatever they wish in "extensions/myapp/". This subdirectory is
completely unmanaged by ostree.

NB: I didn't bother making it a member of the OstreeRepo proper since we
don't really use it for anything else yet.

Closes: #286
Approved by: cgwalters
2016-05-09 14:43:16 +00:00
Krzesimir Nowak 58532e5917 sysroot: Plug some leaks
The deployments and booted deployment were never unreffed.

Also, remote (void) from the call to the unload function - it returns
nothing, so there is no need to fool the compiler.

Closes: #287
Approved by: cgwalters
2016-05-09 13:41:49 +00:00
Colin Walters d270085ef3 trivial-httpd: Add __attribute__((format))
I was briefly looking at building with clang mostly since it
detects unused variables with cleanup attributes, but then
I hit this fatal error.

It's a hard compile error with `-Wformat-nonliteral` since clang
doesn't know it's a format string.
2016-05-07 11:22:47 -04:00
Jonathan Lebon b717fd2c18 ot-builtin-commit.c: add --skip-list option
This was already supported by the commit modifier API, just needed to
expose it. This will also be used to test the libarchive API in a future
test.

Closes: #275
Approved by: cgwalters
2016-05-06 14:44:55 +00:00
Jonathan Lebon b1d3dd151c ostree-repo-libarchive.c: major refactor
- Make hardlink handling more generic. The previous strategy worked for
  tar archives, but not for cpio. It now works for both.
- Add support for SEL labeling (through the OstreeRepoCommitModifier)
- Add support for xattr_callback (through the OstreeRepoCommitModifier)
- Add support for filter (through the OstreeRepoCommitModifier)
- Add a use_ostree_convention option

Closes: #275
Approved by: cgwalters
2016-05-06 14:44:55 +00:00
Colin Walters 6724519080 libglnx porting: Migrate to glnx_stream_fstat()
I ended up deciding to move this one into libglnx, seems like
something other libglnx-using software might want to do, even though
xdg-app doesn't right now.

Closes: #282
Approved by: jlebon
2016-05-06 14:29:59 +00:00
Colin Walters 5a90781cd8 lib: Add more filename validations (no ., .. or /) in commit logic
The filesystem commit code will never give us potentially hostile
filenames, and when importing from archives, we do some validation.

However, we should be extra paranoid and also add error messages in
the mtree in case someone tries to import a hostile
libarchive-supported format.

Closes: #283
Approved by: jlebon
2016-05-06 01:15:19 +00:00
Colin Walters 7021c4f876 repo: Make repo/tmp expiry configurable via tmp-expiry-seconds
We were arbitrarily only deleting content after exactly one day.  Some
use cases may want something else; make it configurable.

Closes: #170
Approved by: jlebon
2016-05-02 18:44:44 +00:00
Colin Walters a56ba6081a repo: Clean up staging directory for previous boot IDs
We had a policy of cleaning up all files in `$repo/tmp` older
than one day, but we should really clean up previous bootid staging
directories too, as they can potentially take up a lot of disk space.

https://bugzilla.gnome.org/show_bug.cgi?id=760531

Closes: #170
Approved by: jlebon
2016-05-02 18:44:44 +00:00
Colin Walters e3ec83a934 repo: Add OSTREE_BOOTID override envvar for debugging
It's useful for test cases to be able to influence this.

Conflicts:
	src/libostree/ostree-repo.c

Closes: #170
Approved by: jlebon
2016-05-02 18:44:44 +00:00
Colin Walters 15b3cab65e repo: Add OSTREE_REPO_TEST_ERROR=pre-commit env var
Setting this causes commit to error out.  There are other ways we
could do this in a more sophisticated fashion, such as via SystemTap
etc.  But this has low-tech applicablity, works as non-root.

The reason I'm adding this is so that we can add test cases for
cleanup of the `tmp/staging-` directory.

Closes: #170
Approved by: jlebon
2016-05-02 18:44:44 +00:00
Colin Walters 3111248373 repo: Fix reading repos on read-only media
I have a cache drive I often mount read-only, and the previous commit
for opening `tmp/cache` broke since `errno == EROFS`, not `EPERM`.

It turns out we already had the concept of a "writable" repo, so just
piggy back off that.

Closes: #281
Approved by: giuseppe
2016-05-02 14:27:33 +00:00
Colin Walters a6c731f6e7 libglnx porting: Migrate from GSConsole
To GLnxConsoleRef.  There were some subtleties here, for example we
used to reference `GSConsole` inside the progress changed function,
which at first seems like an ABI hazard, because e.g. rpm-ostree or
xdg-app could still be passing a `GSConsole` instance there.  Luckily,
it turns out to be compatible to just start calling libglnx here.

Another issue was that due to libglnx's use of the cleanup function,
we needed to ensure we always called `ostree_async_progress_finish()`
*before* the cleanup function was invoked.

Closes: #280
Approved by: giuseppe
2016-05-02 11:41:00 +00:00
Colin Walters 72abe62370 deploy: Start hardlinking kernel/initramfs on single-part again
Commit
1810de2b51
lost an optimization where we would try hardlinks for the
kernel/initramfs in `/boot`.  This would be a noticeable space savings
on single-partition systems.

Closes: #277
Approved by: gatispaeglis
2016-04-26 11:48:42 +00:00
Alexander Larsson f2fd1f50e2 repo: Handle parent repos with different remote configuration
In the case we have a repo with a parent, and the child repo has a
remote called "foo", but some option is unset. Then when we look up
the parent repo for a value before using the default we will fail due
to the parent not having the "foo" remote. As soon as we find the
requested remote at some point in the hierarchy we need to ignore further
errors and use the default value.

Closes: #274
Approved by: giuseppe
2016-04-22 14:38:00 +00:00
Krzesimir Nowak a6ce162231 trivial-httpd: Add a --log-file option
Might be useful to see what files the client wants to fetch.

Closes: #271
Approved by: cgwalters
2016-04-22 14:27:06 +00:00
Krzesimir Nowak 560cc49234 pull: Add a --url option
This allows ostree to pull the objects from a different URL without
modifying the repo's config.

Closes: #271
Approved by: cgwalters
2016-04-22 14:27:06 +00:00
Krzesimir Nowak 08d2b8ab7b lib: Add URL override pull option
The "override-url" option allows to use the other URL while still
using some options from the passed remote.

Closes: #271
Approved by: cgwalters
2016-04-22 14:27:06 +00:00
Alexander Larsson ad019def9a repo: Fix temporary directory allocation
We looked for and locked old temporary directories so we can
reuse them if not in use. However, once we found one that
we can reuse we didn't stop iterating, and eventually we
reached the end. This means we can lock multiple dirs.

Closes: #273
Approved by: giuseppe
2016-04-22 08:46:53 +00:00
Colin Walters 8609cb036b repo: Simplify internal has_object() lookup code
There was some leftover intermediate cruft here I noticed
while reviewing another patch:

 - We had an output `GFile*` for that was never used
 - We required the caller to allocate the loose pathbuf, but
   none of them ever reused it
 - We had an extra intermediate function

Also while looking at this, I'm now uncertain whether some of the
callers of `_ostree_repo_has_loose_object` should really be invoking
`ostree_repo_has_object()`, but let's leave that aside for now.

Closes: #272
Approved by: alexlarsson
2016-04-21 19:50:53 +00:00
Alexander Larsson 8f8ab56211 repo: Allow loading files staged in the transaction
Currently we can load metadata from the stage dir, but not file
data, which makes no sense.

Closes: #269
Approved by: cgwalters
2016-04-21 19:05:06 +00:00
Gatis Paeglis bd3ad8cc5c Remove unused variables from install_deployment_kernel
Closes: #270
Approved by: cgwalters
2016-04-20 15:09:37 +00:00
Alexander Larsson 5595664e47 ostree export: Add --prefix option
This lets you set a prefix for the resulting archive patsh.
Especially useful in combination with --subpath, for instance
--subpath=subdir --prefix=subdir to extract just subdir.

Closes: #265
Approved by: cgwalters
2016-04-19 12:28:06 +00:00
Alexander Larsson 5079f70ec0 ostree export: Add --subpath support
This lets you export a subset of a commit.

Closes: #265
Approved by: cgwalters
2016-04-19 12:28:06 +00:00
Krzesimir Nowak 9db2f43b14 tests, lib: Remove unused variables
Closes: #267
Approved by: cgwalters
2016-04-19 12:16:16 +00:00
Krzesimir Nowak 6ff7c876dc lib: Fix an introspection annotation
The "allow-none" annotation does not make sense for a plain boolean
parameter.

Closes: #267
Approved by: cgwalters
2016-04-19 12:16:16 +00:00
Krzesimir Nowak 90400d3a62 trivial-httpd: Remove useless code
Closes: #267
Approved by: cgwalters
2016-04-19 12:16:16 +00:00
Krzesimir Nowak 925faca108 lib: Fix a typo
Closes: #267
Approved by: cgwalters
2016-04-19 12:16:16 +00:00
Colin Walters e9a1809c4d Rename test-abi to test-symbols, start verifying symbols are documented
We keep forgetting to update `apidoc/ostree-sections.txt`, so let's
start enforcing it.  Of course it turns out we had some bugs here
like symbols marked as public but never implemented, etc.  Those
are fixed in the prior commits.

Closes: #263
Approved by: giuseppe
2016-04-17 13:52:07 +00:00
Colin Walters 6923c088c5 lib: Remove ostree_repo_file_make_empty_tree
This was removed in 14d682305b - long
before we had a stable library.

I again claim removing unimplemented symbols from the header is not an
API/ABI break.

Closes: #263
Approved by: giuseppe
2016-04-17 13:52:07 +00:00
Colin Walters 1ac46828f2 core: Remove ostree_checksum_update_meta that was not implemented
If a symbol falls in a git merkle tree forest, but no one hears it,
did it ever exist?

I'm claiming this isn't an API/ABI break because nothing could
have actually used this.  `git log -S checksum_update_meta` leads
me to 38ef75e6e0 which was before
we really had a stable shared library.

Closes: #263
Approved by: giuseppe
2016-04-17 13:52:07 +00:00
Alexander Larsson b4b26907c8 static-delta: Initialize read_source_fd to -1
If not, we'll get ESPIPE when seeking on fd 0.

Closes: #260
Approved by: cgwalters
2016-04-15 11:56:06 +00:00
Alexander Larsson a08b7765b7 static-delta: Put temp files in /var/tmp
We may not have write permissions in the current directory.

Closes: #259
Approved by: cgwalters
2016-04-14 20:49:32 +00:00
Colin Walters f3796a4458 refs: Add g_prefix_error around opendir for easier debugging
Addresses:
  https://github.com/projectatomic/rpm-ostree/issues/264

We should consider moving this down into `glnx_opendirat`, but for now
a quick fix.

Closes: #255
Approved by: jlebon
2016-04-14 18:25:10 +00:00
Alexander Larsson 7ac8b0442c Look for $remotename.trustedkeys.gpg in remotes.d dir
This is a nice way to add gpg keys for system configured remotes
without making them globally trusted.

Closes: #247
Approved by: cgwalters
2016-04-14 16:21:01 +00:00
Alexander Larsson c86e4f0c90 Add remotes-config-dir to OstreeRepo
This allows you to replace the default
$sysroot/$sysconfdir/ostree/repos.d string value, and to use a similar
feature for repos that are not the system repo.

In particular, this allows us to support /etc/xdg-app/remotes.d for
xdg-app.

Closes: #247
Approved by: cgwalters
2016-04-14 16:21:01 +00:00
Alexander Larsson 9e7e594907 Add OstreeRepo option for an out-of-band cache dir
This allows you to have a writable cache dir even for a system-owned
repository.

Closes: #250
Approved by: cgwalters
2016-04-14 15:55:08 +00:00
Alexander Larsson b787fce612 Add cache_dir_fd to OstreeRepo
This will allow us later to easily swap out the cache dir.

Closes: #250
Approved by: cgwalters
2016-04-14 15:55:08 +00:00
Alexander Larsson 77ea287cd2 commit: Fix crash if dfd_iter is NULL
in write_directory_content_to_mtree_internal dfd_iter can be NULL,
for instance if commiting from --tree=ref=FOO. Don't blindly de-ref
it to avoid crashing.

Closes: #256
Approved by: cgwalters
2016-04-13 19:37:06 +00:00
Alexander Larsson 6a57d0a2f0 fetcher: Initialize output_stream_set_lock mutex
ostree pull-local crashed for me in thread_closure_unref () doing:
    g_mutex_clear (&thread_closure->output_stream_set_lock);

Seems like we never initialize this mutex.

Closes: #254
Approved by: cgwalters
2016-04-13 14:11:46 +00:00
Colin Walters 594162f16a pull: More consistently use remote_repo_local for local repos
I think it's cleaner if we use `remote_repo_local` to know
that we have a local repo.  In reality, it might be nicest
if we didn't even create an `OstreeFetcher` for this case,
but untangling the code is tricky.

Closes: #239
Approved by: alexlarsson
2016-04-11 13:51:50 +00:00
Jonathan Lebon b69fd11487 ostree-repo-pull: always initialize flags_i
Otherwise we get undefined behaviour if the client didn't explicitly set
any flags.

Also, add documentation for all the other options supported by
ostree_repo_pull_with_options().

Closes: #252
Approved by: cgwalters
2016-04-11 13:31:20 +00:00
Alexander Larsson e62beae695 Fix the symbol versions for ostree_repo_get_remote_*option
These were accidentally added to 2016.4 instead of 2016.5

Closes: #251
Approved by: cgwalters
2016-04-11 13:07:07 +00:00
Jonathan Lebon 41661e47e1 small cleanups
- Revert 'cannot' --> 'can not' (it's the exception!)
- Remove duplicate function
- Squelch compiler warnings

Closes: #248
Approved by: cgwalters
2016-04-08 18:43:18 +00:00
Alexander Larsson ddda8e5b8b Add support for ostree static-delta delete
Closes: #245
Approved by: giuseppe
2016-04-08 13:42:43 +00:00
Alexander Larsson d7181f22a6 Inherit remotes and remote options from parent repo
Closes: #236
Approved by: cgwalters
2016-04-07 20:02:46 +00:00
Alexander Larsson 37382590dc Export ostree_repo_get_remote_option* functions
These are useful for ostree users (like xdg-app) that have custom
options for remotes. In particular they are useful when we later make them
all respect self->parent_repo.

Closes: #236
Approved by: cgwalters
2016-04-07 20:02:46 +00:00
Alexander Larsson 91734a8a18 Support pathnames for --subpath=...
This allows you to pull a single file, rather than just a directory.

Closes: #244
Approved by: cgwalters
2016-04-07 15:15:39 +00:00
Giuseppe Scrivano 3152516ab3 Remove empty new lines at the EOF
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #242
Approved by: cgwalters
2016-04-07 12:25:24 +00:00
Alexander Larsson ace0d4650b pull-local: Support --gpg-verify and --gpg-verify-summary
Force the otherwise disabled gpg verifications on.
Note: You need to pass --remote=foo so we know what gpg keys to verify
against.

Closes: #237
Approved by: cgwalters
2016-04-05 19:12:09 +00:00
Alexander Larsson eabb4e3545 pull: Don't try to cache summaries for pull-local
Not only does this not make sense from a performance perspective, but
it also doesn't work because we can't use a url as a path element.

Closes: #237
Approved by: cgwalters
2016-04-05 19:12:09 +00:00
Gatis Paeglis 4e81548447 Introducing ostree-grub-generator
ostree-grub-generator can be used to customize
the generated grub.cfg file. Compile time
decision ostree-grub-generator vs grub2-mkconfig
can be overwritten with the OSTREE_GRUB2_EXEC
envvar - useful for auto tests and OS installers.

Why this alternative approach:

1) The current approach is less flexible than using a
   custom 'ostree-grub-generator' script. Each system can
   adjust this script for its needs, instead of using the
   hardcoded values from ostree-bootloader-grub2.c.

2) Too much overhead on embedded to generate grub.cfg
   via /etc/grub.d/ configuration files. It is still
   possible to do so, even with this patch applied.
   No need to install grub2 package on a target device.

3) The grub2-mkconfig code path has other issues:
   https://bugzilla.gnome.org/show_bug.cgi?id=761180

Task: https://bugzilla.gnome.org/show_bug.cgi?id=762220

Closes: #228
Approved by: cgwalters
2016-04-04 14:19:35 +00:00
Jonathan Lebon 9260d3dba1 commit: support editor for orphan commits
This is a follow up to #227 to allow ostree to open the editor also for
orphan commits when no subject or body is given on the cmdline.

Closes: #229
Approved by: cgwalters
2016-03-30 12:19:06 +00:00
Colin Walters 23d26d5f65 commit: Support writing orphans
The API supports this, and it's not hard for us to do in the command
line as well.  One possible use case is separating "content
generation" in a separate server.

Related: https://github.com/ostreedev/ostree/pull/223

Closes: #227
Approved by: jlebon
2016-03-30 03:10:50 +00:00
Colin Walters c6b4ecd474 commit: Support generating commits with no parent, or a custom one
When I'm doing local development builds, it's quite common for me not
to want to accumulate history.  There are also use cases for this on
build servers as well.

In particular, using this, one could write a build system that didn't
necessarily need to have access to (a copy of) the OSTree repository.
Instead, the build system would determine the last commit ID on the
branch, and pass that to a worker node, then sync the generated
content back.

The API supported generating custom commits that don't necessarily
reference the previous commit on the same branch, let's just expose
this in the command line for convenience.

I plan to also support this rpm-ostree.

Closes: #223
Approved by: jlebon
2016-03-29 14:31:29 +00:00
Dan Nicholson b1e1e51660 main: Set log handler for OSTree domain
Now that OSTree is used as G_LOG_DOMAIN, set the main handler to match
so the appropriate messages are filtered. It would probably be more
appropriate to spell out "OSTree" in the code, but since G_LOG_DOMAIN is
being defined globally in the project, might as well reuse it here.

https://bugzilla.gnome.org/show_bug.cgi?id=764237

Closes: #225
Approved by: cgwalters
2016-03-26 18:22:59 +00:00
Dan Nicholson 750e2cbf33 core: Add debug messages for traversing
If you have a repo where a needed object has been inadvertantly removed,
all you'll get is a "No such metadata object" error with no clue about
where it was referenced from.

Add some debug messages to provide clues about which objects are being
traversed and found.

https://bugzilla.gnome.org/show_bug.cgi?id=764006

Closes: #224
Approved by: cgwalters
2016-03-26 13:50:16 +00:00
Dan Nicholson 31240982e7 core: Add verbose messages for pruning
When prune fails, it can be really difficult to figure out why. This at
least lets you know which objects are being considered.

https://bugzilla.gnome.org/show_bug.cgi?id=764006

Closes: #224
Approved by: cgwalters
2016-03-26 13:50:16 +00:00
Jonathan Lebon b7a04d51f8 OstreeSePolicy: add ostree_sepolicy_get_csum()
This can be used as a fingerprint to determine whether two
OstreeSePolicy objects are equivalent.

Also add documentation for ostree_sepolicy_get_name().

Closes: #219
Approved by: cgwalters
2016-03-25 15:28:29 +00:00
Alexander Larsson 456f515522 Add --untrusted option to pull and pull-local
https://bugzilla.gnome.org/show_bug.cgi?id=764125

Closes: #221
Approved by: cgwalters
2016-03-25 12:56:55 +00:00
Alexander Larsson ed1e0c6d04 pull: Add OSTREE_REPO_PULL_FLAGS_UNTRUSTED flag
If this is set we verify all objects we pull, even for local remotes,
and we avoid hard-linking into local source repos.

https://bugzilla.gnome.org/show_bug.cgi?id=764125

Closes: #221
Approved by: cgwalters
2016-03-25 12:56:55 +00:00
Colin Walters 80698543c2 Release 2016.4 2016-03-23 15:45:59 -04:00
Dan Nicholson 7524e904b9 traverse: Require variant when traversing dirtree
The dirtree object is required for traversing, so don't use the
load_variant_if_exists() function. This will return a
G_IO_ERROR_NOT_FOUND to the caller rather than trying to ref a NULL
variant in ostree_repo_commit_traverse_iter_init_dirtree() if the object
is missing.

https://bugzilla.gnome.org/show_bug.cgi?id=764091
2016-03-23 15:36:04 -04:00
Dan Nicholson 2ae7f619b2 prune: Don't fail on partial commits
If a commit only pull has been done, then the commit object exists in
the object store in addition to the commitpartial file. Traversing this
partial commit will likely fail, but that's expected. If traverse
returns a G_IO_ERROR_NOT_FOUND in this case, continue with pruning.

https://bugzilla.gnome.org/show_bug.cgi?id=764091
2016-03-23 15:34:17 -04:00
Alexander Larsson ddf0a02f88 pull local: Don't import objects we already have
In particular, I noticed this because the pull failed when trying to
pull from a shallow repo which only had the new objects that was
needed.

https://bugzilla.gnome.org/show_bug.cgi?id=764059
2016-03-23 14:58:08 -04:00
Stef Walter 2454957e8d Fix building without libarchive
Although libarchive is an optional build option, the build
fails without it.

https://bugzilla.gnome.org/show_bug.cgi?id=764056
2016-03-23 13:55:34 -04:00
Colin Walters 09238da065 admin: Add an `unlock` command, and libostree API
I'm trying to improve the developer experience on OSTree-managed
systems, and I had an epiphany the other day - there's no reason we
have to be absolutely against mutating the current rootfs live.  The
key should be making it easy to rollback/reset to a known good state.

I see this command as useful for two related but distinct workflows:

 - `ostree admin unlock` will assume you're doing "development".  The
   semantics hare are that we mount an overlayfs on `/usr`, but the
   overlay data is in `/var/tmp`, and is thus discarded on reboot.
 - `ostree admin unlock --hotfix` first clones your current deployment,
   then creates an overlayfs over `/usr` persistent
   to this deployment.  Persistent in that now the initramfs switchroot
   tool knows how to mount it as well.  In this model, if you want
   to discard the hotfix, at the moment you roll back/reboot into
   the clone.

Note originally, I tried using `rofiles-fuse` over `/usr` for this,
but then everything immediately explodes because the default (at least
CentOS 7) SELinux policy denies tons of things (including `sshd_t`
access to `fusefs_t`).  Sigh.

So the switch to `overlayfs` came after experimentation.  It still
seems to have some issues...specifically `unix_chkpwd` is broken,
possibly because it's setuid?  Basically I can't ssh in anymore.

But I *can* `rpm -Uvh strace.rpm` which is handy.

NOTE: I haven't tested the hotfix path fully yet, specifically
the initramfs bits.
2016-03-23 11:09:09 -04:00
Colin Walters 0b1d301d81 libglnx porting: Use glnx_opendirat()
This unfortunately adds *more* `gs_file_get_path_cached()`, but we'll
fix that all in one go.
2016-03-23 10:26:01 -04:00
Colin Walters 18530894c7 libglnx porting: Use glnx_shutil_rm_rf_at()
In some cases (such as `ostree-sysroot-cleanup.c`), the surrounding
code would be substantially cleaner if it was also ported to
fd-relative, but I'm going to do that in a separate patch.

That way these patches are easier to review for mechanical
correctness.  I used an Emacs keyboard macro as the poor man's
[Coccinelle](http://coccinelle.lip6.fr/).
2016-03-23 10:26:01 -04:00
Colin Walters d456fe5adb libglnx porting: Use glnx_set_error_from_errno
⚠️ There is a notable spiked pit trap here around
`posix_fallocate()` and `errno`.  This has bit other projects,
see e.g.
7bb87460e6

Otherwise the port was straightforward.
2016-03-23 10:26:01 -04:00
Colin Walters 614483ecd1 Use GSubprocess instead of GSSubprocess (libgsystem removal)
Since we hard-depend on GLib 2.40, we can start using GSubprocess.
This is part of dropping our dependency on libgsystem, which is
deprecated in favor of libglnx (as well as migrating things to GLib).
2016-03-23 10:26:01 -04:00
Colin Walters afb6105a51 admin-switch: Add missing reboot argument
Spotted by jlebon in https://github.com/GNOME/ostree/pull/211
2016-03-23 09:42:17 -04:00
Colin Walters 8894bb3949 deploy: Handle a read-only /boot
I'd like to encourage people to make OSTree-managed systems more
strictly read-only in multiple places.  Ideally everywhere is
read-only normally besides `/var/`, `/tmp/`, and `/run`.

`/boot` is a good example of something to make readonly.  Particularly
now that there's work on the `admin unlock` verb, we need to protect
the system better against things like `rpm -Uvh kernel.rpm` because
the RPM-packaged kernel won't understand how to do OSTree right.

In order to make this work of course, we *do* need to remount `/boot`
as writable when we're doing an upgrade that changes the kernel
configuration.  So the strategy is to detect whether it's read-only,
and if so, temporarily mount read-write, then remount read-only when
the upgrade is done.

We can generalize this in the future to also do `/etc` (and possibly
`/sysroot/ostree/` although that gets tricky).

One detail: In order to detect "is this path a mountpoint" is
nontrivial - I looked at copying the systemd code, but the right place
is to use `libmount` anyways.
2016-03-21 12:49:05 -04:00
Alexander Larsson cb60de0f95 Don't fail "ostree remote refs" if writing the summary cache is not permitted
It used to be allowed to run something like "ostree remote refs" on
a read-only (e.g. system) repo. However, the summary cache caused that to
break. This commit just makes it not save the cache if we get some kind
of permission error when writing it. It'll still work, even without the
cache.

https://bugzilla.gnome.org/show_bug.cgi?id=763855
2016-03-18 17:33:39 +01:00
Colin Walters c58ad36840 libglnx porting: gs_transfer_out_value -> g_steal_pointer
It's a bit more verbose but...eh.
2016-03-18 12:08:19 -04:00
Colin Walters b67f5364ac libglnx porting: xattr calls
These are straightforward as the libgsystem versions were already just
equivalent shims.
2016-03-18 12:08:19 -04:00
Colin Walters 684029daa3 libglnx porting: gs_free -> g_autofree
There were surprisingly few uses left.
2016-03-18 12:08:19 -04:00
Colin Walters ac4c298061 libglnx porting: gs_fd_close -> glnx_fd_close
I'd like to eventually kill libgsystem.
2016-03-18 12:08:19 -04:00
Alexander Larsson 89624ee57d rofiles-fuse: Fix permission comparison
We want to allow write if the devinode is in the set,
not the other way around.

https://bugzilla.gnome.org/show_bug.cgi?id=763676
2016-03-16 16:30:53 +01:00
Alexander Larsson 9b919c8dd2 repo: Fix the skip-summary-if-summary.sig-is-same cache
This code was always downloading the summary even for a cache hit due
to a missing else.
2016-03-15 12:04:43 +01:00
Giuseppe Scrivano cff4e48d02 prune: delete all cached summaries files
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-03-15 09:48:47 +01:00
Giuseppe Scrivano 2bf84d7e5d repo: use the skip summary download optimization for repo_remote_fetch_summary
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-03-15 09:48:47 +01:00
Giuseppe Scrivano 58b48424bc pull: cache summary and summary.sig
It allows an optimization to skip the download of the summary file
if its .sig file is unchanged.

Downloading the .sig file is much cheaper than downloading the summary
file from repositories with many branches.

https://bugzilla.gnome.org/show_bug.cgi?id=762973

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-03-15 09:48:47 +01:00
Giuseppe Scrivano a98133072d libotutil: new function ot_openat_ignore_enoent
Refactor some common code

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-03-15 09:48:47 +01:00
Colin Walters fea786cb2d lib: Add ostree_sysroot_load_if_changed() API
This will allow daemons like rpm-ostree to detect if there are any new
deployments efficiently, in combination with using inotify.  If there
are any changes, rpm-ostree wants publish them on DBus.

While we're here, add some changes to start doing unit C testing of
the sysroot API.
2016-03-03 21:56:23 -05:00
Colin Walters fbd9409ebb lib: Add ostree_sysroot_init_osname() API, bump mtime
And change the command line to use it.  rpm-ostree had a copy
of this code, and thus there's a clear reason to have an API.

While we're moving this into API, ensure the mtime on deploy is bumped
after an osname is created, so that daemons like rpm-ostree can notice
changes.  (In reality, creating the directory should do this, but
let's be double sure)
2016-03-03 14:21:57 -05:00
Colin Walters d49718a619 deploy: Bump the mtime on ostree/deploy after deployments finish
This allows other processes (e.g. rpm-ostreed) to monitor for external
changes (e.g. if someone does `ostree admin undeploy`) in a relatively
sane fashion.

Specifically, I'm trying to fix:
https://github.com/projectatomic/rpm-ostree/issues/220
2016-03-03 08:52:42 -05:00
Giuseppe Scrivano 6d73a620e1 refs: Add argument --list to print the full ref name
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-03-02 14:53:14 -05:00
Giuseppe Scrivano 3e3621b7b6 libostree: Adjust `cleanup_ref_prefix` to use ostree_repo_list_refs_ext
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-03-02 14:52:02 -05:00
Giuseppe Scrivano a4be237a2e refs: allow to specify multiple refs as args
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-03-02 14:52:02 -05:00
Giuseppe Scrivano 898c7b6577 ostree-repo: new public function `ostree_repo_list_refs_ext`
It accepts a `flags` argument to control its behavior.  Differently
from `ostree_repo_list_refs`, the `refspec_prefix` is not removed from
the results.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-03-02 14:52:02 -05:00
Colin Walters 5d463ba577 Add a missing #include to fix "make check" 2016-03-02 10:29:41 -05:00
Colin Walters 3efdcb54b7 repo: Add ostree_repo_get_dfd()
I plan to use this in rpm-ostree at least for two reasons:
 - To find the mtime on the repo
 - To use the tmp/ directory to stage content (but we should eventually
   add a better API)
2016-03-01 21:52:22 -05:00
Colin Walters 16979cc5ed lib: Introduce versioned symbols
As rpm-ostree evolves, it keeps driving API additions to libostree.
This creates a relatively tight coupling.

However, if delivering via e.g. RPM, unless one manually remembers to
increment the `Requires:` in the spec file, it's possible for the two
to become desynchronized.

RPM handles versioned symbols and will ensure a dependency if the
application starts using a newer version.

To implement this, switch to `-fvisibility=hidden`, along with an
annotation in the header, and finally add a `.sym` file.

This matches what other projects like systemd and libvirt do.

Although rather than attempting to retroactively version symbols, glom
them all onto the current one.
2016-03-01 21:45:26 -05:00
Giuseppe Scrivano 82d4e7fe68 Fix make syntax-check
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2016-03-01 10:08:25 -05:00
Colin Walters 5345573470 deltas: Add a compression size heuristic for endianness detection
I see when analyzing a delta here that due to byteswapping a negative
compression ratio of 540%, 66%, and 28%.  Let's arbitrarily pick 20%
as a threshold for detecting byetswapping.
2016-02-26 08:19:01 -05:00
Colin Walters 7fdf072710 deltas: Heuristically detect endianness for older deltas
If the average object size is greater than 4GiB, let's assume we're
dealing with opposite endianness.  I'm fairly confident no one is
going to be shipping peta- or exa- byte size ostree deltas, period.
Past the gigabyte scale you really want bittorrent or something.
2016-02-26 08:19:01 -05:00
Colin Walters 04d77da005 deltas: Use endianness marker when parsing
Extend the `static-delta show` and `pull` commands to use the
endianness information (if available).
2016-02-26 08:19:01 -05:00
Colin Walters 277220aaa6 deltas: Include an endianness marker
We screwed up and had delta integers use host endianness.  Start
digging out by at least annotating the endianness.

https://bugzilla.gnome.org/show_bug.cgi?id=762515
2016-02-26 08:19:01 -05:00
Alexander Larsson 6c285d2e4a rofiles-fuse: Handle operations on the root
ENSURE_RELPATH breaks when path is "/". In that case we need
to return "." instead of "".

https://bugzilla.gnome.org/show_bug.cgi?id=762596
2016-02-24 20:43:23 +01:00
Alexander Larsson 1833142b14 deltas: Fix regression in ostree_repo_static_delta_execute_offline
xdg-app passed this a filename directly, and in this case it should be
used as is. This regressed to always look for "superblock" in the same
directory as the passed in filename.

https://bugzilla.gnome.org/show_bug.cgi?id=762617
2016-02-24 15:54:09 +01:00
Colin Walters ed7266b10a deltas: Fix some more 32 bit warnings 2016-02-22 22:07:02 -05:00
Colin Walters 61b4f26862 lib: Two more compiler warning fixes 2016-02-22 21:11:10 -05:00
Colin Walters 88ae6f1b9e libarchive: Fix a 32 bit format warning
This is actually an error by default with our default CFLAGS.
2016-02-22 20:52:33 -05:00
Colin Walters f461c02bb5 gpg: Use gpg_strerror_r for threadsafety
These APIs are rather painful...this is why GError exists.
2016-02-22 18:07:30 -05:00
Colin Walters 30c5fb1a51 libarchive: Make autocreate_parents imply autocreating root dir
Some Docker layers are just metadata in the `layer.json`.  If one is
mapping Docker layers to OSTree commits, one needs to create a dummy
root directory, because OSTree doesn't support metadata-only commits.

Let's just push that logic down here because it's easier than special
casing it in higher levels.
2016-02-22 17:02:31 -05:00
Colin Walters 11b3050fd7 docs: Add a new formats section, move static deltas in there
The `src/libostree/README-deltas.md` was rather hidden - let's move
this into the manual.
2016-02-22 14:06:20 -05:00
Colin Walters 4beb5f4eaf pull: Add a --dry-run option for static deltas
One of the design goals with deltas was not just wire efficiency,
but also having all the data up front about how much data would
be transferred before starting.

Let's expose that better by adding a `dry-run` option to the pull API.
This requires static deltas to be useful.  Basically we simply call
the progress callback once with the data from the superblock.
2016-02-19 15:21:13 -05:00
Colin Walters f2c5ecb996 pull: Add require-static-deltas pull option
For a production release repository, most OS vendors would want
to just always use static deltas.  Add the ability for the pulls to
require it.

(I think I'll also add a summary key for this actually in addition,
 so the repo manager can force it too)
2016-02-19 15:21:13 -05:00
Jonathan Lebon eba7df0da9 ostree-sysroot: add debug option to help testing
If ostree is run in a test setup where it operates as root in a tmp
directory, it might cause issues to flag the deployments as immutable.
The test harness might simply be doing an `rm -rf` (effectively the case
for gnome-desktop-testing-runner), which will then fail.

We add a new debug option to the ostree_sysroot object using GLib's
GDebugKey functionality to allow our tests to communicate to ostree that
we don't want immutable deployments.
2016-02-19 11:58:08 -05:00
Colin Walters 3a555114bc repo: Add ostree_repo_import_archive_to_mtree
This is a more flexible version of the previous
ostree_repo_write_archive_to_mtree() which took a file reference.
This has an extensible options structure, and in particular
now supports `ignore_unsupported_content`.

I plan to use this for importing Docker images which contain device
nodes.  (There's no reason for container images to have those, so
we'll just ignore them).

Also here, just like the export variant, the caller is responsible for
setting up libarchive.
2016-02-19 08:54:04 -05:00
Colin Walters b08b1abccd Rename libarchive write API to "export", matching command line
I was going to add new API for importing, and it was really confusing
that what I think of now as import and export both had "write" in the
name.  It's just clearer to talk about the direction.

At the same time, include `Export` in the options structure.

This isn't an ABI break as the API isn't in a release.
2016-02-19 08:54:04 -05:00
Colin Walters d3eee15f84 rofiles-fuse: Fix truncate call to not use O_CREAT
I was getting a compilation error with the GCC hardening flags which
look for a missing mode with `O_CREAT`.  The right fix here is to drop
`O_CREAT`, as truncate() should throw `ENOENT` if the file doesn't
exist.
2016-02-17 11:06:53 -05:00
Colin Walters baaf7450da Support Docker-style whiteouts
This is to enable importing Docker layers as ostree commits, then
checking them out in a union.

The prototype work for this is in:
https://github.com/cgwalters/dlayer-ostree

Though it will likely ultimately end up in:
https://github.com/projectatomic/atomic
2016-02-16 10:54:59 -05:00
Colin Walters 42c60effbe pull: Support specifying exact commit to pull via branch@commit
I don't know why we didn't do this a long time ago.  This extends the
pull API to allow grabbing a specific commit, and will set the branch
to it.  There's some support for this in the deploy engine, but there
are a lot of reasons to support it for raw pulls (such as subset
mirroring cases).

In fact I'm thinking we should also have the override-version logic
here too.

NOTE: One thing I debated here is inventing a new syntax on the
command line.  Git doesn't seem to have this functionality (probably
because it'd be rarely used). The '@' character at least doesn't
conflict with anything.

Anyways, I wanted this for some other test cases.  Without this,
writing tests that go between different commits is more awkward as one
must generate the content in one repo, then pull downstream, then
generate more content, then pull again.  But now I can just keep track
of commit IDs and do exactly what I want without synchronizing the
tests.
2016-02-14 10:12:26 -05:00
Colin Walters 355f8438ef Add an `export` builtin, and API to write to libarchive
At the moment I'm looking at using rpm-ostree to manage RPM inputs
which can then be converted into Docker images.  It's most convenient
if we can stream directly out of libostree rather than doing a
checkout + tar combination.

There are also backup/debugging etc. reasons to implement `export` as
well.
2016-02-14 09:53:01 -05:00
Colin Walters e9ccdd2d00 Import rofiles-fuse
While it's not strictly tied to OSTree, let's move
https://github.com/cgwalters/rofiles-fuse in here because:

 - It's *very* useful in concert with OSTree
 - It's tiny
 - We can reuse OSTree's test, documentation, etc. infrastructure

One thing to consider also is that at some point we could experiment
with writing a FUSE filesystem for OSTree.  This could internalize a
better equivalent of `--link-checkout-speedup`, but on the other hand,
the cost of walking filesystem trees for these types of operations is
really quite small.

But if we did decide to do more FUSE things in OSTree, this is a step
towards that too.
2016-02-10 13:11:25 +01:00
Matthew Barnes 5adafd7674 fetcher: Fix hung GTlsInteraction
The GTlsInteraction instance must be created in the session thread
so it uses the correct GMainContext.
2016-02-09 00:58:17 +00:00
Colin Walters 0481389afd lib: Expand `ostree static-delta show` to show part stats
Now we display stats on the individual parts, such as the blob size
and the number of each type of opcode.  Most interesting to me is
things like how many bsdiff opcodes there are vs new objects, etc.
2016-02-08 14:46:13 +01:00
Colin Walters 56fc249d08 lib: Create an internal static delta parsing/opening function
We had code to deal with opening/checksumming/decompressing static
deltas in a few places.  I'd like to teach `ostree static-delta show`
how to display more information, and this will allow it to just use
`_ostree_static_delta_part_open()` too.
2016-02-08 14:46:13 +01:00
Colin Walters 8702ec7b3e build: Remove --disable-static-deltas option
I'm confident now we can declare them stable.
2016-02-08 14:46:13 +01:00