# HG changeset patch # User Paul Boddie # Date 1316123873 -7200 # Node ID 6ea9e4171eea49c48bd6123b75024d1b29c8bfc4 # Parent 1afd3bcd9c809738e9258cc1142dece8e8101244 Changed the command syntax to require a method option before the method name. Flattened the Wiki instance hierarchy, putting the configuration, data, underlay and htdocs in the same top-level directory. Changed the location of MoinMoin 1.9 resources, installing them in the prefix hierarchy and copying only static resources into Wiki instances. Changed the handling of static resources with MoinMoin 1.9 to serve them separately just as MoinMoin 1.8 does; this makes performance much better when CGI is used under Apache. Moved the editing of the moin script into the setup method so that no attempt is made to edit system programs. Moved the example configuration files into their own directory. diff -r 1afd3bcd9c80 -r 6ea9e4171eea README.txt --- a/README.txt Wed Sep 14 00:11:35 2011 +0200 +++ b/README.txt Thu Sep 15 23:57:53 2011 +0200 @@ -30,22 +30,27 @@ moin_distribution A path to a MoinMoin distribution directory, which can also be a clone of a MoinMoin repository. -moin_data A path to the MoinMoin shared data, which may be installed - from a system package in a directory such as - /usr/share/moin. - prefix The directory prefix containing lib, bin and share directories where MoinMoin is (or will be) installed. Although this follows the layout of the /usr directory (on Unix-based systems), it is likely that MoinMoin may be - installed elsewhere + installed elsewhere. + +site_packages The location of a directory which is either a Python + site-packages directory or something providing a selection + of different Python packages. If Python packages are + installed outside the 'prefix' area, perhaps due to a + distribution-specific mechanism, this setting should be + used in addition to the 'prefix' setting. Otherwise, it can + be omitted or left blank. web_app_dir A directory where the moin.cgi program is (or will be) installed. web_static_dir A directory from which static resources are to be served. This directory need only be specified in a limited hosting - environment (see below for more details). + environment (see below for more details), and only for + MoinMoin 1.8. web_site_dir The directory where sites available to the Apache Web server are defined. This directory may just be a place @@ -61,12 +66,38 @@ common_dir The directory in which the Wiki instance being configured or managed resides (or will reside). +farm_config A specific Wiki farm configuration file for multiple Wiki + deployments. This overrides the 'common_dir' setting if + used, indicating that a Wiki farm configuration must be + edited when configuring a Wiki. + +site_config A specific configuration file location for a Wiki deployed + within a Wiki farm. This overrides the 'common_dir' setting + if used. + url_path The URL path (after the host details) of the Wiki. + superuser The superuser of the Wiki. + site_name The name of the Wiki. + +site_identifier An identifier used to refer to the site, typically derived + from 'site_name' if left unspecified, and only really of use + when an Apache site file needs to be written. In limited + hosting environments, this setting has no effect. + front_page_name The name of the Wiki's front page. + theme_default The default theme of the Wiki. +Working with MoinMoin System Installations +------------------------------------------ + +Where MoinMoin has already been installed using a package supplied by an +operating system distribution (such as Debian, Red Hat, Ubuntu), there is no +need to install the software itself. However, it is still necessary to set up +Wiki instances. + Limited Hosting Environments ---------------------------- @@ -86,62 +117,81 @@ web_static_dir = /path/to/www/htdocs web_site_dir = -Inside the static resources directory, a subdirectory will be created to hold -any static content used by MoinMoin. +If the web_static_dir setting is left blank, the static resources will be +placed alongside the CGI script. Some environments have .cgi files served as +CGI scripts and other files served statically. + +Inside the directory used to hold static resources, a subdirectory will be +created to hold the static content used by MoinMoin. + +Wiki Farm Environments +---------------------- + +MoinMoin supports the notion of a Wiki farm where a single common configuration +is overridden by configurations for individual Wiki instances. To work in such +environments, specify the configuration settings in moinsetup.cfg as follows: + +farm_config = /path/to/farmconfig.py +site_config = /path/to/wikiname.py Examples -------- Some of the more useful invocation methods are described below using examples. -To set up MoinMoin and a Wiki instance: +To set up MoinMoin and a Wiki instance (useful when installing MoinMoin +yourself): - python moinsetup.py setup + python moinsetup.py -m setup -To only set up a Wiki instance using a different configuration file: +To set up only a Wiki instance (useful on a system with MoinMoin installed): + + python moinsetup.py -m setup_wiki - python moinsetup.py -f new_wiki.cfg setup_wiki +To set up only a Wiki instance, but using a different configuration file: + + python moinsetup.py -f mywiki.cfg -m setup_wiki To change a Wiki configuration setting (for example, the default theme): - python moinsetup.py reconfigure_moin theme_default mercurialwiki + python moinsetup.py -m reconfigure_moin theme_default mercurialwiki To install a theme from a directory containing a theme module, css and img directories (for example, MercurialWikiTheme): - python moinsetup.py install_theme /path/to/MercurialWikiTheme/themes/mercurialwiki + python moinsetup.py -m install_theme /path/to/MercurialWikiTheme/themes/mercurialwiki To install an extension package from a directory containing a setup.py script (for example, EventAggregator): - python moinsetup.py install_extension_package /path/to/EventAggregator + python moinsetup.py -m install_extension_package /path/to/EventAggregator To install actions from a directory containing action modules: - python moinsetup.py install_actions /path/to/EventAggregator/actions + python moinsetup.py -m install_actions /path/to/EventAggregator/actions To install macros from a directory containing macro modules: - python moinsetup.py install_macros /path/to/EventAggregator/macros + python moinsetup.py -m install_macros /path/to/EventAggregator/macros To install theme-related resources for an extension from a directory containing css and img directories: - python moinsetup.py install_theme_resources /path/to/EventAggregator + python moinsetup.py -m install_theme_resources /path/to/EventAggregator To add theme-related resources to existing stylesheets (for example, adding the event-aggregator.css resource to the screen.css stylesheet for all installed themes): - python moinsetup.py edit_theme_stylesheet screen.css event-aggregator.css + python moinsetup.py -m edit_theme_stylesheet screen.css event-aggregator.css To make a page package containing pages to be added to a Wiki: - python moinsetup.py make_page_package pages_dir pages.zip + python moinsetup.py -m make_page_package pages_dir pages.zip To install a page package in a Wiki: - python moinsetup.py install_page_package pages.zip + python moinsetup.py -m install_page_package pages.zip Contact, Copyright and Licence Information ------------------------------------------ @@ -171,9 +221,24 @@ New in moinsetup 0.3 (Changes since moinsetup 0.2) -------------------------------------------------- - * Added a moin_data setting and made moin_distribution optional so that when - MoinMoin is installed from a system package, the non-installation actions - can still be performed. + * Changed the command syntax to require -m (or --method=) before method + names; improved the error reporting when settings are missing or + inappropriate. + * Flattened the Wiki instance hierarchy, putting the configuration, data, + underlay and htdocs in the same top-level directory. + * Changed the location of MoinMoin 1.9 resources, installing them in the + prefix hierarchy and copying only static resources into Wiki instances. + * Changed the handling of static resources with MoinMoin 1.9 to serve them + separately just as MoinMoin 1.8 does; this makes performance much better + when CGI is used under Apache. + * Moved the editing of the moin script into the setup method so that no + attempt is made to edit system programs. + * Made moin_distribution optional so that when MoinMoin is installed from a + system package, the non-installation actions can still be performed using + shared data typically found in /usr/share/moin. + * Added support for Wiki farms, separate library/site-packages directories, + and site identifiers (based on site names). + * Improved the MoinMoin version detection. New in moinsetup 0.2 (Changes since moinsetup 0.1) -------------------------------------------------- diff -r 1afd3bcd9c80 -r 6ea9e4171eea TO_DO.txt --- a/TO_DO.txt Wed Sep 14 00:11:35 2011 +0200 +++ b/TO_DO.txt Thu Sep 15 23:57:53 2011 +0200 @@ -1,4 +1,4 @@ -Support installations without the conf directory structure. +Generate limited hosting environment site descriptions. Add support for changing the wikis list in the farmconfig module. Support existing MoinMoin home directory installations into ~/lib/python2.x/MoinMoin. This affects the page package installation function which expects to find diff -r 1afd3bcd9c80 -r 6ea9e4171eea examples/moinsetup.cfg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/moinsetup.cfg Thu Sep 15 23:57:53 2011 +0200 @@ -0,0 +1,17 @@ +[installation] +moin_distribution = moin-1.9-hg +prefix = moin +site_packages = +web_app_dir = webapps +web_static_dir = +web_site_dir = sites-available + +[site] +common_dir = wiki +farm_config = +site_config = +url_path = / +superuser = AdminUser +site_name = My Wiki +front_page_name = FrontPage +theme_default = modern diff -r 1afd3bcd9c80 -r 6ea9e4171eea examples/moinsetup.cfg.debian --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/moinsetup.cfg.debian Thu Sep 15 23:57:53 2011 +0200 @@ -0,0 +1,15 @@ +[installation] +prefix = /usr +site_packages = /var/lib/python-support/python2.5 +web_app_dir = /var/www/mywiki +web_site_dir = /etc/apache2/sites-available + +[site] +common_dir = /var/lib/mywiki +farm_config = /etc/moin/farmconfig.py +site_config = /etc/moin/mywiki.py +url_path = /mywiki +superuser = AdminUser +site_name = My Wiki +front_page_name = FrontPage +theme_default = modern diff -r 1afd3bcd9c80 -r 6ea9e4171eea moinsetup.cfg --- a/moinsetup.cfg Wed Sep 14 00:11:35 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -[installation] -moin_distribution = moin-1.9-hg -moin_data = -prefix = moin -site_packages = -web_app_dir = webapps -web_static_dir = -web_site_dir = sites-available - -[site] -common_dir = wiki -farm_config = -site_config = -url_path = / -superuser = AdminUser -site_name = My Wiki -front_page_name = FrontPage -theme_default = modern diff -r 1afd3bcd9c80 -r 6ea9e4171eea moinsetup.cfg.debian --- a/moinsetup.cfg.debian Wed Sep 14 00:11:35 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -[installation] -moin_distribution = -moin_data = /usr/share/moin -prefix = /usr -site_packages = /var/lib/python-support/python2.5 -web_app_dir = /var/www/mywiki -web_static_dir = -web_site_dir = /etc/apache2/sites-available - -[site] -common_dir = /var/lib/mywiki -farm_config = /etc/moin/farmconfig.py -site_config = /etc/moin/mywiki.py -url_path = /mywiki -superuser = AdminUser -site_name = My Wiki -front_page_name = FrontPage -theme_default = modern diff -r 1afd3bcd9c80 -r 6ea9e4171eea moinsetup.py --- a/moinsetup.py Wed Sep 14 00:11:35 2011 +0200 +++ b/moinsetup.py Thu Sep 15 23:57:53 2011 +0200 @@ -55,7 +55,7 @@ ScriptAlias %(url_path)s "%(web_app_dir)s/moin.cgi" """ -apache_site_extra_moin18 = """ +apache_site_extra = """ Alias %(static_url_path)s "%(htdocs_dir)s/" """ @@ -79,26 +79,26 @@ postsetup_setfacl = """#!/bin/sh -find '%(conf_dir)s/data' -type f | xargs setfacl -m u:%(web_user)s:rw -find '%(conf_dir)s/data' -type d | xargs setfacl -m u:%(web_user)s:rwx -find '%(conf_dir)s/underlay' -type f | xargs setfacl -m u:%(web_user)s:rw -find '%(conf_dir)s/underlay' -type d | xargs setfacl -m u:%(web_user)s:rwx +find '%(common_dir)s/data' -type f | xargs setfacl -m u:%(web_user)s:rw +find '%(common_dir)s/data' -type d | xargs setfacl -m u:%(web_user)s:rwx +find '%(common_dir)s/underlay' -type f | xargs setfacl -m u:%(web_user)s:rw +find '%(common_dir)s/underlay' -type d | xargs setfacl -m u:%(web_user)s:rwx """ -postsetup_setfacl_moin18_extra = """ +postsetup_setfacl_extra = """ find '%(htdocs_dir)s' -type f | xargs setfacl -m u:%(web_user)s:r find '%(htdocs_dir)s' -type d | xargs setfacl -m u:%(web_user)s:rx """ postsetup_chown_chmod = """#!/bin/sh -chown -R %(this_user)s.%(web_group)s '%(conf_dir)s/data' -chown -R %(this_user)s.%(web_group)s '%(conf_dir)s/underlay' -chmod -R g+w '%(conf_dir)s/data' -chmod -R g+w '%(conf_dir)s/underlay' +chown -R %(this_user)s.%(web_group)s '%(common_dir)s/data' +chown -R %(this_user)s.%(web_group)s '%(common_dir)s/underlay' +chmod -R g+w '%(common_dir)s/data' +chmod -R g+w '%(common_dir)s/underlay' """ -postsetup_chown_moin18_extra = """ +postsetup_chown_extra = """ chown -R %(this_user)s.%(web_group)s '%(htdocs_dir)s' """ @@ -291,6 +291,7 @@ "setup_wiki", "install_moin", "install_data", + "install_static_data", "configure_moin", "edit_moin_script", "edit_moin_web_script", @@ -327,51 +328,56 @@ theme_master = "modernized" extra_theme_css_files = ["SlideShow.css"] - def __init__(self, moin_distribution=None, moin_data=None, prefix=None, + def __init__(self, moin_distribution=None, prefix=None, site_packages=None, web_app_dir=None, web_static_dir=None, web_site_dir=None, common_dir=None, farm_config=None, site_config=None, url_path=None, - superuser=None, site_name=None, front_page_name=None, theme_default=None): + superuser=None, site_name=None, site_identifier=None, front_page_name=None, + theme_default=None): """ - Initialise a Wiki installation using the following: + Initialise a Wiki installation using the following installation + settings: * moin_distribution - the directory containing a MoinMoin source - distribution - * moin_data - the directory containing MoinMoin shared data - (can be omitted if 'moin_distribution' is given) + distribution (can be omitted) * prefix - the installation prefix (equivalent to /usr) + * site_packages - optional: the location of the Python + site-packages directory if outside the 'prefix' + (overrides the path calculated using 'prefix') * web_app_dir - the directory where Web applications and scripts reside (such as /home/www-user/cgi-bin) + * web_static_dir - optional: the directory where static Web + resources reside (such as /home/www-user/htdocs) + * web_site_dir - optional: the directory where Web site + definitions reside (such as + /etc/apache2/sites-available) + + The following site settings are also applicable: + * common_dir - the directory where the Wiki configuration, resources and instance will reside (such as /home/www-user/mywiki) + * farm_config - optional: any Wiki farm configuration file for + multiple Wiki deployments (overrides the + 'common_dir' setting) + * site_config - optional: a specific configuration file location + (overrides the 'common_dir' setting) * url_path - the URL path at which the Wiki will be made available (such as / or /mywiki) * superuser - the name of the site's superuser (such as "AdminUser") * site_name - the name of the site (such as "My Wiki") + * site_identifier - optional: an identifier used to refer to the + site, typically derived from 'site_name' * front_page_name - the front page name for the site (such as "FrontPage" or a specific name for the site) - * web_site_dir - optional: the directory where Web site - definitions reside (such as - /etc/apache2/sites-available) - * web_static_dir - optional: the directory where static Web - resources reside (such as /home/www-user/htdocs) - * farm_config - optional: any Wiki farm configuration file for - multiple Wiki deployments (overrides the - 'common_dir' setting) - * site_config - optional: a specific configuration file location - (overrides the 'common_dir' setting) - * site_packages - optional: the location of the Python - site-packages directory if outside the 'prefix' - (overrides the path calculated using 'prefix') * theme_default - optional: the default theme (such as modern) """ self.moin_distribution = moin_distribution - self.moin_data = moin_data self.superuser = superuser self.site_name = site_name + self.site_identifier = site_identifier or site_name.replace(" ", "").lower() self.front_page_name = front_page_name self.farm_config = farm_config self.site_config = site_config @@ -379,11 +385,17 @@ # NOTE: Support the detection of the Apache sites directory. - self.prefix, self.web_app_dir, self.web_site_dir, self.web_static_dir, self.common_dir = \ - map(self._get_abspath, (prefix, web_app_dir, web_site_dir, web_static_dir, common_dir)) + self.prefix, self.site_packages, self.web_app_dir, self.web_site_dir, self.web_static_dir, self.common_dir = \ + map(self._get_abspath, (prefix, site_packages, web_app_dir, web_site_dir, web_static_dir, common_dir)) + + if not self.web_app_dir: + raise TypeError, "The 'web_app_dir' setting must be specified." # Strip any trailing "/" from the URL path. + if not url_path: + raise TypeError, "The 'url_path' setting must be specified." + if url_path != "/" and url_path.endswith("/"): self.url_path = url_path[:-1] else: @@ -392,12 +404,15 @@ # Define and create specific directories. # Here are the configuration and actual Wiki data directories. - self.conf_dir = join(self.common_dir, "conf") - self.instance_dir = join(self.common_dir, "wikidata") + if not self.common_dir: + raise TypeError, "The 'common_dir' setting must be specified." # Define the place where the MoinMoin package will actually reside. - self.prefix_site_packages = site_packages or \ + if not self.prefix and not self.site_packages: + raise TypeError, "Either the 'prefix' or the 'site_packages' setting must be specified." + + self.prefix_site_packages = self.site_packages or \ join(self.prefix, "lib", "python%s.%s" % sys.version_info[:2], "site-packages") # Find the version. @@ -405,81 +420,84 @@ self.moin_version = self.get_moin_version() # The static resources reside in different locations depending on the - # version of MoinMoin. Moreover, these resources may end up in a - # published directory for 1.8 installations where the Web server cannot - # be instructed to fetch the content from outside certain designated - # locations. + # version of MoinMoin, but the Web server is used to serve static + # resources in both cases, even though MoinMoin 1.9 can serve static + # files itself. + + # A shared data directory may be in use. - # 1.9: moin/lib/python2.x/site-packages/MoinMoin/web/static/htdocs + self.htdocs_dir_source = join(self.get_moin_data(), "htdocs") - if self.moin_version.startswith("1.9"): + if self.htdocs_dir_source is None or not exists(self.htdocs_dir_source): + + # 1.9: moin/lib/python2.x/site-packages/MoinMoin/web/static/htdocs - # A shared data directory may be in use. - - if self.moin_data: - self.htdocs_dir = self.htdocs_dir_source = join(self.moin_data, "htdocs") + if self.moin_version.startswith("1.9"): + self.htdocs_dir_source = join(self.prefix_site_packages, "MoinMoin", "web", "static", "htdocs") else: - self.htdocs_dir = self.htdocs_dir_source = join(self.prefix_site_packages, "MoinMoin", "web", "static", "htdocs") + raise SetupException, "The static resources could not be found." + + # Add the static identifier to the URL path. For example: + # / -> /moin_static187 + # /hgwiki -> /hgwiki-moin_static187 + + self.static_url_path = self.url_path + (self.url_path != "/" and "-" or "") + self.get_static_identifier() - self.static_url_path = self.url_path + # In limited hosting, the static resources directory is related to + # the URL path. - # 1.8: moin/share/moin/htdocs (optionally copied to a Web directory) + if self.limited_hosting(): + self.htdocs_dir = join(self.web_static_dir or self.web_app_dir, self.static_url_path.lstrip("/")) + + # Otherwise, a mapping is made to the directory. else: - - # A shared data directory may be in use. - - if self.moin_data: - self.htdocs_dir_source = join(self.moin_data, "htdocs") - else: - self.htdocs_dir_source = join(self.instance_dir, "share", "moin", "htdocs") - - # Add the static identifier to the URL path. For example: - # / -> /moin_static187 - # /hgwiki -> /hgwiki-moin_static187 - - self.static_url_path = self.url_path + (self.url_path != "/" and "-" or "") + self.get_static_identifier() - - # In limited hosting, the static resources directory is related to - # the URL path. - - if self.limited_hosting(): - self.htdocs_dir = join(self.web_static_dir or self.web_app_dir, self.static_url_path.lstrip("/")) - - # Otherwise, a mapping is made to the directory. - - else: - self.htdocs_dir = self.htdocs_dir_source + self.htdocs_dir = join(self.common_dir, "htdocs") def _get_abspath(self, d): return d and abspath(d) or None def get_moin_version(self): - "Inspect the MoinMoin package information, returning the version." + "Return the MoinMoin version." if self.moin_distribution: + this_dir = os.getcwd() try: - this_dir = os.getcwd() - try: - os.chdir(self.moin_distribution) - f = open("PKG-INFO") - try: - for line in f.xreadlines(): - columns = line.split() - if columns[0] == "Version:": - return columns[1] + os.chdir(self.moin_distribution) + version = self.get_moin_version_from_package_info() or \ + self.get_moin_version_from_import() + if version: + return version + + finally: + os.chdir(this_dir) + + else: + return self.get_moin_version_from_import() + + def get_moin_version_from_package_info(self): + + "Inspect the MoinMoin package information, returning the version." - return None - - finally: - f.close() + try: + f = open("PKG-INFO") + try: + for line in f.xreadlines(): + columns = line.split() + if columns[0] == "Version:": + return columns[1] + finally: + f.close() - finally: - os.chdir(this_dir) + except IOError: + pass - except IOError: - pass + return None + + def get_moin_version_from_import(self): + + "Return the MoinMoin version from an import of the package itself." # Where no distribution information can be read, try and import an # installed version module. @@ -492,9 +510,10 @@ def get_moin_data(self): - "Return the location of MoinMoin data." + "Return the exact location of MoinMoin data." - return self.moin_data or self.moin_distribution and join(self.moin_distribution, "wiki") or None + return self.moin_distribution and join(self.moin_distribution, "wiki") or \ + self.prefix and join(self.prefix, "share", "moin") or None def get_static_identifier(self): @@ -506,7 +525,7 @@ "Return the directory for plugins of the given 'plugin_type'." - data_dir = join(self.conf_dir, "data") + data_dir = join(self.common_dir, "data") return join(data_dir, "plugin", plugin_type) def limited_hosting(self): @@ -519,7 +538,7 @@ "Make sure that all the directories are available." - for d in (self.conf_dir, self.instance_dir, self.web_app_dir, self.web_static_dir, self.web_site_dir): + for d in (self.common_dir, self.web_app_dir, self.web_static_dir, self.web_site_dir): if d is not None and not exists(d): os.makedirs(d) @@ -551,6 +570,7 @@ self.ensure_directories() self.install_moin() + self.edit_moin_script() self._setup_wiki() def setup_wiki(self): @@ -558,13 +578,6 @@ "Set up a Wiki without installing MoinMoin." self.ensure_directories() - - try: - self.install_moin(data_only=1) - except SetupException: - if not self.moin_data: - raise - self._setup_wiki() def _setup_wiki(self): @@ -572,13 +585,16 @@ "Set up a Wiki without installing MoinMoin." self.install_data() + self.install_static_data() self.configure_moin() - self.edit_moin_script() self.add_superuser() self.edit_moin_web_script(self.make_site_files()) self.make_post_install_script() - def install_moin(self, data_only=0): + if self.moin_version.startswith("1.9"): + note("You may need to visit the LanguageSetup page in the Wiki to create the standard set of pages.") + + def install_moin(self): "Enter the distribution directory and run the setup script." @@ -593,14 +609,10 @@ log_filename = "install-%s.log" % split(self.common_dir)[-1] - status("Installing MoinMoin%s in %s..." % (data_only and " (data only)" or "", self.prefix)) + status("Installing MoinMoin in %s..." % self.prefix) - if data_only: - install_cmd = "install_data" - options = "--install-dir='%s'" % self.instance_dir - else: - install_cmd = "install" - options = "--prefix='%s' --install-data='%s' --record='%s'" % (self.prefix, self.instance_dir, log_filename) + install_cmd = "install" + options = "--prefix='%s' --record='%s'" % (self.prefix, log_filename) os.system("python setup.py --quiet %s %s --force" % (install_cmd, options)) @@ -608,44 +620,48 @@ def install_data(self): - "Install Wiki data." + "Install Wiki data into an instance." moin_data = self.get_moin_data() if not moin_data: raise SetupException, \ - "Cannot install MoinMoin data without either a 'moin_distribution' or a 'moin_data' setting being defined." + "Cannot install MoinMoin data without either a 'moin_distribution' or a 'prefix' setting being defined." # The default wikiconfig assumes data and underlay in the same directory. - status("Installing data and underlay in %s..." % self.conf_dir) + status("Installing data and underlay in %s..." % self.common_dir) for d in ("data", "underlay"): source = join(moin_data, d) source_tar = source + os.path.extsep + "tar" - d_tar = source + os.path.extsep + "tar" if os.path.exists(source): - shutil.copytree(source, join(self.conf_dir, d)) + shutil.copytree(source, join(self.common_dir, d)) elif os.path.exists(source_tar): - shutil.copy(source_tar, self.conf_dir) - os.system("tar xf %s -C %s" % (d_tar, self.conf_dir)) + + note("Copying archive %s instead of directory %s. Running...\n" + "make pagepacks\n" + "in the distribution directory should rectify this." % (source_tar, source)) + + shutil.copy(source_tar, self.common_dir) + os.system("tar xf %s -C %s" % (source_tar, self.common_dir)) else: status("Could not copy %s into installed Wiki." % d) - # Copy static Web data if appropriate. + def install_static_data(self): - if not self.moin_version.startswith("1.9") and self.limited_hosting(): + "Install static Web data if appropriate." - if not exists(self.htdocs_dir): - os.mkdir(self.htdocs_dir) + if not exists(self.htdocs_dir): + os.mkdir(self.htdocs_dir) - for item in os.listdir(self.htdocs_dir_source): - path = join(self.htdocs_dir_source, item) - if isdir(path): - shutil.copytree(path, join(self.htdocs_dir, item)) - else: - shutil.copy(path, join(self.htdocs_dir, item)) + for item in os.listdir(self.htdocs_dir_source): + path = join(self.htdocs_dir_source, item) + if isdir(path): + shutil.copytree(path, join(self.htdocs_dir, item)) + else: + shutil.copy(path, join(self.htdocs_dir, item)) def configure_moin(self): @@ -655,20 +671,15 @@ if not moin_data: raise SetupException, \ - "Cannot configure MoinMoin without either a 'moin_distribution' or a 'moin_data' setting being defined." + "Cannot configure MoinMoin without either a 'moin_distribution' or a 'prefix' setting being defined." # NOTE: Single Wiki only so far. - # Static URLs seem to be different in MoinMoin 1.9.x. - # For earlier versions, reserve URL space alongside the Wiki. # NOTE: MoinMoin usually uses an apparently common URL space associated # NOTE: with the version, but more specific locations are probably # NOTE: acceptable if less efficient. - if self.moin_version.startswith("1.9"): - url_prefix_static = "%r + url_prefix_static" % self.static_url_path - else: - url_prefix_static = "%r" % self.static_url_path + url_prefix_static = "%r" % self.static_url_path # Use a farm configuration file. @@ -678,7 +689,7 @@ # Or copy the Wiki configuration file from the distribution. else: - wikiconfig_py = join(self.conf_dir, "wikiconfig.py") + wikiconfig_py = join(self.common_dir, "wikiconfig.py") shutil.copyfile(join(moin_data, "config", "wikiconfig.py"), wikiconfig_py) status("Editing configuration from %s..." % wikiconfig_py) @@ -718,9 +729,12 @@ Configure Moin, accessing the configuration file using 'wikiconfig'. """ - if not self.moin_version.startswith("1.9"): - data_dir = join(self.conf_dir, "data") - data_underlay_dir = join(self.conf_dir, "underlay") + # Specific site configurations also appear to need 'data_dir', even in + # 1.9. + + if not self.moin_version.startswith("1.9") or self.site_config: + data_dir = join(self.common_dir, "data") + data_underlay_dir = join(self.common_dir, "underlay") wikiconfig.set("data_dir", data_dir) wikiconfig.set("data_underlay_dir", data_underlay_dir) @@ -765,7 +779,7 @@ s = readfile(moin_cgi) s = moin_cgi_prefix.sub("sys.path.insert(0, %r)" % self.prefix_site_packages, s) - s = moin_cgi_wikiconfig.sub("sys.path.insert(0, %r)" % self.conf_dir, s) + s = moin_cgi_wikiconfig.sub("sys.path.insert(0, %r)" % self.common_dir, s) # Handle differences in script names when using limited hosting with # URL rewriting. @@ -787,6 +801,10 @@ writefile(moin_cgi_installed, s) os.system("chmod a+rx '%s'" % moin_cgi_installed) + # Fix the cause of opaque errors in some Apache environments. + + os.system("chmod go-w '%s'" % moin_cgi_installed) + def add_superuser(self): "Add the superuser account." @@ -800,12 +818,12 @@ path = os.environ.get("PYTHONPATH", "") if path: - os.environ["PYTHONPATH"] = path + ":" + self.conf_dir + os.environ["PYTHONPATH"] = path + ":" + self.common_dir else: - os.environ["PYTHONPATH"] = self.conf_dir + os.environ["PYTHONPATH"] = self.common_dir cmd = moin_script + " --config-dir='%s' account create --name='%s' --email='%s' --password='%s'" % ( - self.conf_dir, self.superuser, email, password) + self.common_dir, self.superuser, email, password) os.system(cmd) if path: @@ -824,18 +842,16 @@ if not self.limited_hosting(): - site_def = join(self.web_site_dir, self.site_name) + site_def = join(self.web_site_dir, self.site_identifier) s = apache_site % self.__dict__ - - if not self.moin_version.startswith("1.9"): - s += apache_site_extra_moin18 % self.__dict__ + s += apache_site_extra % self.__dict__ status("Writing Apache site definitions to %s..." % site_def) writefile(site_def, s) - note("Copy the site definitions to the appropriate sites directory if appropriate.") - note("Then, make sure that the site is enabled by running the appropriate tools (such as a2ensite).") + note("Copy the site definitions to the appropriate sites directory if appropriate.\n" + "Then, make sure that the site is enabled by running the appropriate tools (such as a2ensite).") return 1 @@ -861,7 +877,7 @@ # Work out whether setfacl works. - fd, temp_filename = tempfile.mkstemp(dir=self.conf_dir) + fd, temp_filename = tempfile.mkstemp(dir=self.common_dir) os.close(fd) have_setfacl = os.system("setfacl -m user:%(web_user)s:r %(file)s > /dev/null 2>&1" % { @@ -880,21 +896,19 @@ vars.update(locals()) for postinst_script, start, extra in [ - (postinst_scripts[0], postsetup_chown_chmod, postsetup_chown_moin18_extra), - (postinst_scripts[1], postsetup_setfacl, postsetup_setfacl_moin18_extra) + (postinst_scripts[0], postsetup_chown_chmod, postsetup_chown_extra), + (postinst_scripts[1], postsetup_setfacl, postsetup_setfacl_extra) ]: s = start % vars - - if not self.moin_version.startswith("1.9"): - s += extra % vars + s += extra % vars writefile(postinst_script, s) os.chmod(postinst_script, 0755) if have_setfacl: - note("Run %s to set file ownership and permissions." % postinst_scripts[1]) - note("If this somehow fails...") + note("Run %s to set file ownership and permissions.\n" + "If this somehow fails..." % postinst_scripts[1]) note("Run %s as root to set file ownership and permissions." % postinst_scripts[0]) @@ -917,7 +931,7 @@ if self.site_config: wikiconfig_py = self.site_config else: - wikiconfig_py = join(self.conf_dir, "wikiconfig.py") + wikiconfig_py = join(self.common_dir, "wikiconfig.py") status("Editing configuration from %s..." % wikiconfig_py) @@ -947,7 +961,7 @@ if self.farm_config: wikiconfig_py = self.farm_config else: - wikiconfig_py = join(self.conf_dir, "wikiconfig.py") + wikiconfig_py = join(self.common_dir, "wikiconfig.py") status("Editing configuration from %s..." % wikiconfig_py) @@ -1047,8 +1061,8 @@ if exists(css_file_path): shutil.copy(css_file_path, target_dir) - note("Don't forget to add theme resources for extensions for this theme.") - note("Don't forget to edit this theme's stylesheets for extensions.") + note("Don't forget to add theme resources for extensions for this theme.\n" + "Don't forget to edit this theme's stylesheets for extensions.") def install_extension_package(self, extension_dir): @@ -1248,9 +1262,9 @@ path = os.environ.get("PYTHONPATH", "") if path: - os.environ["PYTHONPATH"] = path + ":" + self.prefix_site_packages + ":" + self.conf_dir + os.environ["PYTHONPATH"] = path + ":" + self.prefix_site_packages + ":" + self.common_dir else: - os.environ["PYTHONPATH"] = self.prefix_site_packages + ":" + self.conf_dir + os.environ["PYTHONPATH"] = self.prefix_site_packages + ":" + self.common_dir installer = join(self.prefix_site_packages, "MoinMoin", "packages.py") cmd = "python %s i %s" % (installer, package_filename) @@ -1271,7 +1285,7 @@ # Command line option syntax. -syntax_description = "[ -f ] ( | --method=METHOD ) [ ... ]" +syntax_description = "[ -f ] ( -m | --method=METHOD ) [ ... ]" # Main program. @@ -1296,6 +1310,11 @@ try: config_filename = args.get("config-filename", "moinsetup.cfg") + + if not exists(config_filename): + print "Configuration", config_filename, "not found." + sys.exit(1) + config = ConfigParser() config.read(config_filename) @@ -1309,6 +1328,8 @@ installation = Installation(**config_arguments) except TypeError, exc: + print "Error:" + print print exc.args[0] print print "Configuration settings:" @@ -1327,13 +1348,15 @@ try: method(*method_arguments) - except TypeError: + except TypeError, exc: + print "Error:" + print print exc.args[0] print print "Method documentation:" print print method.__doc__ print - raise + sys.exit(1) # vim: tabstop=4 expandtab shiftwidth=4