diff options
author | Joseph Marrero Corchado <jmarrero@users.noreply.github.com> | 2022-01-11 21:01:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-11 21:01:20 -0500 |
commit | 6567d825252cfa4b1ebab1dd8c9043bc6f73e3d6 (patch) | |
tree | 694e214047806060e78340187779ee72b835828f /src | |
parent | 7cc84819078aec6b9637b3ad29712ca3e2f8433e (diff) | |
parent | 998154f8ffc2f471bf4f3b59602332ba15ef6d07 (diff) | |
download | ostree-6567d825252cfa4b1ebab1dd8c9043bc6f73e3d6.tar.gz |
Merge pull request #2515 from cgwalters/cliwrap-lib
main: Also support CLI extensions in `/usr/libexec/libostree/ext`
Diffstat (limited to 'src')
-rw-r--r-- | src/libostree/ostree-1.pc.in | 1 | ||||
-rw-r--r-- | src/ostree/ot-main.c | 16 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/libostree/ostree-1.pc.in b/src/libostree/ostree-1.pc.in index 9a4debce..cbf0a13c 100644 --- a/src/libostree/ostree-1.pc.in +++ b/src/libostree/ostree-1.pc.in @@ -3,6 +3,7 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ features=@OSTREE_FEATURES@ +cliextdir=@pkglibexecdir@/ext Name: OSTree Description: Git for operating system binaries diff --git a/src/ostree/ot-main.c b/src/ostree/ot-main.c index b72fa9d4..7a4c4707 100644 --- a/src/ostree/ot-main.c +++ b/src/ostree/ot-main.c @@ -41,6 +41,10 @@ static gboolean opt_verbose; static gboolean opt_version; static gboolean opt_print_current_dir; +// TODO: make this public? But no one sane wants to use our C headers +// to find where to put files. Maybe we can make it printed by the CLI? +#define _OSTREE_EXT_DIR PKGLIBEXECDIR "/ext" + static GOptionEntry global_entries[] = { { "verbose", 'v', 0, G_OPTION_ARG_NONE, &opt_verbose, "Print debug information during command processing", NULL }, { "version", 0, 0, G_OPTION_ARG_NONE, &opt_version, "Print version information and exit", NULL }, @@ -188,7 +192,7 @@ ostree_command_lookup_external (int argc, // Find the first verb (ignoring all earlier flags), then // check if it is a known native command. Otherwise, try to look it - // up in $PATH. + // up in /usr/lib/ostree/ostree-$cmd or $PATH. // We ignore argv[0] here, the ostree binary itself is not multicall. for (guint arg_index = 1; arg_index < argc; arg_index++) { @@ -204,10 +208,18 @@ ostree_command_lookup_external (int argc, return NULL; } + g_autofree gchar *ext_command = g_strdup_printf ("ostree-%s", current_arg); + + /* First, search in our libdir /usr/lib/ostree/ostree-$cmd */ + g_autofree char *ext_lib = g_strconcat (_OSTREE_EXT_DIR, "/", ext_command, NULL); + struct stat stbuf; + if (stat (ext_lib, &stbuf) == 0) + return g_steal_pointer (&ext_lib); + + /* Otherwise, look in $PATH */ if (g_find_program_in_path (ext_command) == NULL) return NULL; - return g_steal_pointer (&ext_command); } |