Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Correct Bash completion path in Makefile #452

Merged
merged 7 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
21 changes: 12 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@ 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
sysconfdir = $(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
datarootdir = $(prefix)/share/bash-completion/completions
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
Expand Down Expand Up @@ -95,18 +98,18 @@ 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
rm -f $(DESTDIR)$(sysconfdir)/todo/config
rm -f $(DEST_COMMAND)
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
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- `BASH_COMPLETION`: PATH for autocompletion scripts (default to /etc/bash_completion.d)
- `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)
Expand Down