Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

Commit

Permalink
Add explicit support for being installed into a system triggered with…
Browse files Browse the repository at this point in the history
… --enable-fhs-paths.

Add two mechanism for avoiding name-collisions in a system-wide
installation of charybdis. The ssld and bandb daemons, intended to be
directly used by ircd and not the user, install into libexec when
--enable-fhs-paths is set. For binaries which are meant to be in PATH
(bindir), such as ircd and viconf, there is now an option
--with-program-prefix=progprefix inspired by automake. If the user
specifies --with-program-prefix=charybdis, the ircd binary is named
charybdisircd when installed.

Add support for saving the pidfile to a rundir and storing the ban
database in localstatedir instead of in sysconfdir. This is, again,
conditional on --enable-fhs-paths.

Fix(?) genssl.sh to always write created SSL key/certificate/dh
parameters to the sysconfdir specified during ./configure. The
previous behavior was to assume that the user ran genssl.sh after
ensuring that his current working directory was either sysconfdir or a
sibling directory of sysconfdir.
  • Loading branch information
binki committed Mar 1, 2012
1 parent f2ee5e6 commit c74836d
Show file tree
Hide file tree
Showing 19 changed files with 233 additions and 93 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -34,6 +34,7 @@ src/y.tab.c
ssld/ssld
tools/convertilines
tools/convertklines
tools/genssl.sh
tools/mkpasswd
tools/viconf
include/serno.h
25 changes: 19 additions & 6 deletions Makefile.in
Expand Up @@ -24,10 +24,17 @@ prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
mandir = @mandir@
libdir = @libdir@
pkglibdir = @pkglibdir@
moduledir = @moduledir@
helpdir = @helpdir@
confdir = @confdir@
logdir = @logdir@
rundir = @rundir@
pkgrundir = @pkgrundir@
localstatedir = @localstatedir@
pkglocalstatedir= @pkglocalstatedir@
PACKAGE_TARNAME = @PACKAGE_TARNAME@

# Default CFLAGS
# CFLAGS = -g -O2 -DNDEBUG
Expand Down Expand Up @@ -118,21 +125,27 @@ lint:
install-mkdirs:
@echo "ircd: setting up ircd directory structure"
-@if test ! -d $(DESTDIR)$(prefix); then \
mkdir $(DESTDIR)$(prefix); \
mkdir -p -m 755 $(DESTDIR)$(prefix); \
fi
-@if test ! -d $(DESTDIR)$(bindir); then \
mkdir $(DESTDIR)$(bindir); \
mkdir -p -m 755 $(DESTDIR)$(bindir); \
fi
-@if test ! -d $(DESTDIR)$(confdir); then \
mkdir $(DESTDIR)$(confdir); \
mkdir -p -m 755 $(DESTDIR)$(confdir); \
fi
-@if test ! -d $(DESTDIR)$(mandir); then \
mkdir $(DESTDIR)$(mandir); \
mkdir -p -m 755 $(DESTDIR)$(mandir); \
fi
-@if test ! -d $(DESTDIR)$(logdir); then \
mkdir $(DESTDIR)$(logdir); \
mkdir -p -m 755 $(DESTDIR)$(logdir); \
fi

-@if test ! -d '$(DESTDIR)$(pkgrundir)'; then \
mkdir -p -m 755 '$(DESTDIR)$(pkgrundir)'; \
fi
-@if test ! -d '$(DESTDIR)$(pkglocalstatedir)'; then \
mkdir -p -m 755 '$(DESTDIR)$(pkglocalstatedir)'; \
fi

