systemd-tmpfiles: upgraded package to upstream

Upgraded sys-apps/systemd-tmpfiles to version 246 on amd64

BUG=chromium:884826
TEST=emerge-${BOARD} systemd-tmpfiles

Change-Id: If4a594a5e8ba76681c046790030316ffe3c3f1f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/2538075
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Allen Webb <allenwebb@google.com>
diff --git a/metadata/md5-cache/sys-apps/systemd-tmpfiles-246 b/metadata/md5-cache/sys-apps/systemd-tmpfiles-246
new file mode 100644
index 0000000..1dbd6d3
--- /dev/null
+++ b/metadata/md5-cache/sys-apps/systemd-tmpfiles-246
@@ -0,0 +1,15 @@
+BDEPEND=app-text/docbook-xml-dtd:4.2 app-text/docbook-xml-dtd:4.5 app-text/docbook-xsl-stylesheets dev-libs/libxslt:0 >=dev-util/meson-0.46 >=dev-util/intltool-0.50 >=sys-apps/coreutils-8.16 sys-devel/m4 virtual/pkgconfig test? ( || ( dev-lang/python:3.9 dev-lang/python:3.8 dev-lang/python:3.7 ) ) >=dev-util/meson-0.48.2 >=dev-util/ninja-1.7.2
+DEFINED_PHASES=compile configure install postinst prepare setup test
+DEPEND=sys-apps/acl:0= >=sys-apps/util-linux-2.30:0= >=sys-kernel/linux-headers-3.11 sys-libs/libcap:0=
+DESCRIPTION=Creates, deletes and cleans up volatile and temporary files and directories
+EAPI=7
+HOMEPAGE=https://www.freedesktop.org/wiki/Software/systemd
+IUSE=test
+KEYWORDS=*
+LICENSE=BSD-2 GPL-2 LGPL-2.1 MIT public-domain
+RDEPEND=sys-apps/acl:0= >=sys-apps/util-linux-2.30:0= >=sys-kernel/linux-headers-3.11 sys-libs/libcap:0= !sys-apps/opentmpfiles !sys-apps/systemd
+RESTRICT=!test? ( test )
+SLOT=0
+SRC_URI=https://github.com/systemd/systemd/archive/v246.tar.gz -> systemd-246.tar.gz elibc_musl? ( https://dev.gentoo.org/~gyakovlev/distfiles/systemd-tmpfiles-246-musl.tar.xz )
+_eclasses_=meson	b5ee7a05833ab91225acf30ffdeed006	multilib	2477ebe553d3e4d2c606191fe6c33602	multiprocessing	e32940a7b2a9992ad217eccddb84d548	ninja-utils	132cbb376048d079b5a012f5467c4e7f	python-any-r1	54a3178500786b0a7ede4a23b7f2a6ad	python-utils-r1	157a6a7a3e99c7dbdf81acc9dd4f57cd	toolchain-funcs	605c126bed8d87e4378d5ff1645330cb
+_md5_=4a6fbc617f6832b2cac653b1f0edc260
diff --git a/sys-apps/systemd-tmpfiles/Manifest b/sys-apps/systemd-tmpfiles/Manifest
new file mode 100644
index 0000000..ff1d4d1
--- /dev/null
+++ b/sys-apps/systemd-tmpfiles/Manifest
@@ -0,0 +1,2 @@
+DIST systemd-246.tar.gz 9534036 BLAKE2B 71b72abcd4d066d35d45d9835d41bec8faa9a7eddc80b48fe7073223f07d32f78a8442c52dc0800940f9750d9c5502123a633738981d797cf610d85df2035bf0 SHA512 7103f7da53f7ced3b5543c238f23bd11c82af8e37166c1720a90576b6b431b4329320c78726166c65a9f5e101dd465c0a86dd13c586c4e55e608a6273d8f324f
+DIST systemd-tmpfiles-246-musl.tar.xz 25860 BLAKE2B 87fc4ca37abec9c1a0cee48bf78c575bd53e16a50d427eff338159dc6d5474ffd328af533ccf90a0e1e160a16baa7378070f418f2be0d7f77e00907a5d07d30e SHA512 4a93d9f0cb2df2dd0a2f91820615dd3a95d19583f45dc0589e37ceaedfc2040112310a6e3fc525e28e222e96a91498af2fe8541b5bf86a635c0f52dd1a84deb7
diff --git a/sys-apps/systemd-tmpfiles/files/stmpfiles-dev.initd b/sys-apps/systemd-tmpfiles/files/stmpfiles-dev.initd
new file mode 100644
index 0000000..0952ef1
--- /dev/null
+++ b/sys-apps/systemd-tmpfiles/files/stmpfiles-dev.initd
@@ -0,0 +1,20 @@
+#!/sbin/openrc-run
+# Copyright 1999-2020 Gentoo Authors
+# Released under the 2-clause BSD license.
+
+description="Set up tmpfiles.d entries for /dev"
+
+depend()
+{
+	provide stmpfiles-dev stmpfiles.dev tmpfiles-dev tmpfiles.dev
+	use dev-mount
+	before dev
+	keyword -prefix -vserver
+}
+
+start()
+{
+	ebegin "Setting up tmpfiles.d entries for /dev"
+	/bin/systemd-tmpfiles --prefix=/dev --create --boot ${stmpfiles_opts}
+	eend $?
+}
diff --git a/sys-apps/systemd-tmpfiles/files/stmpfiles-setup.initd b/sys-apps/systemd-tmpfiles/files/stmpfiles-setup.initd
new file mode 100644
index 0000000..a55163d
--- /dev/null
+++ b/sys-apps/systemd-tmpfiles/files/stmpfiles-setup.initd
@@ -0,0 +1,19 @@
+#!/sbin/openrc-run
+# Copyright 1999-2020 Gentoo Authors
+# Released under the 2-clause BSD license.
+
+description="Set up tmpfiles.d entries"
+
+depend()
+{
+	provide stmpfiles-setup stmpfiles.setup tmpfiles-setup tmpfiles.setup
+	need localmount
+}
+
+start()
+{
+	ebegin "Setting up tmpfiles.d entries"
+	/bin/systemd-tmpfiles --exclude-prefix=/dev --create --remove --boot \
+		${stmpfiles_opts}
+	eend $?
+}
diff --git a/sys-apps/systemd-tmpfiles/files/stmpfiles.confd b/sys-apps/systemd-tmpfiles/files/stmpfiles.confd
new file mode 100644
index 0000000..2ec4b5f
--- /dev/null
+++ b/sys-apps/systemd-tmpfiles/files/stmpfiles.confd
@@ -0,0 +1,2 @@
+# Extra options to pass to stmpfiles
+#stmpfiles_opts=""
diff --git a/sys-apps/systemd-tmpfiles/metadata.xml b/sys-apps/systemd-tmpfiles/metadata.xml
new file mode 100644
index 0000000..efcd58f
--- /dev/null
+++ b/sys-apps/systemd-tmpfiles/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+	<maintainer type="person">
+		<email>gyakovlev@gentoo.org</email>
+		<name>Georgy Yakovlev</name>
+	</maintainer>
+</pkgmetadata>
diff --git a/sys-apps/systemd-tmpfiles/systemd-tmpfiles-246.ebuild b/sys-apps/systemd-tmpfiles/systemd-tmpfiles-246.ebuild
new file mode 100644
index 0000000..6898ebf
--- /dev/null
+++ b/sys-apps/systemd-tmpfiles/systemd-tmpfiles-246.ebuild
@@ -0,0 +1,209 @@
+# Copyright 2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+MINKV="3.11"
+PYTHON_COMPAT=( python3_{7..9} )
+inherit meson python-any-r1
+
+DESCRIPTION="Creates, deletes and cleans up volatile and temporary files and directories"
+HOMEPAGE="https://www.freedesktop.org/wiki/Software/systemd"
+SRC_URI="https://github.com/systemd/systemd/archive/v${PV}.tar.gz -> systemd-${PV}.tar.gz
+	elibc_musl? ( https://dev.gentoo.org/~gyakovlev/distfiles/${P}-musl.tar.xz )"
+
+LICENSE="BSD-2 GPL-2 LGPL-2.1 MIT public-domain"
+SLOT="0"
+KEYWORDS="*"
+IUSE="test"
+RESTRICT="!test? ( test )"
+
+DEPEND="
+	sys-apps/acl:0=
+	>=sys-apps/util-linux-2.30:0=
+	>=sys-kernel/linux-headers-${MINKV}
+	sys-libs/libcap:0=
+"
+RDEPEND="${DEPEND}
+	!sys-apps/opentmpfiles
+	!sys-apps/systemd
+"
+
+BDEPEND="
+	app-text/docbook-xml-dtd:4.2
+	app-text/docbook-xml-dtd:4.5
+	app-text/docbook-xsl-stylesheets
+	dev-libs/libxslt:0
+	>=dev-util/meson-0.46
+	>=dev-util/intltool-0.50
+	>=sys-apps/coreutils-8.16
+	sys-devel/m4
+	virtual/pkgconfig
+	test? ( ${PYTHON_DEPS} )
+"
+
+S="${WORKDIR}/systemd-${PV}"
+
+pkg_setup() {
+	use test && python-any-r1_pkg_setup
+}
+
+src_prepare() {
+	# musl patchset from:
+	# http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-core/systemd/systemd
+	use elibc_musl && eapply "${WORKDIR}/${P}-musl"
+	default
+}
+
+src_configure() {
+	# disable everything until configure says "enabled features: ACL, tmpfiles"
+	local systemd_disable_options=(
+		adm-group
+		analyze
+		apparmor
+		audit
+		backlight
+		binfmt
+		blkid
+		bzip2
+		coredump
+		dbus
+		efi
+		elfutils
+		environment-d
+		fdisk
+		gcrypt
+		glib
+		gshadow
+		gnutls
+		hibernate
+		hostnamed
+		hwdb
+		idn
+		ima
+		initrd
+		firstboot
+		kernel-install
+		kmod
+		ldconfig
+		libcryptsetup
+		libcurl
+		libfido2
+		libidn
+		libidn2
+		libiptc
+		link-networkd-shared
+		link-systemctl-shared
+		link-timesyncd-shared
+		link-udev-shared
+		localed
+		logind
+		lz4
+		machined
+		microhttpd
+		networkd
+		nss-myhostname
+		nss-resolve
+		nss-systemd
+		openssl
+		p11kit
+		pam
+		pcre2
+		polkit
+		portabled
+		pstore
+		pwquality
+		randomseed
+		resolve
+		rfkill
+		seccomp
+		selinux
+		smack
+		sysusers
+		timedated
+		timesyncd
+		tpm
+		qrencode
+		quotacheck
+		userdb
+		utmp
+		vconsole
+		wheel-group
+		xdg-autostart
+		xkbcommon
+		xz
+		zlib
+		zstd
+	)
+
+	# prepend -D and append =false, e.g. zstd becomes -Dzstd=false
+	systemd_disable_options=( ${systemd_disable_options[@]/#/-D} )
+	systemd_disable_options=( ${systemd_disable_options[@]/%/=false} )
+
+	local emesonargs=(
+		-Dacl=true
+		-Dtmpfiles=true
+		-Dstandalone-binaries=true # this and below option does the magic
+		-Dstatic-libsystemd=true
+		-Dsysvinit-path=''
+		${systemd_disable_options[@]}
+	)
+	meson_src_configure
+}
+
+src_compile() {
+	# tmpfiles and sysusers can be built as standalone, link systemd-shared in statically.
+	# https://github.com/systemd/systemd/pull/16061 original implementation
+	# we just need to pass -Dstandalone-binaries=true and
+	# use <name>.standalone target below.
+	# check meson.build for if have_standalone_binaries condition per target.
+	local mytargets=(
+		systemd-tmpfiles.standalone
+		man/tmpfiles.d.5
+		man/systemd-tmpfiles.8
+	)
+	meson_src_compile "${mytargets[@]}"
+}
+
+src_install() {
+	# lean and mean installation, single binary and man-pages
+	pushd "${BUILD_DIR}" > /dev/null || die
+	into /
+	newbin systemd-tmpfiles.standalone systemd-tmpfiles
+
+	doman man/{systemd-tmpfiles.8,tmpfiles.d.5}
+
+	popd > /dev/null || die
+
+	# service files adapter from opentmpfiles
+	newinitd "${FILESDIR}"/stmpfiles-dev.initd stmpfiles-dev
+	newinitd "${FILESDIR}"/stmpfiles-setup.initd stmpfiles-setup
+
+	# same content, but install as different file
+	newconfd "${FILESDIR}"/stmpfiles.confd stmpfiles-dev
+	newconfd "${FILESDIR}"/stmpfiles.confd stmpfiles-setup
+}
+
+src_test() {
+	# 'meson test' will compile full systemd, but we can still outsmart it
+	python_fix_shebang src/test/test-systemd-tmpfiles.py
+	"${EPYTHON}" src/test/test-systemd-tmpfiles.py \
+		"${BUILD_DIR}"/systemd-tmpfiles.standalone || die "${FUNCNAME} failed"
+}
+
+# adapted from opentmpfiles ebuild
+add_service() {
+	local initd=$1
+	local runlevel=$2
+
+	elog "Auto-adding '${initd}' service to your ${runlevel} runlevel"
+	mkdir -p "${EROOT}/etc/runlevels/${runlevel}"
+	ln -snf "${EROOT}/etc/init.d/${initd}" "${EROOT}/etc/runlevels/${runlevel}/${initd}"
+}
+
+pkg_postinst() {
+	if [[ -z $REPLACING_VERSIONS ]]; then
+		add_service stmpfiles-dev sysinit
+		add_service stmpfiles-setup boot
+	fi
+}