docs-xml: convert smb.conf.5 build to waf
authorAlexander Bokovoy <ab@samba.org>
Mon, 17 Sep 2012 10:07:26 +0000 (13:07 +0300)
committerAlexander Bokovoy <ab@samba.org>
Mon, 17 Sep 2012 12:18:31 +0000 (14:18 +0200)
smb.conf(5) is different from other manpages because before it is
built, it gets merged together from a number of smaller files, one
per parameter. So we first create a parameters.all.xml file that
references all these files and then include it into master smb.conf.5.xml

One small issue is how to handle generated files in WAF build
from xi:include perspective as the files are generated in bin/default/docs-xml
rather than in docs-xml. We solve this by further expanding use of XML catalogs
and rewriting virtual path http://www.samba.org/samba/smbdotconf/ to proper
location.

Both docs-xml autoconf and waf builds work correctly now.

Autobuild-User(master): Alexander Bokovoy <ab@samba.org>
Autobuild-Date(master): Mon Sep 17 14:18:31 CEST 2012 on sn-devel-104

buildtools/wafsamba/wafsamba.py
docs-xml/build/catalog.xml.in
docs-xml/manpages/smb.conf.5.xml
docs-xml/wscript_build
wscript_build

index 1f71bd39f3424a503383cef61465020ebc9a9a3f..50bd4fa6e2c52e158897c4d765f5f1e8c2b59c28 100644 (file)
@@ -789,14 +789,16 @@ def SAMBAMANPAGES(bld, manpages):
     '''build and install manual pages'''
     bld.env.SAMBA_EXPAND_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/expand-sambadoc.xsl'
     bld.env.SAMBA_MAN_XSL = bld.srcnode.abspath() + '/docs-xml/xslt/man.xsl'
-    os.environ["XML_CATALOG_FILES"] = 'file:///etc/xml/catalog file://' + bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml'
+    bld.env.SAMBA_CATALOGS = 'file:///etc/xml/catalog file://' + bld.srcnode.abspath() + '/bin/default/docs-xml/build/catalog.xml'
     for m in manpages.split():
         source = m + '.xml'
         bld.SAMBA_GENERATOR(m,
                             source=source,
                             target=m,
                             group='final',
-                            rule='${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC} && ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'
+                            rule='''export XML_CATALOG_FILES="${SAMBA_CATALOGS}"
+                                    ${XSLTPROC} --xinclude --stringparam noreference 0 -o ${TGT}.xml --nonet ${SAMBA_EXPAND_XSL} ${SRC}
+                                    ${XSLTPROC} --nonet -o ${TGT} ${SAMBA_MAN_XSL} ${TGT}.xml'''
                             )
         bld.INSTALL_FILES('${MANDIR}/man%s' % m[-1], m, flat=True)
 Build.BuildContext.SAMBAMANPAGES = SAMBAMANPAGES
index 4b99cf50d4dd082b39d58ef1f2f2a8ae4438924b..56d13a6cd3964645ad30ea8cce4d8f0a1fafb284 100644 (file)
@@ -6,9 +6,12 @@
 
     <rewriteURI
                        uriStartString="http://www.samba.org/samba/DTD/"
-                       rewritePrefix="file://@abs_top_builddir@/build/DTD/"/>
+                       rewritePrefix="file://@abs_top_srcdir@/build/DTD/"/>
 
     <rewriteURI
                        uriStartString="http://www.gnu.org/licenses/"
-                       rewritePrefix="file://@abs_top_builddir@/Samba3-ByExample/"/>
+                       rewritePrefix="file://@abs_top_srcdir@/Samba3-ByExample/"/>
+    <rewriteURI
+                       uriStartString="http://www.samba.org/samba/smbdotconf/"
+                       rewritePrefix="file://@abs_top_builddir@/smbdotconf/"/>
 </catalog>
