Commit Graph

1323 Commits

Author SHA1 Message Date
Jasper St. Pierre
2506e8fb26 repo: Make commit_transaction introspectable 2013-09-07 01:46:50 -04:00
Jasper St. Pierre
3dcff0b2c4 Fix build
Before I pushed the "move code to a different file" commit, I rebased,
but forgot to test the build. Sorry.
2013-09-06 20:47:13 -04:00
Jasper St. Pierre
91d3b90c9f Move ref writing to be transaction-based
Rather than having separate write_ref calls, make clients start a
transaction, add some refs, and then commit it. While this doesn't
make it 100% atomic, it makes it easier for us to use an atomic
model, and it means we don't do as much I/O updating the summary
file and such.

https://bugzilla.gnome.org/show_bug.cgi?id=707644
2013-09-06 20:31:12 -04:00
Jasper St. Pierre
bd2948e964 repo: Move the scanning hardlinks optimization out of prepare_transaction
This is just a terrible API to have. Make the scanning a separate method,
and document it as an optimization.
2013-09-06 20:31:12 -04:00
Jasper St. Pierre
f84504a8c4 repo: Make abort_transaction silently succeed if we're not in a transaction
This helps callers out a lot, and means we can always call abort_transaction
at the end of a function.

https://bugzilla.gnome.org/show_bug.cgi?id=707644
2013-09-06 20:31:12 -04:00
Jasper St. Pierre
ef61724269 repo: Move the transaction stats to a separate struct
This is much easier for callers to handle, and simplifies
the API a lot.

https://bugzilla.gnome.org/show_bug.cgi?id=707644
2013-09-06 20:31:12 -04:00
Jasper St. Pierre
5082e1d8e9 repo: Rename "stage" to "write" in the API
An earlier version of this API acted like git in that some objects
would be staged in a temporary directory which would be then committed
in one go by moving files around. The API doesn't match most users
expectations though, as while the stage is nice as a high-level API
it isn't really suited for low-level APIs.

While the stage was removed, the APIs were never renamed. Rename
them now so that they match expectations.

https://bugzilla.gnome.org/show_bug.cgi?id=707644
2013-09-06 20:31:12 -04:00
Jasper St. Pierre
c817217ad8 repo: Move commit code to another file
ostree-repo.c is a bit too big, and most of the commit code is
fairly standalone.

https://bugzilla.gnome.org/show_bug.cgi?id=707644
2013-09-06 20:31:11 -04:00
Jasper St. Pierre
89f4817bdf repo: Make prepare_transaction introspectable
We need to document the out pointer as an out pointer.

https://bugzilla.gnome.org/show_bug.cgi?id=707644
2013-09-06 20:28:42 -04:00
Jasper St. Pierre
b36e61f813 repo: Make OSTreeCommitModifier introspectable
Callbacks need GDestroyNotifies to be usable from bindings.

https://bugzilla.gnome.org/show_bug.cgi?id=707644
2013-09-06 20:28:42 -04:00
Jasper St. Pierre
f5f7fe5e9a repo: Make the ordering consistent between abort/complete_transaction
This just makes the functions nicer to stare at.

https://bugzilla.gnome.org/show_bug.cgi?id=707644
2013-09-06 20:28:42 -04:00
Colin Walters
4dcf1a4282 core: When using hardlinks, always use linkat() for destination
This avoids repeatedly traversing the target pathname, and is just
more efficient.

Part of a prelude to using fd-relative API for the source object path
too.
2013-09-06 18:45:41 -04:00
Colin Walters
2b61caa2fe core: Use fd-relative creation for tmp/
Update libgsystem submodule for a bugfix.

This is both more efficient from a kernel perspective, and avoids us
calling gs_file_get_path_cached() on tmp_dir constantly, which
triggered another bug due to lack of locking.
2013-09-06 18:45:16 -04:00
Jasper St. Pierre
249add9c94 Update .gitignore 2013-09-05 18:18:54 -04:00
Jasper St. Pierre
93a611ff6d Update docs 2013-09-05 17:59:02 -04:00
Jasper St. Pierre
02adfc8c03 repo: Rename ostree_repo_check to ostree_repo_open
As it more clearly describes what the function does: load the
repo from disk and initialize it.

At the same time, add a cancellable parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=707582
2013-09-05 14:07:03 -04:00
Jasper St. Pierre
57d285f619 repo: Move the 'init' builtin command to a public API, ostree_repo_create
This continues the goal of making more of ostree accessible by API,
rather than forking out to subprocesses.

