From caece01a6f484707816a52bdaadc109196749e5d Mon Sep 17 00:00:00 2001 From: Nathan Ross Date: Wed, 23 Dec 2015 22:53:27 -0500 Subject: [PATCH 1/4] add back initial appveyor file --- appveyor.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..b571c1390 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,33 @@ +platform: + - x64 + +environment: + global: + MSYS2_BASEVER: 20150512 + MSYS2_ARCH: x86_64 + MBASH: msys64\usr\bin\sh --login -c + + matrix: + - TARGET: i686-pc-windows-gnu + +install: + - appveyor DownloadFile "http://kent.dl.sourceforge.net/project/msys2/Base/%MSYS2_ARCH%/msys2-base-%MSYS2_ARCH%-%MSYS2_BASEVER%.tar.xz" -FileName "msys2.tar.xz" + - 7z x msys2.tar.xz + - 7z x msys2.tar > NUL + - call %MBASH% "" + - call %MBASH% "for i in {1..3}; do pacman --noconfirm -Suy mingw-w64-%MSYS2_ARCH%-{ragel,freetype,icu,gettext} libtool pkg-config gcc make autoconf automake perl && break || sleep 15; done" + - ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe" + - rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust" + - call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64 + - SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin + - SET PATH=%PATH%;C:\MinGW\bin + - rustc -V + - cargo -V + +build_script: + - call %MBASH% "cd $APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; exec 0 Date: Wed, 23 Dec 2015 22:59:04 -0500 Subject: [PATCH 2/4] appveyor and windows testing tooling updates --- appveyor.yml | 2 -- tests/common/util.rs | 6 ++++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index b571c1390..5454b76f4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -26,8 +26,6 @@ install: build_script: - call %MBASH% "cd $APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; exec 0 Date: Wed, 23 Dec 2015 23:14:55 -0500 Subject: [PATCH 4/4] fixes for linux install see notes calling install goal overrides utility build settings with utility install settings calling install goal defaults profile to --release PROG_PREFIX is now applied to all utilities modify uutils.rs to make symbolic link bins possible binary install paths rmd first to prevent errors due to lns simplify vars for more readable install target other minor fixes --- Makefile | 49 ++++++++++++++++++++++++++------------------ README.md | 16 ++++++++++++--- src/uutils/uutils.rs | 22 +++++++++++++++----- 3 files changed, 59 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 97d389d7c..e5477b630 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,15 @@ # Config options PROFILE ?= debug +ifneq (,$(filter install, $(MAKECMDGOALS))) +override PROFILE:=release +override BUILD:=INSTALL +override DONT_BUILD:=DONT_INSTALL +endif + MULTICALL ?= n PROFILE_CMD := -ifeq (${PROFILE},release) +ifeq ($(PROFILE),release) PROFILE_CMD = --release endif @@ -12,11 +18,16 @@ CARGO ?= cargo CARGOFLAGS ?= # Install directories +FS_ROOT ?= / PREFIX ?= /usr/local BINDIR ?= /bin LIBDIR ?= /lib -INSTALLDIR=$(DESTDIR)$(PREFIX) +INSTALLDIR_BIN=$(FS_ROOT)$(PREFIX)$(BINDIR) +INSTALLDIR_LIB=$(FS_ROOT)$(PREFIX)$(LIBDIR) + +#prefix to apply to uutils binary and all tool binaries +PROG_PREFIX ?= # 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. @@ -189,11 +200,11 @@ endef EXES := \ $(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS)))) +INSTALL ?= $(EXES) + INSTALLEES := \ $(sort $(filter $(INSTALL),$(filter-out $(DONT_INSTALL),$(EXES) uutils))) -INSTALL ?= $(EXES) - # Shared library extension SYSTEM := $(shell uname) DYLIB_EXT := @@ -261,26 +272,24 @@ distclean: clean $(CARGO) clean $(CARGOFLAGS) && $(CARGO) update $(CARGOFLAGS) # TODO: figure out if there is way for prefixes to work with the symlinks -install: build - PROFILE_CMD=--release - mkdir -p $(INSTALLDIR)$(BINDIR) +install: build + mkdir -p $(INSTALLDIR_BIN) + rm -f $(addprefix $(INSTALLDIR_BIN)/$(PROG_PREFIX),$(INSTALLEES)) ifeq (${MULTICALL}, y) - install $(BUILDDIR)/uutils $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX)uutils - cd $(INSTALLDIR)$(BINDIR) - $(foreach prog, $(INSTALLEES), ln -s $(PROG_PREFIX)uutils $$prog;) + install $(BUILDDIR)/uutils $(INSTALLDIR_BIN)/$(PROG_PREFIX)uutils + $(foreach prog, $(INSTALLEES), cd $(INSTALLDIR_BIN) && ln -s $(PROG_PREFIX)uutils $(PROG_PREFIX)$(prog);) else - $(foreach prog, $(INSTALLEES); \ - install $(PKG_BUILDDIR)/$$prog $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX)$$prog;) + $(foreach prog, $(INSTALLEES), \ + install $(PKG_BUILDDIR)/$(prog) $(INSTALLDIR_BIN)/$(PROG_PREFIX)$(prog);) endif - mkdir -p $(INSTALLDIR)$(LIBDIR) - $(foreach lib, $(LIBS), install $(BUILDDIR)/$$lib $(INSTALLDIR)$(LIBDIR)/$$lib;) + mkdir -p $(INSTALLDIR_LIB) + $(foreach lib, $(LIBS), install $(BUILDDIR)/$$lib $(INSTALLDIR_LIB)/$(lib);) uninstall: - rm -f $(addprefix $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX),$(PROGS)) - rm -f $(addprefix $(INSTALLDIR)$(LIBDIR)/,$(LIBS)) - -uninstall-multicall: - rm -f $(addprefix $(INSTALLDIR)$(BINDIR)/,$(PROGS) $(PROG_PREFIX)uutils) - rm -f $(addprefix $(INSTALLDIR)$(LIBDIR)/,$(LIBS)) +ifeq (${MULTICALL}, y) + rm -f $(addprefix $(INSTALLDIR_BIN)/,$(PROG_PREFIX)uutils) +endif + rm -f $(addprefix $(INSTALLDIR_BIN)/$(PROG_PREFIX),$(PROGS)) + rm -f $(addprefix $(INSTALLDIR_LIB)/,$(LIBS)) .PHONY: all build test distclean clean busytest install uninstall diff --git a/README.md b/README.md index 2675aa74d..7125ce710 100644 --- a/README.md +++ b/README.md @@ -64,14 +64,19 @@ To install only a few of the available utilities: make INSTALL='UTILITY_1 UTILITY_2' install ``` -To install every program with a prefix: +To install every program with a prefix (e.g. uu-echo uu-cat): ``` make PROG_PREFIX=PREFIX_GOES_HERE install ``` To install the multicall binary: ``` -make install-multicall +make MULTICALL=y install +``` + +Set install parent directory (default value is /usr/local): +``` +make PREFIX=/my/path install ``` Uninstallation Instructions @@ -89,7 +94,12 @@ make PROG_PREFIX=PREFIX_GOES_HERE uninstall To uninstall the multicall binary: ``` -make uninstall-multicall +make MULTICALL=y uninstall +``` + +To uninstall from a custom parent directory: +``` +make PREFIX=/my/path uninstall ``` Test Instructions diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index de335b6f2..69bafedd5 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -49,14 +49,26 @@ fn main() { None => (), } - if !(binary_as_util.ends_with("uutils") || binary_as_util.starts_with("uutils")) { - println!("{}: applet not found", binary_as_util); - std::process::exit(1); + if binary_as_util.ends_with("uutils") || binary_as_util.starts_with("uutils") { + args.remove(0); + } else { + let mut found = false; + for util in umap.keys() { + if binary_as_util.ends_with(util) { + args[0] = util.clone().to_owned(); + found = true; + break; + } + } + if ! found { + println!("{}: applet not found", binary_as_util); + std::process::exit(1); + } } // try first arg as util name. - if args.len() >= 2 { - args.remove(0); + if args.len() >= 1 { + let util = &args[0][..]; match umap.get(util) {