Commit Graph

1181 Commits

Author SHA1 Message Date
Colin Walters b3ad113f78 Add "unconfigured-state" concept to origin files
Some operating systems may come with external tools for subscription
management that drive access to the content.  In that case, the origin
file may not be useful (for example, it could refer to an installer
ISO).

This patch will allow OS installers to inject that state, with a
useful error message, directing the system administrator to an
external tool.

See: https://github.com/projectatomic/rpm-ostree/issues/31

https://bugzilla.gnome.org/show_bug.cgi?id=737686
2014-10-03 14:03:55 -04:00
Colin Walters 63abc1b513 pull: Support full recursive mirrors of repositories with summary file
Now that we have a summary file, we can use it to allow a simple:

ostree pull --mirror

To download the latest commit on every branch.  Also, for a case I'm
dealing with there's only one branch, but I don't want mirror users to
have to hardcode it.

https://bugzilla.gnome.org/show_bug.cgi?id=737807
2014-10-03 13:56:40 -04:00
Colin Walters 7ab1fb2369 Add API to directly link() objects between repositories
And use it in pull-local.  As one might expect, this is blazingly fast
if they're on the same filesystem.

I'll be using this to "promote" builds between different repositories.
2014-10-01 23:20:35 -04:00
Colin Walters 1b8759a67e upgrader: Hold a ref to the origin
We unref it in _finalize, so we need to hold a ref.  I *thought*
this was the source of
https://github.com/projectatomic/rpm-ostree/issues/30

But apparently not =/
2014-09-30 11:02:14 -04:00
Owen W. Taylor d64d003af0 ostree admin: Add a --print-current-dir option
Add an option --print-current-dir that prints the current deployment
directory to stdout and exits.

https://bugzilla.gnome.org/show_bug.cgi?id=731051
2014-09-26 10:40:38 -04:00
Owen W. Taylor 262cba09c0 ostree admin instutil set-kargs: make more flexible
Add command line arguments:
 --import-proc-cmdline: import values from /proc/cmdline
 --merge: import current values
 --replace=ARG=VALUE: replace value
 --append=ARG=VALUE: append a new argument

Extra command line arguments are treated like --append=, which
gives backwards compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=731051
2014-09-26 10:40:37 -04:00
Colin Walters edf9cf5a7f trivial-httpd: Further fixes for previous commit 2014-09-25 16:03:06 -04:00
Colin Walters 1b19a989fb Followup to SoupServer port deprecation
My patch didn't actually work with newer libsoup.
2014-09-25 15:57:58 -04:00
Owen W. Taylor 3400f2d2ae --help should always go to stdout
The standard convention is that the  output of --help should go to standard
output (so that it can be piped to a pager and searched.) See, e.g., the
GNU coding standards.

https://bugzilla.gnome.org/show_bug.cgi?id=737194
2014-09-25 14:28:58 -04:00
Owen W. Taylor c9018c785c ostree admin instutil: make --help work for subcommands
Even though the subcommands don't take arguments, use a GOptionContext
so that --help works as expected.

https://bugzilla.gnome.org/show_bug.cgi?id=737194
2014-09-25 03:08:06 -04:00
Owen W. Taylor 9d72ff2d8e Fix help output for nested subcommands
Only 'ostree admin' was appearing in the help message for commands
nested within ostree admin.

https://bugzilla.gnome.org/show_bug.cgi?id=737194
2014-09-25 03:08:06 -04:00
Owen W. Taylor 1dca556691 Pass --help to the most nested subcommand
'ostree admin <x> --help' and 'ostree admin instutil <x> --help' should
give help on the deepest subcommand, not on 'ostree admin'.

https://bugzilla.gnome.org/show_bug.cgi?id=737194
2014-09-25 03:08:06 -04:00
Owen W. Taylor 40f490ed11 ostree admin: Fix return value from 'ostree admin [instutil]'
'ostree admin' and 'ostree admin instuil' with no arguments were meant to fail,
but the logic was wrong; add an assertion on the return value from all ostree
commands to catch similar problems in the future.

