use right entity name for table data
[scons.git] / SConstruct
index e00e10919904cb4911bd5aecaa16a4cf096a27ef..34059502ba1ce4904dcc666f8d181e820bc09ed0 100644 (file)
@@ -4,12 +4,12 @@
 # See the README file for an overview of how SCons is built and tested.
 #
 
-# When this gets changed, you also need to change test/option-v.py
-# so it looks for the right string.
-copyright_years = '2001, 2002, 2003, 2004, 2005, 2006, 2007'
+# When this gets changed, you must also change the copyright_years string
+# in QMTest/TestSCons.py so the test scripts look for the right string.
+copyright_years = '2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008'
 
 # This gets inserted into the man pages to reflect the month of release.
-month_year = 'January 2007'
+month_year = 'September 2008'
 
 #
 # __COPYRIGHT__
@@ -42,9 +42,10 @@ import re
 import stat
 import string
 import sys
+import tempfile
 
 project = 'scons'
-default_version = '0.97.0'
+default_version = '1.0.1'
 copyright = "Copyright (c) %s The SCons Foundation" % copyright_years
 
 SConsignFile()
@@ -117,13 +118,14 @@ if checkpoint:
         checkpoint = time.strftime('d%Y%m%d', time.localtime(time.time()))
     elif checkpoint == 'r':
         checkpoint = 'r' + revision
-    version = version + checkpoint
+    version = version + '.' + checkpoint
+
+svn_status = None
+svn_status_lines = []
 
 if svn:
     svn_status = os.popen("%s status --verbose 2> /dev/null" % svn, "r").read()
     svn_status_lines = svn_status[:-1].split('\n')
-else:
-    svn_status_lines = []
 
 build_id = ARGUMENTS.get('BUILD_ID')
 if build_id is None:
@@ -138,8 +140,11 @@ python_ver = sys.version[0:3]
 
 platform = distutils.util.get_platform()
 
+# Re-exporting LD_LIBRARY_PATH is necessary if the Python version was
+# built with the --enable-shared option.
+
 ENV = { 'PATH' : os.environ['PATH'] }
-for key in ['LOGNAME', 'PYTHONPATH']:
+for key in ['LOGNAME', 'PYTHONPATH', 'LD_LIBRARY_PATH']:
     if os.environ.has_key(key):
         ENV[key] = os.environ[key]
 
@@ -158,14 +163,14 @@ command_line_variables = [
                         "The default is whatever hostname is returned " +
                         "by socket.gethostname()."),
 
