slight config cleanup

This commit is contained in:
dockes 2006-01-19 17:11:46 +00:00
parent 9f4b399f92
commit e93dd142d6
11 changed files with 122 additions and 65 deletions

View File

@ -1,14 +1,21 @@
# @(#$Id: Makefile,v 1.26 2006-01-19 12:01:42 dockes Exp $ (C) 2005 J.F.Dockes # @(#$Id: Makefile.in,v 1.1 2006-01-19 17:11:45 dockes Exp $ (C) 2005 J.F.Dockes
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
datadir = @datadir@
mandir = @mandir@
all: mk/sysconf common/rclversion.h all: mk/sysconf common/rclversion.h
cd lib; ${MAKE} cd lib; ${MAKE}
cd bincimapmime; ${MAKE} cd bincimapmime; ${MAKE}
cd index; ${MAKE} recollindex cd index; ${MAKE} recollindex
cd qtgui; PATH=${PATH}:${QTDIR}/bin; export PATH; qmake recoll.pro; \ cd qtgui; PATH=${PATH}:${QTDIR}/bin; export PATH; qmake recoll.pro; \
cat ../mk/sysconf Makefile | ${MAKE} -f - depth=.. cat ../mk/sysconf Makefile | ${MAKE} -f - depth=..
mk/sysconf: mk/sysconf:
./configure @echo "You need to run configure first" ; exit 1
common/rclversion.h: VERSION common/rclversion.h: VERSION
echo 'static const char *rclversion = "'`cat VERSION`'";' \ echo 'static const char *rclversion = "'`cat VERSION`'";' \
@ -22,7 +29,8 @@ static:
cd qtgui; PATH=${PATH}:${QTDIR}/bin; export PATH; qmake recoll.pro; \ cd qtgui; PATH=${PATH}:${QTDIR}/bin; export PATH; qmake recoll.pro; \
rm -f recoll; rm -f recoll;
cat ../mk/sysconf Makefile | \ cat ../mk/sysconf Makefile | \
${MAKE} -f - BSTATIC=-Wl,-Bstatic BDYNAMIC=-Wl,-Bdynamic depth=.. ${MAKE} -f - \
BSTATIC=-Wl,-Bstatic BDYNAMIC=-Wl,-Bdynamic depth=..
clean: clean:
cd common; ${MAKE} clean cd common; ${MAKE} clean
@ -39,9 +47,14 @@ distclean: clean
rm -f mk/sysconf mk/localdefs sampleconf/recoll.conf \ rm -f mk/sysconf mk/localdefs sampleconf/recoll.conf \
recollinstall \ recollinstall \
doc/user/*.html* doc/user/*.txt doc/user/HTML.manifest doc/user/*.html* doc/user/*.txt doc/user/HTML.manifest
# recollinstall can be executed by the user and will compute 'normal'
# values for bindir etc., relative to the prefix argument. When executed
# here, we pass a bunch of variables in the environment, the values will
# override the computed defaults.
install: all install: all
bindir=${bindir} datadir=${datadir} ./recollinstall ${prefix} DESTDIR=${DESTDIR} bindir=${bindir} datadir=${datadir} \
mandir=${mandir} \
./recollinstall ${prefix}
.PHONY: all static clean distclean install .PHONY: all static clean distclean install

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.18 2006-01-10 12:58:39 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.19 2006-01-19 17:11:46 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
@ -23,13 +23,11 @@ using namespace std;
static const char *configfiles[] = {"recoll.conf", "mimemap", "mimeconf"}; static const char *configfiles[] = {"recoll.conf", "mimemap", "mimeconf"};
static int ncffiles = sizeof(configfiles) / sizeof(char *); static int ncffiles = sizeof(configfiles) / sizeof(char *);
static bool createConfig(string &reason) static bool createConfig(const string &datadir, string &reason)
{ {
const char *cprefix = getenv("RECOLL_PREFIX"); // Samples directory
if (cprefix == 0) string exdir = path_cat(datadir, "examples");
cprefix = RECOLL_PREFIX; // User's
string prefix = path_cat(cprefix, "share/recoll/examples");
string recolldir = path_tildexpand("~/.recoll"); string recolldir = path_tildexpand("~/.recoll");
if (mkdir(recolldir.c_str(), 0755) < 0) { if (mkdir(recolldir.c_str(), 0755) < 0) {
reason += string("mkdir(") + recolldir + ") failed: " + reason += string("mkdir(") + recolldir + ") failed: " +
@ -37,7 +35,7 @@ static bool createConfig(string &reason)
return false; return false;
} }
for (int i = 0; i < ncffiles; i++) { for (int i = 0; i < ncffiles; i++) {
string src = path_cat((const string&)prefix, string(configfiles[i])); string src = path_cat((const string&)exdir, string(configfiles[i]));
string dst = path_cat((const string&)recolldir, string(configfiles[i])); string dst = path_cat((const string&)recolldir, string(configfiles[i]));
if (!copyfile(src.c_str(), dst.c_str(), reason)) { if (!copyfile(src.c_str(), dst.c_str(), reason)) {
LOGERR(("Copyfile failed: %s\n", reason.c_str())); LOGERR(("Copyfile failed: %s\n", reason.c_str()));
@ -49,8 +47,8 @@ static bool createConfig(string &reason)
RclConfig::RclConfig() RclConfig::RclConfig()
: m_ok(false), conf(0), mimemap(0), mimeconf(0), stopsuffixes(0) : m_ok(false), m_conf(0), mimemap(0), mimeconf(0), mimemap_local(0),
stopsuffixes(0)
{ {
static int loginit = 0; static int loginit = 0;
if (!loginit) { if (!loginit) {
@ -59,35 +57,45 @@ RclConfig::RclConfig()
loginit = 1; loginit = 1;
} }
// Compute our data dir name, typically /usr/local/share/recoll
const char *cdatadir = getenv("RECOLL_DATADIR");
if (cdatadir == 0) {
// If not in environment, use the compiled-in constant.
m_datadir = RECOLL_DATADIR;
} else {
m_datadir = cdatadir;
}
const char *cp = getenv("RECOLL_CONFDIR"); const char *cp = getenv("RECOLL_CONFDIR");
if (cp) { if (cp) {
confdir = cp; m_confdir = cp;
} else { } else {
confdir = path_home(); m_confdir = path_home();
confdir += ".recoll/"; m_confdir += ".recoll/";
} }
string cfilename = path_cat(confdir, "recoll.conf"); string cfilename = path_cat(m_confdir, "recoll.conf");
if (access(confdir.c_str(), 0) != 0 || access(cfilename.c_str(), 0) != 0) { if (access(m_confdir.c_str(), 0) != 0 ||
if (!createConfig(reason)) access(cfilename.c_str(), 0) != 0) {
if (!createConfig(m_datadir, reason))
return; return;
} }
// Open readonly here so as not to casually create a config file // Open readonly here so as not to casually create a config file
conf = new ConfTree(cfilename.c_str(), true); m_conf = new ConfTree(cfilename.c_str(), true);
if (conf == 0 || if (m_conf == 0 ||
(conf->getStatus() != ConfSimple::STATUS_RO && (m_conf->getStatus() != ConfSimple::STATUS_RO &&
conf->getStatus() != ConfSimple::STATUS_RW)) { m_conf->getStatus() != ConfSimple::STATUS_RW)) {
reason = string("No main configuration file: ") + cfilename + reason = string("No main configuration file: ") + cfilename +
" does not exist or cannot be parsed"; " does not exist or cannot be parsed";
return; return;
} }
string mimemapfile; string mimemapfile;
if (!conf->get("mimemapfile", mimemapfile, "")) { if (!m_conf->get("mimemapfile", mimemapfile, "")) {
mimemapfile = "mimemap"; mimemapfile = "mimemap";
} }
string mpath = path_cat(confdir, mimemapfile); string mpath = path_cat(m_confdir, mimemapfile);
mimemap = new ConfTree(mpath.c_str(), true); mimemap = new ConfTree(mpath.c_str(), true);
if (mimemap == 0 || if (mimemap == 0 ||
(mimemap->getStatus() != ConfSimple::STATUS_RO && (mimemap->getStatus() != ConfSimple::STATUS_RO &&
@ -99,10 +107,10 @@ RclConfig::RclConfig()
// mimemap->list(); // mimemap->list();
string mimeconffile; string mimeconffile;
if (!conf->get("mimeconffile", mimeconffile, "")) { if (!m_conf->get("mimeconffile", mimeconffile, "")) {
mimeconffile = "mimeconf"; mimeconffile = "mimeconf";
} }
mpath = path_cat(confdir, mimeconffile); mpath = path_cat(m_confdir, mimeconffile);
mimeconf = new ConfTree(mpath.c_str(), true); mimeconf = new ConfTree(mpath.c_str(), true);
if (mimeconf == 0 || if (mimeconf == 0 ||
(mimeconf->getStatus() != ConfSimple::STATUS_RO && (mimeconf->getStatus() != ConfSimple::STATUS_RO &&
@ -210,10 +218,9 @@ string RclConfig::getMimeIconName(const string &mtype)
return hs; return hs;
} }
// Look up an executable filter. // Look up an executable filter. We look in $RECOLL_FILTERSDIR,
// We look in RECOLL_FILTERSDIR, filtersdir param, then // filtersdir in config file, then let the system use the PATH
// let the system use the PATH string RclConfig::findFilter(const string &icmd)
string find_filter(RclConfig *conf, const string &icmd)
{ {
// If the path is absolute, this is it // If the path is absolute, this is it
if (icmd[0] == '/') if (icmd[0] == '/')
@ -222,19 +229,33 @@ string find_filter(RclConfig *conf, const string &icmd)
string cmd; string cmd;
const char *cp; const char *cp;
// Filters dir from environment ?
if ((cp = getenv("RECOLL_FILTERSDIR"))) { if ((cp = getenv("RECOLL_FILTERSDIR"))) {
cmd = path_cat(cp, icmd); cmd = path_cat(cp, icmd);
if (access(cmd.c_str(), X_OK) == 0) if (access(cmd.c_str(), X_OK) == 0)
return cmd; return cmd;
} else if (conf->getConfParam(string("filtersdir"), cmd)) { }
// Filters dir as configuration parameter?
if (getConfParam(string("filtersdir"), cmd)) {
cmd = path_cat(cmd, icmd); cmd = path_cat(cmd, icmd);
if (access(cmd.c_str(), X_OK) == 0) if (access(cmd.c_str(), X_OK) == 0)
return cmd; return cmd;
} else { }
cmd = path_cat(conf->getConfDir(), icmd);
if (access(cmd.c_str(), X_OK) == 0) // Filters dir as datadir subdir. Actually the standard case, but
return cmd; // this is normally the same value found in config file (previous step)
} cmd = path_cat(m_datadir, "filters");
cmd = path_cat(cmd, icmd);
if (access(cmd.c_str(), X_OK) == 0)
return cmd;
// Last resort for historical reasons: check in personal config
// directory
cmd = path_cat(getConfDir(), icmd);
if (access(cmd.c_str(), X_OK) == 0)
return cmd;
// Let the shell try to find it...
return icmd; return icmd;
} }

View File

@ -1,6 +1,6 @@
#ifndef _RCLCONFIG_H_INCLUDED_ #ifndef _RCLCONFIG_H_INCLUDED_
#define _RCLCONFIG_H_INCLUDED_ #define _RCLCONFIG_H_INCLUDED_
/* @(#$Id: rclconfig.h,v 1.11 2006-01-10 11:07:21 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: rclconfig.h,v 1.12 2006-01-19 17:11:46 dockes Exp $ (C) 2004 J.F.Dockes */
#include <list> #include <list>
@ -11,19 +11,25 @@ class RclConfig {
public: public:
RclConfig(); RclConfig();
~RclConfig() {delete conf;delete mimemap;delete mimeconf;} ~RclConfig() {
delete m_conf;
delete mimemap;
delete mimeconf;
delete mimemap_local;
delete stopsuffixes;
}
bool ok() {return m_ok;} bool ok() {return m_ok;}
const string &getReason() {return reason;} const string &getReason() {return reason;}
string getConfDir() {return confdir;} string getConfDir() {return m_confdir;}
//ConfTree *getConfig() {return m_ok ? conf : 0;} //ConfTree *getConfig() {return m_ok ? conf : 0;}
/// Get generic configuration parameter according to current keydir /// Get generic configuration parameter according to current keydir
bool getConfParam(const string &name, string &value) bool getConfParam(const string &name, string &value)
{ {
if (conf == 0) if (m_conf == 0)
return false; return false;
return conf->get(name, value, keydir); return m_conf->get(name, value, keydir);
} }
/* /*
@ -36,9 +42,9 @@ class RclConfig {
void setKeyDir(const string &dir) void setKeyDir(const string &dir)
{ {
keydir = dir; keydir = dir;
conf->get("defaultcharset", defcharset, keydir); m_conf->get("defaultcharset", defcharset, keydir);
string str; string str;
conf->get("guesscharset", str, keydir); m_conf->get("guesscharset", str, keydir);
guesscharset = stringToBool(str); guesscharset = stringToBool(str);
} }
@ -65,11 +71,14 @@ class RclConfig {
bool getGuessCharset() {return guesscharset;} bool getGuessCharset() {return guesscharset;}
std::list<string> getAllMimeTypes(); std::list<string> getAllMimeTypes();
std::string findFilter(const std::string& cmd);
private: private:
int m_ok; int m_ok;
string reason; // Explanation for bad state string reason; // Explanation for bad state
string confdir; // Directory where the files are stored string m_confdir; // Directory where the files are stored
ConfTree *conf; // Parsed main configuration string m_datadir; // Example: /usr/local/share/recoll
ConfTree *m_conf; // Parsed main configuration
string keydir; // Current directory used for parameter fetches. string keydir; // Current directory used for parameter fetches.
ConfTree *mimemap; // These are independant of current keydir. ConfTree *mimemap; // These are independant of current keydir.
@ -82,6 +91,5 @@ class RclConfig {
bool guesscharset; // They are fetched initially or on setKeydir() bool guesscharset; // They are fetched initially or on setKeydir()
}; };
std::string find_filter(RclConfig *conf, const string& cmd);
#endif /* _RCLCONFIG_H_INCLUDED_ */ #endif /* _RCLCONFIG_H_INCLUDED_ */

3
src/configure vendored
View File

@ -2296,6 +2296,8 @@ ac_config_files="$ac_config_files recollinstall"
ac_config_files="$ac_config_files sampleconf/recoll.conf" ac_config_files="$ac_config_files sampleconf/recoll.conf"
ac_config_files="$ac_config_files Makefile"
for d in bincimapmime index lib query for d in bincimapmime index lib query
do do
@ -2802,6 +2804,7 @@ do
"mk/localdefs" ) CONFIG_FILES="$CONFIG_FILES mk/localdefs" ;; "mk/localdefs" ) CONFIG_FILES="$CONFIG_FILES mk/localdefs" ;;
"recollinstall" ) CONFIG_FILES="$CONFIG_FILES recollinstall" ;; "recollinstall" ) CONFIG_FILES="$CONFIG_FILES recollinstall" ;;
"sampleconf/recoll.conf" ) CONFIG_FILES="$CONFIG_FILES sampleconf/recoll.conf" ;; "sampleconf/recoll.conf" ) CONFIG_FILES="$CONFIG_FILES sampleconf/recoll.conf" ;;
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
echo "$as_me: error: invalid argument: $ac_config_target" >&2;} echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
{ (exit 1); exit 1; }; };; { (exit 1); exit 1; }; };;