https://bugzilla.gnome.org/show_bug.cgi?id=707582
2013-09-05 14:07:03 -04:00
Jasper St. Pierre
eb6f017ef8 repo: Use constructed, not constructor
It's simpler to do this after the object is constructed, rather
than in the middle of construction.

https://bugzilla.gnome.org/show_bug.cgi?id=707582
2013-09-05 13:54:36 -04:00
Jasper St. Pierre
33f232f76c Update .gitignore 2013-09-05 00:21:05 -04:00
Colin Walters
8a59f6561c main: Call setlocale()
While we're not translating anything right now, we should still
setlocale() so that our output is formatted as command line users will
expect.
2013-09-04 16:45:51 -04:00
Colin Walters
1ae83002b5 core: Delete unused prototype 2013-09-04 08:22:13 -04:00
Colin Walters
eeb1f9e07b core: Delete unused ostree_create_temp_dir() API
Nothing was using it.  Poof.  Gone!
2013-09-04 08:18:45 -04:00
Colin Walters
36815f52b5 libostree: Move file creation APIs out of core, into checkout.c
Since this was the only user, let's not have generic code to go from
OSTree representation -> filesystem here.  It should live in checkout.
2013-09-04 08:17:42 -04:00
Colin Walters
79c922a00b core: Remove unused prototypes 2013-09-04 07:54:32 -04:00
Colin Walters
ee2b66ef00 core: Make a helper function private
Nothing was using this, so make it private.
2013-09-04 07:53:02 -04:00
Colin Walters
2534714501 core: Make ostree_write_variant_with_size() private
More work making the file formats and utilities private.
2013-09-04 07:49:41 -04:00
Colin Walters
0d72168961 libostree: Make the format of file objects private
It's now isolated almost entirely to ostree-core.c, except
ostree-repo.c needs to know how to create archive-z2 file headers.  So
give it a private API for that.
2013-09-03 18:43:42 -04:00
Colin Walters
356de33b49 repo: Drop ostree_repo_load_variant_c API
Originally we had this to avoid forcing callers to malloc() if they
had a csum, but nowadays we have in-place conversion APIs that are
fast enough.
2013-09-03 18:23:11 -04:00
Colin Walters
dd7d2f7b43 repo: Only apply setuid/xattrs after checksum validation
See the new comment in the source; basically if we're fetching content
over http, then someone with the capability to MITM the network could
create a transient setuid binary on disk with arbitrary content.  If
they also had a process running on the system (such as an application)
it could be escalated to root.

https://bugzilla.gnome.org/show_bug.cgi?id=707139
2013-09-02 15:31:55 -04:00
Colin Walters
597da6ca6b libostree: Change synchronous fetching API to return a stream
There's not a good reason to write small things such as repo/config to
the filesystem, only to read them back in again.  Change the
non-partial API to just return a stream, then read it into a memory
buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=707157
2013-09-02 14:48:21 -04:00
Colin Walters
95a78542e9 fetcher: Only open files when we are ready to write to them
Otherwise we quickly run out of file descriptors when doing large
requests.

https://bugzilla.gnome.org/show_bug.cgi?id=707157
2013-09-02 14:48:21 -04:00
Colin Walters
8b5f684b68 fetcher: Clean up code to avoid intermediate files
I think originally we had the .part/.done separation because we were
trying to support partial downloads of files like repo/config and
repo/refs.

But now that the http server configuration won't give us partial
results, we don't need to support caching those files between runs.

And thus, there's no reason to have the .part/.done and do the dance
with renaming them.

When fetching objects/ and other things that use _with_async, we
continue to use _append_to(), and if the returned range tells us we
have all the bytes, then we hand the full file over to the caller.

Don't attempt to shortcut in the case where the last run told us we
already have the object; the object fetcher code will not make a
request.

While we're here, also clean up use of GError and consistently use the
cancellable from the pending.

https://bugzilla.gnome.org/show_bug.cgi?id=707157
2013-09-02 14:48:20 -04:00
Colin Walters
9e497a4ce7 prepare-root: Fix ostree= kernel argument at end
Extracting the code for parse_ostree_cmdline() and running it on some
test input (on RHEL6.4 glibc), I can reproduce the odd behavior from
getline() where it apparently returns the size of the default malloc
buffer in the size output, and some non-zero value.

This behavior would be OK except that it breaks the logic for
stripping off the trailing newline, which in turn breaks booting
because we return "ostree=foo\n".

This has worked so far in gnome-ostree because syslinux apparently
injects initrd=/path/to/initrd as a final kernel argment.

