beagle r4720 - in trunk/beagle: conf-data tools



Author: dbera
Date: Fri Apr 18 21:40:02 2008
New Revision: 4720
URL: http://svn.gnome.org/viewvc/beagle?rev=4720&view=rev

Log:
Add 'blocate' - beagle powered locate, a wrapper over beagle-static-query. From Nirbheek Chauhan. It uses a global config file /etc/beagle/blocate.conf overriden by the users ~/.beagle/config/blocate.conf


Added:
   trunk/beagle/conf-data/blocate.conf
   trunk/beagle/tools/blocate   (contents, props changed)
Modified:
   trunk/beagle/conf-data/Makefile.am
   trunk/beagle/tools/Makefile.am

Modified: trunk/beagle/conf-data/Makefile.am
==============================================================================
--- trunk/beagle/conf-data/Makefile.am	(original)
+++ trunk/beagle/conf-data/Makefile.am	Fri Apr 18 21:40:02 2008
@@ -23,8 +23,9 @@
 global_config_files_DATA = $(GLOBAL_CONFIG_FILES)
 
 confdir = $(sysconfdir)/beagle
-conf_DATA = external-filters.xml.sample \
-	    query-mapping.xml
+conf_DATA = $(srcdir)/blocate.conf			\
+	    $(srcdir)/external-filters.xml.sample	\
+	    $(srcdir)/query-mapping.xml
 
 EXTRA_DIST =				\
 	$(CRAWL_RULES)			\

Added: trunk/beagle/conf-data/blocate.conf
==============================================================================
--- (empty file)
+++ trunk/beagle/conf-data/blocate.conf	Fri Apr 18 21:40:02 2008
@@ -0,0 +1,6 @@
+# Names of system indexes
+BACKENDS="applications monodoc documentation manpages"
+
+# System-wide static indexes
+# Use full path of non-system static indexes
+STATIC_INDEXES=""

Modified: trunk/beagle/tools/Makefile.am
==============================================================================
--- trunk/beagle/tools/Makefile.am	(original)
+++ trunk/beagle/tools/Makefile.am	Fri Apr 18 21:40:02 2008
@@ -181,7 +181,8 @@
 PREBUILT_WRAPPERS =		\
 	beagle-index-info	\
 	beagle-ping		\
-	beagle-status
+	beagle-status		\
+	blocate
 
 BIN_WRAPPERS = $(BUILT_WRAPPERS) $(PREBUILT_WRAPPERS)
 
@@ -261,6 +262,7 @@
 	beagle-index-info		\
 	beagle-ping			\
 	beagle-status			\
+	blocate				\
 	boot.inotify.init		\
 	beagle-settings.desktop.in.in
 

Added: trunk/beagle/tools/blocate
==============================================================================
--- (empty file)
+++ trunk/beagle/tools/blocate	Fri Apr 18 21:40:02 2008
@@ -0,0 +1,110 @@
+#!/bin/bash
+#
+# blocate
+# 
+# Copyright (C) 2008 Nirbheek Chauhan <nirbheek chauhan gmail com>
+#
+
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+#
+
+
+# Get the config directory
+if [ -n "${BEAGLE_HOME}" ]; then
+	CONFDIR="${BEAGLE_HOME}/.beagle/config"
+elif [ -n "${BEAGLE_STORAGE}" ]; then
+	CONFDIR="${BEAGLE_STORAGE}/config"
+elif [ -n "${BEAGLE_CONF_DIR}" ]; then
+	CONFDIR="${BEAGLE_CONF_DIR}"
+else
+	CONFDIR="/etc/beagle"
+fi
+
+CONFFILE="${CONFDIR}/blocate.conf"
+
+if ! [ -e "${CONFFILE}" ]; then
+	echo "Error: config file \"${CONFFILE}\" does not exist"
+	exit 1
+fi
+
+# Read config settings
+source "${CONFFILE}"
+
+print_help() {
+	# Use here-documents for great justice.
+	cat <<-DELIM
+		blocate: Special locate powered by Beagle
+		Web page: http://www.beagle-project.org/
+		Usage: blocate [OPTIONS] <query string>
+
+		Options:
+		  -d, --database NAME	    query backend given by NAME instead of default
+		  -d, --database PATH	    query backend given by PATH instead of default
+		  			    Both of the above options can be repeated.
+					    If they are specified then the default backends are ignored.
+					    Default backends are specified in ~/.beagle/config/blocate.conf or /etc/beagle/blocate.conf
+	DELIM
+}
+
+# While we still have arguments..
+while [ -n "${1}" ]; do
+	# Take one in; shift
+	arg=${1}; shift
+	if [[ "${arg}" == "-h" || "${arg}" == "--help" ]]; then
+		print_help
+		exit
+	elif [[ "${arg}" == "-d" || "${arg}" == "--database" ]]; then 
+		# Take in it's value; shift
+		argvalue=${1}; shift
+		# Ignore config file
+		ignore_config="true"
+		if [[ "${argvalue}" =~ "/" ]]; then
+			# If the dir is not an absolute path
+			if [ -n "${argvalue%%/*}" ]; then
+				echo "Error: \"${argvalue}\" - relative paths not allowed"
+				exit 1
+			else
+				# If absolute path and DNE
+				if ! [ -d "${argvalue}" ]; then
+					echo "Error: directory \"${argvalue}\" does not exist"
+					exit 1
+				fi
+			fi
+			arg="--add-static-backend ${argvalue}"
+		else
+			arg="--backend ${argvalue}"
+		fi
+	fi
+	OPTS=("${OPTS[ ]}" "${arg}")
+done
+
+# If you give -d, --database as args, the entire config is ignored
+if [ "$ignore_config" != "true" ]; then
+	for i in ${STATIC_INDEXES}; do
+		OPTS=("${OPTS[ ]}" "--add-static-backend" "${i}")
+	done
+	for i in ${BACKENDS}; do
+		OPTS=("${OPTS[ ]}" "--backend" "${i}")
+	done
+fi
+
+# We add "--backend none" else it'll query all backends if there are no --backend params
+beagle-static-query ${OPTS[ ]} --backend none
+



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