This is a Makefile, a patch, and a line in the top-level Makefile bringing in BASH for Akaros. I've been using this as my shell for a few months now.
Change-Id: I09032cf55dc596f04cdc4ed4f741c9bddd2d78a2 Signed-off-by: Dan Cross <[email protected]> --- Makefile | 1 + tools/sys-apps/bash/Makefile | 57 +++++++ .../bash/akaros-patches/4.3.30/bash-4.3.30.patch | 179 +++++++++++++++++++++ 3 files changed, 237 insertions(+) create mode 100644 tools/sys-apps/bash/Makefile create mode 100644 tools/sys-apps/bash/akaros-patches/4.3.30/bash-4.3.30.patch diff --git a/Makefile b/Makefile index cf34227..5a95b57 100644 --- a/Makefile +++ b/Makefile @@ -687,6 +687,7 @@ apps-install: $(app-dirs-install) @$(call make_as_parent, -C tools/apps/ipconfig install) @$(call make_as_parent, -C tools/dev-libs/elfutils install) @$(call make_as_parent, -C tools/dev-util/perf install) + @$(call make_as_parent, -C tools/sys-apps/bash install) PHONY += apps-clean apps-clean: $(app-dirs-clean) diff --git a/tools/sys-apps/bash/Makefile b/tools/sys-apps/bash/Makefile new file mode 100644 index 0000000..b0a181e --- /dev/null +++ b/tools/sys-apps/bash/Makefile @@ -0,0 +1,57 @@ +include ../../Makefrag + +########## Package-specific variables +version := 4.3.30 +src-dir = bash-$(version) +build-dir = $(src-dir)/build +tarball = bash-$(version).tar.gz +fetch-url = http://ftp.gnu.org/gnu/bash/$(tarball) +config-opts = --prefix=/usr \ + --bindir=/bin \ + --without-bash-malloc \ + --disable-nls \ + --host=x86_64-ucb-akaros \ + --build=i686-pc-linux-gnu + +########## Generic Infrastructure + +PHONY := all +all: make + +%.tar.gz: + $(Q)wget $(fetch-url) + +akaros-patches := $(sort $(wildcard akaros-patches/$(version)/*)) + +$(build-dir): $(tarball) $(akaros-patches) + rm -fr $(src-dir) + tar -xf $< + $(Q)mkdir $(build-dir) && \ + for i in $(akaros-patches); do \ + (cd $(src-dir) && patch -p1 < ../$$i); \ + done + +PHONY += config +$(build-dir)/Makefile config: $(build-dir) + cd $(build-dir) && env ../configure $(config-opts) + +PHONY += make +make: config + $(Q)$(MAKE) -C $(build-dir) + +PHONY += install +install: make + rm -f $(KFS_ROOT)/bin/bash + $(Q)$(MAKE) -C $(build-dir) install DESTDIR=$(KFS_ROOT) + +PHONY += clean +clean: + $(Q)[ -d $(build-dir) ] && \ + [ -f $(build-dir)/Makefile ] && \ + $(MAKE) -C $(build-dir) clean || true + +PHONY += mrproper +mrproper: + $(Q)rm -rf $(src-dir) + +.PHONY: $(PHONY) diff --git a/tools/sys-apps/bash/akaros-patches/4.3.30/bash-4.3.30.patch b/tools/sys-apps/bash/akaros-patches/4.3.30/bash-4.3.30.patch new file mode 100644 index 0000000..c84c561 --- /dev/null +++ b/tools/sys-apps/bash/akaros-patches/4.3.30/bash-4.3.30.patch @@ -0,0 +1,179 @@ +Only in bash-4.3.30: build +diff -ur bash-4.3.30.dist/builtins/echo.def bash-4.3.30/builtins/echo.def +--- bash-4.3.30.dist/builtins/echo.def 2011-06-29 09:55:58.000000000 -0400 ++++ bash-4.3.30/builtins/echo.def 2016-06-03 17:40:57.834915855 -0400 +@@ -108,8 +108,9 @@ + echo_builtin (list) + WORD_LIST *list; + { +- int display_return, do_v9, i, len; +- char *temp, *s; ++ int display_return, do_v9, i, j, len, malloc_len; ++ char *temp, *s, *m; ++ WORD_LIST *save_list; + + do_v9 = xpg_echo; + display_return = 1; +@@ -162,6 +163,30 @@ + clearerr (stdout); /* clear error before writing and testing success */ + + terminate_immediately++; ++ malloc_len = 0; ++ m = NULL; ++ save_list = list; ++ while (list) ++ { ++ i = len = 0; ++ temp = do_v9 ? ansicstr (list->word->word, STRLEN (list->word->word), 1, &i, &len) ++ : list->word->word; ++ if (!temp) ++ continue; ++ malloc_len += do_v9 ? len : strlen(temp); ++ if (do_v9) ++ free (temp); ++ list = list->next; ++ if (list) ++ malloc_len++; ++ } ++ if (display_return) ++ malloc_len++; ++ m = malloc(malloc_len); ++ if (m == NULL) ++ fatal_error ("echo: could not allocate %lu bytes", (unsigned long)malloc_len); ++ list = save_list; ++ j = 0; + while (list) + { + i = len = 0; +@@ -169,19 +194,13 @@ + : list->word->word; + if (temp) + { +- if (do_v9) +- { +- for (s = temp; len > 0; len--) +- putchar (*s++); +- } +- else +- printf ("%s", temp); +-#if defined (SunOS5) +- fflush (stdout); /* Fix for bug in SunOS 5.5 printf(3) */ +-#endif ++ if (!do_v9) ++ len = strlen(temp); ++ memmove(m + j, temp, len); ++ j += len; ++ if (do_v9) ++ free (temp); + } +- if (do_v9 && temp) +- free (temp); + list = list->next; + if (i) + { +@@ -189,11 +208,15 @@ + break; + } + if (list) +- putchar(' '); ++ m[j++] = ' '; + } +- + if (display_return) +- putchar ('\n'); ++ m[j++] = '\n'; ++ write(STDOUT_FILENO, m, j); ++ free(m); ++#if defined (SunOS5) ++ fflush (stdout); /* Fix for bug in SunOS 5.5 printf(3) */ ++#endif + + terminate_immediately--; + return (sh_chkwrite (EXECUTION_SUCCESS)); +diff -ur bash-4.3.30.dist/configure bash-4.3.30/configure +--- bash-4.3.30.dist/configure 2014-02-11 10:38:00.000000000 -0500 ++++ bash-4.3.30/configure 2016-05-16 23:04:59.481616025 -0400 +@@ -2853,6 +2853,7 @@ + sparc-linux*) opt_bash_malloc=no ;; # sparc running linux; requires ELF + #*-freebsd*-gnu) opt_bash_malloc=no ;; # there's some undetermined problem here + #*-freebsd*) opt_bash_malloc=no ;; # they claim it's better; I disagree ++*-akaros*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment + *-openbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment + *-mirbsd*) opt_bash_malloc=no ;; # they claim it needs eight-bit alignment + *-aix*) opt_bash_malloc=no ;; # AIX machines +diff -ur bash-4.3.30.dist/error.c bash-4.3.30/error.c +--- bash-4.3.30.dist/error.c 2014-01-17 08:09:33.000000000 -0500 ++++ bash-4.3.30/error.c 2016-05-25 13:40:26.978379551 -0400 +@@ -487,3 +487,32 @@ + { + report_error (_("%s: readonly variable"), s); + } ++ ++#if defined (USE_AKAROS_STRERROR) ++#ifndef MAX_ERRSTR_LEN ++#define MAX_ERRSTR_LEN 128 ++#endif ++char * ++akaros_strerror(e) ++ int e; ++{ ++ static char emsg[2*MAX_ERRSTR_LEN]; ++ char ebuf[MAX_ERRSTR_LEN]; ++ size_t len; ++ int serrno; ++ char *estr, *strerror_str; ++ ++ serrno = errno; ++ estr = errstr (); ++ strerror_str = strerror_r (e, ebuf, sizeof (ebuf)); ++ len = strlen (strerror_str); ++ if (len > (sizeof (emsg) - 1)) ++ len = sizeof (emsg) - 1; ++ memmove (emsg, strerror_str, len); ++ if (e == serrno && estr && *estr) ++ snprintf (emsg + len, sizeof (emsg) - len, ", %s", estr); ++ ebuf[sizeof (ebuf) - 1] = '\0'; ++ ++ return emsg; ++} ++#endif +diff -ur bash-4.3.30.dist/mksyntax.c bash-4.3.30/mksyntax.c +--- bash-4.3.30.dist/mksyntax.c 2012-07-29 19:48:38.000000000 -0400 ++++ bash-4.3.30/mksyntax.c 2016-05-25 11:59:57.560352289 -0400 +@@ -40,6 +40,10 @@ + extern int errno; + #endif + ++#ifdef strerror ++#undef strerror ++#endif ++ + #ifndef HAVE_STRERROR + extern char *strerror(); + #endif +diff -ur bash-4.3.30.dist/support/config.guess bash-4.3.30/support/config.guess +--- bash-4.3.30.dist/support/config.guess 2013-12-16 16:02:33.000000000 -0500 ++++ bash-4.3.30/support/config.guess 2016-05-16 23:04:12.844336864 -0400 +@@ -219,6 +219,10 @@ + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; ++ *:Akaros:*:*) ++ UNAME_MACHINE_ARCH=x86_64 ++ echo x86_64-ucb-akaros1.0 ++ exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} +diff -ur bash-4.3.30.dist/support/config.sub bash-4.3.30/support/config.sub +--- bash-4.3.30.dist/support/config.sub 2013-12-17 10:49:47.000000000 -0500 ++++ bash-4.3.30/support/config.sub 2016-05-16 23:05:28.906423063 -0400 +@@ -1356,7 +1356,7 @@ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ +- | -aos* | -aros* \ ++ | -akaros* | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ -- 2.8.0.rc3.226.g39d4020 -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
