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

change makefile to default to user writable directory for install by default #351

Open
skewballfox opened this issue Mar 16, 2023 · 3 comments

Comments

@skewballfox
Copy link
Contributor

related to #350 I think the Makefile should default to somewhere writeable by the user. /usr/local is owned by root and does not have write permissions by anyone else. There are two ways I can think of handling this

if you would rather leave the Makefile mostly as is and allow the user to override this you can use

PREFIX ?= $(/usr/local)

this will read the value of PREFIX from the environment if it is set, otherwise default to /usr/local.

Alternatively, if you don't mind changing the default you could use

ifeq ($(SUDO_USER),)
    PREFIX := $(HOME)/.local
else
    PREFIX := /usr/local
endif

the environment variable SUDO_USER should only be set if the current command is running with sudo

this would only do a system wide installation if running with sudo make install

I could submit a PR for either of these if you specify which one you prefer

@ErikBjare
Copy link
Member

ErikBjare commented Mar 16, 2023 via email

@johan-bjareholt
Copy link
Member

The first one is the more "classical" way to do it. Not saying it's the best, just that it's a very well-known pattern.

Also, regardless which version you choose you should use ?= for the prefix, so the user has the ability to override the prefix without modifying the Makefile.

On top of that, we have some hardcoded paths in aw-server-rust where to find the static web files, so using some other prefix will break the web-ui unless you do some additional change.

@skewballfox
Copy link
Contributor Author

Also, regardless which version you choose you should use ?= for the prefix, so the user has the ability to override the prefix without modifying the Makefile.

On top of that, we have some hardcoded paths in aw-server-rust where to find the static web files, so using some other prefix will break the web-ui unless you do some additional change.

I addressed both in #353
Kind of messed up at first (didn't realize that && wasn't a thing in makefiles), but I reran make install and rust-server to confirm that they work.

right now the prefix setting is a little redundant because my make foo isn't good enough to figure out how to chain conditionals when one of those is meant to be an empty value. but it first checks if the user is root, then checks if one of the variables set by sudo is present. If there is anything I should do to update that, please let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants