Opened 2 months ago

Last modified 11 days ago

#4914 new task

Eudev deprecation

Reported by: pierre Owned by: lfs-book
Priority: normal Milestone: 11.1
Component: Book Version: git
Severity: normal Keywords:
Cc:

Description

See https://github.com/gentoo/eudev/issues/199

It looks like udev can be extracted directly from systemd (needs meson and ninja): https://gitea.artixlinux.org/packagesX/xudev/src/branch/master/trunk/PKGBUILD

Attachments (1)

replace-eudev-with-udev.patch (20.2 KB ) - added by DJ Lucas 7 weeks ago.
Patch to replace eudev with udev directly from systemd

Download all attachments as: .zip

Change History (14)

comment:1 by Bruce Dubbs, 2 months ago

This is unfortunate. The procedure referenced is very complicated.

comment:2 by Xi Ruoyao, 8 weeks ago

I think the following will work:

# use systemd tarball
tar xf systemd-249.tar.gz
cd systemd-249

# systemd-249-security_fix-1.patch is unneeded for udev
# but udev rules should be fixed as well
# or we can create "render" and "sgx" groups in chapter 7?
sed -i -e 's/GROUP="render"/GROUP="video"/' \
       -e 's/GROUP="sgx", //' rules.d/50-udev-default.rules.in

# meson
mkdir build
cd build
meson .. --prefix=/usr -Dlink-udev-shared=false \
      ... ... ... # follow systemd instruction

# build
ninja udevadm \
      $(grep '^build' build.ninja | sed 's/build \([^:]*\).*/\1/' | egrep "^src/libudev|^src/udev|^rules.d|^hwdb.d") \
      $(realpath libudev.so --relative-to .)

# install
install -vm755 udevadm /usr/bin
ln -sv ../bin/udevadm /usr/sbin/udevd
install -vm755 libudev.so{,*[0-9]} /usr/lib
install -vm755 $(find src/udev -type f | fgrep -v ".") /usr/lib/udev
install -vm644 src/libudev/*.pc /usr/lib/pkgconfig
install -vm644 src/udev/*.pc /usr/share/pkgconfig
install -d -vm755 {/usr/lib,/etc}/{hwdb,rules}.d
install -vm644 ../src/udev/udev.conf /etc/udev
install -vm644 rules.d/* ../rules.d/{*.rules,README} /usr/lib/udev/rules.d
install -vm644 hwdb.d/* ../hwdb.d/{*.hwdb,README} /usr/lib/udev/hwdb.d

# man pages need to be installed from systemd-man-pages-249.tar.xz
tar xf ../../systemd-man-pages-249.tar.xz --strip-components=1 -C /usr/share/man \
    systemd-man-pages-249/{man3/libudev.3,man5/udev.conf.5,man7/{udev,hwdb}.7,man8/udevadm.8}

# configuring: generate /etc/udev/hwdb.bin
udevadm hwdb --update
Last edited 8 weeks ago by Xi Ruoyao (previous) (diff)

comment:3 by DJ Lucas, 8 weeks ago

Did you catch Joe's note about not linking to libsystemd/udev? Although, ISTR that we might actually want libudev, there are packages that look for it. Might want to repost in the dev thread. Also, the additional rules that use .in files should be created. The closer we are to upstream, the better IMO. I'm not sure if that's covered above or not, but I've got to run.

comment:4 by pierre, 8 weeks ago

Another alternative: libudev-zero. Alpine linux should begin to use it.

Last edited 8 weeks ago by pierre (previous) (diff)

in reply to:  4 ; comment:5 by Bruce Dubbs, 7 weeks ago

Replying to pierre:

Another alternative: libudev-zero. Alpine linux should begin to use it.

Looks interesting. Are you going to try it?

in reply to:  5 comment:6 by ken@…, 7 weeks ago

Replying to Bruce Dubbs:

Replying to pierre:

Another alternative: libudev-zero. Alpine linux should begin to use it.

Looks interesting. Are you going to try it?

It seems to be incomplete - apart from possibly breaking dosfstools, it needs a device manager for hotplugging (e.g. usb disks, sticks, printers). It mentions mdev, looking at closed issues that seems to be the preferred way.

I remember the name mdev (I think hardened lfs maybe used it), the first link google came up with for me was https://wiki.gentoo.org/wiki/Mdev - does not look encouraging.

comment:7 by DJ Lucas, 7 weeks ago

Replying to Xi Ruoyao:

I think the following will work:

# use systemd tarball
<snip>
install -vm755 $(find src/udev -type f | fgrep -v ".") /usr/lib/udev
<snip>

Works, except you need to create /usr/lib/udev just before this line, and libudev.h needs to be installed: install -vdm755 /usr/lib/udev ... install -vm644 ../src/libudev/libudev.h /usr/include

I queued it up locally and was running a -j8 jhalfs build. I didn't catch the lack of libudev.h until util-linux so I'm going to start over quick. I run all testsuites, so it'll be about 2.5 hours including kernel so I can boot it. Using revision for the sysv book was not possible, so I just made a copy locally. Currently I've called it systemd-udev to make it easy for my pacman variant of LFS, but will fix that in my sandbox shortly, assuming that is not what is ultimately wanted, the title for the page/package should just be udev?

by DJ Lucas, 7 weeks ago

Patch to replace eudev with udev directly from systemd

comment:8 by DJ Lucas, 7 weeks ago

Sorry, forgot to report back on this.

So, there were a couple of minor changes, but this will work. We will need to correct the location of /usr/sbin/udevadm in elogind in BLFS, but otherwise, this works well.

I needed it anyway, so a complete patch based on what Xi had above is attached (minus changelog, also build size is not correct) in the event that this is the selected route over other options.

FWIW, this is my preferred solution, despite the addition of Jinja2 and MarkupSafe, because it stays closer to upstream and it further minimizes the differences between the books of the two init variants.

comment:9 by DJ Lucas, 7 weeks ago

I stand corrected. No file descriptors are created in /dev, including the /dev/fd -> /proc/self/fd symlink. Still investigating.

comment:10 by DJ Lucas, 7 weeks ago

Caused by this commit: https://github.com/systemd/systemd/commit/6b2229c6c60d0486#diff-000342aa23dfb7299537dded24bb982625fdb7bc62f94be779c94041e49e1e5aR1861-L1865

This is simple enough to revert, but would we want to? It's easy enough to create the five missing symlinks as upstream suggests, presumably in the udev bootscript.

From src/shared/dev-setup.c:

...
int dev_setup(const char *prefix, uid_t uid, gid_t gid) {
        static const char symlinks[] =
                "-/proc/kcore\0"     "/dev/core\0"
                "/proc/self/fd\0"    "/dev/fd\0"
                "/proc/self/fd/0\0"  "/dev/stdin\0"
                "/proc/self/fd/1\0"  "/dev/stdout\0"
                "/proc/self/fd/2\0"  "/dev/stderr\0";
...

comment:11 by pierre, 5 weeks ago

FWIIW, looking at the code in dev-setup.c, the "-" before /proc/kcore means that the existence of that file is tested, and the symlink is not created if non existent.

comment:12 by pierre, 5 weeks ago

From Frans de Boer message on -support, Eudev might be maintained again at devuan or at alpine linux

comment:13 by Bruce Dubbs, 11 days ago

A new github instance: https://github.com/eudev-project/eudev

Currently still at the version we have in the book.

Note: See TracTickets for help on using tickets.