author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2013-04-17 15:45:39 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2013-04-17 15:45:39 (UTC) |
commit | 48c9280c9a255f2a85ad5729830df884e64a9c5d (patch) (unidiff) | |
tree | 14787438153cdc0b4b445c66f046bccf3dd99ee2 /scripts | |
parent | 4ce8041b11afc7f02c678565e0e96e59a5a557b6 (diff) | |
download | clipperz-48c9280c9a255f2a85ad5729830df884e64a9c5d.zip clipperz-48c9280c9a255f2a85ad5729830df884e64a9c5d.tar.gz clipperz-48c9280c9a255f2a85ad5729830df884e64a9c5d.tar.bz2 |
Updated build script to handle 'checksum' target
The build script can now be invoked, for example, with the following options:
> ./scripts/build checksum --frontend beta gamma
-rwxr-xr-x[-rw-r--r--] | scripts/builder/backendBuilder.py | 2 | ||||
-rwxr-xr-x | scripts/builder/backends/checksumBuilder.py | 50 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/builder/backends/devBuilder.py | 8 | ||||
-rwxr-xr-x | scripts/builder/main.py | 7 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/builder/repository.py | 0 |
5 files changed, 58 insertions, 9 deletions
diff --git a/scripts/builder/backendBuilder.py b/scripts/builder/backendBuilder.py index 20b4bd0..b4ee990 100644..100755 --- a/scripts/builder/backendBuilder.py +++ b/scripts/builder/backendBuilder.py | |||
@@ -82,15 +82,17 @@ class BackendBuilder(object): | |||
82 | 82 | ||
83 | 83 | ||
84 | def logChecksums (self, content, message): | 84 | def logChecksums (self, content, message): |
85 | md5Digest = self.formatMAC(hashlib.md5(content.encode('utf-8')).hexdigest()) | 85 | md5Digest = self.formatMAC(hashlib.md5(content.encode('utf-8')).hexdigest()) |
86 | shaDigest = self.formatMAC(hashlib.sha1(content.encode('utf-8')).hexdigest()) | 86 | shaDigest = self.formatMAC(hashlib.sha1(content.encode('utf-8')).hexdigest()) |
87 | sha256Digest= self.formatMAC(hashlib.sha256(content.encode('utf-8')).hexdigest()) | 87 | sha256Digest= self.formatMAC(hashlib.sha256(content.encode('utf-8')).hexdigest()) |
88 | print "-----" | ||
88 | print message + ": " + md5Digest + " (md5)" | 89 | print message + ": " + md5Digest + " (md5)" |
89 | print message + ": " + shaDigest + " (sha1)" | 90 | print message + ": " + shaDigest + " (sha1)" |
90 | print message + ": " + sha256Digest + " (sha256)" | 91 | print message + ": " + sha256Digest + " (sha256)" |
92 | print "=====" | ||
91 | 93 | ||
92 | 94 | ||
93 | def shouldCompileCode (self): | 95 | def shouldCompileCode (self): |
94 | return ('debug' in self.versions) or ('install' in self.versions) | 96 | return ('debug' in self.versions) or ('install' in self.versions) |
95 | 97 | ||
96 | 98 | ||
diff --git a/scripts/builder/backends/checksumBuilder.py b/scripts/builder/backends/checksumBuilder.py new file mode 100755 index 0000000..5f44c8a --- a/dev/null +++ b/scripts/builder/backends/checksumBuilder.py | |||
@@ -0,0 +1,50 @@ | |||
1 | #!/usr/bin/env python | ||
2 | # -*- coding: UTF-8 -*- | ||
3 | |||
4 | import os | ||
5 | import shutil | ||
6 | import subprocess | ||
7 | import main | ||
8 | |||
9 | from backendBuilder import BackendBuilder | ||
10 | |||
11 | class ChecksumBuilder(BackendBuilder): | ||
12 | |||
13 | def name(self): | ||
14 | return "Checksum builder" | ||
15 | |||
16 | |||
17 | def relativePath(self): | ||
18 | return 'checksum' | ||
19 | |||
20 | |||
21 | def compileCode (self): | ||
22 | pass | ||
23 | |||
24 | |||
25 | def createPackage (self): | ||
26 | src = self.tempFolder() | ||
27 | dst = self.targetFolder() | ||
28 | |||
29 | shutil.copytree(src, dst) | ||
30 | |||
31 | |||
32 | def run (self): | ||
33 | print self.name() + " - RUN (checksum)" | ||
34 | |||
35 | for frontend in self.frontends: | ||
36 | if (frontend.module == frontend.submodule): | ||
37 | submoduleExtension = '' | ||
38 | else: | ||
39 | submoduleExtension = '.' + frontend.submodule | ||
40 | |||
41 | main.createFolder(os.path.join(self.frontEndTempFolder(), frontend.module)) | ||
42 | |||
43 | index = self.configureIndexContent(frontend.assemble()) | ||
44 | self.writeToFolder(self.frontEndTempFolder(), os.path.join(frontend.module, 'index' + submoduleExtension + '.html'), index) | ||
45 | self.logChecksums(index, "[" + self.name() + " - " + frontend.module + "] index" + submoduleExtension + ".html checksum") | ||
46 | print "" | ||
47 | |||
48 | self.createPackage() | ||
49 | |||
50 | |||
diff --git a/scripts/builder/backends/devBuilder.py b/scripts/builder/backends/devBuilder.py index 671765e..354e014 100644..100755 --- a/scripts/builder/backends/devBuilder.py +++ b/scripts/builder/backends/devBuilder.py | |||
@@ -15,20 +15,12 @@ class DevBuilder(BackendBuilder): | |||
15 | 15 | ||
16 | 16 | ||
17 | def relativePath(self): | 17 | def relativePath(self): |
18 | return 'dev' | 18 | return 'dev' |
19 | 19 | ||
20 | 20 | ||
21 | #def frontEndTempFolder (self): | ||
22 | # return os.path.join(self.tempFolder(), 'src', 'main', 'webapp') | ||
23 | |||
24 | |||
25 | #def targetFolder (self): | ||
26 | # return self.projectTargetDir | ||
27 | |||
28 | |||
29 | def compileCode (self): | 21 | def compileCode (self): |
30 | pass | 22 | pass |
31 | 23 | ||
32 | 24 | ||
33 | def createPackage (self): | 25 | def createPackage (self): |
34 | src = self.tempFolder() | 26 | src = self.tempFolder() |
diff --git a/scripts/builder/main.py b/scripts/builder/main.py index b9fe04a..ecdbf6a 100755 --- a/scripts/builder/main.py +++ b/scripts/builder/main.py | |||
@@ -149,13 +149,13 @@ def main (): | |||
149 | sys.path.append(os.path.join(scriptDir(), 'backends')) | 149 | sys.path.append(os.path.join(scriptDir(), 'backends')) |
150 | sys.path.append(os.path.join(scriptDir(), 'frontends')) | 150 | sys.path.append(os.path.join(scriptDir(), 'frontends')) |
151 | currentRepository = repository.repositoryWithPath(projectBaseDir()) | 151 | currentRepository = repository.repositoryWithPath(projectBaseDir()) |
152 | 152 | ||
153 | clean() | 153 | clean() |
154 | versions = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters)) | 154 | versions = list(itertools.takewhile(lambda x: not x.startswith('--'), parameters)) |
155 | settings['versions'] = versions; #['debug', 'install', 'development'] | 155 | settings['versions'] = versions; #['debug', 'install', 'development', 'checksum'] |
156 | parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) | 156 | parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) |
157 | 157 | ||
158 | if len(parameters) > 0: | 158 | if len(parameters) > 0: |
159 | parameter = parameters.popleft() | 159 | parameter = parameters.popleft() |
160 | if parameter == "--ALL": | 160 | if parameter == "--ALL": |
161 | settings['frontends'] = allFrontends() | 161 | settings['frontends'] = allFrontends() |
@@ -172,12 +172,17 @@ def main (): | |||
172 | parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) | 172 | parameters = deque(itertools.dropwhile(lambda x: not x.startswith('--'), parameters)) |
173 | if parameters: | 173 | if parameters: |
174 | parameter = parameters.popleft() | 174 | parameter = parameters.popleft() |
175 | else: | 175 | else: |
176 | parameter = None | 176 | parameter = None |
177 | 177 | ||
178 | if 'checksum' in settings['versions']: | ||
179 | if not 'backends' in settings: | ||
180 | settings['backends'] = [] | ||
181 | settings['backends'].append('checksum') | ||
182 | |||
178 | if (not settings.has_key('versions')): | 183 | if (not settings.has_key('versions')): |
179 | usage("missing 'versions'") | 184 | usage("missing 'versions'") |
180 | if (not settings.has_key('frontends')): | 185 | if (not settings.has_key('frontends')): |
181 | usage("missing 'frontends'") | 186 | usage("missing 'frontends'") |
182 | if (not settings.has_key('backends')): | 187 | if (not settings.has_key('backends')): |
183 | usage("missing 'backends'") | 188 | usage("missing 'backends'") |
diff --git a/scripts/builder/repository.py b/scripts/builder/repository.py index 2d4a12b..2d4a12b 100644..100755 --- a/scripts/builder/repository.py +++ b/scripts/builder/repository.py | |||