Commit Graph

1123 Commits

Author SHA1 Message Date
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
Colin Walters 45c7536697 cmd: Drop "ostree admin install" and curl fetcher
It isn't useful at the moment, since the deploy stuff all changed.  It
will make sense to bring back later, but for now let's not carry
broken untested code.
2013-07-09 20:18:29 -04:00
Colin Walters 2535f32c56 libostree: Move pull code into here
More library work.
2013-07-09 20:14:53 -04:00
Colin Walters 5dd0d5da40 libostree: Move prune into OstreeRepo namespace
More library work.
2013-07-09 20:05:31 -04:00
Colin Walters 2aa0251b1b libostree: Rename ostree-traverse.h into OstreeRepo namespace
This operates on the repo, it might as well be methods on it.
2013-07-09 19:59:39 -04:00
Colin Walters cb6b69616c libostree: Split off -refs.c
Continuing to break up ostree-repo.c.
2013-07-09 19:49:00 -04:00
Colin Walters 3b6a94d272 libostree: Split off libarchive code 2013-07-09 19:11:37 -04:00
Colin Walters dbffd31017 libostree: Start splitting up the monstrous ostree-repo.c
Checkout now lives in its own file.
2013-07-09 19:02:38 -04:00
Colin Walters 5ad0671cd2 Switch to #pragma once for headers
It's just less tedious, and we're GCC/LLVM specific anyways.
2013-07-09 18:53:22 -04:00
Colin Walters 7f48c77204 pull: Explicitly use thread-default main context
As preparation for pushing our own temporary context.
2013-07-09 18:46:00 -04:00
Colin Walters 13e33cd76b admin: Use internal pull API instead of subprocess
So we're doing more of the library thing.
2013-07-09 18:34:05 -04:00
Colin Walters 4c2a8bc210 pull: Destroy queue watching GSource
When being more of a library, we can't leave garbage attached to the
default main context.
2013-07-09 18:33:30 -04:00
Colin Walters b18e21be1d core: Move pull logic into an API
The general trend should be becoming more of a shared library with
command line wrappers.
2013-07-09 17:58:03 -04:00
Colin Walters a181310a49 pull: Add "tls-permissive" config option to disable SSL/TLS certificate checks
Like GIT_SSL_NO_VERIFY=true, available for the same reasons.
2013-07-09 15:40:20 -04:00
Colin Walters 7092e88eac pull: Verify SSL/TLS certificates against system CA file by default
We also need a mechanism like GIT_SSL_NO_VERIFY...probably an option
in the config.
2013-07-09 15:02:48 -04:00
Colin Walters b5b2aca592 prepare-root: Don't be strict about the sysroot mount name here
While the systemd integration effectively requires /sysroot, it will
help people trying to use OSTree with other initramfs systems
(e.g. initramfs-tools) if we don't hardcode that requirement in this
tool.
2013-07-09 12:04:02 -04:00
Colin Walters 43d69ac8a3 tests: Drop numeric prefix
Theoretically it's useful to have layers of tests, but in practice
it's just annoying to assign numbers.
2013-07-09 10:41:07 -04:00
Colin Walters 56f8584fe4 repo: Store transaction file, use it to optimize for pull resumes
If pull is interrupted, we may have downloaded an arbitrary subset of
the requested objects.  Previously, we handled this by scanning for
all objects each time.

However, there's an easy optimization - this patch creates a lock file
in the repo.  If we don't see that file when starting a pull, we know
we don't need to stat() every file; presence of a dirtree object for
example implies the existence of everything it references.
2013-07-08 09:05:34 -04:00
Colin Walters 305cd02e0c Drop obsolete GRUB2 and kernel update hooks
We only support syslinux at the moment; grub2 should learn to parse
the bootloader spec.
2013-07-07 21:56:54 -04:00
Colin Walters 53dcb3a68d Remove stub daemon code
This really shouldn't have lived so long...it does nothing now, and we
should probably just be exposing an API for packagekit anyways.
2013-07-07 18:14:53 -04:00
Colin Walters 26cef497a6 Remove built in "triggers"
Originally, the idea was that clients would replicate "OS/tree"s from
a build server, but we'd run things like "ldconfig" on the client.
This was to allow adding e.g. the nVidia binary driver.

However, the triggers were the only thing in the system at the moment
that really had expected knowledge of the *contents* of the OS, like
the location of binaries.

