mirror of
https://github.com/tobi/disktree.git
synced 2026-11-28 08:00:53 +00:00
disktree built and drew on macOS already, through GPUI's Metal backend, but the Linux plumbing underneath did not carry over. This makes it work well there, without unsafe code, and tightens removal safety for every platform on the way. Trash and removal - On macOS always the system Trash, through NSFileManager (the trash crate): the same move as Finder's, into the item's own disk's Trash. gio/trash-put/XDG would put files in ~/.local/share/Trash, which Finder never shows. - Refuse a directory holding the home directory (/Users is on the same volume as / on macOS) or a system tree (/opt holds /opt/homebrew); add /System, /Library, /private, /opt/homebrew, /cores, /Network. - Refuse a directory with a mount inside it; on macOS the mount list comes from /sbin/mount, read on a background thread. - Permanent deletion walks the tree itself and stops at a mount boundary, like rm -rf --one-file-system (the walker is from #10). - Guards see through /System/Volumes/Data spellings and, on macOS, case. Scanning - Skip /System/Volumes/Data when scanning /: it is /Users, /Applications and the rest again under firmlinks, so / was counted twice. - Whole disk (g, --disk) works: the disk root and device come from statfs. - Never list cloud-only (dataless) iCloud/File Provider folders, which would download them. - Keep a file's identity only when it has more than one name. App - Explain unreadable items when Full Disk Access is missing, with a button to the privacy settings. - A menu bar: Open Folder… (⌘O), Show in Finder (o, ⌘⇧R), Rescan (⌘R), Hide, Quit; closing the window quits; other ⌘ chords are not read as plain letters; help shows ⌘. - Follow the system light/dark appearance when no Omarchy theme exists. - Worth a look knows Xcode DerivedData, DeviceSupport and ~/Library/Logs. - git: skipped without the developer tools (its stub opens a dialog), and never runs a checkout's programs: fsmonitor, hooks and pager off, and no status for a checkout that defines its own filter drivers. Packaging - cargo xtask bundle builds disktree.app and a zip: Info.plist (bundle id io.github.tobi.disktree, macOS 11+), an icon drawn from an SVG on the macOS grid, ad-hoc or Developer ID signing, and --notarize. - make install on macOS puts the app in ~/Applications and links ~/.local/bin/disktree to it. - CI lints, tests and bundles on macOS; the release adds an arm64 macOS zip, signed and notarized when the repository has the Apple secrets.
122 lines
3.8 KiB
Makefile
122 lines
3.8 KiB
Makefile
# disktree: build, check, and install.
|
|
#
|
|
# `make install` puts the binary, a desktop entry and an icon under PREFIX
|
|
# (default: ~/.local), so disktree shows up in the Omarchy launcher and in
|
|
# "Open with" for directories. The default needs no root:
|
|
#
|
|
# make install # ~/.local/bin/disktree
|
|
# sudo make install PREFIX=/usr/local # system-wide
|
|
#
|
|
# On macOS it installs disktree.app into ~/Applications instead (APPS to
|
|
# change that), plus a `disktree` command in BINDIR that runs the app's
|
|
# binary, so both Spotlight and a terminal find it.
|
|
|
|
PREFIX ?= $(HOME)/.local
|
|
BINDIR ?= $(PREFIX)/bin
|
|
APPDIR ?= $(PREFIX)/share/applications
|
|
ICONDIR ?= $(PREFIX)/share/icons/hicolor/scalable/apps
|
|
|
|
APPS ?= $(HOME)/Applications
|
|
BUNDLE = target/bundle/disktree.app
|
|
UNAME := $(shell uname -s)
|
|
|
|
MANIFEST = Cargo.toml
|
|
CARGO ?= cargo
|
|
TARGET = target/release/disktree
|
|
ICON = assets/disktree.svg
|
|
DESKTOP = packaging/disktree.desktop.in
|
|
|
|
.PHONY: help build run install uninstall bundle lint test ci fmt clean
|
|
|
|
help:
|
|
@echo "disktree"
|
|
@echo
|
|
@echo " make build release build"
|
|
@echo " make run build and run, scanning $$HOME"
|
|
@echo " make install install to $(PREFIX): binary, desktop entry, icon"
|
|
@echo " (macOS: disktree.app into $(APPS))"
|
|
@echo " make bundle macOS: build target/bundle/disktree.app and its zip"
|
|
@echo " make uninstall remove what install put there"
|
|
@echo " make lint rustfmt --check and clippy -D warnings"
|
|
@echo " make test core and window-harness tests"
|
|
@echo " make ci lint, then test"
|
|
@echo " make fmt format in place"
|
|
@echo " make clean cargo clean"
|
|
|
|
# Always ask cargo: it is incremental and knows every source file, where a
|
|
# make file-target would only compare the binary against the manifest and
|
|
# happily install a stale build.
|
|
build:
|
|
$(CARGO) build --release
|
|
|
|
run: build
|
|
$(TARGET)
|
|
|
|
lint:
|
|
$(CARGO) xtask lint
|
|
|
|
test:
|
|
$(CARGO) xtask test
|
|
|
|
ci: lint test
|
|
|
|
fmt:
|
|
$(CARGO) xtask fmt-fix
|
|
|
|
ifeq ($(UNAME),Darwin)
|
|
# Replaced whole rather than copied over: a stale file left inside a signed
|
|
# bundle breaks its signature.
|
|
install:
|
|
$(CARGO) xtask bundle
|
|
install -d "$(APPS)" "$(BINDIR)"
|
|
rm -rf "$(APPS)/disktree.app"
|
|
ditto "$(BUNDLE)" "$(APPS)/disktree.app"
|
|
ln -sf "$(APPS)/disktree.app/Contents/MacOS/disktree" "$(BINDIR)/disktree"
|
|
@echo
|
|
@echo "installed:"
|
|
@echo " $(APPS)/disktree.app"
|
|
@echo " $(BINDIR)/disktree -> the app's binary"
|
|
@case ":$$PATH:" in *":$(BINDIR):"*) ;; *) \
|
|
echo; echo "note: $(BINDIR) is not on PATH in this shell";; esac
|
|
|
|
uninstall:
|
|
rm -rf "$(APPS)/disktree.app"
|
|
@if [ -L "$(BINDIR)/disktree" ]; then rm -f "$(BINDIR)/disktree"; fi
|
|
@echo "removed"
|
|
else
|
|
install: build
|
|
install -d $(BINDIR) $(APPDIR) $(ICONDIR)
|
|
install -m755 $(TARGET) $(BINDIR)/disktree
|
|
install -m644 $(ICON) $(ICONDIR)/disktree.svg
|
|
VERSION=$$(sed -n 's/^version = "\(.*\)"/\1/p' $(MANIFEST) | head -1) && \
|
|
sed -e 's|@BINDIR@|$(BINDIR)|' -e "s|@VERSION@|$$VERSION|" \
|
|
$(DESKTOP) > $(APPDIR)/disktree.desktop && \
|
|
chmod 644 $(APPDIR)/disktree.desktop
|
|
@if command -v update-desktop-database >/dev/null 2>&1; then \
|
|
update-desktop-database $(APPDIR) 2>/dev/null || true; \
|
|
fi
|
|
@echo
|
|
@echo "installed:"
|
|
@echo " $(BINDIR)/disktree"
|
|
@echo " $(APPDIR)/disktree.desktop"
|
|
@echo " $(ICONDIR)/disktree.svg"
|
|
@if command -v desktop-file-validate >/dev/null 2>&1; then \
|
|
desktop-file-validate $(APPDIR)/disktree.desktop || true; \
|
|
fi
|
|
@case ":$$PATH:" in *":$(BINDIR):"*) ;; *) \
|
|
echo; echo "note: $(BINDIR) is not on PATH in this shell";; esac
|
|
|
|
uninstall:
|
|
rm -f $(BINDIR)/disktree $(APPDIR)/disktree.desktop $(ICONDIR)/disktree.svg
|
|
@if command -v update-desktop-database >/dev/null 2>&1; then \
|
|
update-desktop-database $(APPDIR) 2>/dev/null || true; \
|
|
fi
|
|
@echo "removed"
|
|
endif
|
|
|
|
bundle:
|
|
$(CARGO) xtask bundle
|
|
|
|
clean:
|
|
$(CARGO) clean
|