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

Install UDev rules to the proper location by default #4114

Closed
wants to merge 1 commit into from
Closed

Install UDev rules to the proper location by default #4114

wants to merge 1 commit into from

Conversation

PureTryOut
Copy link

@PureTryOut PureTryOut commented Jul 17, 2021

The comment in the CMakeLists.txt talks about some proper location the
file has to be installed too, but itself installs it to a wrong
directory. Rather than telling people to turn the option off and install
the file to the right directory manually, install it directly to the
correct directory instead. ${CMAKE_INSTALL_LIBDIR} will expand to
whatever distros require it to be

Also while we're at it, make sure it's loaded before 70-uaccess.rules
rather than just having a comment mention that in the udev file itself

@github-actions github-actions bot added the build label Jul 17, 2021
@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

I'll leave this open for a little to give others a chance to comment, but it looks good to me.

@Be-ing Be-ing closed this Jul 18, 2021
@Be-ing Be-ing reopened this Jul 18, 2021
@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

Ugh, why does the "Close and comment" button exist?!

@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

@dvzrv could you take a look at this?

@PureTryOut
Copy link
Author

@Be-ing I just noticed a comment in the UDev file saying it has to be named 69-mixxx-usb-uaccess.rules to make sure it gets loaded before 70-uaccess.rules. Not sure why it wasn't just named that in the repo in the first place, so I renamed it in this PR now.

@dvzrv
Copy link

dvzrv commented Jul 18, 2021

LGTM! :)

Copy link
Member

@Holzhaus Holzhaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ubuntu build fails, because the udev file was moved. Please also update the other locations where the file is used:

