From 9348fe4586d46bedd4e46b54dbb7854ba52a0599 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sat, 28 Dec 2024 09:07:37 +0100 Subject: [PATCH 1/7] Tests: Also execute installation, uninstallation, clean to test suite To verify that these steps succeed on the workflow runners. This currently fails because of #451 --- .github/workflows/tests.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0d73c835..1eddfe29 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,4 +18,6 @@ jobs: - run: make - run: make dist - run: make test - + - run: sudo make install + - run: sudo make uninstall + - run: sudo make clean From 8f4889870feecbc352177ded85162f2ae58d88e6 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sat, 28 Dec 2024 09:14:19 +0100 Subject: [PATCH 2/7] FIX: Regression: Forgot to add .sh extension to removal of completion script (after 491979b) There are so many instances of todo.sh that this is easy to miss. I'll make it more DRY. (This corrects commit 491979b76a9505b098b57fb042a510f9e89feb5b) --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e17e7735..036f7088 100644 --- a/Makefile +++ b/Makefile @@ -103,7 +103,7 @@ install: build installdirs ## local package install .PHONY: uninstall uninstall: ## uninstall package rm -f $(DESTDIR)$(bindir)/todo.sh - rm -f $(DESTDIR)$(datarootdir)/todo + rm -f $(DESTDIR)$(datarootdir)/todo.sh rm -f $(DESTDIR)$(sysconfdir)/todo/config rmdir $(DESTDIR)$(datarootdir) From 49a0d1d56824911c50d73fc38d991fbe7b20b029 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sat, 28 Dec 2024 09:22:52 +0100 Subject: [PATCH 3/7] Refactoring: Extract DEST_{COMMAND,CONFIG,COMPLETION} vars To remove the duplication. --- Makefile | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 036f7088..c6f29644 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,7 @@ ifdef INSTALL_DIR else bindir = $(prefix)/bin endif +DEST_COMMAND = $(DESTDIR)$(bindir)/todo.sh # The directory to install the config file in. ifdef CONFIG_DIR @@ -26,12 +27,14 @@ ifdef CONFIG_DIR else sysconfdir = $(prefix)/etc endif +DEST_CONFIG = $(DESTDIR)$(sysconfdir)/todo/config ifdef BASH_COMPLETION datarootdir = $(BASH_COMPLETION) else datarootdir = $(prefix)/share/bash_completion.d endif +DEST_COMPLETION = $(DESTDIR)$(datarootdir)/todo.sh # generate list of targets from this Makefile # looks for any lowercase target with a double hash mark (##) on the same line @@ -95,16 +98,16 @@ clean: test-pre-clean VERSION-FILE ## remove dist directory and all release fi .PHONY: install install: build installdirs ## local package install - $(INSTALL_PROGRAM) $(DISTNAME)/todo.sh $(DESTDIR)$(bindir)/todo.sh - $(INSTALL_DATA) $(DISTNAME)/todo_completion $(DESTDIR)$(datarootdir)/todo.sh - [ -e $(DESTDIR)$(sysconfdir)/todo/config ] || \ - sed "s/^\(export[ \t]*TODO_DIR=\).*/\1~\/.todo/" $(DISTNAME)/todo.cfg > $(DESTDIR)$(sysconfdir)/todo/config + $(INSTALL_PROGRAM) $(DISTNAME)/todo.sh $(DEST_COMMAND) + $(INSTALL_DATA) $(DISTNAME)/todo_completion $(DEST_COMPLETION) + [ -e $(DEST_CONFIG) ] || \ + sed "s/^\(export[ \t]*TODO_DIR=\).*/\1~\/.todo/" $(DISTNAME)/todo.cfg > $(DEST_CONFIG) .PHONY: uninstall uninstall: ## uninstall package - rm -f $(DESTDIR)$(bindir)/todo.sh - rm -f $(DESTDIR)$(datarootdir)/todo.sh - rm -f $(DESTDIR)$(sysconfdir)/todo/config + rm -f $(DEST_COMMAND) + rm -f $(DEST_COMPLETION) + rm -f $(DEST_CONFIG) rmdir $(DESTDIR)$(datarootdir) rmdir $(DESTDIR)$(sysconfdir)/todo From 258f85c7d2a36017026840f2d6a928590bec929b Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sat, 28 Dec 2024 09:24:12 +0100 Subject: [PATCH 4/7] Robustness: Ignore failure to remove $(DESTDIR)$(datarootdir) Unlike the other directories, this is a shared one; if there are other (locally installed) completions, it's not empty and cannot be removed. But if we're the only / last locally installed completion, it's nice to clean it up. Suppress errors and command failure so that "make uninstall" does not fail due to this inconsequential error. Fixes #451 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c6f29644..57cbdce1 100644 --- a/Makefile +++ b/Makefile @@ -109,7 +109,7 @@ uninstall: ## uninstall package rm -f $(DEST_COMPLETION) rm -f $(DEST_CONFIG) - rmdir $(DESTDIR)$(datarootdir) + rmdir $(DESTDIR)$(datarootdir) 2>/dev/null || : rmdir $(DESTDIR)$(sysconfdir)/todo # create local installation directories From d5d6ee717d0029dfe954ddcbb920be54cc1ce794 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sat, 28 Dec 2024 09:37:34 +0100 Subject: [PATCH 5/7] FIX: Correct location for (dynamically sourced) locally installed completions /usr/share/bash-completion/bash_completion looks into /usr/[local/]share/bash-completion/completions/; the bash_completion.d is the legacy (statically sourced) location in /etc. This was overlooked when moving away from that. That change also failed to update the default location in the readme. (But the override example in the readme already used the correct one?!) --- Makefile | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 57cbdce1..850bd492 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ DEST_CONFIG = $(DESTDIR)$(sysconfdir)/todo/config ifdef BASH_COMPLETION datarootdir = $(BASH_COMPLETION) else - datarootdir = $(prefix)/share/bash_completion.d + datarootdir = $(prefix)/share/bash-completion/completions endif DEST_COMPLETION = $(DESTDIR)$(datarootdir)/todo.sh diff --git a/README.md b/README.md index 877981ea..e116e805 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ make test - `INSTALL_DIR`: PATH for executables (default /usr/local/bin) - `CONFIG_DIR`: PATH for the todo.txt configuration template -- `BASH_COMPLETION`: PATH for autocompletion scripts (default to /etc/bash_completion.d) +- `BASH_COMPLETION`: PATH for autocompletion scripts (default to `/usr/local/share/bash-completion/completions`) ```shell make install CONFIG_DIR=/etc INSTALL_DIR=/usr/bin BASH_COMPLETION=/usr/share/bash-completion/completions From e92d64fdc1edb2551762e7577ab2215b32163539 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sat, 28 Dec 2024 09:41:46 +0100 Subject: [PATCH 6/7] Documentation: Consistency: Mention CONFIG_DIR default, legacy location for completion Add a note that the legacy locations (now also consistently used for the completion script) are not recommended, just to illustrate how to override the default locations. --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e116e805..d5389fa8 100644 --- a/README.md +++ b/README.md @@ -41,12 +41,13 @@ make test *NOTE:* Makefile defaults to several default paths for installed files. Adjust to your system: -- `INSTALL_DIR`: PATH for executables (default /usr/local/bin) -- `CONFIG_DIR`: PATH for the todo.txt configuration template +- `INSTALL_DIR`: PATH for executables (default `/usr/local/bin`) +- `CONFIG_DIR`: PATH for the `todo/config` configuration template (default `/usr/local/etc`) - `BASH_COMPLETION`: PATH for autocompletion scripts (default to `/usr/local/share/bash-completion/completions`) ```shell -make install CONFIG_DIR=/etc INSTALL_DIR=/usr/bin BASH_COMPLETION=/usr/share/bash-completion/completions +# Note: Showcasing config overrides for legacy locations; NOT recommended! +make install CONFIG_DIR=/etc INSTALL_DIR=/usr/bin BASH_COMPLETION=/etc/bash_completion.d ``` #### Arch Linux (AUR) From 5b8c3d681cc4c3f3f65025796d229ba716ace555 Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Sun, 29 Dec 2024 10:35:28 +0100 Subject: [PATCH 7/7] Documentation: Update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed4ed586..e7739fb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Added - `TODOTXT_DEFAULT_ACTION` now also allows action parameters ([#159], [#407]) +### Fixed +- `make install` installed the Bash completion in the wrong directory ([#452]) +- `make uninstall` fails ([#451]) + ## [2.13.0] - 2024-12-25 ### Added @@ -541,3 +545,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. [#359]: https://github.com/todotxt/todo.txt-cli/pull/359 [#386]: https://github.com/todotxt/todo.txt-cli/pull/386 [#407]: https://github.com/todotxt/todo.txt-cli/pull/407 +[#451]: https://github.com/todotxt/todo.txt-cli/pull/451 +[#452]: https://github.com/todotxt/todo.txt-cli/pull/452