--- /usr/lib/portage/bin/dohtml.old 2007-01-07 16:11:16.000000000 -0700 +++ /usr/lib/portage/bin/dohtml 2007-01-08 07:11:29.000000000 -0700 @@ -12,18 +12,18 @@ # # # Detailed usage: -# dohtml -# - will install the files in the list of files (space-separated list) into -# /usr/share/doc/${PF}/html, provided the file ends in .html, .png, .jpg -# or .css +# dohtml +# - will install the files in the list of files (space-separated list) into +# /usr/share/doc/${PF}/html, provided the file ends in .css, .gif, .htm, +# .html, .jpg, .js or .png # dohtml -r -# - will do as 'dohtml', but recurse into all directories, as long as the +# - will do as 'dohtml', but recurse into all directories, as long as the # directory name is not CVS # dohtml -A jpe,java [-r] # - will do as 'dohtml' but add .jpe,.java (default filter list is # added to your list) # dohtml -a png,gif,html,htm [-r] -# - will do as 'dohtml' but filter on .png,.gif,.html,.htm (default filter +# - will do as 'dohtml' but filter on .png,.gif,.html,.htm (default filter # list is ignored) # dohtml -x CVS,SCCS,RCS -r # - will do as 'dohtml -r', but ignore directories named CVS, SCCS, RCS @@ -34,6 +34,8 @@ import sys import types +from output import EOutput + def dodir(path): os.system("install -d '%s'" % path) @@ -48,21 +50,30 @@ if dirname: fullpath = dirname + "/" + fullpath if options.DOCDESTTREE: - destdir = options.D + "usr/share/doc/" + options.PF + "/" + options.DOCDESTTREE + "/" + options.doc_prefix + "/" + prefix + docdesttree = options.DOCDESTTREE else: - destdir = options.D + "usr/share/doc/" + options.PF + "/html/" + options.doc_prefix + "/" + prefix + docdesttree = 'html' + destdir = options.D + '/'.join (('usr/share/doc', + options.PF, + docdesttree, + options.doc_prefix, + prefix)) if os.path.isfile(fullpath): ext = os.path.splitext(basename)[1] if (len(ext) and ext[1:] in options.allowed_exts) or basename in options.allowed_files: dodir(destdir) dofile(fullpath, destdir + "/" + basename) - elif options.recurse and os.path.isdir(fullpath) and \ - basename not in options.disallowed_dirs: - for i in os.listdir(fullpath): - pfx = basename - if prefix: pfx = prefix + "/" + pfx - install(i, dirname, options, pfx) + elif os.path.isdir (fullpath) and basename not in options.disallowed_dirs: + if options.recurse: + for i in os.listdir(fullpath): + pfx = basename + if prefix: pfx = prefix + "/" + pfx + install(i, dirname, options, pfx) + else: + # bug #149745 + EOutput().ewarn ('QA Notice: directory %s given to dohtml without recursion (option -r)' % fullpath) + return False else: return False return True @@ -73,14 +84,14 @@ self.PF = "" self.D = "" self.DOCDESTTREE = "" - + if os.environ.has_key("PF"): self.PF = os.environ["PF"] if os.environ.has_key("D"): self.D = os.environ["D"] if os.environ.has_key("DOCDESTTREE"): self.DOCDESTTREE = os.environ["DOCDESTTREE"] - + self.allowed_exts = [ 'png', 'gif', 'html', 'htm', 'jpg', 'css', 'js' ] self.allowed_files = [] self.disallowed_dirs = [ 'CVS' ] @@ -92,14 +103,14 @@ opts = OptionsClass() print "dohtml [-a .foo,.bar] [-A .foo,.bar] [-f foo,bar] [-x foo,bar]" - print " [-r] [-V] [file ...]" + print " [-r] [-V] [file ...]" print print " -a Set the list of allowed to those that are specified." - print " Default:", string.join(opts.allowed_exts, ",") + print " Default:", string.join(opts.allowed_exts, ",") print " -A Extend the list of allowed file types." print " -f Set list of allowed extensionless file names." print " -x Set directories to be excluded from recursion." - print " Default:", string.join(opts.disallowed_dirs, ",") + print " Default:", string.join(opts.disallowed_dirs, ",") print " -r Install files and directories recursively." print " -V Be verbose." print @@ -107,7 +118,7 @@ def parse_args(): options = OptionsClass() args = [] - + x = 1 while x < len(sys.argv): arg = sys.argv[x] @@ -139,7 +150,7 @@ else: args.append(sys.argv[x]) x += 1 - + return (options, args) def main(): @@ -151,22 +162,17 @@ if options.verbose: print "Allowed extensions:", options.allowed_exts - print "Document prefix : '" + options.doc_prefix + "'" + print "Document prefix : '%s'" % options.doc_prefix print "Allowed files :", options.allowed_files success = True - for x in args: basename = os.path.basename(x) - dirname = os.path.dirname(x) - success = success and install(basename, dirname, options) - - if success: - retcode = 0 - else: - retcode = 1 - - sys.exit(retcode) + dirname = os.path.dirname(x) + # bug #149745, comment #1 + success &= install (basename, dirname, options) + + sys.exit (int (not success)) # 0 True, 1 False if __name__ == "__main__": main()