Skip to content

Commit

Permalink
Large overall improvement to docbook build scripts.
Browse files Browse the repository at this point in the history
-a, --all, --html, --pdf options allow selecting what to build
-d, --delete allow specifying to delete install dir before rebuilding
-f, --force allows repo script to ignore last-commit timestamps
  • Loading branch information
amyreese committed Nov 18, 2008
1 parent 39e1efa commit c605d53
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 15 deletions.
59 changes: 51 additions & 8 deletions docbook-manual-repo.py
Expand Up @@ -6,6 +6,7 @@
import os, sys
from os import path

import getopt
import re

# Absolute path to docbook-manual.py
Expand All @@ -18,8 +19,19 @@
'-1\.1\.[\w\d]+'
])

# Script options
options = "hfda"
long_options = [ "help", "force", "delete", "all", "pdf", "html" ]

def usage():
print '''Usage: docbook-manual-repo /path/to/mantisbt/repo /path/to/install [<lang> ...]'''
print '''Usage: docbook-manual-repo /path/to/mantisbt/repo /path/to/install [<lang> ...]
Options: -h | --help Print this usage message
-f | --force Ignore timestamps and force building
-d | --delete Delete install directories before building
--html Build HTML manual
--pdf Build PDF manual
-a | --all Build all manual types'''
#end usage()

def ignore( ref ):
'''Decide which refs to ignore based on regexen listed in 'ignorelist'.
Expand All @@ -33,16 +45,46 @@ def ignore( ref ):
#end ignore()

def main():
if len(sys.argv) < 3:
try:
opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options)
except getopt.GetoptError, err:
print str(err)
usage()
sys.exit(2)

force = False
pass_opts = ""

for opt, val in opts:
if opt in ("-h", "--help"):
usage()
sys.exit(0)

elif opt in ("-f", "--force"):
force = True

elif opt in ("-d", "--delete"):
pass_opts += " -d"

elif opt in ("-a", "--all"):
pass_opts += " -a"

elif opt == "--html":
pass_opts += " --html"

elif opt == "--pdf":
pass_opts += " --pdf"

if len(args) < 2:
usage()
sys.exit(1)

repo = sys.argv[1]
installroot = sys.argv[2]
repo = args[0]
installroot = args[1]
languages = []

if len(sys.argv) > 3:
languages = sys.argv[3:]
if len(sys.argv) > 2:
languages = args[2:]

# Update repo from default remote
os.chdir(repo)
Expand Down Expand Up @@ -74,8 +116,9 @@ def main():
lastbuild = f.read()
f.close()

if lastchange > lastbuild:
buildcommand = '%s %s %s %s'%(manualscript, path.abspath('docbook'), manualpath, ' '.join(languages))
if lastchange > lastbuild or force:
buildcommand = '%s %s %s %s %s'%(manualscript, pass_opts, path.abspath('docbook'), manualpath, ' '.join(languages))
print "Calling: " + buildcommand
if(os.system(buildcommand)):
print 'here'

Expand Down
62 changes: 55 additions & 7 deletions docbook-manual.py
Expand Up @@ -3,23 +3,70 @@
import os, sys
from os import path

import getopt

# Script options
options = "hda"
long_options = [ "help", "delete", "all", "pdf", "html" ]

def usage():
print '''Usage: docbook-manual /path/to/mantisbt/docbook /path/to/install [<lang> ...]'''
print '''Usage: docbook-manual /path/to/mantisbt/docbook /path/to/install [<lang> ...]
Options: -h | --help Print this usage message
-d | --delete Delete install directory before building
--html Build HTML manual
--pdf Build PDF manual
-a | --all Build all manual types'''
#end usage()

def main():
if len(sys.argv) < 3:
try:
opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options)
except getopt.GetoptError, err:
print str(err)
usage()
sys.exit(2)

delete = False
types = "html pdf"

for opt, val in opts:
if opt in ("-h", "--help"):
usage()
sys.exit(0)

elif opt in ("-d", "--delete"):
delete = True

elif opt in ("-a", "--all"):
types = "html html_onefile html.tar.gz text pdf ps"

elif opt == "--html":
types = "html html_onefile html.tar.gz"

elif opt == "--pdf":
types = "pdf"

if len(args) < 2:
usage()
sys.exit(1)

docroot = sys.argv[1]
installroot = sys.argv[2]
docroot = args[0]
installroot = args[1]
languages = []

if len(sys.argv) > 3:
languages = sys.argv[3:]
if len(sys.argv) > 2:
languages = args[2:]

os.chdir( docroot )

if delete and installroot != "/" and path.isdir( installroot ):
print "Deleting install directory " + installroot
for root, dirs, files in os.walk( installroot, topdown=False ):
for name in files:
os.remove( path.join( root, name ) )
for name in dirs:
os.rmdir( path.join( root, name ) )

for dir in os.listdir( docroot ):
if dir == '.svn' or dir == 'template':
continue
Expand All @@ -34,10 +81,11 @@ def main():
for lang in langs:
builddir = path.join( docroot, dir, lang )
installdir = path.join( installroot, lang )

if path.isdir( builddir ):
print "Building manual in " + builddir
os.chdir( builddir )
os.system( 'make clean html 2>&1 && make INSTALL_DIR=' + installdir + ' install 2>&1' )
os.system( 'make clean %s 2>&1 && make INSTALL_DIR=%s install 2>&1'%(types, installdir) )
#end main

if __name__ == '__main__':
Expand Down

0 comments on commit c605d53

Please sign in to comment.