This will cause `make sdist` to fail on platforms which create
hard links of symbolic links as regular files, such as MacOS (Darwin).
This prevents accidental creation of an sdist tarball without
the necessary symbolic links.
... | ... |
@@ -231,8 +231,12 @@ install_manpages: |
231 | 231 |
gzip -9 $(wildcard ./docs/man/man1/ansible*.1) |
232 | 232 |
cp $(wildcard ./docs/man/man1/ansible*.1.gz) $(PREFIX)/man/man1/ |
233 | 233 |
|
234 |
+.PHONY: sdist_check |
|
235 |
+sdist_check: |
|
236 |
+ $(PYTHON) packaging/sdist/check-link-behavior.py |
|
237 |
+ |
|
234 | 238 |
.PHONY: sdist |
235 |
-sdist: clean docs |
|
239 |
+sdist: sdist_check clean docs |
|
236 | 240 |
$(PYTHON) setup.py sdist |
237 | 241 |
|
238 | 242 |
.PHONY: sdist_upload |
239 | 243 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,51 @@ |
0 |
+#!/usr/bin/env python |
|
1 |
+"""Checks for link behavior required for sdist to retain symlinks.""" |
|
2 |
+ |
|
3 |
+from __future__ import (absolute_import, division, print_function) |
|
4 |
+ |
|
5 |
+__metaclass__ = type |
|
6 |
+ |
|
7 |
+import os |
|
8 |
+import platform |
|
9 |
+import shutil |
|
10 |
+import sys |
|
11 |
+import tempfile |
|
12 |
+ |
|
13 |
+ |
|
14 |
+def main(): |
|
15 |
+ """Main program entry point.""" |
|
16 |
+ temp_dir = tempfile.mkdtemp() |
|
17 |
+ |
|
18 |
+ target_path = os.path.join(temp_dir, 'file.txt') |
|
19 |
+ symlink_path = os.path.join(temp_dir, 'symlink.txt') |
|
20 |
+ hardlink_path = os.path.join(temp_dir, 'hardlink.txt') |
|
21 |
+ |
|
22 |
+ try: |
|
23 |
+ with open(target_path, 'w'): |
|
24 |
+ pass |
|
25 |
+ |
|
26 |
+ os.symlink(target_path, symlink_path) |
|
27 |
+ os.link(symlink_path, hardlink_path) |
|
28 |
+ |
|
29 |
+ if not os.path.islink(symlink_path): |
|
30 |
+ abort('Symbolic link not created.') |
|
31 |
+ |
|
32 |
+ if not os.path.islink(hardlink_path): |
|
33 |
+ # known issue on MacOS (Darwin) |
|
34 |
+ abort('Hard link of symbolic link created as a regular file.') |
|
35 |
+ finally: |
|
36 |
+ shutil.rmtree(temp_dir) |
|
37 |
+ |
|
38 |
+ |
|
39 |
+def abort(reason): |
|
40 |
+ """ |
|
41 |
+ :type reason: str |
|
42 |
+ """ |
|
43 |
+ sys.exit('ERROR: %s\n' |
|
44 |
+ 'This will prevent symbolic links from being preserved in the resulting tarball.\n' |
|
45 |
+ 'Aborting creation of sdist on platform: %s' |
|
46 |
+ % (reason, platform.system())) |
|
47 |
+ |
|
48 |
+ |
|
49 |
+if __name__ == '__main__': |
|
50 |
+ main() |