install: install-mkdirs all
@for i in $(SUBDIRS); do \
echo "install ==> $$i";\
Expand Down
8 changes: 6 additions & 2 deletions aclocal.m4
Expand Up @@ -2,8 +2,12 @@
AC_DEFUN([AC_DEFINE_DIR], [
test "x$prefix" = xNONE && prefix="$ac_default_prefix"
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
ac_define_dir=`eval echo [$]$2`
ac_define_dir=`eval echo [$]ac_define_dir`
last_ac_define_dir=`eval echo [$]$2`
ac_define_dir=`eval echo [$]last_ac_define_dir`
while test "x[$]last_ac_define_dir" != "x[$]ac_define_dir"; do
last_ac_define_dir="[$]ac_define_dir"
ac_define_dir=`eval echo [$]last_ac_define_dir`
done
$1="$ac_define_dir"
AC_SUBST($1)
ifelse($3, ,
Expand Down
22 changes: 17 additions & 5 deletions bandb/Makefile.in
Expand Up @@ -22,8 +22,12 @@ exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
libexecdir = @libexecdir@
pkglibexecdir = @pkglibexecdir@
confdir = @confdir@
localstatedir = @localstatedir@
PACKAGE_TARNAME = @PACKAGE_TARNAME@

PROGRAM_PREFIX = @PROGRAM_PREFIX@

ZIP_LIB = @ZLIB_LD@

Expand All @@ -34,7 +38,9 @@ CPPFLAGS = ${INCLUDES} @CPPFLAGS@

CFLAGS += -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION=1

PROGS = bandb bantool
pkglibexec_PROGS = bandb
bin_PROGS = bantool
PROGS = $(pkglibexec_PROGS) $(bin_PROGS)

BANDB_SOURCES = \
bandb.c \
Expand Down Expand Up @@ -64,12 +70,18 @@ bantool: ${BANTOOL_OBJECTS}

install: build
@echo "ircd: installing bandb ($(PROGS))"
@for i in $(PROGS); do \
if test -f $(DESTDIR)$(bindir)/$$i; then \
$(MV) $(DESTDIR)$(bindir)/$$i $(DESTDIR)$(bindir)/$$i.old; \
@for i in $(bin_PROGS); do \
if test -f $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i; then \
$(MV) $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i.old; \
fi; \
$(INSTALL_BIN) $$i $(DESTDIR)$(bindir); \
$(INSTALL_BIN) $$i $(DESTDIR)$(bindir)/$(PROGRAM_PREFIX)$$i; \
done
@for i in $(pkglibexec_PROGS); do \
if test -f '$(DESTDIR)$(pkglibexecdir)/'$$i; then \
$(MV) '$(DESTDIR)$(pkglibexecdir)/'$$i '$(DESTDIR)$(pkglibexecdir)/'$$i.old; \
fi; \
$(INSTALL_BIN) $$i '$(DESTDIR)$(pkglibexecdir)/'$$i; \
done

.c.o:
${CC} ${CPPFLAGS} ${CFLAGS} -c $<
Expand Down
112 changes: 82 additions & 30 deletions configure.ac
Expand Up @@ -225,12 +225,37 @@ if test "$LEX" = ":"; then
AC_MSG_ERROR([could not locate a suitable lexical generator, install flex or lex.])
fi

AC_ARG_ENABLE([fhs-paths],
[AS_HELP_STRING([--enable-fhs-paths], [User more FHS-like pathnames (for packagers).])],
[],
[dnl detect if the user appears to want --enable-fhs-paths
AS_IF([test "$libexecdir" = '${exec_prefix}/libexec' && \
test "$localstatedir" = '${prefix}/var' && \
test "$libdir" = '${exec_prefix}/lib'],
[enable_fhs_paths=no],
[enable_fhs_paths=yes])
])
dnl use directory structure of cached as default (hack)
if test "$libexecdir" = '${exec_prefix}/libexec' &&
test "$localstatedir" = '${prefix}/var'; then
libexecdir='${bindir}'
AS_IF([test "x$enable_fhs_paths" = "xyes"],
[dnl Avoid name collisions.
pkglibexecdir='${libexecdir}/${PACKAGE_TARNAME}'
rundir=${rundir-'${prefix}/run'}
pkgrundir='${rundir}/${PACKAGE_TARNAME}'
pkglocalstatedir='${localstatedir}/${PACKAGE_TARNAME}'],
[libexecdir='${bindir}'
pkglibexecdir='${libexecdir}'
rundir='${sysconfdir}'
pkgrundir='${rundir}'
localstatedir='${prefix}'
fi
pkglocalstatedir='${sysconfdir}'])
pkglibdir='${libdir}/${PACKAGE_TARNAME}'
AC_SUBST([pkglibdir])
AC_SUBST([rundir])
AC_SUBST([pkgrundir])
AC_SUBST([pkglocalstatedir])
AC_DEFINE_DIR([PKGLOCALSTATEDIR], [pkglocalstatedir], [[Directory in which to store state, such as band database]])
AC_SUBST([pkglibexecdir])
AC_DEFINE_DIR([PKGLIBEXECDIR], [pkglibexecdir], [Directory where binaries the IRCd itself spawns live])

dnl Checks for header files.
AC_HEADER_STDC
Expand Down Expand Up @@ -595,7 +620,7 @@ AC_HELP_STRING([--with-confdir=DIR],
AC_MSG_RESULT(yes)
AC_DEFINE_DIR(ETC_DIR, confdir, [Prefix where config files are installed.])
AC_SUBST_DIR([confdir]) ],
[ confdir='${prefix}/etc'
[ confdir='${sysconfdir}'
AC_MSG_RESULT(no)
AC_DEFINE_DIR(ETC_DIR, confdir, [Prefix where config files are installed.])
AC_SUBST_DIR([confdir])]
Expand All @@ -610,14 +635,13 @@ AC_ARG_WITH(logdir,
AC_HELP_STRING([--with-logdir=DIR],
[Directory where to write logfiles.]),
[ logdir=`echo $withval | sed 's/\/$//'`
AC_MSG_RESULT(yes)
AC_DEFINE_DIR(LOG_DIR, logdir, [Prefix where to write logfiles.])
AC_SUBST_DIR([logdir]) ],
[ logdir='${prefix}/logs'
AC_MSG_RESULT(no)
AC_DEFINE_DIR(LOG_DIR, logdir, [Prefix where to write logfiles.])
AC_SUBST_DIR([logdir])]
)
AC_MSG_RESULT(yes)],
[ AS_IF([test "x$enable_fhs_paths" = "xyes"],
[logdir='${localstatedir}/log/${PACKAGE_TARNAME}'],
[logdir='${prefix}/logs'])
AC_MSG_RESULT(no)])
AC_DEFINE_DIR([LOG_DIR], [logdir], [Prefix where to write logfiles.])
AC_SUBST_DIR([logdir])

dnl **********************************************************************
dnl Check for --with-helpdir
Expand All @@ -628,32 +652,58 @@ AC_ARG_WITH(helpdir,
AC_HELP_STRING([--with-helpdir=DIR],
[Directory to install help files.]),
[ helpdir=`echo $withval | sed 's/\/$//'`
AC_MSG_RESULT(yes)
AC_DEFINE_DIR(HELP_DIR, helpdir, [Prefix where help files are installed.])
AC_SUBST_DIR([helpdir]) ],
[ helpdir='${prefix}/help'
AC_MSG_RESULT(no)
AC_DEFINE_DIR(HELP_DIR, helpdir, [Prefix where help file are installed.])
AC_SUBST_DIR([helpdir])]
)
AC_MSG_RESULT(yes) ],
[ AS_IF([test "x$enable_fhs_paths" = "xyes"],
[helpdir='${datadir}/${PACKAGE_TARNAME}/help'],
[helpdir='${prefix}/help'])
AC_MSG_RESULT(no) ])
AC_DEFINE_DIR([HELP_DIR], [helpdir], [Prefix where help files are installed.])
AC_SUBST_DIR([helpdir])