https://bugzilla.gnome.org/show_bug.cgi?id=737194
2014-09-25 03:08:06 -04:00
Colin Walters 8f4ffa6950 deploy: Copy parent directories for modified config files
Previously, in the case where a parent directory of a modified config
file was removed, we would throw an exception.  This happens when
switching from a tree that has some software (e.g. firewalld), to one
that does not.

While it's nice to have this warning that your config file probably no
longer applies, there's no need to make it so...fatal.

It's particularly problematic that the only easy workaround is to
remove the config files from your current tree - which breaks
rollback.

The solution then is for for us to take ownership of the parent
directories too into the new /etc.  Admins can clean up these files
afterwards at any time.

https://bugzilla.gnome.org/show_bug.cgi?id=734293
2014-09-16 12:06:10 -04:00
Colin Walters b756a13a65 Extract opendirat() helper function into libotutil
We were duplicating the code to do an opendirat() in a few places.
2014-09-16 11:34:39 -04:00
Colin Walters dfeb27eca5 deploy: Remove legacy "current" symbolic links
Per comment, this was a temporary non-atomic hack, and it's time to
remove it.

https://bugzilla.gnome.org/show_bug.cgi?id=731051
2014-09-13 10:44:29 -04:00
Colin Walters 12e3ed83d3 deploy: Clean up leftover state before creating new directories
This fixes a regression introduced with https://git.gnome.org/browse/ostree/commit/?id=7baa600e237b326899de2899a9bc54a6b863943c

The original code in "ostree admin upgrade" had a comment:

 /* Here we perform cleanup of any leftover data from previous
  * partial failures. This avoids having to call gs_shutil_rm_rf()
  * at random points throughout the process. */

But since I deleted that initial cleanup call, we *do* need to do the
cleanup during the process run.  It turns out there are only a few
places this is necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=733030
2014-09-13 10:43:14 -04:00
Colin Walters 7b01bd2e43 deploy: Consistently use fd-relative API
While looking to fix a different bug here, I found the current
state of things where we had a mix of fd-relative API versus not
frustrating.

Change the code around to consistently use *at, and also add some more
tests.
2014-09-13 10:41:59 -04:00
Colin Walters 34c336c1f3 Work around deprecation of SoupServer's port property
See https://bugzilla.gnome.org/show_bug.cgi?id=732184
2014-09-09 09:30:02 -04:00
Colin Walters a593078722 pull: Squash some uninitialized variable warnings 2014-09-08 13:43:12 -04:00
Colin Walters b30f32e0da Drop g_type_init() call now that we depend on GLib 2.36 2014-09-07 12:58:10 -04:00
Colin Walters f8f5da219e Add repository "summary" file and metalink support
For Fedora and potentially other distributions which use globally
distributed mirrors, metalink is a popular solution to redirect
clients to a dynamic set of mirrors.

In order to make metalink work though, it needs *one* file which can
be checksummed.  (Well, potentially we could explode all refs into the
metalink.xml, but that would be a lot more invasive, and a bit weird
as we'd end up checksumming the checksum file).

This commit adds a new command:

$ ostree summary -u

To regenerate the summary file.  Can only be run by one process at a
time.

After that's done, the metalink can be generated based on it, and the
client fetch code will parse and load it.

https://bugzilla.gnome.org/show_bug.cgi?id=729585
2014-09-03 13:21:52 -04:00
Colin Walters c08a4503ce fetcher: Close request body on error paths
Otherwise, we're potentially holding up subsequent requests.

I was hitting this when testing the metalink code, where we want to
continue doing more fetches after hitting a 404.

https://bugzilla.gnome.org/show_bug.cgi?id=729585
2014-08-27 14:00:31 -04:00
Anne LoVerso 6dfe99a283 pull: Fix use-after-free
The strchr() was pointing into a string we were freeing.
2014-08-21 13:57:31 -04:00
Anne LoVerso 3742c32945 repo-pull: Allow pulling only one directory
Changes the pull API to allow pulling only a single directory instead
of the whole deployment.  This option is utilized by the check-diff
option in rpm-ostree.

Add a new state directory to hold <checksum>.commitpartial files, so
we know that we've only downloaded partial state.
2014-08-20 15:09:32 -04:00
Colin Walters 6a55d2c32f sysroot: Add precondition that load() has been called for some API calls
We require the caller to invoke load() at the moment to do most
things.
2014-08-15 15:21:40 -04:00
Colin Walters 82fb07e4ae deploy: Also honor multiply-specified kernel args with existing config
If we deployed a new tree inside an existing OS, inheriting kernel
args, we need to use append() instead of replace() to avoid collapsing
multiply specified kernel arguments like console=/dev/foo
console=/dev/bar.

Reported-by: Dusty Mabe <dusty@dustymabe.com>
2014-08-03 14:34:28 -04:00
Colin Walters 05114f8565 deploy: Propertly append multiple kernel arguments with --karg-proc-cmdline
We want to allow multiply specified arguments, as it's useful for
things like console= and rd.lvm.lv.

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

Reported-by: Dusty Mabe <dustymabe@gmail.com>
2014-08-03 14:11:40 -04:00
Colin Walters b97a5f59df core: Support a per-remote "proxy" configuration option
We don't want to have to force people to set it in the environment.

https://bugzilla.gnome.org/show_bug.cgi?id=733734
2014-07-28 13:49:38 -04:00
James Antill 43bba232a0 Display bytes/second during pull
Add start time to the AsyncProgress object, use it in the common
progress.
2014-07-28 08:37:15 -04:00
James Antill 249da7aef2 pull: override max-conns-per-host to 8, for faster downloads
Modern web browsers are all converging on 6 or 8.  Let's match that.
2014-07-25 10:22:55 -04:00
Colin Walters d5e813c52c refs: Don't try searching for input strings that can't be objects
I noticed OSTree was a bit slower, did some investigation
and saw we were enumerating all objects for things like

$ ostree rev-parse blah

Since "blah" can never be an object (because of the 'l' and 'h'), just
return no matches.
2014-07-23 15:09:24 -04:00
Colin Walters 9bd229dff5 pull-local: Write detached metadata into the correct repository
We want to write to the dest repo, not src.

Noticed while reviewing this code for some other bug.

https://bugzilla.gnome.org/show_bug.cgi?id=733579
2014-07-22 15:43:33 -04:00
Colin Walters cdaa9517af repofile: Avoid segfault if querying child in non-directory
The user might "ostree ls /usr/bin/bash/blah", which previously would
segfault.

A somewhat related future enhancement here would be for "ostree ls" to
follow symbolic links.

Reported-by: Dusty Mabe <dustymabe@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=733476
2014-07-21 07:58:07 -04:00
Colin Walters e392820541 core: Do enumerate ff/ objects as well
An embarassing off-by-one here.  I noticed we weren't pruning them.

https://bugzilla.gnome.org/show_bug.cgi?id=733458
2014-07-21 07:25:51 -04:00
Colin Walters 1834a71b1f core: Do enumerate content objects in archive-z2 repositories
Prune has worked fine on bare repositories for some time, but now that
I finally try to delete data on the server side, I notice we weren't
actually enumerating content objects =/

That caused them to not be pruned.

https://bugzilla.gnome.org/show_bug.cgi?id=733458
2014-07-21 07:25:51 -04:00
Colin Walters 72da2e0c36 core: Unify object deletion code with prune
The prune API duplicated logic to delete objects, and furthermore the
core API to delete an object didn't clean up detached metadata.

Fix the duplication by doing the obvious thing: prune should call
_delete.

https://bugzilla.gnome.org/show_bug.cgi?id=733452
2014-07-20 08:57:37 -04:00
Colin Walters 1dd4435936 Fix typo in previous commit 2014-07-18 15:49:40 -04:00
Anne LoVerso fd56952d6b ostree-repo-resolve-rev: Add function to accept a partial checksum
This patch adds a function that will parse a partial checksum when
resolving a refspec.  If the inputted refspec matches a truncated
existing checksum, it will return that checksum to be parsed.  If
multiple truncated checksums match the partial refspec, it is not
unique and will return false.  This addition is inspired by the same
functionality in Docker, which allows a user to reference a specific
commit without typing the entire checksum.

partial checksums: Add function to abstract comparison

This modifies the list_objects and list_objects_at functions
to take an additional argument for the string that a commit starts
with.  If this string arg is not null, it will only list commit
objects beginning with that string.  This allows for a new function
ostree_repo_list_commit_objects_starting_with to pass a partial string
and return a list of all matching commits.  This improves on the
previous strategy of listing refs because it will list all commit objects,
even ones in past history.  This update also includes bugfixes on
error handling and string comparison, and changes the output structure
of resolve_partial_checksum. The new strcuture will no longer return FALSE
without error.  Also, the hashtable foreach now uses iter.  Also
includes modified test file
2014-07-18 15:15:44 -04:00
James Antill 3645afc6d7 core: Use ostree_commit_get_parent in ostree_repo_resolve_rev 2014-07-18 10:10:06 -04:00
Owen W. Taylor ff6883ca06 ostree-remount: mount a tmpfs on /var if necessary so /var is read-write
/var needs to be read-write for a functioning system. Various
systemd services will fail to start if /var is read-only. After we
remount /var (or if we skip remounting /var because / is read-only),
if /var is still readonly, mount a tmpfs file system on /var.

While this isn't strictly part of ostree, keeping it here makes sense
because it keeps twiddling around with the /var mount in one place
for easier coordination and maintenance. This will likely need updating
if systemd gains better support for a readonly root filesystem.

https://bugzilla.gnome.org/show_bug.cgi?id=732979
2014-07-09 21:24:07 -04:00
Colin Walters 772409e945 pull: Only set ca path if we actually have a setting for it
Otherwise, GTlsFileDatabase ends up accepting NULL for anchors, and
then we don't trust any CAs at all.

https://bugzilla.gnome.org/show_bug.cgi?id=726256
2014-07-01 08:53:39 -04:00
Colin Walters f60bac45fd core: add "tls-ca-path" option
Some organizations will want to use private Certificate Authorities to
serve content to their clients.  While it's possible to add the CA
to the system-wide CA store, that has two drawbacks:

1) Compromise of that cert means it can be used for other web traffic
2) All of ca-certificates is trusted

