Added detection of docs and examples.
authorRob Cakebread <pythonhead@gentoo.org>
Thu, 31 Jul 2008 06:54:29 +0000 (06:54 +0000)
committerRob Cakebread <pythonhead@gentoo.org>
Thu, 31 Jul 2008 06:54:29 +0000 (06:54 +0000)
git-svn-id: http://g-pypi.googlecode.com/svn/trunk@12 118783bc-b352-0410-bbc3-0f610f6f7ae8

g_pypi/ebuild.py

index b2749d05d671dbfbbf1e51cab1c85f076aae77ba..428ae591ba1d88b05d052d7493e1bdc7ef3576c3 100755 (executable)
@@ -345,6 +345,44 @@ class Ebuild:
         if req not in self.requires:
             self.requires.append(req)
 
+    def get_docs(self):
+        """
+        Add src_install for installing docs and examples if found
+        and appropriate USE flags e.g. IUSE='doc examples' 
+        
+        """
+        doc_dirs = ['doc', 'docs']
+        example_dirs = ['example', 'examples', 'demo', 'demos']
+        have_docs = False
+        have_examples = False
+        src_install = ''
+        for ddir in doc_dirs:
+            if os.path.exists(os.path.join(self.unpacked_dir, ddir)):
+                have_docs = ddir
+                self.add_use("doc")
+                break
+
+        for edir in example_dirs:
+            if os.path.exists(os.path.join(self.unpacked_dir, edir)):
+                have_examples = edir
+                self.add_use("examples")
+                break
+
+        if have_docs or have_examples:
+            src_install += '\tdistutils_src_install\n'
+            if have_docs:
+                src_install += '\tif use doc; then\n'
+                src_install += '\t\tinsinto /usr/share/doc/"${PF}"\n'
+                src_install += '\t\tdodocs -r "${S}"/%s/*\n' % have_docs
+                src_install += '\tfi\n'
+            if have_examples:
+                src_install += '\tif use examples; then\n'
+                src_install += '\t\tinsinto /usr/share/doc/"${PF}"/examples\n'
+                src_install += '\t\tdoins -r "${S}"/%s/*\n' % have_examples
+                src_install += '\tfi'
+        return src_install
+
+
     def get_src_test(self):
         """Create src_test if tests detected"""
         nose_test = '''\tPYTHONPATH=. "${python}" setup.py nosetests || die "tests failed"'''
@@ -395,6 +433,7 @@ class Ebuild:
             #    not self.options.subversion:
             self.post_unpack() 
             functions['src_test'] = self.get_src_test() 
+            functions['src_install'] = self.get_docs()
         # *_f variables are formatted text ready for ebuild
         self.vars['depend_f'] = format_depend(self.vars['depend'])
         self.vars['rdepend_f'] = format_depend(self.vars['rdepend'])