[tracker/wip/carlosg/parallel-installable: 39/51] build: Install CLI tool as "tracker3"



commit eb3282d9510701fd336392c16a7530d1179f067f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Feb 23 15:52:36 2020 +0100

    build: Install CLI tool as "tracker3"
    
    This involved some small changes around:
    - Subcommands are now looked in $libexecdir/tracker-3
    - The CLI tool is named tracker3
    - Manpages are also named tracker3-*
    
    This has been all made generic, so it depends on tracker_api_major as
    defined in meson.build.

 docs/manpages/meson.build            | 23 +++++++++++++++++------
 src/tracker/make-subcommand-links.sh | 16 +++++++++-------
 src/tracker/meson.build              | 16 ++++++++++++----
 src/tracker/tracker-help.c           |  6 +++---
 src/tracker/tracker-main.c           |  6 +++---
 5 files changed, 44 insertions(+), 23 deletions(-)
---
diff --git a/docs/manpages/meson.build b/docs/manpages/meson.build
index 7274d1d36..97031a962 100644
--- a/docs/manpages/meson.build
+++ b/docs/manpages/meson.build
@@ -1,6 +1,17 @@
-install_man('tracker-endpoint.1')
-install_man('tracker-export.1')
-install_man('tracker-import.1')
-install_man('tracker-info.1')
-install_man('tracker-sparql.1')
-install_man('tracker-sql.1')
+manpages = [
+    'endpoint',
+    'export',
+    'import',
+    'info',
+    'sparql',
+    'sql'
+]
+
+foreach m: manpages
+    manpage = configure_file(
+        input: 'tracker-@0@.1'.format(m),
+        output: 'tracker@0@-@1@.1'.format(tracker_api_major, m),
+        copy: true,
+        install: false)
+    install_man(manpage)
+endforeach
diff --git a/src/tracker/make-subcommand-links.sh b/src/tracker/make-subcommand-links.sh
index 2bfc44c91..296f01fb4 100644
--- a/src/tracker/make-subcommand-links.sh
+++ b/src/tracker/make-subcommand-links.sh
@@ -2,24 +2,26 @@
 
 set -e
 
-bindir=$MESON_INSTALL_PREFIX/bin
-libexecdir=$MESON_INSTALL_PREFIX/libexec
+clicommand=$1
+subcommanddir=$2
+shift
+shift
 
-if [ -d $libexecdir/tracker ]
+if [ -d $subcommanddir ]
 then
-    for l in `find $libexecdir/tracker -type l`
+    for l in `find $subcommanddir -type l`
     do
        # Delete all previous links to our own binary
-       if [ `readlink $l` = "$bindir/tracker" ]
+       if [ `readlink $l` = "$clicommand" ]
        then
            rm $l
        fi
     done
 fi
 
-mkdir -p $libexecdir/tracker
+mkdir -p $subcommanddir
 
 for subcommand in $@
 do
-    ln -s $bindir/tracker $libexecdir/tracker/$subcommand
+    ln -s $clicommand $subcommanddir/$subcommand
 done
diff --git a/src/tracker/meson.build b/src/tracker/meson.build
index 6de986314..a64b0d9b2 100644
--- a/src/tracker/meson.build
+++ b/src/tracker/meson.build
@@ -16,9 +16,13 @@ foreach m: modules
     sources += 'tracker-@0@.c'.format(m)
 endforeach
 
-executable('tracker', sources,
+command_name = 'tracker@0@'.format(tracker_api_major)
+subcommands_dir = join_paths(get_option('prefix'), get_option('libexecdir'), tracker_versioned_name)
+
+executable(command_name, sources,
     c_args: tracker_c_args + [
-        '-DLIBEXECDIR="@0@"'.format(join_paths(get_option('prefix'), get_option('libexecdir'))),
+        '-DCOMMANDNAME="@0@"'.format(command_name),
+        '-DSUBCOMMANDSDIR="@0@"'.format(subcommands_dir),
         '-DMANDIR="@0@"'.format(join_paths(get_option('prefix'), get_option('datadir'), 'man')),
         '-DBINDIR="@0@"'.format(join_paths(get_option('prefix'), get_option('bindir'))),
     ],
@@ -30,12 +34,16 @@ executable('tracker', sources,
     include_directories: [commoninc, configinc, srcinc],
 )
 
-meson.add_install_script('make-subcommand-links.sh', modules)
+meson.add_install_script('make-subcommand-links.sh',
+    [ '@0@'.format(join_paths(get_option('prefix'), get_option('bindir'), command_name)),
+      '@0@'.format(subcommands_dir),
+    ] + modules)
 
 if get_option('bash_completion')
     install_data(
         sources: 'bash-completion/tracker',
-        install_dir: bash_completion_dir)
+        install_dir: bash_completion_dir,
+       rename: command_name)
 endif
 
 run_command('make-uninstalled-subcommand-links.sh', modules,
diff --git a/src/tracker/tracker-help.c b/src/tracker/tracker-help.c
index fef95e16e..efefb63e7 100644
--- a/src/tracker/tracker-help.c
+++ b/src/tracker/tracker-help.c
@@ -78,11 +78,11 @@ static char *
 cmd_to_page (const char *cmd)
 {
        if (!cmd) {
-               return g_strdup ("tracker");
-       } else if (g_str_has_prefix (cmd, "tracker")) {
+               return g_strdup (COMMANDNAME);
+       } else if (g_str_has_prefix (cmd, COMMANDNAME "-")) {
                return g_strdup (cmd);
        } else {
-               return g_strdup_printf ("tracker-%s", cmd);
+               return g_strdup_printf (COMMANDNAME "-%s", cmd);
        }
 }
 
diff --git a/src/tracker/tracker-main.c b/src/tracker/tracker-main.c
index 54930e216..7120fd79a 100644
--- a/src/tracker/tracker-main.c
+++ b/src/tracker/tracker-main.c
@@ -170,7 +170,7 @@ print_usage_list_cmds (void)
 
        subcommands_dir = g_getenv ("TRACKER_CLI_SUBCOMMANDS_DIR");
        if (!subcommands_dir) {
-               subcommands_dir = LIBEXECDIR "/tracker/";
+               subcommands_dir = SUBCOMMANDSDIR;
        }
 
        for (i = 0; i < G_N_ELEMENTS(commands); i++) {
@@ -248,12 +248,12 @@ main (int argc, char *argv[])
        textdomain (GETTEXT_PACKAGE);
 
        command_basename = g_path_get_basename (argv[0]);
-       basename_is_bin = g_strcmp0 (command_basename, "tracker") == 0;
+       basename_is_bin = g_strcmp0 (command_basename, COMMANDNAME) == 0;
        g_free (command_basename);
 
        subcommands_dir = g_getenv ("TRACKER_CLI_SUBCOMMANDS_DIR");
        if (!subcommands_dir) {
-               subcommands_dir = LIBEXECDIR "/tracker/";
+               subcommands_dir = SUBCOMMANDSDIR;
        }
 
        if (g_path_is_absolute (argv[0]) &&


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]