-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[feature] Prevent hardcoded install #1431
Open
sansyse
wants to merge
1
commit into
stlink-org:testing
Choose a base branch
from
sansyse:feat-1430-prevent_hardcoded_install
base: testing
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that this is a self-defined
cmake
command. It needs to be documented before having it added to the code. Also this topic should be discussed in general.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just an environment variable that, if defined non-null, prevents this install. It works.
In my opinion, it is not a good practice, if a build process of a development tool needs root privileges and forces modifications on the host system. Due to security reason, I never ever run such a build process with root privileges, in particular if you have not reverse-engineered the installation process and know exactly which modifications are done. I'm working on several different projects on the same development host and need to track modification manually. On the other hand a good practice is, if a project can installed relatively for packatizing, archiving, in-docker installation and/or project-local use. The modification on the host system is only done once (fully intentional), but the build process and debugging is done regularly and should never be done with root privileges.
In my environment the stlink stuff are archived in the project together with sources and other resources and the build and installation process of stlink tools are part of the project build. It is installed locally only.
STLINK_INSTPREFIX = $(abspath host)
STLINK_CMAKEFLAGS = -DCMAKE_INSTALL_FULL_DATADIR=$(STLINK_INSTPREFIX) -DCMAKE_INSTALL_PREFIX=$(STLINK_INSTPREFIX) -DPREVENT_HARDCODED_INSTALL=1
... make -j1 CMAKEFLAGS="$(STLINK_CMAKEFLAGS)" release install
I agree, that a hobbyist or standard-user may do not need such a feature and for him it would be safer to install everthing in one automated installation process. But there are also experienced users with non-standard use cases.
A compromise and maybe better solution would be, to use the sysconfig_dir feature in you installation script to use it like this:
STLINK_INSTPREFIX = $(abspath host)
STLINK_CMAKEFLAGS = -DCMAKE_INSTALL_SYSCONFDIR=$(STLINK_INSTPREFIX)/etc -DCMAKE_INSTALL_FULL_DATADIR=$(STLINK_INSTPREFIX) -DCMAKE_INSTALL_PREFIX=$(STLINK_INSTPREFIX)
... make -j1 CMAKEFLAGS="$(STLINK_CMAKEFLAGS)" release install