diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | lua/lua_bindings.c | 8 | ||||
-rw-r--r-- | preload/libsb2.c | 20 | ||||
-rwxr-xr-x | utils/sb2 | 2 | ||||
-rw-r--r-- | utils/sb_gcc_wrapper.cc | 11 |
5 files changed, 37 insertions, 10 deletions
@@ -26,6 +26,8 @@ build: configure $(ll_toplevel_build) @echo Build completed successfully! +gcc_bins = addr2line,ar,as,cc,c++,c++filt,cpp,g++,gcc,gcov,gdb,gdbtui,gprof,ld,nm,objcopy,objdump,ranlib,rdi-stub,readelf,run,size,strings,strip + install: build install -d -m 755 $(prefix)/bin install -d -m 755 $(prefix)/lib @@ -38,7 +40,9 @@ install: build install -c -m 644 redir_scripts/main.lua $(prefix)/share/scratchbox2/redir_scripts/main.lua install -c -m 644 redir_scripts/parts/default.lua $(prefix)/share/scratchbox2/redir_scripts/parts/default.lua install -c -m 644 etc/sb2.config.sample $(prefix)/share/scratchbox2/sb2.config.sample - + @for f in $(prefix)/bin/host-{$(gcc_bins)}; do \ + ln -sf sb_gcc_wrapper $$f; \ + done CLEAN_FILES = $(targets) diff --git a/lua/lua_bindings.c b/lua/lua_bindings.c index c711b66..1969118 100644 --- a/lua/lua_bindings.c +++ b/lua/lua_bindings.c @@ -389,13 +389,15 @@ char *scratchbox_path(const char *func_name, const char *path) char pidlink[17]; /* /proc/2^8/exe */ if (!path) return NULL; + if (getenv("SBOX_DISABLE_MAPPING")) { + return strdup(path); + } decolon_path = decolonize_path(path); - if (strstr(decolon_path, getenv("SBOX_TARGET_ROOT")) - || strstr(decolon_path, getenv("HOME"))) { + if (strstr(decolon_path, getenv("SBOX_TARGET_ROOT"))) { /* short circuit a direct reference to a file inside the sbox - * target dir, or to $HOME dir */ + * target dir */ //DBGOUT("about to short circuit: %s\n", func_name); free(decolon_path); return strdup(path); diff --git a/preload/libsb2.c b/preload/libsb2.c index 300aa52..1a27517 100644 --- a/preload/libsb2.c +++ b/preload/libsb2.c @@ -786,7 +786,7 @@ _out: static int is_gcc_tool(char *fname) { - unsigned int i, index, start, c; + unsigned int i, index, start, c, len; char *t; char **gcc_prefixes; char **p; @@ -818,7 +818,19 @@ static int is_gcc_tool(char *fname) NULL }; char **tmp; - t = getenv("SBOX_CROSS_GCC_PREFIX_LIST"); + if (!getenv("SBOX_CROSS_GCC_PREFIX_LIST") + ||!getenv("SBOX_HOST_GCC_PREFIX_LIST")) { + return 0; + } + + len = strlen(getenv("SBOX_CROSS_GCC_PREFIX_LIST")); + len += 1 + strlen(getenv("SBOX_HOST_GCC_PREFIX_LIST")); + t = malloc((len + 1) * sizeof(char)); + + strcpy(t, getenv("SBOX_CROSS_GCC_PREFIX_LIST")); + strcat(t, ":"); + strcat(t, getenv("SBOX_HOST_GCC_PREFIX_LIST")); + //DBGOUT("here we are: [%s]\n", t); if (!t) { return 0; } @@ -890,6 +902,10 @@ static int do_exec(const char *file, char *const *argv, char *const *envp) if (next_execve == NULL) fakechroot_init(); + if (getenv("SBOX_DISABLE_MAPPING")) { + /* just run it, don't worry, be happy! */ + return next_execve(file, argv, envp); + } enum binary_type type = inspect_binary(file); binaryname = strdup(basename(file)); @@ -27,6 +27,7 @@ export SBOX_LIBSB2 SBOX_REDIR_SCRIPTS SBOX_TARGET_ROOT SBOX_GCCWRAPPER SBOX_TARG cd $SBOX_TARGET_ROOT +export PATH=$PATH:$SBOX_DIR/bin export LD_PRELOAD=$SBOX_LIBSB2 export SBOX_SCRATCHBOX_CONFIG=$SBOX_TARGET_ROOT/sb2.config export PS1="[SB2] \u@\h \w \$ " @@ -44,6 +45,7 @@ echo "SBOX_TARGET_ROOT = $SBOX_TARGET_ROOT" export SBOX_COMPILER_ROOT=$(readlink -f $SBOX_CROSS_GCC_DIR/..) export SBOX_CPUTRANSPARENCY_METHOD export SBOX_CROSS_GCC_PREFIX_LIST +export SBOX_HOST_GCC_PREFIX_LIST export SBOX_UNAME_MACHINE=$SBOX_CPU if [ -z "$*" ]; then diff --git a/utils/sb_gcc_wrapper.cc b/utils/sb_gcc_wrapper.cc index ed40502..265b2ae 100644 --- a/utils/sb_gcc_wrapper.cc +++ b/utils/sb_gcc_wrapper.cc @@ -68,7 +68,6 @@ static void init_compilers() host_gcc.name = config["SBOX_HOST_GCC_NAME"]; host_gcc.prefix_list = sb::split(config["SBOX_HOST_GCC_PREFIX_LIST"]); host_gcc.subst_prefix = config["SBOX_HOST_GCC_SUBST_PREFIX"]; - host_gcc.specs_file = config["SBOX_HOST_GCC_SPECS_FILE"]; host_gcc.dir = config["SBOX_HOST_GCC_DIR"]; host_gcc.ld_args = config["SBOX_HOST_GCC_LD_ARGS"]; @@ -171,10 +170,14 @@ static Program *detect_program(const char *const name, const Group group) prog = new Program(group[i], default_gcc); break; } - - if ((prog = detect_program(name, group[i], cross_gcc)) || - (prog = detect_program(name, group[i], host_gcc ))) + + if ((prog = detect_program(name, group[i], cross_gcc))) { + break; + } + if ((prog = detect_program(name, group[i], host_gcc ))) { + setenv("SBOX_DISABLE_MAPPING", "1", 1); break; + } } if (prog) |