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

Merge pull request #766 from nathanross/install

*nix install script and appveyor script
This commit is contained in:
Heather 2015-12-25 08:28:28 +04:00
commit 97793313c0
5 changed files with 103 additions and 28 deletions

View file

@ -1,9 +1,15 @@
# Config options # Config options
PROFILE ?= debug PROFILE ?= debug
ifneq (,$(filter install, $(MAKECMDGOALS)))
override PROFILE:=release
override BUILD:=INSTALL
override DONT_BUILD:=DONT_INSTALL
endif
MULTICALL ?= n MULTICALL ?= n
PROFILE_CMD := PROFILE_CMD :=
ifeq (${PROFILE},release) ifeq ($(PROFILE),release)
PROFILE_CMD = --release PROFILE_CMD = --release
endif endif
@ -12,11 +18,16 @@ CARGO ?= cargo
CARGOFLAGS ?= CARGOFLAGS ?=
# Install directories # Install directories
FS_ROOT ?= /
PREFIX ?= /usr/local PREFIX ?= /usr/local
BINDIR ?= /bin BINDIR ?= /bin
LIBDIR ?= /lib 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 # 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.
@ -189,11 +200,11 @@ endef
EXES := \ EXES := \
$(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS)))) $(sort $(filter $(BUILD),$(filter-out $(DONT_BUILD),$(PROGS))))
INSTALL ?= $(EXES)
INSTALLEES := \ INSTALLEES := \
$(sort $(filter $(INSTALL),$(filter-out $(DONT_INSTALL),$(EXES) uutils))) $(sort $(filter $(INSTALL),$(filter-out $(DONT_INSTALL),$(EXES) uutils)))
INSTALL ?= $(EXES)
# Shared library extension # Shared library extension
SYSTEM := $(shell uname) SYSTEM := $(shell uname)
DYLIB_EXT := DYLIB_EXT :=
@ -262,25 +273,23 @@ distclean: clean
# TODO: figure out if there is way for prefixes to work with the symlinks # TODO: figure out if there is way for prefixes to work with the symlinks
install: build install: build
PROFILE_CMD=--release mkdir -p $(INSTALLDIR_BIN)
mkdir -p $(INSTALLDIR)$(BINDIR) rm -f $(addprefix $(INSTALLDIR_BIN)/$(PROG_PREFIX),$(INSTALLEES))
ifeq (${MULTICALL}, y) ifeq (${MULTICALL}, y)
install $(BUILDDIR)/uutils $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX)uutils install $(BUILDDIR)/uutils $(INSTALLDIR_BIN)/$(PROG_PREFIX)uutils
cd $(INSTALLDIR)$(BINDIR) $(foreach prog, $(INSTALLEES), cd $(INSTALLDIR_BIN) && ln -s $(PROG_PREFIX)uutils $(PROG_PREFIX)$(prog);)
$(foreach prog, $(INSTALLEES), ln -s $(PROG_PREFIX)uutils $$prog;)
else else
$(foreach prog, $(INSTALLEES); \ $(foreach prog, $(INSTALLEES), \
install $(PKG_BUILDDIR)/$$prog $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX)$$prog;) install $(PKG_BUILDDIR)/$(prog) $(INSTALLDIR_BIN)/$(PROG_PREFIX)$(prog);)
endif endif
mkdir -p $(INSTALLDIR)$(LIBDIR) mkdir -p $(INSTALLDIR_LIB)
$(foreach lib, $(LIBS), install $(BUILDDIR)/$$lib $(INSTALLDIR)$(LIBDIR)/$$lib;) $(foreach lib, $(LIBS), install $(BUILDDIR)/$$lib $(INSTALLDIR_LIB)/$(lib);)
uninstall: uninstall:
rm -f $(addprefix $(INSTALLDIR)$(BINDIR)/$(PROG_PREFIX),$(PROGS)) ifeq (${MULTICALL}, y)
rm -f $(addprefix $(INSTALLDIR)$(LIBDIR)/,$(LIBS)) rm -f $(addprefix $(INSTALLDIR_BIN)/,$(PROG_PREFIX)uutils)
endif
uninstall-multicall: rm -f $(addprefix $(INSTALLDIR_BIN)/$(PROG_PREFIX),$(PROGS))
rm -f $(addprefix $(INSTALLDIR)$(BINDIR)/,$(PROGS) $(PROG_PREFIX)uutils) rm -f $(addprefix $(INSTALLDIR_LIB)/,$(LIBS))
rm -f $(addprefix $(INSTALLDIR)$(LIBDIR)/,$(LIBS))
.PHONY: all build test distclean clean busytest install uninstall .PHONY: all build test distclean clean busytest install uninstall

View file

@ -64,14 +64,19 @@ To install only a few of the available utilities:
make INSTALL='UTILITY_1 UTILITY_2' install 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 make PROG_PREFIX=PREFIX_GOES_HERE install
``` ```
To install the multicall binary: 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 Uninstallation Instructions
@ -89,7 +94,12 @@ make PROG_PREFIX=PREFIX_GOES_HERE uninstall
To uninstall the multicall binary: 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 Test Instructions

38
appveyor.yml Normal file
View file

@ -0,0 +1,38 @@
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</dev/null; make PROFILE='release' build"
- 7z a -tzip uutils.zip .\target\release\deps\*.exe
artifacts:
- path: uutils.zip
name: zipfile
- path: target\release\uutils.exe
name: uutils.exe
test_script:
- call %MBASH% "cd $APPVEYOR_BUILD_FOLDER; PATH=$PATH:/mingw64/bin:/mingw32/bin; exec 0</dev/null; make test"

View file

@ -49,14 +49,26 @@ fn main() {
None => (), None => (),
} }
if !(binary_as_util.ends_with("uutils") || binary_as_util.starts_with("uutils")) { if binary_as_util.ends_with("uutils") || binary_as_util.starts_with("uutils") {
println!("{}: applet not found", binary_as_util); args.remove(0);
std::process::exit(1); } 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. // try first arg as util name.
if args.len() >= 2 { if args.len() >= 1 {
args.remove(0);
let util = &args[0][..]; let util = &args[0][..];
match umap.get(util) { match umap.get(util) {

View file

@ -16,7 +16,13 @@ use std::ffi::OsStr;
use self::tempdir::TempDir; use self::tempdir::TempDir;
use std::rc::Rc; use std::rc::Rc;
#[cfg(windows)]
static PROGNAME: &'static str = "target\\debug\\uutils.exe";
#[cfg(windows)]
static FIXTURES_DIR: &'static str = "tests\\fixtures";
#[cfg(not(windows))]
static PROGNAME: &'static str = "target/debug/uutils"; static PROGNAME: &'static str = "target/debug/uutils";
#[cfg(not(windows))]
static FIXTURES_DIR: &'static str = "tests/fixtures"; static FIXTURES_DIR: &'static str = "tests/fixtures";
static ALREADY_RUN: &'static str = " you have already run this UCommand, if you want to run \ static ALREADY_RUN: &'static str = " you have already run this UCommand, if you want to run \
another command in the same test, use TestSet::new instead of \ another command in the same test, use TestSet::new instead of \