diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
commit | 8a754e0858d922e955e71b253c139e071ecec432 (patch) | |
tree | 527d16e74bfd1840c85efd675fdecad056c54107 /packaging/sdist | |
parent | Initial commit. (diff) | |
download | ansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging/sdist')
-rwxr-xr-x | packaging/sdist/check-link-behavior.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/packaging/sdist/check-link-behavior.py b/packaging/sdist/check-link-behavior.py new file mode 100755 index 0000000..34e0502 --- /dev/null +++ b/packaging/sdist/check-link-behavior.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +"""Checks for link behavior required for sdist to retain symlinks.""" + +from __future__ import (absolute_import, division, print_function) + +__metaclass__ = type + +import os +import platform +import shutil +import sys +import tempfile + + +def main(): + """Main program entry point.""" + temp_dir = tempfile.mkdtemp() + + target_path = os.path.join(temp_dir, 'file.txt') + symlink_path = os.path.join(temp_dir, 'symlink.txt') + hardlink_path = os.path.join(temp_dir, 'hardlink.txt') + + try: + with open(target_path, 'w'): + pass + + os.symlink(target_path, symlink_path) + os.link(symlink_path, hardlink_path) + + if not os.path.islink(symlink_path): + abort('Symbolic link not created.') + + if not os.path.islink(hardlink_path): + # known issue on MacOS (Darwin) + abort('Hard link of symbolic link created as a regular file.') + finally: + shutil.rmtree(temp_dir) + + +def abort(reason): + """ + :type reason: str + """ + sys.exit('ERROR: %s\n' + 'This will prevent symbolic links from being preserved in the resulting tarball.\n' + 'Aborting creation of sdist on platform: %s' + % (reason, platform.system())) + + +if __name__ == '__main__': + main() |