From: Wayne Davison Date: Sun, 14 Jun 2020 04:10:13 +0000 (-0700) Subject: More release improvements. X-Git-Tag: v3.2.0pre2~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ba6ce1b67bd6d617c7fb59924a1a4c3c4c79069;p=thirdparty%2Frsync.git More release improvements. --- diff --git a/packaging/md2html b/packaging/md2html new file mode 100755 index 00000000..f0f61cdc --- /dev/null +++ b/packaging/md2html @@ -0,0 +1,87 @@ +#!/usr/bin/python3 + +# Copyright (C) 2020 Wayne Davison +# +# This program is freely redistributable. + +import re, argparse + +HTML_START = """\ + +%s + + + +""" + +HTML_END = """\ + +""" + +md_parser = None + +def main(): + for mdfn in args.mdfiles: + title = re.sub(r'.*/', '', mdfn).replace('.md', '') + htfn = mdfn.replace('.md', '.html') + + print("Parsing", mdfn, '->', htfn) + + with open(mdfn, 'r', encoding='utf-8') as fh: + txt = fh.read() + + html = md_parser(txt) + + with open(htfn, 'w', encoding='utf-8') as fh: + fh.write(HTML_START % title) + fh.write(html) + fh.write(HTML_END) + + +def html_via_cmarkgfm(txt): + return cmarkgfm.markdown_to_html(txt) + + +def html_via_commonmark(txt): + return commonmark.HtmlRenderer().render(commonmark.Parser().parse(txt)) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Output html for md pages.', add_help=False) + parser.add_argument("--help", "-h", action="help", help="Output this help message and exit.") + parser.add_argument("mdfiles", nargs='+', help="The .md files to turn into .html files.") + args = parser.parse_args() + + try: + import cmarkgfm + md_parser = html_via_cmarkgfm + except: + try: + import commonmark + md_parser = html_via_commonmark + except: + die("Failed to find cmarkgfm or commonmark for python3.") + + main() diff --git a/packaging/release-rsync b/packaging/release-rsync index ee771bd0..a4c193c6 100755 --- a/packaging/release-rsync +++ b/packaging/release-rsync @@ -329,13 +329,18 @@ About to: shutil.rmtree(rsync_ver) print(f"Updating the other files in {dest} ...") - cmd_chk('rsync -a README.md NEWS.md OLDNEWS.md TODO'.split() + [dest]) - if os.path.lexists(news_file): - os.unlink(news_file) - os.link(f"{dest}/NEWS.md", news_file) - cmd_chk(f"git log --name-status | gzip -9 >{dest}/ChangeLog.gz") + md_files = 'README.md NEWS.md OLDNEWS.md'.split() + html_files = [ fn for fn in gen_files if fn.endswith('.html') ] + cmd_chk(['rsync', '-a', *md_files, *html_files, dest]) + cmd_chk(["packaging/md2html"] + [ dest +'/'+ fn for fn in md_files ]) + + for topfn, verfn in (('NEWS.md', news_file), ('NEWS.html', news_file.replace('.md', '.html'))): + topfn = dest + '/' + topfn + if os.path.lexists(verfn): + os.unlink(verfn) + os.link(topfn, verfn) - cmd_chk(['rsync', '-a', *glob.glob('*.[1-9].html'), os.path.join(dest, html_fn)]) + cmd_chk(f"git log --name-status | gzip -9 >{dest}/ChangeLog.gz") for fn in (srctar_file, pattar_file, diff_file): asc_fn = fn + '.asc'