app-arch/upx-bin: remove old
[gentoo.git] / sys-fs / udev / udev-243.ebuild
1 # Copyright 2003-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit bash-completion-r1 linux-info meson ninja-utils multilib-minimal toolchain-funcs udev
7
8 if [[ ${PV} = 9999* ]]; then
9         EGIT_REPO_URI="https://github.com/systemd/systemd.git"
10         inherit git-r3
11 else
12         MY_PV=${PV/_/-}
13         MY_P=systemd-${MY_PV}
14         S=${WORKDIR}/${MY_P}
15         SRC_URI="https://github.com/systemd/systemd/archive/v${MY_PV}/${MY_P}.tar.gz"
16         KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86"
17 fi
18
19 DESCRIPTION="Linux dynamic and persistent device naming support (aka userspace devfs)"
20 HOMEPAGE="https://www.freedesktop.org/wiki/Software/systemd"
21
22 LICENSE="LGPL-2.1 MIT GPL-2"
23 SLOT="0"
24 IUSE="acl +kmod selinux"
25
26 RESTRICT="test"
27
28 COMMON_DEPEND=">=sys-apps/util-linux-2.30[${MULTILIB_USEDEP}]
29         sys-libs/libcap[${MULTILIB_USEDEP}]
30         acl? ( sys-apps/acl )
31         kmod? ( >=sys-apps/kmod-16 )
32         selinux? ( >=sys-libs/libselinux-2.1.9 )
33         !<sys-libs/glibc-2.11
34         !sys-apps/gentoo-systemd-integration
35         !sys-apps/systemd"
36 DEPEND="${COMMON_DEPEND}
37         dev-util/gperf
38         >=dev-util/intltool-0.50
39         >=dev-util/meson-0.40.0
40         dev-util/ninja
41         >=sys-apps/coreutils-8.16
42         virtual/os-headers
43         virtual/pkgconfig
44         >=sys-kernel/linux-headers-3.9
45         app-text/docbook-xml-dtd:4.2
46         app-text/docbook-xml-dtd:4.5
47         app-text/docbook-xsl-stylesheets
48         dev-libs/libxslt"
49 RDEPEND="${COMMON_DEPEND}
50         acct-group/kmem
51         acct-group/tty
52         acct-group/audio
53         acct-group/cdrom
54         acct-group/dialout
55         acct-group/disk
56         acct-group/input
57         acct-group/kvm
58         acct-group/lp
59         acct-group/render
60         acct-group/tape
61         acct-group/video
62         !<sys-fs/lvm2-2.02.103
63         !<sec-policy/selinux-base-2.20120725-r10"
64 PDEPEND=">=sys-apps/hwids-20140304[udev]
65         >=sys-fs/udev-init-scripts-26"
66
67 pkg_setup() {
68         if [[ ${MERGE_TYPE} != buildonly ]]; then
69                 CONFIG_CHECK="~BLK_DEV_BSG ~DEVTMPFS ~!IDE ~INOTIFY_USER ~!SYSFS_DEPRECATED ~!SYSFS_DEPRECATED_V2 ~SIGNALFD ~EPOLL ~FHANDLE ~NET ~!FW_LOADER_USER_HELPER ~UNIX"
70                 linux-info_pkg_setup
71
72                 # CONFIG_FHANDLE was introduced by 2.6.39
73                 local MINKV=2.6.39
74
75                 if kernel_is -lt ${MINKV//./ }; then
76                         eerror "Your running kernel is too old to run this version of ${P}"
77                         eerror "You need to upgrade kernel at least to ${MINKV}"
78                 fi
79
80                 if kernel_is -lt 3 7; then
81                         ewarn "Your running kernel is too old to have firmware loader and"
82                         ewarn "this version of ${P} doesn't have userspace firmware loader"
83                         ewarn "If you need firmware support, you need to upgrade kernel at least to 3.7"
84                 fi
85         fi
86 }
87
88 src_prepare() {
89         cat <<-EOF > "${T}"/40-gentoo.rules
90         # Gentoo specific floppy and usb groups
91         ACTION=="add", SUBSYSTEM=="block", KERNEL=="fd[0-9]", GROUP="floppy"
92         ACTION=="add", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="usb"
93         EOF
94
95         if [[ -d "${WORKDIR}/patches" ]]; then
96                 eapply "${WORKDIR}/patches"
97         fi
98
99         default
100 }
101
102 meson_multilib_native_use() {
103         if multilib_is_native_abi && use "$1"; then
104                 echo true
105         else
106                 echo false
107         fi
108 }
109
110 multilib_src_configure() {
111         local emesonargs=(
112                 -Dacl=$(meson_multilib_native_use acl)
113                 -Defi=false
114                 -Dkmod=$(meson_multilib_native_use kmod)
115                 -Dselinux=$(meson_multilib_native_use selinux)
116                 -Dlink-udev-shared=false
117                 -Dsplit-usr=true
118
119                 # Prevent automagic deps
120                 -Dgcrypt=false
121                 -Dlibcryptsetup=false
122                 -Dlibidn=false
123                 -Dlibidn2=false
124                 -Dlibiptc=false
125                 -Dseccomp=false
126                 -Dlz4=false
127                 -Dxz=false
128         )
129         meson_src_configure
130 }
131
132 src_configure() {
133         # Prevent conflicts with i686 cross toolchain, bug 559726
134         tc-export AR CC NM OBJCOPY RANLIB
135         multilib-minimal_src_configure
136 }
137
138 multilib_src_compile() {
139         # meson creates this link
140         local libudev=$(readlink src/udev/libudev.so.1)
141
142         local targets=(
143                 src/udev/${libudev}
144         )
145         if multilib_is_native_abi; then
146                 targets+=(
147                         systemd-udevd
148                         udevadm
149                         src/udev/ata_id
150                         src/udev/cdrom_id
151                         src/udev/mtd_probe
152                         src/udev/scsi_id
153                         src/udev/v4l_id
154                         man/udev.conf.5
155                         man/systemd.link.5
156                         man/hwdb.7
157                         man/udev.7
158                         man/systemd-udevd.service.8
159                         man/udevadm.8
160                 )
161         fi
162         eninja "${targets[@]}"
163 }
164
165 multilib_src_install() {
166         local libudev=$(readlink src/udev/libudev.so.1)
167
168         into /
169         dolib.so src/udev/{${libudev},libudev.so.1,libudev.so}
170
171         insinto "/usr/$(get_libdir)/pkgconfig"
172         doins src/libudev/libudev.pc
173
174         if multilib_is_native_abi; then
175                 into /
176                 dobin udevadm
177
178                 exeinto /lib/systemd
179                 doexe systemd-udevd
180
181                 exeinto /lib/udev
182                 doexe src/udev/{ata_id,cdrom_id,mtd_probe,scsi_id,v4l_id}
183
184                 rm rules/99-systemd.rules || die
185                 insinto /lib/udev/rules.d
186                 doins rules/*.rules
187
188                 insinto /usr/share/pkgconfig
189                 doins src/udev/udev.pc
190
191                 mv man/systemd-udevd.service.8 man/systemd-udevd.8 || die
192                 rm man/systemd-udevd-{control,kernel}.socket.8 || die
193                 doman man/*.[0-9]
194         fi
195 }
196
197 multilib_src_install_all() {
198         doheader src/libudev/libudev.h
199
200         insinto /etc/udev
201         doins src/udev/udev.conf
202         keepdir /etc/udev/{hwdb.d,rules.d}
203
204         insinto /lib/systemd/network
205         doins network/99-default.link
206
207         # see src_prepare() for content of 40-gentoo.rules
208         insinto /lib/udev/rules.d
209         doins "${T}"/40-gentoo.rules
210         doins "${S}"/rules/*.rules
211
212         dobashcomp shell-completion/bash/udevadm
213
214         insinto /usr/share/zsh/site-functions
215         doins shell-completion/zsh/_udevadm
216
217         einstalldocs
218 }
219
220 pkg_postinst() {
221         mkdir -p "${ROOT%/}"/run
222
223         # "losetup -f" is confused if there is an empty /dev/loop/, Bug #338766
224         # So try to remove it here (will only work if empty).
225         rmdir "${ROOT%/}"/dev/loop 2>/dev/null
226         if [[ -d ${ROOT%/}/dev/loop ]]; then
227                 ewarn "Please make sure your remove /dev/loop,"
228                 ewarn "else losetup may be confused when looking for unused devices."
229         fi
230
231         local fstab="${ROOT%/}"/etc/fstab dev path fstype rest
232         while read -r dev path fstype rest; do
233                 if [[ ${path} == /dev && ${fstype} != devtmpfs ]]; then
234                         ewarn "You need to edit your /dev line in ${fstab} to have devtmpfs"
235                         ewarn "filesystem. Otherwise udev won't be able to boot."
236                         ewarn "See, https://bugs.gentoo.org/453186"
237                 fi
238         done < "${fstab}"
239
240         if [[ -d ${ROOT%/}/usr/lib/udev ]]; then
241                 ewarn
242                 ewarn "Please re-emerge all packages on your system which install"
243                 ewarn "rules and helpers in /usr/lib/udev. They should now be in"
244                 ewarn "/lib/udev."
245                 ewarn
246                 ewarn "One way to do this is to run the following command:"
247                 ewarn "emerge -av1 \$(qfile -q -S -C /usr/lib/udev)"
248                 ewarn "Note that qfile can be found in app-portage/portage-utils"
249         fi
250
251         local old_cd_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-cd.rules
252         local old_net_rules="${ROOT%/}"/etc/udev/rules.d/70-persistent-net.rules
253         for old_rules in "${old_cd_rules}" "${old_net_rules}"; do
254                 if [[ -f ${old_rules} ]]; then
255                         ewarn
256                         ewarn "File ${old_rules} is from old udev installation but if you still use it,"
257                         ewarn "rename it to something else starting with 70- to silence this deprecation"
258                         ewarn "warning."
259                 fi
260         done
261
262         elog
263         elog "Starting from version >= 197 the new predictable network interface names are"
264         elog "used by default, see:"
265         elog "https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames"
266         elog "https://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-net_id.c"
267         elog
268         elog "Example command to get the information for the new interface name before booting"
269         elog "(replace <ifname> with, for example, eth0):"
270         elog "# udevadm test-builtin net_id /sys/class/net/<ifname> 2> /dev/null"
271         elog
272         elog "You can use either kernel parameter \"net.ifnames=0\", create empty"
273         elog "file /etc/systemd/network/99-default.link, or symlink it to /dev/null"
274         elog "to disable the feature."
275
276         if has_version 'sys-apps/biosdevname'; then
277                 ewarn
278                 ewarn "You can replace the functionality of sys-apps/biosdevname which has been"
279                 ewarn "detected to be installed with the new predictable network interface names."
280         fi
281
282         ewarn
283         ewarn "You need to restart udev as soon as possible to make the upgrade go"
284         ewarn "into effect."
285         ewarn "The method you use to do this depends on your init system."
286         if has_version 'sys-apps/openrc'; then
287                 ewarn "For sys-apps/openrc users it is:"
288                 ewarn "# /etc/init.d/udev --nodeps restart"
289         fi
290
291         elog
292         elog "For more information on udev on Gentoo, upgrading, writing udev rules, and"
293         elog "fixing known issues visit:"
294         elog "https://wiki.gentoo.org/wiki/Udev"
295         elog "https://wiki.gentoo.org/wiki/Udev/upgrade"
296
297         # If user has disabled 80-net-name-slot.rules using a empty file or a symlink to /dev/null,
298         # do the same for 80-net-setup-link.rules to keep the old behavior
299         local net_move=no
300         local net_name_slot_sym=no
301         local net_rules_path="${ROOT%/}"/etc/udev/rules.d
302         local net_name_slot="${net_rules_path}"/80-net-name-slot.rules
303         local net_setup_link="${net_rules_path}"/80-net-setup-link.rules
304         if [[ ! -e ${net_setup_link} ]]; then
305                 [[ -f ${net_name_slot} && $(sed -e "/^#/d" -e "/^\W*$/d" ${net_name_slot} | wc -l) == 0 ]] && net_move=yes
306                 if [[ -L ${net_name_slot} && $(readlink ${net_name_slot}) == /dev/null ]]; then
307                         net_move=yes
308                         net_name_slot_sym=yes
309                 fi
310         fi
311         if [[ ${net_move} == yes ]]; then
312                 ebegin "Copying ${net_name_slot} to ${net_setup_link}"
313
314                 if [[ ${net_name_slot_sym} == yes ]]; then
315                         ln -nfs /dev/null "${net_setup_link}"
316                 else
317                         cp "${net_name_slot}" "${net_setup_link}"
318                 fi
319                 eend $?
320         fi
321
322         # Update hwdb database in case the format is changed by udev version.
323         if has_version 'sys-apps/hwids[udev]'; then
324                 udevadm hwdb --update --root="${ROOT%/}"
325                 # Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
326                 # https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
327                 [[ -z ${REPLACING_VERSIONS} ]] && udev_reload
328         fi
329 }