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