mirror of
https://github.com/uutils/coreutils
synced 2024-11-14 17:07:10 +00:00
stdbuf - install multicall
This commit is contained in:
parent
b71df2fd78
commit
ec4182fcf1
2 changed files with 21 additions and 17 deletions
25
Makefile
25
Makefile
|
@ -3,15 +3,15 @@ ENABLE_LTO ?= n
|
|||
ENABLE_STRIP ?= n
|
||||
|
||||
# Binaries
|
||||
RUSTC ?= rustc
|
||||
CARGO ?= cargo
|
||||
CC ?= gcc
|
||||
RM := rm
|
||||
RUSTC ?= rustc
|
||||
CARGO ?= cargo
|
||||
CC ?= gcc
|
||||
RM := rm
|
||||
|
||||
# Install directories
|
||||
PREFIX ?= /usr/local
|
||||
BINDIR ?= /bin
|
||||
LIBDIR ?= /lib
|
||||
PREFIX ?= /usr/local
|
||||
BINDIR ?= /bin
|
||||
LIBDIR ?= /lib
|
||||
|
||||
# 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.
|
||||
|
@ -143,16 +143,16 @@ INSTALLEES := \
|
|||
SYSTEM := $(shell uname)
|
||||
DYLIB_EXT :=
|
||||
ifeq ($(SYSTEM),Linux)
|
||||
DYLIB_EXT := so
|
||||
DYLIB_EXT := .so
|
||||
endif
|
||||
ifeq ($(SYSTEM),Darwin)
|
||||
DYLIB_EXT := dylib
|
||||
DYLIB_EXT := .dylib
|
||||
endif
|
||||
|
||||
# Libaries to install
|
||||
LIBS :=
|
||||
ifneq (,$(findstring stdbuf, $(INSTALLEES)))
|
||||
LIBS += libstdbuf.$(DYLIB_EXT)
|
||||
LIBS += libstdbuf$(DYLIB_EXT)
|
||||
endif
|
||||
|
||||
# Programs with usable tests
|
||||
|
@ -319,6 +319,10 @@ install-multicall: $(BUILDDIR)/uutils
|
|||
for prog in $(INSTALLEES); do \
|
||||
ln -s $(PROG_PREFIX)uutils $$prog; \
|
||||
done
|
||||
mkdir -p $(DESTDIR)$(PREFIX)$(LIBDIR)
|
||||
for lib in $(LIBS); do \
|
||||
install $(BUILDDIR)/$$lib $(DESTDIR)$(PREFIX)$(LIBDIR)/$$lib; \
|
||||
done
|
||||
|
||||
uninstall:
|
||||
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/$(PROG_PREFIX),$(PROGS))
|
||||
|
@ -326,6 +330,7 @@ uninstall:
|
|||
|
||||
uninstall-multicall:
|
||||
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(BINDIR)/,$(PROGS) $(PROG_PREFIX)uutils)
|
||||
rm -f $(addprefix $(DESTDIR)$(PREFIX)$(LIBDIR)/,$(LIBS))
|
||||
|
||||
# Test under the busybox testsuite
|
||||
$(BUILDDIR)/busybox: $(BUILDDIR)/uutils
|
||||
|
|
|
@ -57,7 +57,7 @@ fn preload_strings() -> (&'static str, &'static str) {
|
|||
|
||||
#[cfg(target_os = "macos")]
|
||||
fn preload_strings() -> (&'static str, &'static str) {
|
||||
("DYLD_INSERT_LIBRARIES", ".dyl")
|
||||
("DYLD_INSERT_LIBRARIES", ".dylib")
|
||||
}
|
||||
|
||||
#[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 command_idx = -1;
|
||||
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) => {
|
||||
command_idx = i - 1;
|
||||
break;
|
||||
|
@ -239,14 +239,13 @@ pub fn uumain(args: Vec<String>) -> isize {
|
|||
let ref command_name = args[command_idx];
|
||||
let mut command = Command::new(command_name);
|
||||
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));
|
||||
set_command_env(&mut command, "_STDBUF_I", options.stdin);
|
||||
set_command_env(&mut command, "_STDBUF_O", options.stdout);
|
||||
set_command_env(&mut command, "_STDBUF_E", options.stderr);
|
||||
match command.spawn() {
|
||||
Ok(_) => {},
|
||||
Err(e) => crash!(1, "failed to execute process: {}", e),
|
||||
};
|
||||
if let Err(e) = command.spawn() {
|
||||
crash!(1, "failed to execute process: {}", e);
|
||||
}
|
||||
0
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue