PATCH: Create working Windows distributions
Mark Mitchell
mark at codesourcery.com
Mon Nov 24 06:37:02 UTC 2003
This patch allows "python setup.py bdist_wininst" to generate usable
QMTest distributions.
--
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com
2003-11-23 Mark Mitchell <mark at codesourcery.com>
* setup.py: Tidy up. Use "qmtest.py" as the name of the main
script under Windows.
* qm/__init__.py: Do not honor qm.config settings under Windows.
* qm/test/.cvsignore: Add qmtest.py.
* qm/test/execution_engine.py
(ExecutionEngine.IsTerminationRequested): Rename to ..
(ExecutionEngine._IsTerminationRequested): ... this.
* qm/test/execution_thread.py
(ExecutionThread.IsTerminationRequested): Rename to ..
(ExecutionEngine._IsTerminationRequested): ... this.
* qm/test/qmtest: Do not honor rel_libdir on Windows.
* qm/test/clasess/pickle_result_stream.py
(PickleResultStream._is_binary_file): Set it.
* qm/test/doc/tour.xml: Update for changes in installation
procedures.
* qmdist/command/install_scripts.py (install_scripts.run): Process
both the "qmtest" and the "qmtest.py" script.
* scripts/qm-release: Remove.
Index: setup.py
===================================================================
RCS file: /home/sc/Repository/qm/setup.py,v
retrieving revision 1.7
diff -c -5 -p -r1.7 setup.py
*** setup.py 24 Nov 2003 00:52:57 -0000 1.7
--- setup.py 24 Nov 2003 06:26:39 -0000
***************
*** 19,44 ****
from distutils.core import setup
import sys
import os
import os.path
import string
import glob
from qmdist.command.build import build
from qmdist.command.build_doc import build_doc
from qmdist.command.install_data import install_data
from qmdist.command.install_lib import install_lib
from qmdist.command.install_scripts import install_scripts
from qmdist.command.check import check
########################################################################
# Functions
########################################################################
def prefix(list, pref):
! return map(lambda x, p=pref: os.path.join(p, x), list)
def files_with_ext(dir, ext):
"""Return all files in 'dir' with a particular extension.
--- 19,47 ----
from distutils.core import setup
import sys
import os
import os.path
+ from os.path import join
import string
import glob
from qmdist.command.build import build
from qmdist.command.build_doc import build_doc
from qmdist.command.install_data import install_data
from qmdist.command.install_lib import install_lib
from qmdist.command.install_scripts import install_scripts
from qmdist.command.check import check
+ from qm.__version import version
+ import shutil
########################################################################
# Functions
########################################################################
def prefix(list, pref):
! return map(lambda x, p=pref: join(p, x), list)
def files_with_ext(dir, ext):
"""Return all files in 'dir' with a particular extension.
*************** def select_share_files(share_files, dir,
*** 68,98 ****
files = filter(lambda f: \
f == "CATALOG" or (os.path.splitext(f)[1] in exts),
files)
if files:
files = prefix(files, dir)
! dir = os.path.join("qm", dir[len("share/"):])
share_files[dir] = files
- packages=['qm',
- 'qm/external',
- 'qm/external/DocumentTemplate',
- 'qm/test',
- 'qm/test/classes',
- 'qm/test/web']
-
- classes = ["classes.qmc"]
-
diagnostics=['common.txt','common-help.txt']
messages=['help.txt', 'diagnostics.txt']
- html_docs = []
-
if not os.path.isdir(os.path.normpath('qm/test/doc/html')):
print """Warning: to include documentation run the
\'build_doc\' command first."""
else:
html_docs = filter(lambda f: f.endswith(".html"),
os.listdir(os.path.normpath('qm/test/doc/html')))
--- 71,91 ----
files = filter(lambda f: \
f == "CATALOG" or (os.path.splitext(f)[1] in exts),
files)
if files:
files = prefix(files, dir)
! dir = join("qm", dir[len("share/"):])
share_files[dir] = files
diagnostics=['common.txt','common-help.txt']
messages=['help.txt', 'diagnostics.txt']
if not os.path.isdir(os.path.normpath('qm/test/doc/html')):
print """Warning: to include documentation run the
\'build_doc\' command first."""
+ html_docs = []
else:
html_docs = filter(lambda f: f.endswith(".html"),
os.listdir(os.path.normpath('qm/test/doc/html')))
*************** tutorial_files = files_with_ext("qm/test
*** 100,127 ****
test_dtml_files = files_with_ext("qm/test/share/dtml", ".dtml")
share_files = {}
os.path.walk("share", select_share_files, share_files)
setup(name="qm",
! version="2.1",
author="CodeSourcery, LLC",
author_email="info at codesourcery.com",
maintainer="Mark Mitchell",
maintainer_email="mark at codesourcery.com",
url="http://www.codesourcery.com/qm/test",
! description="QMTest is a automated software test execution tool.",
cmdclass={'build': build,
'build_doc': build_doc,
'install_data': install_data,
'install_lib': install_lib,
'install_scripts' : install_scripts,
'check': check},
! packages=packages,
! scripts=['qm/test/qmtest'],
data_files=[('qm/messages/test',
prefix(messages, 'qm/test/share/messages')),
# DTML files for the GUI.
("qm/dtml/test", test_dtml_files),
# The documentation.
--- 93,141 ----
test_dtml_files = files_with_ext("qm/test/share/dtml", ".dtml")
share_files = {}
os.path.walk("share", select_share_files, share_files)
+ # On UNIX, we want the main script to be "qmtest". On Windows, we need
+ # to use a ".py" extension so that users can invoke the script directly;
+ # if we were to omit the ".py" extension they would have to explicitly
+ # type "python qmtest" to invoke the script. Searching for
+ # "bdist_wininst" in sys.argv is an (inelegant) way of checking to see
+ # if we are building a Windows binary installer.
+ qmtest_script = join("qm", "test", "qmtest")
+ py_script = qmtest_script + ".py"
+ if "bdist_wininst" in sys.argv:
+ shutil.copyfile(qmtest_script, py_script)
+ qmtest_script = py_script
+ elif os.path.exists(py_script):
+ # Avoid accidentally packaging the ".py" version of the script, if
+ # it exists.
+ os.remove(py_script)
+
setup(name="qm",
! version=version,
author="CodeSourcery, LLC",
author_email="info at codesourcery.com",
maintainer="Mark Mitchell",
maintainer_email="mark at codesourcery.com",
url="http://www.codesourcery.com/qm/test",
! description="QMTest is an automated software test execution tool.",
cmdclass={'build': build,
'build_doc': build_doc,
'install_data': install_data,
'install_lib': install_lib,
'install_scripts' : install_scripts,
'check': check},
! packages=('qm',
! 'qm/external',
! 'qm/external/DocumentTemplate',
! 'qm/test',
! 'qm/test/classes',
! 'qm/test/web'),
! scripts=[qmtest_script],
data_files=[('qm/messages/test',
prefix(messages, 'qm/test/share/messages')),
# DTML files for the GUI.
("qm/dtml/test", test_dtml_files),
# The documentation.
Index: qm/__init__.py
===================================================================
RCS file: /home/sc/Repository/qm/qm/__init__.py,v
retrieving revision 1.11
diff -c -5 -p -r1.11 __init__.py
*** qm/__init__.py 24 Nov 2003 00:52:57 -0000 1.11
--- qm/__init__.py 24 Nov 2003 06:26:39 -0000
***************
*** 12,33 ****
# For license terms see the file COPYING.
#
########################################################################
########################################################################
! # imports
########################################################################
import string
! from qm.common import *
! from qm.diagnostic import error, warning, message
try:
! # The config file is created during "make install" by setup.py.
! from qm.config import version, data_dir, lib_dir
version_info = tuple(string.split(version, '.'))
"""The version of QM as a tuple of '(major, minor, release)'."""
except:
# If qm.config was not available, we are running out of the source tree.
common.is_installed = 0
from qm.__version import version, version_info
data_dir = "share"
--- 12,56 ----
# For license terms see the file COPYING.
#
########################################################################
########################################################################
! # Imports
########################################################################
+ from qm.common import *
+ from qm.diagnostic import error, warning, message
import string
! import sys
!
! ########################################################################
! # Variables
! ########################################################################
try:
! # The config file is created during "make install" by Distutils.
! from qm.config import version
version_info = tuple(string.split(version, '.'))
"""The version of QM as a tuple of '(major, minor, release)'."""
+
+ # Get the relative paths from the prefix where QMTest was
+ # installed to the data directory (where documentation and such
+ # is installed) and the library directory (where the Python
+ # modules making up QMTest are installed).
+ if sys.platform != "win32":
+ # On non-Windows platforms, the values written out at
+ # installation time are accurate.
+ from qm.config import data_dir, lib_dir
+ else:
+ # On Windows, Distutils does a mock installation and then
+ # creates a binary installer. Unfortunately, at the time
+ # the mock installation is performed there is no way to know
+ # the eventual paths. Therefore, the values indicated in
+ # config.py are incorrect. The values given below correspond
+ # to the behavior of the binary installer.
+ data_dir = "qm"
+ lib_dir = os.path.join("Lib", "site-packages", "qm")
except:
# If qm.config was not available, we are running out of the source tree.
common.is_installed = 0
from qm.__version import version, version_info
data_dir = "share"
Index: qm/test/.cvsignore
===================================================================
RCS file: /home/sc/Repository/qm/qm/test/.cvsignore,v
retrieving revision 1.6
diff -c -5 -p -r1.6 .cvsignore
*** qm/test/.cvsignore 14 Oct 2003 21:56:07 -0000 1.6
--- qm/test/.cvsignore 24 Nov 2003 06:26:39 -0000
***************
*** 1,2 ****
--- 1,3 ----
*.pyc
*.pyo
+ qmtest.py
Index: qm/test/execution_engine.py
===================================================================
RCS file: /home/sc/Repository/qm/qm/test/execution_engine.py,v
retrieving revision 1.24
diff -c -5 -p -r1.24 execution_engine.py
*** qm/test/execution_engine.py 11 Aug 2003 22:55:14 -0000 1.24
--- qm/test/execution_engine.py 24 Nov 2003 06:26:39 -0000
*************** class ExecutionEngine:
*** 224,246 ****
# Termination has not yet been requested.
self.__terminated = 0
def RequestTermination(self):
! """Request termination.
! Request that the execution thread be terminated. This may
! take some time; tests that are already running will continue
to run, for example."""
self.__terminated = 1
!
!
! def IsTerminationRequested(self):
"""Returns true if termination has been requested.
! returns -- True if Terminate has been called."""
return self.__terminated
def Run(self):
--- 224,248 ----
# Termination has not yet been requested.
self.__terminated = 0
def RequestTermination(self):
! """Request that the execution engine stop executing tests.
! Request that the execution thread be terminated. Termination
! may take some time; tests that are already running will continue
to run, for example."""
self.__terminated = 1
!
!
! def _IsTerminationRequested(self):
"""Returns true if termination has been requested.
! returns -- True if no further tests should be executed. If the
! value is -1, the execution engine should simply terminate
! gracefully."""
return self.__terminated
def Run(self):
*************** class ExecutionEngine:
*** 339,350 ****
self.__patterns = {}
# A map from target patterns to lists of test descriptors ready
# to run.
self.__target_pattern_queues = {}
! while (self.__num_tests_started < num_tests
! and not self.IsTerminationRequested()):
# Process any responses and update the count of idle targets.
while self.__CheckForResponse(wait=0):
pass
# Now look for idle targets.
--- 341,354 ----
self.__patterns = {}
# A map from target patterns to lists of test descriptors ready
# to run.
self.__target_pattern_queues = {}
! while self.__num_tests_started < num_tests:
! # If the user interrupted QMTest, stop executing tests.
! if self._IsTerminationRequested():
! break
# Process any responses and update the count of idle targets.
while self.__CheckForResponse(wait=0):
pass
# Now look for idle targets.
Index: qm/test/execution_thread.py
===================================================================
RCS file: /home/sc/Repository/qm/qm/test/execution_thread.py,v
retrieving revision 1.6
diff -c -5 -p -r1.6 execution_thread.py
*** qm/test/execution_thread.py 13 May 2003 07:10:47 -0000 1.6
--- qm/test/execution_thread.py 24 Nov 2003 06:26:39 -0000
*************** class ExecutionThread(Thread, ExecutionE
*** 108,124 ****
self.__lock.acquire()
ExecutionEngine.RequestTermination(self)
self.__lock.release()
! def IsTerminationRequested(self):
"""Returns true if termination has been requested.
return -- True if Terminate has been called."""
self.__lock.acquire()
! terminated = ExecutionEngine.IsTerminationRequested(self)
self.__lock.release()
return terminated
########################################################################
--- 108,124 ----
self.__lock.acquire()
ExecutionEngine.RequestTermination(self)
self.__lock.release()
! def _IsTerminationRequested(self):
"""Returns true if termination has been requested.
return -- True if Terminate has been called."""
self.__lock.acquire()
! terminated = ExecutionEngine._IsTerminationRequested(self)
self.__lock.release()
return terminated
########################################################################
Index: qm/test/qmtest
===================================================================
RCS file: /home/sc/Repository/qm/qm/test/qmtest,v
retrieving revision 1.2
diff -c -5 -p -r1.2 qmtest
*** qm/test/qmtest 10 Nov 2003 22:33:42 -0000 1.2
--- qm/test/qmtest 24 Nov 2003 06:26:39 -0000
*************** rel_prefix = os.path.join(os.pardir, os.
*** 40,57 ****
This string gives the relative path from the directory containing this
script to the installation directory. The value above is correct when
QMTest is being run out of the source tree. When QMTest is installed,
this value is updated appropriately."""
- rel_libdir = ""
- """The relative path from the prefix to the library directory.
-
- This path gives the relative path from the prefix to the library
- directory. The value above is correct when QMTest is being run out of
- the source tree. When QMTest is installed, this value is updated
- appropriately."""
-
# Get the path to this script.
qm_path = os.path.abspath(sys.argv[0])
# Get the root of the QMTest installation.
qm_home = os.environ.get("QM_HOME")
--- 40,49 ----
*************** if qm_home is None:
*** 59,71 ****
# Get the path to the installation directory.
qm_home = os.path.normpath(os.path.join(os.path.dirname(qm_path),
rel_prefix))
# Update sys.path so that we can find the rest of QMTest.
! libdir = os.path.normpath(os.path.join(qm_home, rel_libdir))
! if libdir not in sys.path:
! sys.path.insert(0, libdir)
import qm
# Set the prefix variable so that the rest of QMTest can find
# documentation files, test classes, and so forth.
--- 51,79 ----
# Get the path to the installation directory.
qm_home = os.path.normpath(os.path.join(os.path.dirname(qm_path),
rel_prefix))
# Update sys.path so that we can find the rest of QMTest.
! if sys.platform != "win32":
! rel_libdir = ""
! """The relative path from the prefix to the library directory.
!
! This path gives the relative path from the prefix to the library
! directory. The value above is correct when QMTest is being run out of
! the source tree. When QMTest is installed, this value is updated
! appropriately."""
!
! libdir = os.path.normpath(os.path.join(qm_home, rel_libdir))
! if libdir not in sys.path:
! sys.path.insert(0, libdir)
! else:
! # On Windows, the value computed for rel_libdir is incorrect because
! # Distutils does a mock pre-installation using different directory
! # names than are used by the binary installer. On Windows, however,
! # the QM module files are installed into a location that is already in
! # sys.path.
! pass
import qm
# Set the prefix variable so that the rest of QMTest can find
# documentation files, test classes, and so forth.
Index: qm/test/classes/pickle_result_stream.py
===================================================================
RCS file: /home/sc/Repository/qm/qm/test/classes/pickle_result_stream.py,v
retrieving revision 1.6
diff -c -5 -p -r1.6 pickle_result_stream.py
*** qm/test/classes/pickle_result_stream.py 28 Sep 2003 22:53:21 -0000 1.6
--- qm/test/classes/pickle_result_stream.py 24 Nov 2003 06:26:39 -0000
*************** class PickleResultStream(FileResultStrea
*** 112,121 ****
--- 112,123 ----
""",
default_value = 1,
),
]
+ _is_binary_file = 1
+
def __init__(self, arguments):
# Initialize the base class.
super(PickleResultStream, self).__init__(arguments)
# Create initial pickler.
Index: qm/test/doc/tour.xml
===================================================================
RCS file: /home/sc/Repository/qm/qm/test/doc/tour.xml,v
retrieving revision 1.8
diff -c -5 -p -r1.8 tour.xml
*** qm/test/doc/tour.xml 26 Sep 2003 22:57:38 -0000 1.8
--- qm/test/doc/tour.xml 24 Nov 2003 06:26:39 -0000
***************
*** 41,63 ****
copy of it. Copy the entire test database directory tree to
another location. If you've installed &qmtest; in the default
location you can make a copy of the sample database by running this
command on a UNIX system:
<screen>
! &prompt;<userinput>cp -r /usr/local/share/qm/tutorial/test/tdb tdb</userinput>
</screen>
On a Windows system, use this command at a DOS
<footnote><para>Under Windows, you must use the standard Windows
command shell (DOS) to run &qmtest;; alternative shells (such as Cygwin)
will not work with &qmtest;.</para></footnote>
prompt:
<screen>
! &prompt;<userinput>xcopy c:\progra~1\qm\share\qm\tutorial\test\tdb tdb\ /s</userinput>
! </screen>
! If you installed &qmtest; in another directory,
! substitute that directory for <filename>/usr/local</filename> or
! <filename>c:\progra~1\qm</filename> in the commands above.</para>
<para>Then, enter the new directory you have created. On both UNIX
and Windows systems, you can do this with this command:
<screen>
&prompt;<userinput>cd tdb</userinput>
--- 41,65 ----
copy of it. Copy the entire test database directory tree to
another location. If you've installed &qmtest; in the default
location you can make a copy of the sample database by running this
command on a UNIX system:
<screen>
! &prompt;<userinput>cp -r /usr/qm/tutorial/test/tdb tdb</userinput>
</screen>
On a Windows system, use this command at a DOS
<footnote><para>Under Windows, you must use the standard Windows
command shell (DOS) to run &qmtest;; alternative shells (such as Cygwin)
will not work with &qmtest;.</para></footnote>
prompt:
<screen>
! &prompt;<userinput>xcopy c:\Python23\qm\tutorial\test\tdb tdb\ /s</userinput>
! </screen>
! The exact paths to use depend on exactly how you have built and
! installed QMTest. The paths above are correct for the binary RPM
! and Windows packages distributed by CodeSourcery. If you build
! from the QMTest source distribution, the tutorial may be in another
! location, such as <filename>/usr/local/share/qm</filename>.</para>
<para>Then, enter the new directory you have created. On both UNIX
and Windows systems, you can do this with this command:
<screen>
&prompt;<userinput>cd tdb</userinput>
***************
*** 66,90 ****
<para>Make sure that &qmtest; is in your <envar>PATH</envar> so
that the operating system can find it. On UNIX, you can use this
command:
<screen>
! &prompt;<userinput>PATH=/usr/local/bin:${PATH}; export PATH</userinput>
</screen>
in the Bourne shell. In the C shell, use:
<screen>
! &prompt;<userinput>setenv PATH /usr/local/bin:${PATH}</userinput>
</screen>
On Windows, use:
<screen>
! &prompt;<userinput>PATH C:\progra~1\qm\bin;%PATH%</userinput>
</screen>
! In order to avoid having to retype these commands every time you
want to use &qmtest;, you can set up your system so that these
commands are executed automatically when you log in. Consult your
system's manuals to find out how to do this.
</para>
</section> <!-- sec-testtut-setting-up -->
<section id="sec-testtut-gui">
<title>Starting the Graphical Interface</title>
--- 68,110 ----
<para>Make sure that &qmtest; is in your <envar>PATH</envar> so
that the operating system can find it. On UNIX, you can use this
command:
<screen>
! &prompt;<userinput>PATH=/usr/bin:${PATH}; export PATH</userinput>
</screen>
in the Bourne shell. In the C shell, use:
<screen>
! &prompt;<userinput>setenv PATH /usr/bin:${PATH}</userinput>
</screen>
On Windows, use:
<screen>
! &prompt;<userinput>PATH C:\Python23\Scripts;%PATH%</userinput>
</screen>
! If you are not using Python 2.3, replace
! <filename>C:\Python23</filename> with the directory containing your
! Python installation.</para>
!
! <para>In order to avoid having to retype these commands every time you
want to use &qmtest;, you can set up your system so that these
commands are executed automatically when you log in. Consult your
system's manuals to find out how to do this.
</para>
+
+ <para>On Windows, every command in this manual that begins with
+ <command>qmtest</command> should be read as if it starts with
+ <command>qmtest.py</command>. For example, if this tutorial
+ instructs you to type:
+ <screen>
+ &prompt;<userinput>qmtest run</userinput>
+ </screen>
+ you should instead type:
+ <screen>
+ &prompt;<userinput>qmtest.py run</userinput>
+ </screen>
+ on a Windows system.
+ </para>
</section> <!-- sec-testtut-setting-up -->
<section id="sec-testtut-gui">
<title>Starting the Graphical Interface</title>
*************** QMTest running at http://127.0.0.1:1158/
*** 352,362 ****
</screen>
On a Windows system, use these commands instead:
<screen>
&prompt;<userinput>cd ..</userinput>
&prompt;<userinput>rmdir /s tdb</userinput>
! &prompt;<userinput>xcopy c:\progra~1\qm\share\qm\tutorial\test\tdb tdb\ /s</userinput>
&prompt;<userinput>cd tdb</userinput>
</screen>
</para>
<para>The command for running tests is <command>&qmtest-cmd;
--- 372,382 ----
</screen>
On a Windows system, use these commands instead:
<screen>
&prompt;<userinput>cd ..</userinput>
&prompt;<userinput>rmdir /s tdb</userinput>
! &prompt;<userinput>xcopy c:\Python23\qm\tutorial\test\tdb tdb\ /s</userinput>
&prompt;<userinput>cd tdb</userinput>
</screen>
</para>
<para>The command for running tests is <command>&qmtest-cmd;
Index: qmdist/command/install_scripts.py
===================================================================
RCS file: /home/sc/Repository/qm/qmdist/command/install_scripts.py,v
retrieving revision 1.2
diff -c -5 -p -r1.2 install_scripts.py
*** qmdist/command/install_scripts.py 24 Nov 2003 00:52:58 -0000 1.2
--- qmdist/command/install_scripts.py 24 Nov 2003 06:26:39 -0000
*************** class install_scripts(base.install_scrip
*** 33,59 ****
def run(self):
# Do the standard installation.
base.install_scripts.run(self)
! # Postprocess the main QMTest Python script.
! qmtest_file = os.path.join(self.install_dir, "qmtest")
! qmtest_script = open(qmtest_file).read()
! # Encode the relative path from that script to the top of the
! # installation directory.
! i = self.distribution.get_command_obj('install')
! prefix = i.root or i.prefix
! rel_prefix = get_relative_path(self.install_dir, prefix)
! assignment = 'rel_prefix = "%s"' % rel_prefix
! qmtest_script = re.sub("rel_prefix = .*", assignment,
! qmtest_script)
! # Encode the relative path from the prefix to the library
! # directory.
! il = self.distribution.get_command_obj('install_lib')
! rel_libdir = get_relative_path(prefix, il.install_dir)
! assignment = 'rel_libdir = "%s"' % rel_libdir
! qmtest_script = re.sub("rel_libdir = .*", assignment,
! qmtest_script)
!
! # Write the script back out.
! open(qmtest_file, "w").write(qmtest_script)
--- 33,64 ----
def run(self):
# Do the standard installation.
base.install_scripts.run(self)
! # Postprocess the main QMTest Python script. The script will
! # have ".py" extension on Windows systems, but not on UNIX
! # systems.
! for basename in ("qmtest", "qmtest.py"):
! qmtest_file = os.path.join(self.install_dir, basename)
! if not os.path.exists(qmtest_file):
! continue
! # Read the contents of the script.
! qmtest_script = open(qmtest_file).read()
! # Encode the relative path from that script to the top of the
! # installation directory.
! i = self.distribution.get_command_obj('install')
! prefix = i.root or i.prefix
! rel_prefix = get_relative_path(self.install_dir, prefix)
! assignment = 'rel_prefix = "%s"' % rel_prefix
! qmtest_script = re.sub("rel_prefix = .*", assignment,
! qmtest_script)
! # Encode the relative path from the prefix to the library
! # directory.
! il = self.distribution.get_command_obj('install_lib')
! rel_libdir = get_relative_path(prefix, il.install_dir)
! assignment = 'rel_libdir = "%s"' % rel_libdir
! qmtest_script = re.sub("rel_libdir = .*", assignment,
! qmtest_script)
! # Write the script back out.
! open(qmtest_file, "w").write(qmtest_script)
Index: scripts/qm-release
===================================================================
RCS file: scripts/qm-release
diff -N scripts/qm-release
*** scripts/qm-release 7 Aug 2003 17:05:20 -0000 1.9
--- /dev/null 1 Jan 1970 00:00:00 -0000
***************
*** 1,416 ****
- #! /bin/sh
-
- ########################################################################
- #
- # File: qm-release
- # Author: Mark Mitchell
- # Date: 11/16/2001
- #
- # Contents:
- # Script to build QM releases.
- #
- # Copyright (C) 2001, 2002 CodeSourcery LLC
- #
- # For license terms see the file COPYING.
- #
- ########################################################################
-
- ########################################################################
- # Functions
- ########################################################################
-
- # Issue the error message given by $1 and exit with a non-zero
- # exit code.
-
- error() {
- echo "qm-release: error: $1"
- exit 1
- }
-
- # Issue a usage message explaining how to use this script.
-
- usage() {
- cat <<EOF
- qm-release [-v version] [-u] [source] [rpm] [binary] [exec] [tag]
- EOF
- exit 1
- }
-
- # Change to the directory given by $1.
-
- changedir() {
- cd $1 || \
- error "Could not change directory to $1"
- }
-
- # Determine the current version of QM by checking out the mainline
- # version file. Set QM_VERSION, QM_MAJOR_VER, QM_MINOR_VER, and
- # QM_RELEASE_VER accordingly.
-
- get_qm_version() {
- echo "Determining QM version..."
-
- # Remove any old source distribution.
- rm -rf qm-${DATE}
- # Check out the source distribution.
- ${CVS} co -d qm-${DATE} qm/version || \
- error "Could not check out version file"
- . qm-${DATE}/version || \
- error "Could not read version file"
- # Clean up.
- rm -rf qm-${DATE}
- }
-
- # Tag the sources.
-
- tag_qm() {
- echo "Tagging QM..."
-
- # Remove any old source distribution.
- rm -rf qm-${QM_VERSION}
- # Check out the source distribution.
- ${CVS} co -d qm-${QM_VERSION} -r ${BRANCH} qm || \
- error "Could not check out QM"
- changedir qm-${QM_VERSION}
- # Create the version file.
- if [ $SNAPSHOT -eq 0 ]; then
- cat > version <<EOF
- # This file is automatically generated. Do not edit.
-
- QM_VERSION=${QM_VERSION}
- QM_MAJOR_VER=${QM_MAJOR_VER}
- QM_MINOR_VER=${QM_MINOR_VER}
- QM_RELEASE_VER=${QM_RELEASE_VER}
- EOF
- # Commit the version file.
- ${CVS} commit -m 'Update version numbers.' version
- fi
- # Tag the sources. Using the "-F" option to CVS makes sure that any
- # existing tag is moved, in case it takes several tries to get a
- # release that we are happy with.
- ${CVS} tag -F ${QM_RELEASE_TAG} || \
- error "Could not tag QM"
- # Go back to the directory we started in.
- changedir ..
- }
-
- # Build QM itself from the source distribution.
-
- build_qm() {
- echo "Building QM..."
-
- # Remove any old source distribution.
- rm -rf qm-${QM_VERSION}
- # Untar the source distribution. Under Windows there seem
- # to be cases where "tar xzf" will crash, but separating the
- # decompression and untarring steps works reliably.
- (zcat ${QM_SOURCE_TAR_GZ} | tar xf -) || \
- error "Could not unpack source distribution"
- changedir qm-${QM_VERSION}
- # Create an installation directory.
- rm -rf ${QM_INSTALL_DIR}
- mkdir -p ${QM_INSTALL_DIR} || \
- error "Could not create installation directory"
- # Configure QM.
- ./configure --prefix=${QM_INSTALL_DIR} "$@" || \
- error "Could not configure QM"
- # Build it.
- make || error "Could not build QM"
- # Install it.
- make install || error "Could not install QM"
- # Go back to the directory we started in.
- changedir ..
- }
-
- # Build the source distribution.
-
- build_source() {
- echo "Building source distribution..."
- # Remove the old version of the source distribution.
- rm -rf ${QM_SOURCE_TAR_GZ} qm-${QM_VERSION}
- ${CVS} export -d qm-${QM_VERSION} -r ${QM_RELEASE_TAG} qm || \
- error "Could not check out QM"
- # Remove the qm/track directory and packages that only it uses.
- rm -rf qm-${QM_VERSION}/qm/track qm-${QM_VERSION}/gadfly
- # The "-P" option is documented, but does not work, with "cvs export"
- # in CVS 1.10.7. Therefore, just try to remove all the directories
- # exported; this will succeed only with empty directories.
- find qm-${QM_VERSION} -type d -exec rmdir {} \; > /dev/null 2>&1
- # Create the tar file.
- tar czf ${QM_SOURCE_TAR_GZ} ${TAR_OPTS} qm-${QM_VERSION} || \
- error "Could not create tar file"
- # Build QM to obtain documentation files.
- build_qm --enable-maintainer_mode
- # Recreate the source directory.
- echo "Copying documentation..."
- rm -rf qm-${QM_VERSION}
- tar xzf ${QM_SOURCE_TAR_GZ} || \
- error "Could not unpack source distribution"
- cp -r ${QM_INSTALL_DIR}/share/doc/qm/test/html \
- qm-${QM_VERSION}/qm/test/doc/html || \
- error "Could not copy HTML manual"
- (mkdir qm-${QM_VERSION}/qm/test/doc/print && \
- cp -r ${QM_INSTALL_DIR}/share/doc/qm/test/pdf/manual.pdf \
- qm-${QM_VERSION}/qm/test/doc/print) || \
- error "Could not copy PDF manual"
- tar czf ${QM_SOURCE_TAR_GZ} ${TAR_OPTS} qm-${QM_VERSION} || \
- error "Could not create tar file"
- }
-
- # Build the RPM distribution.
-
- build_rpm() {
- echo "Building RPM distribution..."
- cp ${QM_SOURCE_TAR_GZ} ${RPM_BASE}/SOURCES || \
- error "Could not install source distribution"
- (tar xzf ${QM_SOURCE_TAR_GZ} -O qm-${QM_VERSION}/qm.spec.in | \
- sed -e "s|@QM_VERSION@|${QM_VERSION}|g" > qm.spec) || \
- error "Could not extract spec file"
- rpmbuild --quiet -ba --rmsource qm.spec || \
- error "Could not create RPM"
- cp ${RPM_BASE}/RPMS/i386/qm-${QM_VERSION}-0.i386.rpm ${QM_RPM}
- }
-
- # Build a binary distribution.
-
- build_binary() {
- build_qm
- echo "Building binary distribution..."
- changedir ${QM_INSTALL_DIR}/..
- rm -f ../${QM_BINARY_TAR_GZ}
- tar czf ../${QM_BINARY_TAR_GZ} ${TAR_OPTS} qm-${QM_VERSION} || \
- error "Could not create tar file"
- changedir ..
- }
-
- # Build a self-extracting executable.
-
- build_exec() {
- build_qm --with-python=/cygdrive/c/Python22/Python.exe
- echo "Building ZIP file..."
- changedir ${QM_INSTALL_DIR}
- rm -f ${QM_BINARY_ZIP}
- zip -q ${QM_BINARY_ZIP} -r . || \
- error "Could not create zip file"
- changedir ${QM_RELEASE_DIR}
- rm -f ${QM_BINARY_EXE}
- # The makesfx.exe exit code is apparently non-zero even on
- # success, so we do not check the result.
- "c:/Program Files/FreeExtractor/makesfx.exe" \
- /zip="`cygpath -w ${QM_BINARY_ZIP}`" \
- /sfx="`cygpath -w ${QM_BINARY_EXE}`" \
- /title="QM ${QM_VERSION}" \
- /website="http://www.codesourcery.com" \
- /intro="Thank you for installing QMTest!" \
- /defaultpath="\$programfiles\$\\QM"
- }
-
- # Upload files to the FTP server.
-
- upload() {
- # Figure out what platform we are on.
- tar xzf ${QM_SOURCE_TAR_GZ} qm-${QM_VERSION}/config.guess || \
- error "Could not obtain config.guess from source distribution."
- PLATFORM=`qm-${QM_VERSION}/config.guess`
- if [ $? -ne 0 ]; then
- error "Could not obtain platform name."
- fi
- # We are not building Cygwin binaries, so transform "cygwin" into
- # "windows".
- if [ $PLATFORM = i686-pc-cygwin ]; then
- PLATFORM="windows"
- fi
- PLATFORM_FTP_DIRECTORY="${FTP_DIRECTORY}/${PLATFORM}"
-
- # Make sure the FTP directory exists.
- ssh ${FTP_SERVER} mkdir -p ${FTP_DIRECTORY} ${PLATFORM_FTP_DIRECTORY} || \
- error "Could not create FTP directory."
-
- # Upload the source distribution.
- if [ ${SOURCE} -ne 0 ]; then
- scp ${QM_SOURCE_TAR_GZ} "${FTP_SERVER}:${FTP_DIRECTORY}" || \
- error "Could not upload source distribution."
- # Upload the manual as well.
- tar xzf ${QM_SOURCE_TAR_GZ} \
- qm-${QM_VERSION}/qm/test/doc/print/manual.pdf \
- qm-${QM_VERSION}/qm/test/doc/html || \
- error "Could not extract manuals."
- scp qm-${QM_VERSION}/qm/test/doc/print/manual.pdf \
- "${FTP_SERVER}:${FTP_DIRECTORY}" ||
- error "Could not upload PDF manual."
- scp -r qm-${QM_VERSION}/qm/test/doc/html \
- "${FTP_SERVER}:${FTP_DIRECTORY}/manual.html" ||
- error "Could not upload HTML manual."
- fi
-
- # Upload the RPM distribution.
- if [ ${RPM} -ne 0 ]; then
- scp ${QM_RPM} "${FTP_SERVER}:${PLATFORM_FTP_DIRECTORY}" || \
- error "Could not upload RPM distribution."
- fi
-
- # Upload the binary distribution.
- if [ ${BINARY} -ne 0 ]; then
- scp ${QM_BINARY_TAR_GZ} "${FTP_SERVER}:${PLATFORM_FTP_DIRECTORY}" || \
- error "Could not upload binary distribution."
- fi
-
- # Upload the self-extracting executable.
- if [ ${EXEC} -ne 0 ]; then
- scp ${QM_BINARY_EXE} "${FTP_SERVER}:${PLATFORM_FTP_DIRECTORY}" || \
- error "Could not upload Windows distribution."
- fi
- }
-
- ########################################################################
- # Initialization
- ########################################################################
-
- # The CVS server containing the GCC repository.
- CVS_SERVER="cvs.codesourcery.com"
- # The path to the repository on that server.
- CVS_REPOSITORY="/home/sc/Repository"
- # The CVS protocol to use.
- CVS_PROTOCOL="pserver"
- # The username to use when connecting to the server.
- CVS_USERNAME="anoncvs"
-
- # The major version of QM.
- QM_MAJOR_VER=
- # The minor version of QM.
- QM_MINOR_VER=
- # The version of QM.
- QM_VERSION=
-
- # The base RPM directory.
- RPM_BASE=/usr/src/redhat
-
- # The source distribution.
- QM_SOURCE_TAR_GZ=
- # The binary distribution.
- QM_BINARY_TAR_GZ=
- # The ZIP file.
- QM_BINARY_ZIP=
- # The executable file.
- QM_BINARY_EXE=
- # The RPM distribution.
- QM_RPM=
-
- # True if we are building a development snapshot, rather than a release.
- SNAPSHOT=1
-
- # Options to use with tar when creating an archive.
- TAR_OPTS="--owner=root --group=root --mode=u+w,go-w,a+rX,a-st"
-
- # The CVS binary.
- CVS="cvs -f -z9 -Q"
- # The QMTest branch to use.
- BRANCH=HEAD
-
- # The FTP server.
- FTP_SERVER="ftp.codesourcery.com"
- # The FTP directory.
- FTP_DIRECTORY="~ftp/pub/qmtest"
-
- # Modes of operation.
- SOURCE=0
- RPM=0
- BINARY=0
- EXEC=0
- TAG=0
- UPLOAD=0
-
- ########################################################################
- # Main Program
- ########################################################################
-
- # Set our umask so that everyone can read the files created.
- umask 002
-
- # Parse options.
- while getopts "uv:" ARG; do
- case $ARG in
- u)
- UPLOAD=1
- ;;
- v)
- QM_VERSION=$OPTARG
- # Compute the components of the version number.
- QM_MAJOR_VER=`echo $QM_VERSION | awk --assign FS=. '{ print $1; }'`
- QM_MINOR_VER=`echo $QM_VERSION | awk --assign FS=. '{ print $2; }'`
- QM_RELEASE_VER=`echo $QM_VERSION | awk --assign FS=. '{ print $3; }'`
- if test -z "$QM_RELEASE_VER"; then
- QM_RELEASE_VER=0
- fi
- # Use the release branch.
- BRANCH="release-${QM_MAJOR_VER}-${QM_MINOR_VER}-branch"
- # Because a version was explicitly specified, we are not building
- # a snapshot.
- SNAPSHOT=0
- ;;
- \?)
- usage
- ;;
- esac
- done
- shift `expr ${OPTIND} - 1`
-
- # Set up a snapshot.
- if [ $SNAPSHOT -ne 0 ]; then
- DATE=`date +%Y%m%d`
- get_qm_version
- # Add the date to the version name.
- QM_VERSION="${QM_VERSION}-${DATE}"
- fi
-
- QM_RELEASE_DIR=`pwd`
- QM_SOURCE_TAR_GZ=qm-${QM_VERSION}.tar.gz
- QM_BINARY_TAR_GZ=qm-${QM_VERSION}-binary.tar.gz
- QM_BINARY_ZIP=${QM_RELEASE_DIR}/qm-${QM_VERSION}.zip
- QM_BINARY_EXE=${QM_RELEASE_DIR}/qm-${QM_VERSION}.exe
- QM_RPM=${QM_RELEASE_DIR}/qm-${QM_VERSION}-0.i386.rpm
- QM_INSTALL_DIR=${QM_RELEASE_DIR}/install/qm-${QM_VERSION}
- FTP_DIRECTORY=${FTP_DIRECTORY}/qm-${QM_VERSION}
- QM_RELEASE_TAG="release-`echo $QM_VERSION | sed -e 's|\.|-|g'`"
-
- # Handle the major modes.
- while [ $# -ne 0 ]; do
- case $1 in
- source) SOURCE=1;;
- rpm) RPM=1;;
- binary) BINARY=1;;
- exec) EXEC=1;;
- tag) TAG=1;;
- *) usage;;
- esac
- shift
- done
-
- # Set up CVS.
- CVSROOT=":${CVS_PROTOCOL}:${CVS_USERNAME}@"
- CVSROOT="${CVSROOT}${CVS_SERVER}:${CVS_REPOSITORY}"
- export CVSROOT
-
- if [ ${UPLOAD} -eq 0 ]; then
- if [ ${TAG} -ne 0 ]; then
- tag_qm
- fi
-
- if [ ${SOURCE} -ne 0 ]; then
- build_source
- fi
-
- if [ ${RPM} -ne 0 ]; then
- build_rpm
- fi
-
- if [ ${BINARY} -ne 0 ]; then
- build_binary
- fi
-
- if [ ${EXEC} -ne 0 ]; then
- build_exec
- fi
- else
- upload
- fi
--- 0 ----
More information about the qmtest
mailing list