index e09eee0d55f1ef11e6bd785ab02ca2bac1f08799..a73382f54a69eb2da4e7fc56ddcfd6abd574bfd6 100644 (file)
@@ -757,7 +757,10 @@ chmod 1770 /usr/local/samba/lib/usershares
        <title>EXPLANATION OF EACH PARAMETER</title>
        
        <samba:parameterlist>
-               <xi:include href="../smbdotconf/parameters.all.xml" parse="xml"/>
+               <!-- The URI below is resolved to local generated version of parameters.all.xml //-->
+               <!-- WAF build places it in bin/default/docs-xml/smbdotconf/parameters.all.xml //-->
+               <!-- and we redirect there via use of XML_CATALOG_FILES, see docs-xml/build/catalog.xml.in //-->
+               <xi:include href="http://www.samba.org/samba/smbdotconf/parameters.all.xml" parse="xml"/>
        </samba:parameterlist>
 
 </refsect1>
index 011854b2e610710db28d95c984d558da64c1ba9e..c5d5839d96a5389024028e293400a2a27e20b4c1 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-
+from samba_utils import save_file
 manpages='''
          manpages/eventlogadm.8
          manpages/findsmb.1
@@ -23,7 +23,6 @@ manpages='''
          manpages/rpcclient.1
          manpages/samba.7
          manpages/sharesec.1
-         manpages/smb.conf.5
          manpages/smbcacls.1
          manpages/smbclient.1
          manpages/smbcontrol.1
@@ -87,8 +86,30 @@ pam_winbind_manpages = '''
 
 krb5_locator_manpages = 'manpages/winbind_krb5_locator.7'
 
+def smbdotconf_generate_parameter_list(task):
+    parameter_all = task.outputs[0].bldpath(task.env)
+    articles = task.inputs
+
+    t = '<section xmlns:xi="http://www.w3.org/2003/XInclude">\n'
+    for article in articles:
+        t += "<xi:include href='file://" + article.abspath(task.env) + "' parse='xml'/>\n"
+    t += "</section>\n"
+    save_file(parameter_all, t , create_dir=True)
+    return 0
+
+def SMBDOTCONF_MANPAGE(bld, target):
+    ''' assemble and build smb.conf.5 manual page'''
+    articles = bld.path.ant_glob("smbdotconf/**/*.xml")
+    parameter_all = 'smbdotconf/parameters.all.xml'
+    bld.SAMBA_GENERATOR(parameter_all,
+                        source=articles,
+                        target=parameter_all,
+                        rule=smbdotconf_generate_parameter_list)
+    bld.SAMBAMANPAGES(target)
+
 if ('XSLTPROC_MANPAGES' in bld.env and bld.env['XSLTPROC_MANPAGES']):
 
+    SMBDOTCONF_MANPAGE(bld, 'manpages/smb.conf.5')
     bld.SAMBAMANPAGES(manpages)
 
     if bld.CONFIG_SET('WITH_PAM_MODULES') and bld.CONFIG_SET('HAVE_PAM_START'):
index 5434056fe1a42f40e1297da370b11e3d5760ceb5..0098036531ac9f01c4172612d0e94dab8296d1ce 100755 (executable)
@@ -144,7 +144,9 @@ bld.RECURSE('testsuite/headers')
 bld.SYMBOL_CHECK()
 bld.DUP_SYMBOL_CHECK()
 
-bld.env.ABS_TOP_BUILDDIR = bld.srcnode.abspath() + '/docs-xml'
+bld.env.ABS_TOP_SRCDIR = bld.srcnode.abspath() + '/docs-xml'
+bld.env.ABS_TOP_BUILDDIR = bld.srcnode.abspath() + '/bin/default/docs-xml'
 bld.CONFIGURE_FILE('docs-xml/build/catalog.xml',
-                   ABS_TOP_BUILDDIR = bld.env.ABS_TOP_BUILDDIR)
+                   ABS_TOP_BUILDDIR = bld.env.ABS_TOP_BUILDDIR,
+                   ABS_TOP_SRCDIR=bld.env.ABS_TOP_SRCDIR)
 bld.RECURSE('docs-xml')