For now, it's architecturally cleaner if we move the burden of
triggers to the tree builder (e.g. gnome-ostree or RPM).  Eventually
we may want OSTree to assist with this type of thing (perhaps
something like RPM %ghost), but this is the right thing to do now.
2013-07-07 14:37:59 -04:00
Colin Walters f6bca20551 admin: Fix various compiler warnings 2013-07-07 14:30:01 -04:00
Colin Walters c66148160c admin: Also delete unsed boot directories
My VM filled up /boot.  Oops.
2013-07-07 13:45:18 -04:00
Colin Walters 1fa1443bae admin: Split up the monstrous ot-admin-functions.c
Now util, cleanup, and functions.
2013-07-07 12:42:02 -04:00
Colin Walters 4b170d656c Switch to libgsystem local allocation macros
And drop our compatibility wrapper.
2013-07-07 12:27:44 -04:00
Colin Walters bb6eedfb25 [INCOMPATIBLE CHANGE] Implement new deployment model
See https://wiki.gnome.org/OSTree/DeploymentModel2

This is a major rework of the on-disk filesystem layout, and the boot
process.  OSTree now explicitly supports upgrading kernels, and these
upgrades are also atomic.

The core concept of the new model is the "deployment list", which is
an ordered list of bootable operating system trees.  The deployment
list is reflected in the bootloader configuration; which has a kernel
argument that tells the initramfs (dracut) which operating system root
to use.

Invidiual notable changes that come along with this:

1) Operating systems should now come with their etc in usr/etc; OSTree
   will perform a 3-way merge at deployment time, and place etc in
   the actual root.  This avoids the need for a bind mount, and is
   just a lot cleaner.
2) OSTree no longer bind mounts /root, /home, and /tmp.  It is expected
   that the the OS/ has these as symbolic links into /var.

At the moment, OSTree only supports managing syslinux; other
bootloader backends will follow.
2013-07-07 11:31:26 -04:00
Colin Walters ecb3f0de03 deploy: Error out if we see usr/etc
This version of the code doesn't know what to do with new-model trees,
so just abort if we see that.  We'll likely never care about upgrades
from 1.0 to 2.0.
2013-07-05 17:29:07 -04:00
Colin Walters e8cba55a34 core: Allow '.' in refspecs too
For version numbers.
2013-07-05 16:51:47 -04:00
Colin Walters ec21dc4242 Add "trivial-httpd" builtin, use it in tests
A simple HTTP server implementation is so few lines of code when one
is linking to libsoup anyways, so let's just have one here in ostree
that will be used for the test suite.

This allows us to run the archive tests that previously required
apache even in gnome-ostree.
2013-07-05 16:28:40 -04:00
Colin Walters a93f2b8d16 pull: Make fetcher work for file:/// URIs too
Even if very suboptimally, for now; we copy the files, then copy them
again.

The obvious long term plan is to merge pull-local and pull together,
but truly optimizing that requires the pull code to know how to use
the OstreeRepo APIs when operating on local repositories (as
pull-local does), rather than assuming the remote is an archive-z
fetched over HTTP.
2013-07-01 22:43:17 -04:00
Colin Walters dc0f3c3dcb Add support for deleting refs
The internal API will be used by admin, and "ostree refs --delete"
is handy for interactive management.
2013-07-01 15:41:27 -04:00
Colin Walters 5b3fca8426 Add "refs" builtin
This is just useful to look at before pruning, etc.
2013-06-29 14:51:08 -04:00
Colin Walters 613f57007c Extract prune logic into an internal API
This will be used by ostree admin deploy.
2013-06-29 13:49:34 -04:00
Colin Walters a167bb7342 pull-local: Support --remote argument
For offline upgrades, pull-local can now write the refs into a
specific remote, rather than using the local heads.
2013-06-29 13:00:42 -04:00
Colin Walters 1ba852ebaa core: Add "refspec" which is remote:refname
This allows an unambiguous reference; otherwise, it was too easy to
have confusion between local heads and remotes.
2013-06-29 12:51:29 -04:00
Colin Walters e3dc0c91df gioutils: Many new utility functions
Reading symbolic links becomes a much more common thing now.
2013-06-29 12:51:29 -04:00
Colin Walters f6946a368f prepare-root: Only bind mount /home, /tmp, /root if they are directories
What we expect for new systems is for these to be symbolic links:
/home -> /sysroot/home
etc.
2013-06-23 17:56:14 -04:00
Colin Walters 7bb20b0533 core: Port more callsites to gs_file_enumerator_iterate()
See previous commit.
2013-06-14 19:45:40 -04:00
Colin Walters fbd9f17e39 core: Update libgsystem, port some uses of GFileEnumerator
This makes the code *so* much nicer.
2013-06-14 19:14:35 -04:00
Colin Walters c57e63a515 pull-local: Fix race condition pointed out by Benjamin
We could drop into g_main_loop_run() after the worker
thread had called g_main_loop_quit().

