summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-04 15:00:59 +0300
committerPaul Buetow <paul@buetow.org>2026-06-04 15:00:59 +0300
commit688a2b313e6d20044e0d32c7fa6309d183f2400f (patch)
tree55decf46d4b272297db00c170923d99171952506
parent89946d35517fb0f530b343956cdb42089ae07dcc (diff)
qi0 add just install workflow
-rw-r--r--Justfile68
-rw-r--r--Makefile50
-rw-r--r--README.md18
-rwxr-xr-xtests/cli.sh30
4 files changed, 118 insertions, 48 deletions
diff --git a/Justfile b/Justfile
new file mode 100644
index 0000000..f397cc0
--- /dev/null
+++ b/Justfile
@@ -0,0 +1,68 @@
+set shell := ["bash", "-euo", "pipefail", "-c"]
+
+NAME := "photoalbum"
+VERSION := "0.6.0"
+DESTDIR := env_var_or_default("DESTDIR", "")
+PREFIX := env_var_or_default("PREFIX", "/usr")
+BINDIR := env_var_or_default("BINDIR", PREFIX + "/bin")
+DATADIR := env_var_or_default("DATADIR", PREFIX + "/share")
+SYSCONFDIR := env_var_or_default("SYSCONFDIR", "/etc/default")
+
+default: build
+
+all: build
+
+version:
+ printf '%s\n' "{{VERSION}}"
+
+build:
+ mkdir -p ./bin
+ sed "s/PHOTOALBUMVERSION/{{VERSION}}/" \
+ "src/{{NAME}}.sh" > "./bin/{{NAME}}"
+ chmod 0755 "./bin/{{NAME}}"
+
+test: build
+ bash ./tests/cli.sh
+
+install: build
+ install -d "{{DESTDIR}}{{BINDIR}}"
+ install -m 0755 "./bin/{{NAME}}" "{{DESTDIR}}{{BINDIR}}/{{NAME}}"
+ install -d "{{DESTDIR}}{{DATADIR}}/{{NAME}}"
+ rm -rf "{{DESTDIR}}{{DATADIR}}/{{NAME}}/templates"
+ cp -R ./share/templates "{{DESTDIR}}{{DATADIR}}/{{NAME}}/"
+ install -d "{{DESTDIR}}{{SYSCONFDIR}}"
+ install -m 0644 \
+ ./src/photoalbum.default.conf \
+ "{{DESTDIR}}{{SYSCONFDIR}}/{{NAME}}"
+
+deinstall:
+ rm -f "{{DESTDIR}}{{BINDIR}}/{{NAME}}"
+ rm -rf "{{DESTDIR}}{{DATADIR}}/{{NAME}}"
+ rm -f "{{DESTDIR}}{{SYSCONFDIR}}/{{NAME}}"
+
+uninstall: deinstall
+
+clean:
+ rm -rf ./bin
+
+shellcheck:
+ # SC1090: ShellCheck can't follow non-constant source.
+ # SC2001: See if you can use ${variable//search/replace} instead.
+ # SC2010: Don't use ls | grep. Use a glob or a for loop.
+ # SC2012: Use find instead of ls for unusual filenames.
+ # SC2103: Use a subshell to avoid having to cd back.
+ # SC2155: Declare and assign separately to avoid masking return values.
+ # SC2164: Use 'cd ... || exit' or 'cd ... || return'.
+ # SC2207: Prefer mapfile or read -a to split command output.
+ shellcheck \
+ --exclude SC1090 \
+ --exclude SC2001 \
+ --exclude SC2010 \
+ --exclude SC2012 \
+ --exclude SC2103 \
+ --exclude SC2155 \
+ --exclude SC2164 \
+ --exclude SC2207 \
+ ./src/photoalbum.sh \
+ ./tests/cli.sh \
+ ./tests/helpers.sh
diff --git a/Makefile b/Makefile
index 31c3f9b..c329da1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,46 +1,4 @@
-NAME=photoalbum
-VERSION=0.6.0
-#DESTDIR=/
-all: build
-version:
- printf '%s\n' "$(VERSION)"
-build:
- test ! -d ./bin && mkdir ./bin || exit 0
- sed "s/PHOTOALBUMVERSION/$(VERSION)/" src/$(NAME).sh > ./bin/$(NAME)
- chmod 0755 ./bin/$(NAME)
-test: build
- bash ./tests/cli.sh
-install:
- test ! -d $(DESTDIR)/usr/bin && mkdir -p $(DESTDIR)/usr/bin || exit 0
- cp ./bin/* $(DESTDIR)/usr/bin
- test ! -d $(DESTDIR)/usr/share/photoalbum/templates && mkdir -p $(DESTDIR)/usr/share/photoalbum/templates || exit 0
- cp -R ./share/templates $(DESTDIR)/usr/share/photoalbum/
- test ! -d $(DESTDIR)/etc/default && mkdir -p $(DESTDIR)/etc/default || exit 0
- cp ./src/photoalbum.default.conf $(DESTDIR)/etc/default/photoalbum
-deinstall:
- test ! -z "$(DESTDIR)" && test -f $(DESTDIR)/usr/bin/$(NAME) && rm $(DESTDIR)/usr/bin/$(NAME) || exit 0
- test ! -z "$(DESTDIR)" && test -d $(DESTDIR)/usr/share/$(NAME) && rm -r $(DESTDIR)/usr/share/$(NAME) || exit 0
- test ! -z "$(DESTDIR)" && test -f $(DESTDIR)/etc/default/photoalbum && rm $(DESTDIR)/etc/default/photoalbum || exit 0
-clean:
- test -d ./bin && rm -Rf ./bin || exit 0
-shellcheck:
- # SC1090: ShellCheck can't follow non-constant source. Use a directive to specify location.
- # SC2001: See if you can use ${variable//search/replace} instead.
- # SC2010: Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.
- # SC2012: Use find instead of ls to better handle non-alphanumeric filenames.
- # SC2103: Use a ( subshell ) to avoid having to cd back.
- # SC2155: Declare and assign separately to avoid masking return values.
- # SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails.
- # SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
- shellcheck \
- --exclude SC1090 \
- --exclude SC2001 \
- --exclude SC2010 \
- --exclude SC2012 \
- --exclude SC2103 \
- --exclude SC2155 \
- --exclude SC2164 \
- --exclude SC2207 \
- ./src/photoalbum.sh \
- ./tests/cli.sh \
- ./tests/helpers.sh
+.PHONY: all build clean deinstall install shellcheck test uninstall version
+
+all build clean deinstall install shellcheck test uninstall version:
+ just $@
diff --git a/README.md b/README.md
index 3b0dc09..e9feb9a 100644
--- a/README.md
+++ b/README.md
@@ -9,10 +9,24 @@ Build and install the command, templates, and default config from a source
checkout with:
```
-make
-sudo make install
+just build
+sudo just install
```
+`just install` installs `photoalbum` to `/usr/bin`, templates to
+`/usr/share/photoalbum/templates`, and the default config to
+`/etc/default/photoalbum`. Override paths with `DESTDIR`, `PREFIX`, `BINDIR`,
+`DATADIR`, or `SYSCONFDIR` when packaging or staging an install:
+
+```
+DESTDIR="$PWD/pkg" PREFIX=/usr just install
+DESTDIR="$PWD/pkg" PREFIX=/usr just deinstall
+```
+
+`just uninstall` is an alias for `just deinstall`. The legacy Makefile forwards
+the same targets to `just`, so `make test` remains available for existing
+automation.
+
ImageMagick must also be installed. The script prefers the
modern `magick` command and falls back to `convert` when needed.
diff --git a/tests/cli.sh b/tests/cli.sh
index 2d3f1cb..6cd363a 100755
--- a/tests/cli.sh
+++ b/tests/cli.sh
@@ -178,6 +178,33 @@ test_init_existing_config_fails_without_overwrite() {
test::teardown
}
+test_just_install_and_deinstall_with_destdir() {
+ local stage_dir
+
+ test::setup
+ stage_dir="$TEST_TMPDIR/stage"
+
+ (
+ cd "$TEST_REPO_ROOT"
+ DESTDIR="$stage_dir" PREFIX=/usr just install
+ )
+
+ test::assert_file_exists "$stage_dir/usr/bin/photoalbum"
+ test::assert_file_exists "$stage_dir/etc/default/photoalbum"
+ test::assert_file_exists \
+ "$stage_dir/usr/share/photoalbum/templates/default/view.tmpl"
+
+ (
+ cd "$TEST_REPO_ROOT"
+ DESTDIR="$stage_dir" PREFIX=/usr just deinstall
+ )
+
+ test::assert_path_absent "$stage_dir/usr/bin/photoalbum"
+ test::assert_path_absent "$stage_dir/etc/default/photoalbum"
+ test::assert_path_absent "$stage_dir/usr/share/photoalbum"
+ test::teardown
+}
+
test_clean() {
local staging_dir
@@ -2279,6 +2306,9 @@ main() {
test::run_case \
'--init refuses existing config without overwrite' \
test_init_existing_config_fails_without_overwrite
+ test::run_case \
+ 'just install and deinstall supports DESTDIR' \
+ test_just_install_and_deinstall_with_destdir
test::run_case '--clean succeeds' test_clean
test::run_case '--clean --config succeeds' test_clean_with_config
test::run_case '--clean --dist overrides config' \