dnl **********************************************************************
dnl Check for --with-moduledir
dnl **********************************************************************

AC_MSG_CHECKING([whether to modify moduledir])
AC_ARG_WITH(moduledir,
AC_HELP_STRING([--with-moduledir=DIR],
[Directory to install modules.]),
[AC_HELP_STRING([--with-moduledir=DIR],
[Directory to install modules.])],
[ moduledir=`echo $withval | sed 's/\/$//'`
AC_MSG_RESULT(yes)
AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
AC_SUBST_DIR([moduledir]) ],
[ moduledir='${prefix}/modules'
AC_MSG_RESULT(yes)],
[ AS_IF([test "x$enable_fhs_paths" = "xyes"],
[moduledir='${pkglibdir}/modules'],
[moduledir='${prefix}/modules'])
AC_MSG_RESULT(no)
AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
AC_SUBST_DIR([moduledir])]
)
])
AC_DEFINE_DIR(MODULE_DIR, moduledir, [Prefix where modules are installed.])
AC_SUBST_DIR([moduledir])

dnl Check for --with-rundir

AC_MSG_CHECKING([whether or modify rundir])
AC_ARG_WITH([rundir],
[AC_HELP_STRING([--with-rundir=DIR],
[Directory in which to store pidfile.])],
[AC_MSG_RESULT([yes])
rundir=`echo $withval | sed 's/\/$//'`],
[AC_MSG_RESULT([no])
AS_IF([test "x$enable_fhs_paths" = "xyes"],
[rundir='${prefix}/run'],
[rundir='${sysconfdir}'])])
AC_SUBST([rundir])
AC_DEFINE_DIR([PKGRUNDIR], [pkgrundir], [Directory to store pidfile in.])

dnl Installed utility program prefixes (does not affect binaries
dnl installed into pkglibexecdir)
AC_MSG_CHECKING([for program prefix])
AC_ARG_WITH([program-prefix],
[AS_HELP_STRING([--with-program-prefix=], [If set, programs installed into PATH will be installed with names prefixed by this prefix.])],
[test "x$with_program_prefix" = "xno" && with_program_prefix=],
[with_program_prefix=])
AC_MSG_RESULT(["$with_program_prefix"])
PROGRAM_PREFIX="$with_program_prefix"
AC_SUBST([PROGRAM_PREFIX])
AC_DEFINE_UNQUOTED([PROGRAM_PREFIX], ["$with_program_prefix"], [String with which all programs intended to be in PATH are prefixed.])