-    ("CHECKPOINT=",     "The specific checkpoint release being packaged " +
-                        "This will be appended to the VERSION string.  " +
+    ("CHECKPOINT=",     "The specific checkpoint release being packaged, " +
+                        "which will be appended to the VERSION string.  " +
                         "A value of CHECKPOINT=d will generate a string " +
-                        "of 'd' plus today's date in the format YYYMMDD." +
+                        "of 'd' plus today's date in the format YYYMMDD.  " +
                         "A value of CHECKPOINT=r will generate a " +
-                        "string of 'r' plus the Subversion revision number.  " +
-                        "Any other CHECKPOINT= string will be used as is." +
-                        "There is no default value."),
+                        "string of 'r' plus the Subversion revision " +
+                        "number.  Any other CHECKPOINT= string will be " +
+                        "used as is.  There is no default value."),
 
     ("DATE=",           "The date string representing when the packaging " +
                         "build occurred.  The default is the day and time " +
@@ -238,7 +243,7 @@ import textwrap
 
 indent_fmt = '  %-26s  '
 
-Help("""
+Help("""\
 The following aliases build packages of various types, and unpack the
 contents into build/test-$PACKAGE subdirectories, which can be used by the
 runtest.py -p option to run tests against what's been actually packaged:
@@ -480,18 +485,54 @@ python_scons = {
                           },
 }
 
-# The RPM spec file we generate will just execute "python", not
-# necessarily the one in sys.executable.  If that version of python has
-# a distutils that knows about Python eggs, then setup.py will generate
-# a .egg-info file.  Check for whether or not to add it to the expected
-# RPM files by executing "python" in a subshell.
+# Figure out the name of a .egg-info file that might be generated
+# as part of the RPM package.  There are two complicating factors.
+#
+# First, the RPM spec file we generate will just execute "python", not
+# necessarily the one in sys.executable.  If *that* version of python has
+# a distutils that knows about Python eggs, then setup.py will generate a
+# .egg-info file, so we have to execute any distutils logic in a subshell.
+#
+# Second, we can't just have the subshell check for the existence of the
+# distutils.command.install_egg_info module and generate the expected
+# file name by hand, the way we used to, because different systems can
+# have slightly different .egg-info naming conventions.  (Specifically,
+# Ubuntu overrides the default behavior to remove the Python version
+# string from the .egg-info file name.)  The right way to do this is to
+# actually call into the install_egg_info() class to have it generate
+# the expected name for us.
+#
+# This is all complicated enough that we do it by writing an in-line
+# script to a temporary file and then feeding it to a separate invocation
+# of "python" to tell us the actual name of the generated .egg-info file.
 
-cmd = "python -c 'import distutils.command.install_egg_info' > /dev/null 2>&1"
-import_egg_error = os.system(cmd)
+print_egg_info_name = """
+try:
+    from distutils.dist import Distribution
+    from distutils.command.install_egg_info import install_egg_info
+except ImportError:
+    pass
+else:
+    dist = Distribution({'name' : "scons", 'version' : '%s'})
+    i = install_egg_info(dist)
+    i.finalize_options()
+    import os.path
+    print os.path.split(i.outputs[0])[1]
+""" % version
 
-if not import_egg_error:
-    egg_info_file = 'scons-' + version + '.egg-info'
-    python_scons['extra_rpm_files'].append(egg_info_file)
+try:
+    fd, tfname = tempfile.mkstemp()
+    tfp = os.fdopen(fd, "w")
+    tfp.write(print_egg_info_name)
+    tfp.close()
+    egg_info_file = os.popen("python %s" % tfname).read()[:-1]
+    if egg_info_file:
+        python_scons['extra_rpm_files'].append(egg_info_file)
+finally:
+    try:
+        os.unlink(tfname)
+    except EnvironmentError:
+        pass
 
 #
 # The original packaging scheme would have have required us to push
@@ -765,9 +806,13 @@ for p in [ scons ]:
 
     distutils_targets = [ win32_exe ]
 
-    Local(env.Install('$DISTDIR', distutils_targets))
+    dist_distutils_targets = env.Install('$DISTDIR', distutils_targets)
+    Local(dist_distutils_targets)
+    AddPostAction(dist_distutils_targets, Chmod(dist_distutils_targets, 0644))
 
-    if gzip:
+    if not gzip:
+        print "gzip not found; skipping .tar.gz package for %s." % pkg
+    else:
 
         distutils_formats.append('gztar')
 
@@ -778,6 +823,8 @@ for p in [ scons ]:
         dist_tar_gz             = env.Install('$DISTDIR', tar_gz)
         dist_platform_tar_gz    = env.Install('$DISTDIR', platform_tar_gz)
         Local(dist_tar_gz, dist_platform_tar_gz)
+        AddPostAction(dist_tar_gz, Chmod(dist_tar_gz, 0644))
+        AddPostAction(dist_platform_tar_gz, Chmod(dist_platform_tar_gz, 0644))
 
         #
         # Unpack the tar.gz archive created by the distutils into
@@ -851,7 +898,9 @@ for p in [ scons ]:
                                                                 bytes))
         env.Command(digest, tar_gz, Digestify)
 
-    if zipit:
+    if not zipit:
+        print "zip not found; skipping .zip package for %s." % pkg
+    else:
 
         distutils_formats.append('zip')
 
@@ -862,6 +911,8 @@ for p in [ scons ]:
         dist_zip            = env.Install('$DISTDIR', zip)
         dist_platform_zip   = env.Install('$DISTDIR', platform_zip)
         Local(dist_zip, dist_platform_zip)
+        AddPostAction(dist_zip, Chmod(dist_zip, 0644))
+        AddPostAction(dist_platform_zip, Chmod(dist_platform_zip, 0644))
 
         #
         # Unpack the zip archive created by the distutils into
@@ -949,6 +1000,8 @@ for p in [ scons ]:
         dist_noarch_rpm = env.Install('$DISTDIR', noarch_rpm)
         dist_src_rpm    = env.Install('$DISTDIR', src_rpm)
         Local(dist_noarch_rpm, dist_src_rpm)
+        AddPostAction(dist_noarch_rpm, Chmod(dist_noarch_rpm, 0644))
+        AddPostAction(dist_src_rpm, Chmod(dist_src_rpm, 0644))
 
         dfiles = map(lambda x, d=test_rpm_dir: os.path.join(d, 'usr', x),
                      dst_files)
@@ -1017,6 +1070,8 @@ for p in [ scons ]:
 
     dist_local_tar_gz = os.path.join("$DISTDIR/%s.tar.gz" % s_l_v)
     dist_local_zip = os.path.join("$DISTDIR/%s.zip" % s_l_v)
+    AddPostAction(dist_local_tar_gz, Chmod(dist_local_tar_gz, 0644))
+    AddPostAction(dist_local_zip, Chmod(dist_local_zip, 0644))
 
     commands = [
         Delete(build_dir_local),
@@ -1118,7 +1173,9 @@ SConscript('doc/SConscript')
 # source archive from the project files and files in the change.
 #
 
-if svn_status:
+if not svn_status:
+   "Not building in a Subversion tree; skipping building src package."
+else:
     slines = filter(lambda l: l[0] in ' MA', svn_status_lines)
     sentries = map(lambda l: l.split()[-1], slines)
     sfiles = filter(os.path.isfile, sentries)