From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 035A5158086 for ; Sat, 23 Oct 2021 06:10:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D24F1E0878; Sat, 23 Oct 2021 06:10:37 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 94499E0878 for ; Sat, 23 Oct 2021 06:10:37 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C4924343230 for ; Sat, 23 Oct 2021 06:10:35 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3861A172 for ; Sat, 23 Oct 2021 06:10:34 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1634969130.3459f28f82fdf4e1da0b6ca0d24d00ce4dfd0fe7.vapier@gentoo> Subject: [gentoo-commits] proj/sandbox:master commit in: src/, libsbutil/ X-VCS-Repository: proj/sandbox X-VCS-Files: libsbutil/sbutil.h src/namespaces.c src/options.c X-VCS-Directories: src/ libsbutil/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 3459f28f82fdf4e1da0b6ca0d24d00ce4dfd0fe7 X-VCS-Branch: master Date: Sat, 23 Oct 2021 06:10:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 12115a6e-6cb3-44a4-851d-512b0257f5ab X-Archives-Hash: 1cd4949e51644d80d77aa6ad42c52de3 commit: 3459f28f82fdf4e1da0b6ca0d24d00ce4dfd0fe7 Author: Mike Frysinger gentoo org> AuthorDate: Sat Oct 23 06:05:30 2021 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sat Oct 23 06:05:30 2021 +0000 URL: https://gitweb.gentoo.org/proj/sandbox.git/commit/?id=3459f28f sandbox: add a --run-configure option When setting up sandbox on a new system for development, it helps to be able to build the new sandbox checkout in the same way as it is currently installed in the system. Add a command line option for this explicitly to speed up development. Signed-off-by: Mike Frysinger gentoo.org> libsbutil/sbutil.h | 8 ++++++++ src/namespaces.c | 7 ------- src/options.c | 23 ++++++++++++++++++++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/libsbutil/sbutil.h b/libsbutil/sbutil.h index 5194dde..d81543b 100644 --- a/libsbutil/sbutil.h +++ b/libsbutil/sbutil.h @@ -153,6 +153,14 @@ char *__xstrndup(const char *str, size_t size, const char *file, const char *fun #define xstrndup(_str, _size) __xstrndup(_str, _size, __FILE__, __func__, __LINE__) #define xalloc_die() __sb_ebort(__FILE__, __func__, __LINE__, "out of memory") +#define xasprintf(fmt, ...) \ +({ \ + int _ret = asprintf(fmt, __VA_ARGS__); \ + if (_ret == 0) \ + sb_perr("asprintf(%s) failed", #fmt); \ + _ret; \ +}) + /* string helpers */ #define streq(s1, s2) (strcmp(s1, s2) == 0) diff --git a/src/namespaces.c b/src/namespaces.c index 1f93b60..ee9f82a 100644 --- a/src/namespaces.c +++ b/src/namespaces.c @@ -26,13 +26,6 @@ #define xchmod(...) sb_assert(chmod(__VA_ARGS__) == 0) #define xsymlink(...) sb_assert(symlink(__VA_ARGS__) == 0) -#define xasprintf(fmt, ...) \ -({ \ - int _ret = asprintf(fmt, __VA_ARGS__); \ - if (_ret == 0) \ - sb_perr("asprintf(%s) failed", #fmt); \ - _ret; \ -}) #define xfopen(path, ...) \ ({ \ FILE *_ret = fopen(path, __VA_ARGS__); \ diff --git a/src/options.c b/src/options.c index 383b139..03cffda 100644 --- a/src/options.c +++ b/src/options.c @@ -50,9 +50,11 @@ static void read_config(void) } } +static const char sb_sonfigure_opts[] = SANDBOX_CONFIGURE_OPTS; + static void show_version(void) { - puts( + printf( "Gentoo path sandbox\n" " version: " PACKAGE_VERSION "\n" " C lib: " LIBC_VERSION " (" LIBC_PATH ")\n" @@ -68,8 +70,8 @@ static void show_version(void) # define SB_SCHIZO "no" #endif " schizo: " SB_SCHIZO "\n" - "\nconfigured with these options:\n" - SANDBOX_CONFIGURE_OPTS + "\nconfigured with these options:\n%s\n", + sb_sonfigure_opts ); exit(0); } @@ -99,6 +101,7 @@ static struct option const long_opts[] = { {"ns-uts-off", no_argument, &opt_use_ns_uts, false}, {"help", no_argument, NULL, 'h'}, {"version", no_argument, NULL, 'V'}, + {"run-configure", no_argument, NULL, 0x800}, {NULL, no_argument, NULL, 0x0} }; static const char * const opts_help[] = { @@ -124,6 +127,7 @@ static const char * const opts_help[] = { "Disable the use of UTS (hostname/uname) namespaces", "Print this help and exit", "Print version and exit", + "Run local sandbox configure in same way and exit (developer only)", NULL }; @@ -180,6 +184,17 @@ static void show_usage(int status) exit(status); } +static void run_configure(int argc, char *argv[]) +{ + int i; + char *cmd; + xasprintf(&cmd, "set -x; ./configure %s", sb_sonfigure_opts); + /* This doesn't need to be fast, so keep it simple. */ + for (i = optind; i < argc; ++i) + xasprintf(&cmd, "%s %s", cmd, argv[i]); + exit(system(cmd)); +} + void parseargs(int argc, char *argv[]) { int i; @@ -190,6 +205,8 @@ void parseargs(int argc, char *argv[]) show_version(); case 'h': show_usage(0); + case 0x800: + run_configure(argc, argv); case '?': show_usage(1); }