Commit Graph

3776 Commits

Author SHA1 Message Date
Colin Walters aec1191fa9 deltas: Add an if0'd bit to print bsdiff objects
I used this to find the bsdiff'd objects.

Closes: #1314
Approved by: jlebon
2017-11-01 17:38:26 +00:00
Colin Walters e885d029aa bin/delta-compilation: Add a "progress bar" for bsdiff generation
It's the slowest part, let's show admins something. This "update every 10%" code
was copied from the fsck command; obviously a better approach would be "progress
every N seconds" but doing that somewhat accurately requires making things
async; not worth it here yet.

Closes: #1314
Approved by: jlebon
2017-11-01 17:38:26 +00:00
Colin Walters 62445166fc lib/pull: Delete unused "exampleos" code
We never ended up using this, and I'm going to revisit this in another patch
with a different approach that has useful *content* and not just a lot of files.

Closes: #1314
Approved by: jlebon
2017-11-01 17:38:26 +00:00
Colin Walters 80ff73ba26 lib/pull: When --require-static-deltas, use them even for file:/// repos
I didn't fully spelunk this, but from what `static-delta-generate-crosscheck.sh`
had, we appeared to be doing this before, and it's clearly useful for local
testing rather than needing to spin up a HTTP server.

Closes: #1313
Approved by: jlebon
2017-10-31 14:20:20 +00:00
Colin Walters 7f8ff5756e lib: Minor static delta fixes
First, the manual crosscheck script bitrotted; it got caught up
in the "use libtest repo creation wrapper" bit, and also it
seems like at some point `pull --require-static-deltas` changed
meaning when dealing with `file:///` repos.  I have more work to
unwind that.

Next, I'm seeing a delta failure which looks like a static delta
miscompilation with rollsums; change the compiler to print out
the source object too, which helped me debug this.

And finally in the processing code, fix incorrect error prefixing, which was
misleading.

Closes: #1311
Approved by: ashcrow
2017-10-30 22:52:02 +00:00
Colin Walters 0d259ac401 lib/deltas: Fix change to use pread() in write opcode
Fixes: 93457071cb "lib/deltas: Use pread() instead of lseek()+read()"

Caught this when trying to test alex's patch locally. I am going to review our
static delta pulls and try to get something more comprehensive locally. But in
the meantime this patch is clearly right.

Closes: #1312
Approved by: jlebon
2017-10-30 19:03:16 +00:00
Alexander Larsson de0e015908 static deltas: Process each part as soon as its done
Directly when we allocate a new part we finish the old one,
writing the compressed data to a temporary file and generating
the delta header for it.

When all these are done we loop over them and collect the headers,
sizes and either copy the tempfile data into the inlined superblock
or link the tempfiles to disk with the proper names.

Closes: #1309
Approved by: cgwalters
2017-10-27 21:49:26 +00:00
Alexander Larsson cbbd159a5d static-delta-compilation: Move some things around
We will do some changes later that need these earliers, so move them up.

Closes: #1309
Approved by: cgwalters
2017-10-27 21:49:26 +00:00
Alexander Larsson 74a5df7bd7 static deltas: Use OtVariantBuilder to create deltas
This allows us to create the final delta desciptor directly on disk
rather than having it all in memory. This is nice because it can
become quite large if inlined parts are used.

Note however, that we currently generate all the delta parts in
memory before adding them to the delta, so we still keep all individual
parts in memory. Fixing that is the next step.

Closes: #1309
Approved by: cgwalters
2017-10-27 21:49:26 +00:00
Alexander Larsson 72bb1a6b17 Add OtVariantBuilder
This is similar to GVariantBuilder in that it constructs variant
containers, but it writes it directly to a file descriptor rather
than keep the entier thing in memory. This is useful to create large
variants without using a lot of memory.

Closes: #1309
Approved by: cgwalters
2017-10-27 21:49:26 +00:00
Simon McVittie 74e00d32be ostree-system-generator: Include <libglnx.h> for autocleanups
g_autoptr was new in GLib 2.44, but we officially only require 2.40,
so we need to use the backport in libglnx.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #1310
Approved by: cgwalters
2017-10-27 18:54:11 +00:00
Colin Walters 90ebd48f6a lib/repo: Fix loading commitstate with parent repos
This makes the code nicer too. Properly unit testing this though really wants
like a whole set of stuff around parent repos...but we do have coverage of the
non-parent path in the current pull tests.

Closes: https://github.com/ostreedev/ostree/issues/1306

Closes: #1308
Approved by: alexlarsson
2017-10-26 07:06:50 +00:00
Philip Withnall 0760ce1281 lib/repo-finder-mount: Ignore mounts which have a ‘system’ file system
For example, tmpfs or a cgroup file system. This is basically an
optimisation of the list of file systems we check for repositories,
since we would never expect any of these file systems to be capable of
containing a repository.

Depends on the new API from
https://bugzilla.gnome.org/show_bug.cgi?id=788927.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1307
Approved by: cgwalters
2017-10-26 01:34:14 +00:00
Colin Walters d76840d0c1 tree-wide: Use autoptr for OstreeKernelArgs
Much nicer looking.  Prep for more cleanup from
https://github.com/projectatomic/rpm-ostree/pull/1013

Closes: #1302
Approved by: peterbaouoft
2017-10-25 01:48:56 +00:00
Dan Nicholson 63ce86d597 lib/repo: Properly handle NULL homedir when signing commit
Without this, ostree_repo_sign_commit throws a critical message when no
homedir is provided:

(ostree gpg-sign:5034): GLib-GIO-CRITICAL **: g_file_new_for_path: assertion 'path != NULL' failed

Closes: #1305
Approved by: cgwalters
2017-10-24 19:58:07 +00:00
Philip Withnall 886a5d7928 lib/repo-finder-mount: Fix propagating NULL errors
These two code paths tried to propagate errors which had never been set.
Set new errors instead.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1303
Approved by: cgwalters
2017-10-24 16:59:54 +00:00
Colin Walters b11d1aa3f2 ci: Update centos container to current again
Repo sync issue should be cleared now, and for some reason the previous
container is already GC'd.

Closes: #1304
Approved by: peterbaouoft
2017-10-24 14:59:21 +00:00
Philip Withnall 90680e1b29 lib/repo-finder-avahi: Fix memory corruption of a GVariantIter
A GVariantIter* was being passed to a GVariant format string varargs,
rather than a GVariantIter**. This resulted in memory corruption.

So we can continue to reuse ref_map throughout the function, make it a
GVariantIter* rather than a stack-allocated GVariantIter.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1301
Approved by: cgwalters
2017-10-24 12:55:24 +00:00
Colin Walters ed15723cd1 lib/commit: Fix hardlink checkout commit with bare-user + mod xattrs
This is more subtle fallout from:
https://github.com/ostreedev/ostree/pull/1170
AKA commit: 8fe4536257

Before, if we found a devino cache hit, we'd use it unconditionally.

Recall that `bare-user` repositories are very special in that they're the only
mode where the on disk state ("physical state") is not the "real" state. The
latter is stored in the `user.ostreemeta` xattr. (`bare-user` repos are also
highly special in that symlinks are regular files physically, but that's not
immediately relevant here).

Since we now have `bare-user-only` for the "pure unprivileged container" case,
`bare-user` should just be used for "OS builds" which have nonzero uids (and
possibly SELinux labels etc.)

In an experimental tool I'm writing "skopeo2ostree" which imports OCI images
into refs, then squashes them together into a single final commit, we lost the
the `81` group ID for `/usr/libexec/dbus-1/dbus-daemon-launch-helper`.

This happened because the commit code was loading the "physical" disk state,
where the uid/gid are zero because that's the uid I happened to be using. We
didn't just directly do the link speedup because I was using `--selinux-policy`
which caused the xattrs to change, which caused us to re-commit objects from the
physical state.

The unit test I added actually doesn't quite trigger this, but I left
it because "why not".  Really testing this requires the installed test
which uses SELinux policy from `/`.

The behavior without this fix looks like:

```
-00755 0 0     12 { [(b'user.ostreemeta', [byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x81, 0xed]), (b'security.selinux', b'system_u:object_r:lib_t:s0')] } /usr/lib/dbus-daemon-helper
```

which was obviously totally broken - we shouldn't be picking up the
`user.ostreemeta` xattr and actually committing it of course.

Closes: #1297
Approved by: jlebon
2017-10-23 17:02:28 +00:00
Philip Withnall 4c0f67be0c lib/sysroot: Expand docs for ostree_sysroot_get_repo()
Add some missing annotations and clarify that it always returns an open
repository on success.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1300
Approved by: cgwalters
2017-10-23 16:17:20 +00:00
Colin Walters 795a953a36 core: Add standard SOURCE_TITLE metadata key
This is a freeform string useful to track/display when a commit is "derived"
from some other format.  For example, in the rpm-ostree test we make a
`vmcheck` ref that conceptually overlays the default ref like
`fedora-atomic:fedora/26/x86_64/atomic-host`.

My current patch sets the source title to e.g.
"Dev overlay on fedora-atomic:fedora/26/x86_64/atomic-host".

Another case I'm working on now is importing OCI images to use
as host images.  For that case, the source title is
With this patch we could then set the original OCI image name + tag
as the source name, like:
"oci:cgwalters/demo-custom-fedora-atomic-host:26".

Closes: #1296
Approved by: jlebon
2017-10-23 14:19:41 +00:00
Colin Walters 0e0fe85922 bin/status: Inline metadata parsing for versions
Pull out the commit metadata explicitly; still just rendering the version, but
this is prep for rendering other metadata keys.

Closes: #1296
Approved by: jlebon
2017-10-23 14:19:41 +00:00
Colin Walters 32357cef4d bin/status: Port to new style
No functional changes; prep for more work.

Closes: #1296
Approved by: jlebon
2017-10-23 14:19:41 +00:00
Colin Walters 4cda9f14fb docs/related-projects: Add Google Usenix link
Closes: https://github.com/ostreedev/ostree/issues/1284

Closes: #1299
Approved by: cgwalters
2017-10-21 14:12:02 +00:00
Colin Walters 1222c2271b repo: Add wrapper function for setting devino cache on checkout opts
I was trying to use this with pygobject for an OCI+ostree project, and pygobject
rejected simply assigning to the field (understandably, since it can't bind the
lifetime together).

Add a wrapper function, which is still unsafe, but hides that unsafety
where most people shouldn't find it.  And if they do...well, sorry,
Rust wasn't invented when ostree was started.

Closes: #1295
Approved by: pwithnall
2017-10-20 18:20:19 +00:00
Colin Walters b8251d26bd lib/checkout: For "process whiteouts" mode, replace directories too
I'm playing around with some ostree ⇔ OCI/Docker bits, and ran
into this while importing an OCI image that built from the Fedora
base image where `/home` is a regular directory, and I added a layer
that did the ostree bits of moving it to `/var` and leaving a symlink.

OCI/Docker supports this.  Now since "process whiteouts" is really the
"enable OCI/Docker" mode, let's only replace dirs if that's enabled.
This leaves the `UNION_FILES` targeted for its original use case
which is unioning components/packages.  (Although that use case itself
is now a bit superceded by `UNION_IDENTICAL`, but eh).

Closes: #1294
Approved by: jlebon
2017-10-20 13:20:27 +00:00
Ruixin Bao 9166605e5a ostree: provide command description in a better place
This is similar idea as
5c0bf88915,

The duplicated description is now removed, and the description
of the command is now displayed beneath the Usage.

For example:
ostree cat -h will output the following:

"Usage:
  ostree cat [OPTION?] COMMIT PATH...

Concatenate contents of files"

Closes: #1267
Approved by: cgwalters
2017-10-20 12:59:33 +00:00
Ruixin Bao 298c151fd8 ostree: move flags into command struct, pass down through builtins
This is a similar approach as
12c34bb249.

One thing to note is when we parse the admin related functions,
we still keep the old admin related flags, and added a new parameter
to represent the command struct.

This allows us to identify the caller of the function, making it
easier for us to possibly deduplicate the subcommand handling in
the future. A similar approach is done in rpm-ostree:
83aeb018c1

This also makes it easier for us to change the prototype of the function.
If we want to add something new in the future, we won't need to touch every prototype.

Closes: #1267
Approved by: cgwalters
2017-10-20 12:59:33 +00:00
Ruixin Bao 3c360a720f ostree: Describe subcommands in help output
Added a description argument to all type
of commands. Now when we include -h or --help
for commands that contain subcommands, the description
for those subcommands are shown.

The added subcommands help will be provided to the following commands:
- ostree -h
- ostree admin -h
- ostree admin instutil -h
- ostree remote -h
- ostree static-delta -h

Closes: #1267
Approved by: cgwalters
2017-10-20 12:59:32 +00:00
Philip Withnall 2531d8fe63 lib/repo-finder: Add OstreeRepoFinderOverride
This is another OstreeRepoFinder implementation; it returns results from
a given set of URIs. It’s designed to be used for implementing user
overrides to other repo-finders, or for implementing unit tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1281
Approved by: mwleeds
2017-10-19 19:11:58 +00:00
Philip Withnall a1f020ffa4 lib/repo-finder-avahi: Fix a leak in a GVariantIter loop
Use g_variant_iter_loop() rather than next(), since it automatically
handles freeing the child memory each iteration. Previously, we leaked
it for all but the last iteration.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1293
Approved by: cgwalters
2017-10-19 13:16:59 +00:00
Colin Walters e466e482b1 Disallow refs starting with a non-letter or digit
Change the regexp for validating refs to require at least one letter or digit
before allowing the other special chars in the set `[.-_]`. Names that start
with `.` are traditionally Unix hidden files; let's ignore them under the
assumption they're metadata for some other tool, and we don't want to
potentially conflict with the special `.` and `..` Unix directory entries.
Further, names starting with `-` are problematic for Unix cmdline option
processing; there's no good reason to support that. Finally, disallow `_` just
on general principle - it's simpler to say that ref identifiers must start with
a letter or digit.

We also ignore any existing files (that might be previously created refs) that
start with `.` in the `refs/` directory - there's a Red Hat tool for content
management that injects `.rsync` files, which is why this patch was first
written.

V1: Update to ban all refs starting with a non-letter/digit, and
    also add another call to `ostree_validate_rev` in the pull
    code.

Closes: https://github.com/ostreedev/ostree/issues/1285

Closes: #1286
Approved by: jlebon
2017-10-18 20:55:43 +00:00
Dan Nicholson 3f3d3d64ac build: Do *.am.inc substitutions from make correctly
The string needs to be escaped with a $ since we want to replace the
literal string $(path). Without this make will run the command with the
value of the variable, which won't match anything in the input Makefile
stub.

Closes: #1291
Approved by: smcv
2017-10-18 16:53:29 +00:00
Jonathan Lebon 18b85fa8bd lib/commit: fix checking flag with bitwise OR
Caught by Coverity.

Coverity CID: 1458339

Closes: #1290
Approved by: cgwalters
2017-10-18 14:27:20 +00:00
Colin Walters a2f8315eae lib/commit: (refactor) Clean up delta bare write API
The way `_ostree_repo_open_content_bare()` did both looking for the object and
possibly creating a new fd was just weird and inconsistent with e.g. the pull
code where we always call `has_object()` first.

Just call `has_object()` in the delta paths that used this too, making the
implementation right now a thin wrapper around
`glnx_open_tmpfile_linkable_at()`, but this is prep for a later patch which does
more.

Closes: #1283
Approved by: jlebon
2017-10-18 14:07:55 +00:00
Colin Walters 40a0b9fb73 lib/repo: Update summary code to use newer hashing API
And drop the unnecessary wrapper.

Closes: #1287
Approved by: jlebon
2017-10-18 13:27:11 +00:00
Colin Walters de5f781089 lib/pull: Update summary checksum code to use new checksum API
This is another case where making an input stream out of a memory buffer is a
bit silly; just hash the `GBytes` directly.

Closes: #1287
Approved by: jlebon
2017-10-18 13:27:11 +00:00
Marcus Folkesson 075e676eb6 docs: mention the $OSTREE_REPO environment variable
$OSTREE_REPO may be set to override the default location
of the repository.

Link: https://mail.gnome.org/archives/ostree-list/2017-October/msg00003.html

Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>

Closes: #1282
Approved by: cgwalters
2017-10-18 00:56:36 +00:00
Colin Walters 9955695da3 syntax-check: Add a rule to enforce glnx_autofd over glnx_fd_close
And fix the one final use.

