diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2018-06-27 11:36:23 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2018-06-27 11:36:23 +0300 |
commit | 6a4f97aa9e759afd3a413edeb604d6ab26a1b181 (patch) | |
tree | 6a53346f41076c81de42fea2b1e34be6365b7c34 | |
parent | d8c549ad7c2ad7d3e542bb6241ffbee2c815209f (diff) |
distcc-scm added
-rw-r--r-- | packages/sys-devel/distcc/distcc-scm.exheres-0 | 53 | ||||
-rw-r--r-- | packages/sys-devel/distcc/files/3.2/conf | 40 | ||||
-rw-r--r-- | packages/sys-devel/distcc/files/3.2/distcc-config | 181 | ||||
-rw-r--r-- | packages/sys-devel/distcc/files/3.2/init | 32 | ||||
-rw-r--r-- | packages/sys-devel/distcc/files/distcc-3.0-xinetd.patch | 15 | ||||
-rw-r--r-- | packages/sys-devel/distcc/files/distcc-3.2_rc1-socks5.patch | 191 | ||||
-rw-r--r-- | packages/sys-devel/distcc/files/distcc-config | 165 | ||||
-rw-r--r-- | packages/sys-devel/distcc/files/distcc-hardened.patch | 24 | ||||
-rw-r--r-- | packages/sys-devel/distcc/files/distccd.service | 10 | ||||
-rw-r--r-- | packages/sys-devel/distcc/files/distccd.service.conf | 6 |
10 files changed, 717 insertions, 0 deletions
diff --git a/packages/sys-devel/distcc/distcc-scm.exheres-0 b/packages/sys-devel/distcc/distcc-scm.exheres-0 new file mode 100644 index 0000000..1af0644 --- /dev/null +++ b/packages/sys-devel/distcc/distcc-scm.exheres-0 @@ -0,0 +1,53 @@ +DOWNLOADS="" + +SCM_REPOSITORY="https://github.com/distcc/distcc.git" + +require scm-git +require autotools [ supported_autoconf=[ 2.5 ] supported_automake=[ 1.15 1.13 1.12 1.11 ] need_libtool=false ] + +SUMMARY="Distribute compilation of C code across several machines on a network" +DESCRIPTION="" +SLOT="0" +HOMEPAGE="http://distcc.org/" +PLATFORMS="~amd64 ~x86" + +MYOPTIONS=" + gnome + gtk + hardened + ipv6 + xinetd + zeroconf +" + +DEPENDENCIES=" + build+run: + dev-libs/popt + gnome? ( + gnome-platform/libgnome:2 + gnome-platform/libgnomeui:2 + x11-libs/pango + x11-libs/gtk+:2 + ) +" + + +src_prepare() { + expatch "${FILES}/${PN}-3.0-xinetd.patch" + expatch "${FILES}/${PN}-3.2_rc1-socks5.patch" + option hardened && expatch "${FILES}/distcc-hardened.patch" + default_src_prepare + autotools_src_prepare +} + +src_configure() { + local myconf="--disable-Werror" + option ipv6 && myconf="${myconf} --enable-rfc2553" + econf \ + --disable-auth \ + $(option_with gtk) \ + $(option_with gnome) \ + $(option_with zeroconf avahi) \ + ${myconf} +} + diff --git a/packages/sys-devel/distcc/files/3.2/conf b/packages/sys-devel/distcc/files/3.2/conf new file mode 100644 index 0000000..c499271 --- /dev/null +++ b/packages/sys-devel/distcc/files/3.2/conf @@ -0,0 +1,40 @@ +# /etc/conf.d/distccd: config file for /etc/init.d/distccd + +DISTCCD_OPTS="" + +# this is the distccd executable +DISTCCD_EXEC="/usr/bin/distccd" + +# this is where distccd will store its pid file +DISTCCD_PIDFILE="/var/run/distccd/distccd.pid" + +# set this option to run distccd with extra parameters +# Default port is 3632. For most people the default is okay. +DISTCCD_OPTS="${DISTCCD_OPTS} --port 3632" + +# Logging +# You can change some logging options here: +# --log-file FILE +# --log-level LEVEL [critical,error,warning, notice, info, debug] +# +# Leaving --log-file blank will log to syslog +# example: --log-file /dev/null --log-level warning +# example: --log-level critical + +DISTCCD_OPTS="${DISTCCD_OPTS} --log-level critical" + +# SECURITY NOTICE: +# It is HIGHLY recommended that you use the --listen option +# for increased security. You can specify an IP to permit connections +# from or a CIDR mask +# --listen accepts only a single IP +# --allow is now mandatory as of distcc-2.18. +# example: --allow 192.168.0.0/24 +# example: --allow 192.168.0.5 --allow 192.168.0.150 +# example: --listen 192.168.0.2 +DISTCCD_OPTS="${DISTCCD_OPTS} --allow 192.168.0.0/24" +#DISTCCD_OPTS="${DISTCCD_OPTS} --listen 192.168.0.2" + +# set this for niceness +# Default is 15 +DISTCCD_OPTS="${DISTCCD_OPTS} -N 15" diff --git a/packages/sys-devel/distcc/files/3.2/distcc-config b/packages/sys-devel/distcc/files/3.2/distcc-config new file mode 100644 index 0000000..6f3bd27 --- /dev/null +++ b/packages/sys-devel/distcc/files/3.2/distcc-config @@ -0,0 +1,181 @@ +#!/usr/bin/env python2 +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +import os, re, signal, subprocess, sys + +options=[ + '--get-hosts', + '--set-hosts', + '--get-verbose', + '--set-verbose', + '--get-log', + '--set-log', + '--update-masquerade', + '--update-masquerade-with-crossdev', + '--help', + '--get-env', + '--set-env' +] + +tmpcmdline=sys.argv[1:] +cmdline=[] + +eprefix = '@EPREFIX@' +bindir = os.path.join(eprefix, 'usr', 'bin') +sbindir = os.path.join(eprefix, 'usr', 'sbin') +libdir = os.path.join(eprefix, '@libdir@') +sysconfdir = os.path.join(eprefix, 'etc') + +gcc_config = os.path.join(bindir, 'gcc-config') +env_update = os.path.join(sbindir, 'env-update') +envfile = os.path.join(sysconfdir, 'env.d', '02distcc') +default_distcc_dir = os.path.join(sysconfdir, 'distcc') +hostfile = os.path.join(default_distcc_dir, 'hosts') +distcc_path = os.path.join(bindir, 'distcc') +dccc_dir = os.path.join(libdir, 'distcc', 'bin') + +def exithandler(foo,bar): + os.kill(0,signal.SIGKILL) + sys.exit(1) + +signal.signal(signal.SIGINT,exithandler) + +def isroot(ret=0): + if os.getuid() != 0: + if ret == 0: + print('!!! %s %s must be run as root' % (sys.argv[:1][0],tmpcmdline[0])) + sys.exit(1) + else: + retval = 0 + else: + retval = 1 + return retval + +def writeenv(var,value): + isroot() + distcc_env = [] + distcc_env = open(envfile, 'r').readlines() + distcc_env_new = open(envfile, 'w') + for i in range(len(distcc_env)): + if re.compile(var+'="(.*)"').match(distcc_env[i]): + distcc_env[i] = var+'="'+value+'"\n' + distcc_env_new.write(distcc_env[i]) + #print('Set %s to: %s ' % (var,value)) + subprocess.Popen(env_update, shell=True) + print('If you want to use these new settings in an existing shell,') + print('you need to "source /etc/profile" to get the changes.') + +def readenv(var): + distcc_env = open(envfile, 'r').read() + match = re.compile(var+'="(.*)"').search(distcc_env) + if match: + print(var+'='+match.group(1)) + else: + print(var,'not set.') + +def installlink(chost='', version=''): + for file in ['gcc', 'cc', 'c++', 'g++']: + if not chost == '': + file = '%s-%s' % (chost,file) + if not version == '': + file = '%s-%s' % (file,version) + path = os.path.join(dccc_dir,file) + if os.path.exists(os.path.join(bindir,file)): + if not os.path.exists(path): + print('Creating %s symlink...' % (path)) + os.symlink(distcc_path,path) + #else: + # print('Already exists. Skipping...') + +def installlinks(): + p = subprocess.Popen([gcc_config+" -C -l"], shell=True, stdout=subprocess.PIPE) + lines = p.stdout.read().rstrip().split('\n') + for line in lines: + columns = line.split() + if len(columns) >= 2: + matches = re.match("(.*)-(.*)", columns[1]) + chost = matches.group(1) + version = matches.group(2) + installlink(chost) + installlink(chost, version) + +def uninstalllinks(): + for root, dirs, files in os.walk(dccc_dir): + for file in files: + os.remove(os.path.join(root, file)) + +def createdistccdir(dir): + if not os.path.exists(dir): + os.mkdir(dir) + os.chmod(dir, 0o755) + +for x in tmpcmdline: + if not x: + continue + if x[0:2]=="--": + if not x in options: + print("!!! Error: %s is an invalid option." % (x)) + sys.exit(1) + else: + cmdline = x + +if '--get-hosts' in tmpcmdline: + HOSTS_ENV = os.environ.get('DISTCC_HOSTS') + HOSTS_HOME = os.path.join(os.environ.get('HOME'), '.distcc', 'hosts') + if HOSTS_ENV: + print(HOSTS_ENV) + elif os.path.isfile(HOSTS_HOME) and os.path.getsize(HOSTS_HOME) != 0: + print(HOSTS_HOME) + elif os.path.exists(hostfile): + print(open(hostfile, 'r').read().rstrip()) + else: + print('No configuration file found. Setup your hosts with --set-hosts.') +elif '--set-hosts' in tmpcmdline: + if isroot(1): + PATH = default_distcc_dir + else: + PATH = os.path.join(os.environ.get('HOME'), '.distcc') + createdistccdir(PATH) + open(os.path.join(PATH, 'hosts'), 'w').write(cmdline + '\n') +elif '--get-verbose' in tmpcmdline: + readenv('DISTCC_VERBOSE') +elif '--set-verbose' in tmpcmdline: + writeenv('DISTCC_VERBOSE',tmpcmdline[1]) +elif '--get-log' in tmpcmdline: + readenv('DISTCC_LOG') +elif '--set-log' in tmpcmdline: + writeenv('DISTCC_LOG',tmpcmdline[1]) +elif '--update-masquerade' in tmpcmdline: + isroot() + uninstalllinks() + print('Creating symlinks...') + installlink() + installlinks() +elif '--update-masquerade-with-crossdev' in tmpcmdline: + isroot() + uninstalllinks() + print('Creating symlinks...') + installlinks() +elif '--get-env' in tmpcmdline: + if len(tmpcmdline) == 1: + print(open(envfile, 'r').read().rstrip()) + elif len(tmpcmdline) == 2: + readenv(tmpcmdline[1]) + else: + print('!!! Error: Specify only one variable.') +elif '--set-env' in tmpcmdline: + if len(tmpcmdline) > 2 and len(tmpcmdline) <= 3: + isroot() + writeenv(tmpcmdline[1],tmpcmdline[2]) + else: + print('!!! Error: Awaiting two parameters.') +else: + cmd = sys.argv[:1][0] + print('Usage: %s --set-hosts DISTCC_HOSTS | --get-hosts' % (cmd)) + print(' %s --set-verbose { 0 | 1 } | --get-verbose' % (cmd)) + print(' %s --set-log FILE | --get-log' % (cmd)) + print(' %s --set-env VARIABLE VALUE | --get-env [VARIABLE]' % (cmd)) + print(' %s --update-masquerade' % (cmd)) + print(' %s --update-masquerade-with-crossdev' % (cmd)) diff --git a/packages/sys-devel/distcc/files/3.2/init b/packages/sys-devel/distcc/files/3.2/init new file mode 100644 index 0000000..783c065 --- /dev/null +++ b/packages/sys-devel/distcc/files/3.2/init @@ -0,0 +1,32 @@ +#!/sbin/openrc-run +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +depend() { + need net + use avahi-daemon ypbind +} + +start() { + ebegin "Starting distccd" + + if [ ! -e /var/run/distccd ] ; then + mkdir -p /var/run/distccd + chown distcc:daemon /var/run/distccd + fi + + # Load PATH and GCC_SPECS from gcc-config, bug #262773 + eval "$(gcc-config -E)" + + start-stop-daemon --start --quiet --exec "${DISTCCD_EXEC}" --user distcc -- \ + --daemon --pid-file "${DISTCCD_PIDFILE}" \ + ${DISTCCD_OPTS} + eend $? +} + +stop() { + ebegin "Stopping distccd" + start-stop-daemon --stop --quiet --pidfile "${DISTCCD_PIDFILE}" + eend $? +} diff --git a/packages/sys-devel/distcc/files/distcc-3.0-xinetd.patch b/packages/sys-devel/distcc/files/distcc-3.0-xinetd.patch new file mode 100644 index 0000000..47877ad --- /dev/null +++ b/packages/sys-devel/distcc/files/distcc-3.0-xinetd.patch @@ -0,0 +1,15 @@ +diff -Naur distcc-3.0.orig/doc/example/xinetd distcc-3.0/doc/example/xinetd +--- distcc-3.0.orig/doc/example/xinetd 2008-08-07 05:52:13.000000000 +0900 ++++ distcc-3.0/doc/example/xinetd 2008-10-27 15:32:14.000000000 +0900 +@@ -19,10 +19,6 @@ + socket_type = stream + wait = no + user = distcc +- server = /usr/local/bin/distccd ++ server = /usr/bin/distccd + server_args = --inetd +- +- # This makes xinetd cope if there is no service listed in +- # /etc/services +- type = UNLISTED + } diff --git a/packages/sys-devel/distcc/files/distcc-3.2_rc1-socks5.patch b/packages/sys-devel/distcc/files/distcc-3.2_rc1-socks5.patch new file mode 100644 index 0000000..256a16f --- /dev/null +++ b/packages/sys-devel/distcc/files/distcc-3.2_rc1-socks5.patch @@ -0,0 +1,191 @@ +From fdd93b1e9545b66d1b3a2a1ec24d4c8613ee43fb Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Sat, 24 Jan 2015 23:59:21 +0100 +Subject: [PATCH] Support SOCKSv5 proxy + +Support using a SOCKSv5 proxy specified as DISTCC_SOCKS_PROXY. +The variable can either a hostname, a host:port pair or an absolute path +to a UNIX socket. When SOCKS is used, the hostname is passed to +the proxy and therefore the name resolution is done remotely. +--- + src/clinet.c | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 135 insertions(+), 2 deletions(-) + +diff --git a/src/clinet.c b/src/clinet.c +index 010a884..4773d8b 100644 +--- a/src/clinet.c ++++ b/src/clinet.c +@@ -31,6 +31,7 @@ + + #include <stdio.h> + #include <stdlib.h> ++#include <stddef.h> + #include <unistd.h> + #include <string.h> + #include <fcntl.h> +@@ -42,8 +43,10 @@ + #include <sys/types.h> + #include <sys/socket.h> + ++#include <arpa/inet.h> + #include <netinet/in.h> + #include <netinet/tcp.h> ++#include <sys/un.h> + + #include <netdb.h> + +@@ -161,7 +164,7 @@ out_failed: + /** + * Open a socket to a tcp remote host with the specified port. + **/ +-int dcc_connect_by_name(const char *host, int port, int *p_fd) ++static int dcc_connect_by_name_real(const char *host, int port, int *p_fd) + { + struct addrinfo hints; + struct addrinfo *res; +@@ -201,7 +204,7 @@ int dcc_connect_by_name(const char *host, int port, int *p_fd) + * + * @todo Don't try for too long to connect. + **/ +-int dcc_connect_by_name(const char *host, int port, int *p_fd) ++static int dcc_connect_by_name_real(const char *host, int port, int *p_fd) + { + struct sockaddr_in sock_out; + struct hostent *hp; +@@ -224,3 +227,133 @@ int dcc_connect_by_name(const char *host, int port, int *p_fd) + } + + #endif /* not ENABLE_RFC2553 */ ++ ++static int dcc_connect_via_socks5(const char *host, int port, int *p_fd, const char *proxy) ++{ ++ int ret; ++ char *proxy_host, *proxy_it; ++ int proxy_port; ++ char buf[262]; ++ int host_length; ++ struct sockaddr_in addr_buf; ++ int skip_bytes; ++ ++ host_length = strlen(host); ++ if (host_length > 255) { ++ rs_log_error("hostname \"%s\" too long for SOCKSv5 (over 255 chars)", host); ++ return EXIT_CONNECT_FAILED; ++ } ++ ++ if (proxy[0] == '/') { /* UNIX socket */ ++ struct sockaddr_un unix_addr; ++ ++ if (strlen(proxy) >= sizeof(unix_addr.sun_path)) ++ { ++ rs_log_error("UNIX socket path \"%s\" too long", proxy); ++ return EXIT_CONNECT_FAILED; ++ } ++ ++ unix_addr.sun_family = AF_UNIX; ++ strcpy(unix_addr.sun_path, proxy); ++ ++ ret = dcc_connect_by_addr((struct sockaddr *) &unix_addr, ++ offsetof(struct sockaddr_un, sun_path) + strlen(proxy) + 1, ++ p_fd); ++ ++ } else { /* hostname? IP address? */ ++ proxy_host = strdup(proxy); ++ if (proxy_host == NULL) return EXIT_OUT_OF_MEMORY; ++ ++ proxy_it = strrchr(proxy_host, ':'); ++ if (proxy_it) { ++ *(proxy_it++) = 0; ++ proxy_port = atoi(proxy_it); ++ ++ if (proxy_port <= 0) { ++ rs_log_error("invalid proxy port \"%s\"", proxy_it); ++ free(proxy_host); ++ return EXIT_CONNECT_FAILED; ++ } ++ } ++ else ++ proxy_port = 1080; ++ ++ ret = dcc_connect_by_name_real(proxy_host, proxy_port, p_fd); ++ free(proxy_host); ++ } ++ ++ if (ret != 0) ++ return ret; ++ ++ /* connected to proxy, now identifier/method selection */ ++ buf[0] = 0x05; /* SOCKSv5 */ ++ buf[1] = 0x01; /* one method */ ++ buf[2] = 0x00; /* NO AUTHENTICATION REQUIRED */ ++ ret = dcc_writex(*p_fd, buf, 3); ++ if (ret != 0) ++ return ret; ++ ++ /* wait for method selection */ ++ ret = dcc_readx(*p_fd, buf, 2); ++ if (ret != 0) ++ return ret; ++ if (buf[0] != 0x05 || buf[1] != 0x00) { /* version, method */ ++ rs_log_error("invalid proxy reply (version 0x%02x, method 0x%02x)", ++ buf[0], buf[1]); ++ return EXIT_CONNECT_FAILED; ++ } ++ ++ /* send connect request */ ++ buf[0] = 0x05; /* SOCKSv5 */ ++ buf[1] = 0x01; /* CONNECT command */ ++ buf[2] = 0x00; /* reserved */ ++ buf[3] = 0x03; /* DOMAINNAME address type */ ++ buf[4] = host_length; ++ memcpy(&buf[5], host, host_length); ++ addr_buf.sin_port = htons(port); ++ memcpy(&buf[5 + host_length], &addr_buf.sin_port, 2); ++ ret = dcc_writex(*p_fd, buf, 7 + host_length); ++ if (ret != 0) ++ return ret; ++ ++ /* wait for the connection */ ++ /* read first 4 bytes of reply + 2 extra bytes we know will be there */ ++ ret = dcc_readx(*p_fd, buf, 6); ++ if (ret != 0) ++ return ret; ++ if (buf[0] != 0x05 || buf[2] != 0x00) { /* version, reserved */ ++ rs_log_error("invalid proxy reply (version 0x%02x, reserved 0x%02x)", ++ buf[0], buf[2]); ++ return EXIT_CONNECT_FAILED; ++ } ++ if (buf[1] != 0x00) { /* reply */ ++ rs_log_error("proxy connection failed, reason=0x%02x", buf[1]); ++ return EXIT_CONNECT_FAILED; ++ } ++ ++ /* now read the remaining (packet size - 6) bytes */ ++ switch (buf[3]) { /* address type */ ++ case 0x01: skip_bytes = 4; break; /* IPv4 */ ++ case 0x03: skip_bytes = buf[4] + 1; break; /* hostname with length field */ ++ case 0x04: skip_bytes = 16; break; /* IPv6 */ ++ default: ++ rs_log_error("invalid proxy reply (address type 0x%02x)", buf[3]); ++ return EXIT_CONNECT_FAILED; ++ } ++ ret = dcc_readx(*p_fd, buf, skip_bytes); ++ if (ret != 0) ++ return ret; ++ ++ return 0; ++} ++ ++int dcc_connect_by_name(const char *host, int port, int *p_fd) ++{ ++ const char *proxy; ++ ++ proxy = getenv("DISTCC_SOCKS_PROXY"); ++ if (proxy) ++ return dcc_connect_via_socks5(host, port, p_fd, proxy); ++ else ++ return dcc_connect_by_name_real(host, port, p_fd); ++} +-- +2.3.0 + diff --git a/packages/sys-devel/distcc/files/distcc-config b/packages/sys-devel/distcc/files/distcc-config new file mode 100644 index 0000000..c7e6622 --- /dev/null +++ b/packages/sys-devel/distcc/files/distcc-config @@ -0,0 +1,165 @@ +#!/usr/bin/env python +# Copyright 1999-2004 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +import os, re, signal, sys, commands, pwd +from string import rstrip + +options=[ + '--get-hosts', + '--set-hosts', + '--get-verbose', + '--set-verbose', + '--get-log', + '--set-log', + '--install', + '--help', + '--get-env', + '--set-env' +] + +tmpcmdline=sys.argv[1:] +cmdline=[] +envfile = '/etc/env.d/02distcc' + +def exithandler(foo,bar): + os.kill(0,signal.SIGKILL) + sys.exit(1) + +signal.signal(signal.SIGINT,exithandler) + +def isroot(ret=0): + if os.getuid() != 0: + if ret == 0: + print '!!!',sys.argv[:1][0],tmpcmdline[0],'must be run as root' + sys.exit(1) + else: + retval = 0 + else: + retval = 1 + return retval + +def writeenv(var,value): + isroot() + distcc_env = [] + distcc_env = open(envfile, 'r').readlines() + distcc_env_new = open(envfile, 'w') + for i in range(len(distcc_env)): + if re.compile(var+'="(.*)"').match(distcc_env[i]): + distcc_env[i] = var+'="'+value+'"\n' + distcc_env_new.write(distcc_env[i]) + #print 'Set',var,'to:',value + os.popen('/usr/sbin/env-update') + print 'If you want to use these new settings in an existing shell,' + print 'you need to "source /etc/profile" to get the changes.' + +def readenv(var): + distcc_env = open(envfile, 'r').read() + match = re.compile(var+'="(.*)"').search(distcc_env) + if match: + print var+'='+match.group(1) + else: + print var,'not set.' + +def permissions(path,user,group): + for file in os.listdir(path): + #print 'Configuring',path+file+'...' + os.chown(path+file,user,group) + +def installlinks(chost=''): + for file in ['gcc', 'cc', 'c++', 'g++']: + path = '/usr/lib/distcc/bin/' + if not chost == '': + file = chost+'-'+file + if os.path.exists('/usr/bin/'+file): + #print 'Creating',path+file,'symlink...' + if not os.path.exists(path+file): + os.symlink('/usr/bin/distcc',path+file) + #else: + # print 'Already exists. Skipping...' + +def createdistccdir(dir): + if not os.path.exists(dir): + os.mkdir(dir) + os.chmod(dir, 1777) + +for x in tmpcmdline: + if not x: + continue + if x[0:2]=="--": + if not x in options: + print "!!! Error:",x,"is an invalid option." + sys.exit(1) + else: + cmdline = x + +if '--get-hosts' in tmpcmdline: + HOSTS_ENV = os.environ.get('DISTCC_HOSTS') + HOSTS_HOME = os.environ.get('HOME')+'/hosts' + if HOSTS_ENV: + print HOSTS_ENV + elif os.path.isfile(HOSTS_HOME) and os.path.getsize(HOSTS_HOME) != 0: + print HOSTS_HOME + elif os.path.exists('/etc/distcc/hosts'): + print rstrip(open('/etc/distcc/hosts', 'r').read()) + else: + print 'No configuration file found. Setup your hosts with --set-hosts.' +elif '--set-hosts' in tmpcmdline: + if isroot(1): + PATH = '/etc/distcc' + else: + PATH = os.environ.get('HOME') + createdistccdir(PATH) + open(PATH+'/hosts', 'w').write(cmdline + '\n') +elif '--get-verbose' in tmpcmdline: + readenv('DISTCC_VERBOSE') +elif '--set-verbose' in tmpcmdline: + writeenv('DISTCC_VERBOSE',tmpcmdline[1]) +elif '--get-log' in tmpcmdline: + readenv('DISTCC_LOG') +elif '--set-log' in tmpcmdline: + writeenv('DISTCC_LOG',tmpcmdline[1]) +elif '--install' in tmpcmdline: + isroot() + print 'Creating',envfile+'...' + distcc_env = open(envfile, 'w') + distcc_env.write('# This file is managed by distcc-config; use it to change these settings.\n') + distcc_env.write('DISTCC_LOG=""\n') + distcc_env.write('DCCC_PATH="/usr/lib/distcc/bin"\n') + distcc_env.write('DISTCC_VERBOSE="0"\n') + + if os.WEXITSTATUS(commands.getstatusoutput('/usr/sbin/useradd -u 240 -g daemon -s /bin/false -d /dev/null -c "distccd" distcc')[0]) == 9: + os.WEXITSTATUS(commands.getstatusoutput('/usr/sbin/usermod -g daemon -s /bin/false -d /dev/null -c "distccd" distcc')[0]) + + foobar = pwd.getpwnam('distcc') + user = foobar[2] + group = foobar[3] + + makeconf = open('/etc/make.conf', 'r').read() + chost = re.compile('CHOST="(.*)"').search(makeconf).group(1) + print 'Creating symlinks...' + installlinks() + installlinks(chost) + + print 'Checking permissions...' + permissions('/usr/lib/distcc/bin/',user,group) + permissions('/var/run/distccd/',user,group) +elif '--get-env' in tmpcmdline: + if len(tmpcmdline) == 1: + print rstrip(open(envfile, 'r').read()) + elif len(tmpcmdline) == 2: + readenv(tmpcmdline[1]) + else: + print '!!! Error: Specify only one variable.' +elif '--set-env' in tmpcmdline: + if len(tmpcmdline) > 2 and len(tmpcmdline) <= 3: + isroot() + writeenv(tmpcmdline[1],tmpcmdline[2]) + else: + print '!!! Error: Awaiting two parameters.' +else: + print 'Usage: /usr/bin/distcc-config --set-hosts DISTCC_HOSTS | --get-hosts' + print ' /usr/bin/distcc-config --set-verbose { 0 | 1 } | --get-verbose' + print ' /usr/bin/distcc-config --set-log FILE | --get-log' + print ' /usr/bin/distcc-config --set-env VARIABLE VALUE | --get-env [VARIABLE]' diff --git a/packages/sys-devel/distcc/files/distcc-hardened.patch b/packages/sys-devel/distcc/files/distcc-hardened.patch new file mode 100644 index 0000000..69b3a65 --- /dev/null +++ b/packages/sys-devel/distcc/files/distcc-hardened.patch @@ -0,0 +1,24 @@ +From: Gordon Malm <gengor@gentoo.org> + +Make distcc client pass -D__KERNEL__ macro. Hardened GCC uses this +macro to determine if code intended to be run in-kernel is being compiled. +If the code is kernel code, certain compile flags are not applied. + +When using distcc to build kernel code (modules, etc.) without this patch, +the distccd host doesn't get passed -D__KERNEL__. Consequently, gcc on +the distccd host applies all kinds of flags that it shouldn't. + +--- distcc-2.18.3/src/strip.c ++++ distcc-2.18.3-hardened/src/strip.c +@@ -73,7 +73,10 @@ int dcc_strip_local_args(char **from, ch + /* skip through argv, copying all arguments but skipping ones that + * ought to be omitted */ + for (from_i = to_i = 0; from[from_i]; from_i++) { +- if (str_equal("-D", from[from_i]) ++ if (str_equal("-D__KERNEL__", from[from_i])) { ++ to[to_i++] = from[from_i]; ++ } ++ else if (str_equal("-D", from[from_i]) + || str_equal("-I", from[from_i]) + || str_equal("-U", from[from_i]) + || str_equal("-L", from[from_i]) diff --git a/packages/sys-devel/distcc/files/distccd.service b/packages/sys-devel/distcc/files/distccd.service new file mode 100644 index 0000000..3eb6139 --- /dev/null +++ b/packages/sys-devel/distcc/files/distccd.service @@ -0,0 +1,10 @@ +[Unit] +Description=Distccd: A Distributed Compilation Server +After=network.target + +[Service] +User=distcc +ExecStart=/usr/bin/distccd --verbose --no-detach --daemon --port 3632 -N 15 --allow $ALLOWED_SERVERS + +[Install] +WantedBy=multi-user.target diff --git a/packages/sys-devel/distcc/files/distccd.service.conf b/packages/sys-devel/distcc/files/distccd.service.conf new file mode 100644 index 0000000..a334c37 --- /dev/null +++ b/packages/sys-devel/distcc/files/distccd.service.conf @@ -0,0 +1,6 @@ +# --allow is now mandatory as of distcc-2.18. +# example: --allow 192.168.0.0/24 +# example: --allow 192.168.0.5 --allow 192.168.0.150 + +[Service] +Environment="ALLOWED_SERVERS=127.0.0.1" |