systemd-9999.ebuild 13 KB

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