From 6742e41e3d205c1dc1d6961a1cefe0f1c30d33a8 Mon Sep 17 00:00:00 2001 From: Greg Gauthier Date: Mon, 1 Jun 2026 21:03:04 +0100 Subject: [PATCH] refactor(install): move program files to ~/.local/share/floppy-utils Installs the core script + lib/ under XDG_DATA_HOME/floppy-utils and generates thin wrappers in ~/.local/bin. Updates floppy resolver, install.sh, README, and adds early returns in check-deps logging helpers. --- README.md | 4 ++++ check-deps.sh | 6 +++++- install.sh | 34 ++++++++++++++++++++++++++++------ src/floppy | 22 +++++++++++++++++++++- 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b83431c..d75d39c 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ floppy-utils/ There is no daemon. Scripts use `sudo` when not root for `dd`, `blockdev`, `losetup`, and mount operations. +After `install.sh`, the main script lives at `~/.local/share/floppy-utils/floppy`; `~/.local/bin/floppy` is a wrapper that finds it. + --- ## Requirements @@ -124,6 +126,8 @@ sudo ./check-deps.sh --install ./install.sh ``` +This installs the library to `~/.local/share/floppy-utils/` (including `lib/common.sh`) and places small wrapper scripts in `~/.local/bin/`. You can still run `./src/floppy` directly from a git checkout. + Ensure `~/.local/bin` is in your shell `PATH` (add to `~/.bashrc` or `~/.zshrc` if needed): ```bash diff --git a/check-deps.sh b/check-deps.sh index 3916ffb..97f4c1e 100755 --- a/check-deps.sh +++ b/check-deps.sh @@ -35,11 +35,15 @@ while [[ $# -gt 0 ]]; do done log() { - [[ "$QUIET" -eq 0 ]] && echo "$@" + if [[ "$QUIET" -eq 0 ]]; then + echo "$@" + fi + return 0 } warn() { echo "check-deps.sh: $*" >&2 + return 0 } die() { diff --git a/install.sh b/install.sh index a33879e..14006d5 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# Install floppy-utils scripts to ~/.local/bin +# Install floppy-utils: program files in ~/.local/share, wrappers in ~/.local/bin set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" @@ -12,12 +12,34 @@ if [[ -x "$ROOT/check-deps.sh" ]]; then fi SRC="$ROOT/src" +SHARE="${XDG_DATA_HOME:-$HOME/.local/share}/floppy-utils" DEST="${HOME}/.local/bin" -mkdir -p "$DEST" -for cmd in floppy floppy-make floppy-attach floppy-burn; do - install -m 755 "$SRC/$cmd" "$DEST/$cmd" -done +mkdir -p "$SHARE/lib" "$DEST" +install -m 755 "$SRC/floppy" "$SHARE/floppy" +install -m 644 "$SRC/lib/common.sh" "$SHARE/lib/common.sh" -echo "Installed to $DEST" +install_wrapper() { + local name="$1" + shift + local launcher="$SHARE/floppy" + local args_quoted="" + local arg + for arg in "$@"; do + args_quoted+="$(printf '%q' "$arg") " + done + cat >"$DEST/$name" <&2 + exit 1 +} + +FLOPPY_SCRIPT_DIR="$(floppy_resolve_script_dir)" # shellcheck source=lib/common.sh source "$FLOPPY_SCRIPT_DIR/lib/common.sh" floppy_load_config