summaryrefslogtreecommitdiff
path: root/src/ostree/main.c
blob: edb8a7a04fd4ed975630df40f9535326bbe22b12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 * Copyright (C) 2011 Colin Walters <walters@verbum.org>
 *
 * SPDX-License-Identifier: LGPL-2.0+
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <https://www.gnu.org/licenses/>.
 *
 * Author: Colin Walters <walters@verbum.org>
 */

#include "config.h"

#include <gio/gio.h>

#include <errno.h>
#include <string.h>
#include <unistd.h>

#include "ot-builtins.h"

static OstreeCommand commands[] = {
  /* Note: all admin related commands have
   * no_repo as their command flag, but each
   * admin command may have their own
   * admin flag
   */
  { "admin", OSTREE_BUILTIN_FLAG_NO_REPO, ostree_builtin_admin,
    "Commands for managing a host system booted with ostree" },
  { "cat", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_cat, "Concatenate contents of files" },
  { "checkout", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_checkout,
    "Check out a commit into a filesystem tree" },
  { "checksum", OSTREE_BUILTIN_FLAG_NO_REPO, ostree_builtin_checksum,
    "Checksum a file or directory" },
  { "commit", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_commit, "Commit a new revision" },
  { "config", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_config,
    "Change repo configuration settings" },
  { "diff", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_diff,
    "Compare directory TARGETDIR against revision REV" },
  { "export", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_export,
    "Stream COMMIT to stdout in tar format" },
  { "find-remotes", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_find_remotes,
    "Find remotes to serve the given refs" },
  { "create-usb", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_create_usb,
    "Copy the refs to a USB stick" },
  { "fsck", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_fsck, "Check the repository for consistency" },
#ifndef OSTREE_DISABLE_GPGME
  { "gpg-sign", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_gpg_sign, "Sign a commit" },
#endif /* OSTREE_DISABLE_GPGME */
  { "init", OSTREE_BUILTIN_FLAG_NO_CHECK, ostree_builtin_init,
    "Initialize a new empty repository" },
  { "log", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_log, "Show log starting at commit or ref" },
  { "ls", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_ls, "List file paths" },
  { "prune", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_prune, "Search for unreachable objects" },
  { "pull-local", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_pull_local, "Copy data from SRC_REPO" },
#ifdef HAVE_LIBCURL_OR_LIBSOUP
  { "pull", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_pull, "Download data from remote repository" },
#endif
  { "refs", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_refs, "List refs" },
  { "remote", OSTREE_BUILTIN_FLAG_NO_REPO, ostree_builtin_remote,
    "Remote commands that may involve internet access" },
  { "reset", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_reset, "Reset a REF to a previous COMMIT" },
  { "rev-parse", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_rev_parse, "Output the target of a rev" },
  { "sign", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_sign, "Sign a commit" },
  { "show", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_show, "Output a metadata object" },
  { "static-delta", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_static_delta,
    "Static delta related commands" },
  { "summary", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_summary, "Manage summary metadata" },
#if defined(HAVE_LIBSOUP_OR_LIBSOUP3) && defined(BUILDOPT_ENABLE_TRIVIAL_HTTPD_CMDLINE)
  { "trivial-httpd", OSTREE_BUILTIN_FLAG_NONE, ostree_builtin_trivial_httpd, NULL },
#endif
  { NULL }
};

int
main (int argc, char **argv)
{
  g_assert (argc > 0);

  g_autofree gchar *ext_command = ostree_command_lookup_external (argc, argv, commands);
  if (ext_command != NULL)
    {
      argv[0] = ext_command;
      return ostree_command_exec_external (argv);
    }
  else
    {
      return ostree_main (argc, argv, commands);
    }
}