# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python class Recipe(recipe.Recipe): name = 'docbook-xsl' version = '1.76.1' licenses = [License.BSD_like] btype = BuildType.CUSTOM stype = SourceType.TARBALL url = 'http://sourceforge.net/projects/docbook/files/docbook-xsl/1.78.1/docbook-xsl-1.78.1.tar.bz2' files_catalog = ['etc/catalog.xml'] 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, 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("\n") f.write('\n') f.write(etc_catalog_lines) f.write("\n") f.write(new_catalog_lines) f.write("")