Skip to content

Commit

Permalink
merge with upstream master
Browse files Browse the repository at this point in the history
  • Loading branch information
staalmannen committed Nov 27, 2015
2 parents b0ce184 + ab879a4 commit 298b4db
Show file tree
Hide file tree
Showing 610 changed files with 12,748 additions and 47,136 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,11 @@ core
/busybox.links
/runtest-tempdir-links
/testsuite/echo-ne

#
# cscope output
#
cscope.files
cscope.in.out
cscope.out
cscope.po.out
27 changes: 19 additions & 8 deletions Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -644,16 +644,27 @@ config LFS
cp, mount, tar, and many others. If you want to access files larger
than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.

config NOGLOB
bool "Turn off MSVCRT argument processing"
default y
config GLOBBING
bool "Allow busybox.exe to expand wildcards"
default n
depends on PLATFORM_MINGW32
help
In Microsoft Windows expansion of wildcards on the command line
('globbing') is handled by the C runtime while the BusyBox shell
does its own wildcard expansion. For best results when using the
shell globbing by the C runtime should be turned off. If you want
the BusyBox binary to handle wildcard expansion using the C runtime
set this to 'Y'.

config SAFE_ENV
bool "Manipulate the environment through safe API calls"
default n
depends on PLATFORM_MINGW32
help
The Microsoft C Runtime handles the expansion of wildcards on the
command line while the BusyBox shell does its own wildcard expansion.
For best results when using the shell MSVCRT globbing should be
turned off. If you want the BusyBox binary to handle wildcard
expansion using the Microsoft C Runtime set this to 'N'.
Enable this option to use safe API calls when clearing environment
variables. This is necessary if BusyBox is to run on ReactOS or
64-bit Windows. The default is 'N', which must be used if BusyBox
is to run on Windows XP.

config CROSS_COMPILER_PREFIX
string "Cross Compiler prefix"
Expand Down
25 changes: 4 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION = 1
PATCHLEVEL = 23
PATCHLEVEL = 25
SUBLEVEL = 0
EXTRAVERSION =
EXTRAVERSION = .git
NAME = Unnamed

# *DOCUMENTATION*
Expand Down Expand Up @@ -555,7 +555,7 @@ export INSTALL_PATH ?= /boot
#
# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
# relocations required by build roots. This is not defined in the
# makefile but the arguement can be passed to make if needed.
# makefile but the argument can be passed to make if needed.
#

MODLIB = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
Expand Down Expand Up @@ -1176,24 +1176,7 @@ endif
ALLSOURCE_ARCHS := $(ARCH)

define all-sources
( find $(__srctree) $(RCS_FIND_IGNORE) \
\( -name include -o -name arch \) -prune -o \
-name '*.[chS]' -print; \
for ARCH in $(ALLSOURCE_ARCHS) ; do \
find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \
-name '*.[chS]' -print; \
done ; \
find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \
-name '*.[chS]' -print; \
find $(__srctree)include $(RCS_FIND_IGNORE) \
\( -name config -o -name 'asm-*' \) -prune \
-o -name '*.[chS]' -print; \
for ARCH in $(ALLINCLUDE_ARCHS) ; do \
find $(__srctree)include/asm-$${ARCH} $(RCS_FIND_IGNORE) \
-name '*.[chS]' -print; \
done ; \
find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
-name '*.[chS]' -print )
( find -regex '.*\.[ch]$$' )
endef

quiet_cmd_cscope-file = FILELST cscope.files
Expand Down
4 changes: 4 additions & 0 deletions Makefile.custom
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ ifeq ($(CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER),y)
INSTALL_OPTS:= --scriptwrapper
endif
endif
ifeq ($(CONFIG_FEATURE_INDIVIDUAL),y)
INSTALL_OPTS:= --binaries
LIBBUSYBOX_SONAME:= 0_lib/libbusybox.so.$(BB_VER)
endif
install: $(srctree)/applets/install.sh busybox busybox.links
$(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
$(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
Expand Down
26 changes: 17 additions & 9 deletions Makefile.flags
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ CPPFLAGS += \
$(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
-D"BB_VER=\"$(BB_VER)\"" -DBB_BT=AUTOCONF_TIMESTAMP


CFLAGS += $(call cc-option,-Wall,)
CFLAGS += $(call cc-option,-Wshadow,)
CFLAGS += $(call cc-option,-Wwrite-strings,)
Expand Down Expand Up @@ -72,6 +73,9 @@ CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1
# Defeat .eh_frame bloat (gcc 4.6.3 x86-32 defconfig: 20% smaller busybox binary):
CFLAGS += $(call cc-option,-fno-unwind-tables,)
CFLAGS += $(call cc-option,-fno-asynchronous-unwind-tables,)
# No automatic printf->puts,putchar conversions
# (try disabling this and comparing assembly, it's instructive)
CFLAGS += $(call cc-option,-fno-builtin-printf,)

# FIXME: These warnings are at least partially to be concerned about and should
# be fixed..
Expand Down Expand Up @@ -197,15 +201,19 @@ LDLIBS += m
endif
endif #watcom does not have any of these

# libpam may use libpthread, libdl and/or libaudit.
# On some platforms that requires an explicit -lpthread, -ldl, -laudit.
# However, on *other platforms* it fails when some of those flags
# given needlessly. On some systems, crypt needs pthread.
#
# I even had a system where a runtime test for pthread
# (similar to CRYPT_AVAILABLE test above) was not reliable.
#
# Do not propagate this mess by adding libraries to CONFIG_PAM/CRYPT_AVAILABLE blocks.
# Add libraries you need to CONFIG_EXTRA_LDLIBS instead.

ifeq ($(CONFIG_PAM),y)
# libpam uses libpthread, so for static builds busybox must be linked to
# libpthread. On some platforms that requires an explicit -lpthread, so
# it should be in LDLIBS. For non-static builds, scripts/trylink will
# take care of removing -lpthread if possible. (Not bothering to check
# CONFIG_STATIC because even in a non-static build it could be that the
# only libpam available is libpam.a, so -lpthread could still be
# needed.)
LDLIBS += pam pam_misc pthread
LDLIBS += pam pam_misc
endif

ifeq ($(CONFIG_SELINUX),y)
Expand Down Expand Up @@ -234,7 +242,7 @@ SKIP_STRIP = y
endif

ifneq ($(CONFIG_EXTRA_LDFLAGS),)
EXTRA_LDFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_LDFLAGS)))
LDFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_LDFLAGS)))
#"))
endif

Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Supported hardware:
Under 2.4 Linux kernels, kernel module loading was implemented in a
platform-specific manner. Busybox's insmod utility has been reported to
work under ARM, CRIS, H8/300, x86, ia64, x86_64, m68k, MIPS, PowerPC, S390,
SH3/4/5, Sparc, v850e, and x86_64. Anything else probably won't work.
SH3/4/5, Sparc, and v850e. Anything else probably won't work.

The module loading mechanism for the 2.6 kernel is much more generic, and
we believe 2.6.x kernel module loading support should work on all
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
### Status

This port is used in production at Tigress. Things may work for you, or may not. Things may never work because of huge differences between Linux and Windows. Or things may work in future, if you report the problem to https://github.com/rmyorston/busybox-w32.
Things may work for you, or may not. Things may never work because of huge differences between Linux and Windows. Or things may work in future, if you report the problem to https://github.com/rmyorston/busybox-w32.

### Building

You need a MinGW compiler and a POSIX environment (so that `make menuconfig` works). I cross compile from Linux, but MSYS or Cygwin should be OK.
You need a MinGW compiler and a POSIX environment (so that `make menuconfig` works). I cross-compile on Linux. On Fedora or RHEL/CentOS+EPEL installing mingw32-gcc (32-bit build) or mingw64-gcc (64-bit build) will pull in everything needed.

To start, run `make mingw32_defconfig`. You can then customize your build with `make menuconfig`. Alternatively, to build using Open Watcom, run `make watcom386_win32_defconfig`. For more details about Open Watcom
, see README.watcom.
To start, run `make mingw32_defconfig` or `make mingw64_defconfig`. You can then customize your build with `make menuconfig`. alternatively, to build using Open Watcom, run `make watcom386_win32_defconfig`. For more details about Open Watcom, see README.watcom.

In particular you may need to adjust the compiler by going to Busybox Settings -> Build Options -> Cross Compiler Prefix

Expand All @@ -17,4 +16,7 @@ Then just `make`.

- Use forward slashes in paths: Windows doesn't mind and the shell will be happier.
- Don't do wild things with Windows drive or UNC notation.
- tar doesn't support seamless compression/decompression: use a pipeline to a compressor/decompressor.
- Wildcard expansion is disabled by default, though it can be turned on at compile time. This only affects command line arguments to the binary: the BusyBox shell has full support for wildcards.
- Handling of users, groups and permissions is totally bogus. The system only admits to knowing about the current user and always returns the same hardcoded uid, gid and permission values.
- Some crufty old Windows code (Windows XP, cmd.exe) doesn't like forward slashes in environment variables. The -X shell option (which must be the first argument) prevents busybox-w32 from changing backslashes to forward slashes. If Windows programs don't run from the shell it's worth trying it.
- If you want to install 32-bit BusyBox in a system directory on a 64-bit version of Windows you should put it in `C:\Windows\SysWOW64`, not `C:\Windows\System32` as you might expect. On 64-bit systems the latter is for 64-bit binaries.
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,3 @@ vdprintf() -> similar sized functionality

* more support for advanced linux 2.6.x features, see: iotop
most likely there is more

* even more support for statistics: mpstat, iostat, powertop....
26 changes: 24 additions & 2 deletions applets/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,26 @@ export LC_CTYPE=POSIX

prefix=$1
if [ -z "$prefix" ]; then
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--scriptwrapper]"
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--binaries/--scriptwrapper]"
exit 1
fi

# Source the configuration
. ./.config

h=`sort busybox.links | uniq`

sharedlib_dir="0_lib"

linkopts=""
scriptwrapper="n"
binaries="n"
cleanup="0"
noclobber="0"
case "$2" in
--hardlinks) linkopts="-f";;
--symlinks) linkopts="-fs";;
--binaries) binaries="y";;
--scriptwrapper) scriptwrapper="y";swrapall="y";;
--sw-sh-hard) scriptwrapper="y";linkopts="-f";;
--sw-sh-sym) scriptwrapper="y";linkopts="-fs";;
Expand All @@ -40,8 +47,9 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
for i in $DO_INSTALL_LIBS; do
rm -f "$prefix/$libdir/$i" || exit 1
if [ -f "$i" ]; then
echo " Installing $i to the target at $prefix/$libdir/"
cp -pPR "$i" "$prefix/$libdir/" || exit 1
chmod 0644 "$prefix/$libdir/$i" || exit 1
chmod 0644 "$prefix/$libdir/`basename $i`" || exit 1
fi
done
fi
Expand All @@ -68,6 +76,7 @@ install -m 755 busybox "$prefix/bin/busybox" || exit 1

for i in $h; do
appdir=`dirname "$i"`
app=`basename "$i"`
mkdir -p "$prefix/$appdir" || exit 1
if [ "$scriptwrapper" = "y" ]; then
if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then
Expand All @@ -78,6 +87,19 @@ for i in $h; do
chmod +x "$prefix/$i"
fi
echo " $prefix/$i"
elif [ "$binaries" = "y" ]; then
# Copy the binary over rather
if [ -e $sharedlib_dir/$app ]; then
if [ "$noclobber" = "0" ] || [ ! -e "$prefix/$i" ]; then
echo " Copying $sharedlib_dir/$app to $prefix/$i"
cp -pPR $sharedlib_dir/$app $prefix/$i || exit 1
else
echo " $prefix/$i already exists"
fi
else
echo "Error: Could not find $sharedlib_dir/$app"
exit 1
fi
else
if [ "$2" = "--hardlinks" ]; then
bb_path="$prefix/bin/busybox"
Expand Down
9 changes: 9 additions & 0 deletions applets/usage_compressed
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ exec >"$target.$$"

echo '#define UNPACKED_USAGE "" \'
"$loc/usage" | od -v -b \
| grep -v '^ ' \
| $SED -e 's/^[^ ]*//' \
-e 's/ //g' \
-e '/^$/d' \
-e 's/\(...\)/\\\1/g' \
-e 's/^/"/' \
-e 's/$/" \\/'
echo ''
# "grep -v '^ '" is for toybox's od bug: od -b prints some extra lines:
#0000000 010 000 010 000 133 055 144 146 135 040 133 055 143 040 103 117
# 000010 000010 026533 063144 020135 026533 020143 047503
#0000020 116 106 104 111 122 135 040 133 055 154 040 114 117 107 106 111
# 043116 044504 056522 055440 066055 046040 043517 044506
#0000040 114 105 135 040 133 055 141 040 101 103 124 111 117 116 106 111
# 042514 020135 026533 020141 041501 044524 047117 044506

