systemd-226-r2.ebuild 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. if [[ ${PV} == 9999 ]]; then
  5. EGIT_REPO_URI="https://github.com/systemd/systemd.git"
  6. inherit git-r3
  7. else
  8. SRC_URI="https://github.com/systemd/systemd/archive/v${PV}.tar.gz -> ${P}.tar.gz"
  9. KEYWORDS="alpha amd64 arm ia64 ppc ppc64 sparc x86"
  10. fi
  11. inherit autotools bash-completion-r1 linux-info multilib \
  12. multilib-minimal pam systemd toolchain-funcs udev user
  13. DESCRIPTION="System and service manager for Linux"
  14. HOMEPAGE="https://www.freedesktop.org/wiki/Software/systemd"
  15. LICENSE="GPL-2 LGPL-2.1 MIT public-domain"
  16. SLOT="0/2"
  17. IUSE="acl apparmor audit build cryptsetup curl elfutils gcrypt gnuefi http
  18. idn importd +kdbus +kmod +lz4 lzma nat pam policykit
  19. qrcode +seccomp selinux ssl sysv-utils test vanilla xkb"
  20. REQUIRED_USE="importd? ( curl gcrypt lzma )"
  21. MINKV="3.11"
  22. COMMON_DEPEND=">=sys-apps/util-linux-2.26:0=[${MULTILIB_USEDEP}]
  23. sys-libs/libcap:0=[${MULTILIB_USEDEP}]
  24. !<sys-libs/glibc-2.16
  25. acl? ( sys-apps/acl:0= )
  26. apparmor? ( sys-libs/libapparmor:0= )
  27. audit? ( >=sys-process/audit-2:0= )
  28. cryptsetup? ( >=sys-fs/cryptsetup-1.6:0= )
  29. curl? ( net-misc/curl:0= )
  30. elfutils? ( >=dev-libs/elfutils-0.158:0= )
  31. gcrypt? ( >=dev-libs/libgcrypt-1.4.5:0=[${MULTILIB_USEDEP}] )
  32. http? (
  33. >=net-libs/libmicrohttpd-0.9.33:0=
  34. ssl? ( >=net-libs/gnutls-3.1.4:0= )
  35. )
  36. idn? ( net-dns/libidn:0= )
  37. importd? (
  38. app-arch/bzip2:0=
  39. sys-libs/zlib:0=
  40. )
  41. kmod? ( >=sys-apps/kmod-15:0= )
  42. lz4? ( >=app-arch/lz4-0_p119:0=[${MULTILIB_USEDEP}] )
  43. lzma? ( >=app-arch/xz-utils-5.0.5-r1:0=[${MULTILIB_USEDEP}] )
  44. nat? ( net-firewall/iptables:0= )
  45. pam? ( virtual/pam:= )
  46. qrcode? ( media-gfx/qrencode:0= )
  47. seccomp? ( sys-libs/libseccomp:0= )
  48. selinux? ( sys-libs/libselinux:0= )
  49. sysv-utils? (
  50. !sys-apps/systemd-sysv-utils
  51. !sys-apps/sysvinit )
  52. xkb? ( >=x11-libs/libxkbcommon-0.4.1:0= )
  53. abi_x86_32? ( !<=app-emulation/emul-linux-x86-baselibs-20130224-r9
  54. !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)] )"
  55. # baselayout-2.2 has /run
  56. RDEPEND="${COMMON_DEPEND}
  57. >=sys-apps/baselayout-2.2
  58. !build? ( || (
  59. sys-apps/util-linux[kill(-)]
  60. sys-process/procps[kill(+)]
  61. sys-apps/coreutils[kill(-)]
  62. ) )
  63. !sys-auth/nss-myhostname
  64. !sys-fs/eudev
  65. !sys-fs/udev"
  66. # sys-apps/dbus: the daemon only (+ build-time lib dep for tests)
  67. PDEPEND=">=sys-apps/dbus-1.6.8-r1:0[systemd]
  68. >=sys-apps/hwids-20150417[udev]
  69. >=sys-fs/udev-init-scripts-25
  70. policykit? ( sys-auth/polkit )
  71. !vanilla? ( sys-apps/gentoo-systemd-integration )"
  72. # Newer linux-headers needed by ia64, bug #480218
  73. DEPEND="${COMMON_DEPEND}
  74. app-arch/xz-utils:0
  75. <dev-util/gperf-3.1
  76. >=dev-util/intltool-0.50
  77. >=sys-apps/coreutils-8.16
  78. >=sys-devel/binutils-2.23.1
  79. >=sys-devel/gcc-4.6
  80. >=sys-kernel/linux-headers-${MINKV}
  81. virtual/pkgconfig
  82. gnuefi? ( >=sys-boot/gnu-efi-3.0.2 )
  83. test? ( >=sys-apps/dbus-1.6.8-r1:0 )
  84. app-text/docbook-xml-dtd:4.2
  85. app-text/docbook-xml-dtd:4.5
  86. app-text/docbook-xsl-stylesheets
  87. dev-libs/libxslt:0
  88. >=dev-libs/libgcrypt-1.4.5:0"
  89. pkg_pretend() {
  90. local CONFIG_CHECK="~AUTOFS4_FS ~BLK_DEV_BSG ~CGROUPS
  91. ~DEVTMPFS ~DMIID ~EPOLL ~FANOTIFY ~FHANDLE
  92. ~INOTIFY_USER ~IPV6 ~NET ~NET_NS ~PROC_FS ~SIGNALFD ~SYSFS
  93. ~TIMERFD ~TMPFS_XATTR ~UNIX
  94. ~!FW_LOADER_USER_HELPER ~!GRKERNSEC_PROC ~!IDE ~!SYSFS_DEPRECATED
  95. ~!SYSFS_DEPRECATED_V2"
  96. use acl && CONFIG_CHECK+=" ~TMPFS_POSIX_ACL"
  97. use seccomp && CONFIG_CHECK+=" ~SECCOMP ~SECCOMP_FILTER"
  98. kernel_is -lt 3 7 && CONFIG_CHECK+=" ~HOTPLUG"
  99. kernel_is -lt 4 7 && CONFIG_CHECK+=" ~DEVPTS_MULTIPLE_INSTANCES"
  100. if linux_config_exists; then
  101. local uevent_helper_path=$(linux_chkconfig_string UEVENT_HELPER_PATH)
  102. if [ -n "${uevent_helper_path}" ] && [ "${uevent_helper_path}" != '""' ]; then
  103. ewarn "It's recommended to set an empty value to the following kernel config option:"
  104. ewarn "CONFIG_UEVENT_HELPER_PATH=${uevent_helper_path}"
  105. fi
  106. fi
  107. if [[ ${MERGE_TYPE} != binary ]]; then
  108. if [[ $(gcc-major-version) -lt 4
  109. || ( $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 6 ) ]]
  110. then
  111. eerror "systemd requires at least gcc 4.6 to build. Please switch the active"
  112. eerror "gcc version using gcc-config."
  113. die "systemd requires at least gcc 4.6"
  114. fi
  115. fi
  116. if [[ ${MERGE_TYPE} != buildonly ]]; then
  117. if kernel_is -lt ${MINKV//./ }; then
  118. ewarn "Kernel version at least ${MINKV} required"
  119. fi
  120. check_extra_config
  121. fi
  122. }
  123. pkg_setup() {
  124. :
  125. }
  126. src_unpack() {
  127. default
  128. [[ ${PV} != 9999 ]] || git-r3_src_unpack
  129. }
  130. src_prepare() {
  131. # Bug 463376
  132. sed -i -e 's/GROUP="dialout"/GROUP="uucp"/' rules/*.rules || die
  133. epatch "${FILESDIR}/218-Dont-enable-audit-by-default.patch"
  134. epatch "${FILESDIR}/226-noclean-tmp.patch"
  135. epatch "${FILESDIR}/CVE-2015-7510.patch"
  136. epatch "${FILESDIR}/226-kcmp.patch"
  137. epatch_user
  138. eautoreconf
  139. }
  140. src_configure() {
  141. # Keep using the one where the rules were installed.
  142. MY_UDEVDIR=$(get_udevdir)
  143. # Fix systems broken by bug #509454.
  144. [[ ${MY_UDEVDIR} ]] || MY_UDEVDIR=/lib/udev
  145. # Prevent conflicts with i686 cross toolchain, bug 559726
  146. tc-export AR CC NM OBJCOPY RANLIB
  147. multilib-minimal_src_configure
  148. }
  149. multilib_src_configure() {
  150. local myeconfargs=(
  151. # disable -flto since it is an optimization flag
  152. # and makes distcc less effective
  153. cc_cv_CFLAGS__flto=no
  154. # Workaround for gcc-4.7, bug 554454.
  155. cc_cv_CFLAGS__Werror_shadow=no
  156. # Workaround for bug 516346
  157. --enable-dependency-tracking
  158. --disable-maintainer-mode
  159. --localstatedir=/var
  160. --with-pamlibdir=$(getpam_mod_dir)
  161. # avoid bash-completion dep
  162. --with-bashcompletiondir="$(get_bashcompdir)"
  163. # make sure we get /bin:/sbin in $PATH
  164. --enable-split-usr
  165. # For testing.
  166. --with-rootprefix="${ROOTPREFIX-/usr}"
  167. --with-rootlibdir="${ROOTPREFIX-/usr}/$(get_libdir)"
  168. # disable sysv compatibility
  169. --with-sysvinit-path=
  170. --with-sysvrcnd-path=
  171. # no deps
  172. --enable-efi
  173. --enable-ima
  174. --without-python
  175. # Optional components/dependencies
  176. $(multilib_native_use_enable acl)
  177. $(multilib_native_use_enable apparmor)
  178. $(multilib_native_use_enable audit)
  179. $(multilib_native_use_enable cryptsetup libcryptsetup)
  180. $(multilib_native_use_enable curl libcurl)
  181. $(multilib_native_use_enable elfutils)
  182. $(use_enable gcrypt)
  183. $(multilib_native_use_enable gnuefi)
  184. $(multilib_native_use_enable http microhttpd)
  185. $(usex http $(multilib_native_use_enable ssl gnutls) --disable-gnutls)
  186. $(multilib_native_use_enable idn libidn)
  187. $(multilib_native_use_enable importd)
  188. $(multilib_native_use_enable importd bzip2)
  189. $(multilib_native_use_enable importd zlib)
  190. $(use_enable kdbus)
  191. $(multilib_native_use_enable kmod)
  192. $(use_enable lz4)
  193. $(use_enable lzma xz)
  194. $(multilib_native_use_enable nat libiptc)
  195. $(multilib_native_use_enable pam)
  196. $(multilib_native_use_enable policykit polkit)
  197. $(multilib_native_use_enable qrcode qrencode)
  198. $(multilib_native_use_enable seccomp)
  199. $(multilib_native_use_enable selinux)
  200. $(multilib_native_use_enable test tests)
  201. $(multilib_native_use_enable test dbus)
  202. $(multilib_native_use_enable xkb xkbcommon)
  203. # hardcode a few paths to spare some deps
  204. KILL=/bin/kill
  205. QUOTAON=/usr/sbin/quotaon
  206. QUOTACHECK=/usr/sbin/quotacheck
  207. # TODO: we may need to restrict this to gcc
  208. EFI_CC="$(tc-getCC)"
  209. # dbus paths
  210. --with-dbuspolicydir="${EPREFIX}/etc/dbus-1/system.d"
  211. --with-dbussessionservicedir="${EPREFIX}/usr/share/dbus-1/services"
  212. --with-dbussystemservicedir="${EPREFIX}/usr/share/dbus-1/system-services"
  213. --with-ntp-servers="0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org 2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org"
  214. )
  215. # Work around bug 463846.
  216. tc-export CC
  217. ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
  218. }
  219. multilib_src_compile() {
  220. local mymakeopts=(
  221. udevlibexecdir="${MY_UDEVDIR}"
  222. )
  223. if multilib_is_native_abi; then
  224. emake "${mymakeopts[@]}"
  225. else
  226. echo 'gentoo: $(BUILT_SOURCES)' | \
  227. emake "${mymakeopts[@]}" -f Makefile -f - gentoo
  228. echo 'gentoo: $(lib_LTLIBRARIES) $(pkgconfiglib_DATA)' | \
  229. emake "${mymakeopts[@]}" -f Makefile -f - gentoo
  230. fi
  231. }
  232. multilib_src_test() {
  233. multilib_is_native_abi || continue
  234. # Needed for bus-related tests
  235. local -x SANDBOX_WRITE=${SANDBOX_WRITE}
  236. addwrite /sys/fs/kdbus
  237. default
  238. }
  239. multilib_src_install() {
  240. local mymakeopts=(
  241. # automake fails with parallel libtool relinking
  242. # https://bugs.gentoo.org/show_bug.cgi?id=491398
  243. -j1
  244. udevlibexecdir="${MY_UDEVDIR}"
  245. dist_udevhwdb_DATA=
  246. DESTDIR="${D}"
  247. )
  248. if multilib_is_native_abi; then
  249. emake "${mymakeopts[@]}" install
  250. else
  251. mymakeopts+=(
  252. install-libLTLIBRARIES
  253. install-pkgconfiglibDATA
  254. install-includeHEADERS
  255. # safe to call unconditionally, 'installs' empty list
  256. install-pkgincludeHEADERS
  257. )
  258. emake "${mymakeopts[@]}"
  259. fi
  260. # install compat pkg-config files
  261. # Change dbus to >=sys-apps/dbus-1.8.8 if/when this is dropped.
  262. local pcfiles=( src/compat-libs/libsystemd-{daemon,id128,journal,login}.pc )
  263. emake "${mymakeopts[@]}" install-pkgconfiglibDATA \
  264. pkgconfiglib_DATA="${pcfiles[*]}"
  265. }
  266. multilib_src_install_all() {
  267. prune_libtool_files --modules
  268. einstalldocs
  269. if use sysv-utils; then
  270. for app in halt poweroff reboot runlevel shutdown telinit; do
  271. dosym "..${ROOTPREFIX-/usr}/bin/systemctl" /sbin/${app}
  272. done
  273. dosym "..${ROOTPREFIX-/usr}/lib/systemd/systemd" /sbin/init
  274. else
  275. # we just keep sysvinit tools, so no need for the mans
  276. rm "${D}"/usr/share/man/man8/{halt,poweroff,reboot,runlevel,shutdown,telinit}.8 \
  277. || die
  278. rm "${D}"/usr/share/man/man1/init.1 || die
  279. fi
  280. # Disable storing coredumps in journald, bug #433457
  281. mv "${D}"/usr/lib/sysctl.d/50-coredump.conf{,.disabled} || die
  282. # Preserve empty dirs in /etc & /var, bug #437008
  283. keepdir /etc/binfmt.d /etc/modules-load.d /etc/tmpfiles.d \
  284. /etc/systemd/ntp-units.d /etc/systemd/user /var/lib/systemd \
  285. /var/log/journal/remote
  286. # Symlink /etc/sysctl.conf for easy migration.
  287. dosym ../sysctl.conf /etc/sysctl.d/99-sysctl.conf
  288. # If we install these symlinks, there is no way for the sysadmin to remove them
  289. # permanently.
  290. rm "${D}"/etc/systemd/system/multi-user.target.wants/systemd-networkd.service || die
  291. rm "${D}"/etc/systemd/system/multi-user.target.wants/systemd-resolved.service || die
  292. rm -r "${D}"/etc/systemd/system/network-online.target.wants || die
  293. rm -r "${D}"/etc/systemd/system/sockets.target.wants || die
  294. rm -r "${D}"/etc/systemd/system/sysinit.target.wants || die
  295. }
  296. migrate_locale() {
  297. local envd_locale_def="${EROOT%/}/etc/env.d/02locale"
  298. local envd_locale=( "${EROOT%/}"/etc/env.d/??locale )
  299. local locale_conf="${EROOT%/}/etc/locale.conf"
  300. if [[ ! -L ${locale_conf} && ! -e ${locale_conf} ]]; then
  301. # If locale.conf does not exist...
  302. if [[ -e ${envd_locale} ]]; then
  303. # ...either copy env.d/??locale if there's one
  304. ebegin "Moving ${envd_locale} to ${locale_conf}"
  305. mv "${envd_locale}" "${locale_conf}"
  306. eend ${?} || FAIL=1
  307. else
  308. # ...or create a dummy default
  309. ebegin "Creating ${locale_conf}"
  310. cat > "${locale_conf}" <<-EOF
  311. # This file has been created by the sys-apps/systemd ebuild.
  312. # See locale.conf(5) and localectl(1).
  313. # LANG=${LANG}
  314. EOF
  315. eend ${?} || FAIL=1
  316. fi
  317. fi
  318. if [[ ! -L ${envd_locale} ]]; then
  319. # now, if env.d/??locale is not a symlink (to locale.conf)...
  320. if [[ -e ${envd_locale} ]]; then
  321. # ...warn the user that he has duplicate locale settings
  322. ewarn
  323. ewarn "To ensure consistent behavior, you should replace ${envd_locale}"
  324. ewarn "with a symlink to ${locale_conf}. Please migrate your settings"
  325. ewarn "and create the symlink with the following command:"
  326. ewarn "ln -s -n -f ../locale.conf ${envd_locale}"
  327. ewarn
  328. else
  329. # ...or just create the symlink if there's nothing here
  330. ebegin "Creating ${envd_locale_def} -> ../locale.conf symlink"
  331. ln -n -s ../locale.conf "${envd_locale_def}"
  332. eend ${?} || FAIL=1
  333. fi
  334. fi
  335. }
  336. migrate_net_name_slot() {
  337. # If user has disabled 80-net-name-slot.rules using a empty file or a symlink to /dev/null,
  338. # do the same for 80-net-setup-link.rules to keep the old behavior
  339. local net_move=no
  340. local net_name_slot_sym=no
  341. local net_rules_path="${EROOT%/}"/etc/udev/rules.d
  342. local net_name_slot="${net_rules_path}"/80-net-name-slot.rules
  343. local net_setup_link="${net_rules_path}"/80-net-setup-link.rules
  344. if [[ -e ${net_setup_link} ]]; then
  345. net_move=no
  346. elif [[ -f ${net_name_slot} && $(sed -e "/^#/d" -e "/^\W*$/d" ${net_name_slot} | wc -l) == 0 ]]; then
  347. net_move=yes
  348. elif [[ -L ${net_name_slot} && $(readlink ${net_name_slot}) == /dev/null ]]; then
  349. net_move=yes
  350. net_name_slot_sym=yes
  351. fi
  352. if [[ ${net_move} == yes ]]; then
  353. ebegin "Copying ${net_name_slot} to ${net_setup_link}"
  354. if [[ ${net_name_slot_sym} == yes ]]; then
  355. ln -nfs /dev/null "${net_setup_link}"
  356. else
  357. cp "${net_name_slot}" "${net_setup_link}"
  358. fi
  359. eend $? || FAIL=1
  360. fi
  361. }
  362. reenable_unit() {
  363. if systemctl is-enabled --root="${ROOT}" "$1" &> /dev/null; then
  364. ebegin "Re-enabling $1"
  365. systemctl reenable --root="${ROOT}" "$1"
  366. eend $? || FAIL=1
  367. fi
  368. }
  369. pkg_postinst() {
  370. newusergroup() {
  371. enewgroup "$1"
  372. enewuser "$1" -1 -1 -1 "$1"
  373. }
  374. enewgroup input
  375. enewgroup systemd-journal
  376. newusergroup systemd-bus-proxy
  377. newusergroup systemd-journal-gateway
  378. newusergroup systemd-journal-remote
  379. newusergroup systemd-journal-upload
  380. newusergroup systemd-network
  381. newusergroup systemd-resolve
  382. newusergroup systemd-timesync
  383. use http && newusergroup systemd-journal-gateway
  384. systemd_update_catalog
  385. # Keep this here in case the database format changes so it gets updated
  386. # when required. Despite that this file is owned by sys-apps/hwids.
  387. if has_version "sys-apps/hwids[udev]"; then
  388. udevadm hwdb --update --root="${ROOT%/}"
  389. fi
  390. udev_reload || FAIL=1
  391. # Bug 465468, make sure locales are respect, and ensure consistency
  392. # between OpenRC & systemd
  393. migrate_locale
  394. # Migrate 80-net-name-slot.rules -> 80-net-setup-link.rules
  395. migrate_net_name_slot
  396. # Re-enable systemd-networkd for socket activation
  397. reenable_unit systemd-networkd.service
  398. if [[ ${FAIL} ]]; then
  399. eerror "One of the postinst commands failed. Please check the postinst output"
  400. eerror "for errors. You may need to clean up your system and/or try installing"
  401. eerror "systemd again."
  402. eerror
  403. fi
  404. if [[ $(readlink "${ROOT}"/etc/resolv.conf) == */run/systemd/network/resolv.conf ]]; then
  405. ewarn "resolv.conf is now generated by systemd-resolved. To use it, enable"
  406. ewarn "systemd-resolved.service, and create a symlink from /etc/resolv.conf"
  407. ewarn "to /run/systemd/resolve/resolv.conf"
  408. ewarn
  409. fi
  410. }
  411. pkg_prerm() {
  412. # If removing systemd completely, remove the catalog database.
  413. if [[ ! ${REPLACED_BY_VERSION} ]]; then
  414. rm -f -v "${EROOT}"/var/lib/systemd/catalog/database
  415. fi
  416. }