aboutsummaryrefslogtreecommitdiff
blob: ff50b37bdcbda37c3199a518eea8d26aced8ca7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env python

#######################################
package_version = '2.2.0'
#######################################


from distutils.cmd import Command
from distutils.command.build import build
from distutils.command.install import install
from distutils.command.sdist import sdist


import fileinput
import os
import subprocess
import sys
import tempfile
import unittest


class jc_build(build):
	def run(self):
		build.run(self)

		for base, dirs, files in os.walk(self.build_base):
			for f in files:
				for line in fileinput.input(os.path.join(base, f),inplace=True):
					sys.stdout.write(line.replace('@PACKAGE_VERSION@', package_version))
				for line in fileinput.input(os.path.join(base, f),inplace=True):
					sys.stdout.write(line.replace('@GENTOO_PORTAGE_EPREFIX@', eprefix))


class jc_test(Command):
	user_options = []

	def initialize_options(self):
		self.build_base = None
		self.build_lib = None

	def finalize_options(self):
		self.set_undefined_options('build', ('build_lib', 'build_lib'))

	def run(self):
		self.run_command('build')

		sys.path.insert(0, 'tests')
		sys.path.insert(0, self.build_lib)

		import testsuite
		suite = unittest.defaultTestLoader.loadTestsFromNames(testsuite.__all__, testsuite)

		result = unittest.TextTestRunner().run(suite)
		sys.exit(not result.wasSuccessful())


class jc_install(install):
	"""
	Generate and install the jdk defaults configuration file.

	For the most part useless, wasn't updated in a long time either and doesn't
	reflect reality anymore. Doing it here is at least a lot more maintainable
	then a couple dozen files where it was defined before.
	Also what should be default is a downstream decision and java-config
	shouldn't have any business here. Still keeping it for the time being.
	"""

	def run(self):
		install.run(self)

		arch = os.getenv('ARCH', 'unknown')
		defaults = '*= icedtea'
		if arch in ['amd64', 'x86']:
			defaults = '*= icedtea6 icedtea6-bin icedtea7 icedtea7-bin'
		elif arch in ['ppc-macos', 'x64-macos', 'x86-macos']:
			defaults = '*= apple-jdk-bin'
		elif arch in ['ppc', 'ppc64', 'ppc-linux', 'ppc-aix']:
			defaults = '*= ibm-jdk-bin'
		elif arch in ['arm']:
			defaults = '*= icedtea-7 icedtea-6 icedtea-bin-7 icedtea-bin-6'

		with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:
			f.write("# Supported JDKs\n")
			f.write(defaults + "\n")
		confdir = self.root + '/usr/share/java-config-2/config/'
		self.mkpath(confdir)
		self.copy_file(f.name, confdir + 'jdk-defaults.conf', preserve_mode=0)
		os.remove(f.name)

from distutils.core import setup

eprefix = os.getenv('EPREFIX', '')

setup(
	cmdclass = {
		'build' : jc_build,
		'test' : jc_test,
		'install' : jc_install,
	},
	name = 'java-config',
	version = package_version,
	description = 'java enviroment configuration tool',
	long_description = \
	"""
		java-config is a tool for configuring various enviroment
		variables and configuration files involved in the java
		environment for Gentoo Linux.
	""",
	maintainer = 'Gentoo Java Team',
	maintainer_email = 'java@gentoo.org',
	url = 'http://www.gentoo.org',
	packages = ['java_config_2'],
	package_dir = { 'java_config_2' : 'src/java_config_2' },
	scripts = ['src/java-config-2','src/depend-java-query','src/gjl'],
	data_files = [
		(eprefix + '/usr/share/java-config-2/launcher', ['src/launcher.bash']),
		(eprefix + '/usr/share/man/man1/', ['man/java-config-2.1']),
		(eprefix + '/etc/java-config-2/', ['config/virtuals']),
	]
)

# vim: noet:ts=4: