From 671911762d1bcd90c10d8ac0eb30fe10be4a65f6 Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Sat, 12 Mar 2016 13:13:56 -0500 Subject: tmpfiles: Process command line before gathering config files This is part of #83. --- sh/tmpfiles.sh.in | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'sh') diff --git a/sh/tmpfiles.sh.in b/sh/tmpfiles.sh.in index f711b1da..95b8b932 100644 --- a/sh/tmpfiles.sh.in +++ b/sh/tmpfiles.sh.in @@ -264,6 +264,32 @@ _Z() { BOOT=0 CREATE=0 REMOVE=0 CLEAN=0 VERBOSE=0 DRYRUN=0 error=0 LINENO=0 EXCLUDE= PREFIX= + +while [ $# -gt 0 ]; do + case $1 in + --boot) BOOT=1 ;; + --create) CREATE=1 ;; + --remove) REMOVE=1 ;; + --clean) CLEAN=1 ;; # TODO: Not implemented + --verbose) VERBOSE=1 ;; + --dryrun|--dry-run) DRYRUN=1 ;; + --exclude-prefix=*) EXCLUDE="${EXCLUDE}${1##--exclude-prefix=} " ;; + --prefix=*) PREFIX="${PREFIX}${1##--prefix=} " ;; + -*) invalid_option "$1" ;; + esac + shift +done + +if [ $(( CLEAN )) -eq 1 ] ; then + printf '%s clean mode is not implemented\n' "${0##*/}" + exit 1 +fi + +if [ "$CREATE$REMOVE" = '00' ]; then + printf 'usage: %s [--exclude-prefix=path] [--prefix=path] [--boot] [--create] [--remove] [--clean] [--verbose] [--dry-run]\n' "${0##*/}" + exit 1 +fi + FILE= fragments= # XXX: The harcoding of /usr/lib/ is an explicit choice by upstream @@ -294,31 +320,6 @@ for b in $tmpfiles_basenames ; do [ -f "${real_f}" ] && tmpfiles_d="${tmpfiles_d} ${real_f}" done -while [ $# -gt 0 ]; do - case $1 in - --boot) BOOT=1 ;; - --create) CREATE=1 ;; - --remove) REMOVE=1 ;; - --clean) CLEAN=1 ;; # TODO: Not implemented - --verbose) VERBOSE=1 ;; - --dryrun|--dry-run) DRYRUN=1 ;; - --exclude-prefix=*) EXCLUDE="${EXCLUDE}${1##--exclude-prefix=} " ;; - --prefix=*) PREFIX="${PREFIX}${1##--prefix=} " ;; - -*) invalid_option "$1" ;; - esac - shift -done - -if [ $(( CLEAN )) -eq 1 ] ; then - printf '%s clean mode is not implemented\n' "${0##*/}" - exit 1 -fi - -if [ "$CREATE$REMOVE" = '00' ]; then - printf 'usage: %s [--exclude-prefix=path] [--prefix=path] [--boot] [--create] [--remove] [--clean] [--verbose] [--dry-run]\n' "${0##*/}" - exit 1 -fi - error=0 # loop through the gathered fragments, sorted globally by filename. -- cgit v1.2.3