ames icon indicating copy to clipboard operation
ames copied to clipboard

Add makefile (make install) for making the install

Open equwal opened this issue 1 year ago • 1 comments

Also moved the config to /etc/ames/config because root is required to install ames (which messses up trying to find the users home dir in Make)

TODO: fix XDG basedir spec to work (or: don't TODO)

equwal avatar Apr 24 '24 04:04 equwal

Hi @equwal, thanks for the PR! (sorry for the delay in review)

I'd be happy to merge, but unfortunately neither I nor @eshrh actively use ames anymore. We are also both on NixOS which makes it hard to test the PR. That being said, I'd be happy to merge if you changed the following things.

Instead of editing ames.sh to change the config path, which would break user configuration, could you instead source a system configuration before the user configuration, if it exists? Something like this should work.

--- a/ames.sh
+++ b/ames.sh
@@ -41,7 +41,8 @@ get_config_dir() {
 }

 # the config is sourced at the bottom of this file to overwrite functions.
-CONFIG_FILE_PATH="$(get_config_dir)/config"
+GLOBAL_CONFIG_FILE_PATH="/etc/ames/config"
+USER_CONFIG_FILE_PATH="$(get_config_dir)/config"

 usage() {
     # display help
@@ -476,9 +477,13 @@ clipboard() {
     notify_sentence_add
 }

+if [[ -f "$GLOBAL_CONFIG_FILE_PATH" ]]; then
+    # shellcheck disable=SC1090
+    source "$GLOBAL_CONFIG_FILE_PATH"
+fi
 if [[ -f "$CONFIG_FILE_PATH" ]]; then
     # shellcheck disable=SC1090
-    source "$CONFIG_FILE_PATH"
+    source "$USER_CONFIG_FILE_PATH"
 fi

 if [[ -z "${1-}" ]]; then

Hopefully this allows user configuration to override system configuration if it exists, defaulting to system configuration if it doesn't. I agree that ames was not XDG basedir spec compliant which should be fixed in https://github.com/eshrh/ames/commit/3332cf67a50f8f7e328e47525c13f770af0494f8.

Could you move the Makefile to contrib/Makefile? Since ames is a shell script, there is no build and the makefile serves as installation. The canonical way to install ames is through a Linux package manager, e.g. AUR, Nix.

Lastly, could you add installation instructions in the README? A short section titled "Makefile" after the "Arch users" section in the same style (bulleted list of steps) is sufficient.

stephen-huan avatar Apr 28 '24 21:04 stephen-huan

LGTM

The canonical way to install ames is through a Linux package manager, e.g. AUR, Nix.

I use gentoo btw

equwal avatar May 11 '24 03:05 equwal

Although, the global config + user config solution results in the global config overwriting user configs, which is a bit backwards.

equwal avatar May 11 '24 04:05 equwal

@equwal I changed your PR to be more aligned with the aur pkgbuild and fhs wrt to the location of man pages.

Also fixed a few bugs with the Makefile (consistent usage of ${DESTDIR}, adding mkdirs, make the install/uninstall idempotent and perfect inverses of each other, simplify install with install, etc.).

I changed my mind on the global configuration as I remembered ames actually comes shipped

https://github.com/eshrh/ames/blob/3332cf67a50f8f7e328e47525c13f770af0494f8/ames.sh#L18-L30

with the global configuration build-in. This means sourcing the default configuration is a no-op. It's not advised to edit the global configuration either, since it's overwritten on update (both with AUR and make install). That's why we recommend copying the configuration to the home directory and editing it there, which is something for the user to manually configure after installation (and so it is out of scope for the Makefile).

Although, the global config + user config solution results in the global config overwriting user configs, which is a bit backwards.

This point is not relevant anymore, but when I tested it seems to work fine. The order of the sources seems correct.

Note that there is a bug in my provided diff as

 if [[ -f "$CONFIG_FILE_PATH" ]]; then
     # shellcheck disable=SC1090
-    source "$CONFIG_FILE_PATH"
+    source "$USER_CONFIG_FILE_PATH"
 fi

should have be

-if [[ -f "$CONFIG_FILE_PATH" ]]; then
+if [[ -f "$USER_CONFIG_FILE_PATH" ]]; then
     # shellcheck disable=SC1090
-    source "$CONFIG_FILE_PATH"
+    source "$USER_CONFIG_FILE_PATH"
 fi

which caused the user config to not be sourced at all. Is that why you thought it was backwards?

If there is nothing you want changed I'll go ahead and merge.

stephen-huan avatar May 11 '24 06:05 stephen-huan

Looks like you deleted that bit so LGTM

equwal avatar May 11 '24 20:05 equwal

thanks for all the edits

equwal avatar May 11 '24 20:05 equwal

Thanks for your contribution! And apologies that all the back and forth took so long.

stephen-huan avatar May 11 '24 20:05 stephen-huan