From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-893594-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 25E9F13832E
	for <garchives@archives.gentoo.org>; Mon, 25 Jul 2016 20:54:55 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 5D9FDE0AD2;
	Mon, 25 Jul 2016 20:54:54 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id E647BE0AD2
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Jul 2016 20:54:53 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id A4D72340C54
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Jul 2016 20:54:52 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 4225EE6B
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Jul 2016 20:54:47 +0000 (UTC)
From: "William Hubbs" <williamh@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" <williamh@gentoo.org>
Message-ID: <1469479038.3092e310acd376fc626cc051549e02bcd7697aed.williamh@OpenRC>
Subject: [gentoo-commits] proj/openrc:master commit in: sh/
X-VCS-Repository: proj/openrc
X-VCS-Files: sh/tmpfiles.sh.in
X-VCS-Directories: sh/
X-VCS-Committer: williamh
X-VCS-Committer-Name: William Hubbs
X-VCS-Revision: 3092e310acd376fc626cc051549e02bcd7697aed
X-VCS-Branch: master
Date: Mon, 25 Jul 2016 20:54:47 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 8a179009-e0fb-476f-af77-f9aea3fa8576
X-Archives-Hash: 13e04dc08351becf0dd6cf186cbfaa73

commit:     3092e310acd376fc626cc051549e02bcd7697aed
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 12 19:10:42 2016 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Mon Jul 25 20:37:18 2016 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=3092e310

tmpfiles: Accept filenames as command line arguments

This brings us closer to being able to use tmpfiles.sh as a full
replacement for systemd-tmpfiles.

This closes #83.

 sh/tmpfiles.sh.in | 61 ++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 36 insertions(+), 25 deletions(-)

diff --git a/sh/tmpfiles.sh.in b/sh/tmpfiles.sh.in
index 95b8b93..f7ee11b 100644
--- a/sh/tmpfiles.sh.in
+++ b/sh/tmpfiles.sh.in
@@ -264,6 +264,7 @@ _Z() {
 BOOT=0 CREATE=0 REMOVE=0 CLEAN=0 VERBOSE=0 DRYRUN=0 error=0 LINENO=0
 EXCLUDE=
 PREFIX=
+FILES=
 
 while [ $# -gt 0 ]; do
 	case $1 in
@@ -276,6 +277,7 @@ while [ $# -gt 0 ]; do
 		--exclude-prefix=*) EXCLUDE="${EXCLUDE}${1##--exclude-prefix=} " ;;
 		--prefix=*) PREFIX="${PREFIX}${1##--prefix=} " ;;
 		-*) invalid_option "$1" ;;
+		*) FILES="${FILES} $1"
 	esac
 	shift
 done
@@ -290,40 +292,49 @@ if [ "$CREATE$REMOVE" = '00' ]; then
 	exit 1
 fi
 
-FILE=
-fragments=
 # XXX: The harcoding of /usr/lib/ is an explicit choice by upstream
-tmpfiles_dirs='/usr/lib/tmpfiles.d/ /run/tmpfiles.d/ /etc/tmpfiles.d/'
+tmpfiles_dirs='/usr/lib/tmpfiles.d /run/tmpfiles.d /etc/tmpfiles.d'
 tmpfiles_basenames=''
+
+if [ -z "${FILES}" ]; then
+	# Build a list of sorted unique basenames
+	# directories declared later in the tmpfiles_d array will override earlier
+	# directories, on a per file basename basis.
+	# `/etc/tmpfiles.d/foo.conf' supersedes `/usr/lib/tmpfiles.d/foo.conf'.
+	# `/run/tmpfiles/foo.conf' will always be read after `/etc/tmpfiles.d/bar.conf'
+	for d in ${tmpfiles_dirs} ; do
+		[ -d $d ] && for f in ${d}/*.conf ; do
+			case "${f##*/}" in
+				systemd.conf|systemd-*.conf) continue;;
+			esac
+			[ -f $f ] && tmpfiles_basenames="${tmpfiles_basenames}\n${f##*/}"
+		done # for f in ${d}
+	done # for d in ${tmpfiles_dirs}
+	FILES="$(printf "${tmpfiles_basenames}\n" | sort -u )"
+fi
+
 tmpfiles_d=''
-# Build a list of sorted unique basenames
-# directories declared later in the tmpfiles_d array will override earlier
-# directories, on a per file basename basis.
-# `/etc/tmpfiles.d/foo.conf' supersedes `/usr/lib/tmpfiles.d/foo.conf'.
-# `/run/tmpfiles/foo.conf' will always be read after `/etc/tmpfiles.d/bar.conf'
-for d in ${tmpfiles_dirs} ; do
-	[ -d $d ] && for f in ${d}/*.conf ; do
-		case "${f##*/}" in
-			systemd.conf|systemd-*.conf) continue;;
-		esac
-		[ -f $f ] && tmpfiles_basenames="${tmpfiles_basenames}\n${f##*/}"
-	done # for f in ${d}
-done # for d in ${tmpfiles_dirs}
-tmpfiles_basenames="$(printf "${tmpfiles_basenames}\n" | sort -u )"
-
-for b in $tmpfiles_basenames ; do
-	real_f=''
-	for d in $tmpfiles_dirs ; do
-		f=${d}/${b}
-		[ -f "${f}" ] && real_f=$f
-	done
-	[ -f "${real_f}" ] && tmpfiles_d="${tmpfiles_d} ${real_f}"
+
+for b in ${FILES} ; do
+	if [ "${b##*/}" != "${b}" ]; then
+		# The user specified a path on the command line
+		# Just pass it through unaltered
+		tmpfiles_d="${tmpfiles_d} ${b}"
+	else
+		real_f=''
+		for d in $tmpfiles_dirs ; do
+			f=${d}/${b}
+			[ -f "${f}" ] && real_f=$f
+		done
+		[ -f "${real_f}" ] && tmpfiles_d="${tmpfiles_d} ${real_f}"
+	fi
 done
 
 error=0
 
 # loop through the gathered fragments, sorted globally by filename.
 # `/run/tmpfiles/foo.conf' will always be read after `/etc/tmpfiles.d/bar.conf'
+FILE=
 for FILE in $tmpfiles_d ; do
 	LINENUM=0