Commit Graph

3146 Commits

Author SHA1 Message Date
Colin Walters
94948e3522 checkout: Support a "pure addition" mode
I plan to use this for `rpm-ostree livefs`.
https://github.com/projectatomic/rpm-ostree/issues/639

Closes: #714
Approved by: jlebon
2017-03-06 20:58:04 +00:00
Colin Walters
ff34810097 repo/checkout: Verify early if src/destination are on same device
At least in all Linux kernels up to today, one can never `link()` across
devices, so we might as well verify that up front. This will help for a future
patch to add a new type of union-add checkout, since Linux checks for `EEXIST`
before `EXDEV`.

Closes: #714
Approved by: jlebon
2017-03-06 20:58:04 +00:00
Colin Walters
3219a5d0ee Allow and start using C99 declaration-after-statement
I've seen code in a few places that I think on balance is definitely better this
way.  Some of our functions have huge variable declaration sections.
This change includes one small example where we could start using declarations
after statements.

A concern I had was - how does this interact with `__attribute__((cleanup))` and
early returns? I tested it, and AFAICS the behavior is what you'd expect - the
cleanup function isn't called if its variable isn't reachable.

Closes: #718
Approved by: jlebon
2017-03-06 18:33:50 +00:00
Philip Withnall
574c3ea6f9 libostree: Allow compression level to be set for archive-z2 stream
Add a ostree_raw_file_to_archive_z2_stream_with_options() variant of
ostree_raw_file_to_archive_z2_stream(), to allow a compression-level
option to be passed in and passed through to zlib.

This is useful when building archive-z2 files on the fly for
transmission over a non-bandwidth-limited channel, such as a local
network. In this case, CPU time is more valuable than bandwidth, so we
want a low compression level.

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

Closes: #721
Approved by: cgwalters
2017-03-06 18:19:45 +00:00
Colin Walters
72336f1c48 fetcher/curl: Fix leaks caught by ASAN
I had to rebuild `glib` with `-fsanitize=address` in order to get a stack trace
to finally get this one.  However, *installing* that glib "system wide"
in my container breaks everything (including `rpm-ostree`, `dnf`, `pkg-config` etc.)
that wasn't built with ASAN.

So my test scenario right now is to extract the libs and do e.g.:
```
make && env LD_LIBRARY_PATH=$HOME/src/distgit/fedora/glib2/asan-libs make check TESTS=tests/test-basic.sh
```

Closes: #719
Approved by: jlebon
2017-03-06 17:30:19 +00:00
Philip Withnall
f667a82fc1 build: Fix disabling --enable-man if xsltproc is not available
If --enable-man=maybe (the default), and xsltproc is not available, the
configuration code would check for it, correctly set enable_man=no, then
incorrectly overwrite that with enable_man=yes, which would result in
later trying to execute $(XSLTPROC) when it’s empty.

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

Closes: #720
Approved by: cgwalters
2017-03-06 13:48:17 +00:00
Colin Walters
a787e0c072 pull: Use all available commits for delta sources
The previous logic for static deltas was to use as a FROM
revision the current branch tip.  However, we want
to support deltas between branches in an automatic
fashion.

If a summary file is available, we already have an
enumerated list of deltas - so the logic introduced
here is to search it, and find the newest commit
we have locally that matches the TO revision target.

This builds on some thoughts from
https://github.com/ostreedev/ostree/pull/151#issuecomment-232390232

Closes: https://github.com/ostreedev/ostree/pull/151

Closes: #710
Approved by: giuseppe
2017-03-04 10:11:14 +00:00
Colin Walters
b41f150a72 grub2: Use "linux16" only on x86/x86_64
Got a report that a Fedora Atomic Host built for ppc64le didn't work with the
`linux16`, it needed `linux`. See the comments for more links.

Closes: #716
Approved by: vathpela
2017-03-03 15:36:36 +00:00
Jonathan Lebon
c4f6522829 libglnx: bump for -Wmaybe-uninitialized fix
https://github.com/GNOME/libglnx/pull/37

Closes: #715
Approved by: cgwalters
2017-03-02 20:35:24 +00:00
Jonathan Lebon
199646ccfa pull: don't use static deltas if archive repo
In https://github.com/ostreedev/ostree/pull/408, we disabled the use of
static deltas when mirroring. Later,
https://github.com/ostreedev/ostree/pull/506 loosened this up again so
that we could use static deltas when mirroring into bare{-user} repos.

However, the issue which originally spurrred #408 is even more generic
than that: we want to avoid static deltas for any archive repo, not just
when doing a mirror pull. This patch tightens this up, and also
relocates the decision code to make it easier to read.

Closes: #715
Approved by: cgwalters
2017-03-02 20:35:24 +00:00
Gatis Paeglis
64422a7d0b deltas: Expose the filename parameter
The C API (ostree_repo_static_delta_generate) knows what to do
with it, but this parameter was never exposed via command line
tool.

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

Closes: #703
Approved by: jlebon
2017-02-27 22:10:26 +00:00
Colin Walters
9695c47684 grub2: Use g_spawn_sync() rather than GSubprocess to avoid SIGCHLD
Due to the async nature of `GSubprocess` it grabs `SIGCHLD` which
affects other software which might be using libostree, such as
QtOTA.

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

Closes: #702
Approved by: jlebon
2017-02-27 21:55:17 +00:00
Colin Walters
36b28cb4d2 upgrade: Add support for --pull-only and --deploy-only
This makes it easier to script downloading updates in the background,
and only do deployments just before rebooting.

Partially addresses https://github.com/ostreedev/ostree/issues/640

Closes: #642
Approved by: jlebon
2017-02-27 20:57:23 +00:00
Colin Walters
2c326d705e fetcher: Log failures into journal
Particularly when HTTP requests fail, I really want a lot more information.
We could theoretically stuff it into the `GError` message field, but
that gets ugly *fast*.

Using the systemd journal allows us to log things in a structured fashion.
Right now e.g. rpm-ostree won't be aware of this additional information,
but I think we could teach it to be down the line.

In the short term, users can learn to find it from `systemctl status rpm-ostreed`
or `journalctl -b -r -u rpm-ostreed`, etc.

One thing I'd like to do next is log successful fetches of e.g. commit objects
as well with more information about the originating server (things like the
final URL if we were redirected, did we use TLS pinning, what was the negotiated
TLS version+cipher, etc).

Closes: #708
Approved by: jlebon
2017-02-24 22:30:24 +00:00
Colin Walters
cee57a0268 deploy/libmount: Fix build with old util-linux 2.23 (CentOS7)
https://github.com/ostreedev/ostree/pull/705 broke the build
on CentOS 7 which only has util-linux 2.23.

When I was thinking about this, I realized that there must really be a way to
make this safe even for older versions. Looking at that version of util-linux,
all we need to do is invert the order of frees so we `mnt_free_table()` *before*
`mnt_free_cache()`, like util-linux does:

https://github.com/karelzak/util-linux/blob/stable/v2.23/sys-utils/eject.c#L1131

We still use the `_unref()` versions if available.  I also fixed
the ordering there too for double plus redundant safety.

Closes: #712
Approved by: jlebon
2017-02-24 17:24:15 +00:00
Colin Walters
877a27da0f tree-wide: Squash noncritical compiler warnings
Should fix everything from
<https://kojipkgs.fedoraproject.org//packages/ostree/2017.2/3.fc25/data/logs/x86_64/build.log>

Anything that uses autocleanups should *always* be initialized directly I think,
even if a few lines down we directly assign, since this way it's more robust
against refactoring.

And the `freopen()` warnings are right - IMO we should *always* check return
values.