This patch allows a much stronger scenario where *only* the CAs in
tls-ca-path are used for verification from the given repository.

https://bugzilla.gnome.org/show_bug.cgi?id=726256
2014-06-27 13:16:47 -04:00
Anne LoVerso 9cb9a31b4f manpage: Add separate manpages for each command
Using docker as a model, this update creates separate manpages
for each OSTree command, such that the main manpage is not
cluttered and the separate pages can provide more in-depth detail
and exanples that might be useful to a user.  Each page includes
synopsis, description, example, and a list of options if needd.
This update also alphabetizes the usage error output for ostree
and ostree admin so that it matches the list on the manpage.
2014-06-23 16:02:37 -04:00
Colin Walters 40f99f764e [staticanalysis]: Delete an unused variable
https://bugzilla.gnome.org/show_bug.cgi?id=732020
2014-06-21 18:08:49 -04:00
Colin Walters 4d04b148d8 [staticanalysis]: Fix in_status_line
We need to end the status line *after* we've done a pull, as ostree
admin upgrade does.  Also add the correct in_status_line assignment.

https://bugzilla.gnome.org/show_bug.cgi?id=732020
2014-06-21 18:08:49 -04:00
Colin Walters 5936740b95 [staticanalysis]: Fix some dead code
One was an unused variable, the other is actually dead because we
can't have mfile != NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=732020
2014-06-21 18:08:49 -04:00
Colin Walters 54079982d8 [staticanalysis]: Actually check errors on splice() of objects
We were using unsigned size when we should have been using signed,
this means we basically weren't checking for errors on write...ouch.

Luckily if we e.g. hit ENOSPC during a pull, the checksums wouldn't
match and we'd return an error anyways.  However when writing an
object, we'd end up silently ignoring it =/

https://bugzilla.gnome.org/show_bug.cgi?id=732020
2014-06-21 18:08:49 -04:00
Colin Walters 2dc0cea503 [staticanalysis]: Add assertion to pacify analyzer
This condition can't actually be hit, let's hint that's the case.

https://bugzilla.gnome.org/show_bug.cgi?id=732020
2014-06-21 18:08:49 -04:00
Colin Walters dfda6e3a46 [staticanalysis]: Add missing va_end()
https://bugzilla.gnome.org/show_bug.cgi?id=732020
2014-06-21 18:08:49 -04:00