1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

stdbuf - install multicall

This commit is contained in:
dokaptur 2015-01-23 17:35:54 +01:00
parent b71df2fd78
commit ec4182fcf1
2 changed files with 21 additions and 17 deletions

View file

@ -3,15 +3,15 @@ ENABLE_LTO ?= n
ENABLE_STRIP ?= n ENABLE_STRIP ?= n
# Binaries # Binaries
RUSTC ?= rustc RUSTC ?= rustc
CARGO ?= cargo CARGO ?= cargo
CC ?= gcc CC ?= gcc
RM := rm RM := rm
# Install directories # Install directories
PREFIX ?= /usr/local PREFIX ?= /usr/local
BINDIR ?= /bin BINDIR ?= /bin
LIBDIR ?= /lib LIBDIR ?= /lib
# This won't support any directory with spaces in its name, but you can just # This won't support any directory with spaces in its name, but you can just
# make a symlink without spaces that points to the directory. # make a symlink without spaces that points to the directory.
@ -143,16 +143,16 @@ INSTALLEES := \
SYSTEM := $(shell uname) SYSTEM := $(shell uname)
DYLIB_EXT := DYLIB_EXT :=
ifeq ($(SYSTEM),Linux) ifeq ($(SYSTEM),Linux)
DYLIB_EXT := so DYLIB_EXT := .so
endif endif
ifeq ($(SYSTEM),Darwin) ifeq ($(SYSTEM),Darwin)
DYLIB_EXT := dylib DYLIB_EXT := .dylib
endif endif
# Libaries to install # Libaries to install
LIBS := LIBS :=
ifneq (,$(findstring stdbuf, $(INSTALLEES))) ifneq (,$(findstring stdbuf, $(INSTALLEES)))
LIBS += libstdbuf.$(DYLIB_EXT) LIBS += libstdbuf$(DYLIB_EXT)
endif endif
# Programs with usable tests # Programs with usable tests
@ -319,6 +319,10 @@ install-multicall: $(BUILDDIR)/uutils
for prog in $(INSTALLEES); do \ for prog in $(INSTALLEES); do \
ln -s $(PROG_PREFIX)uutils $$prog; \ ln -s $(PROG_PREFIX)uutils $$prog; \
done done
mkdir -p $(DESTDIR)$(PREFIX)$(LIBDIR)
for lib in $(LIBS); do \
install $(BUILDDIR)/$$lib $(DESTDIR)$(PREFIX)$(LIBDIR)/$$lib; \
done
uninstall: uninstall:
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX),$(PROGS)) rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX),$(PROGS))
@ -326,6 +330,7 @@ uninstall:
uninstall-multicall: uninstall-multicall:
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/,$(PROGS) $(PROG_PREFIX)uutils) rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/,$(PROGS) $(PROG_PREFIX)uutils)
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(LIBDIR)/,$(LIBS))
# Test under the busybox testsuite # Test under the busybox testsuite
$(BUILDDIR)/busybox: $(BUILDDIR)/uutils $(BUILDDIR)/busybox: $(BUILDDIR)/uutils

View file

@ -57,7 +57,7 @@ fn preload_strings() -> (&'static str, &'static str) {
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
fn preload_strings() -> (&'static str, &'static str) { fn preload_strings() -> (&'static str, &'static str) {
("DYLD_INSERT_LIBRARIES", ".dyl") ("DYLD_INSERT_LIBRARIES", ".dylib")
} }
#[cfg(not(any(target_os = "linux", target_os = "macos")))] #[cfg(not(any(target_os = "linux", target_os = "macos")))]
@ -216,7 +216,7 @@ pub fn uumain(args: Vec<String>) -> isize {
let mut options = ProgramOptions {stdin: BufferType::Default, stdout: BufferType::Default, stderr: BufferType::Default}; let mut options = ProgramOptions {stdin: BufferType::Default, stdout: BufferType::Default, stderr: BufferType::Default};
let mut command_idx = -1; let mut command_idx = -1;
for i in range_inclusive(1, args.len()) { for i in range_inclusive(1, args.len()) {
match parse_options(args.slice(1, i), &mut options, &optgrps) { match parse_options(&args[1 .. i], &mut options, &optgrps) {
Ok(OkMsg::Buffering) => { Ok(OkMsg::Buffering) => {
command_idx = i - 1; command_idx = i - 1;
break; break;
@ -239,14 +239,13 @@ pub fn uumain(args: Vec<String>) -> isize {
let ref command_name = args[command_idx]; let ref command_name = args[command_idx];
let mut command = Command::new(command_name); let mut command = Command::new(command_name);
let (preload_env, libstdbuf) = get_preload_env(); let (preload_env, libstdbuf) = get_preload_env();
command.args(args.slice_from(command_idx+1)).env(preload_env.as_slice(), libstdbuf.as_slice()); command.args(&args[command_idx + 1 ..]).env(preload_env.as_slice(), libstdbuf.as_slice());
command.stdin(StdioContainer::InheritFd(0)).stdout(StdioContainer::InheritFd(1)).stderr(StdioContainer::InheritFd(2)); command.stdin(StdioContainer::InheritFd(0)).stdout(StdioContainer::InheritFd(1)).stderr(StdioContainer::InheritFd(2));
set_command_env(&mut command, "_STDBUF_I", options.stdin); set_command_env(&mut command, "_STDBUF_I", options.stdin);
set_command_env(&mut command, "_STDBUF_O", options.stdout); set_command_env(&mut command, "_STDBUF_O", options.stdout);
set_command_env(&mut command, "_STDBUF_E", options.stderr); set_command_env(&mut command, "_STDBUF_E", options.stderr);
match command.spawn() { if let Err(e) = command.spawn() {
Ok(_) => {}, crash!(1, "failed to execute process: {}", e);
Err(e) => crash!(1, "failed to execute process: {}", e), }
};
0 0
} }