blob: 8c7bb361f97267fe136f0b6f42101524c9f7d6d5 (
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
|
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
class Recipe(recipe.Recipe):
name = 'docbook-xsl'
version = '1.79.1'
licenses = [{License.BSD_like: ['COPYING']}]
btype = BuildType.CUSTOM
stype = SourceType.TARBALL
url = 'sf://docbook/%(name)s-%(version)s.tar.bz2'
tarball_checksum = '725f452e12b296956e8bfb876ccece71eeecdd14b94f667f3ed9091761a4a968'
files_catalog = ['etc/catalog.xml']
async def install(self):
etc_path = os.path.join(self.config.prefix, 'etc')
if not os.path.exists(etc_path):
os.makedirs(etc_path)
etc_catalog_path = os.path.join(etc_path, 'catalog.xml')
new_catalog_path = os.path.join(self.build_dir, 'catalog.xml')
def read_catalog(path):
try:
with open(path, 'r') as f:
lines= f.readlines()
if len(lines) != 0:
lines = lines[2:-1]
except Exception as ex:
lines = ['']
return ''.join(lines)
etc_catalog_lines = read_catalog(etc_catalog_path)
new_catalog_lines = read_catalog(new_catalog_path)
if new_catalog_lines in etc_catalog_lines:
return
with open(etc_catalog_path, 'w') as f:
f.write("<?xml version='1.0'?>\n")
f.write('<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">\n')
f.write(etc_catalog_lines)
f.write("\n")
f.write(new_catalog_lines)
f.write("</catalog>")
|