udev: sync udev rules directories with systemd units directories
PATCH 1/1 udev: sync udev rules directories with systemd units directories
From: Michał Górny <[email protected]>
This adds /usr/lib, /usr/local/lib, and /lib (if split-usr is enabled) to the directories where udev searches for rules.d. This brings udev in line with how systemd searches for units and it is also needed if split-usr is enabled because other software packages currently install rules in /lib/udev/rules.d.
--- src/udev/udev-rules.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
src/udev/udev-rules.c +5 -0
@@ -1759,7 +1759,12 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) rules->dirs = strv_new(TEST_PREFIX SYSCONFDIR "/udev/rules.d",TEST_PREFIX "/run/udev/rules.d" , +TEST_PREFIX "/usr/local/lib/udev/rules.d" , TEST_PREFIX UDEVLIBEXECDIR "/rules.d", +TEST_PREFIX "/usr/lib/udev/rules.d" , +#ifdef HAVE_SPLIT_USR +TEST_PREFIX "/lib/udev/rules.d" , +#endifNULL );if (!rules->dirs) {log_error ("failed to build config directory array" );
Signature · 1 line
1.7.8.6
Quoted 16 lines · William Hubbs
From: Michał Górny <[email protected]>
This adds
/usr/lib,/usr/local/lib, and /lib (if split-usr is enabled) to the directories where udev searches for rules.d. This brings udev in line with how systemd searches for units and it is also needed if split-usr is enabled because other software packages currently install rules in/lib/udev/rules.d.--- src/udev/udev-rules.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)src/udev/udev-rules.c +0
-0
src/udev/udev-rules.c struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) · line 1762
Quoted 4 lines
src/udev/udev-rules.c +1
-0@@ -1759,7 +1759,12 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) rules->dirs = strv_new(TEST_PREFIX SYSCONFDIR "/udev/rules.d", TEST_PREFIX "/run/udev/rules.d", + TEST_PREFIX "/usr/local/lib/udev/rules.d",
Udev will *never* look in /usr/local, that is no place for system-level software. My take on this is: early boot has absolutely zero business in /usr/local.
I see that you just want to sync this, but I will not allow /usr/local happen to udev. It makes no sense, does not solve any problem, creates nothing but needless issues with custom setups and custom mounts (which are not uncommon) on /usr/local that are better avoided.
I tried several times to talk Lennart out of that nonsense, but wasn't successful so far. :)
src/udev/udev-rules.c struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) · line 1767
Quoted 5 lines
src/udev/udev-rules.c +4
-0TEST_PREFIX UDEVLIBEXECDIR "/rules.d", + TEST_PREFIX "/usr/lib/udev/rules.d", +#ifdef HAVE_SPLIT_USR + TEST_PREFIX "/lib/udev/rules.d", +#endif
I have no problem with that, even when I think it's the wrong way to do these things. It just creates mess, that is much bigger than the split-usr ever was. But we have it in systemd, and there is no real argument for me to make against it.
Thanks,
Kay
Quoted 12 lines · Kay Sievers
Udev will *never* look in
/usr/local, that is no place for system-level software. My take on this is: early boot has absolutely zero business in/usr/local.I see that you just want to sync this, but I will not allow
/usr/localhappen to udev. It makes no sense, does not solve any problem, creates nothing but needless issues with custom setups and custom mounts (which are not uncommon) on/usr/localthat are better avoided.I tried several times to talk Lennart out of that nonsense, but wasn't successful so far. :)
Quoted 10 lines
src/udev/udev-rules.c struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) · line 1767
Quoted 5 lines
TEST_PREFIXUDEVLIBEXECDIR "/rules.d",src/udev/udev-rules.c +4
-0+ TEST_PREFIX "/usr/lib/udev/rules.d", +#ifdef HAVE_SPLIT_USR + TEST_PREFIX "/lib/udev/rules.d", +#endif I have no problem with that, even when I think it's the wrong way to do these things. It just creates mess, that is much bigger than the split-usr ever was. But we have it in systemd, and there is no real argument for me to make against it.
I'm personally not concerned with /usr/local, but the portion above is the more important to me. For split /usr systems, there is a lot of software that installs rules in /lib/udev, so I think we need to support that directory.
Should I resubmit the patch?
Thanks,
William
Quoted 7 lines · William Hubbs
Quoted 5 lines · Kay Sievers
src/udev/udev-rules.c struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) · line 1767
Quoted 5 lines
TEST_PREFIXUDEVLIBEXECDIR "/rules.d",src/udev/udev-rules.c +4
-0+ TEST_PREFIX "/usr/lib/udev/rules.d", +#ifdef HAVE_SPLIT_USR + TEST_PREFIX "/lib/udev/rules.d", +#endif
Now we have 3 instead of one directory here, that really needs to be sorted out. It's not cool to just add every random thing here. :)
Quoted 9 lines
Quoted 4 lines
I have no problem with that, even when I think it's the wrong way to do these things. It just creates mess, that is much bigger than the split-usr ever was. But we have it in systemd, and there is no real argument for me to make against it.
I'm personally not concerned with
/usr/local, but the portion above is the more important to me. For split /usr systems, there is a lot of software that installs rules in/lib/udev, so I think we need to support that directory.
You are aware that this will not work with the installed binaries in /lib/udev/ referenced from rules and whatever? The code is really not made to have this I-read-stuff-from-all-possible locations.
It's a mess you are creating here, by not just merging /lib and /usr/lib right away.
Quoted 1 line
Should I resubmit the patch?
Nah, we need to decide what to do first, I'll let you know.
Kay
Quoted 2 lines · Kay Sievers
It's a mess you are creating here, by not just merging /lib and
/usr/libright away.
I'm not interested in the binaries being installed in /lib/udev. We just need to be able to read rules from /lib/udev/rules.d along with /usr/lib/udev/rules.d. The reason is not because of udev, but other packages which install their rules in /lib/udev/rules.d need to be fixed to install them in /usr/lib/udev/rules.d.
We are working on fixing things so we can merge /lib into /usr/lib, but that is a process for us and can't happen over night.
Thanks,
William
Quoted 3 lines · William Hubbs
/usr/lib/udev/rules.d. The reason is not because of udev, but other packages which install their rules in/lib/udev/rules.dneed to be fixed to install them in/usr/lib/udev/rules.d.
As the maintainer of udev for a distribution which still supports a standalone /usr I fail to see how this can be an issue. Why should an upstream package install something in /usr/lib/udev/rules.d/ if no distribution supports this directory?
Signature · 2 lines
ciao, Marco
Quoted 9 lines · Marco d'Itri
Quoted 3 lines · William Hubbs
/usr/lib/udev/rules.d. The reason is not because of udev, but other packages which install their rules in/lib/udev/rules.dneed to be fixed to install them in/usr/lib/udev/rules.d.As the maintainer of udev for a distribution which still supports a standalone /usr I fail to see how this can be an issue. Why should an upstream package install something in
/usr/lib/udev/rules.d/if no distribution supports this directory?
I'm not sure if you are asking me or Kay, but here is what we are running into.
The default configuration of udev-186 installs its rules in /usr/lib/udev/rules.d. When users upgrade to this udev, they will still have packages on their system that install rules in /lib/udev/rules.d. Udev needs to keep this directory as a place for rules for a while for that reason.
With the /usr merge coming, I'm thinking that packages that install rules in /lib/udev/rules.d will have to be fixed to install them in /usr/lib/udev/rules.d eventually, but until then, we should retain support in udev to read from both places.
Thoughts?
William
Quoted 6 lines · William Hubbs
With the /usr merge coming, I'm thinking that packages that install rules in
/lib/udev/rules.dwill have to be fixed to install them in/usr/lib/udev/rules.deventually, but until then, we should retain support in udev to read from both places.Thoughts?
Now I see the your point. I need to think a bit about the best solution for the transition period, but right now I suspect that it will be a /usr/lib/udev/rules.d/ to /lib/udev/rules.d/ symlink.
(My problem is that I need to think when the symlink should be created and removed to support the merge, distributions which do not support upgrades do not need to care about this detail...)
Signature · 2 lines
ciao, Marco
Quoted 7 lines · Marco d'Itri
Quoted 5 lines · William Hubbs
With the /usr merge coming, I'm thinking that packages that install rules in
/lib/udev/rules.dwill have to be fixed to install them in/usr/lib/udev/rules.deventually, but until then, we should retain support in udev to read from both places.
Quoted 8 lines
Quoted 1 line
Thoughts?
Now I see the your point. I need to think a bit about the best solution for the transition period, but right now I suspect that it will be a
/usr/lib/udev/rules.d/to/lib/udev/rules.d/symlink.(My problem is that I need to think when the symlink should be created and removed to support the merge, distributions which do not support upgrades do not need to care about this detail...)
I don't follow how a symlink either /usr/lib/udev/rules.d->/lib/udev/rules.d or the other way around is going to make the transition work smoothly for us. If we support both locations as directories, once all of the packages that still install things in /lib/udev/rules.d give us a way in their upstreams to install the rules under /usr, /lib/udev/rules.d will just naturally disappear from everyone's systems.
How is linking /usr/lib/udev/rules.d to /lib/udev/rules.d going to aid in the transition? That seems to be going backward.
William
Hello Marco,
Marco d'Itri [2012-07-14 7:52 +0200]:
Quoted 3 lines
Now I see the your point. I need to think a bit about the best solution for the transition period, but right now I suspect that it will be a
/usr/lib/udev/rules.d/to/lib/udev/rules.d/symlink.
FWIW, this seems like the best solution to me. In Debian we don't want packages (which are under our control) nor third-party packages (which would be covered by the symlink) to install udev rules (or binaries) under /usr, as (as far as I understand) Debian still wants to support a standalone /usr.
I take it the Debian udev/systemd package would not change the layout? I. e. still install most things under /lib?
Quoted 2 lines
(My problem is that I need to think when the symlink should be created and removed to support the merge
Which merge?
Thanks,
Martin
Signature · 2 lines
Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
Quoted 2 lines · Martin Pitt
I take it the Debian udev/systemd package would not change the layout? I. e. still install most things under /lib?
Indeed.
Quoted 3 lines
Quoted 2 lines
(My problem is that I need to think when the symlink should be created and removed to support the merge
Which merge?
The "everything in /usr" merge, which I plan to propose after the release. Does Ubuntu have plans about this?
Signature · 2 lines
ciao, Marco
Marco d'Itri [2012-07-15 19:14 +0200]:
Quoted 3 lines
Quoted 1 line
Which merge?
The "everything in /usr" merge, which I plan to propose after the release. Does Ubuntu have plans about this?
No, we don't. We do support a separate /usr (just like Debian), but quite frankly this is an issue which is of little interest on the areas Ubuntu is concerned with, so on the the Ubuntu side we won't spend any work on on this subject, one way or the other. I. e. we'll continue to support separate /usr for as long as Debian does.
Martin
Signature · 2 lines
Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
Quoted 11 lines · Marco d'Itri
Quoted 2 lines · Martin Pitt
I take it the Debian udev/systemd package would not change the layout? I. e. still install most things under /lib?
Indeed.
Quoted 3 lines
Quoted 2 lines
(My problem is that I need to think when the symlink should be created and removed to support the merge
Which merge?
The "everything in /usr" merge, which I plan to propose after the release. Does Ubuntu have plans about this?
That's the problem with a symlink, either way. How do you know when to create or remove it?
For us, I would have to do the following on every user's system a udev upgrade:
cp -a /lib/udev /usr/lib/udev
ln -s /usr/lib/udev /lib/udev
Then, I have no idea how I would know when to remove the link.
William
Quoted 16 lines · William Hubbs
Quoted 11 lines · Marco d'Itri
Quoted 2 lines · Martin Pitt
I take it the Debian udev/systemd package would not change the layout? I. e. still install most things under /lib?
Indeed.
Quoted 3 lines
Quoted 2 lines
(My problem is that I need to think when the symlink should be created and removed to support the merge
Which merge?
The "everything in /usr" merge, which I plan to propose after the release. Does Ubuntu have plans about this?
That's the problem with a symlink, either way. How do you know when to create or remove it?
Quoted 6 lines
For us, I would have to do the following on every user's system a udev upgrade:
cp -a
/lib/udev/usr/lib/udev
ln -s/usr/lib/udev/lib/udevThen, I have no idea how I would know when to remove the link.
Which is why you don't do such a mess.
You keep the historic split as long as it works (some day it will break step-by-step in non-interesting ways because upstream projects don't care or test a anymore), or you convert /bin, /sbin, /lib, /lib64 _one_ go to symlinks.
The conversion of the top-level dirs to symlinks is almost trivial. We did it in Fedora with no interesting problems at all.
http://people.freedesktop.org/~kay/usrmove-convert-log.png
http://people.freedesktop.org/~kay/usrmove-convert-log.txt
Doing what you try to do here, with creating a total mess with stuff randomly spread around the filesystem is just plain crazy. We do not really support that in any tool, and honestly the --enable-split-usr configure option you added to systemd should just be removed. We do not support that mess, and it makes no sense to even try. That should be a distro patch, that makes it clear that you are completely on your own here.
Better get your stuff together and make decision, by either doing nothing for now, leaving the stuff in /lib, or by really doing it and make /lib a symlink. There is no sane option to choose from doing only a part of it, or gradual, it's just madness.
Kay
Quoted 2 lines · William Hubbs
That's the problem with a symlink, either way. How do you know when to create or remove it?
This is a general problem for every package which ships the same file in / and /usr, I fear that the only solution will be to create the link in postinst if needed.
Quoted 1 line · Kay Sievers
The conversion of the top-level dirs to symlinks is almost trivial. We
Except for patching tens of packages which ship the a file with the same name in / and /usr.
Signature · 2 lines
ciao, Marco
Quoted 5 lines · Marco d'Itri
Quoted 1 line · Kay Sievers
The conversion of the top-level dirs to symlinks is almost trivial. We
Except for patching tens of packages which ship the a file with the same name in / and /usr.
Which was ~25 for Fedora, which is: nothing.
Then it might be ~75 for Debian, and that can still be fixed in one single day, if wanted to.
Kay
Quoted 11 lines · Kay Sievers
Quoted 5 lines · Marco d'Itri
Quoted 1 line · Kay Sievers
The conversion of the top-level dirs to symlinks is almost trivial. We
Except for patching tens of packages which ship the a file with the same name in / and /usr.
Which was ~25 for Fedora, which is: nothing.
Then it might be ~75 for Debian, and that can still be fixed in one single day, if wanted to.
Then there are things like what we did in gentoo years before I came on board to get around a toolchain bug https://bugs.gentoo.org/4411.
Whoever was working on this back then decided that we should move most of the critical shared libraries to /lib or /lib64 and put linker scripts in /usr/lib*. That has to disappear before we can even think about the /usr merge.
Also, remember that we are a rolling release distro. We do not have specific gentoo x.x releases; users just go along updating packages. So, I'm not sure how to force the /usr merge and symlink creation to happen on all of our users' systems in one go.
William
I need to try to make the issue for us a bit more clear.
Basically gentoo does not have fixed releases, and we support in-place upgrades of packages. So if udev changes in a way that does not retain backward compatibility for a while, it will cause breakage for us.
This is why we are asking that you continue supporting rules in /lib/udev for a while.
Thanks for your consideration,
William
Hi William,
Quoted 21 lines · William Hubbs
Quoted 11 lines · Kay Sievers
Quoted 5 lines · Marco d'Itri
Quoted 1 line · Kay Sievers
The conversion of the top-level dirs to symlinks is almost trivial. We
Except for patching tens of packages which ship the a file with the same name in / and /usr.
Which was ~25 for Fedora, which is: nothing.
Then it might be ~75 for Debian, and that can still be fixed in one single day, if wanted to.
Then there are things like what we did in gentoo years before I came on board to get around a toolchain bug https://bugs.gentoo.org/4411.
Whoever was working on this back then decided that we should move most of the critical shared libraries to /lib or /lib64 and put linker scripts in
/usr/lib*. That has to disappear before we can even think about the /usr merge.
Quoted 4 lines
Also, remember that we are a rolling release distro. We do not have specific gentoo x.x releases; users just go along updating packages. So, I'm not sure how to force the /usr merge and symlink creation to happen on all of our users' systems in one go.
Talk to Dave and Tom (CC'ed) . Archlinux is a rolling distro as welll, and they managed to get it working.
Lucas De Marchi
Quoted 9 lines · William Hubbs
Whoever was working on this back then decided that we should move most of the critical shared libraries to /lib or /lib64 and put linker scripts in
/usr/lib*. That has to disappear before we can even think about the /usr merge.Also, remember that we are a rolling release distro. We do not have specific gentoo x.x releases; users just go along updating packages. So, I'm not sure how to force the /usr merge and symlink creation to happen on all of our users' systems in one go.
We had a similar issue in Arch. What we did was the following:
Patch udev+kmod+systemd (the last one was for free) to read from {/usr,}/lib/{modprobe.d,depmod.d,udev/rules.d,systemd/system}.
We then rebuild all the packages that installed binaries to /lib/udev/ and /lib/systemd to move them to their /usr/lib counterparts (as we did not want to patch udev/systemd to read the helpers from more than one location).
Then we let people rebuild their packages to move things from /lib to /usr/lib on a package-by-package basis.
Then we rebuilt all our kernels and pointed kmod/udev to /usr/lib/modules rather than /lib/modules.
At this point only glibc owned stuff in /lib, so we rebuilt that to move it all to /usr/lib and replace /lib with a symlink to /usr/lib.
The only step that caused any issues was the last one, and that was due to users ignoring the upgrade instructions[0] and doing clever things like "rm -rf /lib".
HTH,
Tom
[0]: <http://www.archlinux.org/news/the-lib-directory-becomes-a-symlink/>
Quoted 10 lines · Tom Gundersen
We had a similar issue in Arch. What we did was the following:
Patch udev+kmod+systemd (the last one was for free) to read from {/usr,}/lib/{modprobe.d,depmod.d,udev/rules.d,systemd/system}.
We then rebuild all the packages that installed binaries to
/lib/udev/and/lib/systemdto move them to their/usr/libcounterparts (as we did not want to patch udev/systemd to read the helpers from more than one location).
Quoted 8 lines
Then we let people rebuild their packages to move things from /lib to
/usr/libon a package-by-package basis.Then we rebuilt all our kernels and pointed kmod/udev to
/usr/lib/modulesrather than/lib/modules.At this point only glibc owned stuff in /lib, so we rebuilt that to move it all to
/usr/liband replace /lib with a symlink to/usr/lib.
The problem for us with these steps is that the building happens on users' systems since we are source based, so we have to go about it differently. We can't rebuild packages and send them down to the users.
This is why it would be very helpful if udev would keep some backward compatibility and read rules from /lib/udev/rules.d as long as it was a directory.
Thanks for consideration,
William
Quoted 17 lines · William Hubbs
Quoted 16 lines · Tom Gundersen
We had a similar issue in Arch. What we did was the following:
Patch udev+kmod+systemd (the last one was for free) to read from {/usr,}/lib/{modprobe.d,depmod.d,udev/rules.d,systemd/system}.
We then rebuild all the packages that installed binaries to
/lib/udev/and/lib/systemdto move them to their/usr/libcounterparts (as we did not want to patch udev/systemd to read the helpers from more than one location).Then we let people rebuild their packages to move things from /lib to
/usr/libon a package-by-package basis.Then we rebuilt all our kernels and pointed kmod/udev to
/usr/lib/modulesrather than/lib/modules.
Quoted 6 lines
Quoted 2 lines
At this point only glibc owned stuff in /lib, so we rebuilt that to move it all to
/usr/liband replace /lib with a symlink to/usr/lib.The problem for us with these steps is that the building happens on users' systems since we are source based, so we have to go about it differently. We can't rebuild packages and send them down to the users.
No, but we can fix all packages in the tree, and then update the udev version, with a big fat warning / error when we install the new udev package saying that the rules need to be fixed by updating the packages that placed them there.
Quoted 3 lines
This is why it would be very helpful if udev would keep some backward compatibility and read rules from
/lib/udev/rules.das long as it was a directory.
I don't think this is really necessary, as long as we just fix up all packages in the tree that are doing things wrong. That shouldn't take very long (hint, if you need help, I'll be glad to do so.)
thanks,
greg k-h
Quoted 30 lines · greg
Quoted 17 lines · William Hubbs
Quoted 16 lines · Tom Gundersen
We had a similar issue in Arch. What we did was the following:
Patch udev+kmod+systemd (the last one was for free) to read from {/usr,}/lib/{modprobe.d,depmod.d,udev/rules.d,systemd/system}.
We then rebuild all the packages that installed binaries to
/lib/udev/and/lib/systemdto move them to their/usr/libcounterparts (as we did not want to patch udev/systemd to read the helpers from more than one location).Then we let people rebuild their packages to move things from /lib to
/usr/libon a package-by-package basis.Then we rebuilt all our kernels and pointed kmod/udev to
/usr/lib/modulesrather than/lib/modules.Quoted 6 lines
Quoted 2 lines
At this point only glibc owned stuff in /lib, so we rebuilt that to move it all to
/usr/liband replace /lib with a symlink to/usr/lib.The problem for us with these steps is that the building happens on users' systems since we are source based, so we have to go about it differently. We can't rebuild packages and send them down to the users.
No, but we can fix all packages in the tree, and then update the udev version, with a big fat warning / error when we install the new udev package saying that the rules need to be fixed by updating the packages that placed them there.
Quoted 7 lines
Quoted 3 lines
This is why it would be very helpful if udev would keep some backward compatibility and read rules from
/lib/udev/rules.das long as it was a directory.I don't think this is really necessary, as long as we just fix up all packages in the tree that are doing things wrong. That shouldn't take very long (hint, if you need help, I'll be glad to do so.)
Hey greg,
write to me off list and let me know what we need to do and we can go from there.
Thanks,
William