Anyways, we don't handle NUL characters here in /proc/cmdline, so
let's just call strlen () to be safe.

https://bugzilla.gnome.org/show_bug.cgi?id=707192
2013-09-02 13:27:41 -04:00
Jasper St. Pierre
52dd6b0b74 libostree: Make introspectable again
At some point, the variable name for the headers changed and the
introspection build line forgot to be updated.

https://bugzilla.gnome.org/show_bug.cgi?id=707228
2013-09-01 11:19:15 -04:00
Colin Walters
b2625268aa tests: Drop kernel modules from checksums
We can actually share these across different kernels.  Thanks to
Tobias Hunger <tobias.hunger@gmail.com> for pointing this out.
2013-08-30 18:12:31 -04:00
Colin Walters
72a8f41ad4 admin: Error out if we see malformed or mismatched checksums for /boot
The kernel/initramfs both need to end in -SHA256 and match.
2013-08-30 18:10:35 -04:00
Colin Walters
23e2593b6d repo: Use non-deprecated API with sufficiently new libarchive
Based on a patch Tobias Hunger <tobias.hunger@gmail.com>
2013-08-30 14:34:32 -04:00
Tobias Hunger
2a14f2cd52 Fix warning about format string not being a string literal 2013-08-30 14:26:24 -04:00
Tobias Hunger
ed56908ccb Fix warnings about unused variables 2013-08-30 14:23:45 -04:00
Tobias Hunger
4cdd444dcf gitignore: Add ostree-prepare-root and ostree-remount binaries 2013-08-29 19:27:47 -04:00
Stef Walter
a4c3c4ae38 ostree: Support for using EDITOR to fill commit subject/body
Behave similar to git when 'ostree commit' is run without
a --subject or --body. Bring up an editor. The first line becomes
the subject and following lines become the --body after an optional
blank line.

Use similar logic to git in determining EDITOR

https://bugzilla.gnome.org/show_bug.cgi?id=707063
2013-08-29 21:08:32 +02:00
Stef Walter
1a708accf1 ostree: Fix bug printing out commit body
Body was printed out repeated and mangled due to bad printf format string.

https://bugzilla.gnome.org/show_bug.cgi?id=707067
2013-08-29 21:07:18 +02:00
Colin Walters
8fce2513e9 pull: Clean up synchronous fetching code
Fold in fetch_uri to fetch_uri_utf8(), and rename the latter to
include _sync as a suffix, since it's synchronous.

Improve the status line to show when we're fetching a synchronous URI;
previously we just showed "Scanning metadata".

https://bugzilla.gnome.org/show_bug.cgi?id=707023
2013-08-29 08:01:51 -04:00
Colin Walters
c9d7050d3d main: Support passing bare directory names to commit
It segfaulted before if you passed non-options, and a single directory
name is probably what people want.
2013-08-28 17:32:21 -04:00
Jeremy Whiting
499df2a90b pull: Add support for resuming downloads via range requests
Use a consistent temporary filename to download uri's.
Check for downloaded files before fetching from uri.
Download to hash.part file, then copy/move to hash.done when complete.
Add argument support to setup_fake_remote_repo1 function.
Add test for pull resume.
To implement this, pass --force-range-requests into the trivial-httpd,
which will only serve half of the objects to clients at a time.

https://bugzilla.gnome.org/show_bug.cgi?id=706344
2013-08-28 14:35:54 -04:00
Jeremy Whiting
902848cd71 test: Improve pull corruption test
To verify pull with a second repo works.
2013-08-27 20:35:45 -04:00
Colin Walters
bb8418ff01 build: Add a note that ostree only supports InstalledTests 2013-08-27 19:34:58 -04:00
Colin Walters
d92eedac4a repo: Clean up tmpdir also on transaction abort
Pull the cleanup code to a helper function, and ensure we delete
leftover temporary files also when aborting a transaction.  Mainly
this will happen if a local 'ostree commit' fails.

While we're here, also change it to use gs_shutil_rm_rf() which also
handles directories, should we start using those.

Reviewed-by: Jeremy Whiting <jpwhiting@kde.org>
2013-08-27 11:35:45 -04:00
Jeremy Whiting
d58a4c9f79 repo: Clean up temporaries after a transaction completes
Prevously, we were just leaving temporary files there forever if
a transaction was interrupted.

https://bugzilla.gnome.org/show_bug.cgi?id=706344
2013-08-27 11:35:36 -04:00
Colin Walters
dd3d522fa8 trivial-httpd: Add missing include for shutdown() on eglibc 2013-08-26 17:57:43 -04:00