-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New package: distcc #1785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
New package: distcc #1785
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5ad37ff
New package: distcc
shawnl ca5ecb3
command-not-found for distcc
shawnl 9765973
do not require --allow to distccd (less typing on phone)
shawnl eb4b488
depend on popt
shawnl e47e7aa
use @TERMUX_PREFIX@
shawnl aae02bc
add my patches
shawnl 15ab71c
more complete cross compile patch
shawnl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| From 5eeec8310ba95b9beb3c74903a91e44bcbdc925d Mon Sep 17 00:00:00 2001 | ||
| From: Shawn Landden <slandden@gmail.com> | ||
| Date: Sat, 25 Nov 2017 23:42:43 -0800 | ||
| Subject: [PATCH] cross-compilation support | ||
|
|
||
| --- | ||
| man/distcc.1 | 5 ++++ | ||
| src/compile.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 2 files changed, 95 insertions(+) | ||
|
|
||
| diff --git a/src/compile.c b/src/compile.c | ||
| index df73e9c..936c4b3 100644 | ||
| --- a/src/compile.c | ||
| +++ b/src/compile.c | ||
| @@ -445,6 +445,92 @@ static int dcc_please_send_email_after_investigation( | ||
| return dcc_note_discrepancy(discrepancy_filename); | ||
| } | ||
|
|
||
| +/* Clang is a native cross-compiler, but needs to be told to what target it is | ||
| + * building. | ||
| + * TODO: actually probe clang with clang --version, instead of trusting | ||
| + * autoheader. | ||
| + */ | ||
| +static void dcc_add_clang_target(char **argv) | ||
| +{ | ||
| + /* defined by autoheader */ | ||
| + const char *target = GNU_HOST; | ||
| + | ||
| + if (strcmp(argv[0], "clang") == 0 || strncmp(argv[0], "clang-", strlen("clang-")) == 0 || | ||
| + strcmp(argv[0], "clang++") == 0 || strncmp(argv[0], "clang++-", strlen("clang++-")) == 0) | ||
| + ; | ||
| + else | ||
| + return; | ||
| + | ||
| + if (dcc_argv_search(argv, "-target")) | ||
| + return; | ||
| + | ||
| + rs_log_info("Adding '-target %s' to support clang cross-compilation.", | ||
| + target); | ||
| + dcc_argv_append(argv, strdup("-target")); | ||
| + dcc_argv_append(argv, strdup(target)); | ||
| +} | ||
| + | ||
| +/* | ||
| + * Cross compilation for gcc | ||
| +*/ | ||
| +static int dcc_gcc_rewrite_fqn(char **argv) | ||
| +{ | ||
| + /* defined by autoheader */ | ||
| + const char *target_with_vendor = GNU_HOST, *path; | ||
| + char *newcmd, *t; | ||
| + int pathlen = 0; | ||
| + | ||
| + if (strcmp(argv[0], "gcc") == 0 || strncmp(argv[0], "gcc-", strlen("gcc-")) == 0 || | ||
| + strcmp(argv[0], "g++") == 0 || strncmp(argv[0], "g++-", strlen("g++-")) == 0) | ||
| + ; | ||
| + else | ||
| + return -ENOENT; | ||
| + | ||
| + | ||
| + newcmd = malloc(strlen(target_with_vendor) + 1 + strlen(argv[0] + 1)); | ||
| + if (!newcmd) | ||
| + return -ENOMEM; | ||
| + | ||
| + if ((t = strstr(target_with_vendor, "-pc-"))) { | ||
| + strncpy(newcmd, target_with_vendor, t - target_with_vendor); | ||
| + strcat(newcmd, t + strlen("-pc")); | ||
| + } else | ||
| + strcpy(newcmd, target_with_vendor); | ||
| + | ||
| + | ||
| + strcat(newcmd, "-"); | ||
| + strcat(newcmd, argv[0]); | ||
| + | ||
| + /* TODO, is this the right PATH? */ | ||
| + path = getenv("PATH"); | ||
| + do { | ||
| + char *t, *binname = alloca(pathlen + 1 + strlen(newcmd) + 1); | ||
| + int r; | ||
| + | ||
| + /* emulate strchrnul() */ | ||
| + t = strchr(path, ':'); | ||
| + if (!t) | ||
| + t = path + strlen(path); | ||
| + pathlen = t - path; | ||
| + if (*path == '\0') | ||
| + return -ENOENT; | ||
| + strncpy(binname, path, pathlen); | ||
| + binname[pathlen] = '\0'; | ||
| + strcat(binname, "/"); | ||
| + strcat(binname, newcmd); | ||
| + r = access(binname, X_OK); | ||
| + if (r < 0) | ||
| + continue; | ||
| + /* good!, now rewrite */ | ||
| + rs_log_info("Re-writing call to '%s' to '%s' to support cross-compilation.", | ||
| + argv[0], newcmd); | ||
| + free(argv[0]); | ||
| + argv[0] = newcmd; | ||
| + return 0; | ||
| + } while ((path += pathlen + 1)); | ||
| + return -ENOENT; | ||
| +} | ||
| + | ||
| /** | ||
| * Execute the commands in argv remotely or locally as appropriate. | ||
| * | ||
| @@ -521,6 +607,10 @@ dcc_build_somewhere(char *argv[], | ||
| ret = dcc_scan_args(argv, &input_fname, &output_fname, &new_argv); | ||
| dcc_free_argv(argv); | ||
| argv = new_argv; | ||
| + if (!getenv("DISTCC_NO_REWRITE_CROSS")) { | ||
| + dcc_add_clang_target(new_argv); | ||
| + dcc_gcc_rewrite_fqn(new_argv); | ||
| + } | ||
| if (ret != 0) { | ||
| /* we need to scan the arguments even if we already know it's | ||
| * local, so that we can pick up distcc client options. */ | ||
| -- | ||
| 2.14.1 | ||
|
|
130 changes: 130 additions & 0 deletions
130
packages/distcc/0001-new-allow-private-option-to-allow-non-Internet-routa.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| From 4f6fc0cd50dd6987ba72e01dca58361b693bbf13 Mon Sep 17 00:00:00 2001 | ||
| From: Shawn Landden <slandden@gmail.com> | ||
| Date: Mon, 6 Nov 2017 17:59:05 -0800 | ||
| Subject: [PATCH 1/3] new --allow-private option to allow non-Internet routable | ||
| addresses | ||
|
|
||
| --- | ||
| man/distccd.1 | 4 ++++ | ||
| src/access.h | 2 ++ | ||
| src/daemon.c | 6 ++++-- | ||
| src/dopt.c | 28 +++++++++++++++++++++++++++- | ||
| 4 files changed, 37 insertions(+), 3 deletions(-) | ||
|
|
||
| diff --git a/man/distccd.1 b/man/distccd.1 | ||
| index 41596d8..86518eb 100644 | ||
| --- a/man/distccd.1 | ||
| +++ b/man/distccd.1 | ||
| @@ -147,6 +147,10 @@ match in the most significant MASK bits will be allowed. If no | ||
| connections are rejected by closing the TCP connection immediately. A | ||
| warning is logged on the server but nothing is sent to the client. | ||
| .TP | ||
| +.B --allow-private | ||
| +Allow private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, and | ||
| +127.0.0.0/8). | ||
| +.TP | ||
| .B --job-lifetime SECONDS | ||
| Kills a distccd job if it runs for more than SECONDS seconds. This prevents | ||
| denial of service from clients that don't properly disconnect and compilers | ||
| diff --git a/src/access.h b/src/access.h | ||
| index e6bd69c..c1e95ee 100644 | ||
| --- a/src/access.h | ||
| +++ b/src/access.h | ||
| @@ -20,6 +20,8 @@ | ||
| * USA. | ||
| */ | ||
|
|
||
| +#pragma once | ||
| + | ||
| #include <config.h> | ||
|
|
||
| /* access.c */ | ||
| diff --git a/src/daemon.c b/src/daemon.c | ||
| index a1056f8..545cb32 100644 | ||
| --- a/src/daemon.c | ||
| +++ b/src/daemon.c | ||
| @@ -168,8 +168,10 @@ int main(int argc, char *argv[]) | ||
| /* check this before redirecting the logs, so that it's really obvious */ | ||
| if (!dcc_should_be_inetd()) | ||
| if (opt_allowed == NULL) { | ||
| - rs_log_error("--allow option is now mandatory; " | ||
| - "you must specify which clients are allowed to connect"); | ||
| + rs_log_error("--allow or --allow-private option is now mandatory; " | ||
| + "you must specify which clients are allowed to connect." | ||
| + " Use --allow-private to allow non-Internet (globally" | ||
| + " routable) addresses."); | ||
| ret = EXIT_BAD_ARGUMENTS; | ||
| goto out; | ||
| } | ||
| diff --git a/src/dopt.c b/src/dopt.c | ||
| index 9c36daa..e38c1a3 100644 | ||
| --- a/src/dopt.c | ||
| +++ b/src/dopt.c | ||
| @@ -68,6 +68,8 @@ int arg_port = DISTCC_DEFAULT_PORT; | ||
| int arg_stats = DISTCC_DEFAULT_STATS_ENABLED; | ||
| int arg_stats_port = DISTCC_DEFAULT_STATS_PORT; | ||
|
|
||
| +int opt_allow_private = 0; | ||
| + | ||
| /** If true, serve all requests directly from listening process | ||
| without forking. Better for debugging. **/ | ||
| int opt_no_fork = 0; | ||
| @@ -115,8 +117,16 @@ enum { | ||
| int opt_zeroconf = 0; | ||
| #endif | ||
|
|
||
| + | ||
| +/*TODO: IPv6*/ | ||
| +static const char *dcc_private_networks[] = {"192.168.0.0/16", | ||
| + "10.0.0.0/8", | ||
| + "172.16.0.0/12", | ||
| + "127.0.0.0/8"}; | ||
| + | ||
| const struct poptOption options[] = { | ||
| { "allow", 'a', POPT_ARG_STRING, 0, 'a', 0, 0 }, | ||
| + { "allow-private", 0,POPT_ARG_STRING, &opt_allow_private, 0, 0, 0 }, | ||
| #ifdef HAVE_GSSAPI | ||
| { "auth", 0, POPT_ARG_NONE, &opt_auth_enabled, 'A', 0, 0 }, | ||
| { "blacklist", 0, POPT_ARG_STRING, &arg_list_file, 'b', 0, 0 }, | ||
| @@ -225,6 +235,7 @@ int distccd_parse_options(int argc, const char **argv) | ||
| { | ||
| poptContext po; | ||
| int po_err, exitcode; | ||
| + struct dcc_allow_list *new; | ||
|
|
||
| po = poptGetContext("distccd", argc, argv, options, 0); | ||
|
|
||
| @@ -238,7 +249,6 @@ int distccd_parse_options(int argc, const char **argv) | ||
| case 'a': { | ||
| /* TODO: Allow this to be a hostname, which is resolved to an address. */ | ||
| /* TODO: Split this into a small function. */ | ||
| - struct dcc_allow_list *new; | ||
| new = malloc(sizeof *new); | ||
| if (!new) { | ||
| rs_log_crit("malloc failed"); | ||
| @@ -367,6 +377,22 @@ int distccd_parse_options(int argc, const char **argv) | ||
| } | ||
| } | ||
|
|
||
| + if (opt_allow_private) { | ||
| + int i; | ||
| + for (i = 0;i<3;i++) { | ||
| + new = malloc(sizeof *new); | ||
| + if (!new) { | ||
| + rs_log_crit("malloc failed"); | ||
| + exitcode = EXIT_OUT_OF_MEMORY; | ||
| + goto out_exit; | ||
| + } | ||
| + new->next = opt_allowed; | ||
| + opt_allowed = new; | ||
| + if ((exitcode = dcc_parse_mask(dcc_private_networks[i], &new->addr, &new->mask))) | ||
| + goto out_exit; | ||
| + } | ||
| + } | ||
| + | ||
| poptFreeContext(po); | ||
| return 0; | ||
|
|
||
| -- | ||
| 2.14.1 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| From 18b9faf205314f5f9329dff9c3f0b5c295384580 Mon Sep 17 00:00:00 2001 | ||
| From: Shawn Landden <slandden@gmail.com> | ||
| Date: Sun, 19 Nov 2017 16:31:13 -0800 | ||
| Subject: [PATCH 2/3] make --allow-private the default | ||
|
|
||
| --- | ||
| src/daemon.c | 8 +++----- | ||
| src/dopt.c | 4 ++-- | ||
| src/dopt.h | 1 + | ||
| 3 files changed, 6 insertions(+), 7 deletions(-) | ||
|
|
||
| diff --git a/src/daemon.c b/src/daemon.c | ||
| index 545cb32..b3e269c 100644 | ||
| --- a/src/daemon.c | ||
| +++ b/src/daemon.c | ||
| @@ -168,12 +168,10 @@ int main(int argc, char *argv[]) | ||
| /* check this before redirecting the logs, so that it's really obvious */ | ||
| if (!dcc_should_be_inetd()) | ||
| if (opt_allowed == NULL) { | ||
| - rs_log_error("--allow or --allow-private option is now mandatory; " | ||
| - "you must specify which clients are allowed to connect." | ||
| - " Use --allow-private to allow non-Internet (globally" | ||
| + rs_log_warning("No --allow option specified. Defaulting to --allow-private." | ||
| + " Allowing non-Internet (globally" | ||
| " routable) addresses."); | ||
| - ret = EXIT_BAD_ARGUMENTS; | ||
| - goto out; | ||
| + opt_allow_private = 1; | ||
| } | ||
|
|
||
| if ((ret = dcc_set_lifetime()) != 0) | ||
| diff --git a/src/dopt.c b/src/dopt.c | ||
| index e38c1a3..602b0af 100644 | ||
| --- a/src/dopt.c | ||
| +++ b/src/dopt.c | ||
| @@ -68,8 +68,6 @@ int arg_port = DISTCC_DEFAULT_PORT; | ||
| int arg_stats = DISTCC_DEFAULT_STATS_ENABLED; | ||
| int arg_stats_port = DISTCC_DEFAULT_STATS_PORT; | ||
|
|
||
| -int opt_allow_private = 0; | ||
| - | ||
| /** If true, serve all requests directly from listening process | ||
| without forking. Better for debugging. **/ | ||
| int opt_no_fork = 0; | ||
| @@ -83,6 +81,8 @@ char *opt_listen_addr = NULL; | ||
|
|
||
| struct dcc_allow_list *opt_allowed = NULL; | ||
|
|
||
| +int opt_allow_private = 0; | ||
| + | ||
| /** | ||
| * If true, don't detach from the parent. This is probably necessary | ||
| * for use with daemontools or other monitoring programs, and is also | ||
| diff --git a/src/dopt.h b/src/dopt.h | ||
| index 695bc1e..5064a11 100644 | ||
| --- a/src/dopt.h | ||
| +++ b/src/dopt.h | ||
| @@ -24,6 +24,7 @@ | ||
|
|
||
| /* dopt.c */ | ||
| extern struct dcc_allow_list *opt_allowed; | ||
| +extern int opt_allow_private; | ||
| int distccd_parse_options(int argc, const char *argv[]); | ||
|
|
||
| extern int arg_port; | ||
| -- | ||
| 2.14.1 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| diff --git a/Makefile.in b/Makefile.in | ||
| index 3ea595c..0fb1efd 100644 | ||
| --- a/Makefile.in | ||
| +++ b/Makefile.in | ||
| @@ -21,7 +21,7 @@ PYTHON_CFLAGS = @PYTHON_CFLAGS@ | ||
| POPT_CFLAGS = @POPT_CFLAGS@ | ||
| POPT_INCLUDES = @POPT_INCLUDES@ | ||
|
|
||
| -LDFLAGS = @LDFLAGS@ | ||
| +LDFLAGS = @LDFLAGS@ -llog -pie | ||
| CC = @CC@ | ||
| CPP = @CPP@ | ||
| # We add a few cppflags. -Isrc is so that config.h can be found in the build | ||
| @@ -67,7 +67,7 @@ GNOME_LIBS = @GNOME_LIBS@ | ||
|
|
||
| LIBS = @LIBS@ | ||
|
|
||
| -DESTDIR = | ||
| +DESTDIR = @TERMUX_PREFIX@ | ||
|
|
||
| INSTALL = @INSTALL@ | ||
| INSTALL_PROGRAM = @INSTALL_PROGRAM@ | ||
| @@ -85,7 +85,7 @@ RESTRICTED_PATH = /usr/local/bin:/bin:/usr/bin | ||
| # directory names of possible locations for the installation to be | ||
| # checked. Change the value of this variable to @bindir@ to check the | ||
| # installation at the location determined by 'configure'. | ||
| -DISTCC_INSTALLATION = $(RESTRICTED_PATH) | ||
| +DISTCC_INSTALLATION = @bindir@ | ||
|
|
||
| dist_files = \ | ||
| src/config.h.in \ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| TERMUX_PKG_HOMEPAGE=http://distcc.org/ | ||
| TERMUX_PKG_DESCRIPTION="Distributed C/C++ compiler." | ||
| TERMUX_PKG_VERSION=3.2-rc1 | ||
| TERMUX_PKG_REVISION=1 | ||
| TERMUX_PKG_SHA256=8cf474b9e20f5f3608888c6bff1b5f804a9dfc69ae9704e3d5bdc92f0487760a | ||
| TERMUX_PKG_SRCURL=https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/distcc/distcc-3.2rc1.tar.gz | ||
| TERMUX_PKG_BUILD_IN_SRC=yes | ||
| TERMUX_PKG_DEPENDS=libpopt | ||
|
|
||
| termux_step_configure () { | ||
| #the configure script checks if $PYTHON is executable | ||
| PYTHON=/etc/hosts sh ./configure -disable-Werror --without-libiberty --prefix=/ --host `dpkg-architecture -q DEB_HOST_GNU_TYPE` | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might want to consider morving to github's archives https://github.com/distcc/distcc/archive/v3.2rc1.tar.gz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
github archives suffer from distcc/distcc#237
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about adding this step to get around
termux_step_pre_configure() { ./autogen.sh }