echo '#define PACKED_USAGE \'
## Breaks on big-endian systems!
Expand All @@ -40,6 +48,7 @@ echo '#define PACKED_USAGE \'
## -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
## -e 's/$/ \\/'
"$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -b \
| grep -v '^ ' \
| $SED -e 's/^[^ ]*//' \
-e 's/ //g' \
-e '/^$/d' \
Expand Down
2 changes: 1 addition & 1 deletion archival/Config.src
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ config FEATURE_SEAMLESS_GZ

config FEATURE_SEAMLESS_Z
bool "tar, rpm, modprobe etc understand .Z data"
default n
default n # it is ancient
help
Make tar, rpm, modprobe etc understand .Z data.

Expand Down
2 changes: 1 addition & 1 deletion archival/Kbuild.src
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Licensed under GPLv2, see file LICENSE in this source tree.

libs-y += libarchive/
libs-y += libarchive/

lib-y:=

Expand Down
32 changes: 18 additions & 14 deletions archival/ar.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,13 @@
//config: default n # needs to be improved to be able to replace binutils ar
//config: help
//config: ar is an archival utility program used to create, modify, and
//config: extract contents from archives. An archive is a single file holding
//config: a collection of other files in a structure that makes it possible to
//config: retrieve the original individual files (called archive members).
//config: The original files' contents, mode (permissions), timestamp, owner,
//config: and group are preserved in the archive, and can be restored on
//config: extraction.
//config: extract contents from archives. In practice, it is used exclusively
//config: for object module archives used by compilers.
//config:
//config: The stored filename is limited to 15 characters. (for more information
//config: see long filename support).
//config: ar has 60 bytes of overheads for every stored file.
//config:
//config: This implementation of ar can extract archives, it cannot create or
//config: modify them.
//config: On an x86 system, the ar applet adds about 1K.
//config:
//config: Unless you have a specific application which requires ar, you should
//config: probably say N here.
//config: probably say N here: most compilers come with their own ar utility.
//config:
//config:config FEATURE_AR_LONG_FILENAMES
//config: bool "Support for long filenames (not needed for debs)"
Expand Down Expand Up @@ -175,6 +165,7 @@ static int write_ar_archive(archive_handle_t *handle)
{
struct stat st;
archive_handle_t *out_handle;
char *temp_fn = NULL;

xfstat(handle->src_fd, &st, handle->ar__name);

Expand All @@ -183,8 +174,14 @@ static int write_ar_archive(archive_handle_t *handle)
*/
if (st.st_size != 0) {
out_handle = init_handle();
#if !ENABLE_PLATFORM_MINGW32
xunlink(handle->ar__name);
out_handle->src_fd = xopen(handle->ar__name, O_WRONLY | O_CREAT | O_TRUNC);
#else
/* can't unlink open file, create temporary output file */
temp_fn = xasprintf("%sXXXXXX", handle->ar__name);
out_handle->src_fd = xmkstemp(temp_fn);
#endif
out_handle->accept = handle->accept;
} else {
out_handle = handle;
Expand All @@ -206,12 +203,19 @@ static int write_ar_archive(archive_handle_t *handle)
continue;

/* optional, since we exit right after we return */
if (ENABLE_FEATURE_CLEAN_UP) {
if (ENABLE_FEATURE_CLEAN_UP || ENABLE_PLATFORM_MINGW32) {
close(handle->src_fd);
if (out_handle->src_fd != handle->src_fd)
close(out_handle->src_fd);
}

#if ENABLE_PLATFORM_MINGW32
if ( temp_fn != NULL ) {
xrename(temp_fn, handle->ar__name);
free(temp_fn);
}
#endif

return EXIT_SUCCESS;
}
#endif /* FEATURE_AR_CREATE */
Expand Down
Loading

0 comments on commit 298b4db

Please sign in to comment.