-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Use pkg config udevdir #4126
Use pkg config udevdir #4126
Conversation
This is not yet tested widely. Please let confirm that it does not break existing packaging and does the right thing. |
CMakeLists.txt
Outdated
if(INSTALL_USER_UDEV_RULES) | ||
set(MIXXX_UDEVDIR "${MIXXX_INSTALL_DATADIR}/udev") | ||
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr") | ||
message(FATAL_ERROR "Bla") |
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.
???
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.
Ups, a debug left over.
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.
rebased out
if(PKGCONFIG_UDEVDIR) | ||
file(TO_CMAKE_PATH "${PKGCONFIG_UDEVDIR}" MIXXX_UDEVDIR) | ||
endif() |
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.
Are you sure that PKGCONFIG_UDEVDIR is not an absolute path outside CMAKE_INSTALL_PREFIX? Mixxx mustn't install anything outside the chosen prefix under any circumstances.
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 does not:
-- Installing: /home/be/local/share/mixxx/udev/rules.d/mixxx-usb-uaccess.rules
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.
And this is certainly the case on all systems? So returning a relative path instead of an absolute one is guaranteed by pkg-config?
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.
I don't know.
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.
Are you sure that PKGCONFIG_UDEVDIR is not an absolute path outside CMAKE_INSTALL_PREFIX? Mixxx mustn't install anything outside the chosen prefix under any circumstances.
In case of udevdir it is an exception. The rules files have to be installed at the common folder returned by pkg-config IF Mixxx is installed in the system location "/usr". This should happens only in the packaging case.
In all other case the udevdir is useless and the rules file is installed under our fall back location .../share/mixxx/udev/rules.d/mixxx-usb-uaccess.rules as before.
This should make all hacks in the packaging scripts obsolete.
Do we know a distro where this assumption is void?
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.
That would be wrong for Ubuntu sorry
What would be wrong? Have you read the special case section at: https://cmake.org/cmake/help/v3.15/module/GNUInstallDirs.html?highlight=gnuinstalldirs#special-cases
The following values of CMAKE_INSTALL_PREFIX are special:
/
For<dir>
other than theSYSCONFDIR
,LOCALSTATEDIR
andRUNSTATEDIR
, the value ofCMAKE_INSTALL_<dir>
is prefixed withusr/
if it is not user-specified as an absolute path. For example, the INCLUDEDIR value include becomes usr/include. This is required by the GNU Coding Standards, which state:
When building the complete GNU system, the prefix will be empty and /usr will be a symbolic link to /.
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.
Ah Ok, so we need to check how debuild uses CMake
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.
What does PC return for udevdir on arch?
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.
$ pkgconf --variable=udevdir udev
/usr/lib/udev
Arch does not use /lib
or /lib64
(it is symlinked to /usr/lib
), as well as we also don't do /usr/sbin
or /bin
or /sbin
(it is symlinked to /usr/bin
): https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/
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.
Cool, so it should work for all major distros at least
CMakeLists.txt
Outdated
") | ||
if(INSTALL_USER_UDEV_RULES) | ||
set(MIXXX_UDEVDIR "${MIXXX_INSTALL_DATADIR}/udev") | ||
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr") |
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.
I am not sure this will work on e.g. nixOS, as they have a very different directory structure as packages are installed to the /nix
directory (but I also don't really know how they handle udev rule files, better ask someone who knows!).
Can we not check whether CMAKE_INSTALL_PREFIX
does not match /usr/local
instead?
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.
The install prefix can also be
~/.local or /opt or wherever the user thinks it is correct.
So it is IMHO more reasonable to check for the system path that corospods to the system udev dir.
We can extend the list of suitable packaging install prefixes on demand.
debuild uses prefix /usr and requires the udevdir at /lib/udev If we want to install the rules automatically to the final location, we cannot enforce the rule "no file outside the install prefix" at the same time. Since pkg-config is telling us to violate the rule, it should be OK to follow. Interestingly CMAKE_INSTALL_PREFIX "/" and "/usr" are treated as the same location: So we can argue that we don't even voialate the rule, because "/usr" is actually "/" which allows any location. I have added a comment, with some hints. |
if (MIXXX_UDEVDIR STREQUAL "${MIXXX_INSTALL_DATADIR}/udev") | ||
install( | ||
FILES | ||
"${CMAKE_CURRENT_SOURCE_DIR}/res/linux/mixxx-usb-uaccess.rules" |
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.
"${CMAKE_CURRENT_SOURCE_DIR}/res/linux/mixxx-usb-uaccess.rules" | |
"${CMAKE_CURRENT_SOURCE_DIR}/packaging/linux/69-mixxx-dj-hardware.rules" |
This file needs to be renamed to have the correct priority.
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.
This is the path where we install the file to the data directory. I have not renamed it to not break existing packaging scripts. To use the file the user can move and rename it as desired.
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.
That defeats the purpose. The packager should not have to do anything besides the CMake install step.
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.
Here we are in the branch that is not for packagers. In the packager's branch the file is renamed.
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.
This is unnecessarily complicated. Please simply rename the file. Packagers have already said that is not a problem. At most it is changing a single line of code for them.
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.
This place is not for packagers!
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.
Can't we just rename it in main
? I think it's not really that important to change in 2.3
and packagers have already written packaging scripts with the old name for 2.3.0, so let's not break existing scripts in a point release.
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.
Why is this file even installed to somewhere it has no effect? I think we should just show a warning that the file has not been installed.
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 makes sense to have this file as part of the installer and move it yourself. FWIW it's actually a bit unexpected that just having mixxx installed messes around with your system permissions instead of copying the file yourself, but in this special case it's not an issue because the security implications of giving all users permission to access HID DJ controllers are small :D
This is IMHO in a mergeable state. @Holzhaus please have a look. |
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.
A simple test seems to work, make DESTDIR=/tmp/foo install
seems to work correctly.
I'm still unsure if we actually need the pkgconfig magic instead of letting the packager take care of it. But I don't want to bikeshed over this. Would be good to get confirmation from @dvzrv and @PureTryOut though.
if (MIXXX_UDEVDIR STREQUAL "${MIXXX_INSTALL_DATADIR}/udev") | ||
install( | ||
FILES | ||
"${CMAKE_CURRENT_SOURCE_DIR}/res/linux/mixxx-usb-uaccess.rules" |
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 makes sense to have this file as part of the installer and move it yourself. FWIW it's actually a bit unexpected that just having mixxx installed messes around with your system permissions instead of copying the file yourself, but in this special case it's not an issue because the security implications of giving all users permission to access HID DJ controllers are small :D
") | ||
if(INSTALL_USER_UDEV_RULES) | ||
set(MIXXX_UDEVDIR "${MIXXX_INSTALL_DATADIR}/udev") | ||
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr" OR CMAKE_INSTALL_PREFIX STREQUAL "/" ) |
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.
just an idea, maybe it's not better:
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr" OR CMAKE_INSTALL_PREFIX STREQUAL "/" ) | |
if (CMAKE_INSTALL_PREFIX IN_LIST "/;/usr" ) |
Uh, I'm still unsure why #4114 didn't do the right thing and why this would be better. In the end both PR's achieve the same result (assuming packaging is done correctly, which it doesn't seem to be for Ubuntu currently as it doesn't set Why is making sure
I'm definitely against packagers having to do a |
Co-authored-by: Jan Holthuis <holthuis.jan@googlemail.com>
#4114 does not work for all, because it guesses the right udev location. This one does only install it when it is certain to be correct. That is an improvement. In case of Ubuntu we use a manual install step using dh_installudev Line 10 in bee21d8
With this PR the packager can omit this step.
Two reasons:
|
So set it to |
Yes right, on Ubuntu the default install prefix is /usr while the udev dir is /lib/udev. |
Weird... But ok, valid point then. |
@Holzhaus merge? |
This PR implement the suggestions by @dvzrv #4114 to make use of pk-config to install the udev rules file in the correct location.