Commit Graph

1123 Commits

Author SHA1 Message Date
Colin Walters 3ffdef07a4 repo: Split generic GPG commit verification out into helper
This will be used for a future commit which GPG verifies static
deltas.
2014-02-10 09:40:35 -05:00
Colin Walters 60c4d467aa deltas: Add a timestamp to delta metadata 2014-02-10 09:40:35 -05:00
Colin Walters f526fd4e3c pull: Remove a duplicate hash table
Not sure why we had two...perhaps the code originally had them
separate.
2014-02-10 09:40:35 -05:00
Colin Walters 2ee2751fd1 repo: Don't set GPG engine executable path
The instructions one finds on the internets are apparently wrong, we
really need to keep the default here, since gpgme uses it to actually
find the helper binary it runs.

This fixes the GPG tests for me on EL7 at least.
2014-02-10 09:12:00 -05:00
Colin Walters 8dd7b5575e Drop refs/summary
I'm not aware of anyone using this, and it's not efficient to write a
whole file every time a ref changes, plus it's not atomic.
2014-02-09 14:01:27 -05:00
Colin Walters a30fcba273 sysroot: Add a log with MESSAGE_ID when deployment is complete 2014-02-09 13:17:24 -05:00
Colin Walters d744436a50 pull: Don't crash if the URL is not found 2014-02-06 03:46:14 -05:00
Colin Walters 2d6374822b Initial basic static delta code drop
This has a very basic level of functionality (deltas can be generated,
and applied offline).  There is only some stubbed out pull code to
fetch them via HTTP.

But, better to commit this now and improve it from a known starting
point, rather than have it languish in a branch.
2014-02-04 10:31:44 -05:00
Colin Walters 844c5ea652 core: Import bup's "rollsum" code, add a test case
For static deltas, one strategy that will be employed is to split each
object into chunks, and only include changed chunks in the deltas.
2014-02-04 10:12:56 -05:00
Colin Walters 3007aeb160 build: Fix --without-selinux case 2014-02-02 11:49:43 -05:00
Colin Walters e580a88f4e SELinux: Ensure we label /var, and fix /etc merge wrt xattrs
First, /var needs to be labeled at least once.  We should probably
rearrange things so that /var is only created (and labeled) on the
first deployment, but this patch adds a /var/.ostree-selabeled file
instead.

Second, when doing the /etc merge, we compare the xattrs of the old
/usr/etc versus the current /etc.  The problem with that is that the
policy has different labels for /usr/etc on disk than the real /etc.

The correct fix for this is a bit invasive - we have to take the
physical content of the old /usr/etc, but compare the labels as if
they were really in /etc.

Instead for now, just ignore changes to xattrs.  If the file
content/mode changes, then we take the new file (including any changed
xattrs).

Bottom line: just doing chcon -t blah_t /etc/foo.conf may be lost on
upgrade (for now).
2014-02-02 11:32:52 -05:00
Colin Walters f86a132eb0 libostree: Also use xattr callback for directories
They need labels too, obviously.
2014-02-01 11:30:10 -05:00
Colin Walters 234ae70b4c Add --disable-fsync option to pull-local, and API to repo
This will be used by guestmount - it's WAY faster.  We only take disks
as a unit, so it's safe.  If the process fails halfway through, we
just start over from scratch the next time anyways.
2014-01-31 22:18:13 -05:00
Colin Walters 2313bdcb62 Add SELinux support
The trees as shipped come with /usr/etc, which should just be labeled
as usr_t.  When we do a deployment, we need to relabel the copies of
the files we're making in /etc.

