Commit Graph

53 Commits

Author SHA1 Message Date
Colin Walters f0519e541f [TSAN] main: Stop calling g_set_prgname()
It turns out this is basically racy with the presence of other
threads.  It was really cosmetic so let's stop doing it and make
`-fsanitize=thread` happy.

Closes: #582
Approved by: jlebon
2016-11-17 19:41:57 +00:00
Simon McVittie 4c32344b8e ostree_admin_option_context_parse: explicitly clean up when exiting early
The cleanup attribute doesn't clean up before calling a noreturn
function like exit(). Explicitly clean up the pointer variables
(but don't assume that a simple g_object_unref() would be OK either,
in case the behaviour of the cleanup attribute changes).

This isn't a real leak since we're about to exit anyway, but if we
don't fix it then valgrind memcheck will make the tests fail.

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #559
Approved by: cgwalters
2016-10-30 21:37:38 +00:00
Alexander Larsson d368624798 Build on older versions of glib
Various places need to include libglnx.h for the autoptr backport
fallbacks to be there before ostree-autocleanups.h is included.

This fixes the build on centos7·

Closes: #309
Approved by: giuseppe
2016-05-25 14:01:39 +00:00
Dan Nicholson b1e1e51660 main: Set log handler for OSTree domain
Now that OSTree is used as G_LOG_DOMAIN, set the main handler to match
so the appropriate messages are filtered. It would probably be more
appropriate to spell out "OSTree" in the code, but since G_LOG_DOMAIN is
being defined globally in the project, might as well reuse it here.

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

Closes: #225
Approved by: cgwalters
2016-03-26 18:22:59 +00:00
Colin Walters c58ad36840 libglnx porting: gs_transfer_out_value -> g_steal_pointer
It's a bit more verbose but...eh.
2016-03-18 12:08:19 -04:00
Giuseppe Scrivano b393e5a2e9 ostree: do not print the usage on each G_IO_ERROR_NOT_SUPPORTED
It may have a different meaning, and the usage screen is not helpful.

Print the usage screen only when the command is not found.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-11-16 11:07:55 +01:00
Giuseppe Scrivano 0aa836c205 prune: add --delete-commit
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-11-16 10:57:33 +01:00
Matthew Barnes 254def3584 main: Fix UID check based on sysroot path
This is another place where we were hard-coding a default.  Create the
OstreeSysroot first and THEN check if its path is the root directory.
2015-07-16 12:49:28 -04:00
Colin Walters c10bc00249 admin: Use locking for most sysroot commands
The previous commit introduced locking for `ostree admin deploy`, but
we do expect people to possibly accidentally do e.g.
`ostree admin upgrade` concurrently.

Using consistent locking in the admin commands will help rpm-ostree.

Closes: https://github.com/GNOME/ostree/pull/110
2015-05-13 17:23:07 -04:00
Matthew Barnes 4ef0280941 Remove unnecessary #include "libgsystem.h" 2015-05-06 22:07:11 -04:00
Matthew Barnes bb231fdf74 Use g_autoptr(GPtrArray) instead of gs_unref_ptrarray 2015-05-06 22:07:10 -04:00
Matthew Barnes 6a5f7b1288 Use glnx_unref_object instead of gs_unref_object
For non-GIO object types, at least until autocleanup support for GObject
based types becomes more widespread.
2015-05-06 22:07:04 -04:00
Matthew Barnes 4ee1acd981 Use g_autoptr() for GIO object types
GLib 2.44 supplies all the necessary autocleanup macros for GIO types,
and libglnx backports the relevant macros for ostree.
2015-05-06 21:51:19 -04:00
Matthew Barnes 7a62d64968 Use g_autofree instead of gs_free 2015-05-06 21:50:17 -04:00
Matthew Barnes 4f33515316 Juggling libglnx.h includes 2015-05-06 21:50:06 -04:00
Matthew Barnes 60ebec770e main: Tweak GPG output to match rpm-ostree 2015-04-17 12:43:46 -04:00
Matthew Barnes d7a6f257a0 pull: Print GPG signature status as soon as its known 2015-04-16 18:13:08 -04:00
Giuseppe Scrivano 1de4035d49 src/ostree/ot-main.c: drop empty newline at end of file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-04-03 09:57:20 +02:00
Colin Walters 2a30af72db main: Only verify SUPERUSER flag if using default sysroot
The use case for non-default sysroots that I know of are:
 1) The current test suite
 2) Installers (Anaconda)
 3) Inspecting VM disks