View File

@ -116,6 +116,7 @@ AC_SUBST(INCICONV)
AC_CONFIG_FILES(mk/localdefs) AC_CONFIG_FILES(mk/localdefs)
AC_CONFIG_FILES(recollinstall) AC_CONFIG_FILES(recollinstall)
AC_CONFIG_FILES(sampleconf/recoll.conf) AC_CONFIG_FILES(sampleconf/recoll.conf)
AC_CONFIG_FILES(Makefile)
for d in bincimapmime index lib query for d in bincimapmime index lib query
do do

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.13 2005-12-08 08:44:14 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: internfile.cpp,v 1.14 2006-01-19 17:11:46 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
#ifndef TEST_INTERNFILE #ifndef TEST_INTERNFILE
@ -33,7 +33,7 @@ static bool uncompressfile(RclConfig *conf, const string& ifn,
LOGERR(("uncompressfile: can't clear temp dir %s\n", tdir.c_str())); LOGERR(("uncompressfile: can't clear temp dir %s\n", tdir.c_str()));
return false; return false;
} }
string cmd = find_filter(conf, cmdv.front()); string cmd = conf->findFilter(cmdv.front());
// Substitute file name and temp dir in command elements // Substitute file name and temp dir in command elements
list<string>::const_iterator it = cmdv.begin(); list<string>::const_iterator it = cmdv.begin();

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: mh_exec.cpp,v 1.3 2005-11-24 07:16:15 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: mh_exec.cpp,v 1.4 2006-01-19 17:11:46 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
#include "execmd.h" #include "execmd.h"
@ -24,7 +24,7 @@ MimeHandlerExec::mkDoc(RclConfig *conf, const string &fn,
return MimeHandler::MHError; return MimeHandler::MHError;
} }
// Command name // Command name
string cmd = find_filter(conf, params.front()); string cmd = conf->findFilter(params.front());
// Build parameter list: delete cmd name and add the file name // Build parameter list: delete cmd name and add the file name
list<string>::iterator it = params.begin(); list<string>::iterator it = params.begin();