dnl **********************************************************************
dnl Branding
Expand Down Expand Up @@ -1197,9 +1247,11 @@ AC_CONFIG_FILES( \
src/Makefile \
modules/Makefile \
tools/Makefile \
tools/genssl.sh \
doc/Makefile \
help/Makefile \
)
AC_CONFIG_COMMANDS([tools/genssl.sh_chmod], [chmod 755 tools/genssl.sh])

AC_OUTPUT

Expand Down
6 changes: 4 additions & 2 deletions doc/Makefile.in
Expand Up @@ -15,6 +15,8 @@ RM = @RM@
CP = @CP@
TOUCH = @TOUCH@

PROGRAM_PREFIX = @PROGRAM_PREFIX@

prefix = @prefix@
exec_prefix = @exec_prefix@
exec_suffix = @exec_suffix@
Expand Down Expand Up @@ -73,8 +75,8 @@ install: install-mkdirs build

@echo "ircd: installing manpage"
@for i in $(MANPAGES); do \
if test ! -f $(DESTDIR)$(mandir)/$$i; then \
$(INSTALL_DATA) $$i $(DESTDIR)$(mandir); \
if test ! -f $(DESTDIR)$(mandir)/$(PROGRAM_PREFIX)$$i; then \
$(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/$(PROGRAM_PREFIX)$$i; \
fi; \
done

Expand Down
9 changes: 8 additions & 1 deletion extensions/Makefile.in
Expand Up @@ -16,7 +16,14 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SUID = @INSTALL_PROGRAM@ -o root -m 4755
SHELL = /bin/sh
AUTOMODULEDIR = @moduledir@/extensions

prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
pkglibdir = @pkglibdir@
moduledir = @moduledir@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
AUTOMODULEDIR = $(moduledir)/extensions

SSL_LIBS = @SSL_LIBS@
SSL_INCLUDES = @SSL_INCLUDES@
Expand Down
4 changes: 3 additions & 1 deletion help/Makefile.in
Expand Up @@ -7,7 +7,9 @@ INSTALL_DATA= @INSTALL_DATA@
RM= @RM@

prefix= @prefix@
exec_prefix= @execprefix@
exec_prefix= @exec_prefix@
datarootdir = @datarootdir@
datadir = @datadir@
helpdir= @helpdir@
uhelpdir= ${helpdir}/users
ohelpdir= ${helpdir}/opers
Expand Down
7 changes: 3 additions & 4 deletions include/config.h
Expand Up @@ -59,14 +59,13 @@
#define HPATH HELP_DIR "/opers"

/* files */
#define SPATH BINPATH "/ircd" /* ircd executable */
#define LIPATH LIBPATH "/libircd" SHARED_SUFFIX /* ircd library */
#define SPATH BINPATH "/" PROGRAM_PREFIX "ircd" /* ircd executable */
#define CPATH ETCPATH "/ircd.conf" /* ircd.conf file */
#define MPATH ETCPATH "/ircd.motd" /* MOTD file */
#define LPATH LOGPATH "/ircd.log" /* ircd logfile */
#define PPATH ETCPATH "/ircd.pid" /* pid file */
#define PPATH PKGRUNDIR "/ircd.pid" /* pid file */
#define OPATH ETCPATH "/opers.motd" /* oper MOTD file */
#define DBPATH ETCPATH "/ban.db" /* bandb file */
#define DBPATH PKGLOCALSTATEDIR "/ban.db" /* bandb file */

/* IGNORE_BOGUS_TS
* Ignore bogus timestamps from other servers. Yes this will desync
Expand Down
8 changes: 6 additions & 2 deletions libratbox/acinclude.m4
Expand Up @@ -2,8 +2,12 @@
AC_DEFUN([AC_DEFINE_DIR], [
test "x$prefix" = xNONE && prefix="$ac_default_prefix"
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
ac_define_dir=`eval echo [$]$2`
ac_define_dir=`eval echo [$]ac_define_dir`
last_ac_define_dir=`eval echo [$]$2`
ac_define_dir=`eval echo [$]last_ac_define_dir`
while test "x[$]last_ac_define_dir" != "x[$]ac_define_dir"; do
last_ac_define_dir="[$]ac_define_dir"
ac_define_dir=`eval echo [$]last_ac_define_dir`
done
$1="$ac_define_dir"
AC_SUBST($1)
ifelse($3, ,
Expand Down
4 changes: 4 additions & 0 deletions modules/Makefile.in
Expand Up @@ -28,7 +28,11 @@ SSL_INCLUDES = @SSL_INCLUDES@
IRCDLIBS = @LIBS@ $(SSL_LIBS)

prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
pkglibdir = @pkglibdir@
moduledir = @moduledir@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
# Change this later! -- adrian
automoduledir = @moduledir@/autoload

Expand Down

0 comments on commit c74836d

Please sign in to comment.