Closes: #711
Approved by: jlebon
2017-02-24 17:08:27 +00:00
Colin Walters
a71d550860 man/repo-config: Document mirrorlist
We should get more strict about docs. Add some text about `contenturl` and
mirrorlists.

Closes: #709
Approved by: jlebon
2017-02-24 14:39:35 +00:00
Colin Walters
0817be61a1 deploy: Correctly use libmount unref() calls rather than free()
We saw a random ostree SEGV start popping up in our CI environment:
https://github.com/projectatomic/rpm-ostree/pull/641#issuecomment-281870424

Looking at this code more and comparing it to what util-linux does, I noticed we
had a write-after-free, since `mnt_unref_table()` will invoke
`mnt_unref_cache()` on its cache, and that function does:

```
	if (cache) {
		cache->rfcount--;
```

unconditionally.

Fix this by using `unref()`.

Closes: #705
Approved by: jlebon
2017-02-23 15:31:25 +00:00
Colin Walters
09b392675a main: Make ostree --version output YAML (and add gitrev)
I learned today that `docker version` does this and I really like
the idea.  While we have the patient open, also add the gitrev
with code taken from https://github.com/projectatomic/rpm-ostree/pull/584

Closes: #691
Approved by: giuseppe
2017-02-22 18:57:18 +00:00
Colin Walters
3ec509c89b build: Add --with-smack, use it to reset contexts for writing objects
At some point we'll want to follow what systemd is doing and add
better support for smack, along the lines of `OstreeSePolicy`.  However,
short term this patch fixes AGL which uses Smack.

See: https://jira.automotivelinux.org/browse/SPEC-386
See: https://github.com/ostreedev/ostree/pull/698

Closes: #698
Approved by: OYTIS
2017-02-22 14:37:19 +00:00
Colin Walters
515f832067 ci: Hard error on all -fsanitize=undefined warnings
I saw in a recent test log a ton of spam
```
libglnx/glnx-dirfd.c:253:3: runtime error: null pointer passed as argument 1, which is declared to never be null
```
which actually turned out to be libglnx getting reverted.  But
let's be sure now we actually bomb out quickly on UBSAN warnings
in general.

Closes: #693
Approved by: jlebon
2017-02-21 16:59:19 +00:00
Colin Walters
6d7e85bb38 libglnx: Re-bump to master due to accidental reversion
Commit a1805d6101 reverted
this unintentionally.

We should have some CI check that requires a commit message has
something like "libglnx bump" or something?

Closes: #693
Approved by: jlebon
2017-02-21 16:59:19 +00:00
Colin Walters
7d7ab92a05 README.md: Add more/clean up links to consuming projects
Add meta-updater and QtOTA, and delete OpenEmbedded since it's implied by the
first two. Merge rpm-ostree + Atomic Host since they're close. Clarify
gnome-continuous a bit.

Closes: #700
Approved by: jlebon
2017-02-21 16:34:14 +00:00
Colin Walters
f02dcc4997 libtest: Re-enable quiet mode for building fs tree
I think I commented this out while debugging something, and forgot to re-enable
it. Reading the log files should be a better again after this.

Closes: #699
Approved by: giuseppe
2017-02-21 15:35:23 +00:00
Colin Walters
c9356a50b8 lib: Ensure an error is set in ensure_unlinked() if errno != ENOENT
We hit this with:
```
27411 unlink("/boot/efi/EFI/fedora/grub.cfg.new") = -1 EROFS (Read-only file system)
```
from the grub2 code.

https://github.com/projectatomic/rpm-ostree/issues/633

Closes: #694
Approved by: giuseppe
2017-02-20 14:36:09 +00:00
Colin Walters
6b93cb3173 ci: Install PyYAML
We'll use it for https://github.com/ostreedev/ostree/pull/691

Closes: #692
Approved by: jlebon
2017-02-17 21:38:14 +00:00
Colin Walters
b5c5003ff6 pull: Fold together deltapart+fallback count for display
It's just simpler, and I'm not sure people are going to care
much about the difference by default.

