setup.py revision 1265
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
import errno
import fnmatch
import os
import platform
import stat
import sys
import shutil
import re
import subprocess
import tarfile
import tempfile
import urllib
import py_compile
import sha
# 3rd party software required for the build
CP = 'CherryPy'
CPIDIR = 'cherrypy'
CPVER = '3.1.1'
CPHASH = '0a8aace00ea28adc05edd41e20dd910042e6d265'
PO = 'pyOpenSSL'
POIDIR = 'OpenSSL'
POVER = '0.7'
POHASH = 'bd072fef8eb36241852d25a9161282a051f0a63e'
FL = 'figleaf'
FLIDIR = 'figleaf'
FLVER = 'latest'
# No hash, since we always fetch the latest
FLHASH = None
MAKO = 'Mako'
MAKOIDIR = 'mako'
MAKOVER = '0.2.2'
MAKOHASH = '85c04ab3a6a26a1cab47067449712d15a8b29790'
PLY = 'ply'
PLYIDIR = 'ply'
PLYVER = '3.1'
PLYHASH = '38efe9e03bc39d40ee73fa566eb9c1975f1a8003'
PC = 'pycurl'
PCIDIR = 'pycurl'
PCVER = '7.19.0'
PCHASH = '3fb59eca1461331bb9e9e8d6fe3b23eda961a416'
if osname == 'sunos':
ostype = "posix"
elif osname == 'linux':
ostype = "posix"
elif osname == 'windows':
ostype = "windows"
elif osname == 'darwin':
ostype = "posix"
#
# Unbuffer stdout and stderr. This helps to ensure that subprocess output
# is properly interleaved with output from this program.
#
else:
scripts_dir = 'usr/bin'
svc_method_dir = 'lib/svc/method'
resource_dir = 'usr/share/lib/pkg'
smf_dir = 'var/svc/manifest/application'
scripts_sunos = {
scripts_dir: [
['client.py', 'pkg'],
['pkgdep.py', 'pkgdep'],
['publish.py', 'pkgsend'],
['pull.py', 'pkgrecv'],
['packagemanager.py', 'packagemanager'],
['updatemanager.py', 'pm-updatemanager'],
],
lib_dir: [
['depot.py', 'pkg.depotd'],
['updatemanagernotifier.py', 'updatemanagernotifier'],
['checkforupdates.py', 'pm-checkforupdates'],
['launch.py', 'pm-launch'],
],
['svc/svc-pkg-depot', 'svc-pkg-depot'],
],
}
scripts_windows = {
scripts_dir: [
['publish.py', 'publish.py'],
['scripts/pkgsend.bat', 'pkgsend.bat'],
['scripts/pkgrecv.bat', 'pkgrecv.bat'],
],
lib_dir: [
['scripts/pkg.depotd.bat', 'pkg.depotd.bat'],
],
}
scripts_dir: [
['pkgdep.py', 'pkgdep'],
['publish.py', 'publish.py'],
['scripts/pkgsend.sh', 'pkgsend'],
['scripts/pkgrecv.sh', 'pkgrecv'],
],
lib_dir: [
['scripts/pkg.depotd.sh', 'pkg.depotd'],
],
}
# indexed by 'osname'
scripts = {
"sunos": scripts_sunos,
"linux": scripts_other_unix,
"windows": scripts_windows,
"darwin": scripts_other_unix,
"unknown": scripts_sunos,
}
man1_files = [
]
man1m_files = [
]
man5_files = [
]
packages = [
'pkg',
'pkg.actions',
'pkg.bundle',
'pkg.client',
'pkg.client.transport',
'pkg.flavor',
'pkg.portable',
'pkg.publish',
'pkg.server'
]
web_files = []
if not files:
continue
if f != "Makefile"
]))
zones_files = [
]
brand_files = [
'brand/config.xml',
'brand/common.ksh',
]
smf_files = [
]
pspawn_srcs = [
]
elf_srcs = [
]
arch_srcs = [
]
_actions_srcs = [
]
include_dirs = [ 'modules' ]
# Runs the test suite with the code coverage suite (figleaf) turned on, and
# outputs a coverage report.
# TODO: Make the cov report format an option (html, ast, cov, etc)
description = "Runs figleaf code coverage suite"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
# Run the test suite with coverage enabled
# Reconstruct the cmdline and send that to run.py
print "Generating coverage report in directory: '%s/cov_report'" % \
# Runs lint on the extension module source code
description = "Runs various lint tools over IPS extension source code"
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
# Make string shell-friendly
# assumes lint is on the $PATH
# Insert tests directory onto sys.path so any custom checkers
# can be found.
# assumes pylint is accessible on the sys.path
scriptlist = [ 'setup.py' ]
for d, m in scripts_sunos.items():
for a in m:
# specify the filenames of the scripts, in addition
# to the package names themselves
# For some reason, the load-plugins option, when used in the
# rcfile, does not work, so we put it here instead, to load
# our custom checkers.
class install_func(_install):
def initialize_options(self):
# PRIVATE_BUILD set in the environment tells us to put the build
# directory into the .pyc files, rather than the final
# installation directory.
if private_build is None:
else:
# This is used when installing scripts, below, but it isn't a
# standard distutils variable.
"""
At the end of the install function, we need to rename some files
because distutils provides no way to rename files as they are
placed in their install locations.
Also, make sure that cherrypy and other external dependencies
are installed.
"""
# make scripts executable
# Take cacerts in cacert_dir and install them in
# proto-area-relative cacert_install_dir
#
# to ensure that this builds and runs on older
#
if osname == "sunos":
# Remove some bits that we're not going to package, but be sure
# not to complain if we try to remove them twice.
raise
try:
except EnvironmentError, e:
raise
if swhash == None:
return True
print "checksumming %s" % swname
while True:
if data == "":
break
f.close()
return True
else:
return False
def install_cacerts():
# Copy certificate
if not copied:
continue
# Call openssl to create hash symlink
p.wait()
hashval += ".0"
else:
print "downloading %s" % swname
try:
except IOError:
pass
"Please retrieve the file " \
# remove a partial download or error message from proxy
print "unpacking %s" % swname
# extractall doesn't exist until python 2.5
for m in tar.getmembers():
# If there are patches, apply them now.
for p in patches:
print "Applying %s to %s" % (p, swname)
if osname == "windows":
if ret != 0:
"patch failed and returned %d." % ret
print "installing %s" % swname
'--root=%s' % root_dir,
'--install-lib=%s' % py_install_dir,
'--install-data=%s' % py_install_dir]
if ret != 0:
"install failed and returned %d." % ret
print("deleting %s" % swname)
else:
class build_func(_build):
def initialize_options(self):
def get_hg_version():
try:
except OSError:
return "unknown"
def syntax_check(filename):
""" Run python's compiler over the file, and discard the results.
Arrange to generate an exception if the file does not compile.
This is needed because distutil's own use of pycompile (in the
distutils.utils module) is broken, and doesn't stop on error. """
try:
except py_compile.PyCompileError, e:
raise DistutilsError("%s: failed syntax check: %s" %
(filename, e))
class build_py_func(_build_py):
# override the build_module method to do VERSION substitution on pkg/__init__.py
versionre = '(?m)^VERSION[^"]*"([^"]*)"'
# Grab the previously-built version out of the build
# tree.
try:
ocontent = \
except IOError:
ov = None
v = get_hg_version()
vstr = 'VERSION = "%s"' % v
# If the versions haven't changed, there's no need to
# recompile.
if v == ov:
return
print "doing version substitution: ", v
return rv
# Will raise a DistutilsError on failure.
class clean_func(_clean):
def initialize_options(self):
class clobber_func(Command):
user_options = []
description = "Deletes any and all files created by setup"
def initialize_options(self):
pass
def finalize_options(self):
pass
# nuke everything
print("deleting " + dist_dir)
print("deleting " + build_dir)
print("deleting " + root_dir)
print("deleting " + pkgs_dir)
print("deleting " + extern_dir)
# list of options stored in initialize_options below. The first entry
# in each tuple must be the exact name of a member variable.
("genbaseline", 'g', "generate test baseline"),
("parseable", 'p', "parseable output"),
("timing", "t", "timing file <file>"),
("baselinefile=", 'b', "baseline file <file>"),
("only=", "o", "only <regex>")]
description = "Runs unit and functional tests"
def initialize_options(self):
def finalize_options(self):
pass
# Reconstruct the cmdline and send that to run.py
args = ""
def initialize_options(self):
# These are set to real values based on the platform, down below
compile_args = None
link_args = None
ext_modules = [
'actions._actions',
),
]
elf_libraries = None
cmdclasses = {
'install': install_func,
'build': build_func,
'build_py': build_py_func,
'bdist': dist_func,
'lint': lint_func,
'clean': clean_func,
'clobber': clobber_func,
'coverage': cov_func,
'test': test_func,
}
# all builds of IPS should have manpages
data_files += [
(man1_dir, man1_files),
(man1m_dir, man1m_files),
(man5_dir, man5_files),
]
if osname == 'sunos':
# Solaris-specific extensions are added here
data_files += [
(zones_dir, zones_files),
(brand_dir, brand_files),
]
# Unix platforms which the elf extension has been ported to
# are specified here, so they are built automatically
elf_libraries = ['elf']
ext_modules += [
'elf',
),
]
# Solaris has built-in md library and Solaris-specific arch extension
# All others use OpenSSL and cross-platform arch module
if osname == 'sunos':
elf_libraries += [ 'md' ]
ext_modules += [
'arch',
),
'pspawn',
),
]
else:
elf_libraries += [ 'ssl' ]
name = 'ips',
version = '1.0',
ext_package = 'pkg',
)