1.1 --- a/README.txt Wed Sep 14 00:11:35 2011 +0200
1.2 +++ b/README.txt Thu Sep 15 23:57:53 2011 +0200
1.3 @@ -30,22 +30,27 @@
1.4 moin_distribution A path to a MoinMoin distribution directory, which can
1.5 also be a clone of a MoinMoin repository.
1.6
1.7 -moin_data A path to the MoinMoin shared data, which may be installed
1.8 - from a system package in a directory such as
1.9 - /usr/share/moin.
1.10 -
1.11 prefix The directory prefix containing lib, bin and share
1.12 directories where MoinMoin is (or will be) installed.
1.13 Although this follows the layout of the /usr directory (on
1.14 Unix-based systems), it is likely that MoinMoin may be
1.15 - installed elsewhere
1.16 + installed elsewhere.
1.17 +
1.18 +site_packages The location of a directory which is either a Python
1.19 + site-packages directory or something providing a selection
1.20 + of different Python packages. If Python packages are
1.21 + installed outside the 'prefix' area, perhaps due to a
1.22 + distribution-specific mechanism, this setting should be
1.23 + used in addition to the 'prefix' setting. Otherwise, it can
1.24 + be omitted or left blank.
1.25
1.26 web_app_dir A directory where the moin.cgi program is (or will be)
1.27 installed.
1.28
1.29 web_static_dir A directory from which static resources are to be served.
1.30 This directory need only be specified in a limited hosting
1.31 - environment (see below for more details).
1.32 + environment (see below for more details), and only for
1.33 + MoinMoin 1.8.
1.34
1.35 web_site_dir The directory where sites available to the Apache Web
1.36 server are defined. This directory may just be a place
1.37 @@ -61,12 +66,38 @@
1.38 common_dir The directory in which the Wiki instance being configured
1.39 or managed resides (or will reside).
1.40
1.41 +farm_config A specific Wiki farm configuration file for multiple Wiki
1.42 + deployments. This overrides the 'common_dir' setting if
1.43 + used, indicating that a Wiki farm configuration must be
1.44 + edited when configuring a Wiki.
1.45 +
1.46 +site_config A specific configuration file location for a Wiki deployed
1.47 + within a Wiki farm. This overrides the 'common_dir' setting
1.48 + if used.
1.49 +
1.50 url_path The URL path (after the host details) of the Wiki.
1.51 +
1.52 superuser The superuser of the Wiki.
1.53 +
1.54 site_name The name of the Wiki.
1.55 +
1.56 +site_identifier An identifier used to refer to the site, typically derived
1.57 + from 'site_name' if left unspecified, and only really of use
1.58 + when an Apache site file needs to be written. In limited
1.59 + hosting environments, this setting has no effect.
1.60 +
1.61 front_page_name The name of the Wiki's front page.
1.62 +
1.63 theme_default The default theme of the Wiki.
1.64
1.65 +Working with MoinMoin System Installations
1.66 +------------------------------------------
1.67 +
1.68 +Where MoinMoin has already been installed using a package supplied by an
1.69 +operating system distribution (such as Debian, Red Hat, Ubuntu), there is no
1.70 +need to install the software itself. However, it is still necessary to set up
1.71 +Wiki instances.
1.72 +
1.73 Limited Hosting Environments
1.74 ----------------------------
1.75
1.76 @@ -86,62 +117,81 @@
1.77 web_static_dir = /path/to/www/htdocs
1.78 web_site_dir =
1.79
1.80 -Inside the static resources directory, a subdirectory will be created to hold
1.81 -any static content used by MoinMoin.
1.82 +If the web_static_dir setting is left blank, the static resources will be
1.83 +placed alongside the CGI script. Some environments have .cgi files served as
1.84 +CGI scripts and other files served statically.
1.85 +
1.86 +Inside the directory used to hold static resources, a subdirectory will be
1.87 +created to hold the static content used by MoinMoin.
1.88 +
1.89 +Wiki Farm Environments
1.90 +----------------------
1.91 +
1.92 +MoinMoin supports the notion of a Wiki farm where a single common configuration
1.93 +is overridden by configurations for individual Wiki instances. To work in such
1.94 +environments, specify the configuration settings in moinsetup.cfg as follows:
1.95 +
1.96 +farm_config = /path/to/farmconfig.py
1.97 +site_config = /path/to/wikiname.py
1.98
1.99 Examples
1.100 --------
1.101
1.102 Some of the more useful invocation methods are described below using examples.
1.103
1.104 -To set up MoinMoin and a Wiki instance:
1.105 +To set up MoinMoin and a Wiki instance (useful when installing MoinMoin
1.106 +yourself):
1.107
1.108 - python moinsetup.py setup
1.109 + python moinsetup.py -m setup
1.110
1.111 -To only set up a Wiki instance using a different configuration file:
1.112 +To set up only a Wiki instance (useful on a system with MoinMoin installed):
1.113 +
1.114 + python moinsetup.py -m setup_wiki
1.115
1.116 - python moinsetup.py -f new_wiki.cfg setup_wiki
1.117 +To set up only a Wiki instance, but using a different configuration file:
1.118 +
1.119 + python moinsetup.py -f mywiki.cfg -m setup_wiki
1.120
1.121 To change a Wiki configuration setting (for example, the default theme):
1.122
1.123 - python moinsetup.py reconfigure_moin theme_default mercurialwiki
1.124 + python moinsetup.py -m reconfigure_moin theme_default mercurialwiki
1.125
1.126 To install a theme from a directory containing a theme module, css and img
1.127 directories (for example, MercurialWikiTheme):
1.128
1.129 - python moinsetup.py install_theme /path/to/MercurialWikiTheme/themes/mercurialwiki
1.130 + python moinsetup.py -m install_theme /path/to/MercurialWikiTheme/themes/mercurialwiki
1.131
1.132 To install an extension package from a directory containing a setup.py script
1.133 (for example, EventAggregator):
1.134
1.135 - python moinsetup.py install_extension_package /path/to/EventAggregator
1.136 + python moinsetup.py -m install_extension_package /path/to/EventAggregator
1.137
1.138 To install actions from a directory containing action modules:
1.139
1.140 - python moinsetup.py install_actions /path/to/EventAggregator/actions
1.141 + python moinsetup.py -m install_actions /path/to/EventAggregator/actions
1.142
1.143 To install macros from a directory containing macro modules:
1.144
1.145 - python moinsetup.py install_macros /path/to/EventAggregator/macros
1.146 + python moinsetup.py -m install_macros /path/to/EventAggregator/macros
1.147
1.148 To install theme-related resources for an extension from a directory
1.149 containing css and img directories:
1.150
1.151 - python moinsetup.py install_theme_resources /path/to/EventAggregator
1.152 + python moinsetup.py -m install_theme_resources /path/to/EventAggregator
1.153
1.154 To add theme-related resources to existing stylesheets (for example, adding
1.155 the event-aggregator.css resource to the screen.css stylesheet for all
1.156 installed themes):
1.157
1.158 - python moinsetup.py edit_theme_stylesheet screen.css event-aggregator.css
1.159 + python moinsetup.py -m edit_theme_stylesheet screen.css event-aggregator.css
1.160
1.161 To make a page package containing pages to be added to a Wiki:
1.162
1.163 - python moinsetup.py make_page_package pages_dir pages.zip
1.164 + python moinsetup.py -m make_page_package pages_dir pages.zip
1.165
1.166 To install a page package in a Wiki:
1.167
1.168 - python moinsetup.py install_page_package pages.zip
1.169 + python moinsetup.py -m install_page_package pages.zip
1.170
1.171 Contact, Copyright and Licence Information
1.172 ------------------------------------------
1.173 @@ -171,9 +221,24 @@
1.174 New in moinsetup 0.3 (Changes since moinsetup 0.2)
1.175 --------------------------------------------------
1.176
1.177 - * Added a moin_data setting and made moin_distribution optional so that when
1.178 - MoinMoin is installed from a system package, the non-installation actions
1.179 - can still be performed.
1.180 + * Changed the command syntax to require -m (or --method=) before method
1.181 + names; improved the error reporting when settings are missing or
1.182 + inappropriate.
1.183 + * Flattened the Wiki instance hierarchy, putting the configuration, data,
1.184 + underlay and htdocs in the same top-level directory.
1.185 + * Changed the location of MoinMoin 1.9 resources, installing them in the
1.186 + prefix hierarchy and copying only static resources into Wiki instances.
1.187 + * Changed the handling of static resources with MoinMoin 1.9 to serve them
1.188 + separately just as MoinMoin 1.8 does; this makes performance much better
1.189 + when CGI is used under Apache.
1.190 + * Moved the editing of the moin script into the setup method so that no
1.191 + attempt is made to edit system programs.
1.192 + * Made moin_distribution optional so that when MoinMoin is installed from a
1.193 + system package, the non-installation actions can still be performed using
1.194 + shared data typically found in /usr/share/moin.
1.195 + * Added support for Wiki farms, separate library/site-packages directories,
1.196 + and site identifiers (based on site names).
1.197 + * Improved the MoinMoin version detection.
1.198
1.199 New in moinsetup 0.2 (Changes since moinsetup 0.1)
1.200 --------------------------------------------------
7.1 --- a/moinsetup.py Wed Sep 14 00:11:35 2011 +0200
7.2 +++ b/moinsetup.py Thu Sep 15 23:57:53 2011 +0200
7.3 @@ -55,7 +55,7 @@
7.4 ScriptAlias %(url_path)s "%(web_app_dir)s/moin.cgi"
7.5 """
7.6
7.7 -apache_site_extra_moin18 = """
7.8 +apache_site_extra = """
7.9 Alias %(static_url_path)s "%(htdocs_dir)s/"
7.10 """
7.11
7.12 @@ -79,26 +79,26 @@
7.13
7.14 postsetup_setfacl = """#!/bin/sh
7.15
7.16 -find '%(conf_dir)s/data' -type f | xargs setfacl -m u:%(web_user)s:rw
7.17 -find '%(conf_dir)s/data' -type d | xargs setfacl -m u:%(web_user)s:rwx
7.18 -find '%(conf_dir)s/underlay' -type f | xargs setfacl -m u:%(web_user)s:rw
7.19 -find '%(conf_dir)s/underlay' -type d | xargs setfacl -m u:%(web_user)s:rwx
7.20 +find '%(common_dir)s/data' -type f | xargs setfacl -m u:%(web_user)s:rw
7.21 +find '%(common_dir)s/data' -type d | xargs setfacl -m u:%(web_user)s:rwx
7.22 +find '%(common_dir)s/underlay' -type f | xargs setfacl -m u:%(web_user)s:rw
7.23 +find '%(common_dir)s/underlay' -type d | xargs setfacl -m u:%(web_user)s:rwx
7.24 """
7.25
7.26 -postsetup_setfacl_moin18_extra = """
7.27 +postsetup_setfacl_extra = """
7.28 find '%(htdocs_dir)s' -type f | xargs setfacl -m u:%(web_user)s:r
7.29 find '%(htdocs_dir)s' -type d | xargs setfacl -m u:%(web_user)s:rx
7.30 """
7.31
7.32 postsetup_chown_chmod = """#!/bin/sh
7.33
7.34 -chown -R %(this_user)s.%(web_group)s '%(conf_dir)s/data'
7.35 -chown -R %(this_user)s.%(web_group)s '%(conf_dir)s/underlay'
7.36 -chmod -R g+w '%(conf_dir)s/data'
7.37 -chmod -R g+w '%(conf_dir)s/underlay'
7.38 +chown -R %(this_user)s.%(web_group)s '%(common_dir)s/data'
7.39 +chown -R %(this_user)s.%(web_group)s '%(common_dir)s/underlay'
7.40 +chmod -R g+w '%(common_dir)s/data'
7.41 +chmod -R g+w '%(common_dir)s/underlay'
7.42 """
7.43
7.44 -postsetup_chown_moin18_extra = """
7.45 +postsetup_chown_extra = """
7.46 chown -R %(this_user)s.%(web_group)s '%(htdocs_dir)s'
7.47 """
7.48
7.49 @@ -291,6 +291,7 @@
7.50 "setup_wiki",
7.51 "install_moin",
7.52 "install_data",
7.53 + "install_static_data",
7.54 "configure_moin",
7.55 "edit_moin_script",
7.56 "edit_moin_web_script",
7.57 @@ -327,51 +328,56 @@
7.58 theme_master = "modernized"
7.59 extra_theme_css_files = ["SlideShow.css"]
7.60
7.61 - def __init__(self, moin_distribution=None, moin_data=None, prefix=None,
7.62 + def __init__(self, moin_distribution=None, prefix=None,
7.63 site_packages=None, web_app_dir=None, web_static_dir=None, web_site_dir=None,
7.64 common_dir=None, farm_config=None, site_config=None, url_path=None,
7.65 - superuser=None, site_name=None, front_page_name=None, theme_default=None):
7.66 + superuser=None, site_name=None, site_identifier=None, front_page_name=None,
7.67 + theme_default=None):
7.68
7.69 """
7.70 - Initialise a Wiki installation using the following:
7.71 + Initialise a Wiki installation using the following installation
7.72 + settings:
7.73
7.74 * moin_distribution - the directory containing a MoinMoin source
7.75 - distribution
7.76 - * moin_data - the directory containing MoinMoin shared data
7.77 - (can be omitted if 'moin_distribution' is given)
7.78 + distribution (can be omitted)
7.79 * prefix - the installation prefix (equivalent to /usr)
7.80 + * site_packages - optional: the location of the Python
7.81 + site-packages directory if outside the 'prefix'
7.82 + (overrides the path calculated using 'prefix')
7.83 * web_app_dir - the directory where Web applications and scripts
7.84 reside (such as /home/www-user/cgi-bin)
7.85 + * web_static_dir - optional: the directory where static Web
7.86 + resources reside (such as /home/www-user/htdocs)
7.87 + * web_site_dir - optional: the directory where Web site
7.88 + definitions reside (such as
7.89 + /etc/apache2/sites-available)
7.90 +
7.91 + The following site settings are also applicable:
7.92 +
7.93 * common_dir - the directory where the Wiki configuration,
7.94 resources and instance will reside (such as
7.95 /home/www-user/mywiki)
7.96 + * farm_config - optional: any Wiki farm configuration file for
7.97 + multiple Wiki deployments (overrides the
7.98 + 'common_dir' setting)
7.99 + * site_config - optional: a specific configuration file location
7.100 + (overrides the 'common_dir' setting)
7.101 * url_path - the URL path at which the Wiki will be made
7.102 available (such as / or /mywiki)
7.103 * superuser - the name of the site's superuser (such as
7.104 "AdminUser")
7.105 * site_name - the name of the site (such as "My Wiki")
7.106 + * site_identifier - optional: an identifier used to refer to the
7.107 + site, typically derived from 'site_name'
7.108 * front_page_name - the front page name for the site (such as
7.109 "FrontPage" or a specific name for the site)
7.110 - * web_site_dir - optional: the directory where Web site
7.111 - definitions reside (such as
7.112 - /etc/apache2/sites-available)
7.113 - * web_static_dir - optional: the directory where static Web
7.114 - resources reside (such as /home/www-user/htdocs)
7.115 - * farm_config - optional: any Wiki farm configuration file for
7.116 - multiple Wiki deployments (overrides the
7.117 - 'common_dir' setting)
7.118 - * site_config - optional: a specific configuration file location
7.119 - (overrides the 'common_dir' setting)
7.120 - * site_packages - optional: the location of the Python
7.121 - site-packages directory if outside the 'prefix'
7.122 - (overrides the path calculated using 'prefix')
7.123 * theme_default - optional: the default theme (such as modern)
7.124 """
7.125
7.126 self.moin_distribution = moin_distribution
7.127 - self.moin_data = moin_data
7.128 self.superuser = superuser
7.129 self.site_name = site_name
7.130 + self.site_identifier = site_identifier or site_name.replace(" ", "").lower()
7.131 self.front_page_name = front_page_name
7.132 self.farm_config = farm_config
7.133 self.site_config = site_config
7.134 @@ -379,11 +385,17 @@
7.135
7.136 # NOTE: Support the detection of the Apache sites directory.
7.137
7.138 - self.prefix, self.web_app_dir, self.web_site_dir, self.web_static_dir, self.common_dir = \
7.139 - map(self._get_abspath, (prefix, web_app_dir, web_site_dir, web_static_dir, common_dir))
7.140 + self.prefix, self.site_packages, self.web_app_dir, self.web_site_dir, self.web_static_dir, self.common_dir = \
7.141 + map(self._get_abspath, (prefix, site_packages, web_app_dir, web_site_dir, web_static_dir, common_dir))
7.142 +
7.143 + if not self.web_app_dir:
7.144 + raise TypeError, "The 'web_app_dir' setting must be specified."
7.145
7.146 # Strip any trailing "/" from the URL path.
7.147
7.148 + if not url_path:
7.149 + raise TypeError, "The 'url_path' setting must be specified."
7.150 +
7.151 if url_path != "/" and url_path.endswith("/"):
7.152 self.url_path = url_path[:-1]
7.153 else:
7.154 @@ -392,12 +404,15 @@
7.155 # Define and create specific directories.
7.156 # Here are the configuration and actual Wiki data directories.
7.157
7.158 - self.conf_dir = join(self.common_dir, "conf")
7.159 - self.instance_dir = join(self.common_dir, "wikidata")
7.160 + if not self.common_dir:
7.161 + raise TypeError, "The 'common_dir' setting must be specified."
7.162
7.163 # Define the place where the MoinMoin package will actually reside.
7.164
7.165 - self.prefix_site_packages = site_packages or \
7.166 + if not self.prefix and not self.site_packages:
7.167 + raise TypeError, "Either the 'prefix' or the 'site_packages' setting must be specified."
7.168 +
7.169 + self.prefix_site_packages = self.site_packages or \
7.170 join(self.prefix, "lib", "python%s.%s" % sys.version_info[:2], "site-packages")
7.171
7.172 # Find the version.
7.173 @@ -405,81 +420,84 @@
7.174 self.moin_version = self.get_moin_version()
7.175
7.176 # The static resources reside in different locations depending on the
7.177 - # version of MoinMoin. Moreover, these resources may end up in a
7.178 - # published directory for 1.8 installations where the Web server cannot
7.179 - # be instructed to fetch the content from outside certain designated
7.180 - # locations.
7.181 + # version of MoinMoin, but the Web server is used to serve static
7.182 + # resources in both cases, even though MoinMoin 1.9 can serve static
7.183 + # files itself.
7.184 +
7.185 + # A shared data directory may be in use.
7.186
7.187 - # 1.9: moin/lib/python2.x/site-packages/MoinMoin/web/static/htdocs
7.188 + self.htdocs_dir_source = join(self.get_moin_data(), "htdocs")
7.189
7.190 - if self.moin_version.startswith("1.9"):
7.191 + if self.htdocs_dir_source is None or not exists(self.htdocs_dir_source):
7.192 +
7.193 + # 1.9: moin/lib/python2.x/site-packages/MoinMoin/web/static/htdocs
7.194
7.195 - # A shared data directory may be in use.
7.196 -
7.197 - if self.moin_data:
7.198 - self.htdocs_dir = self.htdocs_dir_source = join(self.moin_data, "htdocs")
7.199 + if self.moin_version.startswith("1.9"):
7.200 + self.htdocs_dir_source = join(self.prefix_site_packages, "MoinMoin", "web", "static", "htdocs")
7.201 else:
7.202 - self.htdocs_dir = self.htdocs_dir_source = join(self.prefix_site_packages, "MoinMoin", "web", "static", "htdocs")
7.203 + raise SetupException, "The static resources could not be found."
7.204 +
7.205 + # Add the static identifier to the URL path. For example:
7.206 + # / -> /moin_static187
7.207 + # /hgwiki -> /hgwiki-moin_static187
7.208 +
7.209 + self.static_url_path = self.url_path + (self.url_path != "/" and "-" or "") + self.get_static_identifier()
7.210
7.211 - self.static_url_path = self.url_path
7.212 + # In limited hosting, the static resources directory is related to
7.213 + # the URL path.
7.214
7.215 - # 1.8: moin/share/moin/htdocs (optionally copied to a Web directory)
7.216 + if self.limited_hosting():
7.217 + self.htdocs_dir = join(self.web_static_dir or self.web_app_dir, self.static_url_path.lstrip("/"))
7.218 +
7.219 + # Otherwise, a mapping is made to the directory.
7.220
7.221 else:
7.222 -
7.223 - # A shared data directory may be in use.
7.224 -
7.225 - if self.moin_data:
7.226 - self.htdocs_dir_source = join(self.moin_data, "htdocs")
7.227 - else:
7.228 - self.htdocs_dir_source = join(self.instance_dir, "share", "moin", "htdocs")
7.229 -
7.230 - # Add the static identifier to the URL path. For example:
7.231 - # / -> /moin_static187
7.232 - # /hgwiki -> /hgwiki-moin_static187
7.233 -
7.234 - self.static_url_path = self.url_path + (self.url_path != "/" and "-" or "") + self.get_static_identifier()
7.235 -
7.236 - # In limited hosting, the static resources directory is related to
7.237 - # the URL path.
7.238 -
7.239 - if self.limited_hosting():
7.240 - self.htdocs_dir = join(self.web_static_dir or self.web_app_dir, self.static_url_path.lstrip("/"))
7.241 -
7.242 - # Otherwise, a mapping is made to the directory.
7.243 -
7.244 - else:
7.245 - self.htdocs_dir = self.htdocs_dir_source
7.246 + self.htdocs_dir = join(self.common_dir, "htdocs")
7.247
7.248 def _get_abspath(self, d):
7.249 return d and abspath(d) or None
7.250
7.251 def get_moin_version(self):
7.252
7.253 - "Inspect the MoinMoin package information, returning the version."
7.254 + "Return the MoinMoin version."
7.255
7.256 if self.moin_distribution:
7.257 + this_dir = os.getcwd()
7.258 try:
7.259 - this_dir = os.getcwd()
7.260 - try:
7.261 - os.chdir(self.moin_distribution)
7.262 - f = open("PKG-INFO")
7.263 - try:
7.264 - for line in f.xreadlines():
7.265 - columns = line.split()
7.266 - if columns[0] == "Version:":
7.267 - return columns[1]
7.268 + os.chdir(self.moin_distribution)
7.269 + version = self.get_moin_version_from_package_info() or \
7.270 + self.get_moin_version_from_import()
7.271 + if version:
7.272 + return version
7.273 +
7.274 + finally:
7.275 + os.chdir(this_dir)
7.276 +
7.277 + else:
7.278 + return self.get_moin_version_from_import()
7.279 +
7.280 + def get_moin_version_from_package_info(self):
7.281 +
7.282 + "Inspect the MoinMoin package information, returning the version."
7.283
7.284 - return None
7.285 -
7.286 - finally:
7.287 - f.close()
7.288 + try:
7.289 + f = open("PKG-INFO")
7.290 + try:
7.291 + for line in f.xreadlines():
7.292 + columns = line.split()
7.293 + if columns[0] == "Version:":
7.294 + return columns[1]
7.295 + finally:
7.296 + f.close()
7.297
7.298 - finally:
7.299 - os.chdir(this_dir)
7.300 + except IOError:
7.301 + pass
7.302
7.303 - except IOError:
7.304 - pass
7.305 + return None
7.306 +
7.307 + def get_moin_version_from_import(self):
7.308 +
7.309 + "Return the MoinMoin version from an import of the package itself."
7.310
7.311 # Where no distribution information can be read, try and import an
7.312 # installed version module.
7.313 @@ -492,9 +510,10 @@
7.314
7.315 def get_moin_data(self):
7.316
7.317 - "Return the location of MoinMoin data."
7.318 + "Return the exact location of MoinMoin data."
7.319
7.320 - return self.moin_data or self.moin_distribution and join(self.moin_distribution, "wiki") or None
7.321 + return self.moin_distribution and join(self.moin_distribution, "wiki") or \
7.322 + self.prefix and join(self.prefix, "share", "moin") or None
7.323
7.324 def get_static_identifier(self):
7.325
7.326 @@ -506,7 +525,7 @@
7.327
7.328 "Return the directory for plugins of the given 'plugin_type'."
7.329
7.330 - data_dir = join(self.conf_dir, "data")
7.331 + data_dir = join(self.common_dir, "data")
7.332 return join(data_dir, "plugin", plugin_type)
7.333
7.334 def limited_hosting(self):
7.335 @@ -519,7 +538,7 @@
7.336
7.337 "Make sure that all the directories are available."
7.338
7.339 - for d in (self.conf_dir, self.instance_dir, self.web_app_dir, self.web_static_dir, self.web_site_dir):
7.340 + for d in (self.common_dir, self.web_app_dir, self.web_static_dir, self.web_site_dir):
7.341 if d is not None and not exists(d):
7.342 os.makedirs(d)
7.343
7.344 @@ -551,6 +570,7 @@
7.345
7.346 self.ensure_directories()
7.347 self.install_moin()
7.348 + self.edit_moin_script()
7.349 self._setup_wiki()
7.350
7.351 def setup_wiki(self):
7.352 @@ -558,13 +578,6 @@
7.353 "Set up a Wiki without installing MoinMoin."
7.354
7.355 self.ensure_directories()
7.356 -
7.357 - try:
7.358 - self.install_moin(data_only=1)
7.359 - except SetupException:
7.360 - if not self.moin_data:
7.361 - raise
7.362 -
7.363 self._setup_wiki()
7.364
7.365 def _setup_wiki(self):
7.366 @@ -572,13 +585,16 @@
7.367 "Set up a Wiki without installing MoinMoin."
7.368
7.369 self.install_data()
7.370 + self.install_static_data()
7.371 self.configure_moin()
7.372 - self.edit_moin_script()
7.373 self.add_superuser()
7.374 self.edit_moin_web_script(self.make_site_files())
7.375 self.make_post_install_script()
7.376
7.377 - def install_moin(self, data_only=0):
7.378 + if self.moin_version.startswith("1.9"):
7.379 + note("You may need to visit the LanguageSetup page in the Wiki to create the standard set of pages.")
7.380 +
7.381 + def install_moin(self):
7.382
7.383 "Enter the distribution directory and run the setup script."
7.384
7.385 @@ -593,14 +609,10 @@
7.386
7.387 log_filename = "install-%s.log" % split(self.common_dir)[-1]
7.388
7.389 - status("Installing MoinMoin%s in %s..." % (data_only and " (data only)" or "", self.prefix))
7.390 + status("Installing MoinMoin in %s..." % self.prefix)
7.391
7.392 - if data_only:
7.393 - install_cmd = "install_data"
7.394 - options = "--install-dir='%s'" % self.instance_dir
7.395 - else:
7.396 - install_cmd = "install"
7.397 - options = "--prefix='%s' --install-data='%s' --record='%s'" % (self.prefix, self.instance_dir, log_filename)
7.398 + install_cmd = "install"
7.399 + options = "--prefix='%s' --record='%s'" % (self.prefix, log_filename)
7.400
7.401 os.system("python setup.py --quiet %s %s --force" % (install_cmd, options))
7.402
7.403 @@ -608,44 +620,48 @@
7.404
7.405 def install_data(self):
7.406
7.407 - "Install Wiki data."
7.408 + "Install Wiki data into an instance."
7.409
7.410 moin_data = self.get_moin_data()
7.411
7.412 if not moin_data:
7.413 raise SetupException, \
7.414 - "Cannot install MoinMoin data without either a 'moin_distribution' or a 'moin_data' setting being defined."
7.415 + "Cannot install MoinMoin data without either a 'moin_distribution' or a 'prefix' setting being defined."
7.416
7.417 # The default wikiconfig assumes data and underlay in the same directory.
7.418
7.419 - status("Installing data and underlay in %s..." % self.conf_dir)
7.420 + status("Installing data and underlay in %s..." % self.common_dir)
7.421
7.422 for d in ("data", "underlay"):
7.423 source = join(moin_data, d)
7.424 source_tar = source + os.path.extsep + "tar"
7.425 - d_tar = source + os.path.extsep + "tar"
7.426
7.427 if os.path.exists(source):
7.428 - shutil.copytree(source, join(self.conf_dir, d))
7.429 + shutil.copytree(source, join(self.common_dir, d))
7.430 elif os.path.exists(source_tar):
7.431 - shutil.copy(source_tar, self.conf_dir)
7.432 - os.system("tar xf %s -C %s" % (d_tar, self.conf_dir))
7.433 +
7.434 + note("Copying archive %s instead of directory %s. Running...\n"
7.435 + "make pagepacks\n"
7.436 + "in the distribution directory should rectify this." % (source_tar, source))
7.437 +
7.438 + shutil.copy(source_tar, self.common_dir)
7.439 + os.system("tar xf %s -C %s" % (source_tar, self.common_dir))
7.440 else:
7.441 status("Could not copy %s into installed Wiki." % d)
7.442
7.443 - # Copy static Web data if appropriate.
7.444 + def install_static_data(self):
7.445
7.446 - if not self.moin_version.startswith("1.9") and self.limited_hosting():
7.447 + "Install static Web data if appropriate."
7.448
7.449 - if not exists(self.htdocs_dir):
7.450 - os.mkdir(self.htdocs_dir)
7.451 + if not exists(self.htdocs_dir):
7.452 + os.mkdir(self.htdocs_dir)
7.453
7.454 - for item in os.listdir(self.htdocs_dir_source):
7.455 - path = join(self.htdocs_dir_source, item)
7.456 - if isdir(path):
7.457 - shutil.copytree(path, join(self.htdocs_dir, item))
7.458 - else:
7.459 - shutil.copy(path, join(self.htdocs_dir, item))
7.460 + for item in os.listdir(self.htdocs_dir_source):
7.461 + path = join(self.htdocs_dir_source, item)
7.462 + if isdir(path):
7.463 + shutil.copytree(path, join(self.htdocs_dir, item))
7.464 + else:
7.465 + shutil.copy(path, join(self.htdocs_dir, item))
7.466
7.467 def configure_moin(self):
7.468
7.469 @@ -655,20 +671,15 @@
7.470
7.471 if not moin_data:
7.472 raise SetupException, \
7.473 - "Cannot configure MoinMoin without either a 'moin_distribution' or a 'moin_data' setting being defined."
7.474 + "Cannot configure MoinMoin without either a 'moin_distribution' or a 'prefix' setting being defined."
7.475
7.476 # NOTE: Single Wiki only so far.
7.477
7.478 - # Static URLs seem to be different in MoinMoin 1.9.x.
7.479 - # For earlier versions, reserve URL space alongside the Wiki.
7.480 # NOTE: MoinMoin usually uses an apparently common URL space associated
7.481 # NOTE: with the version, but more specific locations are probably
7.482 # NOTE: acceptable if less efficient.
7.483
7.484 - if self.moin_version.startswith("1.9"):
7.485 - url_prefix_static = "%r + url_prefix_static" % self.static_url_path
7.486 - else:
7.487 - url_prefix_static = "%r" % self.static_url_path
7.488 + url_prefix_static = "%r" % self.static_url_path
7.489
7.490 # Use a farm configuration file.
7.491
7.492 @@ -678,7 +689,7 @@
7.493 # Or copy the Wiki configuration file from the distribution.
7.494
7.495 else:
7.496 - wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
7.497 + wikiconfig_py = join(self.common_dir, "wikiconfig.py")
7.498 shutil.copyfile(join(moin_data, "config", "wikiconfig.py"), wikiconfig_py)
7.499
7.500 status("Editing configuration from %s..." % wikiconfig_py)
7.501 @@ -718,9 +729,12 @@
7.502 Configure Moin, accessing the configuration file using 'wikiconfig'.
7.503 """
7.504
7.505 - if not self.moin_version.startswith("1.9"):
7.506 - data_dir = join(self.conf_dir, "data")
7.507 - data_underlay_dir = join(self.conf_dir, "underlay")
7.508 + # Specific site configurations also appear to need 'data_dir', even in
7.509 + # 1.9.
7.510 +
7.511 + if not self.moin_version.startswith("1.9") or self.site_config:
7.512 + data_dir = join(self.common_dir, "data")
7.513 + data_underlay_dir = join(self.common_dir, "underlay")
7.514
7.515 wikiconfig.set("data_dir", data_dir)
7.516 wikiconfig.set("data_underlay_dir", data_underlay_dir)
7.517 @@ -765,7 +779,7 @@
7.518
7.519 s = readfile(moin_cgi)
7.520 s = moin_cgi_prefix.sub("sys.path.insert(0, %r)" % self.prefix_site_packages, s)
7.521 - s = moin_cgi_wikiconfig.sub("sys.path.insert(0, %r)" % self.conf_dir, s)
7.522 + s = moin_cgi_wikiconfig.sub("sys.path.insert(0, %r)" % self.common_dir, s)
7.523
7.524 # Handle differences in script names when using limited hosting with
7.525 # URL rewriting.
7.526 @@ -787,6 +801,10 @@
7.527 writefile(moin_cgi_installed, s)
7.528 os.system("chmod a+rx '%s'" % moin_cgi_installed)
7.529
7.530 + # Fix the cause of opaque errors in some Apache environments.
7.531 +
7.532 + os.system("chmod go-w '%s'" % moin_cgi_installed)
7.533 +
7.534 def add_superuser(self):
7.535
7.536 "Add the superuser account."
7.537 @@ -800,12 +818,12 @@
7.538 path = os.environ.get("PYTHONPATH", "")
7.539
7.540 if path:
7.541 - os.environ["PYTHONPATH"] = path + ":" + self.conf_dir
7.542 + os.environ["PYTHONPATH"] = path + ":" + self.common_dir
7.543 else:
7.544 - os.environ["PYTHONPATH"] = self.conf_dir
7.545 + os.environ["PYTHONPATH"] = self.common_dir
7.546
7.547 cmd = moin_script + " --config-dir='%s' account create --name='%s' --email='%s' --password='%s'" % (
7.548 - self.conf_dir, self.superuser, email, password)
7.549 + self.common_dir, self.superuser, email, password)
7.550 os.system(cmd)
7.551
7.552 if path:
7.553 @@ -824,18 +842,16 @@
7.554
7.555 if not self.limited_hosting():
7.556
7.557 - site_def = join(self.web_site_dir, self.site_name)
7.558 + site_def = join(self.web_site_dir, self.site_identifier)
7.559
7.560 s = apache_site % self.__dict__
7.561 -
7.562 - if not self.moin_version.startswith("1.9"):
7.563 - s += apache_site_extra_moin18 % self.__dict__
7.564 + s += apache_site_extra % self.__dict__
7.565
7.566 status("Writing Apache site definitions to %s..." % site_def)
7.567 writefile(site_def, s)
7.568
7.569 - note("Copy the site definitions to the appropriate sites directory if appropriate.")
7.570 - note("Then, make sure that the site is enabled by running the appropriate tools (such as a2ensite).")
7.571 + note("Copy the site definitions to the appropriate sites directory if appropriate.\n"
7.572 + "Then, make sure that the site is enabled by running the appropriate tools (such as a2ensite).")
7.573
7.574 return 1
7.575
7.576 @@ -861,7 +877,7 @@
7.577
7.578 # Work out whether setfacl works.
7.579
7.580 - fd, temp_filename = tempfile.mkstemp(dir=self.conf_dir)
7.581 + fd, temp_filename = tempfile.mkstemp(dir=self.common_dir)
7.582 os.close(fd)
7.583
7.584 have_setfacl = os.system("setfacl -m user:%(web_user)s:r %(file)s > /dev/null 2>&1" % {
7.585 @@ -880,21 +896,19 @@
7.586 vars.update(locals())
7.587
7.588 for postinst_script, start, extra in [
7.589 - (postinst_scripts[0], postsetup_chown_chmod, postsetup_chown_moin18_extra),
7.590 - (postinst_scripts[1], postsetup_setfacl, postsetup_setfacl_moin18_extra)
7.591 + (postinst_scripts[0], postsetup_chown_chmod, postsetup_chown_extra),
7.592 + (postinst_scripts[1], postsetup_setfacl, postsetup_setfacl_extra)
7.593 ]:
7.594
7.595 s = start % vars
7.596 -
7.597 - if not self.moin_version.startswith("1.9"):
7.598 - s += extra % vars
7.599 + s += extra % vars
7.600
7.601 writefile(postinst_script, s)
7.602 os.chmod(postinst_script, 0755)
7.603
7.604 if have_setfacl:
7.605 - note("Run %s to set file ownership and permissions." % postinst_scripts[1])
7.606 - note("If this somehow fails...")
7.607 + note("Run %s to set file ownership and permissions.\n"
7.608 + "If this somehow fails..." % postinst_scripts[1])
7.609
7.610 note("Run %s as root to set file ownership and permissions." % postinst_scripts[0])
7.611
7.612 @@ -917,7 +931,7 @@
7.613 if self.site_config:
7.614 wikiconfig_py = self.site_config
7.615 else:
7.616 - wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
7.617 + wikiconfig_py = join(self.common_dir, "wikiconfig.py")
7.618
7.619 status("Editing configuration from %s..." % wikiconfig_py)
7.620
7.621 @@ -947,7 +961,7 @@
7.622 if self.farm_config:
7.623 wikiconfig_py = self.farm_config
7.624 else:
7.625 - wikiconfig_py = join(self.conf_dir, "wikiconfig.py")
7.626 + wikiconfig_py = join(self.common_dir, "wikiconfig.py")
7.627
7.628 status("Editing configuration from %s..." % wikiconfig_py)
7.629
7.630 @@ -1047,8 +1061,8 @@
7.631 if exists(css_file_path):
7.632 shutil.copy(css_file_path, target_dir)
7.633
7.634 - note("Don't forget to add theme resources for extensions for this theme.")
7.635 - note("Don't forget to edit this theme's stylesheets for extensions.")
7.636 + note("Don't forget to add theme resources for extensions for this theme.\n"
7.637 + "Don't forget to edit this theme's stylesheets for extensions.")
7.638
7.639 def install_extension_package(self, extension_dir):
7.640
7.641 @@ -1248,9 +1262,9 @@
7.642 path = os.environ.get("PYTHONPATH", "")
7.643
7.644 if path:
7.645 - os.environ["PYTHONPATH"] = path + ":" + self.prefix_site_packages + ":" + self.conf_dir
7.646 + os.environ["PYTHONPATH"] = path + ":" + self.prefix_site_packages + ":" + self.common_dir
7.647 else:
7.648 - os.environ["PYTHONPATH"] = self.prefix_site_packages + ":" + self.conf_dir
7.649 + os.environ["PYTHONPATH"] = self.prefix_site_packages + ":" + self.common_dir
7.650
7.651 installer = join(self.prefix_site_packages, "MoinMoin", "packages.py")
7.652 cmd = "python %s i %s" % (installer, package_filename)
7.653 @@ -1271,7 +1285,7 @@
7.654
7.655 # Command line option syntax.
7.656
7.657 -syntax_description = "[ -f <config-filename> ] ( <method> | --method=METHOD ) [ <method-argument> ... ]"
7.658 +syntax_description = "[ -f <config-filename> ] ( -m <method> | --method=METHOD ) [ <method-argument> ... ]"
7.659
7.660 # Main program.
7.661
7.662 @@ -1296,6 +1310,11 @@
7.663
7.664 try:
7.665 config_filename = args.get("config-filename", "moinsetup.cfg")
7.666 +
7.667 + if not exists(config_filename):
7.668 + print "Configuration", config_filename, "not found."
7.669 + sys.exit(1)
7.670 +
7.671 config = ConfigParser()
7.672 config.read(config_filename)
7.673
7.674 @@ -1309,6 +1328,8 @@
7.675 installation = Installation(**config_arguments)
7.676
7.677 except TypeError, exc:
7.678 + print "Error:"
7.679 + print
7.680 print exc.args[0]
7.681 print
7.682 print "Configuration settings:"
7.683 @@ -1327,13 +1348,15 @@
7.684
7.685 try:
7.686 method(*method_arguments)
7.687 - except TypeError:
7.688 + except TypeError, exc:
7.689 + print "Error:"
7.690 + print
7.691 print exc.args[0]
7.692 print
7.693 print "Method documentation:"
7.694 print
7.695 print method.__doc__
7.696 print
7.697 - raise
7.698 + sys.exit(1)
7.699
7.700 # vim: tabstop=4 expandtab shiftwidth=4