diff options
author | lloyd <[email protected]> | 2014-12-02 13:15:08 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-12-02 13:15:08 +0000 |
commit | e78801f8c8a168d70ae06769ec6996c4e0da122f (patch) | |
tree | 20bb25b1def62a60c174135878b17e5ac7c9eeb1 | |
parent | c9f2bf4717966d4f1d3375adbb4f1e68b7c9b7e2 (diff) |
Handle repeated installs into the same dir.
Format and install the license text.
-rwxr-xr-x | src/scripts/install.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/scripts/install.py b/src/scripts/install.py index f3daa9f44..52b197619 100755 --- a/src/scripts/install.py +++ b/src/scripts/install.py @@ -66,6 +66,20 @@ def makedirs(dirname, exist_ok = True): if e.errno != errno.EEXIST or not exist_ok: raise e +def license_text(rst_license): + end_of_rst = 'terms::' + contents = open(rst_license).read() + x = contents.find(end_of_rst) + len(end_of_rst) + + lines = contents[x:].split('\n') + + while lines[0] == '': + lines.pop(0) + + leading_ws = min([len(l) - len(l.lstrip(' ')) for l in lines if l != '']) + + return '\n'.join([l[leading_ws:] for l in lines]) + def main(args = None): if args is None: args = sys.argv @@ -138,8 +152,22 @@ def main(args = None): copy_executable(shared_lib, os.path.join(lib_dir, os.path.basename(shared_lib))) prev_cwd = os.getcwd() + try: os.chdir(lib_dir) + + try: + os.unlink(soname) + except OSError as e: + if e.errno != errno.ENOENT: + raise e + + try: + os.unlink(baselib) + except OSError as e: + if e.errno != errno.ENOENT: + raise e + os.symlink(shared_lib, soname) os.symlink(soname, baselib) finally: @@ -157,8 +185,12 @@ def main(args = None): shutil.copyfile(build_vars['botan_pkgconfig'], os.path.join(pkgconfig_dir, os.path.basename(build_vars['botan_pkgconfig']))) + shutil.rmtree(botan_doc_dir, True) shutil.copytree(build_vars['doc_output_dir'], botan_doc_dir) + with open(os.path.join(botan_doc_dir, 'license.txt'), 'w+') as lic: + lic.write(license_text('doc/license.rst')) + logging.info('Botan %s installation complete', build_vars['version']) if __name__ == '__main__': |