diff options
author | Shawn Landden <slandden@gmail.com> | 2018-02-25 21:32:41 -0800 |
---|---|---|
committer | Shawn Landden <slandden@gmail.com> | 2018-02-26 15:19:55 -0800 |
commit | 7ee937f0a972205e4c88add001194ac7608589a6 (patch) | |
tree | 9bd3201aa21ecfe78be0a9afe2ba731cac17ccb4 | |
parent | 8db562c9da720bb4e8f24b90509da2e8287790dc (diff) | |
download | distcc-git-7ee937f0a972205e4c88add001194ac7608589a6.tar.gz |
add auto-masquerade script
inspired by the perl one in Debian
-rw-r--r-- | Makefile.in | 13 | ||||
-rw-r--r-- | man/distcc.1 | 5 | ||||
-rwxr-xr-x | update-distcc-symlinks.py | 62 |
3 files changed, 80 insertions, 0 deletions
diff --git a/Makefile.in b/Makefile.in index 3ea595c..a1aca1c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -417,6 +417,9 @@ bin_PROGRAMS = \ lsdistcc@EXEEXT@ \ @GNOME_BIN@ +sbin_PROGRAMS = \ + update-distcc-symlinks.py + check_PROGRAMS = \ h_argvtostr@EXEEXT@ \ h_exten@EXEEXT@ \ @@ -1022,6 +1025,7 @@ showpaths: @echo " man pages $(DESTDIR)$(man1dir)" @echo " documents $(DESTDIR)$(docdir)" @echo " programs $(DESTDIR)$(bindir)" + @echo " sbin programs $(DESTDIR)$(sbindir)" @echo " system configuration $(DESTDIR)$(sysconfdir)" @echo " shared data files $(DESTDIR)$(pkgdatadir)" @@ -1034,9 +1038,13 @@ install: showpaths install-doc install-man install-programs \ install-programs: $(bin_PROGRAMS) $(mkinstalldirs) "$(DESTDIR)$(bindir)" + $(mkinstalldirs) "$(DESTDIR)$(sbindir)" for p in $(bin_PROGRAMS); do \ $(INSTALL_PROGRAM) "$$p" "$(DESTDIR)$(bindir)" || exit 1; \ done + for p in $(sbin_PROGRAMS); do \ + $(INSTALL_PROGRAM) "$$p" "$(DESTDIR)$(sbindir)" || exit 1; \ + done # See comments for the include-server target. Also, we work around an issue in # the change_root function of distutils/utils.py that turns the absolute prefix @@ -1161,7 +1169,12 @@ uninstall-programs: file="$(DESTDIR)$(bindir)/`basename $$p`"; \ if [ -e "$$file" ]; then rm -fv "$$file"; fi \ done + for p in $(sbin_PROGRAMS); do \ + file="$(DESTDIR)$(sbindir)/`basename $$p`"; \ + if [ -e "$$file" ]; then rm -fv "$$file"; fi \ + done -[ "`basename $(bindir)`" = "$(PACKAGE)" ] && rmdir "$(DESTDIR)$(bindir)" + -[ "`basename $(sbindir)`" = "$(PACKAGE)" ] && rmdir "$(DESTDIR)$(sbindir)" # There's no setup.py --uninstall. :-( So I depend on # PYTHON_INSTALL_RECORD being set. If it was used at --install time, diff --git a/man/distcc.1 b/man/distcc.1 index 9ab9afb..18e5737 100644 --- a/man/distcc.1 +++ b/man/distcc.1 @@ -371,6 +371,11 @@ Then, to use distcc, a user just needs to put the directory /usr/lib/distcc/bin early in the PATH, and have set a host list in DISTCC_HOSTS or a file. distcc will handle the rest. .PP +To automatically discover compilers and create masquerade links run +the provided +.BR update-distcc-symlinks.py +script. +.PP Note that this masquerade directory must occur on the PATH earlier than the directory that contains the actual compilers of the same names, and that any auxiliary programs that these compilers call (such diff --git a/update-distcc-symlinks.py b/update-distcc-symlinks.py new file mode 100755 index 0000000..f467ead --- /dev/null +++ b/update-distcc-symlinks.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 + +import subprocess, string, os, stat, re + +distcc_dir = "/usr/lib/distcc" +gcc_dir = "/usr/lib/gcc" +old_symlinks = set() +new_symlinks = set() +standard_names = ["cc", "c++", "c89", "c99"] + +if not os.access(distcc_dir, os.X_OK): + os.mkdir(distcc_dir) + +def consider(name): + if os.access("/usr/bin/%(name)s" % vars(), os.X_OK): + new_symlinks.add(name) + print(name) + +def consider_gcc(prefix, suffix): + consider("%(prefix)sgcc%(suffix)s" % vars()) + consider("%(prefix)sg++%(suffix)s" % vars()) + +def consider_clang(suffix): + consider("clang%(suffix)s" % vars()) + consider("clang++%(suffix)s" % vars()) + +for x in standard_names: + consider(x) + +consider_gcc("", "") +consider_gcc("c89-", "") +consider_gcc("c99-", "") +for gnu_host in os.listdir(gcc_dir): + consider_gcc("%(gnu_host)s-" % vars(), "") + for version in os.listdir(gcc_dir + "/" + gnu_host): + consider_gcc("", "-%(version)s" % vars()) + consider_gcc("%(gnu_host)s-" % vars(), "-%(version)s" % vars()) + +consider_clang("") +for ent in os.listdir("/usr/lib"): + if ent.startswith("llvm-"): + version = ent.split("-")[1] + consider_clang("-%(version)s" % vars()) + +for name in os.listdir(distcc_dir): + mode = os.lstat(distcc_dir + "/" + name).st_mode + if stat.S_ISLNK(mode): + if os.access(distcc_dir + "/" + name, os.X_OK): + old_symlinks.add(name) + else: + os.unlink(distcc_dir + "/" + name) + +for link in old_symlinks: + if link not in new_symlinks: + os.unlink(distcc_dir + "/" + link) + +for link in new_symlinks: + if link not in old_symlinks: + if os.access("/usr/bin/distcc", os.X_OK): + os.symlink("../../bin/distcc", distcc_dir + "/" + link) + else: + os.symlink("../../local/bin/distcc", distcc_dir + "/" + link) |