[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8941 - trunk/gnue-common
From: |
jan |
Subject: |
[gnue] r8941 - trunk/gnue-common |
Date: |
Fri, 27 Oct 2006 07:13:38 -0500 (CDT) |
Author: jan
Date: 2006-10-27 07:13:37 -0500 (Fri, 27 Oct 2006)
New Revision: 8941
Modified:
trunk/gnue-common/setup-cvs.py
Log:
Add win32 support for setup-cvs.py
Modified: trunk/gnue-common/setup-cvs.py
===================================================================
--- trunk/gnue-common/setup-cvs.py 2006-10-27 09:19:15 UTC (rev 8940)
+++ trunk/gnue-common/setup-cvs.py 2006-10-27 12:13:37 UTC (rev 8941)
@@ -38,10 +38,15 @@
if __name__ == '__main__':
sys.exit (0)
+# Determine if Windows is used
+WIN=(sys.platform=="win32")
+
CVSDIR = os.path.abspath(os.path.join(os.path.dirname(m.__file__),'..'))
-BASEDIR = os.path.join(CVSDIR, '.cvsdevelbase')
+BASEDIR = WIN and os.path.join(sys.prefix,"gnue-devel") or
os.path.join(CVSDIR, '.cvsdevelbase')
PYTHONBIN=sys.executable
+global CURRENT_DIR
+CURRENT_DIR = ""
CURRENT_TOOL = ""
rootCommands = []
@@ -51,19 +56,31 @@
src = os.path.join(CURRENT_DIR, scriptdir, py)
else:
src = ''
- dest = os.path.join(CURRENT_DIR, scriptdir, script)
+ if WIN:
+ dest = os.path.join(BINDIR, "%s.bat" % script)
+ else:
+ dest = os.path.join(CURRENT_DIR, scriptdir, script)
if not auto:
print "Creating %s....." % dest ,
try:
file = open(dest,'w')
- file.write(cvsbase % src)
- file.close()
- os.system ('chmod 700 %s' % dest)
+ if WIN:
+ # create batch file at final destination
+ file.write("@set PYTHONPATH=%s;%%PYTHONPATH%%\n" % BASEDIR)
+ file.write("@set SCRIPT=%s\n" % src)
+ file.write("@%s \"%%SCRIPT%%\" %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9\n" %
PYTHONBIN)
+ file.close()
+ else:
+ # create script in repository and
+ file.write(cvsbase % src)
+ file.close()
+ os.system ('chmod 700 %s' % dest)
- rootCommands.append ('rm -f %s/%s' % (BINDIR, script))
- rootCommands.append ('ln -s %s %s/%s' % \
+ rootCommands.append ('rm -f %s/%s' % (BINDIR, script))
+ rootCommands.append ('ln -s %s %s/%s' % \
(dest, BINDIR, script))
- rootCommands.append ('chmod o+x %s' % dest)
+ rootCommands.append ('chmod o+x %s' % dest)
+
except IOError:
print "Unable to create. Do you have this package checked out?"
else:
@@ -151,8 +168,12 @@
# Do not include python2.2-popy-config
elif len(version)>8:
pass
+
+ # Do not include python??.dll
+ elif base[-3:]=="dll":
+ pass
- elif os.path.samefile(file, sys.executable):
+ elif os.path.realpath(file)==os.path.realpath(sys.executable):
# If this file is the one being executed, just replace w/full name
if results[0] == sys.executable:
results[0] = file
@@ -184,7 +205,47 @@
% (exe, sys.argv[0], string.join(sys.argv[1:],'" "')))
sys.exit()
+def createLink(file, dest, overwrite=0):
+ if WIN:
+ src=os.path.normpath(os.path.join(CURRENT_DIR, file))
+ dest = os.path.normpath(dest)
+
+ if os.path.isdir(src):
+ ret = os.system("xcopy /S /E /Y \"%s\" \"%s\\\" > NUL" % (src, dest))
+ else:
+ ret = os.system("copy \"%s\" \"%s\" > NUL" % (src, dest))
+ if ret!=0:
+ print "Failed to copy %s to %s." % (src, dest)
+ else:
+ if overwrite:
+ rootCommands.append ("if [ -e %s ]; then rm -f %s; fi" % (dest, dest))
+
+ rootCommands.append("ln -f -s %s/%s %s" % (CURRENT_DIR, file, dest))
+
+
+def linkModule(subdir, module):
+ if WIN:
+ if not os.path.exists("%s/%s" % (GNUEDIR,module)):
+ os.makedirs("%s/%s" % (GNUEDIR,module))
+ # create link via virtual python module
+ output = open ("%s/%s/__init__.py" % (GNUEDIR,module), "w")
+ output.write ("# This file was generated by setup-cvs.py.\n")
+ output.write ("\n")
+ output.write ("__path__ = [\"%s\\%s\"]\n" % (CURRENT_DIR,subdir))
+ output.write ("from __init__ import *")
+ output.close ()
+ else:
+ rootCommands.append("ln -f -s %s/%s %s/%s" % (CURRENT_DIR, subdir,
GNUEDIR, module))
+
+def createDir(subdir):
+ if WIN:
+ if not os.path.exists(subdir):
+ os.makedirs(subdir)
+ else:
+ rootCommands.append("if [ ! -d %s ]; then mkdir %s; fi" % (dir,dir))
+
+
restarting = ('--withNewExecutable' in sys.argv)
auto = ('--auto' in sys.argv)
@@ -248,8 +309,20 @@
restartWithExecutable(exes[int(selection)-1])
+if WIN:
+ print """
+Warning:
+Under Windows GNUe data files (like images, settings etc) will NOT be
+updated by an repository update! For a full update please re-execute
+this script.
+
+You are creating a GNU Enterprise developer installation based on a
+code repository. As Microsoft Windows doesn't support filesystem links
+data files has to be copied from the repository to the installation
+directory. Python source files are instead linked by a specific import
+method and will be updated by a repository update.
+"""
-
if not restarting:
if not auto:
@@ -298,19 +371,9 @@
if not auto:
print
- print "Continuing with the CVS installation...\n"
+ print "Continuing with the developer installation...\n"
-
-try:
- import posixpath
-except ImportError:
- print "This CVS setup script will currently only install on a POSIX-based"
- print "system. To install on non-POSIX systems, you will have to install"
- print "each individual tool using it's 'setup.py install' script."
- sys.exit()
-
-
-if not auto:
+if not auto and not WIN:
print """
This setup script can install GNUe as either a local (per user)
copy or a system-wide copy. If you are unsure, choose the
@@ -318,10 +381,23 @@
the root password and may force all users on this machine to use
your copy."""
-ROOTINSTALL = getInput(
+ROOTINSTALL = WIN or getInput(
"Perform a [L]ocal/per-user or a [S]ystem-wide install?",'L',('L','S')) ==
'S'
+
+# confirm base path
+while WIN:
+ BASEDIR = os.path.abspath(
+ getInput ("Where do you want to install GNU Enterprise?", BASEDIR))
-if ROOTINSTALL:
+ if os.path.isdir(BASEDIR) or \
+ getYesNo("Directory %s does not exist. Create? (Yes,No,All,neVer)" %
BASEDIR, 'Y','directories'):
+ break
+
+if WIN:
+ BINDIR = os.path.join(BASEDIR,"bin")
+ CONFDIR = os.path.join(BASEDIR,"conf")
+ DOCDIR=os.path.join(BASEDIR,"docs")
+elif ROOTINSTALL:
BINDIR = "/usr/local/bin"
CONFDIR = "/usr/local/gnue"
DOCDIR = "/usr/local/gnue/doc/"
@@ -341,7 +417,7 @@
if not auto:
print """
-If you maintain multiple GNUe CVS installations, you may
+If you maintain multiple GNUe developer installations, you may
wish to add a suffix to the script names. For example, if
are installing the 0.1.x branch as a secondary branch, you
may want all the executables to be named as <script>-0.1. To
@@ -385,11 +461,8 @@
for dir in newdirs:
- rootCommands.append("if [ ! -d %s ]; then mkdir %s; fi" % (dir,dir))
+ createDir(dir)
-
-
-
GNUEDIR = os.path.join(BASEDIR,'gnue')
@@ -399,14 +472,15 @@
exec %(PYTHONBIN)s ${SCRIPT} "$@"
""" % globals()
-
-
-if os.path.isdir (GNUEDIR):
+# FIXME: Need to cleanup old files for Win32 install
+if os.path.isdir (GNUEDIR) and not WIN:
os.system ('rm -rf %s' % GNUEDIR)
+try:
+ os.makedirs(GNUEDIR)
+except:
+ pass
-os.makedirs(GNUEDIR)
-
# create path.py
output = open ("%s/paths.py" % GNUEDIR, "w")
output.write ("# This file was generated by setup-cvs.py.\n")
@@ -417,18 +491,20 @@
output.write ("config = \"%s/etc\"\n" % CONFDIR)
output.close ()
-
-rootCommands.append("""
+if WIN:
+ # create import for gnue-common
+ CURRENT_DIR = os.path.join(CVSDIR,"gnue-common")
+ linkModule("src","common")
+ os.system("copy \"%s\\gnue-common\\module\\base\\__init__.py\" \"%s\"" %
(CVSDIR, GNUEDIR) )
+ # FIXME: add locale support to Win32 developer install
+
+else:
+ rootCommands.append("""
cd %(GNUEDIR)s
ln -f -s %(CVSDIR)s/gnue-common/module/base/__init__.py .
ln -f -s %(CVSDIR)s/gnue-common/src common
if [ -f %(CVSDIR)s/gnue-common/src/.GDTD.py ]; then rm -f
%(CVSDIR)s/gnue-common/src/.GDTD.py; fi
-# ln -f -s %(CVSDIR)s/gnue-common/scripts/gnuedtd
%(CVSDIR)s/common/src/.GDTD.py
-# cd %(CONFDIR)s/etc
-# rm -f sample.*
-# ln -f -s %(CVSDIR)s/gnue-common/etc/sample.* .
-
rm -rf %(CONFDIR)s/share/locale/*
cd %(CONFDIR)s/share/locale
for i in %(CVSDIR)s/*; do
@@ -444,17 +520,7 @@
done
""" % globals() )
-
-def createLink(file, dest, overwrite=0):
- if overwrite:
- rootCommands.append ("if [ -e %s ]; then rm -f %s; fi" % (dest, dest))
- rootCommands.append("ln -f -s %s/%s %s" % (CURRENT_DIR, file, dest))
-
-
-def linkModule(subdir, module):
- rootCommands.append("ln -f -s %s/%s %s/%s" % (CURRENT_DIR, subdir, GNUEDIR,
module))
-
-
+
for CURRENT_TOOL in ('gnue-common',
'gnue-designer',
'gnue-dbtools',
@@ -465,7 +531,6 @@
'gnue-integrator',
'gnue-appserver'):
- global CURRENT_DIR
CURRENT_DIR = os.path.join(CVSDIR, CURRENT_TOOL)
setupfile = os.path.join(CURRENT_DIR, 'setup.cvs')
@@ -496,7 +561,7 @@
if os.path.isfile('/usr/local/gnue/etc/gnue.conf') and \
CONFDIR != '/usr/local/gnue' and not
os.path.isfile(CONFDIR+'/etc/gnue.conf'):
if getYesNo('Do you wish to use the current system-wide gnue.conf file?
(Yes,No,All,neVer)','N','conf'):
- rootCommands.append("ln -s /usr/local/gnue/etc/gnue.conf
%(CONFDIR)s/etc/gnue.conf" % globals())
+ rootCommands.append("ln -s /usr/local/gnue/etc/gnue.conf
%(CONFDIR)s/etc/gnue.conf" % globals())
willCreateConf = 1
@@ -518,24 +583,27 @@
print ""
print "You do not currently have a gnue.conf tools configuration file."
if getYesNo("Do you want to create a gnue.conf based on the supplied
examples? (Yes,No,All,neVer)",'Y','autoconf'):
- if not auto:
+ if not auto and not WIN:
print "Since the gnue.conf file format may change from time to time in
CVS,"
print "we can create a symlinked gnue.conf file that always mirrors CVS.
This"
print "will not allow you to customize gnue.conf, however."
- if getYesNo ("Do you want to use a symlinked gnue.conf file?",'N',):
- command = "ln -s %(CVSDIR)s/gnue-common/etc/sample.gnue.conf
%(CONFDIR)s/etc/gnue.conf" % globals()
+
+ if WIN or getYesNo ("Do you want to use a symlinked gnue.conf file?",'N',):
+ createLink("%s/gnue-common/etc/sample.gnue.conf" % CVSDIR,
"%s/etc/gnue.conf" % CONFDIR)
else:
command = "cp %(CVSDIR)s/gnue-common/etc/sample.gnue.conf
%(CONFDIR)s/etc/gnue.conf" % globals()
+ rootCommands.append(command)
- rootCommands.append(command)
-
if not willCreateConn and not
os.path.isfile("%s/etc/connections.conf"%CONFDIR):
if not auto:
print ""
print "You do not currently have a connections.conf configuration file."
if getYesNo("Do you want to create a connections.conf based on the supplied
examples? (Yes,No,All,neVer)",'Y','autoconf'):
- rootCommands.append("cp %(CVSDIR)s/gnue-common/etc/sample.connections.conf
%(CONFDIR)s/etc/connections.conf" % globals())
+ if WIN:
+ createLink("%s/gnue-common/etc/sample.connections.conf" % CVSDIR,
"%s/etc/connections.conf" % CONFDIR)
+ else:
+ rootCommands.append("cp
%(CVSDIR)s/gnue-common/etc/sample.connections.conf
%(CONFDIR)s/etc/connections.conf" % globals())
if not auto:
print
@@ -548,21 +616,21 @@
print ""
print "You do not currently have a report-filters.conf configuration file."
if getYesNo("Do you want to create a report-filters.conf based on the
supplied examples? (Yes,No,All,neVer)",'Y','autoconf'):
- if not auto:
+ if not auto and not WIN:
print "Since the report-filters.conf file format may change from time to
time in CVS,"
print "we can create a symlinked report-filters.conf file that always
mirrors CVS. This"
print "will not allow you to customize report-filters.conf, however."
- if getYesNo ("Do you want to use a symlinked report-filters.conf file?
(Yes,No,All,neVer)",'N', 'symconf'):
- command = "ln -s %(CVSDIR)s/gnue-reports/etc/sample.report-filters.conf
%(CONFDIR)s/etc/report-filters.conf" % globals()
+ if WIN or getYesNo ("Do you want to use a symlinked report-filters.conf
file? (Yes,No,All,neVer)",'N', 'symconf'):
+ createLink("%s/gnue-reports/etc/sample.report-filters.conf" % CVSDIR,
"%s/etc/report-filters.conf" % CONFDIR)
else:
- command = "cp %(CVSDIR)s/gnue-reports/etc/sample.report-filters.conf
%(CONFDIR)s/etc/report-filters.conf" % globals()
+ command = "cp %(CVSDIR)s/gnue-reports/etc/sample.report-filters.conf
%(CONFDIR)s/etc/report-filters.conf" % globals()
+ rootCommands.append(command)
- rootCommands.append(command)
+if WIN:
+ print "Setup completed!"
+elif ROOTINSTALL:
-
-if ROOTINSTALL:
-
out = open("setup-root.sh",'w')
out.write("#!/bin/sh\n")
out.write(string.join(rootCommands,"\n"))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8941 - trunk/gnue-common,
jan <=