From 3080914d23f46b098fd8e8503d68b81d828fee97 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 20 Jun 2011 18:02:00 +0200 Subject: [PATCH 1/6] Revert "build: Put lockdir and cachedir in FHS-like locations by default" This reverts commit 6c9a78074a429773cefd1a3c798b7e3ad7d4c325. --- dynconfig/wscript | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dynconfig/wscript b/dynconfig/wscript index d6b07ef..ccb181c 100755 --- a/dynconfig/wscript +++ b/dynconfig/wscript @@ -9,8 +9,8 @@ dir_options = { 'with-privatedir' : [ '${PREFIX}/private', 'Where to put sam.ldb and other private files' ], 'with-sockets-dir' : [ '${LOCALSTATEDIR}/run', 'sockets directory' ], 'with-winbindd-privileged-socket-dir' : [ '${LOCALSTATEDIR}/lib/winbindd_privileged', 'winbind privileged socket directory'], - 'with-lockdir' : [ '${LOCALSTATEDIR}/lock', 'where to put short term disposable state files' ], - 'with-cachedir' : [ '${LOCALSTATEDIR}/cache', 'where to put cache files' ], + 'with-lockdir' : [ '${LOCALSTATEDIR}/locks', 'where to put short term disposable state files' ], + 'with-cachedir' : [ '${LOCALSTATEDIR}/locks', 'where to put cache files' ], 'with-logfilebase' : [ '${LOCALSTATEDIR}', 'Where to put log files' ], 'with-pammodulesdir' : [ '${LIBDIR}', 'Which directory to use for PAM modules' ], 'with-statedir' : [ '${LOCALSTATEDIR}/locks', 'where to put persistent state files' ], -- 1.7.4.1 From dac016fafcacca2266965f5066cae62c28cb608a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 20 Jun 2011 18:02:04 +0200 Subject: [PATCH 2/6] Revert "s4-build Change default paths and --with flags for a 4.0 release" This reverts commit edd3e8b03aa0bca85d4a9a62b35471e76a1f9390. --- dynconfig/wscript | 78 +++++++++++++++++++++++++++++++++++++++------------- wscript_build | 2 +- 2 files changed, 59 insertions(+), 21 deletions(-) diff --git a/dynconfig/wscript b/dynconfig/wscript index ccb181c..8219234 100755 --- a/dynconfig/wscript +++ b/dynconfig/wscript @@ -5,15 +5,12 @@ from samba_utils import EXPAND_VARIABLES, os_path_relpath # list of directory options to offer in configure dir_options = { - 'with-piddir' : [ '${LOCALSTATEDIR}/run', 'where to put pid files' ], + 'with-piddir' : [ '${PREFIX}/var/run', 'where to put pid files' ], 'with-privatedir' : [ '${PREFIX}/private', 'Where to put sam.ldb and other private files' ], - 'with-sockets-dir' : [ '${LOCALSTATEDIR}/run', 'sockets directory' ], - 'with-winbindd-privileged-socket-dir' : [ '${LOCALSTATEDIR}/lib/winbindd_privileged', 'winbind privileged socket directory'], - 'with-lockdir' : [ '${LOCALSTATEDIR}/locks', 'where to put short term disposable state files' ], - 'with-cachedir' : [ '${LOCALSTATEDIR}/locks', 'where to put cache files' ], - 'with-logfilebase' : [ '${LOCALSTATEDIR}', 'Where to put log files' ], - 'with-pammodulesdir' : [ '${LIBDIR}', 'Which directory to use for PAM modules' ], - 'with-statedir' : [ '${LOCALSTATEDIR}/locks', 'where to put persistent state files' ], + 'with-winbindd-socket-dir' : [ '${PREFIX}/var/lib/winbindd', 'winbind socket directory' ], + 'with-winbindd-privileged-socket-dir' : [ '${PREFIX}/var/lib/winbindd_privileged', 'winbind privileged socket directory'], + 'with-ntp-signd-socket-dir' : [ '${PREFIX}/var/run/ntp_signd', 'NTP signed directory'], + 'with-lockdir' : [ '${PREFIX}/var/locks', 'where to put lock files' ] } # list of cflags to use for dynconfig.c @@ -25,30 +22,56 @@ dyn_cflags = { 'CONFIGFILE' : '${SYSCONFDIR}/smb.conf', 'LMHOSTSFILE' : '${SYSCONFDIR}/lmhosts', 'PRIVATE_DIR' : '${PRIVATEDIR}', - 'LOGFILEBASE' : '${LOGFILEBASE}', - 'LOCKDIR' : '${LOCKDIR}', - 'PIDDIR' : '${PIDDIR}', + 'LOGFILEBASE' : '${LOCALSTATEDIR}', + 'LOCKDIR' : '${LOCALSTATEDIR}/locks', + 'PIDDIR' : '${LOCALSTATEDIR}/run', 'DATADIR' : '${DATADIR}', 'LOCALEDIR' : '${LOCALEDIR}', 'SETUPDIR' : '${DATADIR}/setup', - 'WINBINDD_SOCKET_DIR' : '${SOCKETS_DIR}/winbindd', + 'WINBINDD_SOCKET_DIR' : '${WINBINDD_SOCKET_DIR}', 'WINBINDD_PRIVILEGED_SOCKET_DIR' : '${WINBINDD_PRIVILEGED_SOCKET_DIR}', - 'NTP_SIGND_SOCKET_DIR' : '${SOCKETS_DIR}/ntp_signd', - 'NCALRPCDIR' : '${SOCKETS_DIR}/ncalrpc', + 'NTP_SIGND_SOCKET_DIR' : '${NTP_SIGND_SOCKET_DIR}', + 'NCALRPCDIR' : '${LOCALSTATEDIR}/ncalrpc', 'PYTHONDIR' : '${PYTHONDIR}', 'PYTHONARCHDIR' : '${PYTHONARCHDIR}', 'MODULESDIR' : '${PREFIX}/modules', 'INCLUDEDIR' : '${PREFIX}/include', 'PKGCONFIGDIR' : '${LIBDIR}/pkgconfig', 'SWATDIR' : '${DATADIR}/swat', - 'CODEPAGEDIR' : '${DATADIR}/codepages', + 'CODEPAGEDIR' : '${LIBDIR}/samba', 'LIBDIR' : '${LIBDIR}', - 'LIBEXECDIR' : '${LIBEXECDIR}', - 'STATEDIR' : '${STATEDIR}', - 'CACHEDIR' : '${CACHEDIR}', + 'LIBEXECDIR' : '${MODULESDIR}', + 'STATEDIR' : '${LOCALSTATEDIR}', + 'CACHEDIR' : '${LOCKDIR}', 'SMB_PASSWD_FILE' : '${PRIVATEDIR}/smbpasswd', - 'NMBDSOCKETDIR' : '${SOCKETS_DIR}/nmbd', - 'PAMMODULESDIR' : '${PAMMODULESDIR}', + 'NMBDSOCKETDIR' : '${LOCALSTATEDIR}/nmbd', + } + +# changes for when FHS is enabled +dyn_cflags_fhs = { + 'BINDIR' : '${BINDIR}', + 'SBINDIR' : '${SBINDIR}', + 'SCRIPTSBINDIR' : '${SBINDIR}', + 'CONFIGDIR' : '${SYSCONFDIR}/samba', + 'CONFIGFILE' : '${SYSCONFDIR}/samba/smb.conf', + 'LMHOSTSFILE' : '${SYSCONFDIR}/samba/lmhosts', + 'PRIVATE_DIR' : '${LOCALSTATEDIR}/lib/samba/private', + 'LOGFILEBASE' : '${LOCALSTATEDIR}/log/samba', + 'LOCKDIR' : '${LOCALSTATEDIR}/lib/samba', + 'PIDDIR' : '${LOCALSTATEDIR}/run/samba', + 'SETUPDIR' : '${DATADIR}/samba/setup', + 'WINBINDD_SOCKET_DIR' : '${LOCALSTATEDIR}/run/samba/winbindd', + 'WINBINDD_PRIVILEGED_SOCKET_DIR' : '${LOCALSTATEDIR}/run/samba/winbindd_privileged', + 'NTP_SIGND_SOCKET_DIR' : '${LOCALSTATEDIR}/run/samba/ntp_signd', + 'NCALRPCDIR' : '${LOCALSTATEDIR}/run/samba/ncalrpc', + 'PYTHONARCHDIR' : '${PYTHONARCHDIR}', + 'MODULESDIR' : '${LIBDIR}/samba', + 'LIBEXECDIR' : '${MODULESDIR}', + 'INCLUDEDIR' : '${INCLUDEDIR}/samba-4.0', + 'PKGCONFIGDIR' : '${LIBDIR}/pkgconfig', + 'SWATDIR' : '${DATADIR}/swat', + 'CODEPAGEDIR' : '${DATADIR}/samba', + 'NMBDSOCKETDIR' : '${LOCALSTATEDIR}/run/samba/nmbd', } def get_varname(v): @@ -62,6 +85,9 @@ def get_varname(v): def set_options(opt): # get all the basic GNU options from the gnu_dirs tool + opt.add_option('--enable-fhs', + help=("Use FHS-compliant paths (default no)"), + action="store_true", dest='ENABLE_FHS', default=False) for option in dir_options.keys(): default = dir_options[option][0] help = dir_options[option][1] @@ -84,6 +110,18 @@ def configure(conf): conf.ASSERT(v != '', "Empty dynconfig value for %s" % f) conf.env[f] = v + if Options.options.ENABLE_FHS: + for f in dyn_cflags_fhs.keys(): + v = EXPAND_VARIABLES(conf, dyn_cflags_fhs[f]) + conf.ASSERT(v != '', "Empty dynconfig value for %s" % f) + conf.env[f] = v + + if (not Options.options.ENABLE_FHS and + (conf.env.PREFIX == '/usr' or conf.env.PREFIX == '/usr/local')): + print("ERROR: Don't install directly under /usr or /usr/local without using the FHS option (--enable-fhs)") + sys.exit(1) + + def dynconfig_cflags(bld, list=None): '''work out the extra CFLAGS for dynconfig.c''' cflags = [] diff --git a/wscript_build b/wscript_build index bfbbafb..eb5f993 100644 --- a/wscript_build +++ b/wscript_build @@ -124,6 +124,6 @@ bld.RECURSE('source3') bld.RECURSE('testsuite/headers') # install some extra empty directories -bld.INSTALL_DIRS("", "${LOCKDIR} ${STATEDIR} ${CACHEDIR} ${SWATDIR} ${SYSCONFDIR} ${PIDDIR} ${LOCALSTATEDIR}/lib ${PRIVATEDIR}/smbd.tmp/messaging ${CODEPAGEDIR} ${LOGFILEBASE} ${SETUPDIR}") +bld.INSTALL_DIRS("", "${LOCKDIR} ${SYSCONFDIR} ${LOCKDIR} ${PIDDIR} ${LOCALSTATEDIR}/lib ${PRIVATEDIR}/smbd.tmp/messaging") bld.SYMBOL_CHECK() -- 1.7.4.1 From 9da4312fa5b815f90e93fb2759096225d6b48992 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Jun 2011 12:07:17 +0200 Subject: [PATCH 3/6] dynconfig: use an option group for the samba specific options metze --- dynconfig/wscript | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dynconfig/wscript b/dynconfig/wscript index 8219234..6dcc362 100755 --- a/dynconfig/wscript +++ b/dynconfig/wscript @@ -85,14 +85,16 @@ def get_varname(v): def set_options(opt): # get all the basic GNU options from the gnu_dirs tool - opt.add_option('--enable-fhs', + opt_group=opt.add_option_group('Samba-specific directory layout','') + + opt_group.add_option('--enable-fhs', help=("Use FHS-compliant paths (default no)"), action="store_true", dest='ENABLE_FHS', default=False) for option in dir_options.keys(): default = dir_options[option][0] help = dir_options[option][1] varname = get_varname(option) - opt.add_option('--%s' % option, + opt_group.add_option('--%s' % option, help=(help + ' [%s]' % default), action="store", dest=varname, default=default) -- 1.7.4.1 From f016100df7f371ab883ec6af131340ea3d8cec29 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Jun 2011 12:09:40 +0200 Subject: [PATCH 4/6] dynconfig: remember which options still have their default value If the values are explicit specified on the command line, we need to keep them. metze --- dynconfig/wscript | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dynconfig/wscript b/dynconfig/wscript index 6dcc362..524cbd8 100755 --- a/dynconfig/wscript +++ b/dynconfig/wscript @@ -100,23 +100,31 @@ def set_options(opt): def configure(conf): # get all the basic GNU options from the gnu_dirs tool + + explicit_set = {} + for option in dir_options.keys(): + default = dir_options[option][0] varname = get_varname(option) value = getattr(Options.options, varname, None) conf.ASSERT(value is not None, "Missing configure option %s" % varname) conf.ASSERT(varname not in conf.env, "Variable %s already defined" % varname) conf.env[varname] = value + if value is not default: + explicit_set[varname] = "%s:%s" % (default, value) for f in dyn_cflags.keys(): v = EXPAND_VARIABLES(conf, dyn_cflags[f]) conf.ASSERT(v != '', "Empty dynconfig value for %s" % f) - conf.env[f] = v + if f not in explicit_set: + conf.env[f] = v if Options.options.ENABLE_FHS: for f in dyn_cflags_fhs.keys(): v = EXPAND_VARIABLES(conf, dyn_cflags_fhs[f]) conf.ASSERT(v != '', "Empty dynconfig value for %s" % f) - conf.env[f] = v + if f not in explicit_set: + conf.env[f] = v if (not Options.options.ENABLE_FHS and (conf.env.PREFIX == '/usr' or conf.env.PREFIX == '/usr/local')): -- 1.7.4.1 From 829fcadbc97c71b6412db7886f19a02852732df4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Jun 2011 17:46:36 +0200 Subject: [PATCH 5/6] dynconfig: add SambaIndentedHelpFormatter in order to support \n in option help text metze --- dynconfig/wscript | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 54 insertions(+), 1 deletions(-) diff --git a/dynconfig/wscript b/dynconfig/wscript index 524cbd8..ba1809d 100755 --- a/dynconfig/wscript +++ b/dynconfig/wscript @@ -1,8 +1,58 @@ #!/usr/bin/env python -import string, Utils, Options, sys, Build, os, intltool +import string, Utils, Options, sys, Build, os, intltool, optparse, textwrap from samba_utils import EXPAND_VARIABLES, os_path_relpath +class SambaIndentedHelpFormatter (optparse.IndentedHelpFormatter): + """Format help with indented section bodies. + """ + + def __init__(self, + indent_increment=2, + max_help_position=12, + width=None, + short_first=1): + optparse.IndentedHelpFormatter.__init__( + self, indent_increment, max_help_position, width, short_first) + + def format_option(self, option): + # The help for each option consists of two parts: + # * the opt strings and metavars + # eg. ("-x", or "-fFILENAME, --file=FILENAME") + # * the user-supplied help string + # eg. ("turn on expert mode", "read data from FILENAME") + # + # If possible, we write both of these on the same line: + # -x turn on expert mode + # + # But if the opt string list is too long, we put the help + # string on a second line, indented to the same column it would + # start in if it fit on the first line. + # -fFILENAME, --file=FILENAME + # read data from FILENAME + result = [] + opts = self.option_strings[option] + opt_width = self.help_position - self.current_indent - 2 + if len(opts) > opt_width: + opts = "%*s%s\n" % (self.current_indent, "", opts) + indent_first = self.help_position + else: # start help on same line as opts + opts = "%*s%-*s " % (self.current_indent, "", opt_width, opts) + indent_first = 0 + result.append(opts) + if option.help: + help_text = self.expand_default(option) + if string.find(help_text, '\n') == -1: + help_lines = textwrap.wrap(help_text, self.help_width) + else: + help_lines = help_text.splitlines() + result.append("%*s%s\n" % (indent_first, "", help_lines[0])) + result.extend(["%*s%s\n" % (self.help_position, "", line) + for line in help_lines[1:]]) + elif opts[-1] != "\n": + result.append("\n") + return "".join(result) + # list of directory options to offer in configure dir_options = { 'with-piddir' : [ '${PREFIX}/var/run', 'where to put pid files' ], @@ -85,6 +135,9 @@ def get_varname(v): def set_options(opt): # get all the basic GNU options from the gnu_dirs tool + opt.parser.formatter = SambaIndentedHelpFormatter() + opt.parser.formatter.width=Utils.get_term_cols() + opt_group=opt.add_option_group('Samba-specific directory layout','') opt_group.add_option('--enable-fhs', -- 1.7.4.1 From 703bcf43c2ef02f516e872417fc35fab0fc6a5b8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 21 Jun 2011 17:49:06 +0200 Subject: [PATCH 6/6] dynconfig: rework the logic to support --enable-fhs This reorders the data structure which represents the options to build a more useful hierachy. This makes it more obvious which defaults values are used in the 'STD' and 'FHS' flavors. metze --- dynconfig/wscript | 394 +++++++++++++++++++++++++++++++++++++---------------- wscript_build | 3 - 2 files changed, 275 insertions(+), 122 deletions(-) diff --git a/dynconfig/wscript b/dynconfig/wscript index ba1809d..6bd07c4 100755 --- a/dynconfig/wscript +++ b/dynconfig/wscript @@ -1,6 +1,6 @@ #!/usr/bin/env python -import string, Utils, Options, sys, Build, os, intltool, optparse, textwrap +import string, Logs, Utils, Options, sys, Build, os, intltool, optparse, textwrap from samba_utils import EXPAND_VARIABLES, os_path_relpath class SambaIndentedHelpFormatter (optparse.IndentedHelpFormatter): @@ -53,137 +53,285 @@ class SambaIndentedHelpFormatter (optparse.IndentedHelpFormatter): result.append("\n") return "".join(result) -# list of directory options to offer in configure -dir_options = { - 'with-piddir' : [ '${PREFIX}/var/run', 'where to put pid files' ], - 'with-privatedir' : [ '${PREFIX}/private', 'Where to put sam.ldb and other private files' ], - 'with-winbindd-socket-dir' : [ '${PREFIX}/var/lib/winbindd', 'winbind socket directory' ], - 'with-winbindd-privileged-socket-dir' : [ '${PREFIX}/var/lib/winbindd_privileged', 'winbind privileged socket directory'], - 'with-ntp-signd-socket-dir' : [ '${PREFIX}/var/run/ntp_signd', 'NTP signed directory'], - 'with-lockdir' : [ '${PREFIX}/var/locks', 'where to put lock files' ] - } - -# list of cflags to use for dynconfig.c -dyn_cflags = { - 'BINDIR' : '${BINDIR}', - 'SBINDIR' : '${SBINDIR}', - 'SCRIPTSBINDIR' : '${SBINDIR}', - 'CONFIGDIR' : '${SYSCONFDIR}', - 'CONFIGFILE' : '${SYSCONFDIR}/smb.conf', - 'LMHOSTSFILE' : '${SYSCONFDIR}/lmhosts', - 'PRIVATE_DIR' : '${PRIVATEDIR}', - 'LOGFILEBASE' : '${LOCALSTATEDIR}', - 'LOCKDIR' : '${LOCALSTATEDIR}/locks', - 'PIDDIR' : '${LOCALSTATEDIR}/run', - 'DATADIR' : '${DATADIR}', - 'LOCALEDIR' : '${LOCALEDIR}', - 'SETUPDIR' : '${DATADIR}/setup', - 'WINBINDD_SOCKET_DIR' : '${WINBINDD_SOCKET_DIR}', - 'WINBINDD_PRIVILEGED_SOCKET_DIR' : '${WINBINDD_PRIVILEGED_SOCKET_DIR}', - 'NTP_SIGND_SOCKET_DIR' : '${NTP_SIGND_SOCKET_DIR}', - 'NCALRPCDIR' : '${LOCALSTATEDIR}/ncalrpc', - 'PYTHONDIR' : '${PYTHONDIR}', - 'PYTHONARCHDIR' : '${PYTHONARCHDIR}', - 'MODULESDIR' : '${PREFIX}/modules', - 'INCLUDEDIR' : '${PREFIX}/include', - 'PKGCONFIGDIR' : '${LIBDIR}/pkgconfig', - 'SWATDIR' : '${DATADIR}/swat', - 'CODEPAGEDIR' : '${LIBDIR}/samba', - 'LIBDIR' : '${LIBDIR}', - 'LIBEXECDIR' : '${MODULESDIR}', - 'STATEDIR' : '${LOCALSTATEDIR}', - 'CACHEDIR' : '${LOCKDIR}', - 'SMB_PASSWD_FILE' : '${PRIVATEDIR}/smbpasswd', - 'NMBDSOCKETDIR' : '${LOCALSTATEDIR}/nmbd', - } - -# changes for when FHS is enabled -dyn_cflags_fhs = { - 'BINDIR' : '${BINDIR}', - 'SBINDIR' : '${SBINDIR}', - 'SCRIPTSBINDIR' : '${SBINDIR}', - 'CONFIGDIR' : '${SYSCONFDIR}/samba', - 'CONFIGFILE' : '${SYSCONFDIR}/samba/smb.conf', - 'LMHOSTSFILE' : '${SYSCONFDIR}/samba/lmhosts', - 'PRIVATE_DIR' : '${LOCALSTATEDIR}/lib/samba/private', - 'LOGFILEBASE' : '${LOCALSTATEDIR}/log/samba', - 'LOCKDIR' : '${LOCALSTATEDIR}/lib/samba', - 'PIDDIR' : '${LOCALSTATEDIR}/run/samba', - 'SETUPDIR' : '${DATADIR}/samba/setup', - 'WINBINDD_SOCKET_DIR' : '${LOCALSTATEDIR}/run/samba/winbindd', - 'WINBINDD_PRIVILEGED_SOCKET_DIR' : '${LOCALSTATEDIR}/run/samba/winbindd_privileged', - 'NTP_SIGND_SOCKET_DIR' : '${LOCALSTATEDIR}/run/samba/ntp_signd', - 'NCALRPCDIR' : '${LOCALSTATEDIR}/run/samba/ncalrpc', - 'PYTHONARCHDIR' : '${PYTHONARCHDIR}', - 'MODULESDIR' : '${LIBDIR}/samba', - 'LIBEXECDIR' : '${MODULESDIR}', - 'INCLUDEDIR' : '${INCLUDEDIR}/samba-4.0', - 'PKGCONFIGDIR' : '${LIBDIR}/pkgconfig', - 'SWATDIR' : '${DATADIR}/swat', - 'CODEPAGEDIR' : '${DATADIR}/samba', - 'NMBDSOCKETDIR' : '${LOCALSTATEDIR}/run/samba/nmbd', - } - -def get_varname(v): - '''work out a variable name from a configure option name''' - if v.startswith('with-'): - v = v[5:] - v = v.upper() - v = v.replace('-', '_') - return v +# list of directory options to offer in configure +# +# 'STD' - the default path without --enable-fhs +# 'FHS' - the default path with --enable-fhs +# +# 'OPT' - the configure option to overwrite the default (optional) +# 'TXT' - the help text of the configure option (optional) +# +# 'OVW' - The option referrs to itself and was already from +# the basic GNU options from the gnu_dirs tool. +# We may overwrite the related path. (Default: False) +# +# 'DLY' - The option referrs to other options in the dynconfig list. +# We delay the intialization into a later stage. This +# makes sure the recursion works. (Default: False) +# +dynconfig = { + 'BINDIR' : { + 'STD': '${BINDIR}', + 'FHS': '${BINDIR}', + 'OVW': True, + }, + 'SBINDIR' : { + 'STD': '${SBINDIR}', + 'FHS': '${SBINDIR}', + 'OVW': True, + }, + 'LIBDIR' : { + 'STD': '${LIBDIR}', + 'FHS': '${LIBDIR}', + 'OVW': True, + }, + 'LIBEXECDIR' : { + 'STD': '${LIBEXECDIR}', + 'FHS': '${LIBEXECDIR}', + 'OVW': True, + }, + 'DATADIR' : { + 'STD': '${DATADIR}', + 'FHS': '${DATADIR}', + 'OVW': True, + }, + 'LOCALEDIR' : { + 'STD': '${LOCALEDIR}', + 'FHS': '${LOCALEDIR}', + 'OVW': True, + }, + 'PYTHONDIR' : { + 'STD': '${PYTHONDIR}', + 'FHS': '${PYTHONDIR}', + 'OVW': True, + }, + 'PYTHONARCHDIR' : { + 'STD': '${PYTHONARCHDIR}', + 'FHS': '${PYTHONARCHDIR}', + 'OVW': True, + }, + 'MODULESDIR' : { + 'STD': '${MODULESDIR}', + 'FHS': '${MODULESDIR}/samba', + 'OVW': True, + }, + 'INCLUDEDIR' : { + 'STD': '${INCLUDEDIR}', + 'FHS': '${INCLUDEDIR}/samba-4.0', + 'OVW': True, + }, + 'SCRIPTSBINDIR' : { + 'STD': '${SBINDIR}', + 'FHS': '${SBINDIR}', + }, + 'SETUPDIR' : { + 'STD': '${DATADIR}/setup', + 'FHS': '${DATADIR}/samba/setup', + }, + 'PKGCONFIGDIR' : { + 'STD': '${LIBDIR}/pkgconfig', + 'FHS': '${LIBDIR}/pkgconfig', + }, + 'SWATDIR' : { + 'STD': '${DATADIR}/swat', + 'FHS': '${DATADIR}/samba/swat', + }, + 'CODEPAGEDIR' : { + 'STD': '${DATADIR}/codepages', + 'FHS': '${DATADIR}/samba/codepages', + }, + 'PAMMODULESDIR' : { + 'STD': '${LIBDIR}', + 'FHS': '${LIBDIR}', + 'OPT': '--with-pammodulesdir', + 'TXT': 'Which directory to use for PAM modules', + }, + 'CONFIGDIR' : { + 'STD': '${SYSCONFDIR}', + 'FHS': '${SYSCONFDIR}/samba', + 'OPT': '--with-configdir', + 'TXT': 'Where to put configuration files', + }, + 'PRIVATE_DIR' : { + 'STD': '${PREFIX}/private', + 'FHS': '${LOCALSTATEDIR}/lib/samba/private', + 'OPT': '--with-privatedir', + 'TXT': 'Where to put sam.ldb and other private files', + }, + 'LOCKDIR' : { + 'STD': '${LOCALSTATEDIR}/lock', + 'FHS': '${LOCALSTATEDIR}/lock/samba', + 'OPT': '--with-lockdir', + 'TXT': 'Where to put short term disposable state files', + }, + 'PIDDIR' : { + 'STD': '${LOCALSTATEDIR}/run', + 'FHS': '${LOCALSTATEDIR}/run/samba', + 'OPT': '--with-piddir', + 'TXT': 'Where to put pid files', + }, + 'STATEDIR' : { + 'STD': '${LOCALSTATEDIR}/locks', + 'FHS': '${LOCALSTATEDIR}/lib/samba/', + 'OPT': '--with-statedir', + 'TXT': 'Where to put persistent state files', + }, + 'CACHEDIR' : { + 'STD': '${LOCALSTATEDIR}/cache', + 'FHS': '${LOCALSTATEDIR}/cache/samba', + 'OPT': '--with-cachedir', + 'TXT': 'Where to put temporary cache files', + }, + 'LOGFILEBASE' : { + 'STD': '${LOCALSTATEDIR}', + 'FHS': '${LOCALSTATEDIR}/log/samba', + 'OPT': '--with-logfilebase', + 'TXT': 'Where to put log files', + }, + 'SOCKET_DIR' : { + 'STD': '${LOCALSTATEDIR}/run', + 'FHS': '${LOCALSTATEDIR}/run/samba', + 'OPT': '--with-sockets-dir', + 'TXT': 'socket directory', + }, + 'PRIVILEGED_SOCKET_DIR' : { + 'STD': '${LOCALSTATEDIR}/lib', + 'FHS': '${LOCALSTATEDIR}/lib/samba', + 'OPT': '--with-privileged-socket-dir', + 'TXT': 'privileged socket directory', + }, + 'WINBINDD_SOCKET_DIR' : { + 'STD': '${SOCKET_DIR}/winbindd', + 'FHS': '${SOCKET_DIR}/winbindd', + 'DLY': True, + }, + 'WINBINDD_PRIVILEGED_SOCKET_DIR' : { + 'STD': '${PRIVILEGED_SOCKET_DIR}/winbindd_privileged', + 'FHS': '${PRIVILEGED_SOCKET_DIR}/winbindd_privileged', + 'DLY': True, + }, + 'NMBDSOCKETDIR' : { + 'STD': '${SOCKET_DIR}/nmbd', + 'FHS': '${SOCKET_DIR}/nmbd', + 'DLY': True, + }, + 'NTP_SIGND_SOCKET_DIR' : { + 'STD': '${SOCKET_DIR}/ntp_signd', + 'FHS': '${SOCKET_DIR}/ntp_signd', + 'DLY': True, + }, + 'NCALRPCDIR' : { + 'STD': '${SOCKET_DIR}/ncalrpc', + 'FHS': '${SOCKET_DIR}/ncalrpc', + 'DLY': True, + }, + 'CONFIGFILE' : { + 'STD': '${CONFIGDIR}/smb.conf', + 'FHS': '${CONFIGDIR}/smb.conf', + 'DLY': True, + }, + 'LMHOSTSFILE' : { + 'STD': '${CONFIGDIR}/lmhosts', + 'FHS': '${CONFIGDIR}/lmhosts', + 'DLY': True, + }, + 'SMB_PASSWD_FILE' : { + 'STD': '${PRIVATE_DIR}/smbpasswd', + 'FHS': '${PRIVATE_DIR}/smbpasswd', + 'DLY': True, + }, +} def set_options(opt): - # get all the basic GNU options from the gnu_dirs tool opt.parser.formatter = SambaIndentedHelpFormatter() opt.parser.formatter.width=Utils.get_term_cols() + # get all the basic GNU options from the gnu_dirs tool + opt_group=opt.add_option_group('Samba-specific directory layout','') - opt_group.add_option('--enable-fhs', - help=("Use FHS-compliant paths (default no)"), + fhs_help = "Use FHS-compliant paths (default no)\n" + fhs_help += "You should consider using this together with:\n" + fhs_help += "--prefix=/usr --sysconfdir=/etc --locatestatedir=/var" + opt_group.add_option('--enable-fhs', help=fhs_help, action="store_true", dest='ENABLE_FHS', default=False) - for option in dir_options.keys(): - default = dir_options[option][0] - help = dir_options[option][1] - varname = get_varname(option) - opt_group.add_option('--%s' % option, - help=(help + ' [%s]' % default), - action="store", dest=varname, default=default) + + for varname in dynconfig.keys(): + if 'OPT' not in dynconfig[varname]: + continue + opt = dynconfig[varname]['OPT'] + if 'TXT' in dynconfig[varname]: + txt = dynconfig[varname]['TXT'] + else: + txt = "dynconfig path %s" % (varname) + def_std = dynconfig[varname]['STD'] + def_fhs = dynconfig[varname]['FHS'] + + help = "%s\n[STD-Default: %s]\n[FHS-Default: %s]" % (txt, def_std, def_fhs) + opt_group.add_option(opt, help=help, dest=varname, action="store") def configure(conf): # get all the basic GNU options from the gnu_dirs tool - explicit_set = {} + if Options.options.ENABLE_FHS: + flavor = 'FHS' + else: + flavor = 'STD' + if conf.env.PREFIX == '/usr' or conf.env.PREFIX == '/usr/local': + Logs.error("Don't install directly under /usr or /usr/local without using the FHS option (--enable-fhs)") + raise Utils.WafError("ERROR: invalid --prefix=%s value" % (conf.env.PREFIX)) - for option in dir_options.keys(): - default = dir_options[option][0] - varname = get_varname(option) - value = getattr(Options.options, varname, None) - conf.ASSERT(value is not None, "Missing configure option %s" % varname) + explicit_set ={} + + dyn_vars = {} + for varname in dynconfig.keys(): + dyn_vars[varname] = dynconfig[varname][flavor] + if 'OVW' in dynconfig[varname] and dynconfig[varname]['OVW']: + # we may overwrite this option + continue conf.ASSERT(varname not in conf.env, "Variable %s already defined" % varname) - conf.env[varname] = value - if value is not default: - explicit_set[varname] = "%s:%s" % (default, value) - for f in dyn_cflags.keys(): - v = EXPAND_VARIABLES(conf, dyn_cflags[f]) - conf.ASSERT(v != '', "Empty dynconfig value for %s" % f) - if f not in explicit_set: - conf.env[f] = v + # the explicit block + for varname in dynconfig.keys(): + if 'OPT' not in dynconfig[varname]: + continue + value = getattr(Options.options, varname, None) + if value is None: + continue + conf.ASSERT(value != '', "Empty dynconfig value for %s" % varname) + conf.env[varname] = value + # mark it as explicit from the command line + explicit_set[varname] = value - if Options.options.ENABLE_FHS: - for f in dyn_cflags_fhs.keys(): - v = EXPAND_VARIABLES(conf, dyn_cflags_fhs[f]) - conf.ASSERT(v != '', "Empty dynconfig value for %s" % f) - if f not in explicit_set: - conf.env[f] = v + # defaults stage 1 after the explicit block + for varname in dynconfig.keys(): + if 'DLY' in dynconfig[varname] and dynconfig[varname]['DLY']: + # this option referrs to other options, + # so it needs to wait for stage 2. + continue + value = EXPAND_VARIABLES(conf, dyn_vars[varname]) + conf.ASSERT(value != '', "Empty dynconfig value for %s" % varname) + if varname not in explicit_set: + # only overwrite if not specified explicitly on the command line + conf.env[varname] = value - if (not Options.options.ENABLE_FHS and - (conf.env.PREFIX == '/usr' or conf.env.PREFIX == '/usr/local')): - print("ERROR: Don't install directly under /usr or /usr/local without using the FHS option (--enable-fhs)") - sys.exit(1) + # defaults stage 2 after the explicit block + for varname in dynconfig.keys(): + if 'DLY' not in dynconfig[varname] or not dynconfig[varname]['DLY']: + # this option was already handled in stage 1. + continue + value = EXPAND_VARIABLES(conf, dyn_vars[varname]) + conf.ASSERT(value != '', "Empty dynconfig value for %s" % varname) + if varname not in explicit_set: + # only overwrite if not specified explicitly on the command line + conf.env[varname] = value + # display the expanded pathes for the user + for varname in dynconfig.keys(): + value = conf.env[varname] + conf.start_msg("Dynconfig[%s]: " % (varname)) + conf.end_msg("'%s'" % (value), 'GREEN') def dynconfig_cflags(bld, list=None): '''work out the extra CFLAGS for dynconfig.c''' @@ -195,14 +343,14 @@ def dynconfig_cflags(bld, list=None): 'CODEPAGEDIR' : os.path.join(bld.env.srcdir, 'codepages'), 'SCRIPTSBINDIR' : os.path.join(bld.env.srcdir, 'source4/scripting/bin'), 'SETUPDIR' : os.path.join(bld.env.srcdir, 'source4/setup') } - for f in dyn_cflags.keys(): - if list and not f in list: + for varname in dynconfig.keys(): + if list and not varname in list: continue - value = bld.env[f] + value = bld.env[varname] if not Options.is_install: - if f in override: - value = os.path.join(os.getcwd(), override[f]) - cflags.append('-D%s="%s"' % (f, value)) + if varname in override: + value = os.path.join(os.getcwd(), override[varname]) + cflags.append('-D%s="%s"' % (varname, value)) return cflags Build.BuildContext.dynconfig_cflags = dynconfig_cflags @@ -217,3 +365,11 @@ def build(bld): public_headers=os_path_relpath(os.path.join(Options.launch_dir, version_header), bld.curdir), header_path='samba', cflags=cflags) + + # install some extra empty directories + bld.INSTALL_DIRS("", "${CONFIGDIR} ${PRIVATE_DIR} ${LOGFILEBASE}"); + bld.INSTALL_DIRS("", "${PRIVATE_DIR} ${PRIVILEGED_SOCKET_DIR}") + bld.INSTALL_DIRS("", "${STATEDIR} ${CACHEDIR}"); + + # these might be on non persistent storage + bld.INSTALL_DIRS("", "${LOCKDIR} ${PIDDIR} ${SOCKET_DIR}") diff --git a/wscript_build b/wscript_build index eb5f993..f5ae5f2 100644 --- a/wscript_build +++ b/wscript_build @@ -123,7 +123,4 @@ bld.RECURSE('source3') bld.RECURSE('testsuite/headers') -# install some extra empty directories -bld.INSTALL_DIRS("", "${LOCKDIR} ${SYSCONFDIR} ${LOCKDIR} ${PIDDIR} ${LOCALSTATEDIR}/lib ${PRIVATEDIR}/smbd.tmp/messaging") - bld.SYMBOL_CHECK() -- 1.7.4.1