systemd-233-r1.ebuild 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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. "${FILESDIR}/233-0001-Avoid-strict-DM-interface-version-dependencies-5519.patch"
  132. )
  133. if ! use vanilla; then
  134. PATCHES+=(
  135. "${FILESDIR}/218-Dont-enable-audit-by-default.patch"
  136. "${FILESDIR}/228-noclean-tmp.patch"
  137. "${FILESDIR}/233-systemd-user-pam.patch"
  138. )
  139. fi
  140. [[ -d "${WORKDIR}"/patches ]] && PATCHES+=( "${WORKDIR}"/patches )
  141. default
  142. eautoreconf
  143. }
  144. src_configure() {
  145. # Keep using the one where the rules were installed.
  146. MY_UDEVDIR=$(get_udevdir)
  147. # Fix systems broken by bug #509454.
  148. [[ ${MY_UDEVDIR} ]] || MY_UDEVDIR=/lib/udev
  149. # Prevent conflicts with i686 cross toolchain, bug 559726
  150. tc-export AR CC NM OBJCOPY RANLIB
  151. use doc && python_setup
  152. multilib-minimal_src_configure
  153. }
  154. multilib_src_configure() {
  155. local myeconfargs=(
  156. # disable -flto since it is an optimization flag
  157. # and makes distcc less effective
  158. cc_cv_CFLAGS__flto=no
  159. # disable -fuse-ld=gold since Gentoo supports explicit linker
  160. # choice and forcing gold is undesired, #539998
  161. # ld.gold may collide with user's LDFLAGS, #545168
  162. # ld.gold breaks sparc, #573874
  163. cc_cv_LDFLAGS__Wl__fuse_ld_gold=no
  164. # Workaround for gcc-4.7, bug 554454.
  165. cc_cv_CFLAGS__Werror_shadow=no
  166. # Workaround for bug 516346
  167. --enable-dependency-tracking
  168. --disable-maintainer-mode
  169. --localstatedir=/var
  170. --with-pamlibdir=$(getpam_mod_dir)
  171. # avoid bash-completion dep
  172. --with-bashcompletiondir="$(get_bashcompdir)"
  173. # make sure we get /bin:/sbin in $PATH
  174. --enable-split-usr
  175. # For testing.
  176. --with-rootprefix="${ROOTPREFIX-/usr}"
  177. --with-rootlibdir="${ROOTPREFIX-/usr}/$(get_libdir)"
  178. # disable sysv compatibility
  179. --with-sysvinit-path=
  180. --with-sysvrcnd-path=
  181. # no deps
  182. --enable-efi
  183. --enable-ima
  184. # Optional components/dependencies
  185. $(multilib_native_use_enable acl)
  186. $(multilib_native_use_enable apparmor)
  187. $(multilib_native_use_enable audit)
  188. $(multilib_native_use_enable cryptsetup libcryptsetup)
  189. $(multilib_native_use_enable curl libcurl)
  190. $(multilib_native_use_enable elfutils)
  191. $(use_enable gcrypt)
  192. $(multilib_native_use_enable gnuefi)
  193. --with-efi-libdir="/usr/$(get_libdir)"
  194. $(multilib_native_use_enable http microhttpd)
  195. $(usex http $(multilib_native_use_enable ssl gnutls) --disable-gnutls)
  196. $(multilib_native_use_enable idn libidn)
  197. $(multilib_native_use_enable importd)
  198. $(multilib_native_use_enable importd bzip2)
  199. $(multilib_native_use_enable importd zlib)
  200. $(multilib_native_use_enable kmod)
  201. $(use_enable lz4)
  202. $(use_enable lzma xz)
  203. $(multilib_native_use_enable nat libiptc)
  204. $(use_enable pam)
  205. $(multilib_native_use_enable policykit polkit)
  206. $(multilib_native_use_enable qrcode qrencode)
  207. $(multilib_native_use_enable seccomp)
  208. $(multilib_native_use_enable selinux)
  209. $(multilib_native_use_enable test tests)
  210. $(multilib_native_use_enable test dbus)
  211. $(multilib_native_use_enable xkb xkbcommon)
  212. $(multilib_native_use_with doc python)
  213. # hardcode a few paths to spare some deps
  214. KILL=/bin/kill
  215. QUOTAON=/usr/sbin/quotaon
  216. QUOTACHECK=/usr/sbin/quotacheck
  217. # TODO: we may need to restrict this to gcc
  218. EFI_CC="$(tc-getCC)"
  219. # dbus paths
  220. --with-dbuspolicydir="${EPREFIX}/etc/dbus-1/system.d"
  221. --with-dbussessionservicedir="${EPREFIX}/usr/share/dbus-1/services"
  222. --with-dbussystemservicedir="${EPREFIX}/usr/share/dbus-1/system-services"
  223. --with-ntp-servers="0.gentoo.pool.ntp.org 1.gentoo.pool.ntp.org 2.gentoo.pool.ntp.org 3.gentoo.pool.ntp.org"
  224. # Breaks screen, tmux, etc.
  225. --without-kill-user-processes
  226. )
  227. # Work around bug 463846.
  228. tc-export CC
  229. ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
  230. }
  231. multilib_src_compile() {
  232. local mymakeopts=(
  233. udevlibexecdir="${MY_UDEVDIR}"
  234. )
  235. if multilib_is_native_abi; then
  236. emake "${mymakeopts[@]}"
  237. else
  238. emake built-sources
  239. local targets=(
  240. '$(rootlib_LTLIBRARIES)'
  241. '$(lib_LTLIBRARIES)'
  242. '$(pamlib_LTLIBRARIES)'
  243. '$(pkgconfiglib_DATA)'
  244. )
  245. echo "gentoo: ${targets[*]}" | emake "${mymakeopts[@]}" -f Makefile -f - gentoo
  246. fi
  247. }
  248. multilib_src_test() {
  249. multilib_is_native_abi || return 0
  250. default
  251. }
  252. multilib_src_install() {
  253. local mymakeopts=(
  254. # automake fails with parallel libtool relinking
  255. # https://bugs.gentoo.org/show_bug.cgi?id=491398
  256. -j1
  257. udevlibexecdir="${MY_UDEVDIR}"
  258. dist_udevhwdb_DATA=
  259. DESTDIR="${D}"
  260. )
  261. if multilib_is_native_abi; then
  262. emake "${mymakeopts[@]}" install
  263. else
  264. mymakeopts+=(
  265. install-rootlibLTLIBRARIES
  266. install-libLTLIBRARIES
  267. install-pamlibLTLIBRARIES
  268. install-pkgconfiglibDATA
  269. install-includeHEADERS
  270. install-pkgincludeHEADERS
  271. )
  272. emake "${mymakeopts[@]}"
  273. fi
  274. }
  275. multilib_src_install_all() {
  276. prune_libtool_files --modules
  277. einstalldocs
  278. dodoc "${FILESDIR}"/nsswitch.conf
  279. if [[ ${PV} != 9999 ]]; then
  280. use doc || doman "${WORKDIR}"/man/systemd.{directives,index}.7
  281. fi
  282. if use sysv-utils; then
  283. for app in halt poweroff reboot runlevel shutdown telinit; do
  284. dosym "..${ROOTPREFIX-/usr}/bin/systemctl" /sbin/${app}
  285. done
  286. dosym "..${ROOTPREFIX-/usr}/lib/systemd/systemd" /sbin/init
  287. else
  288. # we just keep sysvinit tools, so no need for the mans
  289. rm "${D}"/usr/share/man/man8/{halt,poweroff,reboot,runlevel,shutdown,telinit}.8 \
  290. || die
  291. rm "${D}"/usr/share/man/man1/init.1 || die
  292. fi
  293. # Preserve empty dirs in /etc & /var, bug #437008
  294. keepdir /etc/binfmt.d /etc/modules-load.d /etc/tmpfiles.d \
  295. /etc/systemd/ntp-units.d /etc/systemd/user /var/lib/systemd \
  296. /var/log/journal/remote
  297. # Symlink /etc/sysctl.conf for easy migration.
  298. dosym ../sysctl.conf /etc/sysctl.d/99-sysctl.conf
  299. # If we install these symlinks, there is no way for the sysadmin to remove them
  300. # permanently.
  301. rm "${D}"/etc/systemd/system/multi-user.target.wants/systemd-networkd.service || die
  302. rm -f "${D}"/etc/systemd/system/multi-user.target.wants/systemd-resolved.service || die
  303. rm -r "${D}"/etc/systemd/system/network-online.target.wants || die
  304. rm -r "${D}"/etc/systemd/system/sockets.target.wants || die
  305. rm -r "${D}"/etc/systemd/system/sysinit.target.wants || die
  306. }
  307. migrate_locale() {
  308. local envd_locale_def="${EROOT%/}/etc/env.d/02locale"
  309. local envd_locale=( "${EROOT%/}"/etc/env.d/??locale )
  310. local locale_conf="${EROOT%/}/etc/locale.conf"
  311. if [[ ! -L ${locale_conf} && ! -e ${locale_conf} ]]; then
  312. # If locale.conf does not exist...
  313. if [[ -e ${envd_locale} ]]; then
  314. # ...either copy env.d/??locale if there's one
  315. ebegin "Moving ${envd_locale} to ${locale_conf}"
  316. mv "${envd_locale}" "${locale_conf}"
  317. eend ${?} || FAIL=1
  318. else
  319. # ...or create a dummy default
  320. ebegin "Creating ${locale_conf}"
  321. cat > "${locale_conf}" <<-EOF
  322. # This file has been created by the sys-apps/systemd ebuild.
  323. # See locale.conf(5) and localectl(1).
  324. # LANG=${LANG}
  325. EOF
  326. eend ${?} || FAIL=1
  327. fi
  328. fi
  329. if [[ ! -L ${envd_locale} ]]; then
  330. # now, if env.d/??locale is not a symlink (to locale.conf)...
  331. if [[ -e ${envd_locale} ]]; then
  332. # ...warn the user that he has duplicate locale settings
  333. ewarn
  334. ewarn "To ensure consistent behavior, you should replace ${envd_locale}"
  335. ewarn "with a symlink to ${locale_conf}. Please migrate your settings"
  336. ewarn "and create the symlink with the following command:"
  337. ewarn "ln -s -n -f ../locale.conf ${envd_locale}"
  338. ewarn
  339. else
  340. # ...or just create the symlink if there's nothing here
  341. ebegin "Creating ${envd_locale_def} -> ../locale.conf symlink"
  342. ln -n -s ../locale.conf "${envd_locale_def}"
  343. eend ${?} || FAIL=1
  344. fi
  345. fi
  346. }
  347. pkg_postinst() {
  348. newusergroup() {
  349. enewgroup "$1"
  350. enewuser "$1" -1 -1 -1 "$1"
  351. }
  352. enewgroup input
  353. enewgroup systemd-journal
  354. newusergroup systemd-bus-proxy
  355. newusergroup systemd-coredump
  356. newusergroup systemd-journal-gateway
  357. newusergroup systemd-journal-remote
  358. newusergroup systemd-journal-upload
  359. newusergroup systemd-network
  360. newusergroup systemd-resolve
  361. newusergroup systemd-timesync
  362. systemd_update_catalog
  363. # Keep this here in case the database format changes so it gets updated
  364. # when required. Despite that this file is owned by sys-apps/hwids.
  365. if has_version "sys-apps/hwids[udev]"; then
  366. udevadm hwdb --update --root="${ROOT%/}"
  367. fi
  368. udev_reload || FAIL=1
  369. # Bug 465468, make sure locales are respect, and ensure consistency
  370. # between OpenRC & systemd
  371. migrate_locale
  372. if [[ ${FAIL} ]]; then
  373. eerror "One of the postinst commands failed. Please check the postinst output"
  374. eerror "for errors. You may need to clean up your system and/or try installing"
  375. eerror "systemd again."
  376. eerror
  377. fi
  378. if [[ $(readlink "${ROOT}"etc/resolv.conf) == */run/systemd/* ]]; then
  379. ewarn "You should replace the resolv.conf symlink:"
  380. ewarn "ln -snf ${ROOTPREFIX-/usr}/lib/systemd/resolv.conf ${ROOT}etc/resolv.conf"
  381. fi
  382. }
  383. pkg_prerm() {
  384. # If removing systemd completely, remove the catalog database.
  385. if [[ ! ${REPLACED_BY_VERSION} ]]; then
  386. rm -f -v "${EROOT}"/var/lib/systemd/catalog/database
  387. fi
  388. }