From 6927c1b910a4ff76eab5fa1719341e621c271121 Mon Sep 17 00:00:00 2001 From: James Kasten Date: Tue, 20 Jan 2015 21:13:56 -0800 Subject: [PATCH] Add manual httpd_transform --- letsencrypt/client/apache/parser.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/letsencrypt/client/apache/parser.py b/letsencrypt/client/apache/parser.py index efff7eba8..9f8dc06d9 100644 --- a/letsencrypt/client/apache/parser.py +++ b/letsencrypt/client/apache/parser.py @@ -255,9 +255,32 @@ class ApacheParser(object): "/augeas/load/Httpd/incl [. ='%s']" % filepath) if not inc_test: # Load up files - self.aug.add_transform("Httpd.lns", [filepath]) + # This doesn't seem to work on TravisCI + # self.aug.add_transform("Httpd.lns", [filepath]) + self._add_httpd_transform(filepath) self.aug.load() + def _add_httpd_transform(self, incl): + """Add a transform to Augeas. + + This function will correctly add a transform to augeas + The existing augeas.add_transform in python doesn't seem to work for + Travis CI as it loads in libaugeas.so.0.10.0 + + :param str incl: filepath to include for transform + + """ + last_include = self.aug.match("/augeas/load/Httpd/incl [last()]") + if last_include: + # Insert a new node immediately after the last incl + self.aug.insert(last_include[0], "incl", False) + self.aug.set("/augeas/load/Httpd/incl[last()]", incl) + # On first use... must load lens and add file to incl + else: + # Augeas uses base 1 indexing... insert at beginning... + self.aug.set("/augeas/load/Httpd/lens", "Httpd.lns") + self.aug.set("/augeas/load/Httpd/incl", incl) + def standardize_excl(self): """Standardize the excl arguments for the Httpd lens in Augeas.