Gentoo Archives: gentoo-commits

From: "Paweł Hajdan" <phajdan.jr@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/chromium-tools:master commit in: scripts/, /
Date: Wed, 27 Apr 2011 09:57:27
Message-Id: afa74fe53dfb6deacd24a9a91105882dfb5bec6b.phajdan.jr@gentoo
1 commit: afa74fe53dfb6deacd24a9a91105882dfb5bec6b
2 Author: Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
3 AuthorDate: Wed Apr 27 09:27:29 2011 +0000
4 Commit: Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
5 CommitDate: Wed Apr 27 09:30:57 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/chromium-tools.git;a=commit;h=afa74fe5
7
8 Clean up:
9
10 - remove switchable subversion support
11 - remove unused v8-extract-version
12 - take advantage of python-2.7 when it leads to simpler code
13 - simplify setup.py
14 - remove chromium_tools.py module (only one user now)
15
16 ---
17 chromium_tools.py | 28 ----------------------------
18 scripts/v8-create-tarball | 30 +++++++++++++++++++++++++++---
19 scripts/v8-extract-version | 11 -----------
20 setup.py | 43 ++++---------------------------------------
21 4 files changed, 31 insertions(+), 81 deletions(-)
22
23 diff --git a/chromium_tools.py b/chromium_tools.py
24 deleted file mode 100644
25 index 9fbf9f9..0000000
26 --- a/chromium_tools.py
27 +++ /dev/null
28 @@ -1,28 +0,0 @@
29 -"""Common utilities for chromium-tools scripts."""
30 -
31 -import re
32 -
33 -_V8_MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)")
34 -_V8_MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)")
35 -_V8_BUILD_NUMBER_PATTERN = re.compile(r"#define\s+BUILD_NUMBER\s+(.*)")
36 -_V8_PATCH_LEVEL_PATTERN = re.compile(r"#define\s+PATCH_LEVEL\s+(.*)")
37 -
38 -_V8_PATTERNS = [
39 - _V8_MAJOR_VERSION_PATTERN,
40 - _V8_MINOR_VERSION_PATTERN,
41 - _V8_BUILD_NUMBER_PATTERN,
42 - _V8_PATCH_LEVEL_PATTERN]
43 -
44 -def v8_extract_version(version_contents):
45 - """
46 - Returns version number as string based on the string
47 - contents of version.cc file.
48 - """
49 - version_components = []
50 - for pattern in _V8_PATTERNS:
51 - version_components.append(pattern.search(version_contents).group(1).strip())
52 -
53 - if version_components[len(version_components) - 1] == '0':
54 - version_components.pop()
55 -
56 - return '.'.join(version_components)
57
58 diff --git a/scripts/v8-create-tarball b/scripts/v8-create-tarball
59 index 8306819..0f7f6bb 100755
60 --- a/scripts/v8-create-tarball
61 +++ b/scripts/v8-create-tarball
62 @@ -1,5 +1,5 @@
63 #!/usr/bin/python2
64 -# Copyright 2010 Gentoo Foundation
65 +# Copyright 2011 Gentoo Foundation
66 # Distributed under the terms of the GNU General Public License v2
67
68 """Creates a tarball containing V8 sources based on an SVN tag."""
69 @@ -7,11 +7,35 @@
70 import optparse
71 import os.path
72 import pysvn
73 +import re
74 import shutil
75 import tarfile
76 import tempfile
77
78 -import chromium_tools
79 +_V8_MAJOR_VERSION_PATTERN = re.compile(r"#define\s+MAJOR_VERSION\s+(.*)")
80 +_V8_MINOR_VERSION_PATTERN = re.compile(r"#define\s+MINOR_VERSION\s+(.*)")
81 +_V8_BUILD_NUMBER_PATTERN = re.compile(r"#define\s+BUILD_NUMBER\s+(.*)")
82 +_V8_PATCH_LEVEL_PATTERN = re.compile(r"#define\s+PATCH_LEVEL\s+(.*)")
83 +
84 +_V8_PATTERNS = [
85 + _V8_MAJOR_VERSION_PATTERN,
86 + _V8_MINOR_VERSION_PATTERN,
87 + _V8_BUILD_NUMBER_PATTERN,
88 + _V8_PATCH_LEVEL_PATTERN]
89 +
90 +def v8_extract_version(version_contents):
91 + """
92 + Returns version number as string based on the string
93 + contents of version.cc file.
94 + """
95 + version_components = []
96 + for pattern in _V8_PATTERNS:
97 + version_components.append(pattern.search(version_contents).group(1).strip())
98 +
99 + if version_components[len(version_components) - 1] == '0':
100 + version_components.pop()
101 +
102 + return '.'.join(version_components)
103
104 parser = optparse.OptionParser(usage="%prog <v8-version>")
105 (options, args) = parser.parse_args()
106 @@ -32,7 +56,7 @@ try:
107 svn_client.checkout(checkout_url, checkout_dir)
108
109 version_contents = open(os.path.join(checkout_dir, 'src', 'version.cc')).read()
110 - actual_version = chromium_tools.v8_extract_version(version_contents)
111 + actual_version = v8_extract_version(version_contents)
112 if actual_version != args[0]:
113 print 'Version info inside version.cc does not match!'
114 print 'Expected %s, got %s. Exiting' % (args[0], actual_version)
115
116 diff --git a/scripts/v8-extract-version b/scripts/v8-extract-version
117 deleted file mode 100755
118 index 277df29..0000000
119 --- a/scripts/v8-extract-version
120 +++ /dev/null
121 @@ -1,11 +0,0 @@
122 -#!/usr/bin/python2
123 -# Copyright 2010 Gentoo Foundation
124 -# Distributed under the terms of the GNU General Public License v2
125 -
126 -"""Extracts V8 version number based on given version.cc file."""
127 -
128 -import sys
129 -
130 -import chromium_tools
131 -
132 -print chromium_tools.v8_extract_version(open(sys.argv[1]).read())
133
134 diff --git a/setup.py b/setup.py
135 index 09abc3a..0f3351b 100644
136 --- a/setup.py
137 +++ b/setup.py
138 @@ -12,10 +12,7 @@ def get_version_from_file():
139 return open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'VERSION')).read()
140
141 def get_version_from_git():
142 - # TODO: replace with check_output when python-2.7 is stable.
143 - output = subprocess.Popen(
144 - ['git', 'describe'],
145 - stdout=subprocess.PIPE).communicate()[0]
146 + output = subprocess.check_output(['git', 'describe'])
147 chunks = output.split('-')
148 return '.'.join(chunks[:2])
149
150 @@ -25,23 +22,6 @@ def get_version():
151 except IOError:
152 return get_version_from_git()
153
154 -def get_option(args, name, default=False):
155 - disable_arg = "--disable-" + name
156 - enable_arg = "--enable-" + name
157 - if disable_arg in args and enable_arg in args:
158 - raise DistutilsArgError(
159 - "Conflicting flags: %s, %s" % (disable_arg, enable_arg))
160 -
161 - if disable_arg in args:
162 - args.remove(disable_arg)
163 - return False
164 -
165 - if enable_arg in args:
166 - args.remove(enable_arg)
167 - return True
168 -
169 - return default
170 -
171 class my_sdist(sdist):
172 def make_release_tree(self, base_dir, files):
173 sdist.make_release_tree(self, base_dir, files)
174 @@ -55,25 +35,10 @@ class my_install_data(install_data):
175 os.path.join('..', 'libexec', 'chromium-depot-tool'),
176 os.path.join(self.install_dir, 'bin', tool))
177
178 -scripts = ["scripts/v8-extract-version"]
179 -data_files = []
180 -
181 -cmdclass = {'sdist': my_sdist}
182 -
183 -args = sys.argv[1:]
184 -
185 -enable_subversion = get_option(args, 'subversion', default=True)
186 -if enable_subversion:
187 - scripts += ["scripts/v8-create-tarball"]
188 - data_files += [["libexec", ["scripts/chromium-depot-tool"]]]
189 - cmdclass['install_data'] = my_install_data
190 -
191 setup(
192 name="chromium-tools",
193 version=get_version(),
194 - py_modules=["chromium_tools"],
195 - scripts=scripts,
196 - data_files=data_files,
197 - cmdclass=cmdclass,
198 - script_args=args
199 + scripts=["scripts/v8-create-tarball"],
200 + data_files=[["libexec", ["scripts/chromium-depot-tool"]]],
201 + cmdclass={'install_data': my_install_data, 'sdist': my_sdist},
202 )