diff --git a/configure.ac b/configure.ac index 84f21c5d..6f73d645 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ AC_PROG_MAKE_SET AC_CHECK_LIB([dl], [dlsym]) PKG_CHECK_MODULES([lua], lua >= 5.2.0) -PKG_CHECK_VAR(LUA_VERSION_MAJOR_MINOR, [lua], [V]) +LUA_VERSION_MAJOR_MINOR=$($PKG_CONFIG --modversion lua | cut -d. -f1,2) PKG_CHECK_VAR(LUA_LIBDIR, [lua], [libdir], [ m4_foreach([lua_module], [[posix]], @@ -164,6 +164,7 @@ setenv \ setxattr \ stat \ stat64 \ +statx \ strchrnul \ symlink \ symlinkat \ diff --git a/execs/Makefile b/execs/Makefile index 253f01d8..8f340ff2 100644 --- a/execs/Makefile +++ b/execs/Makefile @@ -10,7 +10,7 @@ objs := $(D)/exec_ruletree_maint.o \ $(D)/sb_exec.o: preload/exported.h execs/libexecs.a: $(objs) -execs/libexecs.a: override CFLAGS := $(CFLAGS) -O2 -g -fPIC -Wall -W -I$(SRCDIR)/$(LUASRC) -I$(OBJDIR)/preload -I$(SRCDIR)/preload -I$(SRCDIR)/execs \ +execs/libexecs.a: override CFLAGS := $(CFLAGS) $(LUA_CFLAGS) -O2 -g -fPIC -Wall -W -I$(SRCDIR)/$(LUASRC) -I$(OBJDIR)/preload -I$(SRCDIR)/preload -I$(SRCDIR)/execs \ $(WERROR) -Wmissing-prototypes -Wstrict-prototypes execs/libexecs.a: override LDFLAGS := $(LDFLAGS) execs/libexecs.a: override LIBS := diff --git a/include/sb2_stat.h b/include/sb2_stat.h index ebb8c917..bcf14f32 100644 --- a/include/sb2_stat.h +++ b/include/sb2_stat.h @@ -24,6 +24,10 @@ extern int real_fstatat64(int dirfd, const char *path, struct stat64 *statbuf, i extern int i_virtualize_struct_stat(const char *realfnname, struct stat *buf, struct stat64 *buf64); +#ifdef HAVE_STATX +extern int i_virtualize_struct_statx(const char *realfnname, struct statx *bufx); +#endif + extern int sb2_stat_file(const char *path, struct stat *buf, int *result_errno_ptr, int (*statfn_with_ver_ptr)(int ver, const char *filename, struct stat *buf), int ver, diff --git a/lua_scripts/add_rules_to_rule_tree.lua b/lua_scripts/add_rules_to_rule_tree.lua index 2d842ef9..2d5e7eef 100644 --- a/lua_scripts/add_rules_to_rule_tree.lua +++ b/lua_scripts/add_rules_to_rule_tree.lua @@ -311,6 +311,7 @@ local valid_keywords_in_exec_policy = { native_app_ld_library_path_prefix = "string", native_app_ld_library_path_suffix = "string", native_app_ld_preload_prefix = "string", + native_app_ld_preload_suffix = "string", native_app_ld_so = "string", native_app_ld_so_rpath_prefix = "string", diff --git a/lua_scripts/argvenvp_gcc.lua b/lua_scripts/argvenvp_gcc.lua index 9db58df9..d71d03c4 100644 --- a/lua_scripts/argvenvp_gcc.lua +++ b/lua_scripts/argvenvp_gcc.lua @@ -14,7 +14,10 @@ gcc_compilers = { "g++", "cpp", "f77", - "g77" + "g77", + "gccgo", + "go.gcc", + "gofmt.gcc" } compiler_alternative_name = { diff --git a/luaif/Makefile b/luaif/Makefile index 00755f1b..c2c8a72d 100644 --- a/luaif/Makefile +++ b/luaif/Makefile @@ -6,8 +6,8 @@ objs := $(D)/sblib_luaif.o $(D)/sblib_luaif.o: preload/exported.h luaif/libluaif.a: $(objs) -luaif/libluaif.a: override CFLAGS := $(CFLAGS) -O2 -g -fPIC -Wall -W -I$(OBJDIR)/preload -I$(SRCDIR)/preload \ - $(WERROR) -Wmissing-prototypes -Wstrict-prototypes $(LUA_CFLAGS) +luaif/libluaif.a: override CFLAGS := $(CFLAGS) $(LUA_CFLAGS) -O2 -g -fPIC -Wall -W -I$(OBJDIR)/preload -I$(SRCDIR)/preload \ + $(WERROR) -Wmissing-prototypes -Wstrict-prototypes luaif/libluaif.a: override LDFLAGS := $(LDFLAGS) luaif/libluaif.a: override LIBS := $(LUA_LIBS) diff --git a/modes/accel/exec_rules.lua b/modes/accel/exec_rules.lua index 7352f34c..402c9192 100644 --- a/modes/accel/exec_rules.lua +++ b/modes/accel/exec_rules.lua @@ -72,7 +72,7 @@ exec_policy_tools = { native_app_ld_library_path_prefix = devel_mode_tools_ld_library_path_prefix, native_app_ld_library_path_suffix = devel_mode_tools_ld_library_path_suffix, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, native_app_locale_path = devel_mode_locale_path, native_app_gconv_path = devel_mode_gconv_path, @@ -94,7 +94,7 @@ exec_policy_tools_perl = { native_app_ld_library_path_prefix = devel_mode_tools_ld_library_path_prefix, native_app_ld_library_path_suffix = devel_mode_tools_ld_library_path_suffix, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, native_app_locale_path = devel_mode_locale_path, native_app_gconv_path = devel_mode_gconv_path, @@ -116,7 +116,7 @@ exec_policy_tools_python = { native_app_ld_library_path_prefix = devel_mode_tools_ld_library_path_prefix, native_app_ld_library_path_suffix = devel_mode_tools_ld_library_path_suffix, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, native_app_locale_path = devel_mode_locale_path, native_app_gconv_path = devel_mode_gconv_path, @@ -169,7 +169,7 @@ exec_policy_target = { native_app_locale_path = conf_target_locale_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, native_app_ld_library_path_prefix = devel_mode_target_ld_library_path_prefix, native_app_ld_library_path_suffix = devel_mode_target_ld_library_path_suffix, diff --git a/modes/emulate+toolchain+utils/exec_rules.lua b/modes/emulate+toolchain+utils/exec_rules.lua index 5df28342..e680cb5a 100644 --- a/modes/emulate+toolchain+utils/exec_rules.lua +++ b/modes/emulate+toolchain+utils/exec_rules.lua @@ -11,12 +11,12 @@ rule_file_interface_version = "203" exec_policy_host = { name = "Host", - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } exec_policy_toolchain = { name = "Toolchain", - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } -- For target binaries: @@ -64,7 +64,7 @@ local exec_policy_target = { native_app_locale_path = conf_target_locale_path, native_app_gconv_path = conf_target_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, exec_flags = EXEC_FLAGS_FORCE_CPU_TRANSPARENCY, } @@ -115,7 +115,7 @@ local exec_policy_tools = { native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } diff --git a/modes/emulate+toolchain/exec_rules.lua b/modes/emulate+toolchain/exec_rules.lua index 5df28342..e680cb5a 100644 --- a/modes/emulate+toolchain/exec_rules.lua +++ b/modes/emulate+toolchain/exec_rules.lua @@ -11,12 +11,12 @@ rule_file_interface_version = "203" exec_policy_host = { name = "Host", - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } exec_policy_toolchain = { name = "Toolchain", - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } -- For target binaries: @@ -64,7 +64,7 @@ local exec_policy_target = { native_app_locale_path = conf_target_locale_path, native_app_gconv_path = conf_target_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, exec_flags = EXEC_FLAGS_FORCE_CPU_TRANSPARENCY, } @@ -115,7 +115,7 @@ local exec_policy_tools = { native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } diff --git a/modes/emulate/exec_rules.lua b/modes/emulate/exec_rules.lua index 80105cb2..7d44bf1e 100644 --- a/modes/emulate/exec_rules.lua +++ b/modes/emulate/exec_rules.lua @@ -11,7 +11,7 @@ rule_file_interface_version = "203" exec_policy_host = { name = "Host", - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } -- For target binaries: @@ -59,7 +59,7 @@ local exec_policy_target = { native_app_locale_path = conf_target_locale_path, native_app_gconv_path = conf_target_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, exec_flags = EXEC_FLAGS_FORCE_CPU_TRANSPARENCY, } @@ -110,7 +110,7 @@ local exec_policy_tools = { native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } diff --git a/modes/obs-deb-build/exec_rules.lua b/modes/obs-deb-build/exec_rules.lua index 68c365d3..94e281d4 100644 --- a/modes/obs-deb-build/exec_rules.lua +++ b/modes/obs-deb-build/exec_rules.lua @@ -15,12 +15,12 @@ rule_file_interface_version = "203" exec_policy_host = { name = "Host", - native_app_ld_preload_prefix = host_ld_preload_libsb2, + native_app_ld_preload_suffix = host_ld_preload_libsb2, } exec_policy_toolchain = { name = "Toolchain", - native_app_ld_preload_prefix = host_ld_preload_libsb2, + native_app_ld_preload_suffix = host_ld_preload_libsb2, } -- For target binaries: @@ -68,7 +68,7 @@ local exec_policy_target = { native_app_locale_path = conf_target_locale_path, native_app_gconv_path = conf_target_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } -- @@ -121,7 +121,7 @@ local exec_policy_tools = { native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, script_log_level = "debug", script_log_message = "SCRIPT from tools", @@ -140,7 +140,7 @@ local exec_policy_tools_perl = { native_app_ld_library_path_prefix = emulate_mode_tools_ld_library_path_prefix, native_app_ld_library_path_suffix = emulate_mode_tools_ld_library_path_suffix, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, @@ -162,7 +162,7 @@ local exec_policy_tools_python = { native_app_ld_library_path_prefix = emulate_mode_tools_ld_library_path_prefix, native_app_ld_library_path_suffix = emulate_mode_tools_ld_library_path_suffix, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, diff --git a/modes/obs-deb-build/sb2rc b/modes/obs-deb-build/sb2rc index c8928b66..3f244a36 100644 --- a/modes/obs-deb-build/sb2rc +++ b/modes/obs-deb-build/sb2rc @@ -39,6 +39,14 @@ case "$sb2rc_mode" in SBOX_WRAPPERS="gdb ldconfig pwd fakeroot" ;; + ldconfig) + # When ldconfig is used at build time, then it must be the case + # that it is used on the build artefacts (with the help of the + # '-n' option), so locking it to the target root would not be + # desired. + sbox_ldconfig_root=/ + ;; + *) # Default. ;; diff --git a/modes/obs-deb-install/exec_rules.lua b/modes/obs-deb-install/exec_rules.lua index 6aef37ac..af8909f7 100644 --- a/modes/obs-deb-install/exec_rules.lua +++ b/modes/obs-deb-install/exec_rules.lua @@ -16,12 +16,12 @@ rule_file_interface_version = "203" exec_policy_host = { name = "Host", - native_app_ld_preload_prefix = host_ld_preload_libsb2, + native_app_ld_preload_suffix = host_ld_preload_libsb2, } exec_policy_toolchain = { name = "Toolchain", - native_app_ld_preload_prefix = host_ld_preload_libsb2, + native_app_ld_preload_suffix = host_ld_preload_libsb2, } -- For target binaries: @@ -69,7 +69,7 @@ local exec_policy_target = { native_app_locale_path = conf_target_locale_path, native_app_gconv_path = conf_target_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } -- @@ -118,7 +118,7 @@ local exec_policy_tools = { native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } diff --git a/modes/obs-rpm-build+pp/exec_rules.lua b/modes/obs-rpm-build+pp/exec_rules.lua index 2043549e..0ee49c21 100644 --- a/modes/obs-rpm-build+pp/exec_rules.lua +++ b/modes/obs-rpm-build+pp/exec_rules.lua @@ -11,12 +11,12 @@ rule_file_interface_version = "203" exec_policy_host = { name = "Host", - native_app_ld_preload_prefix = host_ld_preload_libsb2, + native_app_ld_preload_suffix = host_ld_preload_libsb2, } exec_policy_toolchain = { name = "Toolchain", - native_app_ld_preload_prefix = host_ld_preload_libsb2, + native_app_ld_preload_suffix = host_ld_preload_libsb2, } -- For target binaries: @@ -64,7 +64,7 @@ local exec_policy_target = { native_app_locale_path = conf_target_locale_path, native_app_gconv_path = conf_target_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } -- @@ -117,7 +117,7 @@ local exec_policy_tools = { native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, script_log_level = "debug", script_log_message = "SCRIPT from tools", @@ -136,7 +136,7 @@ local exec_policy_tools_perl = { native_app_ld_library_path_prefix = emulate_mode_tools_ld_library_path_prefix, native_app_ld_library_path_suffix = emulate_mode_tools_ld_library_path_suffix, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, @@ -158,7 +158,7 @@ local exec_policy_tools_python = { native_app_ld_library_path_prefix = emulate_mode_tools_ld_library_path_prefix, native_app_ld_library_path_suffix = emulate_mode_tools_ld_library_path_suffix, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, diff --git a/modes/obs-rpm-build+pp/fs_rules.lua b/modes/obs-rpm-build+pp/fs_rules.lua index 016a6aa0..bd2b91cf 100644 --- a/modes/obs-rpm-build+pp/fs_rules.lua +++ b/modes/obs-rpm-build+pp/fs_rules.lua @@ -171,9 +171,9 @@ emulate_mode_rules_bin = { actions=accelerated_program_actions}, {path="/bin/egrep", actions=accelerated_program_actions}, - {path="/bin/false", + {path="/bin/env", actions=accelerated_program_actions}, - {path="/bin/fgrep", + {path="/bin/false", actions=accelerated_program_actions}, {path="/bin/fgrep", actions=accelerated_program_actions}, @@ -213,7 +213,7 @@ emulate_mode_rules_bin = { actions=accelerated_program_actions}, {path="/bin/sort", actions=accelerated_program_actions}, - {path="/usr/bin/tar", + {path="/bin/tar", actions=accelerated_program_actions}, {path="/bin/touch", actions=accelerated_program_actions}, @@ -240,6 +240,8 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/basename", actions=accelerated_program_actions}, + {path="/usr/bin/bash", + actions=accelerated_program_actions}, {path="/usr/bin/bison", actions=accelerated_program_actions}, {path="/usr/bin/bzip2", @@ -258,8 +260,6 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/diff3", actions=accelerated_program_actions}, - {path="/usr/bin/diff3", - actions=accelerated_program_actions}, {path="/usr/bin/dir", actions=accelerated_program_actions}, {path="/usr/bin/dircolors", @@ -390,6 +390,8 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/seq", actions=accelerated_program_actions}, + {path="/usr/bin/sh", + actions=accelerated_program_actions}, {path="/usr/bin/sha1sum", actions=accelerated_program_actions}, {path="/usr/bin/sha224sum", @@ -416,6 +418,8 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/tail", actions=accelerated_program_actions}, + {path="/usr/bin/tar", + actions=accelerated_program_actions}, {path="/usr/bin/tee", actions=accelerated_program_actions}, {path="/usr/bin/test", @@ -424,8 +428,6 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/troff", actions=accelerated_program_actions}, - {path="/usr/bin/troff", - actions=accelerated_program_actions}, {path="/usr/bin/tsort", actions=accelerated_program_actions}, {path="/usr/bin/tty", @@ -454,7 +456,7 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/ccache", func_class = FUNC_CLASS_EXEC, - actions=accelerated_program_actions}, + actions=conditionally_accelerated_program_actions}, {path="/usr/bin/qtchooser", func_class = FUNC_CLASS_EXEC, actions=accelerated_program_actions}, diff --git a/modes/obs-rpm-build+pp/sb2rc b/modes/obs-rpm-build+pp/sb2rc index c8928b66..3f244a36 100644 --- a/modes/obs-rpm-build+pp/sb2rc +++ b/modes/obs-rpm-build+pp/sb2rc @@ -39,6 +39,14 @@ case "$sb2rc_mode" in SBOX_WRAPPERS="gdb ldconfig pwd fakeroot" ;; + ldconfig) + # When ldconfig is used at build time, then it must be the case + # that it is used on the build artefacts (with the help of the + # '-n' option), so locking it to the target root would not be + # desired. + sbox_ldconfig_root=/ + ;; + *) # Default. ;; diff --git a/modes/obs-rpm-build/exec_rules.lua b/modes/obs-rpm-build/exec_rules.lua index 10c4fdb1..ad6149c0 100644 --- a/modes/obs-rpm-build/exec_rules.lua +++ b/modes/obs-rpm-build/exec_rules.lua @@ -12,12 +12,12 @@ rule_file_interface_version = "203" exec_policy_host = { name = "Host", - native_app_ld_preload_prefix = host_ld_preload_libsb2, + native_app_ld_preload_suffix = host_ld_preload_libsb2, } exec_policy_toolchain = { name = "Toolchain", - native_app_ld_preload_prefix = host_ld_preload_libsb2, + native_app_ld_preload_suffix = host_ld_preload_libsb2, } -- For target binaries: @@ -65,7 +65,7 @@ local exec_policy_target = { native_app_locale_path = conf_target_locale_path, native_app_gconv_path = conf_target_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } -- @@ -114,7 +114,7 @@ local exec_policy_tools = { native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } diff --git a/modes/obs-rpm-build/fs_rules.lua b/modes/obs-rpm-build/fs_rules.lua index 9b61c6a7..f7a41d69 100644 --- a/modes/obs-rpm-build/fs_rules.lua +++ b/modes/obs-rpm-build/fs_rules.lua @@ -96,9 +96,9 @@ emulate_mode_rules_bin = { actions=accelerated_program_actions}, {path="/bin/egrep", actions=accelerated_program_actions}, - {path="/bin/false", + {path="/bin/env", actions=accelerated_program_actions}, - {path="/bin/fgrep", + {path="/bin/false", actions=accelerated_program_actions}, {path="/bin/fgrep", actions=accelerated_program_actions}, @@ -138,7 +138,7 @@ emulate_mode_rules_bin = { actions=accelerated_program_actions}, {path="/bin/sort", actions=accelerated_program_actions}, - {path="/usr/bin/tar", + {path="/bin/tar", actions=accelerated_program_actions}, {path="/bin/touch", actions=accelerated_program_actions}, @@ -165,6 +165,8 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/basename", actions=accelerated_program_actions}, + {path="/usr/bin/bash", + actions=accelerated_program_actions}, {path="/usr/bin/bison", actions=accelerated_program_actions}, {path="/usr/bin/bzip2", @@ -183,8 +185,6 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/diff3", actions=accelerated_program_actions}, - {path="/usr/bin/diff3", - actions=accelerated_program_actions}, {path="/usr/bin/dir", actions=accelerated_program_actions}, {path="/usr/bin/dircolors", @@ -235,10 +235,6 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/fgrep", actions=accelerated_program_actions}, - {path="/usr/bin/fdupes", - actions=accelerated_program_actions}, - {path="/usr/bin/fgrep", - actions=accelerated_program_actions}, {path="/usr/bin/file", actions=accelerated_program_actions}, {path="/usr/bin/find", @@ -257,10 +253,6 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/grotty", actions=accelerated_program_actions}, - {path="/usr/bin/groff", - actions=accelerated_program_actions}, - {path="/usr/bin/grotty", - actions=accelerated_program_actions}, {path="/usr/bin/gtbl", actions=accelerated_program_actions}, {path="/usr/bin/gzip", @@ -315,6 +307,8 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/seq", actions=accelerated_program_actions}, + {path="/usr/bin/sh", + actions=accelerated_program_actions}, {path="/usr/bin/sha1sum", actions=accelerated_program_actions}, {path="/usr/bin/sha224sum", @@ -339,6 +333,8 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/tac", actions=accelerated_program_actions}, + {path="/usr/bin/tar", + actions=accelerated_program_actions}, {path="/usr/bin/tail", actions=accelerated_program_actions}, {path="/usr/bin/tee", @@ -349,8 +345,6 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/troff", actions=accelerated_program_actions}, - {path="/usr/bin/troff", - actions=accelerated_program_actions}, {path="/usr/bin/tsort", actions=accelerated_program_actions}, {path="/usr/bin/tty", @@ -379,7 +373,7 @@ emulate_mode_rules_usr_bin = { actions=accelerated_program_actions}, {path="/usr/bin/ccache", func_class = FUNC_CLASS_EXEC, - actions=accelerated_program_actions}, + actions=conditionally_accelerated_program_actions}, {path="/usr/bin/qtchooser", func_class = FUNC_CLASS_EXEC, actions=accelerated_program_actions}, diff --git a/modes/obs-rpm-build/sb2rc b/modes/obs-rpm-build/sb2rc index c8928b66..3f244a36 100644 --- a/modes/obs-rpm-build/sb2rc +++ b/modes/obs-rpm-build/sb2rc @@ -39,6 +39,14 @@ case "$sb2rc_mode" in SBOX_WRAPPERS="gdb ldconfig pwd fakeroot" ;; + ldconfig) + # When ldconfig is used at build time, then it must be the case + # that it is used on the build artefacts (with the help of the + # '-n' option), so locking it to the target root would not be + # desired. + sbox_ldconfig_root=/ + ;; + *) # Default. ;; diff --git a/modes/obs-rpm-install/exec_rules.lua b/modes/obs-rpm-install/exec_rules.lua index d7bccf85..7312cae3 100644 --- a/modes/obs-rpm-install/exec_rules.lua +++ b/modes/obs-rpm-install/exec_rules.lua @@ -12,12 +12,12 @@ rule_file_interface_version = "203" exec_policy_host = { name = "Host", - native_app_ld_preload_prefix = host_ld_preload_libsb2, + native_app_ld_preload_suffix = host_ld_preload_libsb2, } exec_policy_toolchain = { name = "Toolchain", - native_app_ld_preload_prefix = host_ld_preload_libsb2, + native_app_ld_preload_suffix = host_ld_preload_libsb2, } -- For target binaries: @@ -65,7 +65,7 @@ local exec_policy_target = { native_app_locale_path = conf_target_locale_path, native_app_gconv_path = conf_target_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } -- @@ -114,7 +114,7 @@ local exec_policy_tools = { native_app_locale_path = conf_tools_locale_path, native_app_gconv_path = conf_tools_gconv_path, - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } diff --git a/modes/obs-rpm-install/fs_rules.lua b/modes/obs-rpm-install/fs_rules.lua index 62cc47d9..9c07e8bd 100644 --- a/modes/obs-rpm-install/fs_rules.lua +++ b/modes/obs-rpm-install/fs_rules.lua @@ -192,6 +192,13 @@ emulate_mode_rules_bin = { } emulate_mode_rules_usr_bin = { + {path = "/usr/bin/sh", + func_class = FUNC_CLASS_EXEC, + actions = accelerated_program_actions}, + {path = "/usr/bin/bash", + func_class = FUNC_CLASS_EXEC, + actions = accelerated_program_actions}, + {path = "/usr/bin/find", func_class = FUNC_CLASS_EXEC, actions = accelerated_program_actions}, diff --git a/modes/simple/exec_rules.lua b/modes/simple/exec_rules.lua index 591099e5..9cebacba 100644 --- a/modes/simple/exec_rules.lua +++ b/modes/simple/exec_rules.lua @@ -21,7 +21,7 @@ end default_exec_policy = { name = "Default", - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, native_app_ld_library_path_prefix = host_ld_library_path_prefix .. diff --git a/modes/tools/exec_rules.lua b/modes/tools/exec_rules.lua index 4d0ef5d9..36a2f1d7 100644 --- a/modes/tools/exec_rules.lua +++ b/modes/tools/exec_rules.lua @@ -14,7 +14,7 @@ rule_file_interface_version = "203" default_exec_policy = { name = "Default", - native_app_ld_preload_prefix = host_ld_preload, + native_app_ld_preload_suffix = host_ld_preload, } -- For binaries from tools_root: diff --git a/network/Makefile b/network/Makefile index d578b440..5d583a8d 100644 --- a/network/Makefile +++ b/network/Makefile @@ -2,7 +2,7 @@ objs := $(D)/net_rules.o network/libsb2net.a: $(objs) -network/libsb2net.a: override CFLAGS := $(CFLAGS) -O2 -g -fPIC -Wall -W -I$(SRCDIR)/$(LUASRC) -I$(OBJDIR)/preload -I$(SRCDIR)/preload -I$(SRCDIR)/network \ +network/libsb2net.a: override CFLAGS := $(CFLAGS) $(LUA_CFLAGS) -O2 -g -fPIC -Wall -W -I$(SRCDIR)/$(LUASRC) -I$(OBJDIR)/preload -I$(SRCDIR)/preload -I$(SRCDIR)/network \ $(WERROR) -Wmissing-prototypes -Wstrict-prototypes network/libsb2net.a: override LDFLAGS := $(LDFLAGS) network/libsb2net.a: override LIBS := diff --git a/pathmapping/Makefile b/pathmapping/Makefile index 362b4b21..a3ea1696 100644 --- a/pathmapping/Makefile +++ b/pathmapping/Makefile @@ -5,7 +5,7 @@ objs := $(D)/pathresolution.o \ $(D)/paths_ruletree_maint.o pathmapping/libpaths.a: $(objs) -pathmapping/libpaths.a: override CFLAGS := $(CFLAGS) -O2 -g -fPIC -Wall -W -I$(SRCDIR)/$(LUASRC) -I$(OBJDIR)/preload -I$(SRCDIR)/preload -I$(SRCDIR)/pathmapping \ +pathmapping/libpaths.a: override CFLAGS := $(CFLAGS) $(LUA_CFLAGS) -O2 -g -fPIC -Wall -W -I$(SRCDIR)/$(LUASRC) -I$(OBJDIR)/preload -I$(SRCDIR)/preload -I$(SRCDIR)/pathmapping \ $(WERROR) -Wmissing-prototypes -Wstrict-prototypes pathmapping/libpaths.a: override LDFLAGS := $(LDFLAGS) pathmapping/libpaths.a: override LIBS := diff --git a/preload/Makefile b/preload/Makefile index 149ec22a..e3a17ee5 100644 --- a/preload/Makefile +++ b/preload/Makefile @@ -35,7 +35,7 @@ $(D)/libsb2.$(SHLIBEXT): pathmapping/libpaths.a $(D)/libsb2.$(SHLIBEXT): execs/libexecs.a $(D)/libsb2.$(SHLIBEXT): network/libsb2net.a $(D)/libsb2.$(SHLIBEXT): rule_tree/libruletree.a -$(D)/libsb2.$(SHLIBEXT): CFLAGS := $(CFLAGS) -fPIC -Wall -W \ +$(D)/libsb2.$(SHLIBEXT): CFLAGS := $(CFLAGS) $(LUA_CFLAGS) -fPIC -Wall -W \ -I$(SRCDIR)/preload -I$(OBJDIR)/preload $(PROTOTYPEWARNINGS) $(D)/libsb2.$(SHLIBEXT): LDFLAGS := $(LDFLAGS) $(LIBSB2_LDFLAGS) $(D)/libsb2.$(SHLIBEXT): LIBS := -ldl $(LIBSB2_LIBS) diff --git a/preload/interface.master b/preload/interface.master index 6ffd7d4e..d4326c07 100644 --- a/preload/interface.master +++ b/preload/interface.master @@ -667,6 +667,13 @@ WRAP: int stat(const char *file_name, struct stat *buf) : \ create_nomap_nolog_version \ map(file_name) class(STAT) +#ifdef HAVE_STATX +GATE: int statx(int dirfd, const char *__restrict pathname, int flags, \ + unsigned int mask, struct statx *__restrict buf) : \ + dont_resolve_final_symlink_if(flags&AT_SYMLINK_NOFOLLOW) \ + map_at(dirfd,pathname) class(STAT) +#endif + #ifdef HAVE_STAT64 WRAP: int stat64(const char *file_name, struct stat64 *buf) : map(file_name) class(STAT) \ create_nomap_nolog_version @@ -786,7 +793,11 @@ WRAP: int mkostemps64(char *template, int suffixlen, int flags) : \ -- that did not exist when the function was called. These need to do path -- mapping when performing the tests.. because of that we need to replace -- these functions completely. +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 34) GATE: char *tmpnam(char __s[L_tmpnam]) : returns_string +#else +GATE: char *tmpnam(char *s) : returns_string +#endif GATE: char *tempnam(const char *tmpdir, const char *prefix) : returns_string WRAP: char *mktemp(char *template) : \ map(template) \ diff --git a/preload/tmpnamegates.c b/preload/tmpnamegates.c index 3a44ffb0..5575884b 100644 --- a/preload/tmpnamegates.c +++ b/preload/tmpnamegates.c @@ -180,8 +180,13 @@ extern void mkostemps64_postprocess_template(const char *realfnname, */ char *tmpnam_gate( int *result_errno_ptr, +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 34) char *(*real_tmpnam_ptr)(char __s[L_tmpnam]), const char *realfnname, char s[L_tmpnam]) +#else + char *(*real_tmpnam_ptr)(char *s), + const char *realfnname, char *s) +#endif { static char static_tmpnam_buf[PATH_MAX]; /* used if s is NULL */ char tmpnam_buf[PATH_MAX]; diff --git a/preload/vperm_filestatgates.c b/preload/vperm_filestatgates.c index 4939a9e4..eb507ac0 100644 --- a/preload/vperm_filestatgates.c +++ b/preload/vperm_filestatgates.c @@ -254,6 +254,29 @@ int __fxstatat64_gate(int *result_errno_ptr, return(res); } +#ifdef HAVE_STATX +int statx_gate(int *result_errno_ptr, + int (*real_statx_ptr)(int dirfd, const char *__restrict pathname, int flags, + unsigned int mask, struct statx *__restrict buf), + const char *realfnname, + int dirfd, + const mapping_results_t *mapped_filename, + int flags, + unsigned int mask, + struct statx *__restrict buf) +{ + int res; + + res = (*real_statx_ptr)(dirfd, mapped_filename->mres_result_path, flags, mask, buf); + if (res == 0) { + i_virtualize_struct_statx(realfnname, buf); + } else { + *result_errno_ptr = errno; + } + return(res); +} +#endif + /* ======================= chown() variants ======================= */ static void vperm_chown( diff --git a/preload/vperm_statfuncts.c b/preload/vperm_statfuncts.c index 96944076..11822629 100644 --- a/preload/vperm_statfuncts.c +++ b/preload/vperm_statfuncts.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "sb2.h" #include "sb2_stat.h" #include "sb2_vperm.h" @@ -114,11 +115,15 @@ int real_fstat64(int fd, struct stat64 *statbuf) } /* return 0 if not modified, positive if something was virtualized. - * only one of {buf,buf64} should be set; set the other one to NULL */ -int i_virtualize_struct_stat( - const char *realfnname, - struct stat *buf, - struct stat64 *buf64) + * only one of {buf,bufx,buf64} should be set; set the other ones to NULL */ +int i_virtualize_struct_stat_internal( + const char *realfnname + , struct stat *buf + , struct stat64 *buf64 +#ifdef HAVE_STATX + , struct statx *bufx +#endif + ) { int res = 0; ruletree_inodestat_handle_t handle; @@ -129,6 +134,12 @@ int i_virtualize_struct_stat( ruletree_clear_inodestat_handle(&handle); if (buf) { ruletree_init_inodestat_handle(&handle, buf->st_dev, buf->st_ino); +#ifdef HAVE_STATX + } else if (bufx) { + ruletree_init_inodestat_handle(&handle, + gnu_dev_makedev(bufx->stx_dev_major, bufx->stx_dev_minor), + bufx->stx_ino); +#endif } else { ruletree_init_inodestat_handle(&handle, buf64->st_dev, buf64->st_ino); } @@ -145,6 +156,9 @@ int i_virtualize_struct_stat( "%s/%s: found, set uid to %d", realfnname, __func__, istat_in_db.inodesimu_uid); if (buf) buf->st_uid = istat_in_db.inodesimu_uid; +#ifdef HAVE_STATX + else if (bufx) bufx->stx_uid = istat_in_db.inodesimu_uid; +#endif else buf64->st_uid = istat_in_db.inodesimu_uid; res++; } else if (set_uid_gid_of_unknown) { @@ -152,6 +166,9 @@ int i_virtualize_struct_stat( "%s/%s: 'unknown' file, set owner to %d", realfnname, __func__, uf_uid); if (buf) buf->st_uid = uf_uid; +#ifdef HAVE_STATX + else if (bufx) bufx->stx_uid = uf_uid; +#endif else buf64->st_uid = uf_uid; res++; } @@ -162,6 +179,9 @@ int i_virtualize_struct_stat( "%s/%s: found, set gid to %d", realfnname, __func__, istat_in_db.inodesimu_gid); if (buf) buf->st_gid = istat_in_db.inodesimu_gid; +#ifdef HAVE_STATX + else if (bufx) bufx->stx_gid = istat_in_db.inodesimu_gid; +#endif else buf64->st_gid = istat_in_db.inodesimu_gid; res++; } else if (set_uid_gid_of_unknown) { @@ -169,6 +189,9 @@ int i_virtualize_struct_stat( "%s/%s: 'unknown' file, set group to %d", realfnname, __func__, uf_gid); if (buf) buf->st_gid = uf_gid; +#ifdef HAVE_STATX + else if (bufx) bufx->stx_gid = uf_gid; +#endif else buf64->st_gid = uf_gid; res++; } @@ -181,6 +204,11 @@ int i_virtualize_struct_stat( if (buf) buf->st_mode = (buf->st_mode & S_IFMT) | (istat_in_db.inodesimu_mode & (~S_IFMT)); +#ifdef HAVE_STATX + else if (bufx) bufx->stx_mode = + (bufx->stx_mode & S_IFMT) | + (istat_in_db.inodesimu_mode & (~S_IFMT)); +#endif else buf64->st_mode = (buf64->st_mode & S_IFMT) | (istat_in_db.inodesimu_mode & (~S_IFMT)); @@ -194,6 +222,11 @@ int i_virtualize_struct_stat( if (buf) buf->st_mode = (buf->st_mode & ~(S_ISUID | S_ISGID)) | (istat_in_db.inodesimu_suidsgid & (S_ISUID | S_ISGID)); +#ifdef HAVE_STATX + else if (bufx) bufx->stx_mode = + (bufx->stx_mode & ~(S_ISUID | S_ISGID)) | + (istat_in_db.inodesimu_suidsgid & (S_ISUID | S_ISGID)); +#endif else buf64->st_mode = (buf64->st_mode & ~(S_ISUID | S_ISGID)) | (istat_in_db.inodesimu_suidsgid & (S_ISUID | S_ISGID)); @@ -210,6 +243,14 @@ int i_virtualize_struct_stat( (buf->st_mode & (~S_IFMT)) | (istat_in_db.inodesimu_devmode & S_IFMT); buf->st_rdev = istat_in_db.inodesimu_rdev; +#ifdef HAVE_STATX + } else if (bufx) { + bufx->stx_mode = + (bufx->stx_mode & (~S_IFMT)) | + (istat_in_db.inodesimu_devmode & S_IFMT); + bufx->stx_rdev_major = major(istat_in_db.inodesimu_rdev); + bufx->stx_rdev_minor = minor(istat_in_db.inodesimu_rdev); +#endif } else { buf64->st_mode = (buf64->st_mode & (~S_IFMT)) | @@ -223,8 +264,14 @@ int i_virtualize_struct_stat( "%s/%s: 'unknown' file, set owner and group to %d.%d", realfnname, __func__, uf_uid, uf_gid); if (buf) buf->st_uid = uf_uid; +#ifdef HAVE_STATX + else if (bufx) bufx->stx_uid = uf_uid; +#endif else buf64->st_uid = uf_uid; if (buf) buf->st_gid = uf_gid; +#ifdef HAVE_STATX + else if (bufx) bufx->stx_gid = uf_gid; +#endif else buf64->st_gid = uf_gid; res += 2; } @@ -233,6 +280,34 @@ int i_virtualize_struct_stat( return(res); } +/* return 0 if not modified, positive if something was virtualized. + * only one of {buf,buf64} should be set; set the other one to NULL */ +int i_virtualize_struct_stat( + const char *realfnname, + struct stat *buf, + struct stat64 *buf64) +{ + return i_virtualize_struct_stat_internal(realfnname + , buf + , buf64 +#ifdef HAVE_STATX + , NULL +#endif + ); +} + +#ifdef HAVE_STATX +int i_virtualize_struct_statx( + const char *realfnname, + struct statx *buf) +{ + return i_virtualize_struct_stat_internal(realfnname + , NULL + , NULL + , buf); +} +#endif + int sb2_stat_file(const char *path, struct stat *buf, int *result_errno_ptr, int (*statfn_with_ver_ptr)(int ver, const char *filename, struct stat *buf), int ver, diff --git a/rpm/scratchbox2.spec b/rpm/scratchbox2.spec index dfce2ea5..1299ff3a 100644 --- a/rpm/scratchbox2.spec +++ b/rpm/scratchbox2.spec @@ -1,19 +1,24 @@ -Summary: Scratchbox2 crosscompiling environment -License: LGPLv2 -URL: https://git.sailfishos.org/mer-core/scratchbox2 -Name: scratchbox2 -Version: 2.3.90 +Summary: Scratchbox2 crosscompiling environment +License: LGPLv2 +URL: https://git.sailfishos.org/mer-core/scratchbox2 +Name: scratchbox2 +Version: 2.3.90+git58 Release: 0 -Source: %{name}-%{version}.tar.gz -Prefix: /usr -ExclusiveArch: %{ix86} +Source: %{name}-%{version}.tar.gz +Prefix: /usr +ExclusiveArch: %{ix86} %{x86_64} BuildRequires: make BuildRequires: autoconf -BuildRequires: pkgconfig(lua) -BuildRequires: automake +BuildRequires: pkgconfig(lua) +BuildRequires: automake +%if 0%{?suse_version} +BuildRequires: lua-luaposix +Requires: lua-luaposix +%else BuildRequires: lua-posix -Requires: libsb2 = %{version}-%{release} -Requires: lua-posix +Requires: lua-posix +%endif +Requires: libsb2 = %{version}-%{release} %description Scratchbox2 crosscompiling environment @@ -31,13 +36,13 @@ Summary: Scratchbox2 docs Scratchbox2 man pages. %prep -%setup +%autosetup %build ./autogen.sh %configure touch .configure -# Can't use %{?_smp_mflags} here: race condition in build system +# Can't use %{?_smp_mflags} here: race condition in build system %{__make} %{_make_output_sync} %{_make_verbose} %install @@ -46,7 +51,6 @@ touch .configure install -D -m 644 utils/sb2.bash %{buildroot}/etc/bash_completion.d/sb2.bash %files -%defattr(-,root,root) %{_bindir}/sb2* %{_datadir}/scratchbox2/* %config %{_sysconfdir}/bash_completion.d/sb2.bash @@ -56,7 +60,6 @@ install -D -m 644 utils/sb2.bash %{buildroot}/etc/bash_completion.d/sb2.bash %doc %attr(0444,root,root) /usr/share/man/man7/* %files -n libsb2 -%defattr(-,root,root) %{_libdir}/libsb2/* %ifarch x86_64 /usr/lib32/libsb2/* diff --git a/rule_tree/Makefile b/rule_tree/Makefile index 826c949f..b2c44c4b 100644 --- a/rule_tree/Makefile +++ b/rule_tree/Makefile @@ -4,7 +4,7 @@ objs := $(D)/rule_tree.o \ $(D)/rule_tree_rpc_client.o rule_tree/libruletree.a: $(objs) -rule_tree/libruletree.a: override CFLAGS := $(CFLAGS) -O2 -g -fPIC -Wall -W -I$(SRCDIR)/$(LUASRC) -I$(OBJDIR)/preload -I$(SRCDIR)/preload \ +rule_tree/libruletree.a: override CFLAGS := $(CFLAGS) $(LUA_CFLAGS) -O2 -g -fPIC -Wall -W -I$(SRCDIR)/$(LUASRC) -I$(OBJDIR)/preload -I$(SRCDIR)/preload \ $(WERROR) -Wmissing-prototypes -Wstrict-prototypes rule_tree/libruletree.a: override LDFLAGS := $(LDFLAGS) rule_tree/libruletree.a: override LIBS := diff --git a/sb2d/Makefile b/sb2d/Makefile index b9fc41c5..32ef5063 100644 --- a/sb2d/Makefile +++ b/sb2d/Makefile @@ -1,11 +1,14 @@ # beware of namespace collisions, all subdir makefiles are included # into the top-level Makefile -$(D)/sb2d: CFLAGS := $(CFLAGS) -Wall -W $(WERROR) \ +$(D)/sb2d: CFLAGS := $(CFLAGS) $(LUA_CFLAGS) -Wall -W $(WERROR) \ $(PROTOTYPEWARNINGS) \ -I$(SRCDIR)/include \ -I$(SRCDIR)/preload -I$(OBJDIR)/preload +$(D)/libsupport.o: CFLAGS := $(CFLAGS) $(LUA_CFLAGS) \ + -I$(SRCDIR)/preload -I$(OBJDIR)/preload + $(D)/sb2d: $(D)/sb2d.o \ $(D)/server_socket.o \ $(D)/libsupport.o \ diff --git a/sblib/Makefile b/sblib/Makefile index 37d84480..b8836d52 100644 --- a/sblib/Makefile +++ b/sblib/Makefile @@ -7,7 +7,7 @@ objs := $(D)/sb_log.o \ $(D)/sb_log.o: preload/exported.h sblib/libsblib.a: $(objs) -sblib/libsblib.a: override CFLAGS := $(CFLAGS) -O2 -g -fPIC -Wall -W -I$(OBJDIR)/preload -I$(SRCDIR)/preload \ +sblib/libsblib.a: override CFLAGS := $(CFLAGS) $(LUA_CFLAGS) -O2 -g -fPIC -Wall -W -I$(OBJDIR)/preload -I$(SRCDIR)/preload \ $(WERROR) -Wmissing-prototypes -Wstrict-prototypes sblib/libsblib.a: override LDFLAGS := $(LDFLAGS) sblib/libsblib.a: override LIBS := diff --git a/utils/sb2 b/utils/sb2 index 5654c05e..6e7e13c9 100755 --- a/utils/sb2 +++ b/utils/sb2 @@ -19,12 +19,12 @@ SBOX_LIBSB2="libsb2.so.1" # Show version. # (called to process a command-line option) -function show_version() +show_version() { cat $SBOX_DIR/share/scratchbox2/version } -function show_usage_and_exit() +show_usage_and_exit() { cat <$SBOX_SESSION_DIR/path_to_nscd_socket.conf - NSSWITCH_CONF_PATH=`cat $SBOX_SESSION_DIR/path_to_nsswitch.conf` - NSCD_SOCKET_PATH=`cat $SBOX_SESSION_DIR/path_to_nscd_socket.conf` - if [ -n "NSSWITCH_CONF_PATH" ]; then + read -r NSSWITCH_CONF_PATH < $SBOX_SESSION_DIR/path_to_nsswitch.conf + read -r NSCD_SOCKET_PATH < $SBOX_SESSION_DIR/path_to_nscd_socket.conf + if [ -n "$NSSWITCH_CONF_PATH" ]; then export NSSWITCH_CONF_PATH fi - if [ -n "NSCD_SOCKET_PATH" ]; then + if [ -n "$NSCD_SOCKET_PATH" ]; then export NSCD_SOCKET_PATH fi } @@ -181,10 +181,10 @@ function locate_target_nsswitch_conf() # Create some additional rules for the default mapping mode: # # Used during stage 3 (generation of automatic rules) -function add_auto_rules_to_mapping_rules() +add_auto_rules_to_mapping_rules() { for ammf in $SBOX_SESSION_DIR/rules/$SBOX_MAPMODE.lua; do - amm_base=`basename $ammf .lua` + amm_base=$(basename $ammf .lua) if [ -f $SBOX_SESSION_DIR/rules_auto/$amm_base.usr_bin.lua ]; then # add the generated rules to the beginning of the rule file @@ -198,7 +198,7 @@ function add_auto_rules_to_mapping_rules() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function set_and_check_SBOX_TARGET() +set_and_check_SBOX_TARGET() { if [ -z "$SBOX_TARGET" ]; then if [ -r ~/.scratchbox2/config ]; then @@ -220,7 +220,7 @@ function set_and_check_SBOX_TARGET() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function load_configuration() +load_configuration() { #----------- # part of the configuration is still stored in the "old format" @@ -236,9 +236,9 @@ function load_configuration() LD_LIBRARY_PATH=$saved_LD_LIBRARY_PATH # resolve possible symlinks in SBOX_TARGET_ROOT and SBOX_TOOLS_ROOT - SBOX_TARGET_ROOT=`readlink -f $SBOX_TARGET_ROOT` + SBOX_TARGET_ROOT=$(readlink -f $SBOX_TARGET_ROOT) if [ -n "$SBOX_TOOLS_ROOT" ]; then - SBOX_TOOLS_ROOT=`readlink -f $SBOX_TOOLS_ROOT` + SBOX_TOOLS_ROOT=$(readlink -f $SBOX_TOOLS_ROOT) fi # now that we know SBOX_TOOLS_ROOT, we can create the required @@ -350,7 +350,7 @@ function load_configuration() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function clone_target_root_dir_from() +clone_target_root_dir_from() { source_directory=$1 @@ -382,7 +382,7 @@ function clone_target_root_dir_from() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function sboxify_environment() +sboxify_environment() { load_configuration @@ -468,12 +468,12 @@ function sboxify_environment() } -function initialize_sb_logging() +initialize_sb_logging() { cmd_param=$1 args_param=$2 if [ "$SBOX_MAPPING_LOGLEVEL" != "" ]; then - tstamp=`SBOX_DISABLE_MAPPING=1 /bin/date +%Y%m%d-%H%M.%N` + tstamp=$(SBOX_DISABLE_MAPPING=1 date +%Y%m%d-%H%M.%N) # put logs to # a) if SBOX_LOG_AND_GRAPH_DIR is set, there @@ -539,7 +539,7 @@ function initialize_sb_logging() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function create_common_sb2_conf_file_for_session() +create_common_sb2_conf_file_for_session() { sbox_user_home_dir=$HOME if [ -z "$HOME" ]; then @@ -599,17 +599,18 @@ END # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function create_gcc_conf_file_for_session() +create_gcc_conf_file_for_session() { - gcc_config_files=`ls ~/.scratchbox2/$SBOX_TARGET/sb2.config.d/gcc.config*.lua 2>/dev/null` - if [ -n "$gcc_config_files" ] ; then - # Create the configuration file. Do some variable substitutions: - # "extra_cross_compiler_args" and "extra_cross_ld_args" - # need absolute paths to the orig. rootstrap location, at least. - cat $gcc_config_files | \ + for gcc_config_file in ~/.scratchbox2/"$SBOX_TARGET"/sb2.config.d/gcc.config*.lua ; do + if [ -e "$gcc_config_file" ] ; then + # Create the configuration file. Do some variable substitutions: + # "extra_cross_compiler_args" and "extra_cross_ld_args" + # need absolute paths to the orig. rootstrap location, at least. sed -e "s:@SBOX_TARGET_ROOT@:$SBOX_TARGET_ROOT:g" \ - >$SBOX_SESSION_DIR/gcc-conf.lua - fi + "$gcc_config_file" \ + >>"$SBOX_SESSION_DIR"/gcc-conf.lua + fi + done } # write_ld_library_path_replacement_to_exec_config(): @@ -621,7 +622,7 @@ function create_gcc_conf_file_for_session() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function write_ld_library_path_replacement_to_exec_config() +write_ld_library_path_replacement_to_exec_config() { rootdir=$1 varname=$2 @@ -642,7 +643,7 @@ function write_ld_library_path_replacement_to_exec_config() # IMPORTANT: $libsb2_dirname and $libsb2_path # will be used by # write_libsb2_and_ld_so_state_to_exec_config() - libsb2_dirname=`dirname $l` + libsb2_dirname=$(dirname $l) libsb2_path=$l break fi @@ -655,12 +656,17 @@ function write_ld_library_path_replacement_to_exec_config() # Include directories listed in ld.so.conf if [ -f $rootdir/etc/ld.so.conf ]; then - lloc2=`egrep '^/' $rootdir/etc/ld.so.conf` + lloc2=$(grep -E '^/' $rootdir/etc/ld.so.conf) liblocations="$liblocations $lloc2" fi # Include directories listed in ld.so.conf.d/* if [ -d $rootdir/etc/ld.so.conf.d ]; then - lloc2=`cat $rootdir/etc/ld.so.conf.d/* 2>/dev/null | egrep '^/'` + for ld_so_conf in "$root"/etc/ld.so.conf.d/* ; do + if [ -e "$ld_so_conf" ] ; then + lloc2=$(grep --extended-regexp --only-matching '^/' "$rootdir"/etc/ld.so.conf.d/* ) + break + fi + done liblocations="$liblocations $lloc2" fi @@ -669,11 +675,11 @@ function write_ld_library_path_replacement_to_exec_config() # print contents of the cache, take destination # names (the part after "=>"), drop file names (leave # directory names, and remove duplicates: - dirs_in_cache=`$rootdir/sbin/ldconfig -p \ - -C $rootdir/etc/ld.so.cache | - fgrep '=>' | - sed -e 's/^.*=> //' -e 's:/[^/]*$::' | - sort | uniq` + dirs_in_cache=$($rootdir/sbin/ldconfig --print-cache \ + -r "$rootdir" \ + -C '/etc/ld.so.cache' | + sed --regexp-extended -n '/=>/ {s/.*=> (.*)/\1/;s|(.*)/.*$|\1|p}' | + sort | uniq) ld_library_extras_from_cache=$dirs_in_cache liblocations="$liblocations $dirs_in_cache" fi @@ -708,7 +714,7 @@ function write_ld_library_path_replacement_to_exec_config() # # Used during initialization stage 2: Requires that binaries # can be executed in the sb2'ed environment. -function check_qemu_features() +check_qemu_features() { qemu_path=$($SBOX_DIR/bin/sb2-show realpath $1) shift @@ -728,10 +734,11 @@ function check_qemu_features() fi # run qemu -h + read qemu_cmdline < $SBOX_SESSION_DIR/qemu_cmdline __SB2_BINARYNAME="sb2:CheckingQemuFeatures" \ sb2-monitor \ -L $SBOX_LIBSB2 -- \ - `cat $SBOX_SESSION_DIR/qemu_cmdline` -h \ + $qemu_cmdline -h \ >$SBOX_SESSION_DIR/qemu_help # we don't test $? here, qemu -h returns with a non-zero # argument anyway @@ -777,7 +784,7 @@ function check_qemu_features() esac fi - test_output=`grep '^-0' $SBOX_SESSION_DIR/qemu_help` + test_output=$(grep -- '^-0' $SBOX_SESSION_DIR/qemu_help) if [ -n "$test_output" ]; then # -0 is supported conf_cputransparency_has_argv0_flag="true" @@ -785,7 +792,7 @@ function check_qemu_features() conf_cputransparency_has_argv0_flag="false" fi - test_output=`grep '^-E' $SBOX_SESSION_DIR/qemu_help` + test_output=$(grep -- '^-E' $SBOX_SESSION_DIR/qemu_help) if [ -n "$test_output" ]; then # -E is supported conf_cputransparency_qemu_has_env_control_flags="true" @@ -793,7 +800,7 @@ function check_qemu_features() conf_cputransparency_qemu_has_env_control_flags="false" fi - test_output=`grep '^-libattr-hack' $SBOX_SESSION_DIR/qemu_help` + test_output=$(grep -- '^-libattr-hack' $SBOX_SESSION_DIR/qemu_help) if [ -n "$test_output" ]; then conf_cputransparency_qemu_has_libattr_hack_flag="true" else @@ -801,33 +808,34 @@ function check_qemu_features() fi qemu_argv="" - for qemuarg in `cat $SBOX_SESSION_DIR/qemu_cmdline`; do - case "$qemuarg" in + read -r qemu_args < $SBOX_SESSION_DIR/qemu_cmdline + for qemu_arg in $qemu_args; do + case "$qemu_arg" in LD_LIBRARY_PATH=*) - conf_cputransparency_qemu_ld_library_path=$qemuarg ;; + conf_cputransparency_qemu_ld_library_path=$qemu_arg ;; LD_PRELOAD=*) - conf_cputransparency_qemu_ld_preload=$qemuarg ;; + conf_cputransparency_qemu_ld_preload=$qemu_arg ;; __SB2_*=*) # skip it ;; SBOX_VPERM_*=*) # skip it ;; [A-Z_]*=*) # other additional env.vars. if [ -z "$qemu_env" ]; then - qemu_env="'$qemuarg'" + qemu_env="'$qemu_arg'" else - qemu_env="$qemu_env,'$qemuarg'" + qemu_env="$qemu_env,'$qemu_arg'" fi ;; [\'\"]*[\'\"]) if [ -z "$qemu_argv" ]; then - qemu_argv="$qemuarg" + qemu_argv="$qemu_arg" else - qemu_argv="$qemu_argv,$qemuarg" + qemu_argv="$qemu_argv,$qemu_arg" fi ;; *) if [ -z "$qemu_argv" ]; then - qemu_argv="'$qemuarg'" + qemu_argv="'$qemu_arg'" else - qemu_argv="$qemu_argv,'$qemuarg'" + qemu_argv="$qemu_argv,'$qemu_arg'" fi ;; esac done @@ -844,7 +852,7 @@ function check_qemu_features() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function check_ld_so_features() +check_ld_so_features() { rootdir=$1 ld_so_path=$2 @@ -855,17 +863,17 @@ function check_ld_so_features() # Executing ld.so without any arguments should print # usage information to stderr: - test_argv0_opt=`$ld_so_path 2>&1 | grep 'argv0 STRING'` + test_argv0_opt=$($ld_so_path 2>&1 | grep 'argv0 STRING') if [ -n "$test_argv0_opt" ]; then # description about --argv0 exists! ld_so_argv_flag_works="true" fi - test_rpath_prefix_opt=`$ld_so_path 2>&1 | grep 'rpath-prefix PREFIX'` + test_rpath_prefix_opt=$($ld_so_path 2>&1 | grep 'rpath-prefix PREFIX') if [ -n "$test_rpath_prefix_opt" ]; then # description about --rpath-prefix exists! ld_so_rpath_prefix_flag_works="true" fi - test_nodefaultdirs_opt=`$ld_so_path 2>&1 | grep 'nodefaultdirs'` + test_nodefaultdirs_opt=$($ld_so_path 2>&1 | grep 'nodefaultdirs') if [ -n "$test_nodefaultdirs_opt" ]; then # description about --nodefaultdirs exists! ld_so_nodefaultdirs_flag_works="true" @@ -875,13 +883,13 @@ function check_ld_so_features() # Locate shell and set the initial binary name for the mapping engine # # Used during stage 5: Preparing environment variables. -function locate_shell() +locate_shell() { __SB2_BINARYNAME="sb2:TestingBash" sb2-monitor \ -L $SBOX_LIBSB2 -- $SBOX_DIR/bin/sb2-show \ which /bin/bash \ >$SBOX_SESSION_DIR/path_to_shell.conf - SHELL_PATH=`cat $SBOX_SESSION_DIR/path_to_shell.conf` + read -r SHELL_PATH < $SBOX_SESSION_DIR/path_to_shell.conf if [ -f "$SHELL_PATH" ]; then # Good, bash exists. Use that. SHELL=/bin/bash @@ -905,11 +913,11 @@ function locate_shell() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function guess_ld_so() +guess_ld_so() { local prefix="$1" - if [ "`uname -m`" = 'x86_64' -a -r "$prefix/lib/ld-linux-x86-64.so.2" ] + if [ "$(uname -m)" = 'x86_64' -a -r "$prefix/lib/ld-linux-x86-64.so.2" ] then printf "$prefix/lib/ld-linux-x86-64.so.2" else @@ -932,7 +940,7 @@ function guess_ld_so() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function write_libsb2_and_ld_so_state_to_exec_config() +write_libsb2_and_ld_so_state_to_exec_config() { rootdir=$1 sb2_installed_varname=$2 @@ -960,7 +968,7 @@ function write_libsb2_and_ld_so_state_to_exec_config() fi if [ -f $libsb2_path ]; then - libsb2_dir=`/usr/bin/dirname $libsb2_path` + libsb2_dir=$(dirname $libsb2_path) echo "-- $libsb2_path" >>$SBOX_SESSION_DIR/exec_config.lua echo "$libsb2_dir_varname=\"$libsb2_dir\"" \ >>$SBOX_SESSION_DIR/exec_config.lua @@ -977,13 +985,13 @@ function write_libsb2_and_ld_so_state_to_exec_config() # check the dynamic linker: # First try if the default linker can be used - ld_so_candidate="`guess_ld_so $rootdir`" + ld_so_candidate="$(guess_ld_so $rootdir)" if [ -f $ld_so_candidate ]; then check_ld_so_features $rootdir $ld_so_candidate if [ "$ld_so_argv_flag_works" != "true" ]; then # the default ld.so does not support --argv0. # Find out if a replacement has been installed for sb2. - ld_so_with_version=`readlink $ld_so_candidate` + ld_so_with_version=$(readlink $ld_so_candidate) # First try if it exists in the same directory where # libsb2.so is: @@ -1021,9 +1029,9 @@ function write_libsb2_and_ld_so_state_to_exec_config() # points to the actual dynamic linker since we don't # know its version. # - ld_so_candidate2="`guess_ld_so $libsb2_dirname`" + ld_so_candidate2="$(guess_ld_so $libsb2_dirname)" if [ -L $ld_so_candidate2 ]; then - ld_so_candidate2=`readlink -f $ld_so_candidate2` + ld_so_candidate2=$(readlink -f $ld_so_candidate2) # check also that it has --argv0 support check_ld_so_features $rootdir $ld_so_candidate2 if [ "$ld_so_argv_flag_works" == "true" ]; then @@ -1066,7 +1074,7 @@ function write_libsb2_and_ld_so_state_to_exec_config() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function write_locale_and_gconv_paths_to_exec_config() +write_locale_and_gconv_paths_to_exec_config() { rootdir=$1 generated_locale_path=$2 @@ -1132,7 +1140,7 @@ function write_locale_and_gconv_paths_to_exec_config() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function create_exec_config_file() +create_exec_config_file() { cat >$SBOX_SESSION_DIR/exec_config.lua </dev/null; then # $file seems to be valid - SBOX_SESSION_DIR=`sed -n -e 's/^SBOX_SESSION_DIR=//p' < $file` - SBOX_TARGET=`sed -n -e 's/^SBOX_TARGET=//p' < $file` + SBOX_SESSION_DIR=$(sed -n -e 's/^SBOX_SESSION_DIR=//p' < $file) + SBOX_TARGET=$(sed -n -e 's/^SBOX_TARGET=//p' < $file) else exit_error "'$file' is not a valid SB2 session information file" fi @@ -1334,7 +1342,7 @@ function get_SBOX_SESSION_DIR_from_file() # used to select a mapping mode which is distributed with sb2. # # (called to process a command-line option) -function add_map_mode() +add_map_mode() { if [ ! -d "$SBOX_DIR/share/scratchbox2/modes/$1" ]; then exit_error "Invalid mode '$1', aborting." @@ -1352,29 +1360,29 @@ function add_map_mode() fi SB2_INTERNAL_MAPMODES="$SB2_INTERNAL_MAPMODES $1" - NUM_MAPMODES=`expr $NUM_MAPMODES + 1` + NUM_MAPMODES=$(($NUM_MAPMODES + 1)) } # Add a non-standard mapping mode. # FIXME: Currently not possible, due to the change to # mapping mode directories. To be fixed. # (called to process a command-line option) -##function add_external_map_mode() +##add_external_map_mode() ##{ ## if [ -z "$SBOX_MAPMODE" ]; then ## # SBOX_MAPMODE was not set. Use basename of the rule file ## # as default mode name: -## SBOX_MAPMODE=`basename $1 .lua` +## SBOX_MAPMODE=$(basename $1 .lua) ## fi ## ## SB2_EXTERNAL_RULEFILES="$SB2_EXTERNAL_RULEFILES $1" -## NUM_MAPMODES=`expr $NUM_MAPMODES + 1` +## NUM_MAPMODES=$(($NUM_MAPMODES + 1)) ##} # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function initialize_new_sb2_session() +initialize_new_sb2_session() { # Create a new session if [ -n "$SBOX_WRITE_SESSION_INFO_TO_FILE" -a \ @@ -1387,14 +1395,14 @@ function initialize_new_sb2_session() SBOX_SESSION_DIR=$OPT_SESSION_DIR else # Create session directories - date_and_time_now=`date +%Y%m%d-%H%M%S` - SBOX_SESSION_DIR=`mktemp -d /tmp/sb2-$USER-$date_and_time_now.XXXXXX` + date_and_time_now=$(date +%Y%m%d-%H%M%S) + SBOX_SESSION_DIR=$(mktemp -d /tmp/sb2-$USER-$date_and_time_now.XXXXXX) if [ $? != 0 ]; then exit_error "Failed to create directory for session (problems with /tmp ?)" fi fi # resolve possible symlinks in SBOX_SESSION_DIR - SBOX_SESSION_DIR=`readlink -f $SBOX_SESSION_DIR` + SBOX_SESSION_DIR=$(readlink -f $SBOX_SESSION_DIR) mkdir -p $SBOX_SESSION_DIR if [ $? != 0 ]; then @@ -1459,7 +1467,7 @@ END # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function join_existing_session() +join_existing_session() { # Join an existing session, don't create it.. get_SBOX_SESSION_DIR_from_file "$SBOX_JOIN_SESSION_FILE" @@ -1487,7 +1495,7 @@ function join_existing_session() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function link_wrappers_for_mapmode() +link_wrappers_for_mapmode() { w_mode=$1 @@ -1528,7 +1536,7 @@ function link_wrappers_for_mapmode() # # Used during initialization stage 1 (while setting # up the environment, which can't be used yet) -function write_configfiles_and_rules_for_new_session() +write_configfiles_and_rules_for_new_session() { # creating a new session.. @@ -1550,7 +1558,7 @@ function write_configfiles_and_rules_for_new_session() # Create links to network rules for netr in $SBOX_DIR/share/scratchbox2/net_rules/*; do ln -s $netr $SBOX_SESSION_DIR/net_rules - netr_b=`basename $netr` + netr_b=$(basename $netr) SB2_ALL_NET_MODES="$SB2_ALL_NET_MODES $netr_b" done # Create a link to the default mode @@ -1558,7 +1566,7 @@ function write_configfiles_and_rules_for_new_session() ##if [ -n "$SB2_EXTERNAL_RULEFILES" ]; then ## for ammf in $SB2_EXTERNAL_RULEFILES; do - ## amm=`basename $ammf .lua` + ## amm=$(basename $ammf .lua) ## write_rules_to_session_dir \ ## $SBOX_SESSION_DIR/rules/$amm.lua $amm $ammf ## @@ -1579,7 +1587,7 @@ function write_configfiles_and_rules_for_new_session() fi } -function delete_old_sb2_session() +delete_old_sb2_session() { # Delete a session get_SBOX_SESSION_DIR_from_file "$SBOX_DELETE_SESSION_FILE" @@ -1593,11 +1601,11 @@ function delete_old_sb2_session() rm "$SBOX_DELETE_SESSION_FILE" } -function print_session_logs() +print_session_logs() { get_SBOX_SESSION_DIR_from_file "$SBOX_PRINT_SESSION_LOGS" - for logfilename in `awk '$1=="#LOG:" {print $3}' <$SBOX_PRINT_SESSION_LOGS`; do + for logfilename in $(awk '$1=="#LOG:" {print $3}' <$SBOX_PRINT_SESSION_LOGS); do # Log files do not exists, if nothing was logged if [ -f "$logfilename" ]; then echo "# ===================== $logfilename" @@ -1859,7 +1867,8 @@ fi # Final addition to LD_LIBRARY_PATH, if needed if [ -f $SBOX_SESSION_DIR/ld_library_path_extras ]; then - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`cat $SBOX_SESSION_DIR/ld_library_path_extras` + read -r ld_library_path_extras < $SBOX_SESSION_DIR/ld_library_path_extras + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ld_library_path_extras fi if [ -z "$SBOX_JOIN_SESSION_FILE" ]; then @@ -1922,7 +1931,7 @@ if [ -z "$SBOX_JOIN_SESSION_FILE" ]; then # to the rule tree. # (this step needs to be syncronous; sb2dctl won't return # before init2.lua is completed) - ctl_result=`$SBOX_DIR/lib/libsb2/sb2dctl -n -s $SBOX_SESSION_DIR init2` + ctl_result=$($SBOX_DIR/lib/libsb2/sb2dctl -n -s $SBOX_SESSION_DIR init2) case "$ctl_result" in *OK*) # Startup OK @@ -1985,7 +1994,7 @@ unset SBOX_TOOLS_ROOT # to an existing session [see the "sb2-session" tool]) if [ -d "$SBOX_SESSION_DIR/env_vars" ]; then for evfile in $SBOX_SESSION_DIR/env_vars/*; do - evname=`basename $evfile` + evname=$(basename $evfile) . $evfile export $evname done diff --git a/utils/sb2-upgrade-config b/utils/sb2-upgrade-config index 24f01bd4..f45b25b3 100755 --- a/utils/sb2-upgrade-config +++ b/utils/sb2-upgrade-config @@ -21,9 +21,9 @@ SBOX_DIR=$(readlink -f $SBOX_SHARE_DIR/../..) SBOX_TARGET=$1 SBOX_CONFIG_DIR=~/.scratchbox2/$SBOX_TARGET/sb2.config.d -function exit_error() +exit_error() { - echo "$my_path: Error: $@" + echo "$my_path: Error: $*" exit 1 } @@ -31,15 +31,15 @@ if [ -z "$SBOX_TARGET" ]; then exit_error "this script is intended for sb2's internal use only!" fi -function log_config_action() +log_config_action() { - tstamp=`/bin/date '+%Y-%m-%d %H:%M:%S'` - echo "$tstamp $*" >>$SBOX_CONFIG_DIR/CONFIG-LOG + tstamp=$(date '+%Y-%m-%d %H:%M:%S') + echo "$tstamp $*" >>"$SBOX_CONFIG_DIR"/CONFIG-LOG } # Get the original arguments that were specified to sb2-init from # the old configuration file; we only need three variables from that file.. -function get_sb2_init_arguments_from_old_config_file() +get_sb2_init_arguments_from_old_config_file() { OLD_CONFIG_FILE=$HOME/.scratchbox2/$SBOX_TARGET/sb2.config @@ -47,22 +47,23 @@ function get_sb2_init_arguments_from_old_config_file() exit_error "$OLD_CONFIG_FILE does not exist" fi - # Check version - vers=`egrep -m 1 '^SBOX_CONFIG_VERSION=' $OLD_CONFIG_FILE` - SBOX_CONFIG_VERSION=0 - eval $vers + + # Check version + SBOX_CONFIG_VERSION=$(sed --regexp-extended \ + -n '/^SBOX_CONFIG_VERSION/ s/^SBOX_CONFIG_VERSION=.*"/\1/ p' $OLD_CONFIG_FILE) if [ "$SBOX_CONFIG_VERSION" -lt 5 ]; then exit_error "configuration file version is too old ($OLD_CONFIG_FILE)" fi + # Get original options & target name & compiler(s) - args=`egrep -m 1 '^SBOX_INIT_ORIG_ARGS=' $OLD_CONFIG_FILE` - eval $args + SBOX_INIT_ORIG_ARGS=$(sed --regexp-extended \ + -n '/^SBOX_INIT_ORIG_ARGS/ s/^SBOX_INIT_ORIG_ARGS=\"(.*)\"/\1/ p' $OLD_CONFIG_FILE) # Get original target_root - targetroot=`egrep -m 1 '^SBOX_TARGET_ROOT=' $OLD_CONFIG_FILE` - eval $targetroot + SBOX_TARGET_ROOT=$(sed --regexp-extended \ + -n '/^SBOX_TARGET_ROOT/ s/^SBOX_TARGET_ROOT=(.*)/\1/ p' $OLD_CONFIG_FILE) export SB2INIT_TARGET_ROOT=$SBOX_TARGET_ROOT $SBOX_SHARE_DIR/scripts/sb2-parse-sb2-init-args $SBOX_INIT_ORIG_ARGS \ @@ -70,7 +71,7 @@ function get_sb2_init_arguments_from_old_config_file() log_config_action "Config upgrade: arguments of original sb2-init restored from old config file" } -function update_toolchain_configs() +update_toolchain_configs() { secondary_compiler="" @@ -111,7 +112,7 @@ function update_toolchain_configs() # "host-ld_library_path.conf" contains settings that are needed for running # host-compatible binaries in host mode (i.e. started directly, not # indirectly by running ld.so). -function update_host_ld_library_path() +update_host_ld_library_path() { # Old versions of sb.config will set $LD_LIBRARY_PATH, # which is not nice... save the current value and restore it later. @@ -157,7 +158,7 @@ function update_host_ld_library_path() log_config_action "Created LD_LIBRARY_PATH configuration file for host-compatible binaries" } -function update_debian_config() +update_debian_config() { $SBOX_DIR/share/scratchbox2/scripts/sb2-config-debian -t $SBOX_TARGET } diff --git a/wrappers/dpkg-checkbuilddeps b/wrappers/dpkg-checkbuilddeps index 2bc23a16..129601ec 100755 --- a/wrappers/dpkg-checkbuilddeps +++ b/wrappers/dpkg-checkbuilddeps @@ -343,7 +343,7 @@ function check_host_builddeps_by_real_tool() # else real dpkg-checkbuilddeps failed. # sed -e 's/^/ /' < $x_missing_dep_file - tools_missing_deps=$(egrep \ + tools_missing_deps=$(grep -E \ "^dpkg-checkbuilddeps: Unmet build dependencies:" \ $x_missing_dep_file | \ sed 's/dpkg-checkbuilddeps: Unmet build dependencies: //') @@ -386,7 +386,7 @@ function check_target_builddeps() if [ -n "$SBOX_CHECKBUILDDEPS_VERBOSE" ]; then sed -e 's/^/ /' < $missing_dep_file fi - missing_deps=$(egrep \ + missing_deps=$(grep -E \ "^dpkg-checkbuilddeps: Unmet build dependencies:" \ $missing_dep_file | \ sed 's/dpkg-checkbuilddeps: Unmet build dependencies: //')