$ grep --exclude-dir .git --exclude-dir build -HrnF 'res/linux/mixxx-usb-uaccess.rules' .
./res/linux/mixxx.metainfo.xml:40:    <!-- Keep these IDs in sync with res/linux/mixxx-usb-uaccess.rules -->
./packaging/CPackDebUploadPPA.cmake:82:file(COPY ${CPACK_TOPLEVEL_DIRECTORY}/${CPACK_PACKAGE_FILE_NAME}/res/linux/mixxx-usb-uaccess.rules
./packaging/CPackDebInstall.cmake:36:file(COPY ${CPACK_DEBIAN_SOURCE_DIR}/res/linux/mixxx-usb-uaccess.rules

@Holzhaus
Copy link
Member

Holzhaus commented Jul 18, 2021

@daschuer Can you test this? The new location works fine for me, but I remember we had a lengthy discussion about the different paths for udev files and which one is correct (for reference:
#3458 (comment)).

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default settings shall be optimized for home builds.
The current version uses
/usr/local/share/mixxx/udev/rules.d

This PR uses
/usr/local/lib/udev/rules.d

On Ubuntu I have no /usr/local/lib/udev/rules.d and I don't like to get one by default.

The issue is that without external help we cannot find the right place without messing around with the user system. That's why we have decided it #3458
To install it to the neutral ground of /usr/local/share/mixxx/udev/rules.d and let the user decide.

According to @Holzhaus

At least on Arch it's pretty standard to install it to share and let users copy it themselves. Also, that way we make sure the rules file is included in binary archives (cpack -G TGZ).

I also think it is a bad idea to move and rename a file in a stable branch. This will break every packaging script which is already adopted.

\"If you are installing Mixxx from source for your own use, copy\n\"
\"mixxx-usb-uaccess.rules to /etc/udev/rules.d/ and run:\n\"
\" udevadm control --reload-rules && udevadm trigger\n\"
\"as root to load the rules.\n\"
\"If you are building a package for a distribution, the correct directory for\n\"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this passage removed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the intent of this PR is to install it to the right place in the first place. At that point this comment is unnecessary, it'll already be in the right place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we install it at the right place, we need to rewrite this message. Maybe it can be omitted entirely and only be issues as a fatal message if the detection of the correct install directory fails.
For that case we may take the directory including file name as a cmake option.

CMakeLists.txt Outdated
)
install(CODE "
message(STATUS \"Important Note: Installation of udev rules\n\"
\"The udev rule file for USB HID and Bulk controller permissions will be\n\"
\"installed to:\n\"
\" ${CMAKE_INSTALL_PREFIX}/${MIXXX_INSTALL_DATADIR}/udev/rules.d.\n\"
\" ${CMAKE_INSTALL_LIBDIR}/udev/rules.d.\n\"
\"If you are installing Mixxx from source for your own use, copy\n\"
\"mixxx-usb-uaccess.rules to /etc/udev/rules.d/ and run:\n\"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\"mixxx-usb-uaccess.rules to /etc/udev/rules.d/ and run:\n\"
\"69-mixxx-usb-uaccess.rules to /etc/udev/rules.d/ and run:\n\"

@daschuer
Copy link
Member

@dvzrv
Copy link

dvzrv commented Jul 18, 2021

This for instance:
https://github.com/rpmfusion/mixxx/blob/0f97f34cd8a726d39039379d4c2419b561d73340/mixxx.spec#L159

Hm, but who are the users of that spec? Downstream distributions? They usually package an upstream their own way.
Unless you want to add your own packages somewhere, maintaining such a .spec file is not useful.

@PureTryOut
Copy link
Author

If on Ubuntu it doesn't install to /lib/udev/rules.d, then something is wrong in the Ubuntu packaging.
${CMAKE_INSTALL_LIBDIR} should expand to whatever is required by the distribution. If Ubuntu builds with -DCMAKE_INSTALL_PREFIX=/ and -DCMAKE_INSTALL_LIBDIR=lib (like it should if it expects things to be installed to /lib), then this PR will do as required.

The comment in the CMakeLists.txt talks about some proper location the
file has to be installed too, but itself installs it to a wrong
directory. Rather than telling people to turn the option off and install
the file to the right directory manually, install it directly to the
correct directory instead. ${CMAKE_INSTALL_LIBDIR} will expand to
whatever distros require it to be _assuming_ they set their
-DCMAKE_INSTALL_PREFIX and -DCMAKE_INSTALL_LIBDIR correctly

Also while we're at it, make sure it's loaded before 70-uaccess.rules
rather than just having a comment mention that in the udev file itself
@dvzrv
Copy link

dvzrv commented Jul 18, 2021

The default settings shall be optimized for home builds.
The current version uses
/usr/local/share/mixxx/udev/rules.d

This PR uses
/usr/local/lib/udev/rules.d

On Ubuntu I have no /usr/local/lib/udev/rules.d and I don't like to get one by default.

Hm, that's odd. From where does ubuntu load udev rules? /usr/share/udev/rules.d/?
Looking at the documentation /usr/lib/udev/rules.d seems certainly the default system-wide (vendor) path, followed by the overrides in /etc/udev/rules.d/ and /run/udev/rules.d. This might be dependant on set defaults, but looking at how we package systemd on Arch Linux (and therefore also udev), I can't see how we are doing anything but follow upstream.

The issue is that without external help we cannot find the right place without messing around with the user system. That's why we have decided it #3458
To install it to the neutral ground of /usr/local/share/mixxx/udev/rules.d and let the user decide.

As an idea: How about letting the user provide a location for it themselves via an option to cmake then? That would solve this problem generically and could default to a "contrib" (i.e. inactive) location.
Generally I would always side with how the default is supposed to be though: install to /usr/local/lib/udev/rules.d/ (local install) or /usr/lib/udev/rules.d/ (packaged/system-wide install).

According to @Holzhaus

At least on Arch it's pretty standard to install it to share and let users copy it themselves. Also, that way we make sure the rules file is included in binary archives (cpack -G TGZ).

It is not standard and I would actually prefer the udev rule to end up in the correct location (without me having to manually move it into place).
Just searching for *.rules files on my current install I only see a few examples of where these files end up in /usr/share:

$ find /usr/share -type f -iname "*.rules"
/usr/share/doc/libvirt/examples/polkit/libvirt-acl.rules
/usr/share/iptables/empty-filter.rules
/usr/share/iptables/empty-mangle.rules
/usr/share/iptables/empty-nat.rules
/usr/share/iptables/empty-raw.rules
/usr/share/iptables/empty-security.rules
/usr/share/iptables/empty.rules
/usr/share/iptables/simple_firewall.rules
find: ‘/usr/share/polkit-1/rules.d’: Permission denied
/usr/share/mixxx/udev/rules.d/mixxx-usb-uaccess.rules
/usr/share/lirc/contrib/60-lirc.rules
/usr/share/lirc/contrib/60-usb-generic-perms.rules
/usr/share/lirc/contrib/97-lircd-uinput.rules
/usr/share/lirc/contrib/98-lirc-stable-link.rules
/usr/share/lirc/contrib/99-remote-control-lirc.rules
/usr/share/postgresql/tsearch_data/unaccent.rules
/usr/share/postgresql/tsearch_data/xsyn_sample.rules
/usr/share/solaar/udev-rules.d/42-logitech-unify-permissions.rules
/usr/share/audit/sample-rules/10-base-config.rules
/usr/share/audit/sample-rules/10-no-audit.rules
/usr/share/audit/sample-rules/11-loginuid.rules
/usr/share/audit/sample-rules/12-cont-fail.rules
/usr/share/audit/sample-rules/12-ignore-error.rules
/usr/share/audit/sample-rules/20-dont-audit.rules
/usr/share/audit/sample-rules/21-no32bit.rules
/usr/share/audit/sample-rules/22-ignore-chrony.rules
/usr/share/audit/sample-rules/23-ignore-filesystems.rules
/usr/share/audit/sample-rules/30-nispom.rules
/usr/share/audit/sample-rules/30-ospp-v42-1-create-failed.rules
/usr/share/audit/sample-rules/30-ospp-v42-1-create-success.rules
/usr/share/audit/sample-rules/30-ospp-v42-2-modify-failed.rules
/usr/share/audit/sample-rules/30-ospp-v42-2-modify-success.rules
/usr/share/audit/sample-rules/30-ospp-v42-3-access-failed.rules
/usr/share/audit/sample-rules/30-ospp-v42-3-access-success.rules
/usr/share/audit/sample-rules/30-ospp-v42-4-delete-failed.rules
/usr/share/audit/sample-rules/30-ospp-v42-4-delete-success.rules
/usr/share/audit/sample-rules/30-ospp-v42-5-perm-change-failed.rules
/usr/share/audit/sample-rules/30-ospp-v42-5-perm-change-success.rules
/usr/share/audit/sample-rules/30-ospp-v42-6-owner-change-failed.rules
/usr/share/audit/sample-rules/30-ospp-v42-6-owner-change-success.rules
/usr/share/audit/sample-rules/30-ospp-v42.rules
/usr/share/audit/sample-rules/30-pci-dss-v31.rules
/usr/share/audit/sample-rules/30-stig.rules
/usr/share/audit/sample-rules/31-privileged.rules
/usr/share/audit/sample-rules/32-power-abuse.rules
/usr/share/audit/sample-rules/40-local.rules
/usr/share/audit/sample-rules/41-containers.rules
/usr/share/audit/sample-rules/42-injection.rules
/usr/share/audit/sample-rules/43-module-load.rules
/usr/share/audit/sample-rules/70-einval.rules
/usr/share/audit/sample-rules/71-networking.rules
/usr/share/audit/sample-rules/99-finalize.rules

Those are either not udev rules or are in place due to upstream deciding to install them to a "contrib" directory (e.g. lirc). There are of course also cases where we specifically decide to install the udev rule to the correct location (e.g. solaar).

I also think it is a bad idea to move and rename a file in a stable branch. This will break every packaging script which is already adopted.

I would not worry about that too much, as downstreams can adapt to such a change.

Eventually I guess (for me) it boils down to:
Do you deem the udev rule as integral to the performance/ use of mixxx (e.g. without it, mixxx does not work as intended)?
If yes, install to the system-wide location, if no install to a contrib directory.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

Do you deem the udev rule as integral to the performance/ use of mixxx (e.g. without it, mixxx does not work as intended)?

Yes. Before we had this udev rule in the repository we got lots of support requests on our forum about users unable to access HID controllers and we had to direct them how to install a udev rule. We still get this sometimes because distribution packages are not all installing it correctly.

If yes, install to the system-wide location, if no install to a contrib directory.

I agree. Installing to PREFIX/share doesn't make sense.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

The default settings shall be optimized for home builds.
The current version uses
/usr/local/share/mixxx/udev/rules.d

This PR uses
/usr/local/lib/udev/rules.d

On Ubuntu I have no /usr/local/lib/udev/rules.d and I don't like to get one by default.

CMake sets the default prefix to /usr/local but distributions explicitly set it to /usr.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

Another option could be not installing this file with CMake and explicitly telling packagers in our release notes what to do (#4115). The current warning message has not been effective as we intended. This discussion has only come up because I specifically asked packagers to check the udev rule gets installed.

@PureTryOut
Copy link
Author

Another option could be not installing this file with CMake and explicitly telling packagers in our release notes what to do

I mean, that's a option, but there is no reason not to just install this file with CMake. Seriously, if you do your packaging right (so seemingly now how the Ubuntu packaging is done currently) then this PR will let CMake install the UDev file to the right directory on all distributions. There is no need to do it any other way.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

I think it would be better to check if the CMAKE_INSTALL_PREFIX is /usr and warn about the udev rule file if it is not. No need to implement that in this PR though.

@daschuer
Copy link
Member

I am not certain what are we trying to solve.
The current situation is like that:

  • CMake does not know where to install the rule file
  • We don't even know about the priorities on the target system
  • We want not clutter the user system with false attempts
  • We warn the package maintainer when INSTALL_USER_UDEV_RULES is left on defaults
  • The package maintainer can override it and provide is own method for installing
  • If the package maintainer ignores it, the rules file is at least part of the package and the user can copy it manually

So in the case of Alpine Linux you can

package() {
	make DESTDIR="$pkgdir" install
        mv "$pkgdir"/usr/local/share/mixxx/udev/rules.d/mixxx-usb-uaccess.rules "$pkgdir"/usr/lib/udev/rules.d/69-mixxx-usb-uaccess.rules
}

Problem solved.

With this patch, we clutter the user directory in some cases and break packaging scripts that have already adopted that approach.

I am not saying that we cannot improve the situation.

For instance we can allow to set the installation path via a cmake option. But It is better tho keep the default like this, to not risk installation issues in point releases where I expect that the package maintainer will only change the commit hash and the check sum.

@dvzrv
Copy link

dvzrv commented Jul 18, 2021

I am not certain what are we trying to solve.

From what I can tell this PR is attempting to install a udev rule to the correct location automatically. A lot of applications do it, e.g. upower using pkgconf --variable=udevdir udev, or libinput using a custom meson option.

From what I understand it can either be done with automatic detection (e.g. pkgconf) or using an option with a default (e.g. install to ${CMAKE_INSTALL_LIBDIR}/udev/rules.d/ if no option is given).

The current situation is like that:

* CMake does not know where to install the rule file

But it does. The default vendor location is {,/usr}/lib/udev/rules.d/.
These paths could even be probed.

* We don't even know about the priorities on the target system

I am not sure what you mean by that. Are you referring to the ordering of udev rule files?
If so, 70-uaccess.rules is owned by systemd (or udev on systems without systemd), which has this name even on ancient Debian systems (from what I can tell).

* We want not clutter the user system with false attempts

There really are only three (common) targets from what I understand:

  • prefix is default -> /usr/local/lib/udev/rules.d/
  • prefix is /usr and /usr/lib/udev/rules.d/ exists -> /usr/lib/udev/rules.d/
  • prefix is /usr, /usr/lib/udev/rules.d/ does not exist, but /lib/udev/rules.d/ exists -> /lib/udev/rules.d/

IIUC the use of CMAKE_INSTALL_LIBDIR of GNUInstallDirs should cover even edge-cases.

* We warn the package maintainer when INSTALL_USER_UDEV_RULES is left on defaults

* The package maintainer can override it and provide is own method for installing

* If the package maintainer ignores it, the rules file is at least part of the package and the user can copy it manually

This can be done, but also reads like unneeded manual steps.

So in the case of Alpine Linux you can

package() {
	make DESTDIR="$pkgdir" install
        mv "$pkgdir"/usr/local/share/mixxx/udev/rules.d/mixxx-usb-uaccess.rules "$pkgdir"/usr/lib/udev/rules.d/69-mixxx-usb-uaccess.rules
}

Problem solved.

Whereas it can just be make DESTDIR="$pkgdir" install

With this patch, we clutter the user directory in some cases and break packaging scripts that have already adopted that approach.

If you mean /usr/local/ with user directory, then there is of course always a possibility of cluttering it, when installing software to that location. Usually the generated Makefile offers an uninstall target for this though (it has been a while since I had the need to install anything to /usr/local/).

I am not saying that we cannot improve the situation.

For instance we can allow to set the installation path via a cmake option. But It is better tho keep the default like this, to not risk installation issues in point releases where I expect that the package maintainer will only change the commit hash and the check sum.

If the file location changes and the packager chose to move the file, the build will fail and the packager can easily adopt as packages are usually built in a clean environment (and depending on distribution also offers tooling around detection of changed files, etc.). There is not a lot to it.

@daschuer
Copy link
Member

Thank you @dvzrv that sounds reasonable. So there is some work and testing left here.
I guess the current state in main was the attempt to get around that work.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

I think a more generic file name would be appropriate, maybe rename from 69-mixxx-usb-uaccess.rules to 69-mixxx-dj-hardware.rules. In the main branch we have moved from the libusb backend of hidapi to hidraw (#4054) which also allows access to Bluetooth HID devices, to the "usb" in the file name is a misnomer. We also have a rule in this file for the audio interface in the Allen & Heath Xone 23C mixer, which is not a controller.

@Holzhaus
Copy link
Member

Holzhaus commented Jul 18, 2021

Itvs just for hid, right? How about mixxx-hid-uaccess.rules?

@Be-ing
Copy link
Contributor

Be-ing commented Jul 18, 2021

No it is not just for HID. It is also for those odd old controllers that Mixxx accesses USB Bulk endpoints through libusb.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 19, 2021

@daschuer merge?

Copy link
Contributor

@uklotzde uklotzde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is inconvenient that we break existing packaging scripts for 2.3.1 with this change. That's my only concern.

If it works and improves platform support then let's apply the required changes.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 19, 2021

It is inconvenient that we break existing packaging scripts for 2.3.1 with this change. That's my only concern.

Packagers are telling us they want this so let's listen to them.

@Be-ing Be-ing closed this Jul 19, 2021
@Be-ing Be-ing reopened this Jul 19, 2021
@Be-ing
Copy link
Contributor

Be-ing commented Jul 19, 2021

Ugh, the close and comment button... why does it exist?!

@uklotzde uklotzde added this to the 2.3.1 milestone Jul 19, 2021
@daschuer daschuer marked this pull request as draft July 19, 2021 23:25
@daschuer
Copy link
Member

The current state brakes existing package scripts and makes the situation worse for local builds. I am happy to merge it if it works like outlined by @dvzrv
For now I have converted it to a draft.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 19, 2021

This is why we need a section for packagers in our release notes.

@daschuer
Copy link
Member

This PR is a good idea and better then every written Text that can be ignored.
Unfortunately it is not complete.

@daschuer
Copy link
Member

let's not hold off 2.3.1 by this

@daschuer daschuer removed this from the 2.3.1 milestone Jul 19, 2021
@Be-ing
Copy link
Contributor

Be-ing commented Jul 19, 2021

What is not complete here? This already works.

@daschuer
Copy link
Member

I have outlined the issues in my review comments.
The main issue is that it now installs to "/usr/local/lib/udev/rules.d" which is wrong at least for Ubuntu
using pkgconf --variable=udevdir udev as suggested by @dvzrv to find the right directory seams to be the right approach instead of just guessing.

DESTINATION
"${MIXXX_INSTALL_DATADIR}/udev/rules.d"
"${CMAKE_INSTALL_LIBDIR}/udev/rules.d"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default this is "/usr/local/lib/udev/rules.d" which is wrong at least for Ubuntu

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what is the problem? It did not install to the right place before either if the prefix was /usr/local

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before it was installed as data to the standard arch directory under a mixxx folder. I did not consider this as clutter.
Please refer to the original decision process. #3458

Copy link
Contributor

@Be-ing Be-ing Jul 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original decision was bad, as packagers have told us. This exists for their convenience. Please listen to them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes no difference whether it is installed to one wrong location or another. Neither has an effect.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that Ubuntu will install it to the correct place if it's packaging sets -DCMAKE_INSTALL_PREFIX=/. If it doesn't right now, that's wrong anyhow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's autoconf and not relevant for a CMake project. Besides, you should be able to overwrite whatever defaults it sets as a packager.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, wrong link:
https://github.com/Debian/debhelper/blob/eb6e510ef52430c6edb96b28879fa4f64fbcafdb/Debian/Debhelper/Buildsystem/cmake.pm#L15

Besides, you should be able to overwrite whatever defaults it sets as a packager.

Yes, but the point of the whole PR is to avoid manual steps, right?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find configuring CMake correctly by adding an argument to the command you're calling any way better than executing an entirely new command 😉

But it seems Ubuntu installs things in places I didn't expect, so I guess the pkg-config method is the way to go. Closing this PR for now.

@Be-ing Be-ing marked this pull request as ready for review July 20, 2021 03:45
@Be-ing
Copy link
Contributor

Be-ing commented Jul 20, 2021

using pkgconf --variable=udevdir udev as suggested by @dvzrv to find the right directory seams to be the right approach instead of just guessing.

No, not really because this would require root permissions to install even if the user has write permission to CMAKE_INSTALL_PREFIX.

@Be-ing
Copy link
Contributor

Be-ing commented Jul 20, 2021

Unfortunately it is not complete.

Rejecting PRs because they don't solve every existing problem is not productive. That is how we get giant PRs and burn out developers.

@Be-ing Be-ing added this to the 2.3.1 milestone Jul 20, 2021
@dvzrv
Copy link

dvzrv commented Jul 20, 2021

using pkgconf --variable=udevdir udev as suggested by @dvzrv to find the right directory seams to be the right approach instead of just guessing.

No, not really because this would require root permissions to install even if the user has write permission to CMAKE_INSTALL_PREFIX.

That is not correct. In a build environment (or even when only building for the user's target system) the required packages to build (and introspect that system) are expected to be installed. One of them should be pkgconf/pkg-config.

We can simply rely on FindPkgConfig's pkg_get_variable, e.g. (if I got it right):

pkg_get_variable(UDEV_DIR udev udevdir)

This way we can always use ${UDEV_DIR}, unless we have the default prefix (/usr/local), in which case it should go to ${CMAKE_INSTALL_LIBDIR}/udev/rules.d/ (which in that case should be /usr/local/lib/udev/rules.d/). All previous assumptions are of course without the use of DESTDIR (so this should be tested, especially whether it holds using the ${UDEV_DIR} variable, as we do not want to install to the users system, but below $DESTDIR if it is defined of course!).

@dvzrv
Copy link

dvzrv commented Jul 20, 2021

Unfortunately it is not complete.

Rejecting PRs because they don't solve every existing problem is not productive. That is how we get giant PRs and burn out developers.

The PR is not rejected, but still being worked on. It does not help to get upset about it either. Sometimes PRs take a little to get right. :)

@PureTryOut If you have time to look into any of my above suggestions, I'd be happy to test them! :)

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

Successfully merging this pull request may close these issues.

6 participants