udev-253.1.ebuild 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. # Copyright 2003-2023 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. PYTHON_COMPAT=( python3_{10..12} )
  5. inherit bash-completion-r1 flag-o-matic linux-info meson-multilib ninja-utils python-any-r1 toolchain-funcs udev usr-ldscript
  6. if [[ ${MY_PV} = 9999* ]] ; then
  7. EGIT_REPO_URI="https://github.com/systemd/systemd.git"
  8. inherit git-r3
  9. else
  10. if [[ ${PV} == *.* ]] ; then
  11. MY_PN=systemd-stable
  12. else
  13. MY_PN=systemd
  14. fi
  15. MY_PV="${PV/_/-}"
  16. MY_P="${MY_PN}-${MY_PV}"
  17. S="${WORKDIR}/${MY_P}"
  18. SRC_URI="https://github.com/systemd/${MY_PN}/archive/v${MY_PV}/${MY_P}.tar.gz"
  19. # musl patches taken from:
  20. # http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-core/systemd/systemd
  21. MUSL_PATCHSET="systemd-musl-patches-250.4"
  22. SRC_URI+="
  23. elibc_musl? (
  24. https://dev.gentoo.org/~floppym/dist/${MUSL_PATCHSET}.tar.gz
  25. )"
  26. [[ ${PV} == *_rc* ]] || \
  27. KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
  28. FIXUP_PATCH="${PN}-253_rc2-revert-systemd-messup.patch"
  29. SRC_URI+=" https://www.gentoofan.org/gentoo/dist/${FIXUP_PATCH}.xz"
  30. fi
  31. DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
  32. HOMEPAGE="https://www.freedesktop.org/wiki/Software/systemd"
  33. LICENSE="LGPL-2.1 MIT GPL-2"
  34. SLOT="0"
  35. IUSE="acl +kmod selinux test"
  36. RESTRICT="!test? ( test )"
  37. BDEPEND="
  38. dev-util/gperf
  39. >=sys-apps/coreutils-8.16
  40. sys-devel/gettext
  41. virtual/pkgconfig
  42. app-text/docbook-xml-dtd:4.2
  43. app-text/docbook-xml-dtd:4.5
  44. app-text/docbook-xsl-stylesheets
  45. dev-libs/libxslt
  46. ${PYTHON_DEPS}
  47. $(python_gen_any_dep 'dev-python/jinja[${PYTHON_USEDEP}]')
  48. test? (
  49. app-text/tree
  50. dev-lang/perl
  51. )
  52. "
  53. COMMON_DEPEND="
  54. dev-libs/openssl:0=
  55. >=sys-apps/util-linux-2.30[${MULTILIB_USEDEP}]
  56. sys-libs/libcap:0=[${MULTILIB_USEDEP}]
  57. virtual/libcrypt:=[${MULTILIB_USEDEP}]
  58. acl? ( sys-apps/acl )
  59. kmod? ( >=sys-apps/kmod-15 )
  60. selinux? ( >=sys-libs/libselinux-2.1.9 )
  61. "
  62. DEPEND="${COMMON_DEPEND}
  63. >=sys-kernel/linux-headers-3.9
  64. "
  65. RDEPEND="${COMMON_DEPEND}
  66. acct-group/kmem
  67. acct-group/tty
  68. acct-group/audio
  69. acct-group/cdrom
  70. acct-group/dialout
  71. acct-group/disk
  72. acct-group/input
  73. acct-group/kvm
  74. acct-group/lp
  75. acct-group/render
  76. acct-group/sgx
  77. acct-group/tape
  78. acct-group/video
  79. !sys-apps/gentoo-systemd-integration
  80. !sys-apps/systemd
  81. !sys-apps/systemd-utils[udev]
  82. !sys-apps/hwids[udev]
  83. "
  84. PDEPEND="
  85. >=sys-fs/udev-init-scripts-34
  86. "
  87. python_check_deps() {
  88. python_has_version "dev-python/jinja[${PYTHON_USEDEP}]"
  89. }
  90. pkg_setup() {
  91. if [[ ${MERGE_TYPE} != buildonly ]] ; then
  92. CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET ~!FW_LOADER_USER_HELPER ~UNIX"
  93. linux-info_pkg_setup
  94. # CONFIG_FHANDLE was introduced by 2.6.39
  95. local MINKV=2.6.39
  96. if kernel_is -lt ${MINKV//./ } ; then
  97. eerror "Your running kernel is too old to run this version of ${MY_P}"
  98. eerror "You need to upgrade kernel at least to ${MINKV}"
  99. fi
  100. if kernel_is -lt 3 7 ; then
  101. ewarn "Your running kernel is too old to have firmware loader and"
  102. ewarn "this version of ${MY_P} doesn't have userspace firmware loader"
  103. ewarn "If you need firmware support, you need to upgrade kernel at least to 3.7"
  104. fi
  105. fi
  106. }
  107. src_prepare() {
  108. if [[ -d "${WORKDIR}/patches" ]] ; then
  109. eapply "${WORKDIR}/patches"
  110. fi
  111. local PATCHES=(
  112. )
  113. use elibc_musl && PATCHES+=( "${WORKDIR}/${MUSL_PATCHSET}" )
  114. #use elibc_musl && PATCHES+=( "${FILESDIR}/musl" )
  115. default
  116. eapply "${WORKDIR}"/${FIXUP_PATCH}
  117. }
  118. multilib_src_configure() {
  119. local emesonargs=(
  120. $(meson_native_use_bool acl)
  121. -Defi=false
  122. $(meson_native_use_bool kmod)
  123. $(meson_native_use_bool selinux)
  124. -Dlink-udev-shared=false
  125. -Dsplit-usr=true
  126. -Drootlibdir="${EPREFIX}/usr/$(get_libdir)"
  127. # Prevent automagic deps
  128. -Dgcrypt=false
  129. -Dlibcryptsetup=false
  130. -Dlibfido2=false
  131. -Didn=false
  132. -Dlibidn=false
  133. -Dlibidn2=false
  134. -Dlibiptc=false
  135. -Dlogind=false
  136. -Dp11kit=false
  137. -Dseccomp=false
  138. -Dlz4=false
  139. -Dxz=false
  140. )
  141. use elibc_musl && emesonargs+=(
  142. -Dgshadow=false
  143. -Dsmack=false
  144. -Dutmp=false
  145. )
  146. meson_src_configure
  147. }
  148. src_configure() {
  149. # Prevent conflicts with i686 cross toolchain, bug 559726
  150. tc-export AR CC NM OBJCOPY RANLIB
  151. python_setup
  152. use elibc_musl && append-cppflags -D__UAPI_DEF_ETHHDR=0
  153. multilib-minimal_src_configure
  154. }
  155. multilib_src_compile() {
  156. # meson creates this link
  157. local libudev=$(readlink libudev.so.1)
  158. local targets=(
  159. ${libudev}
  160. src/libudev/libudev.pc
  161. )
  162. if multilib_is_native_abi ; then
  163. targets+=(
  164. udevd
  165. udevadm
  166. src/udev/ata_id
  167. src/udev/cdrom_id
  168. src/udev/fido_id
  169. src/udev/mtd_probe
  170. src/udev/scsi_id
  171. src/udev/udev.pc
  172. src/udev/v4l_id
  173. man/udev.conf.5
  174. man/udev.link.5
  175. man/udev.7
  176. man/udevd.8
  177. man/udevadm.8
  178. hwdb.d/60-autosuspend-chromiumos.hwdb
  179. rules.d/50-udev-default.rules
  180. rules.d/64-btrfs.rules
  181. )
  182. # former USE="hwdb"
  183. targets+=(
  184. udev-hwdb
  185. man/hwdb.7
  186. # Fixme! Convert from systemd-hwdb.8! New patchset!
  187. #man/udev-hwdb.8
  188. )
  189. fi
  190. eninja "${targets[@]}"
  191. }
  192. src_test() {
  193. # The testsuite is *very* finicky. Don't try running it in
  194. # containers or anything but a full VM or on bare metal.
  195. # udev calls 'mknod' a number of times, and this interacts
  196. # badly with kernel namespaces.
  197. if [[ ! -w /dev ]]; then
  198. ewarn "udev tests needs full access to /dev"
  199. ewarn "Skipping tests"
  200. else
  201. meson-multilib_src_test
  202. fi
  203. }
  204. multilib_src_test() {
  205. # two binaries required by udev-test.pl
  206. eninja systemd-detect-virt test-udev
  207. local -x PATH="${PWD}:${PATH}"
  208. # prepare ${BUILD_DIR}/test/sys, required by udev-test.pl
  209. "${EPYTHON}" "${S}"/test/sys-script.py test || die
  210. # the perl script contains all the udev tests
  211. "${S}"/test/udev-test.pl || die
  212. }
  213. multilib_src_install() {
  214. local libudev=$(readlink libudev.so.1)
  215. dolib.so {${libudev},libudev.so.1,libudev.so}
  216. gen_usr_ldscript -a udev
  217. insinto "/usr/$(get_libdir)/pkgconfig"
  218. doins src/libudev/libudev.pc
  219. if multilib_is_native_abi ; then
  220. exeinto /sbin
  221. doexe udevd
  222. doexe udevadm
  223. dosym ../sbin/udevadm /bin/udevadm
  224. # Former USE="hwdb"
  225. doexe udev-hwdb
  226. exeinto /lib/udev
  227. doexe src/udev/{ata_id,cdrom_id,fido_id,mtd_probe,scsi_id,v4l_id}
  228. # Install generated rules (${BUILD_DIR}/rules.d/*.rules)
  229. insinto /lib/udev/rules.d
  230. doins rules.d/*.rules
  231. insinto /lib/udev/hwdb.d
  232. doins hwdb.d/*.hwdb
  233. insinto /usr/share/pkgconfig
  234. doins src/udev/udev.pc
  235. mv man/systemd-udevd.service.8 man/systemd-udevd.8 || die
  236. rm man/systemd-udevd-{control,kernel}.socket.8 || die
  237. doman man/*.[0-9]
  238. fi
  239. }
  240. multilib_src_install_all() {
  241. doheader src/libudev/libudev.h
  242. insinto /etc/udev
  243. doins src/udev/udev.conf
  244. keepdir /etc/udev/{hwdb.d,rules.d}
  245. insinto /lib/udev/network
  246. doins network/99-default.link
  247. # Install static rules (${S}/rules.d/*.rules)
  248. insinto /lib/udev/rules.d
  249. doins rules.d/*.rules
  250. doins "${FILESDIR}"/40-gentoo.rules
  251. # this file is provided by sys-auth/elogind
  252. rm ${ED}/lib/udev/rules.d/70-power-switch.rules || die
  253. insinto /lib/udev/hwdb.d
  254. doins hwdb.d/*.hwdb
  255. dobashcomp shell-completion/bash/udevadm
  256. insinto /usr/share/zsh/site-functions
  257. doins shell-completion/zsh/_udevadm
  258. einstalldocs
  259. }
  260. pkg_postinst() {
  261. local netrules="80-net-setup-link.rules"
  262. local net_rules="${ROOT}"/etc/udev/rules.d/${netrules}
  263. copy_net_rules() {
  264. [[ -f ${net_rules} ]] || cp "${ROOT}"/usr/share/doc/${PF}/gentoo/${netrules} "${net_rules}"
  265. }
  266. if [[ ${REPLACING_VERSIONS} ]] && [[ ${REPLACING_VERSIONS} < 209 ]] ; then
  267. ewarn "Because this is a upgrade we disable the new predictable network interface"
  268. ewarn "name scheme by default."
  269. copy_net_rules
  270. fi
  271. if [[ -n "${net_rules}" ]] ; then
  272. ewarn
  273. ewarn "udev-197 and newer introduces a new method of naming network"
  274. ewarn "interfaces. The new names are a very significant change, so"
  275. ewarn "they are disabled by default on live systems."
  276. ewarn "Please see the contents of ${net_rules} for more"
  277. ewarn "information on this feature."
  278. ewarn
  279. fi
  280. local fstab="${ROOT}"/etc/fstab dev path fstype rest
  281. while read -r dev path fstype rest ; do
  282. if [[ ${path} == /dev && ${fstype} != devtmpfs ]] ; then
  283. ewarn "You need to edit your /dev line in ${fstab} to have devtmpfs"
  284. ewarn "filesystem. Otherwise udev won't be able to boot."
  285. ewarn "See, https://bugs.gentoo.org/453186"
  286. fi
  287. done < "${fstab}"
  288. if [[ -d ${ROOT}/usr/lib/udev ]] ; then
  289. ewarn
  290. ewarn "Please re-emerge all packages on your system which install"
  291. ewarn "rules and helpers in /usr/lib/udev. They should now be in"
  292. ewarn "/lib/udev."
  293. ewarn
  294. ewarn "One way to do this is to run the following command:"
  295. ewarn "emerge -av1 \$(qfile -CSq /usr/lib/udev | xargs)"
  296. ewarn "Note that qfile can be found in app-portage/portage-utils"
  297. fi
  298. ewarn
  299. ewarn "You need to restart udev as soon as possible to make the upgrade go"
  300. ewarn "into effect."
  301. ewarn "The method you use to do this depends on your init system."
  302. if has_version 'sys-apps/openrc' ; then
  303. ewarn "For sys-apps/openrc users it is:"
  304. ewarn "# /etc/init.d/udev --nodeps restart"
  305. fi
  306. elog
  307. elog "For more information on udev on Gentoo, upgrading, writing udev rules, and"
  308. elog "fixing known issues visit:"
  309. elog "https://wiki.gentoo.org/wiki/Udev"
  310. elog "https://wiki.gentoo.org/wiki/Udev/upgrade"
  311. # Update hwdb database in case the format is changed by udev version.
  312. if has_version 'sys-apps/hwids[udev]' || has_version 'sys-apps/hwdata' ; then
  313. ebegin "Updating hwdb"
  314. udev-hwdb --root="${ROOT}" update
  315. eend $?
  316. fi
  317. udev_reload
  318. }
  319. pkg_postrm() {
  320. udev_reload
  321. }