Fix this by following the pattern suggested by Ryan of a while loop
around our termination condition, and g_main_context_iteration().
2013-06-08 14:15:43 -04:00
Colin Walters 3e1e26352f pull-local: Fix race condition
https://bugzilla.gnome.org/show_bug.cgi?id=701861
2013-06-08 12:58:44 -04:00
Colin Walters 7e882cc2cf dracut: Add ostree-remount
Linux creates a copy of the soure mount flags when creating a bind
mount; if the source is read-only, then the bind mount is.

The problem is that systemd will remount the rootfs read/write, but
each mount (/home, /var etc.) will still be read-only.  We need to
remount every bind mount except for /usr to read-write too.

This only "worked" with the old ostree-switch-root because it
effectively force mounted the rootfs read-write always, ignoring the
"ro" flag.
2013-06-04 15:59:52 -04:00
Colin Walters 26baee6c3b dracut: Also ensure we're using the systemd module
I can't work out how this happens otherwise in Fedora...
2013-06-03 20:49:07 -04:00
Colin Walters 6496abacbd Add --with-dracut
This installs a Dracut module which parses the ostree= kernel command
line argument, and if given, sets up the OS/ at /sysroot, which
systemd's switch-root then moves into.  This only works if dracut is
configured to use systemd itself.
2013-06-03 15:28:09 -04:00
Colin Walters 35df7a7eb4 ostree-prepare-root: Don't require an extraneous argument 2013-06-02 22:19:24 -04:00
Colin Walters 8eaaea795c ostree-prepare-root: Parse /proc/cmdline, make RPRIVATE, set up /sysroot
This does everything we need except for the actual switch-root.
2013-06-02 21:41:08 -04:00
Colin Walters 1e080b9c73 ostree-prepare-root: New binary, used for systemd-in-initramfs setups
Rather than attempting to hack up the "switch-root" functionality of
systemd, this binary allows us to simply prepare the root before we
switch into it.
2013-06-02 15:39:20 -04:00
Colin Walters 16157c61af Drop support for generating initramfs images client side using dracut
This is the responsibility of whatever is generating filesystem trees.
2013-05-31 13:09:27 -04:00
Colin Walters ba5fc5cbcc Fold ostree-pull into main binary
The rationale for the separation was always kind of weak; I want to
refactor the command line argument parsing, and it was complicating
things.
2013-05-30 19:26:48 -04:00
Colin Walters 86e504ba1d pull: Exit cleanly with an error on failure to fetch refs 2013-05-27 09:29:33 -04:00
Colin Walters fab160562d upgrade: Actually prune deployments again
That was a rather critical logic error...
2013-05-27 09:29:05 -04:00
Colin Walters 0852362efa upgrade: Actually deploy upgraded tree again
I need a brown paper bag for this one...
2013-05-16 15:38:17 -04:00
Colin Walters f9484e9bab admin: Add -r option to upgrade to initiate a reboot if tree changes
$ ostree admin upgrade -r

is convenient to fire off inside a VM and come back to it later.
2013-05-16 08:29:20 -04:00
Colin Walters 18af230e17 upgrade: Don't require specification of osname
Since this is a highly visible command, let's have a sane default and
upgrade the currently running OS.
2013-05-15 08:18:53 -04:00
Colin Walters 82f444020e Add a --version argument that also outputs features
And use it in the tests to skip libarchive tests when the build
doesn't support it.
2013-05-01 19:15:06 -04:00
Colin Walters c60c70e9a9 checkout: Add --allow-noent option
This is useful for the gnome-ostree build system where each build is
one commit, but it's split up into /runtime /devel /debug etc. trees.
Ideally we wouldn't have a /debug subdirectory for "noarch"
components for example.

So add an option to not error out if the given path doesn't exist in
the commit.
2013-05-01 12:15:02 -04:00
Colin Walters f4327cc6a0 repo: Fix race condition in async checkout
When multiple threads need to uncompress an object, there was
a race condition where thread A could get EEXIST, unlink,
then thread B calls linkat(), then thread A tries to link() but
fails.

We can just loop in this case.
2013-04-30 19:34:20 -04:00
Colin Walters 8e4b296a96 libotutil: Drop is-hidden from fast queryinfo
Since now we look at .hidden files and bang on the mainloop for every
file lookup if that's specified =(
2013-04-29 22:08:56 -04:00
Colin Walters c110680f5d libgsystem: Update to latest 2013-04-29 14:04:48 -04:00