Mercurial > treepkg
comparison recipes/gnupg/gnupg2.py @ 141:2c942b75b98b
Extend the gnupg2 recipe so that it extracts the PKITS log.
author | Bernhard Herzog <bh@intevation.de> |
---|---|
date | Mon, 02 Jun 2008 15:58:13 +0000 |
parents | 605f6784aae7 |
children | 27e78096a3fe |
comparison
equal
deleted
inserted
replaced
140:0da76aee8035 | 141:2c942b75b98b |
---|---|
5 # This program is free software under the GPL (>=v2) | 5 # This program is free software under the GPL (>=v2) |
6 # Read the file COPYING coming with the software for details. | 6 # Read the file COPYING coming with the software for details. |
7 | 7 |
8 """Recipe to build gnugp2 from SVN""" | 8 """Recipe to build gnugp2 from SVN""" |
9 | 9 |
10 import os | |
11 import shutil | |
12 import logging | |
13 import re | |
14 | |
15 import treepkg.packager | |
16 import treepkg.util | |
17 | |
10 import base | 18 import base |
11 base.define_gnupg_packager("gnupg2") | 19 base.define_gnupg_packager("gnupg2") |
20 | |
21 | |
22 class BinaryPackager(treepkg.packager.BinaryPackager): | |
23 | |
24 pkits_log = treepkg.packager._fromparent("pkits_log") | |
25 | |
26 def package(self): | |
27 self.status.creating_binary_package() | |
28 treepkg.util.ensure_directory(self.binary_dir) | |
29 self.create_pkits_workdir() | |
30 try: | |
31 logging.info("Building binary package; logging to %r", self.logfile) | |
32 extra_env=dict(GNUPG_PKITS_DIRECTORY=self.pkits_workdir) | |
33 self.track.builder.build(self.dsc_file, self.binary_dir, self.logfile, | |
34 bindmounts=[self.pkits_workdir], | |
35 extra_packages=["bzip2"], | |
36 extra_env=extra_env) | |
37 self.extract_pkits_log() | |
38 finally: | |
39 self.remove_pkits_workdir() | |
40 self.status.binary_package_created() | |
41 | |
42 def create_pkits_workdir(self): | |
43 self.pkits_workdir = os.path.join(self.parent.base_dir, "pkits-work") | |
44 treepkg.util.ensure_directory(self.pkits_workdir) | |
45 shutil.copy(os.path.join(self.track.checkout_dir, "tests", "pkits", | |
46 "PKITS_data.tar.bz2"), | |
47 self.pkits_workdir) | |
48 | |
49 def remove_pkits_workdir(self): | |
50 shutil.rmtree(self.pkits_workdir) | |
51 | |
52 def extract_pkits_log(self): | |
53 testlog = None | |
54 for line in open(self.logfile): | |
55 if re.match("--------- END PKITS LOG ---------", line): | |
56 break | |
57 elif re.match("-------- BEGIN PKITS LOG --------", line): | |
58 testlog = [] | |
59 elif testlog is not None and line[:1] in "0123456789": | |
60 testlog.append(line) | |
61 else: | |
62 logging.info("Could not find PKITS LOG in %s", self.logfile) | |
63 return | |
64 treepkg.util.ensure_directory(os.path.dirname(self.pkits_log)) | |
65 outfile = open(self.pkits_log, "w") | |
66 outfile.writelines(testlog) | |
67 outfile.close() | |
68 | |
69 | |
70 class RevisionPackager(treepkg.packager.RevisionPackager): | |
71 | |
72 source_packager_cls = SourcePackager | |
73 binary_packager_cls = BinaryPackager | |
74 | |
75 pkits_log = treepkg.packager._filenameproperty("pkits_log.txt", | |
76 dir_attr="log_dir") | |
77 | |
78 def list_log_files(self): | |
79 files = super(RevisionPackager, self).list_log_files() | |
80 if os.path.exists(self.pkits_log): | |
81 files.append(("PKITS log", self.pkits_log)) | |
82 return files |