We already folded in the fallback sizes into the download totals, so folding in
the count makes things consistent; previously you could see e.g.
`3/3 parts, 100MB/150MB` and be confused.

Closes: #678
Approved by: giuseppe
2017-02-17 14:58:25 +00:00
Colin Walters
693f7c5f60 pull: Explicitly error out if metadata objects are fallbacks
I don't know why I added support for this; it makes no sense really. If we have
large metadata objects something has gone badly wrong.

The delta compiler has always only processed fallbacks for regular
content files.

Dropping support in the fetcher for this will simplify later handling of
fallback progress accounting.

Closes: #678
Approved by: giuseppe
2017-02-17 14:58:25 +00:00
Colin Walters
e1118e320d repo: Fix static delta progress display
There were a few bugs here.

- We need to keep track of the size of the delta parts we've already processed,
  in order to make progress reliable at all in the face of interruptions.  Add
  a new `fetched-delta-part-size` async progress variable for this.
- The total before disregarded what we'd already downloaded, which was confusing.
  Now, a progress percentage is `fetched/total`.
- Correctly handle "unknown bytes/sec" in the progress display.

However, to be fully correct we need to show the fallback objects too. That
would require tracking in the pull code when we fetch an object as a fallback
versus "normally". This would be simpler really if we could assume in a run we
were *only* processing a delta, but currently we don't do that.

Related: https://github.com/ostreedev/ostree/issues/475

Closes: #678
Approved by: giuseppe
2017-02-17 14:58:25 +00:00
Colin Walters
0142e5ff39 delta-show: Don't dump whole superblock, do show fallback checksums
Doing `g_variant_print (superblock)` is unreadable and not very useful,
since we show the checksums as byte arrays.

However, do show the checksums for fallback objects. This makes it easier to see
which objects are fallbacks (and inspect why).

Closes: #678
Approved by: giuseppe
2017-02-17 14:58:25 +00:00
Colin Walters
98a4547510 deltas: Don't put unreadable *from* objects in fallback
In https://github.com/ostreedev/ostree/pull/634 we introduced
a subtle regression - the unreadable object was added to the *new*
reachable objects, when it shouldn't have been.  Because it
was a *from* object, clients already had it.

This became more obvious now that I'm working on fixing delta
progress - I noticed my deltas were always starting out with 40MB
fetched, which turned out to be a non-world-readable initramfs object.

This code should simply *skip* the unreadable object, and the delta processing
below properly iterates over "new objects", so we'll pick it up from there.

Closes: #678
Approved by: giuseppe
2017-02-17 14:58:25 +00:00
Giuseppe Scrivano
a1805d6101 contrib/golang: rm directory
rm -r the directory since we are keeping the Go bindings separately
under https://github.com/ostreedev/ostree-go

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

Closes: #690
Approved by: cgwalters
2017-02-16 20:00:44 +00:00
Colin Walters
da21d7350e Release 2017.2
We should get a release out to try to keep with at least a once-a-month cadence.
This one has some exciting stuff like libcurl and Rust, and various bugfixes.
Also importantly I want to cut this *before* we land some other bigger stuff, so
rpm-ostree can start using the reload_config API etc.

Closes: #685
Approved by: jlebon
2017-02-14 16:21:57 +00:00
Alexander Larsson
4e908f867d rofiles-fuse: Support write/read_buf()
These allow us to avoid copying a lot of data around
in userspace. Instead we splice the data directly from
the fd to the destination fd.

Closes: #684
Approved by: cgwalters
2017-02-14 14:59:28 +00:00
Colin Walters
ba350982e8 build: Remove .PHONY for Rust shared library
I have no idea why I made the lib `.PHONY` originally; it's clearly wrong, and I
noticed because when I was doing `sudo make install`, we were doing a rebuild,
which in turn triggered other things to be built, and they'd be owned by root.

Closes: #682
Approved by: jlebon
2017-02-14 14:27:39 +00:00
Colin Walters
46544f5b4d commit: Support -F/--body-file, like git
This is more convenient to script for projects which haven't
yet made the leap to using the API.

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

Closes: #681
Approved by: jlebon
2017-02-14 14:15:08 +00:00
Colin Walters
5a73a366b9 libglnx: Bump
Pulls in the xattr fixes and the tempname perf improvement.

Closes: #680
Approved by: jlebon
2017-02-14 14:02:59 +00:00
Anton Gerasimov
b8f4465b50 admin-switch: Don't segfault if there's no remote
Switching between local branches should be supported too.

Signed-off-by: Anton Gerasimov <anton@advancedtelematic.com>

Closes: #683
Approved by: cgwalters
2017-02-13 20:32:07 +00:00
Philip Withnall
e6a8979e05 ostree-repo: Clarify error behaviour of remote option getters
Clarify the documentation for functions like
ostree_repo_get_remote_boolean_option(), stating what out_value will be
set to on error.

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

Closes: #676
Approved by: cgwalters
2017-02-10 14:26:00 +00:00
Krisztian Litkey
b13ead1c5b libostree: added empty ot_cleanup_{read,write}_archive macros.
Added empty macros for ot_cleanup_{read,write}_archive to fix
errors when compiling without libarchive.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>

Closes: #677
Approved by: cgwalters
2017-02-10 14:06:37 +00:00
Jonathan Lebon
40a1d32067 fetcher queue: also throttle on outstanding writes
When fetching over a fast enough connection, we can be receiving files
faster than we write them. This can then lead to EMFILE when we have
enough files open. This was made very easy to notice with the upcoming
libcurl backend, which makes use of pipelining.

Closes: #675
Approved by: cgwalters
2017-02-09 16:54:20 +00:00
Colin Walters
361aa449fb libcurl backend
For rpm-ostree, we already link to libcurl indirectly via librepo, and
only having one HTTP library in process makes sense.

Further, libcurl is (I think) more popular in the embedded space.  It
also supports HTTP/2.0 today, which is a *very* nice to have for OSTree.

This seems to be working fairly well for me in my local testing, but it's
obviously brand new nontrivial code, so it's going to need some soak time.

The ugliest part of this is having to vendor in the soup-url code. With
Oxidation we could follow the path of Firefox and use the
[Servo URL parser](https://github.com/servo/rust-url).  Having to redo
cookie parsing also sucked, and that would also be a good oxidation target.

But that's for the future.

Closes: #641
Approved by: jlebon
2017-02-09 16:37:45 +00:00
Colin Walters
425ccc0a33 pull: Show Estimating if we're scanning too
The libcurl backend does all the work in the main thread/loop, which
seems to starve the idle scanning worker more.  With the libcurl
backend, we're a lot more likely to have at least one outstanding
metadata request.

But it can more easily transiently happen with libcurl that all of our current
fetches are content. To be accurate here, just show Estimating if we're scanning
too.

Closes: #654
Approved by: jlebon
2017-02-07 19:59:40 +00:00
Colin Walters
f4d1334e19 fetcher: Drop the libsoup queue
Now that we have queuing in the higher level pull logic, we don't
need to do this anymore.

It's tempting to keep it since the code diff is so small (without
completely rewriting things), but dropping it here will make
it easier to see when things go wrong at a higher level.

Note that I kept an assertion.

Closes: #654
Approved by: jlebon
2017-02-07 19:59:40 +00:00
Colin Walters
c18628ecb8 pull: Add queuing into the higher level logic
Working on the libcurl backend, I didn't want to reimplement another queue. I
think the queue logic is really better done at the high level, since the fetcher
knows how we want to prioritize metadata over content, etc.

Adding another queue here is duplication, but things will look nicer when we can
actually delete the libsoup one in the next commit.

