setup.py revision 2310
#
# 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
#
#
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 hashlib
if osname == 'sunos':
ostype = "posix"
elif osname == 'linux':
ostype = "posix"
elif osname == 'windows':
ostype = "windows"
elif osname == 'darwin':
ostype = "posix"
elif osname == 'aix':
arch = "aix"
ostype = "posix"
# 3rd party software required for the build
CP = 'CherryPy'
CPIDIR = 'cherrypy'
CPVER = '3.1.2'
CPHASH = 'a94aedfd0e675858dbcc32dd250c23d285ee9b88'
PO = 'pyOpenSSL'
POIDIR = 'OpenSSL'
POVER = '0.7'
POHASH = 'bd072fef8eb36241852d25a9161282a051f0a63e'
COV = 'coveragepy'
COVIDIR = 'coverage'
COVVER = '3.2b2'
COVPVER = '3.2'
COVHASH = '4710d033b8c6de1efaa562243e5b29e0a31fb8b9'
LDTP = 'ldtp'
LDTPIDIR = 'ldtp'
LDTPVER = '1.7.1'
LDTPMINORVER = '1.7.x'
LDTPMAJORVER = '1.x'
LDTPHASH = 'd31213d2b1449a0dadcace723b9ff7041169f7ce'
MAKO = 'Mako'
MAKOIDIR = 'mako'
MAKOVER = '0.2.2'
MAKOHASH = '85c04ab3a6a26a1cab47067449712d15a8b29790'
PLY = 'ply'
PLYIDIR = 'ply'
PLYVER = '3.1'
PLYHASH = '38efe9e03bc39d40ee73fa566eb9c1975f1a8003'
PBJ = 'pybonjour'
PBJIDIR = 'pybonjour'
PBJVER = '1.1.1'
PBJHASH = '92cabd14e04c5f62ce067c47c2057ee3d424d29b'
PC = 'pycurl'
PCIDIR = 'curl'
PCVER = '7.19.0'
PCPVER= '7.19.0.1'
PCHASH = '3fb59eca1461331bb9e9e8d6fe3b23eda961a416'
PCENVIRON = {}
M2C = 'M2Crypto'
M2CIDIR = 'm2crypto'
M2CVER = '0.21.1'
M2CHASH = '3c7135b952092e4f2eee7a94c5153319cccba94e'
#
# 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_sys_dir = 'lib/svc/manifest/system'
etcbrand_dir = 'etc/brand/ipkg'
sysrepo_dir = 'etc/pkg/sysrepo'
sysrepo_logs_dir = 'var/log/pkg/sysrepo'
# A list of source, destination tuples of modules which should be hardlinked
# together if the os supports it and otherwise copied.
hardlink_modules = []
scripts_sunos = {
scripts_dir: [
['client.py', 'pkg'],
['pkgdep.py', 'pkgdepend'],
['pkgrepo.py', 'pkgrepo'],
['util/publish/pkgdiff.py', 'pkgdiff'],
['util/publish/pkglint.py', 'pkglint'],
['util/publish/pkgmerge.py', 'pkgmerge'],
['util/publish/pkgmogrify.py', 'pkgmogrify'],
['publish.py', 'pkgsend'],
['pull.py', 'pkgrecv'],
['sign.py', 'pkgsign'],
['packagemanager.py', 'packagemanager'],
['updatemanager.py', 'pm-updatemanager'],
],
lib_dir: [
['depot.py', 'pkg.depotd'],
['checkforupdates.py', 'pm-checkforupdates'],
['updatemanagernotifier.py', 'updatemanagernotifier'],
['launch.py', 'pm-launch'],
['sysrepo.py', 'pkg.sysrepo'],
],
['svc/svc-pkg-depot', 'svc-pkg-depot'],
['svc/svc-pkg-mdns', 'svc-pkg-mdns'],
['svc/svc-pkg-sysrepo', 'svc-pkg-sysrepo'],
],
}
scripts_windows = {
scripts_dir: [
['pkgrepo.py', 'pkgrepo.py'],
['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'],
['util/publish/pkgdiff.py', 'pkgdiff'],
['util/publish/pkgmogrify.py', 'pkgmogrify'],
['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,
"aix" : scripts_other_unix,
"unknown": scripts_sunos,
}
man1_files = [
'man/pkgdepend.1',
'man/pkgmerge.1',
'man/pkgmogrify.1',
]
man1m_files = [
'man/pkg.depotd.1m',
]
man5_files = [
]
packages = [
'pkg',
'pkg.actions',
'pkg.bundle',
'pkg.client',
'pkg.client.transport',
'pkg.file_layout',
'pkg.flavor',
'pkg.lint',
'pkg.portable',
'pkg.publish',
'pkg.server'
]
web_files = []
if not files:
continue
if f != "Makefile"
]))
zones_files = [
]
brand_files = [
'brand/common.ksh',
]
etcbrand_files = [
'brand/pkgrm.conf',
]
smf_app_files = [
'svc/pkg-mdns.xml',
]
smf_sys_files = [
]
resource_files = [
]
sysrepo_files = [
]
]
pspawn_srcs = [
]
elf_srcs = [
]
arch_srcs = [
]
_actions_srcs = [
]
solver_srcs = [
]
if osname == 'sunos':
include_dirs = [ 'modules' ]
# 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.
"""
for e in [".py", ".pyc"]:
if ostype == "posix":
else:
# make scripts executable
" -lsocket -lnsl"
#
# 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
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
args_config = ['./configure',
'--prefix=/usr',
'PYTHONPATH=""',
]
'DESTDIR=%s' % root_dir
]
if extra_env:
print "installing %s" % swname
'--root=%s' % root_dir,
'--install-lib=%s' % py_install_dir,
'--install-data=%s' % py_install_dir]
if env is None:
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:
res = ""
continue
# Assume it's a tuple of (filename, lineno, col, code)
raise DistutilsError(res)
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.
user_options = [
("archivedir=", 'a', "archive failed tests <dir>"),
("baselinefile=", 'b', "baseline file <file>"),
("coverage", "c", "collect code coverage data"),
("genbaseline", 'g', "generate test baseline"),
("only=", "o", "only <regex>"),
("parseable", 'p', "parseable output"),
("port=", "z", "lowest port to start a depot on"),
("timing", "t", "timing file <file>"),
("verbosemode", 'v', "run tests in verbose mode"),
("stoponerr", 'x', "stop when a baseline mismatch occurs"),
("debugoutput", 'd', "emit debugging output"),
("showonexpectedfail", 'f',
"show all failure info, even for expected fails"),
("startattest=", 's', "start at indicated test"),
]
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):
user_options = [
("pkg=", None, "Component package name")
]
description = "Print component information"
def initialize_options(self):
def finalize_options(self):
pkginfo = {
}
print "-D SOURCE_VER=%s -D PKG_VER=%s " \
# These are set to real values based on the platform, down below
compile_args = None
compile_args = [ "-O3" ]
link_args = None
ext_modules = [
'actions._actions',
),
'solver',
),
]
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,
'test': test_func,
'info': info_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),
(sysrepo_cache_dir, {})
]
# 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 = 'pkg',
version = '0.1',
ext_package = 'pkg',
)