For 2) and 3), it'll quickly be obvious if they're not running as
root, and these are more obscure cases.  We want to allow 1), and this
is a simple way to do it.

https://bugzilla.gnome.org/show_bug.cgi?id=747164
2015-04-01 06:21:34 -04:00
Matthew Barnes aeab9df4fe Add OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER
Indicates the command requires superuser privilege.  Fails early with
a more helpful message than would otherwise be returned by libostree.

Currently all admin commands except 'status' require superuser.
2015-03-25 17:24:06 -04:00
Matthew Barnes e48ea0ba05 Add OstreeAdminBuiltinFlags for admin commands
Only OSTREE_ADMIN_BUILTIN_FLAG_NONE so far; does nothing.
2015-03-25 17:24:06 -04:00
Matthew Barnes 7941189dfd Add ostree_ensure_repo_writable()
Commands that need to write files within the repo directory can call
this early to ensure the directory is writable for the current user.
If not, it fails with a helpful "You need to be root to perform this
command" message.
2015-03-25 17:24:05 -04:00
Colin Walters 965a304a17 Use libglnx
Starting down the path of not using libgsystem.  The main win here
will be code sharing between ostree/rpm-ostree as well as going down
the path of not using GFile * for local files.
2015-02-22 21:02:27 -05:00
Giuseppe Scrivano 6a3959c895 syntax-check: Remove empty lines at the end of file
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2015-02-02 15:07:56 +01:00
Matthew Barnes 97558276e4 Refactor command-line parsing
Refactor command-line parsing to better utilize GOptionContext.  This
eliminates most of the manual parsing and global options are now shown
in the help output.

Here's a sample:

    $ ostree admin --help
    Usage:
      ostree admin [OPTION...] --print-current-dir|COMMAND

    Builtin "admin" Commands:
      cleanup
      config-diff
      deploy
      init-fs
      instutil
      os-init
      status
      switch
      undeploy
      upgrade

    Help Options:
      -h, --help         Show help options

    Application Options:
      --sysroot=PATH     Create a new OSTree sysroot at PATH
      -v, --verbose      Print debug information during command processing
      --version          Print version information and exit

https://bugzilla.gnome.org/show_bug.cgi?id=740295
2014-11-24 19:36:07 -05: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 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 b30f32e0da Drop g_type_init() call now that we depend on GLib 2.36 2014-09-07 12:58:10 -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
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
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
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 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 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 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 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 4b170d656c Switch to libgsystem local allocation macros
And drop our compatibility wrapper.
2013-07-07 12:27:44 -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 202c5e35c9 core: Use default /sysroot/ostree/repo or just /ostree/repo as appropriate
The old logic was just weird, special casing root, and we can easily
autodetect the case where we need /ostree/repo.
2013-02-24 10:00:23 -05:00
Jasper St. Pierre cda5b28bab ot-main: Ignore lt- prefixes in binary names
libtool is the best

https://bugzilla.gnome.org/show_bug.cgi?id=682438
2012-10-24 12:20:15 -04:00
Colin Walters fa5485c6c4 Move "ostadmin" => "ostree admin"
This helps us avoid polluting the global binary namespace.
2012-09-08 19:34:10 -04:00
Stef Walter f5cf21e471 Include pull and other external commands in usage output 2012-08-19 15:05:01 -04:00
Stef Walter 66c8a1d3f6 Support non-builtin commands
* Support executing commands in the path
 * This makes 'ostree-pull' work as 'ostree pull'
2012-08-10 15:55:26 +02:00
Colin Walters 311493338e core: Drop ot_gfile_new_for_path
Not necessary anymore since we switched to GIO_USE_VFS=local in the
binaries.
2012-06-30 13:42:24 -04:00
Colin Walters d596615bab main: Fix a format string error 2012-06-27 22:26:16 -04:00
Colin Walters 6d9de91672 core: Make argument parsing more robust against "lt-ostree" name
When running uninstalled, we were parsing our argv[0] incorrectly.
2012-05-14 11:31:53 -04:00
Matthias Clasen 07f67f3baf ostree: avoid a segfault
When running ostree --repo=/ostree/repo without further arguments,
we end up calling strcmp with one argument being NULL.
2012-05-06 13:56:57 -04:00