SELinux support is compile and runtime optional.
2014-01-31 08:10:55 -05:00
Colin Walters be1acfafa0 repo: Add API to provide xattrs
This will be used by rpm-ostree to provide SELinux security contexts,
without requiring us to actually label the disk.
2014-01-30 20:37:27 -05:00
Colin Walters c7bcfc1c61 build: Look for /usr/bin/gpgv2 vs /usr/bin/gpgv
For some reason, RHEL has gpgv, but Fedora doesn't.  We need to detect
which to use, since presumably Debian only has gpgv.
2014-01-30 19:32:59 -05:00
Colin Walters f36cc6a44c repo: Improve GPG error messages
The signing test is failing here on EL7 beta for me - it seems like
gnupg isn't honoring the homedir.
2014-01-30 17:17:36 -05:00
Colin Walters ffb19aef9a libostree: Actually trusted.gpg.d/*.gpg for GPG verification
The intent of this code I'm fairly certain was to use *.gpg from the
trusted.gpg.d, directory.  But right now, we're only using
"pubring.gpg" from that directory, which is odd.

Let's fix this to use all keys ending in .gpg, which will also
include pubring.gpg.
2014-01-30 15:40:46 -05:00
Colin Walters bffd30ff27 ostree-prepare-root.service: Also order before plymouth-switch-root.service
In the OSTree model, /sysroot gets set up twice.  We need to ensure
that the /sysroot plymouth sees is only after OSTree has set it up.
2014-01-27 13:57:18 -05:00
Colin Walters daaddcf536 boot/ostree-remount.service: Run before plymouth-read-write.service
The plymouth service needs a writable /var, so ensure that we run
before it does.
2014-01-27 11:57:35 -05:00
Colin Walters d64d2b6636 pull: Be less chatty with G_MESSAGES_DEBUG=all
Only note state *transitions*, don't spam on simple checks.
2014-01-22 15:02:01 +00:00
Colin Walters 390b781d3a pull: Add remotename:ref syntax
This is really the common case.
2014-01-21 08:57:34 +00:00
Colin Walters 43fdfa0649 repo: Document ostree_repo_sign_commit(), and add introspection data
The important bit for introspection is (allow-none) on the homedir.
2014-01-20 12:13:37 -05:00
Colin Walters 9640171711 pull: Close another race
Only send _IDLE messages if and only if we state transition the main
thread (from idle -> !idle or !idle -> idle).  This ensures that we
don't send IDLE, then get it back, and process that when we're !idle.
2014-01-20 06:26:49 -05:00
Colin Walters 3cd866556c pull: Hopefully squash race where we would exit early
This is a redesign (again) of the pull code.  It is simpler and
survives 20 minutes of testing in a loop, whereas the old code would
only go from 30 seconds to 2 minutes.

The problem with the old code was that there was a race where we might
determine idle state even when there are content requests in flight
between the metadata thread and the main one.

This code majorly reworks things - there's now only one IDLE message,
sent in a circle from the main thread, through the metadata scanner,
and back to the main one.

Crucially it's only sent when the *main* thread is idle.  Previously
we were looking at whether the metadata scanner is idle, but that
doesn't make a lot of sense.  First let's make sure the main thread is
idle, then verify that the metadata one is.

This closes the loop because we'll have ensured we get any pending
requests.

https://bugzilla.gnome.org/show_bug.cgi?id=706456
2014-01-19 18:12:44 -05:00
Colin Walters f841313206 libostree: Ensure we set standard::type when querying files
This makes the obvious code to recursively enumerate directories
operate more sanely.

Noticed this while trying to write corrupt-repo-ref.js.
2014-01-19 13:19:10 -05:00
Colin Walters 3ce687ef1b pull: Add a few more g_debug() and assertions
To help track down the race condition better.
2014-01-19 12:39:18 -05:00
Colin Walters d98eb901c4 deploy/main: Unify some bits between admin-switch and admin-upgrade 2014-01-19 11:28:30 -05:00
Colin Walters 878a43411e admin/switch: New builtin to switch between trees
This is something I want to make easier, as it better showcases the
flexibility of OSTree.
2014-01-18 17:47:16 -05:00
Colin Walters 4fff43da1b Squash some harmless compiler warnings
None of these AFAICS actually can occur, but let's silence gcc.
2014-01-18 04:53:16 -05:00
Colin Walters d0d98d3abe libotutil: Fix a possible uninitialized free() in error path
Spotted by gcc.
2014-01-18 04:52:45 -05:00
Colin Walters 5034bf3a9d commit: Reject non-regular/non-symlinks earlier with better error message
Also avoid _NOT_SUPPORTED as that triggers the --help behavior from
the commandline; just use _FAILED.

https://bugzilla.gnome.org/show_bug.cgi?id=722410
2014-01-17 10:39:36 -05:00
Colin Walters b2d0ba7ac1 deploy: Rework kernel arguments, add --karg-append to "admin deploy"
The "ordered hash" code was really just for kernel arguments.  And it
turns out it needs to be a multihash (for e.g. multiple console=
arguments).

So turn the OstreeOrderedHash into OstreeKernelArgs, and move the bits
to split key=value and such into there.

Now we're not making this public API yet - the public OstreeSysroot
just takes char **kargs.  To facilitate code reuse between ostree/ and
libostree/, make it a noinst libtool library.  It'll be duplicated in
the binary and library, but that's OK for now.  We can investigate
making OstreeKernelArgs public later.

https://bugzilla.gnome.org/show_bug.cgi?id=721136
2014-01-16 15:07:55 -05:00
Colin Walters fd8bd356ae Update libgsystem
This has a GsConsole fix.
2014-01-15 09:19:32 -05:00
Colin Walters 108546c08c admin: Add --karg-proc-cmdline argument
When installing a new tree inside an existing OS, this is a convenient
way to include the command line arguments one needs (such as root=).
2014-01-15 09:19:32 -05:00
Colin Walters 54e58a51ca deploy: Write bootloader config even if just kernel arguments changed
The official way to add bootloader arguments to the current deployment
is to redeploy with --karg.  However, doing so tripped up an
optimization made inside the deployment code to just swap the
bootlinks if we're keeping the same "bootcsum".

Change this optimization to look at the pair of (bootcsum, options).
2014-01-15 09:19:32 -05:00
Colin Walters ff2c592ac9 pull: Ensure we begin a status line
Otherwise if the operation completes before anything happens, we hit
an assertion trying to end a status line when we didn't begin one.
2014-01-10 08:15:54 -05:00
Colin Walters 091523a3bd sysroot: Error out on deploy --os=<unknown> which has not been initialized
We should hard require "ostree admin os-init foo" before letting
deployments go there; it's too easy to typo the argument.
2014-01-08 18:30:38 -05:00
Colin Walters aaeeb45fba Remove 'write-refs' builtin
See https://bugzilla.gnome.org/show_bug.cgi?id=705979

This was just a performance hack for gnome-continuous back before it
used libostree via g-i.
2013-12-25 14:24:49 -05:00
Colin Walters 39e3c1bb8a ostree/remote-add: Add --no-gpg-verify option
To more conveniently disable GPG verification.
2013-12-25 14:17:36 -05:00
Colin Walters 9adbc165e7 repo: Introspect _sign_commit() and _verify_commit()
We can't use #ifdef in the headers, since then g-ir-scanner won't pick
up the functions (unless we included config.h).  Let's instead always
have the symbols, but just set an error if we were built without
support for it, just like how pull works.
2013-12-23 11:40:57 -05:00
Colin Walters a58d3d079c prune: Remove redundant 'bytes' in format string 2013-12-20 17:44:13 -05:00
Colin Walters 76d9d92916 repo: Provide a friendlier error message if no signatures are found
I always forget the key to disable it...
2013-12-17 23:00:01 -05:00
Colin Walters 68c9c45e15 repo-pull: Remove leftover unused %s 2013-12-16 18:24:03 -05:00
Roddy Shuler fe5ed36461 core: Set mtime of content objects to 0
This is necessary to satisfy tools such as guile and python, which
compare mtimes to determine whether or not source files need to be
compiled.

https://bugzilla.gnome.org/show_bug.cgi?id=720363
2013-12-15 11:32:34 -05:00
Colin Walters 41df7efc88 Update libgsystem 2013-11-28 23:45:48 -05:00
Colin Walters a24afd68f0 Move xattr handling into libgsystem, fix sysroot to handle directory ownership/perms
This large patch moves the core xattr logic down into libgsystem,
which allows the gs_shutil_cp_a() API to copy them.  In turn, this
allows us to just use that API instead of rolling our own recursive
copy here.

As noted in the new comment though, one case that we are explicitly
regressing is where the new /etc removes a parent directory that's
needed by a modified file.  This seems unlikely for most vendors now,
but let's do that as a separate bug.

https://bugzilla.gnome.org/show_bug.cgi?id=711058
2013-11-28 23:28:13 -05:00
Colin Walters a897b42a7a ostree-remount.service: Run before systemd-random-seed.service
It's essential that we've mounted /var read-write in order for
random-seed.service to work.
2013-11-22 16:42:20 -05:00
Colin Walters 2b8c717c33 fetcher: Display incremental download progress
Previously the progress meter would bump in large chunks after we
completed a download.  Instead, poll in progress files via fstat() for
their size, and add those to the running total.
2013-11-21 14:34:47 -05:00
Colin Walters e9b35deba8 Update libgsystem
For https://bugzilla.gnome.org/show_bug.cgi?id=711057
2013-11-03 21:35:45 -05:00
Colin Walters affccb343a main: Treat default osname more consistently
The libostree already treats passing NULL for osname as "booted
osname, if any".  We should do the same inside the tools.  The upgrade
builtin had this logic duplicated there; we should be able to safely
remove it.

https://bugzilla.gnome.org/show_bug.cgi?id=710970
2013-10-28 09:15:32 -04:00
Daniel Narvaez 7ecfbff26e Fix crash when deploying with implicit os name
When booted into an ostree you can deploy without passing
an --os option. That was crashing though, because
ot_admin_complete_deploy_one is called with NULL
osname but it was not handling it properly.

https://bugzilla.gnome.org/show_bug.cgi?id=710970
2013-10-28 09:15:32 -04:00
Daniel Narvaez 03aa10f17d main/remote: Add a show-url operation to the remote command
Useful to get the remote url in scripts.

https://bugzilla.gnome.org/show_bug.cgi?id=710967
2013-10-28 09:14:23 -04:00
Colin Walters 73ff642b15 libostree: Remove extra : in comment
g-ir-scanner handles this, but it stuck out.
2013-10-24 20:32:20 -04:00
Colin Walters 379db715d7 libostree: Squash a compiler warning 2013-10-24 14:37:50 -04:00
Colin Walters 87922259ee libostree: Squash two g-ir-scanner warnings 2013-10-24 14:37:35 -04:00
Daniel Narvaez ccb10d592d Add support for mkinitcpio
https://bugzilla.gnome.org/show_bug.cgi?id=710682
2013-10-24 14:27:49 -04:00
Colin Walters c65923e642 Add OstreeAsyncProgress, use it for ostree_repo_pull
Several APIs in libostree were moved there from the commandline code,
and have hardcoded g_print() for progress and notifications.  This
isn't useful for people who want to write PackageKit backends, custom
GUIs and the like.

From what I can tell, there isn't really a winning precedent in GLib
for progress notifications.

PackageKit has the model where the source has GObject properties that
change as async ops execute, which isn't bad...but I'd like something
a bit more general where say you can have multiple outstanding async
ops and sensibly track their state.

So, OstreeAsyncProgress is basically a threadsafe property bag with a
change notification signal.

Use this new API to move the GSConsole usage (i.e. g_print()) out from
libostree/ and into ostree/.
2013-10-24 14:27:13 -04:00
Colin Walters 9aaa29598e Update libgsystem
Just to test the new code.
2013-10-23 15:43:29 -04:00
Jeremy Whiting f583c4ab0b core: Add size information to commit metadata
Add a --generate-sizes option to commit to add size information to the
commit metadata.  This will be used by higher level code which wants
to determine the total size necessary for downloading.
2013-10-19 11:56:51 -04:00
Colin Walters 7c903eb889 repo: Remove set-but-unused variable
The gpgme examples use this, but from what I can tell we don't really
need to because we don't need detailed results; we only care whether
we signed it at all.
2013-10-15 16:44:19 -04:00
Colin Walters 4e5b31b8fc trivial: Don't include config.h in headers
This should be included by each .c file.  This fixes using libostree
from a "plain" project without config.h.
2013-10-15 15:26:37 -04:00
Colin Walters b2a98f4ca3 sysroot: Handle deleting directories in /etc
We need to use the full shutil_rm_rf() in order to actually delete
complete directories.

Test suite code based on a patch from Sjoerd Simons <sjored@luon.net>

https://bugzilla.gnome.org/show_bug.cgi?id=710097
2013-10-15 14:56:43 -04:00
Colin Walters 3b700ccb50 core: Add code to read/write "varints"
Adapted from Google protobufs.  For several cases, we want to support
e.g. file sizes up to guint64, but paying the cost of 8 bytes for each
number is too high.

This will be used for static deltas and sizes metadata.
2013-10-11 12:21:37 -04:00
Jasper St. Pierre 3b31f2b4d1 Update libgsystem 2013-10-09 16:17:38 -04:00
Colin Walters c62141004a libostree: Fix an introspection scanner warning 2013-10-09 12:53:12 -04:00
Colin Walters 2708124190 repo: Tweak traversal API
It's convenient for bindings if we have a version that doesn't mutate
the hash table, because they pass temporary hash tables as input.
2013-10-09 12:05:56 -04:00
Colin Walters cb251ae5ca sysroot: Move ostree_sysroot_origin_new_from_refspec here
Rather than having it live in admin.  This is useful for other
consumers like the test suite.
2013-10-03 18:34:24 -04:00
Colin Walters ae2234b183 sysroot: Ensure we create /boot/loader.%d/entries even if there are no deployments
Not doing so breaks things, and we should support this.
2013-10-03 18:34:24 -04:00
Colin Walters 1641ade728 sysroot: Avoid bad double-free
If a deployment is somehow in the list twice, the hash table will free
the *new* value with g_hash_table_insert which gets all broken.  Just
use g_hash_table_replace().
2013-10-03 18:34:24 -04:00
Colin Walters 2b2c6ead22 sysroot: Update some annotations
We were double-freeing before.
2013-10-03 18:34:04 -04:00
Colin Walters 07904c2457 sysroot: Support more arbitrary deployment changes
This commit changes the sysroot API so that one can create arbitrary
new deployment checkouts, then commit them as one step.  This is to
enable things like an automatic bisection tool which say create 50
deployments at once, then when done clean them up.

This also moves some printfs from the library into src/ostree.
2013-10-02 20:18:06 -04:00
Colin Walters f9379b0ce3 repo: Only delete temp files older than a day
This is somewhat lame, but to do better we need a reliable
multiprocess synchronization mechanism.

https://bugzilla.gnome.org/show_bug.cgi?id=709115
2013-10-02 18:17:27 -04:00
Colin Walters 7b119370a2 repo: Enumerate objects using openat() too, make more efficient
This drops several calls to malloc()/g_object_new() per object
enumeration.  Just a followup to using openat() and friends in other
places.
2013-09-30 08:51:25 -04:00
Colin Walters 8592922c2c core: Make ostree_get_relative_object_path() private
I plan to rename all of these APIs to use the term 'loose', so that it
makes more sense after pack files are introduced.  External users
should not use them; instead use _load_variant() or _read_commit().
2013-09-29 20:17:18 -04:00
Jeremy Whiting 7f9eefb62d pull: Verify commits with gpg signatures from detached metadata
This uses gpgv for verification against DATADIR/ostree/pubring.gpg by
default.  The keyring can be overridden by specifying OSTREE_GPG_HOME.

Add a unit test for commit signing with gpg key and verifying on pull;
to implement this we ship a test GPG key generated with no password
for Ostree Tester <test@test.com>.

Change all of the existing tests to disable GPG verification.
2013-09-29 14:49:47 -04:00
Colin Walters b064581577 commit: Store detached metadata in normal form
Otherwise corrupted variants may crash us.
2013-09-29 14:00:53 -04:00
Jeremy Whiting 7d5aa74dae core: Use libgpgme to add GPG signatures to detached metadata for commit object
Add an optional dependency on gpgme to add GPG signatures into the
detached metadata, with the key "ostree.gpgsigs", as an "aay", an
array of signatures (treated as binary data).

The commit command gains a --gpg-sign=<key-id> argument.  Also add an
argument --gpg-homedir to set the GPG homedir where we look for
keyrings.
2013-09-28 16:12:35 -04:00
Colin Walters 0f486105db remote-add: Add --set=KEY=VALUE option
This can be used to add a remote and set e.g. tls-permissive=true, or
gpgverify=false.
2013-09-28 12:00:16 -04:00
Colin Walters 38a5f6e5ed show: Handle keys of any type, and set an error if key doesn't exist
Previously we were just handling strings, and silently doing nothing
if the key didn't exist, which is pretty broken.
2013-09-27 12:57:01 -04:00
Colin Walters 2ef652439d repo-pull: Allocate with g_new0 rather than g_new.
Conflicts:

	src/libostree/ostree-repo-pull.c
2013-09-26 14:38:37 -04:00
Colin Walters 7d72a4b941 pull: Also fetch detached commitmeta files
These will contain GPG signatures and the like in the future, so we
should fetch them now.
2013-09-26 14:36:06 -04:00
Colin Walters 10cf4ccabc repo: When adding detached metadata, ensure the objdir exists
We may be creating the commitmeta file before the commit, so we need
to call mkdir(<first two checksum characters>) here too.
2013-09-26 13:59:08 -04:00
Colin Walters edcfcd21a3 show: Print an error message if commit doesn't have detached metadata
...instead of segfaulting.
2013-09-26 13:57:59 -04:00
Colin Walters 7959ad9eaf fetcher: Fix previous commit
I was getting hangs in the test suite, and looking at the previous
commit, we were calling the async completion functions out of the
finalizer for the URI, which is weird.  I didn't analyze what's going
wrong, but what we really should be doing is processing our internal
queue after we've downloaded a file, and the request is about to be
finalized.

I suspect doing queue management from the finalizer created a circular
reference type situation.

This patch deduplicates the queue processing bits too.

https://bugzilla.gnome.org/show_bug.cgi?id=708126
2013-09-25 11:59:43 -04:00
Sjoerd Simons 5f310868f7 fetcher: Add a queue to limit requests sent to soup
On a large ostree repository pulling over http slows to a crawl. Pulling
from localhost results in:
 5944 metadata, 63734 content objects fetched; 850509 KiB transferred in
 1106 seconds
In other words about 800KiB/s. Some profiling shows that essentially
all of the CPU goes into libsoup doing its request bookkeeping instead
of into the actual downloading.

Adding a simple queue to limit to number of active request sent into
libsoup makes for a dramatic improvement:
 5944 metadata, 63734 content objects fetched; 850509 KiB transferred
 in 89 seconds
So around 9450 KiB/s.

https://bugzilla.gnome.org/show_bug.cgi?id=708126
2013-09-22 23:40:51 +02:00
Colin Walters 5c406132ce libostree: Document and annotate some methods to quash g-ir-scanner warnings
Since warnings are bad.  Introspection is good.
2013-09-20 14:00:31 -04:00
Colin Walters b4bf5af5fa libostree: Remove private header file from ostree.h
Was breaking pkgsys-ostree.
2013-09-20 13:54:43 -04:00
Colin Walters 0f65d73581 upgrade: Don't segfault if there's no previous deployment
Obviously.
2013-09-20 11:21:08 -04:00
Colin Walters 298625d7f8 deploy: Correctly swap bootloader version with new boot checksums
If we had two deployments with different boot checksums, and were
trying to remove the one that was the same and add a new one (the
normal case), we'd end up assuming due to comparison with 0 that
we only needed to do the fast subbootversion swap.

Fix this by actually putting 1 where we really mean 1.

And update the tests to verify the fix; I have double-verified by
undoing the fix, and noting that the test fails.

https://bugzilla.gnome.org/show_bug.cgi?id=708351
2013-09-20 11:21:08 -04:00
Colin Walters 08b8734576 deploy: Remove checksum from generated loader entries
The actual deployment checksum shouldn't be in there, because we may
just swap bootlinks, rendering the name of the old bootloader entry
file invalid.  Thankfully nothing actually parsed the names of these
files, so let's just use the index.
2013-09-19 22:41:33 -04:00
Colin Walters d03b8bbad9 deploy: Do a full system sync after writing bootloader config
This is just something I noticed on inspection; we should catch any
changes to /boot in the sync(), even though theoretically gio should
have done fdatasync().
2013-09-19 22:26:43 -04:00
Colin Walters ae68b8380f deploy: Only query bootloader if we have to make a loader change
This will also help distinguish in the output when we're just swapping
bootlinks versus when we need to change the loader config.
2013-09-19 22:25:12 -04:00
Colin Walters d1bc9e2acf deploy: Some minor assertion and error message improvements
To help debug https://bugzilla.gnome.org/show_bug.cgi?id=708351

Plus run a status consistently in the tests.
2013-09-19 22:23:19 -04:00
Colin Walters 9b31b526cc libostree: Add API to write metadata as stream
And use it in pull-local.  The goal here is to kill users of
ostree_repo_load_variant(), and move a bit more towards hiding the
variants.
2013-09-18 18:44:57 -04:00
Colin Walters 4c1a69f74e main: Print error: in red bold just for fun
It's easier to see.  Also drop old dead ot_main() function.
2013-09-18 16:34:14 -04:00
Colin Walters 0818a462c2 sysroot: Look for booted deployment correctly
We need to look at the list we just gathered, not potentially NULL.
2013-09-17 10:53:41 -04:00
Colin Walters 8f1ea1b50a sysroot: Clean up API
Now that we have a real GObject for the sysroot, we have a convenient
place to keep track of 4 pieces of state:

* The current deployment list
* The current bootversion
* The current subbootversion
* The current booted deployment (if any)

Avoid requiring callers to pass all of this around and load it
piecemeal; instead the new thing is ostree_sysroot_load().
2013-09-16 18:32:13 -04:00
Colin Walters c07c84cb6f libostree: Use ostree_repo_create() rather than spawning subprocess
We have API now, yay!
2013-09-16 08:52:16 -04:00
Colin Walters b88c4b5c1c doc: Add some more OstreeSysroot docs 2013-09-15 22:44:25 -04:00
Colin Walters ac0154713d libostree: Make OstreeBootloader private
It was only temporarily public while functionality was being merged
down; that's done now.
2013-09-15 20:26:13 -04:00
Colin Walters 4abaf27e57 admin: Drop two uses of ostree_sysroot_get_path()
Moving towards it being a full library.
2013-09-15 20:21:49 -04:00
Colin Walters c6292942ff libostree: Nearly complete move of API into OstreeSysroot
Move the deployment code too.
2013-09-15 20:16:20 -04:00
Colin Walters 95f07d486a libostree: Move a lot more sysroot API here
OstreeBootloader is temporarily public API.
2013-09-15 18:08:06 -04:00
Colin Walters 6f929ca5af libostree: Move sysroot initialization API here 2013-09-15 15:16:56 -04:00
Colin Walters 35bab87691 Move Deployment and BootconfigParser into libostree
As part of moving admin functionality there.  While we are doing this,
rename OtConfigParser to OstreeBootConfig parser since it's a better
name.
2013-09-15 15:06:31 -04:00
Colin Walters af0f888057 libostree: Add new OstreeSysroot class
At the moment, just a container for a path, but we will start moving
admin functionality here.
2013-09-15 14:33:57 -04:00
Colin Walters d302c3d7ff checkout: Fix leak when doing uncompressed cache + copying checkouts
We were reading into "input" twice, leading a fd.  This was
breaking the gnome-continuous integrationtest.
2013-09-13 17:15:30 -04:00
Colin Walters 94e42c521c pull: Drop usage of 2.36 symbol
Really need deprecation warnings while using RHEL6.4...maybe Software
Collections will save me.
2013-09-13 16:45:43 -04:00
Colin Walters a9e82e71fa Update libgsystem
With tempfile fix.
2013-09-13 16:43:27 -04:00
Colin Walters 2e6b64d21b doc: Add OstreeMutableTree, other minor doc updates 2013-09-12 23:53:13 -04:00
Colin Walters ce0fbbfdee admin: Silence a gcc warning
It can't happen, but anyways.
2013-09-12 14:34:38 -04:00
Colin Walters 081da0033a COPYING: Now fully LGPLv2+
I ran into Jeremy Katz today, and he gave me permission to relicense
the small bits of switch-root.c to LGPLv2+.  This combined with
permission from Peter Jones allows OSTree to become fully LGPLv2+.

Not a big deal, it's just a lot clearer to only have one license, and
it makes it easier to turn application code into library code.
2013-09-11 19:57:05 -04:00
Colin Walters 6a01ec1032 checkout: Fix previous commit
Don't try to close in cases where we don't have input.
2013-09-11 11:54:53 -04:00
Colin Walters 0238a2c26c checkout: Fix file descriptor leak for copying checkouts
Hardlink checkouts didn't hit this, but we need to close the input
stream.
2013-09-11 10:58:22 -04:00
Colin Walters c8744beb17 Update libgsystem
And while we're here, also update the TODO slightly.
2013-09-11 08:28:09 -04:00
Colin Walters 27b46cb45c libostree: Fix compiler warning 2013-09-10 12:25:13 -04:00
Colin Walters 4f236ebc1b checkout: Add g_prefix_error() around more failures
So we can debug what's going wrong more easily.
2013-09-10 12:21:04 -04:00
Jasper St. Pierre fb1e140dba repo: Make the optimization for reusing checksums clearer
The code here is a bit hard to understand, so make it clearer by cleaning
up the flow control and adding some comments.

https://bugzilla.gnome.org/show_bug.cgi?id=707727
2013-09-09 23:00:41 -04:00
Jasper St. Pierre 223bccf2f6 repo: Make read_commit spit out a resolved commit ref as well
read_commit resolves the ref to a commit, and a lot of consumers want
the resolved commit for their own purposes; this prevents them from
calling resolve_rev themselves.

https://bugzilla.gnome.org/show_bug.cgi?id=707727
2013-09-09 22:58:39 -04:00
Jasper St. Pierre 6b4ef97c18 repo-libarchive: Apply commit modifiers to libarchive archives as well
And document the libarchive methods as well, so we can pass a NULL
commit modifier.

https://bugzilla.gnome.org/show_bug.cgi?id=707727
2013-09-09 22:51:43 -04:00
Jasper St. Pierre c7f9fc9c63 repo: Change the pairs of checksums to instead be based on OstreeRepoFiles
We want an OstreeRepoFile to be the way to reference a "filesystem
tree" that's stored in the repo, which is a combination of a DIR_TREE
and a DIR_META. The idea is that once you write an mtree to the repo
using ostree_repo_write_mtree, it becomes serialized and you get an
OstreeRepoFile in return.

Change any APIs that care about DIR_TREE / DIR_META checksums to care
about OstreeRepoFiles instead, which right now is mostly is
ostree_repo_write_commit.

https://bugzilla.gnome.org/show_bug.cgi?id=707727
2013-09-09 22:51:33 -04:00
Jasper St. Pierre 33db74d0ce repo-file: Base OstreeRepoFile on trees instead of commits
We want an OstreeRepoFile to be the way to represent a filesystem tree
inside an ostree repository. In order to do this, we need to drop the
commit from an OstreeRepoFile, and make that go to callers.

Switch all current users of ostree_repo_file_new_root to
ostree_repo_read_commit, and make the actual constructor private.

https://bugzilla.gnome.org/show_bug.cgi?id=707727
2013-09-09 22:31:59 -04:00
Colin Walters ac2d61dd51 core: Add detached metadata, readd metadata to commits
Previously I thought we'd have to ditch the current commit
format to avoid a{sv} due to

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

But I realized that we don't really have to care about
unpacking/repacking commit objects, so let's just re-expose the
existing metadata a{sv} in commits in the API.

Also, add support for "detached" metadata that can be updated at any
time post-commit.  This is specifically designed for GPG signatures.

https://bugzilla.gnome.org/show_bug.cgi?id=707379
2013-09-09 17:01:32 -04:00
Colin Walters b4b700c163 Update libgsystem
Now with new shiny implementation of gs_shutil_rm_rf().
2013-09-09 16:06:51 -04:00
Vivek Dasmohapatra f802822034 pull: ref the thread default main context during init, unref in cleanup
...get_thread_default returns NULL when the thread default is also the global
default, so this only shows up when running in a thread (eg g_task_run_in_thread)
2013-09-09 12:06:01 -04:00
Colin Walters 3ff4b1874c core: Use openat() for reading bare file objects too
...unless we want xattrs, in which case we have to fallback to path
lookup due to lack of llistxattrat().

This looks nicer in strace.
2013-09-08 19:31:44 -04:00
Colin Walters a071a3ec3a core: Delete unused OstreeRepoFile API
Was just unused, and it was using further API i want to remove.
2013-09-08 16:49:21 -04:00
Colin Walters d863ef5838 repo: Delete leftover repo/pending dir
This is a relic from long ago when we were trying to stage objects
before finally committing them all in one go in the pull code.

We're no longer doing that, so stop trying to make the directory.
This also fixes trying to use ostree as non-root to read the
root-owned repo, since we'd fail to create the pending dir.
2013-09-08 15:04:35 -04:00
Colin Walters 33e589c018 core: Use at-relative functions for checking out tree copies too
For the cases where we can't hardlink, use at-relative walking of the
path where possible.  We still don't have lsetxattrat, so we also need
to deal with pathnames, but that is now only for symlinks.

Again, the advantages of this are a lot less malloc() of pathnames in
ostree, and much less time spent traversing paths inside the kernel.

https://bugzilla.gnome.org/show_bug.cgi?id=707733
2013-09-08 14:42:50 -04:00
Colin Walters 0c2ea54e68 core: Make ostree_set_xattrs() private
Nothing external uses it.  We keep ostree_get_xattrs_for_file() public
because it's convenient for external consumers to get xattrs in
exactly the format we desire.

https://bugzilla.gnome.org/show_bug.cgi?id=707733
2013-09-08 14:41:51 -04:00
Colin Walters 27c3e7884e core: Make write_object() a bit more efficient
Do as many operations as we can using the original file descriptor
while we have it open, rather than writing, closing, then reopening.

This necessitated very explicitly special casing symbolic links,
mainly due to the lack of lsetxattrat().

https://bugzilla.gnome.org/show_bug.cgi?id=707733
2013-09-08 14:40:52 -04:00
Colin Walters 9846fb27fd core: Use linkat() for hardlink checkouts too
Clean up how we deal with the uncompressed object cache; we now use
openat()/linkat() and such just like we do for the main objects/.

Use linkat() between the objects and the destination, if possible.

https://bugzilla.gnome.org/show_bug.cgi?id=707733
2013-09-08 14:40:09 -04:00
Jasper St. Pierre db148cc9ba repo: Make the body parameter to ostree_repo_commit optional
https://bugzilla.gnome.org/show_bug.cgi?id=707727
2013-09-08 11:50:51 -04:00
Jasper St. Pierre 1f8db2a873 repo: Drop the branch parameter from ostree_repo_commit
It's unused. Make users explicitly write a ref if they want this;
high-level convenience API will be introduced later.

https://bugzilla.gnome.org/show_bug.cgi?id=707727
2013-09-08 11:50:51 -04:00
Jasper St. Pierre f49ed9e74d builtin-commit: Don't parse the parent's GVariant by hand
Instead, use OstreeRepoFile as a handle for the parent commit.
We need to add an accessor for the metadata checksum, as that
hasn't been exposed before.

https://bugzilla.gnome.org/show_bug.cgi?id=707727
2013-09-08 11:50:51 -04:00
Jasper St. Pierre 8ac0f99ed6 repo-file: s/content_checksum/contents_checksum/
This is what we call it everywhere else, so just be consistent.
It also lines up with metadata_checksum better.

https://bugzilla.gnome.org/show_bug.cgi?id=707727
2013-09-08 11:50:51 -04:00
Colin Walters 75225166da repo: Fix file descriptor leak from previous commit
I keep forgetting mmap doesn't take ownership of the fd.
2013-09-08 10:41:18 -04:00
Colin Walters 5a685ff989 core: Use at-relative lookups for archive-z2 content
We can't quite do it for bare repositories yet because we need to have
a way to go from struct stat -> GFileInfo, and that's buried in gio's
private GLocalFile class.
2013-09-07 10:10:21 -04:00
Colin Walters d2c6e19278 core: Use at-relative lookups for metadata reading
Just use openat() for locating variants, rather than doing the lstat()
+ open().  This also drops several malloc+object allocations from the
lookup path.
2013-09-07 05:03:48 -04:00
Colin Walters b97249d4f9 core: Use at-relative lookup for locating objects too
Add new internal API to both fstatat() and write a pathname for the
given object.  Use it in commit, and also wrapped in the old
GFile-based API.

This is more efficient.
2013-09-07 04:47:40 -04:00
Colin Walters a7c0992d94 core: Add malloc-free API for objects, use *at functions for storing
This is more efficient; we avoid malloc of a number of pathname +
GFile objects, plus the kernel doesn't have to traverse the repo path
again.
2013-09-07 04:18:41 -04:00
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