Skip to content

Commit

Permalink
BUG: Correct Bash completion path in Makefile
Browse files Browse the repository at this point in the history
Merge pull request #452 from inkarkat/451-fix-bash-completion
  • Loading branch information
inkarkat authored Dec 29, 2024
2 parents ca1efb7 + 5b8c3d6 commit b20f9b4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
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

0 comments on commit b20f9b4

Please sign in to comment.