Advertisement
Guest User

Untitled

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