mirror of
https://github.com/gromgit/homebrew-fuse.git
synced 2025-12-31 15:02:17 +00:00
barebones brew test-fuse script
This commit is contained in:
parent
516a84eb28
commit
8890281c1a
2 changed files with 96 additions and 0 deletions
24
cmd/brew-test-fuse
Executable file
24
cmd/brew-test-fuse
Executable file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#:`brew test-fuse`
|
||||||
|
#: Tests local FUSE installation
|
||||||
|
|
||||||
|
. "$(dirname "$0")"/../lib/funcs.sh
|
||||||
|
|
||||||
|
tmpdir=/tmp/fuse-test.$$
|
||||||
|
mkdir -p "$tmpdir"
|
||||||
|
trap 'rm -fr "$tmpdir"' EXIT
|
||||||
|
|
||||||
|
[[ $(uname -s) == "Darwin" ]] || fatal "This script can only be run on macOS"
|
||||||
|
|
||||||
|
cd "$tmpdir"
|
||||||
|
eval "$(brew shellenv)"
|
||||||
|
|
||||||
|
info "Checking for FUSE installation"
|
||||||
|
cmd pkgutil --pkg-info io.macfuse.installer.components.core
|
||||||
|
cmd pkgutil --lsbom io.macfuse.installer.components.core
|
||||||
|
|
||||||
|
info "Test FUSE build"
|
||||||
|
# Get the last FUSE 2.x lowlevel example file
|
||||||
|
cmd curl -sOL https://raw.githubusercontent.com/libfuse/libfuse/46b9c3326d50aebe52c33d63885b83a47a2e74ea/example/hello_ll.c
|
||||||
|
# Build it Homebrew-style
|
||||||
|
cmd clang -D_FILE_OFFSET_BITS=64 -I/usr/local/include/fuse -L/usr/local/lib -g -O2 -Wall -o hello_ll hello_ll.c -lfuse -lpthread
|
||||||
72
lib/funcs.sh
Normal file
72
lib/funcs.sh
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
# string formatters
|
||||||
|
if [[ -t 1 ]]; then
|
||||||
|
Tty_escape() { printf "\033[%sm" "$1"; }
|
||||||
|
else
|
||||||
|
Tty_escape() { :; }
|
||||||
|
fi
|
||||||
|
Tty_mkbold() { Tty_escape "1;${1:-39}"; }
|
||||||
|
Tty_red=$(Tty_mkbold 31)
|
||||||
|
Tty_green=$(Tty_mkbold 32)
|
||||||
|
Tty_brown=$(Tty_mkbold 33)
|
||||||
|
Tty_blue=$(Tty_mkbold 34)
|
||||||
|
Tty_magenta=$(Tty_mkbold 35)
|
||||||
|
Tty_cyan=$(Tty_mkbold 36)
|
||||||
|
Tty_white=$(Tty_mkbold 37)
|
||||||
|
Tty_underscore=$(Tty_escape 38)
|
||||||
|
Tty_bold=$(Tty_mkbold 39)
|
||||||
|
Tty_reset=$(Tty_escape 0)
|
||||||
|
|
||||||
|
# fatal: Report fatal error
|
||||||
|
# USAGE: fatal <msg> ...
|
||||||
|
fatal() {
|
||||||
|
echo "${Tty_red}${msg_prefix}FATAL ERROR:${Tty_reset} $*" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# error: Report error
|
||||||
|
# USAGE: error <msg> ...
|
||||||
|
error() {
|
||||||
|
echo "${Tty_red}${msg_prefix}ERROR:${Tty_reset} $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# warn: Report warning
|
||||||
|
# USAGE: warn <msg> ...
|
||||||
|
warn() {
|
||||||
|
echo "${Tty_blue}${msg_prefix}Warning:${Tty_reset} $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# info: Informational message
|
||||||
|
# USAGE: info <msg> ...
|
||||||
|
info() {
|
||||||
|
echo "${Tty_green}${msg_prefix}Info:${Tty_reset} $*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
# need_progs: Checks for command dependencies
|
||||||
|
# USAGE: need_progs <cmd> ...
|
||||||
|
need_progs() {
|
||||||
|
local missing=()
|
||||||
|
local i
|
||||||
|
for i in "$@"; do
|
||||||
|
type -P "$i" &>/dev/null || missing+=("$i")
|
||||||
|
done
|
||||||
|
if [[ ${#missing[@]} -gt 0 ]]; then
|
||||||
|
fatal "Commands missing: ${missing[*]}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# cmd: Show command being run
|
||||||
|
# USAGE: cmd <cmd> ...
|
||||||
|
cmd() {
|
||||||
|
echo "${Tty_cyan}>>> $*${Tty_reset}" >&2
|
||||||
|
command "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# git_in: Run Git command in repo
|
||||||
|
# USAGE: git_in <repo> <cmd> ...
|
||||||
|
git_in() {
|
||||||
|
local repo=$1; shift
|
||||||
|
pushd "$repo" >/dev/null || fatal "Can't cd to '$repo'"
|
||||||
|
cmd git "$@"
|
||||||
|
popd >/dev/null
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue