summaryrefslogtreecommitdiff
path: root/src/tracker/make-subcommand-links.sh
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2019-12-19 14:12:55 +0100
committerCarlos Garnacho <carlosg@gnome.org>2019-12-29 22:46:16 +0100
commit8da1f13c7df386163b26277cfb92b80d1e0c7f8a (patch)
tree338b108ff1007d2c229821e089d7568197c584e9 /src/tracker/make-subcommand-links.sh
parent7bd6b4cce0de53f43833a8b1b270087ead8f8e5f (diff)
downloadtracker-8da1f13c7df386163b26277cfb92b80d1e0c7f8a.tar.gz
tracker: Allow extending the CLI tool with additional subcommands
We still link all the builtin tools in a single binary, and create specific links in $libexecdir/tracker/. External subcommands may install their binaries on $libexecdir/tracker right away. During (sub)command execution, the tracker binary will look for the proper subcommand and execve it. As the same tracker binary implements those same subcommands, it does check argv[0] to know if it is running as one of those subcommands. This keeps a single binary around, but allows transparently falling back to other executables.
Diffstat (limited to 'src/tracker/make-subcommand-links.sh')
-rw-r--r--src/tracker/make-subcommand-links.sh25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tracker/make-subcommand-links.sh b/src/tracker/make-subcommand-links.sh
new file mode 100644
index 000000000..a257d1612
--- /dev/null
+++ b/src/tracker/make-subcommand-links.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+set -e
+
+bindir=$MESON_INSTALL_PREFIX/bin
+libexecdir=$MESON_INSTALL_PREFIX/libexec
+
+if [ -d $libexecdir/tracker ]
+then
+ for l in `find $libexecdir/tracker -type l`
+ do
+ # Delete all previous links to our own binary
+ if [[ `readlink $l` = "$bindir/tracker" ]]
+ then
+ rm $l
+ fi
+ done
+fi
+
+mkdir -p $libexecdir/tracker
+
+for subcommand in $@
+do
+ ln -s $bindir/tracker $libexecdir/tracker/$subcommand
+done