diff options
| author | Barry Warsaw | 2007-07-13 00:19:10 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2007-07-13 00:19:10 -0400 |
| commit | 288ae405b09baa443eb1b39422c48c315fbb2e5a (patch) | |
| tree | e2cd153be141921db8ec9898b2d9fa5cc8ffe9fc /Mailman/bin | |
| parent | da315b5b08029236dc1065089399a4fb16446477 (diff) | |
| download | mailman-288ae405b09baa443eb1b39422c48c315fbb2e5a.tar.gz mailman-288ae405b09baa443eb1b39422c48c315fbb2e5a.tar.zst mailman-288ae405b09baa443eb1b39422c48c315fbb2e5a.zip | |
The start of a setuptools conversion. All the Makefile.in and autoconf
artifacts are removed, as is the C files which we will no longer need.
Diffstat (limited to 'Mailman/bin')
| -rw-r--r-- | Mailman/bin/Makefile.in | 71 | ||||
| -rw-r--r-- | Mailman/bin/make_instance.py | 120 |
2 files changed, 120 insertions, 71 deletions
diff --git a/Mailman/bin/Makefile.in b/Mailman/bin/Makefile.in deleted file mode 100644 index a90fb7094..000000000 --- a/Mailman/bin/Makefile.in +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright (C) 1998-2007 by the Free Software Foundation, Inc. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -# USA. - -# NOTE: Makefile.in is converted into Makefile by the configure script -# in the parent directory. Once configure has run, you can recreate -# the Makefile by running just config.status. - -# Variables set by configure - -VPATH= @srcdir@ -srcdir= @srcdir@ -bindir= @bindir@ -prefix= @prefix@ -exec_prefix= @exec_prefix@ -DESTDIR= - -CC= @CC@ -CHMOD= @CHMOD@ -INSTALL= @INSTALL@ - -DEFS= @DEFS@ - -# Customizable but not set by configure - -OPT= @OPT@ -CFLAGS= $(OPT) $(DEFS) -PACKAGEDIR= $(prefix)/Mailman/bin -SHELL= /bin/sh - -MODULES= *.py - -# Modes for directories and executables created by the install -# process. Default to group-writable directories but -# user-only-writable for executables. -DIRMODE= 775 -EXEMODE= 755 -FILEMODE= 644 -INSTALL_PROGRAM=$(INSTALL) -m $(EXEMODE) - - -# Rules - -all: - -install: - for f in $(MODULES); \ - do \ - $(INSTALL) -m $(FILEMODE) $(srcdir)/$$f $(DESTDIR)$(PACKAGEDIR); \ - done - -finish: - -clean: - -distclean: - -rm *.pyc - -rm Makefile diff --git a/Mailman/bin/make_instance.py b/Mailman/bin/make_instance.py new file mode 100644 index 000000000..756199cea --- /dev/null +++ b/Mailman/bin/make_instance.py @@ -0,0 +1,120 @@ +# Copyright (C) 2007 by the Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. + +from __future__ import with_statement + +import os +import grp +import pwd +import sys +import optparse +from string import Template + +import Mailman +from Mailman.Version import MAILMAN_VERSION +from Mailman.i18n import _ + +__i18n_templates__ = True +SPACE = ' ' + + + +def parseargs(): + parser = optparse.OptionParser(MAILMAN_VERSION, usage=_("""\ +%prog [options] + +Create a Mailman instance by generating all the necessary basic configuration +support and intervening directories. +""")) + parser.add_option('-r', '--runtime-dir', + type='string', default='/var/mailman', help=_("""\ +The top-level run-time data directory. All supporting run-time data will be +placed in subdirectories of this directory. It will be created if necessary, +although this might require superuser privileges.""")) + parser.add_option('-p', '--permchecks', + default=False, action='store_true', help=_("""\ +Perform permission checks on the runtime directory.""")) + parser.add_option('-u', '--user', + type='string', default=None, help=_("""\ +The user id or name to use for the run-time directory. If not specified, the +current user is used.""")) + parser.add_option('-g', '--group', + type='string', default=None, help=_("""\ +The group id or name to use for the run-time directory. If not specified, the +current group is used.""")) + parser.add_option('-l', '--language', + default=[], type='string', action='append', help=_("""\ +Enable the given language. Use 'all' to enable all supported languages.""")) + opts, args = parser.parse_args() + if args: + unexpected = SPACE.join(args) + parser.print_error(_('Unexpected arguments: $unexpected')) + return parser, opts, args + + + +def main(): + parser, opts, args = parseargs() + # Create the Defaults.py file using substitutions. + in_file_path = os.path.join(os.path.dirname(Mailman.__file__), + 'Defaults.py.in') + out_file_path = os.path.splitext(in_file_path)[0] + with open(in_file_path) as fp: + raw = Template(fp.read()) + # Figure out which user name and group name to use. + if opts.user is None: + uid = os.getuid() + else: + try: + uid = int(opts.user) + except ValueError: + try: + uid = pwd.getpwnam(opts.user).pw_uid + except KeyError: + parser.print_error(_('Unknown user: $opts.user')) + try: + user_name = pwd.getpwuid(uid) + except KeyError: + parser.print_error(_('Unknown user: $opts.user')) + if opts.group is None: + gid = os.getgid() + else: + try: + gid = int(opts.group) + except ValueError: + try: + gid = grp.getgrnam(opts.group).gr_gid + except KeyError: + parser.print_error(_('Unknown group: $opts.group')) + try: + group_name = grp.getgrgid(gid) + except KeyError: + parser.print_error(_('Unknown group: $opts.group')) + # Process the .in file and write it to Defaults.py. + processed = raw.safe_substitute(runtime_dir=opts.runtime_dir, + user_name=user_name, + group_name=group_name) + with open(out_file_path, 'w') as fp: + fp.write(processed) + # XXX Do --permchecks + # XXX Do --language + + + +if __name__ == '__main__': + main() + |
