Commit Graph

1181 Commits

Author SHA1 Message Date
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
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 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
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
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
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
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
Jeremy Whiting e7f115d688 trivial-httpd: Close the socket when sending partial files
This will force the client to re-request them, which will be used to
test interrupted "ostree pull" requests.

https://bugzilla.gnome.org/show_bug.cgi?id=706344
2013-08-26 17:53:39 -04:00
Colin Walters edfa76fad5 main: Code cleanup by passing OstreeRepo * directly to builtins
It turns out every builtin (with one special exception) that takes a
repo argument did the same thing; let's just centralize it.  The
special exception was "ostree init --repo=foo" where foo is expected
to *not* actually be a repo.  In that case, simply skip the
ostree_repo_check() invocation.

https://bugzilla.gnome.org/show_bug.cgi?id=706762
2013-08-25 15:28:23 -04:00
Colin Walters 6c61b19107 libostree: Improve commit filter API
Make the structure private, and document the flags.

https://bugzilla.gnome.org/show_bug.cgi?id=706214
2013-08-25 15:23:23 -04:00
Colin Walters 94ce562905 pull: Drop obsoleted "related objects" API
We removed support for writing "related objects" from ostree commits
in ostree git c9b61cbfee because it just
didn't work out as an idea.  This also removes the API and code from
"ostree pull".

Note there was no test suite coverage.

https://bugzilla.gnome.org/show_bug.cgi?id=706342
2013-08-25 15:20:13 -04:00
Colin Walters b600ae5939 repo: Fix object storage size API to be 64 bit
This fixes a pointer size warning on 32-bit builds.

https://bugzilla.gnome.org/show_bug.cgi?id=706235
2013-08-25 15:19:54 -04:00
Colin Walters db4aecee44 pull: Update comment to better reflect current reality 2013-08-23 17:31:24 -04:00
Vivek Dasmohapatra 14c9f88e9c trivial-httpd: Handle the autoexit case when the docroot is a symlink 2013-08-23 12:39:24 -04:00
Vivek Dasmohapatra 3dc6cedba5 trivial-httpd: Close stdout & stdin so $() can capture output when daemonized
Will be used by tests.
2013-08-23 12:28:37 -04:00
Vivek Dasmohapatra 4f127b2d7d trivial-httpd: Handle -p - as meaning write-port-to-stdout
This is convenient to use from tests.
2013-08-23 12:28:33 -04:00
Vivek Dasmohapatra b6d77f6ad6 fetcher: Return NOT_FOUND when the HTTP code is 410 or 404
This will be used by the pull code to download optional data.
2013-08-23 12:15:49 -04:00
Colin Walters fe5dd07772 main: Drop --archive option from init, now that the code is removed
Commit 1ec7c30408 removed archive mode,
so this bit needs to be removed too.

https://bugzilla.gnome.org/show_bug.cgi?id=706327
2013-08-23 09:55:09 -04:00
Javier Martinez Canillas 695621db05 admin: notify detected bootloader configuration
OSTree now supports multiple bootloader backends so
notify which bootloader configuration was detected.

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

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
2013-08-22 07:37:21 -04:00
Colin Walters 000dd5add3 admin: Add API to OtBootloader to get name
https://bugzilla.gnome.org/show_bug.cgi?id=706548
2013-08-22 07:37:21 -04:00
Javier Martinez Canillas 6f6c87877e admin: Don't fail to deploy if there isn't a bootloader config
Currently, when deploying an OSTree that does not contain a
bootloader configuration it fails with the following message:

"No known bootloader configuration detected"

A bootloader configuration is not strictly necessary if the
bootloader used is able to parse /boot/loader/entries on boot.

So, failing to deploy seems to be a little harsh. It is better
to just not write the bootloader configuration if a previous
one was not found but still swap the bootversion.

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

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
2013-08-22 05:52:16 -04:00
Colin Walters 8abad0b452 admin: Write out correct version fields in boot/loader/entries files
Before, we were writing the "bootversion", which is either 0 or 1, for
all entries.  This is completely wrong; the idea of the "version"
field is to compare between entries.

Fix this by writing out the inverted index - internally, index 0 is
the *first* boot entry, so we give it the highest version number, and
index N is the last, so give it version 0.

Then fix the deployment sorting code to correctly reverse the version
number comparison, so we read back the right order.

In practice before this bug didn't matter because "normally" you only
have at most two deployments.

https://bugzilla.gnome.org/show_bug.cgi?id=706546
2013-08-22 05:46:11 -04:00
Colin Walters caf6be331b libostree: Check out directories depth-first in serial, switch to sync API
The way we recurse into subdirectories in parallel makes it far too
easy to hit up against the arbitrary Linux fd limit of 1024.

Since the fix here is about dropping parallelism, let's just go all
the way for now and make a plain old synchronous API =(

This does simplify both internal callers which wanted a sync API
anyways.

https://bugzilla.gnome.org/show_bug.cgi?id=706380
2013-08-21 09:22:37 -04:00
Javier Martinez Canillas 750a60d3aa main: Add U-Boot bootlader backend support
This patch adds support to generate files that
can be used by Universal Bootloader (U-Boot).

U-Boot allows to modify boards default boot commands by
reading and executing a bootscript file or importing a
plain text file that contains environment variables that
could parameterize the boot command or a bootscript.

OSTree generates a uEnv.txt file that contains booting
information that is taken from Boot Loader Specification
snippets files as defined in the new OSTree deployment model:

https://wiki.gnome.org/OSTree/DeploymentModel2

On deploy or upgrade an uEnv.txt env var file is created
in the path /boot/loader.${bootversion}/uEnv.txt. Also, a
/boot/uEnv.txt symbolic link to loader/uEnv.txt is created
so U-Boot can always import the file from a fixed path.

Since U-Boot does not support a menu to list a set of
Operative Systems, the most recent bootloader configuration
from the list is used.

To boot an OSTree using the generated uEnv.txt file, a
board has to parameterize its default boot command using the
following variables defined by OSTree:

${kernel_image}:  path to the Linux kernel image
${ramdisk_image}: path to the initial ramdisk image
${bootargs}:      parameters passed to the kernel command line

Alternatively, for boards that don't support this scheme,
a bootscript that overrides the default boot command can be used.

An example of such a bootscript could be:

setenv scriptaddr 40008000
setenv kernel_addr 0x40007000
setenv ramdisk_addr 0x42000000
ext2load mmc 0:1 ${scriptaddr} uEnv.txt
env import -t ${scriptaddr} ${filesize}
ext2load mmc 0:1 ${kernel_addr} ${kernel_image}
ext2load mmc 0:1 ${ramdisk_addr} ${ramdisk_image}
bootm ${kernel_addr} ${ramdisk_addr}

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>

https://bugzilla.gnome.org/show_bug.cgi?id=706370
2013-08-20 13:00:46 -04:00
Javier Martinez Canillas cf14b398da admin: Extract ot_admin_join_config_lines() helper function
ot-bootloader-syslinux.c has a join_lines() function that is rather
generic and can be used in other places. Let's add it as a helper
function.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>

https://bugzilla.gnome.org/show_bug.cgi?id=706370
2013-08-20 13:00:19 -04:00
Colin Walters 871be4b75a libostree: Extend gtk-doc coverage for refs and prune APIs 2013-08-19 10:32:08 -04:00
Colin Walters 16c36fbc34 main: Use macro to reduce duplication among builtin prototypes
Just less code.
2013-08-19 10:32:08 -04:00
Colin Walters 326be41d12 Revert "libotutil: Make use of GBytes in ot_variant_read()"
This reverts commit c77908bf514d61e75798932f61b5b414d9e36a3c; we can't
do this since g_variant_get_data_as_bytes() is a GLib 2.36 API.
2013-08-18 07:51:25 -04:00
Colin Walters b35840e1b8 libotutil: Drop accidental use of GLib 2.36 API
Sticking with 2.34 for a while longer.
2013-08-18 07:50:50 -04:00
Colin Walters eaee309112 Use { 0, } for structure initialization rather than memset()
It's cleaner, safer, and I had a totally wrong idea stuck in my head
about why memset() should be used.

https://bugzilla.gnome.org/show_bug.cgi?id=705968
2013-08-18 07:20:46 -04:00
Sjoerd Simons e5d9bd97aa ostree init: Fix mode list help string
It's archive-z2, not archive-z.

https://bugzilla.gnome.org/show_bug.cgi?id=705849
2013-08-17 15:05:04 -04:00
Colin Walters 00c352ba67 libostree: Delete some leftover remnant API for archive files 2013-08-17 14:08:04 -04:00
Colin Walters 35d7b9cdbf libostree: Increase gtk-doc coverage of ostree-repo.[ch] 2013-08-17 13:57:22 -04:00
Colin Walters 1fea88e64b libostree: Add gtk-doc section for ostree-repo.c 2013-08-17 13:22:58 -04:00
Colin Walters 0f9d7d2179 libostree: More gtk-doc updates for ostree-core 2013-08-17 10:54:00 -04:00
Colin Walters abe2320039 libostree: Fix many gtk-doc warnings 2013-08-17 08:41:31 -04:00
Colin Walters 06d1a56bc9 core: Drop duplicated type declarations
3 fewer gtk-doc warnings, 99 still left on the wall...
2013-08-17 08:23:28 -04:00
Colin Walters c3121b52bc libostree: Document more core macros 2013-08-17 08:21:04 -04:00
Stef Walter 349d7958f3 Fix use of uninitialized memory in ostree_builtin_checksum()
https://bugzilla.gnome.org/show_bug.cgi?id=705968
2013-08-17 07:07:54 +02:00
Colin Walters 1ec7c30408 core: Remove old "archive" mode
We'll always have "bare" mode for keeping files-as-hardlinks as root.
But "archive" was my second attempt at a format for non-root file
storage, used by the gnome-ostree buildsystem which runs as non-root.

It was really handy to have a "tar" like mode where I can create
tarballs as a user, that contain files owned by root for example.

The "archive" mode stored content files as two pieces in the
filesystem; ".file" contained metadata, and ".filecontent" was the
actual content, uncompressed.  The nice thing about this was that to
check out a tree as non-root, you could just hardlink into the repo.

However, archive was fairly bad for serving via HTTP; it required
*two* HTTP requests per content object, greatly magnifing the already
inefficient fetch process.  So "archive-z2" was introduced.

To allow gnome-ostree to still check out trees as a user, the
"uncompressed-object-cache" was introduced, and that's how things have
been working for a while.

So we should just be able to kill this code.  Specifically note just
how much better the stage_object() function became.

https://bugzilla.gnome.org/show_bug.cgi?id=706057
2013-08-16 22:56:42 -04:00
Colin Walters 17560a57bf Add gtk-doc support
Yes, it's really me.  Colin Walters.  Writing documentation.  You
don't need to do a DNA test.
2013-08-16 22:56:12 -04:00
Stef Walter f9b2c45fc0 Add 'ostree reset' command to undo a bad commit
Accepts the following arguments: ref checksum

Checks that the checksum is a parent of the ref before rewriting
the ref.

https://bugzilla.gnome.org/show_bug.cgi?id=705979
2013-08-16 17:28:43 +02:00
Sjoerd Simons a00eb681a0 Install systemd units in the right location
Debian uses /lib/systemd/system for system unit files, while i'm
putting ostree under the /usr prefix which means the hardcoded path
fails. Leave it to configure to work out the right location for systemd
units (method copied from pollkit).

Furthermore instead of installing the unit in local-fs.target.wants by
hand add a [Install] section so systemctl enable does the right thing

https://bugzilla.gnome.org/show_bug.cgi?id=705864
2013-08-15 18:28:04 -04:00
Colin Walters a04bda126c core: Use gs_stream_fstat()
Just a cleanup.
2013-08-15 14:21:26 -04:00
Colin Walters 6bb4ea46ab core: Add some more gtk-doc 2013-08-15 11:17:16 -04:00
Colin Walters 1f35655ac1 core: Add some gtk-doc
Just documenting a few functions to get in the habit of things.
2013-08-15 07:04:29 -04:00
Stef Walter 3989e0d397 Add 'ostree log' command
Follows the parent of commits showing each in turn until it reaches
the top of the commit tree.

https://bugzilla.gnome.org/show_bug.cgi?id=705973
2013-08-15 07:01:30 +02:00
Stef Walter 5efb8e86e9 Add ostree_commit_get_parent() to get parent from variant
https://bugzilla.gnome.org/show_bug.cgi?id=705973
2013-08-15 06:52:53 +02:00
Stef Walter 790132a81a Intelligible display for 'ostree show'
Show something similar to git metadata display. Show raw variant
data when --raw is specified

https://bugzilla.gnome.org/show_bug.cgi?id=705973
2013-08-15 06:48:25 +02:00
Colin Walters 11bdbe1fb8 repo: Add API to load any object as a stream
We have APIs to load metadata as variants, and files as parsed
content/info/xattrs, but for some cases such as static deltas, all we
want is to operate on all objects in their canonical representation.

https://bugzilla.gnome.org/show_bug.cgi?id=706031
2013-08-14 21:50:37 -04:00
Colin Walters c77908bf51 libotutil: Make use of GBytes in ot_variant_read()
This is just cleaner; we avoid using GObject data, etc.

https://bugzilla.gnome.org/show_bug.cgi?id=706031
2013-08-14 19:55:34 -04:00
Colin Walters d9f59c6fd5 core: Add API to convert checksum -> csum in place
We already have the opposite, and this will be used in some
places to avoid a malloc.

https://bugzilla.gnome.org/show_bug.cgi?id=706031
2013-08-14 19:49:54 -04:00
Colin Walters 76cd7ae4ea libotutil: Add API to create an "ay" GVariant from GBytes
We used to have a version of this, but since I'm trying to use
GBytes more, this became a more common operation, and it's annoying
to type out the whole G_VARIANT_TYPE ("ay") each time, and pass
TRUE for trusted.

https://bugzilla.gnome.org/show_bug.cgi?id=706031
2013-08-14 19:23:33 -04:00
Jeremy Whiting 71f6f10cd2 trivial-httpd: Add --force-range-requests option to force range requests
This will be used to test resuming interrupted downloads for
ostree-pull.

With this option, if a whole file is asked for, only half of the file
is given.  Then the client should retry with a range request, and
we'll give them the other half.

https://bugzilla.gnome.org/show_bug.cgi?id=705925
2013-08-14 17:33:23 -04:00
Colin Walters 61773f6ca4 core: Add a comment header about the format
This should probably be a design document or something, but this is
useful for now.
2013-08-14 17:35:46 +02:00
Stef Walter 1904e3e0f4 Don't pass non-checksums to ostree_repo_has_object()
The 'ostree show' command passed non-checksum arguments
to the ostree_repo_has_object() function which led to
an assertion.

https://bugzilla.gnome.org/show_bug.cgi?id=705967
2013-08-14 16:08:18 +02:00
Colin Walters 8c31e6fda7 tests: Add xattr test case
Since it was broken up until now for multiple attributes =(
2013-08-14 15:07:14 +02:00
Stef Walter 860cc11160 Fix crasher when running 'ostree cat'
Cause was a buffer read overrun.

https://bugzilla.gnome.org/show_bug.cgi?id=705964
2013-08-14 14:53:17 +02:00
Stef Walter 97947373ee Add some verbose log output when xattr functions fail
If any of the system xattr functions fail, clearly write out the
reason in the verbose log output.

https://bugzilla.gnome.org/show_bug.cgi?id=705893
2013-08-14 07:50:49 +02:00
Stef Walter 3f9c150b77 Don't use XATTR_REPLACE with lsetxattr()
If we pass XATTR_REPLACE then the attribute must already exist, which
is not our intent. Passing zero creates the attribute if necessary,
or replaces it when it already exists.

https://bugzilla.gnome.org/show_bug.cgi?id=705893
2013-08-13 15:42:54 +02:00
Stef Walter c246c4194f Properly separate sorted xattr names
We expect to be handling a string delimited by \0 characters, as
returned by llistxattr(). So stick to that behavior here.

https://bugzilla.gnome.org/show_bug.cgi?id=705893
2013-08-13 15:42:54 +02:00
Stef Walter 0111ec1307 Add some verbose logging to 'ostree commit'
This is so we can see near which file we fail when 'ostree commit'
falls over.

https://bugzilla.gnome.org/show_bug.cgi?id=705905
2013-08-13 15:38:51 +02:00
Stef Walter 462bcd86de Add --verbose and -v arguments to ostree for details
Use the GLib debug mechanism to handle verbose output.

https://bugzilla.gnome.org/show_bug.cgi?id=705905
2013-08-13 15:37:12 +02:00
Stef Walter 1f8c7a2524 Better parsing for global ostree options
* Specifying global options after the command for a more natural:
   # ostree commit --repo=/path/to/repo ...
 * Support asking for --help without --repo
   # ostree commit --help
 * Support short form of -h
 * Support specifying --repo without equals sign
   # ostree --repo /path/to/repo commit ...
 * Support global --help and -h
   # ostree --help
 * Ditto for ostree admin sub commands
 * Removed some leaky code

https://bugzilla.gnome.org/show_bug.cgi?id=705903
2013-08-13 14:28:36 +02:00
Colin Walters 44012dbdd9 Update libgsystem
With fd leak fix.
2013-08-07 10:36:52 +02:00
Colin Walters 71c4ea67f7 core: Clean up temporary file creation
Use new libgsystem API, don't expose the repo's tmpdir.
2013-08-06 23:58:29 +02:00
Colin Walters 9e480cd6a9 core: Finish making object path API private
This allows us to more easily change the internals later.
2013-07-31 03:48:33 -04:00
Colin Walters 0dec1b287c core: Reduce API surface for file access
This function was only used by internals, make it private.
2013-07-31 00:35:53 -04:00
Colin Walters 8d5b8dd740 admin: Clean up builtin prototype
Pass through GCancellable, and just use GFile *sysroot, since that's
all OtAdminBuiltinOpts was.
2013-07-29 18:44:41 -04:00
Colin Walters 760b866104 main: Assume / for ls if no path given
Since it just is kind of a sane default.
2013-07-27 20:12:07 -04:00
Colin Walters 7c5c3f2af8 core: Fix all introspection warnings
Still lots more docs to write and API to cleanup, but this is better.
2013-07-27 10:13:30 -04:00
Colin Walters a5d43bb959 Install a shared library
This required a fair bit of surgery because previously ostree.h
included otutil.h, but that's supposed to be a private library.
2013-07-26 19:25:07 -04:00
Colin Walters 74b2c7aab3 core: Work around libguestfs/FUSE issue with setuid binaries
For some reason, the setuid bits are being stripped.  This
workaround is enough for now.
2013-07-26 14:48:15 -04:00
Colin Walters 5aea9db3f2 Add API to retrieve statistics from transactions, use it in commit
It's just interesting to see =) This is also kind of prototyping out
some more "structured" output.
2013-07-25 19:23:25 -04:00
Colin Walters 8aa48a5f9c fsck: Fix crash on repositories with < 10 objects 2013-07-25 12:06:21 -04:00
Colin Walters 2bcb024824 pull: Tweak status line again, do what git does
Almost, we don't have bytes transferred.  And we lie about percentages
since as metadata comes in the total number of objects to fetch goes
up.
2013-07-24 18:20:19 -04:00
Colin Walters 89430bbe71 main: Fix previous commit to find repo in cwd over /ostree/repo
The tests when run inside gnome-ostree broke, and this is better
behavior.
2013-07-24 14:46:53 -04:00
Colin Walters 187c75eae5 main: Support using repo from current directory
$ cd repo
$ ostree ls foo /
...

Can be a lot more convenient than typing --repo=repo a lot.
2013-07-24 14:05:12 -04:00
Colin Walters c9b61cbfee Drop support for related objects and metadata in commit objects
While the actual commit object format is presently the same, for a
number of reasons we'd like to change it fairly radically.  Among
other things, we need to drop our a{sv} types in objects, to protect
against GVariant changing format.

Since now gnome-ostree now longer uses related objects, and nothing
ever used metadata, just drop them both.
2013-07-24 12:59:27 -04:00
Colin Walters 1e7c0bb70b main: Fix an uninitialized variable 2013-07-24 09:36:51 -04:00
Colin Walters 688d8f176b pull: Always scan for commit object, even if ref is unchanged
If the admin encounters corruption and does:

$ ostree admin fsck --delete

We want them to be able to recover the objects easily from the
network; with this patch, they do:

$ ln -s dummyvalue /ostree/repo/transaction
$ ostree refs --delete remotename:branchname
$ ostree pull remotename

This patch avoids the need for the refs --delete; we might as well
force scan the commit, and with this patch we still print that it
changed.
2013-07-23 19:36:15 -04:00
Colin Walters 3ea62abe75 main: ls: Behave like standard Unix "ls" with directories
Default to listing directory contents, add -d/--dironly to suppress
this.
2013-07-23 18:41:03 -04:00
Colin Walters 4de1d51266 main: Squash a compiler warning 2013-07-23 18:34:34 -04:00
Colin Walters 7b056e3c50 main: Consistently use "opt_" as a prefix for option local variables
This makes it easier to find where we're using global state, which is
useful when refactoring code into libostree.
2013-07-23 18:33:29 -04:00
Colin Walters b6ab480272 main: commit: Drop broken --parent option
No idea why we had this, it didn't do anything in the current code.
Noticed while doing other refactoring.
2013-07-23 18:24:52 -04:00
Colin Walters 3b9da094d8 main: Drop log builtin
We may revive this later, but commits in their current form aren't
very useful for humans to read, so it doesn't make sense to have a
tool to show a history of useless stuff.

More interesting things are diffs between commits, object statistics,
etc.
2013-07-23 18:19:14 -04:00
Colin Walters ea914e7e49 main: pull: Reduce the status line length a bit
Drop "objects" where it's obvious [ to me anyways =) ], and drop the
bytes transferred since our math was off, and the HTTP status kind of
shows that.
2013-07-23 17:29:46 -04:00
Colin Walters 3d7bff2d41 admin: Add an "undeploy" command
Otherwise it's really easy to keep accumulating deployments.  Also, we
may want to run this after rebooting, so we're back down to one
operating system.
2013-07-23 09:19:24 -04:00
Colin Walters 67823beb1f core: Don't strip setuid bits when creating files
This ugly regression occurred because I overlooked the fact that our
chown() invocation would strip off setuid.
2013-07-18 14:23:55 -04:00
Colin Walters 3e2d2f3e9e main: show: Don't strip mode, let's see the whole thing
Just useful for debugging.
2013-07-18 14:23:12 -04:00
Colin Walters f0c5a5f334 main: Add --delete option to fsck
This is useful for clearing out all corrupted objects locally.
2013-07-18 12:09:44 -04:00
Colin Walters c8801ae489 main: Clean up fsck code: honor --quiet, warn (but continue) on missing objects
When we make fsck --delete work again, it will be convenient to
continue on missing objects.
2013-07-18 09:05:58 -04:00
Colin Walters a4f5ad8542 Update libgsystem 2013-07-17 23:00:03 -04:00
Colin Walters 41cb37a858 main: Make "ostree show" actually useful for files
We already have "ostree cat" for files, here we want to see a dump of
the metadata.
2013-07-17 21:10:04 -04:00
Colin Walters 1b3ef57cf4 diff: Add --stats option
This a neat way to see how many objects are shared between two
commits.
2013-07-17 19:20:53 -04:00
Colin Walters a3b6401788 main: Add --link-checkout-speedup option to commit
And disable devino scan by default.  For the gnome-ostree build case,
our commits are from "make install DESTDIR=", so they won't be
hardlinks into the repo.  In that case, particularly as the repository
size grows, the cost of building up the devino -> checksum mapping
becomes a problem.

The compose step will use this option though.
2013-07-17 19:20:53 -04:00
Colin Walters aac52cb9f7 main: Move GCancellable to toplevel
This is just cleaner, and makes the builtins slightly more of a
library, which in turn makes it easier to turn them into real API.
2013-07-16 18:13:39 -04:00
Colin Walters 272274f0af prune: Don't fail if a to-be-pruned object doesn't exist
Previously, if a prune was interrupted, further attempts would fail.
It's just better to silently continue here.
2013-07-16 10:01:58 -04:00
Colin Walters 62a896350b Drop support for fifos and devices
While the first was useful way back in the day when we were importing
Debian bits and /sbin/init was expecting to find /dev/.initctl as a
named pipe, that's no longer an issue with systemd since it uses
dynamic Unix sockets.

Likewise, character and block devices in /dev are now dynamically
created by the devtmpfs from the kernel.

Less complexity and code here if we just support directories, regular
files, and symbolic links.
2013-07-16 09:35:44 -04:00
Colin Walters 8724565291 core: Drop a leftover unnecessary #define _GNU_SOURCE
We now use AC_USE_SYSTEM_EXTENSIONS.
2013-07-16 09:22:42 -04:00
Colin Walters 444234e7db core: Use gsystem API for generating temporary names
Drops duplicated code.
2013-07-16 08:51:53 -04:00
Colin Walters acdf1ca4fe core: Use gs_file_create()
This allows us to drop a chmod() invocation, since the regular file
path was the only thing that didn't handle mode.
2013-07-16 08:51:53 -04:00
Colin Walters ed55998f36 Update libgsystem 2013-07-16 08:51:53 -04:00
Colin Walters fb93b95807 admin: Rename prune -> cleanup, avoid doing repo prune twice
Calling it "cleanup" is better since it does more than repo pruning.

We were also doing a prune twice; ot_admin_cleanup() already does one,
so drop the bits to do it in cleanup.c.
2013-07-15 16:13:12 -04:00
Colin Walters d5f1ce4e17 admin: Initialize sysroot to / by default, not garbage from the stack
Oops.
2013-07-11 17:29:04 -04:00
Colin Walters 60f5183298 admin status: Print out origin too
This is useful data.
2013-07-11 17:07:14 -04:00
Colin Walters e95935a3f6 main: Also make ostree admin foo --help work
A followup for the previous commit.
2013-07-10 18:42:58 -04:00
Colin Walters b7460cf0b6 main: Only parse options in subcommands
This makes e.g. "ostree commit --help" work, which is really good.
2013-07-10 18:23:52 -04:00
Colin Walters be2bebaf3e main: Don't look for /sysroot/ostree too
No longer necessary now that we expect OS/ trees to have
/ostree -> /sysroot/ostree.
2013-07-10 18:13:55 -04:00
Colin Walters 124416d832 Use AC_USE_SYSTEM_EXTENSIONS instead of #define _GNU_SOURCE
It's less copy/paste, works everywhere, etc.

Also fix some missing #include "config.h".
2013-07-10 13:25:35 -04:00
Colin Walters 8cb348315e main: Print "error: " prefix on errors
It's just clearer that something went wrong.
2013-07-10 13:25:15 -04:00
Colin Walters 32d2cd57c1 admin: Add a warm fuzzy message to deploy about transactions
Since it sounds cool and stuff.
2013-07-10 02:30:26 -04:00
Colin Walters 12c76188c0 Delete leftover kernel update hooks 2013-07-09 20:38:05 -04:00
Colin Walters 89181c4e8e Build without libsoup again 2013-07-09 20:35:15 -04:00
Colin Walters 88cca89317 ostree: Some header file cleanups 2013-07-09 20:30:00 -04:00