Permalink
Browse files

add auto-masquerade script

inspired by the perl one in Debian
  • Loading branch information...
shawnl committed Feb 26, 2018
1 parent 8db562c commit 7ee937f0a972205e4c88add001194ac7608589a6
Showing with 80 additions and 0 deletions.
  1. +13 −0 Makefile.in
  2. +5 −0 man/distcc.1
  3. +62 −0 update-distcc-symlinks.py
View
@@ -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,
View
@@ -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
View
@@ -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)

0 comments on commit 7ee937f

Please sign in to comment.