Closes: #654
Approved by: jlebon
2017-02-07 19:59:40 +00:00
Colin Walters
3d38f03e4f repo: Add archive/zlib-level option, drop default compression to 6
The gzip default is 6.  When I was writing this code, I chose 9 under
the assumption that for long-term archival, the extra compression was
worth it.

Turns out level 9 is really, really not worth it.  Here's run at level 9
compressing the current Fedora Atomic Host into archive:

```
ostree --repo=repo pull-local repo-build fedora-atomic/25/x86_64/docker-host
real    2m38.115s
user    2m31.210s
sys     0m3.114s
617M    repo
```

And here's the new default level of 6:

```
ostree --repo=repo pull-local repo-build fedora-atomic/25/x86_64/docker-host
real    0m53.712s
user    0m43.727s
sys     0m3.601s
619M    repo
619M    total
```

As you can see, we run almost *three times* faster, and we take up *less
than one percent* more space.

Conclusion: Using level 9 is dumb.  And here's a run at compression level 1:

```
ostree --repo=repo pull-local repo-build fedora-atomic/25/x86_64/docker-host
real    0m24.073s
user    0m17.574s
sys     0m2.636s
643M    repo
643M    total
```

I would argue actually many people would prefer even this for "devel" repos.
For production repos, you want static deltas anyways.  (However, perhaps
we should support a model where generating a delta involves re-compressing
fallback objects with a bit stronger compression level).

Anyways, let's make everyone's life better and switch the default to 6.

Closes: #671
Approved by: jlebon
2017-02-07 17:01:09 +00:00
Colin Walters
9169268c31 rust: Support make dist -> cargo vendor
What we do here basically is set things up in a `dist-hook` so that our Rust
sources are vendored at `dist` time. This gives us a single tarball still, and
ideally should be transparent to downstream builders, as long as they have the
`cargo/rust` toolchain.

Closes: #669
Approved by: jlebon
2017-02-07 16:50:37 +00:00
Colin Walters
9c0af41710 lib: Add ostree_repo_reload_config()
For a long time we've cached the remote configs in the repo, which
mostly makes sense for the `repo/config` file, but less sense
for `/etc/ostree/remotes.d`, because we want to support admins
interactively editing them.

One can delete the repo instance and create a new one, but that's a bit ugly.
Let's introduce an API for this so rpm-ostree can reload remotes after
admins/scripts edit them in `/etc`.  We also might as well reload
any other entries in the config.

Structurually now, `ostree_repo_open()` deals with file descriptors, and then
calls `ostree_repo_reload_config()`. Except for the uncompressed cache, which is
the only thing that deals with FDs that can be configured. But we want to delete
that anyways.

No tests, since...we don't have a daemon in this codebase, don't want to shave
that yak just today.

Closes: #662
Approved by: jlebon
2017-02-07 16:12:58 +00:00
Colin Walters
200887c7c9 packaging/: Delete
This is obsolete for a few reasons. The spec file is out of date (mostly the
%files, but also the BRs), and further down the line we'll need to use `make
dist` so we pick up vendored Rust sources. So the "git archive" approach won't
work for much longer anyways.

This came up in https://mail.gnome.org/archives/ostree-list/2017-February/msg00005.html

Basically, anyone who wants to build packages should look at the upstream
dist-git - until such time as e.g. Fedora learns to support pulling spec files
from upstream.

Closes: #670
Approved by: giuseppe
2017-02-06 15:01:36 +00:00
Jonathan Lebon
0400df75d1 trusted.gpg.d: keep in the same location
With the package rename from ostree to libostree, the trusted.gpg.d/ dir
changed install location from /usr/share/ostree to /usr/share/libostree.
Let's keep the same dir to remain compatible with existing installations
that may already have keys there.

Closes: #668
Approved by: cgwalters
2017-02-03 19:28:41 +00:00