View File

@ -4,9 +4,12 @@ XAPIANCXXFLAGS=@XAPIANCXXFLAGS@
LIBICONV=@LIBICONV@ LIBICONV=@LIBICONV@
INCICONV=@INCICONV@ INCICONV=@INCICONV@
RECOLL_PREFIX=@prefix@
prefix = @prefix@
datadir = @datadir@
RECOLL_DATADIR = ${datadir}/recoll
LOCALCXXFLAGS = $(INCICONV) $(XAPIANCXXFLAGS) \ LOCALCXXFLAGS = $(INCICONV) $(XAPIANCXXFLAGS) \
-DRECOLL_PREFIX=\"$(RECOLL_PREFIX)\" -DRECOLL_DATADIR=\"$(RECOLL_DATADIR)\"
CXXFLAGS = -g CXXFLAGS = -g

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: main.cpp,v 1.28 2006-01-04 11:33:44 dockes Exp $ (C) 2005 J.F.Dockes"; static char rcsid[] = "@(#$Id: main.cpp,v 1.29 2006-01-19 17:11:46 dockes Exp $ (C) 2005 J.F.Dockes";
#endif #endif
#include <unistd.h> #include <unistd.h>
@ -30,7 +30,7 @@ using Rcl::AdvSearchData;
#include "recollmain.h" #include "recollmain.h"
static const char *recollprefix = RECOLL_PREFIX; static const char *recoll_datadir = RECOLL_DATADIR;
RclConfig *rclconfig; RclConfig *rclconfig;
Rcl::Db *rcldb; Rcl::Db *rcldb;
@ -137,8 +137,7 @@ int main( int argc, char ** argv )
a.installTranslator( &qt ); a.installTranslator( &qt );
// Translations for Recoll // Translations for Recoll
recollsharedir = path_cat(recollprefix, "share/recoll"); string translatdir = path_cat(recoll_datadir, "translations");
string translatdir = path_cat(recollsharedir, "translations");
QTranslator translator( 0 ); QTranslator translator( 0 );
// QTextCodec::locale() returns $LANG // QTextCodec::locale() returns $LANG
translator.load( QString("recoll_") + QTextCodec::locale(), translator.load( QString("recoll_") + QTextCodec::locale(),
@ -175,7 +174,7 @@ int main( int argc, char ** argv )
rclconfig->getConfParam("iconsdir", iconsdir); rclconfig->getConfParam("iconsdir", iconsdir);
if (iconsdir.empty()) { if (iconsdir.empty()) {
iconsdir = path_cat(recollsharedir, "images"); iconsdir = path_cat(recoll_datadir, "images");
} else { } else {
iconsdir = path_tildexpand(iconsdir); iconsdir = path_tildexpand(iconsdir);
} }
@ -232,7 +231,7 @@ bool startHelpBrowser(const string &iurl)
{ {
string url; string url;
if (iurl.empty()) { if (iurl.empty()) {
url = path_cat(recollsharedir, "doc"); url = path_cat(recoll_datadir, "doc");
url = path_cat(url, "usermanual.html"); url = path_cat(url, "usermanual.html");
url = string("file://") + url; url = string("file://") + url;
} else } else

View File

@ -33,7 +33,7 @@ unix {
UI_DIR = .ui UI_DIR = .ui
MOC_DIR = .moc MOC_DIR = .moc
OBJECTS_DIR = .obj OBJECTS_DIR = .obj
DEFINES += RECOLL_PREFIX=\"$(RECOLL_PREFIX)\" DEFINES += RECOLL_DATADIR=\"$(RECOLL_DATADIR)\"
LIBS += ../lib/librcl.a ../bincimapmime/libmime.a \ LIBS += ../lib/librcl.a ../bincimapmime/libmime.a \
$(BSTATIC) $(LIBXAPIAN) $(LIBICONV) $(BDYNAMIC) \ $(BSTATIC) $(LIBXAPIAN) $(LIBICONV) $(BDYNAMIC) \
-lz -lz

View File

@ -19,7 +19,7 @@ else
usage usage
fi fi
echo "Installing to $PREFIX"
test -n "$bindir" || bindir=${PREFIX}/bin test -n "$bindir" || bindir=${PREFIX}/bin
test -n "$datadir" || datadir=${PREFIX}/share test -n "$datadir" || datadir=${PREFIX}/share
if test -z "$mandir" ; then if test -z "$mandir" ; then
@ -30,7 +30,16 @@ if test -z "$mandir" ; then
fi fi
fi fi
INSTALL=${INSTALL:="install -c"} if test -n "$DESTDIR" ; then
PREFIX=$DESTDIR/$PREFIX
bindir=$DESTDIR/$bindir
datadir=$DESTDIR/$datadir
mandir=$DESTDIR/$mandir
fi
echo "Installing to $PREFIX"
INSTALL=${INSTALL:="install -c -v"}
STRIP=${STRIP:=strip} STRIP=${STRIP:=strip}
test -x qtgui/recoll || fatal "qtgui/recoll does not exist." \ test -x qtgui/recoll || fatal "qtgui/recoll does not exist." \