2000-04-25 22:44:33 +04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- Mode: python -*-
|
|
|
|
#
|
2006-03-18 05:07:36 +03:00
|
|
|
# Copyright (C) 1999-2006 The ViewCVS Group. All Rights Reserved.
|
2000-04-25 22:44:33 +04:00
|
|
|
#
|
2000-05-09 12:36:29 +04:00
|
|
|
# By using this file, you agree to the terms and conditions set forth in
|
2005-12-17 20:19:28 +03:00
|
|
|
# the LICENSE.html file which can be found at the top level of the ViewVC
|
|
|
|
# distribution or at http://viewvc.org/license-1.html.
|
2000-05-09 12:36:29 +04:00
|
|
|
#
|
2006-03-18 05:07:36 +03:00
|
|
|
# For more information, visit http://viewvc.org/
|
2000-04-25 22:44:33 +04:00
|
|
|
#
|
|
|
|
# -----------------------------------------------------------------------
|
|
|
|
#
|
2005-12-17 20:19:28 +03:00
|
|
|
# install script for viewvc -- temporary?
|
2000-05-09 12:36:29 +04:00
|
|
|
#
|
|
|
|
# ### this will eventually be replaced by autoconf plus tools. an
|
|
|
|
# ### interactive front-end to ./configure may be provided.
|
2000-04-25 22:44:33 +04:00
|
|
|
#
|
|
|
|
# -----------------------------------------------------------------------
|
|
|
|
|
2000-05-12 14:26:11 +04:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import string
|
|
|
|
import re
|
|
|
|
import traceback
|
|
|
|
import py_compile
|
2005-01-06 23:10:47 +03:00
|
|
|
import getopt
|
2001-12-16 04:58:00 +03:00
|
|
|
import StringIO
|
2000-04-25 22:44:33 +04:00
|
|
|
|
2000-05-09 14:29:13 +04:00
|
|
|
# get access to our library modules
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), 'lib'))
|
|
|
|
|
|
|
|
import compat
|
2006-03-18 03:33:54 +03:00
|
|
|
import viewvc
|
2006-02-03 08:16:29 +03:00
|
|
|
import compat_ndiff
|
2006-03-18 03:33:54 +03:00
|
|
|
version = viewvc.__version__
|
2000-04-25 22:44:33 +04:00
|
|
|
|
|
|
|
|
|
|
|
## installer text
|
2005-11-15 19:42:18 +03:00
|
|
|
INFO_TEXT = """
|
2000-04-25 22:44:33 +04:00
|
|
|
|
2005-12-17 20:19:28 +03:00
|
|
|
This is the ViewVC %s installer.
|
2001-10-23 01:17:59 +04:00
|
|
|
|
2005-12-17 20:19:28 +03:00
|
|
|
It will allow you to choose the install path for ViewVC. You will
|
2001-11-19 04:10:08 +03:00
|
|
|
now be asked some installation questions.
|
2001-10-23 01:17:59 +04:00
|
|
|
|
2001-11-19 04:10:08 +03:00
|
|
|
Defaults are given in square brackets. Just hit [Enter] if a default
|
|
|
|
is okay.
|
2001-10-23 01:17:59 +04:00
|
|
|
""" % version
|
2000-04-25 22:44:33 +04:00
|
|
|
|
|
|
|
## installer defaults
|
2005-01-06 23:10:47 +03:00
|
|
|
DESTDIR = None
|
|
|
|
ROOT_DIR = None
|
2000-04-25 22:44:33 +04:00
|
|
|
|
|
|
|
|
2000-04-26 02:26:59 +04:00
|
|
|
## list of files for installation
|
2000-04-27 02:46:47 +04:00
|
|
|
## tuple (source path, destination path, install mode, true/false flag for
|
2001-10-17 11:46:52 +04:00
|
|
|
## search-and-replace, flag or text for prompt before replace,
|
|
|
|
## compile_it)
|
2000-05-12 03:55:07 +04:00
|
|
|
##
|
2000-04-27 02:46:47 +04:00
|
|
|
|
|
|
|
FILE_INFO_LIST = [
|
2006-03-18 03:33:54 +03:00
|
|
|
("bin/cgi/viewvc.cgi", "bin/cgi/viewvc.cgi", 0755, 1, 0, 0),
|
Tigris.org likes to use '/trunk/www' for the project htdocs stuff.
This gives me a chance to finally rename the 'www' directory to
something more in line with other CGI programs I've seen. And while
I'm here, and while we have Subversion, I might as well do many of the
reorgs I've been wanting to do for some time.
* www
Renamed to...
* bin
...this.
* standalone.py,
* tools/make-database,
* tools/svndbadmin,
* tools/loginfo-handler,
* tools/cvsdbadmin
Moved from here...
* bin/standalone.py,
* bin/make-database,
* bin/svndbadmin,
* bin/loginfo-handler,
* bin/cvsdbadmin
...to here.
* viewcvs-install
Update locations of moved files.
* viewcvs.sourceforge.net/upgrading.html
Tweak relevant documentation.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1161 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-12 09:15:20 +03:00
|
|
|
("bin/cgi/query.cgi", "bin/cgi/query.cgi", 0755, 1, 0, 0),
|
2006-03-18 03:33:54 +03:00
|
|
|
("bin/mod_python/viewvc.py", "bin/mod_python/viewvc.py", 0755, 1, 0, 0),
|
Tigris.org likes to use '/trunk/www' for the project htdocs stuff.
This gives me a chance to finally rename the 'www' directory to
something more in line with other CGI programs I've seen. And while
I'm here, and while we have Subversion, I might as well do many of the
reorgs I've been wanting to do for some time.
* www
Renamed to...
* bin
...this.
* standalone.py,
* tools/make-database,
* tools/svndbadmin,
* tools/loginfo-handler,
* tools/cvsdbadmin
Moved from here...
* bin/standalone.py,
* bin/make-database,
* bin/svndbadmin,
* bin/loginfo-handler,
* bin/cvsdbadmin
...to here.
* viewcvs-install
Update locations of moved files.
* viewcvs.sourceforge.net/upgrading.html
Tweak relevant documentation.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1161 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-12 09:15:20 +03:00
|
|
|
("bin/mod_python/query.py", "bin/mod_python/query.py", 0755, 1, 0, 0),
|
2005-12-11 17:51:45 +03:00
|
|
|
("bin/mod_python/handler.py", "bin/mod_python/handler.py", 0755, 1, 0, 0),
|
Tweak logic used to find installed paths ("lib" directory, configuration
file, templates, etc). Specifically, make the following changes:
- Get rid of hardcoded paths in module files ("lib" directory) and
configuration files (viewcvs.conf and mod_python's .htaccess)
- Allow stub scripts (for asp, cgi, and mod_python) to specify
configuration files so it's possible to have multiple configurations of
viewcvs running off a single installation.
- Be more consistent about resolving paths when they aren't hardcoded
(when ViewCVS is running from a source directory). In particular, try
not to depend on the working directory. That way it's legal to run
./standalone.py instead of bin/standalone.py without getting an
ImportError.
- Get rid of global cfg variables in viewcvs.py and cvsdb.py. They led to
all sorts of hacks in other files to pilfer and reset them. They were
also possible sources of races in multithreaded environments like
mod_python and asp.
- Rewrite mod_python handler so library paths can be specified inside the
stub files.
* lib/apache.py
removed, contained old mod_python handler
* lib/config.py
(Config.load_config):
remove sys.argv voodoo, just load the configuration path specified in
the pathname argument
(Config.set_defaults):
use relative path for cvsgraph_conf setting instead of hardcoded
<VIEWCVS_INSTALL_DIRECTORY> literal
* lib/cvsdb.py
(CONF_PATHNAME, config, cfg):
removed, configuration stuff
(CheckinDatabase.__init__, CheckinDatabase.CreateSQLQueryString):
add "_row_limit" member instead of using cfg object
(CreateCheckinDatabase):
removed, a do-nothing function
(ConnectDatabaseReadOnly, ConnectDatabase):
add cfg arguments
(GetUnrecordedCommitList):
add db argument
* lib/query.py
(CONF_PATHAME):
removed
(build_commit, run_query, main):
add cfg arguments, use new viewcvs.get_template function
* lib/viewcvs.py
(CONF_PATHNAME, cfg, g_install_dir):
removed
(Request.__init__):
add cfg member
(Request.run_viewcvs, Request.get_link, check_freshness,
get_view_template, generate_page, default_view, get_file_view_info,
format_log, common_template_data, MarkupEnscript.__init__,
markup_stream_python, markup_stream_php, make_time_string, view_markup,
sort_file_data, view_directory, paging, view_log, view_annotate,
view_cvsgraph_image, view_cvsgraph, view_doc, rcsdiff_date_reformat,
spaced_html_text, DiffSource.__init__, DiffSource._get_row, view_patch,
view_diff, generate_tarball, download_tarball, view_revision,
is_query_supported, english_query, build_commit, view_query,
view_error, main):
stop using global config, use cfg arguments or request member instead
(_install_path):
new, use __file__ to locate template and configuation paths
(get_view_template):
use _install_path and return compiled template instead of path
(is_viewable, default_view):
rename is_viewable to default_view and return view instead of boolean
(handle_config, load_config):
rename handle_config to load_config and return config object instead
of setting cfg global
* bin/cgi/viewcvs.cgi
* bin/cgi/query.cgi
* bin/cvsdbadmin
* bin/loginfo-handler
* bin/standalone.py
* bin/svndbadmin
look for library relative to sys.argv[0] when no hardcoded library
path is available. Also add configuration loading code.
* bin/asp/viewcvs.asp
* bin/asp/query.asp
add configuration loading code
* bin/mod_python/.htaccess
specify new mod_python handler, remove reference to
<VIEWCVS_APACHE_LIBRARY_DIRECTORY>
* bin/mod_python/handler.py
added, holds new mod_python handler
* bin/mod_python/viewcvs.py
* bin/mod_python/query.py
rewrite for new handler, add hardcoded library and configuration paths
* viewcvs.conf.dist
remove references to <VIEWCVS_INSTALL_DIRECTORY>
* viewcvs-install
(FILE_INFO_LIST):
stop hardcoding paths in config files
(SetPythonPaths,):
get rid of <VIEWCVS_INSTALL_DIRECTORY> and
<VIEWCVS_APACHE_LIBRARY_DIRECTORY> substitutions
(ApacheEscape, _re_apache):
removed
(InstallTree):
stop hardcoding paths in lib directory
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1173 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-12-06 07:04:14 +03:00
|
|
|
("bin/mod_python/.htaccess", "bin/mod_python/.htaccess", 0755, 0, 0, 0),
|
Tigris.org likes to use '/trunk/www' for the project htdocs stuff.
This gives me a chance to finally rename the 'www' directory to
something more in line with other CGI programs I've seen. And while
I'm here, and while we have Subversion, I might as well do many of the
reorgs I've been wanting to do for some time.
* www
Renamed to...
* bin
...this.
* standalone.py,
* tools/make-database,
* tools/svndbadmin,
* tools/loginfo-handler,
* tools/cvsdbadmin
Moved from here...
* bin/standalone.py,
* bin/make-database,
* bin/svndbadmin,
* bin/loginfo-handler,
* bin/cvsdbadmin
...to here.
* viewcvs-install
Update locations of moved files.
* viewcvs.sourceforge.net/upgrading.html
Tweak relevant documentation.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1161 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-12 09:15:20 +03:00
|
|
|
("bin/standalone.py", "bin/standalone.py", 0755, 1, 0, 0),
|
2006-03-18 03:33:54 +03:00
|
|
|
("viewvc.conf.dist", "viewvc.conf", 0644, 0,
|
2001-10-17 11:46:52 +04:00
|
|
|
"""Note: If you are upgrading from viewcvs-0.7 or earlier:
|
|
|
|
The section [text] has been removed from viewcvs.conf. The functionality
|
2001-10-23 01:17:59 +04:00
|
|
|
went into the new files in subdirectory templates.""", 0),
|
* www/cgi/viewcvs.cgi, www/cgi/query.cgi, www/viewcvs-strace.sh,
cgi/viewcvs.cgi, cgi/query.cgi, cgi/viewcvs-strace.sh
- moved stub scripts from cgi/ to www/cgi/
* cgi/granny.cgi
- deleted since annotate functionality is already intergrated into
viewcvs
* cvsgraph.conf.dist, viewcvs.conf.dist,
cgi/cvsgraph.conf.dist, cgi/viewcvs.conf.dist
- moved configuration files from cgi/ to project root
* www/mod_python/.htaccess, www/mod_python/query.py, www/mod_python/viewcvs.py,
windows/htaccess.mod_python, windows/query.py windows/viewcvs.py
- moved mod_python files from windows/ to www/mod_python/
* www/asp/query.asp, www/asp/viewcvs.asp,
windows/query.asp, windows/viewcvs.asp
- moved asp files from windows/ to www/asp/
* viewcvs-install
- updated installer to deal with all the moved files
* INSTALL windows/README website/upgrading.html
- updated documentation with new file locations and mod_python information
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@657 8cb11bc2-c004-0410-86c3-e597b4017df7
2003-06-03 10:24:59 +04:00
|
|
|
("cvsgraph.conf.dist", "cvsgraph.conf", 0644, 0, 1, 0),
|
2000-05-12 14:26:11 +04:00
|
|
|
|
Tigris.org likes to use '/trunk/www' for the project htdocs stuff.
This gives me a chance to finally rename the 'www' directory to
something more in line with other CGI programs I've seen. And while
I'm here, and while we have Subversion, I might as well do many of the
reorgs I've been wanting to do for some time.
* www
Renamed to...
* bin
...this.
* standalone.py,
* tools/make-database,
* tools/svndbadmin,
* tools/loginfo-handler,
* tools/cvsdbadmin
Moved from here...
* bin/standalone.py,
* bin/make-database,
* bin/svndbadmin,
* bin/loginfo-handler,
* bin/cvsdbadmin
...to here.
* viewcvs-install
Update locations of moved files.
* viewcvs.sourceforge.net/upgrading.html
Tweak relevant documentation.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1161 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-12 09:15:20 +03:00
|
|
|
("bin/loginfo-handler", "bin/loginfo-handler", 0755, 1, 0, 0),
|
|
|
|
("bin/cvsdbadmin", "bin/cvsdbadmin", 0755, 1, 0, 0),
|
|
|
|
("bin/svndbadmin", "bin/svndbadmin", 0755, 1, 0, 0),
|
|
|
|
("bin/make-database", "bin/make-database", 0755, 1, 0, 0),
|
2000-04-26 02:26:59 +04:00
|
|
|
]
|
|
|
|
|
2003-02-20 02:24:29 +03:00
|
|
|
if sys.platform == "win32":
|
2003-02-20 13:43:11 +03:00
|
|
|
FILE_INFO_LIST.extend([
|
2006-03-18 03:33:54 +03:00
|
|
|
("bin/asp/viewvc.asp", "bin/asp/viewvc.asp", 0755, 1, 0, 0),
|
Tigris.org likes to use '/trunk/www' for the project htdocs stuff.
This gives me a chance to finally rename the 'www' directory to
something more in line with other CGI programs I've seen. And while
I'm here, and while we have Subversion, I might as well do many of the
reorgs I've been wanting to do for some time.
* www
Renamed to...
* bin
...this.
* standalone.py,
* tools/make-database,
* tools/svndbadmin,
* tools/loginfo-handler,
* tools/cvsdbadmin
Moved from here...
* bin/standalone.py,
* bin/make-database,
* bin/svndbadmin,
* bin/loginfo-handler,
* bin/cvsdbadmin
...to here.
* viewcvs-install
Update locations of moved files.
* viewcvs.sourceforge.net/upgrading.html
Tweak relevant documentation.
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1161 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-11-12 09:15:20 +03:00
|
|
|
("bin/asp/query.asp", "bin/asp/query.asp", 0755, 1, 0, 0),
|
2003-02-20 13:43:11 +03:00
|
|
|
])
|
2003-02-20 02:24:29 +03:00
|
|
|
|
2002-05-22 05:16:07 +04:00
|
|
|
TREE_LIST = [
|
|
|
|
("lib", "lib", 0),
|
|
|
|
("templates", "templates", 1),
|
|
|
|
]
|
|
|
|
|
2003-02-09 12:16:09 +03:00
|
|
|
# used to escape substitution strings passed to re.sub(). re.escape() is no
|
|
|
|
# good because it blindly puts backslashes in front of anything that is not
|
|
|
|
# a number or letter regardless of whether the resulting sequence will be
|
|
|
|
# interpreted.
|
|
|
|
def ReEscape(str):
|
|
|
|
return string.replace(str, "\\", "\\\\")
|
2000-04-27 02:46:47 +04:00
|
|
|
|
2000-05-09 14:29:13 +04:00
|
|
|
def Error(text, etype=None, evalue=None):
|
2000-04-27 02:46:47 +04:00
|
|
|
print
|
2000-05-09 14:29:13 +04:00
|
|
|
print "[ERROR] %s" % text
|
|
|
|
if etype:
|
|
|
|
print '[ERROR] ',
|
|
|
|
traceback.print_exception(etype, evalue, None, file=sys.stdout)
|
2000-04-27 02:46:47 +04:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
def MkDir(path):
|
2000-05-09 14:29:13 +04:00
|
|
|
try:
|
|
|
|
compat.makedirs(path)
|
2000-05-17 10:42:49 +04:00
|
|
|
except os.error, e:
|
|
|
|
if e[0] == 17:
|
2000-05-09 14:29:13 +04:00
|
|
|
# EEXIST: file exists
|
|
|
|
return
|
2000-05-17 10:42:49 +04:00
|
|
|
if e[0] == 13:
|
2000-05-09 14:29:13 +04:00
|
|
|
# EACCES: permission denied
|
|
|
|
Error("You do not have permission to create directory %s" % path)
|
|
|
|
Error("Unknown error creating directory %s" % path, OSError, e)
|
2000-04-27 02:46:47 +04:00
|
|
|
|
2000-05-09 14:29:13 +04:00
|
|
|
|
|
|
|
|
|
|
|
def SetOnePath(contents, var, value):
|
|
|
|
pattern = re.compile('^' + var + r'\s*=\s*.*$', re.MULTILINE)
|
2003-02-09 12:16:09 +03:00
|
|
|
repl = '%s = r"%s"' % (var, os.path.join(ROOT_DIR, value))
|
|
|
|
return re.sub(pattern, ReEscape(repl), contents)
|
2000-05-09 14:29:13 +04:00
|
|
|
|
2001-12-16 04:58:00 +03:00
|
|
|
|
2000-05-09 14:29:13 +04:00
|
|
|
def SetPythonPaths(contents):
|
2000-05-12 05:56:50 +04:00
|
|
|
if contents[:2] == '#!':
|
|
|
|
shbang = '#!' + sys.executable
|
2003-02-09 12:16:09 +03:00
|
|
|
contents = re.sub('^#![^\n]*', ReEscape(shbang), contents)
|
2000-05-09 14:29:13 +04:00
|
|
|
contents = SetOnePath(contents, 'LIBRARY_DIR', 'lib')
|
2006-03-18 03:33:54 +03:00
|
|
|
contents = SetOnePath(contents, 'CONF_PATHNAME', 'viewvc.conf')
|
2000-05-09 14:29:13 +04:00
|
|
|
return contents
|
2000-04-26 02:26:59 +04:00
|
|
|
|
2000-04-27 02:46:47 +04:00
|
|
|
|
2000-05-12 14:26:11 +04:00
|
|
|
def InstallFile(src_path, dest_path, mode, set_python_paths, prompt_replace,
|
|
|
|
compile_it):
|
2001-12-16 04:58:00 +03:00
|
|
|
dest_path = os.path.join(ROOT_DIR, dest_path)
|
2000-05-12 03:55:07 +04:00
|
|
|
|
2005-01-06 23:10:47 +03:00
|
|
|
if prompt_replace and os.path.exists(DESTDIR + dest_path):
|
2001-12-16 04:58:00 +03:00
|
|
|
# Collect ndiff output from ndiff
|
|
|
|
sys.stdout = StringIO.StringIO()
|
2006-02-15 18:09:57 +03:00
|
|
|
compat_ndiff.main([DESTDIR + dest_path, src_path])
|
2001-12-16 04:58:00 +03:00
|
|
|
ndiff_output = sys.stdout.getvalue()
|
|
|
|
|
|
|
|
# Return everything to normal
|
|
|
|
sys.stdout = sys.__stdout__
|
|
|
|
|
|
|
|
# Collect the '+ ' and '- ' lines
|
|
|
|
# total collects the difference lines to be printed later
|
|
|
|
total = ""
|
|
|
|
# I use flag to throw out match lines.
|
|
|
|
flag = 1
|
|
|
|
for line in string.split(ndiff_output,'\n'):
|
|
|
|
# Print line if it is a difference line
|
|
|
|
if line[:2] == "+ " or line[:2] == "- " or line[:2] == "? ":
|
|
|
|
total = total + line + "\n"
|
|
|
|
flag = 1
|
|
|
|
else:
|
|
|
|
# Compress lines that are the same to print one blank line
|
|
|
|
if flag:
|
|
|
|
total = total + "\n"
|
|
|
|
flag = 0
|
|
|
|
|
|
|
|
if total == "\n":
|
2005-01-06 23:10:47 +03:00
|
|
|
print " File %s exists,\n but there is no difference between target and source files.\n" % (DESTDIR + dest_path)
|
2001-12-16 04:58:00 +03:00
|
|
|
return
|
|
|
|
|
|
|
|
if type(prompt_replace) == type(""):
|
|
|
|
print prompt_replace
|
|
|
|
while 1:
|
2005-11-15 19:42:18 +03:00
|
|
|
temp = raw_input("""
|
|
|
|
File %s exists and is different from source file.
|
|
|
|
DO YOU WANT TO,
|
|
|
|
overwrite [o]
|
|
|
|
do not overwrite [d]
|
|
|
|
view differences [v]: """ % (DESTDIR + dest_path))
|
2001-12-16 04:58:00 +03:00
|
|
|
print
|
|
|
|
|
|
|
|
temp = string.lower(temp[0])
|
|
|
|
|
|
|
|
if temp == "d":
|
|
|
|
return
|
|
|
|
|
|
|
|
if temp == "v":
|
2004-09-22 10:22:42 +04:00
|
|
|
if string.lower(src_path[-4:]) in [ '.gif', '.png', '.jpg' ]:
|
|
|
|
print 'Can not print differences between binary files'
|
|
|
|
else:
|
|
|
|
print total
|
2005-11-15 19:42:18 +03:00
|
|
|
print """
|
|
|
|
LEGEND
|
|
|
|
A leading '- ' indicates line to remove from installed file
|
|
|
|
A leading '+ ' indicates line to add to installed file
|
|
|
|
A leading '? ' shows intraline differences."""
|
2001-12-16 04:58:00 +03:00
|
|
|
|
|
|
|
if temp == "o":
|
2005-11-15 19:42:18 +03:00
|
|
|
ReplaceFile(src_path, dest_path, mode, set_python_paths,
|
|
|
|
prompt_replace, compile_it)
|
2001-12-16 04:58:00 +03:00
|
|
|
return
|
|
|
|
else:
|
2005-11-15 19:42:18 +03:00
|
|
|
ReplaceFile(src_path, dest_path, mode, set_python_paths,
|
|
|
|
prompt_replace, compile_it)
|
2001-12-16 04:58:00 +03:00
|
|
|
return
|
|
|
|
|
2005-11-15 19:42:18 +03:00
|
|
|
def ReplaceFile(src_path, dest_path, mode, set_python_paths,
|
|
|
|
prompt_replace, compile_it):
|
2001-12-16 04:58:00 +03:00
|
|
|
try:
|
2003-02-09 12:16:09 +03:00
|
|
|
contents = open(src_path, "rb").read()
|
2001-12-16 04:58:00 +03:00
|
|
|
except IOError, e:
|
|
|
|
Error(str(e))
|
|
|
|
|
|
|
|
if set_python_paths:
|
|
|
|
contents = SetPythonPaths(contents)
|
|
|
|
|
|
|
|
## write the file to the destination location
|
2005-01-06 23:10:47 +03:00
|
|
|
path, basename = os.path.split(DESTDIR + dest_path)
|
2001-12-16 04:58:00 +03:00
|
|
|
MkDir(path)
|
|
|
|
|
|
|
|
try:
|
2005-01-06 23:10:47 +03:00
|
|
|
open(DESTDIR + dest_path, "wb").write(contents)
|
2001-12-16 04:58:00 +03:00
|
|
|
except IOError, e:
|
|
|
|
if e[0] == 13:
|
|
|
|
# EACCES: permission denied
|
|
|
|
Error("You do not have permission to write file %s" % dest_path)
|
|
|
|
Error("Unknown error writing file %s" % dest_path, IOError, e)
|
2000-05-12 03:55:07 +04:00
|
|
|
|
2005-01-06 23:10:47 +03:00
|
|
|
os.chmod(DESTDIR + dest_path, mode)
|
2001-12-16 04:58:00 +03:00
|
|
|
|
|
|
|
if compile_it:
|
2005-11-15 19:42:18 +03:00
|
|
|
py_compile.compile(DESTDIR + dest_path,
|
|
|
|
DESTDIR + dest_path + "c" , dest_path)
|
2001-12-16 04:58:00 +03:00
|
|
|
|
|
|
|
return
|
2000-04-25 22:44:33 +04:00
|
|
|
|
|
|
|
|
2002-05-22 05:16:07 +04:00
|
|
|
def install_tree(src_path, dst_path, prompt_replace):
|
|
|
|
files = os.listdir(src_path)
|
|
|
|
files.sort()
|
|
|
|
for fname in files:
|
|
|
|
# eliminate some items which appear in a development area
|
2006-02-25 20:17:29 +03:00
|
|
|
if fname == 'CVS' or fname == '.svn' or fname == '_svn' \
|
|
|
|
or fname[-4:] == '.pyc' or fname[-5:] == '.orig' \
|
|
|
|
or fname[-4:] == '.rej' or fname[0] == '.' \
|
|
|
|
or fname[-1] == '~':
|
2002-05-22 05:16:07 +04:00
|
|
|
continue
|
|
|
|
|
|
|
|
src = os.path.join(src_path, fname)
|
|
|
|
dst = os.path.join(dst_path, fname)
|
|
|
|
if os.path.isdir(src):
|
|
|
|
install_tree(src, dst, prompt_replace)
|
|
|
|
else:
|
|
|
|
print " ", src
|
Tweak logic used to find installed paths ("lib" directory, configuration
file, templates, etc). Specifically, make the following changes:
- Get rid of hardcoded paths in module files ("lib" directory) and
configuration files (viewcvs.conf and mod_python's .htaccess)
- Allow stub scripts (for asp, cgi, and mod_python) to specify
configuration files so it's possible to have multiple configurations of
viewcvs running off a single installation.
- Be more consistent about resolving paths when they aren't hardcoded
(when ViewCVS is running from a source directory). In particular, try
not to depend on the working directory. That way it's legal to run
./standalone.py instead of bin/standalone.py without getting an
ImportError.
- Get rid of global cfg variables in viewcvs.py and cvsdb.py. They led to
all sorts of hacks in other files to pilfer and reset them. They were
also possible sources of races in multithreaded environments like
mod_python and asp.
- Rewrite mod_python handler so library paths can be specified inside the
stub files.
* lib/apache.py
removed, contained old mod_python handler
* lib/config.py
(Config.load_config):
remove sys.argv voodoo, just load the configuration path specified in
the pathname argument
(Config.set_defaults):
use relative path for cvsgraph_conf setting instead of hardcoded
<VIEWCVS_INSTALL_DIRECTORY> literal
* lib/cvsdb.py
(CONF_PATHNAME, config, cfg):
removed, configuration stuff
(CheckinDatabase.__init__, CheckinDatabase.CreateSQLQueryString):
add "_row_limit" member instead of using cfg object
(CreateCheckinDatabase):
removed, a do-nothing function
(ConnectDatabaseReadOnly, ConnectDatabase):
add cfg arguments
(GetUnrecordedCommitList):
add db argument
* lib/query.py
(CONF_PATHAME):
removed
(build_commit, run_query, main):
add cfg arguments, use new viewcvs.get_template function
* lib/viewcvs.py
(CONF_PATHNAME, cfg, g_install_dir):
removed
(Request.__init__):
add cfg member
(Request.run_viewcvs, Request.get_link, check_freshness,
get_view_template, generate_page, default_view, get_file_view_info,
format_log, common_template_data, MarkupEnscript.__init__,
markup_stream_python, markup_stream_php, make_time_string, view_markup,
sort_file_data, view_directory, paging, view_log, view_annotate,
view_cvsgraph_image, view_cvsgraph, view_doc, rcsdiff_date_reformat,
spaced_html_text, DiffSource.__init__, DiffSource._get_row, view_patch,
view_diff, generate_tarball, download_tarball, view_revision,
is_query_supported, english_query, build_commit, view_query,
view_error, main):
stop using global config, use cfg arguments or request member instead
(_install_path):
new, use __file__ to locate template and configuation paths
(get_view_template):
use _install_path and return compiled template instead of path
(is_viewable, default_view):
rename is_viewable to default_view and return view instead of boolean
(handle_config, load_config):
rename handle_config to load_config and return config object instead
of setting cfg global
* bin/cgi/viewcvs.cgi
* bin/cgi/query.cgi
* bin/cvsdbadmin
* bin/loginfo-handler
* bin/standalone.py
* bin/svndbadmin
look for library relative to sys.argv[0] when no hardcoded library
path is available. Also add configuration loading code.
* bin/asp/viewcvs.asp
* bin/asp/query.asp
add configuration loading code
* bin/mod_python/.htaccess
specify new mod_python handler, remove reference to
<VIEWCVS_APACHE_LIBRARY_DIRECTORY>
* bin/mod_python/handler.py
added, holds new mod_python handler
* bin/mod_python/viewcvs.py
* bin/mod_python/query.py
rewrite for new handler, add hardcoded library and configuration paths
* viewcvs.conf.dist
remove references to <VIEWCVS_INSTALL_DIRECTORY>
* viewcvs-install
(FILE_INFO_LIST):
stop hardcoding paths in config files
(SetPythonPaths,):
get rid of <VIEWCVS_INSTALL_DIRECTORY> and
<VIEWCVS_APACHE_LIBRARY_DIRECTORY> substitutions
(ApacheEscape, _re_apache):
removed
(InstallTree):
stop hardcoding paths in lib directory
git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@1173 8cb11bc2-c004-0410-86c3-e597b4017df7
2005-12-06 07:04:14 +03:00
|
|
|
set_paths = 0
|
2002-05-22 05:16:07 +04:00
|
|
|
compile_it = fname[-3:] == '.py'
|
2002-05-22 13:01:14 +04:00
|
|
|
InstallFile(src, dst, 0644, set_paths, prompt_replace, compile_it)
|
2002-05-22 05:16:07 +04:00
|
|
|
|
2003-03-03 12:57:06 +03:00
|
|
|
# prompt to delete all .py and .pyc files that don't belong in installation
|
2005-01-06 23:10:47 +03:00
|
|
|
full_dst_path = os.path.join(DESTDIR + ROOT_DIR, dst_path)
|
2003-03-03 12:57:06 +03:00
|
|
|
for fname in os.listdir(full_dst_path):
|
|
|
|
if not os.path.isfile(os.path.join(full_dst_path, fname)) or \
|
|
|
|
not ((fname[-3:] == '.py' and fname not in files) or
|
|
|
|
(fname[-4:] == '.pyc' and fname[:-1] not in files)):
|
|
|
|
continue
|
|
|
|
|
|
|
|
while 1:
|
2005-11-15 19:42:18 +03:00
|
|
|
temp = raw_input("""
|
2005-12-17 20:19:28 +03:00
|
|
|
File %s does not belong in ViewVC %s.
|
2005-11-15 19:42:18 +03:00
|
|
|
DO YOU WANT TO,
|
|
|
|
delete [d]
|
|
|
|
leave as is [l]: """ % (os.path.join(dst_path, fname), version))
|
2003-03-03 12:57:06 +03:00
|
|
|
print
|
|
|
|
|
|
|
|
temp = string.lower(temp[0])
|
|
|
|
|
|
|
|
if temp == "l":
|
|
|
|
break
|
|
|
|
|
|
|
|
if temp == "d":
|
|
|
|
os.unlink(os.path.join(full_dst_path, fname))
|
|
|
|
break
|
2002-05-22 05:16:07 +04:00
|
|
|
|
2000-04-25 22:44:33 +04:00
|
|
|
## MAIN
|
|
|
|
if __name__ == "__main__":
|
2005-01-06 23:10:47 +03:00
|
|
|
# option parsing
|
2006-03-27 00:23:14 +04:00
|
|
|
try:
|
|
|
|
optlist, args = getopt.getopt(sys.argv[1:], "", ['prefix=', 'destdir='])
|
|
|
|
except getopt.GetoptError, e:
|
|
|
|
Error("Invalid option", getopt.GetoptError, e)
|
2005-01-06 23:10:47 +03:00
|
|
|
for opt, arg in optlist:
|
|
|
|
if opt == '--prefix':
|
|
|
|
ROOT_DIR = arg
|
|
|
|
if opt == '--destdir':
|
|
|
|
DESTDIR = arg
|
|
|
|
|
2006-03-27 00:23:14 +04:00
|
|
|
## print greeting
|
|
|
|
print INFO_TEXT
|
|
|
|
|
2005-01-06 23:10:47 +03:00
|
|
|
## prompt for ROOT_DIR if none provided
|
|
|
|
if ROOT_DIR is None:
|
|
|
|
if sys.platform == "win32":
|
|
|
|
pf = os.getenv("ProgramFiles", "C:\\Program Files")
|
2005-12-17 20:19:28 +03:00
|
|
|
default = os.path.join(pf, "viewvc-" + version)
|
2005-01-06 23:10:47 +03:00
|
|
|
else:
|
2005-12-17 20:19:28 +03:00
|
|
|
default = "/usr/local/viewvc-" + version
|
2006-02-15 18:09:57 +03:00
|
|
|
temp = string.strip(raw_input("Installation path [%s]: " % default))
|
2005-01-06 23:10:47 +03:00
|
|
|
print
|
|
|
|
if len(temp):
|
2000-04-26 02:26:59 +04:00
|
|
|
ROOT_DIR = temp
|
2005-01-06 23:10:47 +03:00
|
|
|
else:
|
|
|
|
ROOT_DIR = default
|
|
|
|
|
|
|
|
## prompt for DESTDIR if none provided
|
|
|
|
if DESTDIR is None:
|
|
|
|
default = ''
|
2006-02-15 18:09:57 +03:00
|
|
|
temp = string.strip(raw_input(
|
|
|
|
"DESTDIR path (generally, only package maintainers will need "
|
|
|
|
"to change\nthis) [%s]: " % default))
|
2005-01-06 23:10:47 +03:00
|
|
|
print
|
|
|
|
if len(temp):
|
|
|
|
DESTDIR = temp
|
|
|
|
else:
|
|
|
|
DESTDIR = default
|
2000-04-26 02:26:59 +04:00
|
|
|
|
2000-04-27 02:46:47 +04:00
|
|
|
## install the files
|
2005-12-17 20:19:28 +03:00
|
|
|
print "Installing ViewVC to:", ROOT_DIR,
|
2005-01-06 23:10:47 +03:00
|
|
|
if DESTDIR:
|
|
|
|
print "(DESTDIR = %s)" % (DESTDIR)
|
|
|
|
else:
|
|
|
|
print
|
2000-05-09 14:29:13 +04:00
|
|
|
|
2000-05-12 14:26:11 +04:00
|
|
|
for args in FILE_INFO_LIST:
|
2001-12-16 04:58:00 +03:00
|
|
|
print " ", args[0]
|
2000-05-12 14:26:11 +04:00
|
|
|
apply(InstallFile, args)
|
2000-04-26 02:26:59 +04:00
|
|
|
|
2002-05-22 05:16:07 +04:00
|
|
|
for args in TREE_LIST:
|
|
|
|
apply(install_tree, args)
|
|
|
|
|
2002-01-23 08:24:31 +03:00
|
|
|
print """
|
|
|
|
|
2005-12-17 20:19:28 +03:00
|
|
|
ViewVC File Installation Complete
|
2002-01-23 08:24:31 +03:00
|
|
|
|
|
|
|
Consult INSTALL for detailed information to finish the installation
|
2005-12-17 20:19:28 +03:00
|
|
|
and configure ViewVC for your system.
|
2002-01-23 08:24:31 +03:00
|
|
|
|
|
|
|
Overview of remaining steps:
|
|
|
|
|
2003-02-09 12:16:09 +03:00
|
|
|
1) Edit the %s file.
|
2002-01-23 08:24:31 +03:00
|
|
|
|
|
|
|
2) Configure an existing web server to run (or copy to cgi-bin)
|
2003-02-09 12:16:09 +03:00
|
|
|
%s.
|
2005-11-15 19:42:18 +03:00
|
|
|
OR
|
2005-12-17 20:19:28 +03:00
|
|
|
Run the web server that comes with ViewVC at
|
2003-02-09 12:16:09 +03:00
|
|
|
%s.
|
|
|
|
""" % (
|
2006-03-18 03:33:54 +03:00
|
|
|
os.path.join(ROOT_DIR, 'viewvc.conf'),
|
|
|
|
os.path.join(ROOT_DIR, 'bin', 'cgi', 'viewvc.cgi'),
|
2006-05-16 02:37:24 +04:00
|
|
|
os.path.join(ROOT_DIR, 'bin', 'standalone.py'))
|