Closes: #1280
Approved by: jlebon
2017-10-17 16:43:02 +00:00
Colin Walters 3577b4a6c6 lib/commit: Use direct fd xattr operations again on regular files
A side effect of commit 8fe4536257 is that
we started listing all xattrs even for files with device/inode matches;
further, we did that using the dfd/name which means we went through
the `/proc` path, which is slower and uglier.

Noticed this in strace while looking at adoption code.

Closes: #1280
Approved by: jlebon
2017-10-17 16:43:02 +00:00
Colin Walters eeabd4baf7 lib/commit: Fix indentation in file commit code
No functional changes; the indentation was off here and it was
confusing me working on another patch.

Closes: #1280
Approved by: jlebon
2017-10-17 16:43:02 +00:00
Colin Walters bc7ff2cd1d lib/commit: Avoid trying to delete `.` with _CONSUME flag
This helps port rpm-ostree.

Closes: #1278
Approved by: jlebon
2017-10-17 16:24:13 +00:00
Colin Walters 93457071cb lib/deltas: Use pread() instead of lseek()+read()
That's why the syscall was invented, so let's use it. Just noticed while reading
the code while working on another patch.

Closes: #1270
Approved by: jlebon
2017-10-17 15:20:08 +00:00
Colin Walters bb05b187b6 lib/deltas: Use fastpath for regfile writes for bare-user-only
Noticed this omission while looking at the code while working on another patch.

Closes: #1270
Approved by: jlebon
2017-10-17 15:20:08 +00:00
Colin Walters 95afe2848d tests: Add test-pull-bareuseronly
I was going to fix a bug in the static deltas code and I noticed
we were missing `pull-test.sh` coverage for bareuseronly 🙈.

Obviously fixing this requires duplicating some of the bits we have in
`basic-test.sh`; need to hoist that into `libtest.sh`. For now though let's get
the coverage.

Closes: #1270
Approved by: jlebon
2017-10-17 15:20:08 +00:00
Colin Walters 464965e6b4 lib/sysroot: Fix error handling when mounting overlayfs fails
This isn't perfect, but at least we fix an error-overwrite error, and in
practice `ostree admin unlock` isn't wrapped by `rpm-ostree` yet, so spew to
stderr is OK.

Closes: https://github.com/ostreedev/ostree/issues/1273

Closes: #1279
Approved by: guyshapiro
2017-10-17 06:58:22 +00:00
Colin Walters e744f2ad6f lib: Use a common helper function to compare checksums
So we get a consistent error message; came up in a PR review.

Closes: #1277
Approved by: jlebon
2017-10-17 05:06:07 +00:00
Colin Walters 16c31a9b58 lib/commit: Implement "adoption" with CONSUME flag
For checkouts that are on the same device, for regular files we can simply
"adopt" existing files. This is useful in the "build from subtrees" pattern that
happens with e.g. `rpm-ostree install` as well as flatpak and gnome-continuous.

New files are things like an updated `ldconfig` cache, etc. And particularly for
`rpm-ostree` we always regenerate the rpmdb, which for e.g. this workstation is
`61MB`.

We probably should have done this from the start, and instead had a `--copy`
flag to commit, but obviously we have to be backwards compatible.

There's more to do here - the biggest gap is probably for `bare-user` repos,
which are often used with things like `rpm-ostree compose tree` for host
systems. But we can do that later.

Closes: #1272
Approved by: jlebon
2017-10-16 18:22:09 +00:00
Colin Walters 729790bedc tests/basic: Add missing ${COMMIT_ARGS} for bare-user-only
I was working on "adopt" and hit corruption; turns out we were missing the
`--canonical-permissions` arg in this existing test.

(Need to abstract all of this more)

Closes: #1272
Approved by: jlebon
2017-10-16 18:22:09 +00:00
Dan Nicholson 9b3e01be30 build: Fix bsdiff Makefile circular dependency
The intended use was to have the .am.inc generated from the .am like the
libglnx one. Without this, make was detecting a circular dependency and
dropping the rule:

  make: Circular bsdiff/Makefile-bsdiff.am.inc <- bsdiff/Makefile-bsdiff.am.inc dependency dropped.

Closes: #1276
Approved by: jlebon
2017-10-16 16:40:11 +00:00