From 5daf8dbb8956d09def750415e129ac6d4032fd34 Mon Sep 17 00:00:00 2001 From: Thomas Veerman Date: Mon, 7 May 2012 14:22:27 +0000 Subject: [PATCH] mtree.sh: reverse last two parameters This way we can treat DESTDIR like a special case just as the build system does (i.e., if not set, assume DESTDIR="/"). --- etc/Makefile | 2 +- etc/mtree.sh | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/etc/Makefile b/etc/Makefile index 8fddd0b74..ee989063d 100644 --- a/etc/Makefile +++ b/etc/Makefile @@ -37,7 +37,7 @@ install: installpw # installpw needed to bootstrap pw db mkdir -p $(ETC) $(USRLIB) mkdir -p $(ETC)/devmand/scripts @echo "Making hierarchy.." - sh mtree.sh mtree/minix.tree ${TOOL_AWK} ${TOOL_STAT} ${DESTDIR} ${MKUNPRIVED} + sh mtree.sh mtree/minix.tree ${TOOL_AWK} ${TOOL_STAT} ${MKUNPRIVED} ${DESTDIR}; # DESTDIR must be last; special case! @for f in $(FILES1); do if [ -f $(ETC)/$$f ]; then :; else cp $$f $(ETC)/$$f; chmod 755 $(ETC)/$$f; fi; done @for f in $(USRFILES); do cp usr/$$f $(USR)/$$f; chmod 644 $(USR)/$$f; done @for f in $(FILES3); do if [ -f $(USRETC)/$$f ]; then :; else cp usr/$$f $(USRETC); chmod 755 $(USRETC)/$$f; fi; done diff --git a/etc/mtree.sh b/etc/mtree.sh index 907b413a6..96e794ac9 100755 --- a/etc/mtree.sh +++ b/etc/mtree.sh @@ -1,15 +1,20 @@ #!/bin/sh set -e -if [ $# -ne 5 ] -then echo "Usage: $0 mtreefile TOOL_AWK TOOL_STAT DEST_DIR UNPRIV" +if [ $# -ne 4 -a $# -ne 5 ] +then echo "Usage: $0 mtreefile TOOL_AWK TOOL_STAT UNPRIV DESTDIR" exit 1 fi AWK=$2 STAT=$3 -DESTDIR=$4 -UNPRIV=$5 +UNPRIV=$4 + +if [ $# -eq 5 ] +then DESTDIR=$5 +else DESTDIR="/" # If not set, default to root (i.e., normal case) +fi + cat "$1" | while read line do NF="`echo $line | ${AWK} '{ print NF }'`"