Reputation: 246
I have an install target in my Makefile and wish to run some commands that install shared libraries(requires root permissions) and some that install config files into $HOME/.config
Usually I'd just tell the user to run sudo make install, however that results in the config file being installed to /root/.config
instead of the actual users config directory.
How do I work around this issue? Thanks alot.
Upvotes: 2
Views: 2093
Reputation: 53006
You can just change the owner and permissions of the config files, although a Makefile
that installs per user configuration files, is not a good idea because it would ideally need to find out how many users exist on the system to install the files for each user.
If you use the install
command, you could even do
install -v -m644 -o$(USERNAME) -g$(USERGROUP) $(FILE) $(USERHOME)/.config/$(FILE)
A better approach would be to let the program install the default config files from a system wide directory when it doesn't find them, for example
/usr/share/my-application/default-config/config.conf
and then the program would search for the files in the appropriate directoy and copy them to the $HOME
directory of the user that is currently running the program, that if the files are modifiable by the user, otherwise you just access them from their system-wide location.
Upvotes: 2