Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Necessary patches for building busybox for Android
diff --git a/Makefile.flags b/Makefile.flags
index cff935ff5..e5818f5db 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -152,7 +152,7 @@ CRYPT_AVAILABLE := $(shell echo 'int main(void){return 0;}' >crypttest.c; $(CC)
ifeq ($(CRYPT_AVAILABLE),y)
LDLIBS += m rt crypt
else
-LDLIBS += m rt
+LDLIBS += m
endif
# libm may be needed for dc, awk, ntpd
# librt may be needed for clock_gettime()
diff --git a/include/libbb.h b/include/libbb.h
index 6be934994..7ff89cad2 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -2205,7 +2205,7 @@ static ALWAYS_INLINE void* not_const_pp(const void *p) { return (void*)p; }
* use bb_default_login_shell and following defines.
* If you change LIBBB_DEFAULT_LOGIN_SHELL,
* don't forget to change increment constant. */
-#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh"
+#define LIBBB_DEFAULT_LOGIN_SHELL "-/system/bin/sh"
extern const char bb_default_login_shell[] ALIGN1;
/* "/bin/sh" */
#define DEFAULT_SHELL (bb_default_login_shell+1)
diff --git a/init/init.c b/init/init.c
index 28775a65c..07236cc37 100644
--- a/init/init.c
+++ b/init/init.c
@@ -1107,7 +1107,7 @@ int init_main(int argc UNUSED_PARAM, char **argv)
/* Make sure environs is set to something sane */
putenv((char *) "HOME=/");
putenv((char *) bb_PATH_root_path);
- putenv((char *) "SHELL=/bin/sh");
+ putenv((char *) "SHELL=/system/bin/sh");
putenv((char *) "USER=root"); /* needed? why? */
if (argv[1])
diff --git a/miscutils/time.c b/miscutils/time.c
index d15d363f3..22abfad2a 100644
--- a/miscutils/time.c
+++ b/miscutils/time.c
@@ -86,7 +86,7 @@ static void resuse_end(pid_t pid, resource_t *resp)
/* Ignore signals, but don't ignore the children. When wait3
* returns the child process, set the time the command finished. */
- while ((caught = wait3(&resp->waitstatus, 0, &resp->ru)) != pid) {
+ while ((caught = wait4(-1, &resp->waitstatus, 0, &resp->ru)) != pid) {
if (caught == -1 && errno != EINTR) {
bb_simple_perror_msg("wait");
return;
diff --git a/shell/ash.c b/shell/ash.c
index ecb9b132b..d800c4669 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -14444,7 +14444,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
/* Non-NULL minusc tells procargs that an embedded script is being run */
minusc = get_script_content(-argc - 1);
#endif
- login_sh = procargs(argv);
+ login_sh = procargs(argv) || true;
#if DEBUG
TRACE(("Shell args: "));
trace_puts_args(argv);
@@ -14454,7 +14454,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
const char *hp;
state = 1;
- read_profile("/etc/profile");
+ read_profile("/system/etc/profile");
state1:
state = 2;
hp = lookupvar("HOME");
@@ -14499,15 +14499,16 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
if (iflag) {
const char *hp = lookupvar("HISTFILE");
if (!hp) {
- hp = lookupvar("HOME");
- if (hp) {
- INT_OFF;
- hp = concat_path_file(hp, ".ash_history");
- setvar0("HISTFILE", hp);
- free((char*)hp);
- INT_ON;
- hp = lookupvar("HISTFILE");
- }
+ setvar("HISTFILE", "/data/local/tmp/ash_history", 0);
+ // hp = lookupvar("HOME");
+ // if (hp) {
+ // INT_OFF;
+ // hp = concat_path_file(hp, ".ash_history");
+ // setvar0("HISTFILE", hp);
+ // free((char*)hp);
+ // INT_ON;
+ // hp = lookupvar("HISTFILE");
+ // }
}
if (hp)
line_input_state->hist_file = hp;
@ttimasdf

This comment has been minimized.

Copy link
Owner Author

@ttimasdf ttimasdf commented Aug 13, 2020

wait3 is not available in usr/include/sys/wait.h on my version of bionic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment