1.1 --- a/test_files/mk_e2test.sh Tue Feb 08 00:03:32 2022 +0100
1.2 +++ b/test_files/mk_e2test.sh Wed Feb 09 22:30:29 2022 +0100
1.3 @@ -1,6 +1,9 @@
1.4 #!/bin/sh
1.5
1.6 -THIS_DIR=$(realpath $(dirname "$0"))
1.7 +# NOTE: There should be a stable user identifier defined, not that of the user
1.8 +# NOTE: running this script.
1.9 +
1.10 +PROGNAME=$(basename "$0")
1.11
1.12 if [ "$1" = '-q' ] ; then
1.13 QUIET=$1
1.14 @@ -9,19 +12,21 @@
1.15 QUIET=
1.16 fi
1.17
1.18 -PKGDIR=$1
1.19 -E2ACCESS_DIR=$2
1.20 -TARGET=$3
1.21 +PKGDIR=$(realpath "$1")
1.22 +E2ACCESS_DIR=$(realpath "$2")
1.23 +TARGET=$(realpath "$3")
1.24
1.25 if [ ! -e "$PKGDIR" ] || [ ! -e "$E2ACCESS_DIR" ] || [ ! "$TARGET" ] ; then
1.26 - echo "Usage: $0 [ -q ] <package directory> <e2access directory> <target>" 1>&2
1.27 + cat 1>&2 <<EOF
1.28 +Usage: $PROGNAME [ -q ] <package directory> <e2access directory> <target>
1.29 +
1.30 +Package directory: $PKGDIR
1.31 +e2access directory: $E2ACCESS_DIR
1.32 +Target filesystem: $TARGET
1.33 +EOF
1.34 exit 1
1.35 fi
1.36
1.37 -PKGDIR=`realpath "$PKGDIR"`
1.38 -E2ACCESS_DIR=`realpath "$E2ACCESS_DIR"`
1.39 -TARGET=`realpath "$TARGET"`
1.40 -
1.41 # Initialise the program details and environment.
1.42
1.43 E2ACCESS="$E2ACCESS_DIR"/e2access
1.44 @@ -31,6 +36,34 @@
1.45
1.46 mkdir tmp_e2test
1.47 cd tmp_e2test
1.48 +
1.49 +# Set a sensible umask.
1.50 +
1.51 +umask 0022
1.52 +
1.53 +mkdir -p home/paulb/public
1.54 +echo "Public!" > home/paulb/public/message
1.55 +
1.56 +# Set a restrictive umask.
1.57 +
1.58 +umask 0077
1.59 +
1.60 +echo "Not public!" > home/paulb/public/message2
1.61 +
1.62 +mkdir -p home/paulb/private
1.63 +echo "Private!" > home/paulb/private/message
1.64 +
1.65 +# Set a permissive umask.
1.66 +
1.67 +umask 0000
1.68 +
1.69 +mkdir -p home/paulb/shared
1.70 +echo "Editable!" > home/paulb/shared/message
1.71 +
1.72 +# Restore the umask for the remaining files.
1.73 +
1.74 +umask 0022
1.75 +
1.76 mkdir -p home/paulb/many
1.77 cd home/paulb/many
1.78
1.79 @@ -62,12 +95,12 @@
1.80 exit 1
1.81 fi
1.82
1.83 -# Add the directory and files to the image.
1.84 +# Add the directories and files to the image.
1.85
1.86 -"$E2ACCESS" "$TARGET" --make-dirs home/paulb/many
1.87 -
1.88 -"$E2ACCESS" "$TARGET" --copy-in $(find home/paulb/many -maxdepth 1 -type f | sort) home/paulb/many
1.89 -"$E2ACCESS" "$TARGET" --copy-in $(find home/paulb -maxdepth 1 -type f | sort) home/paulb
1.90 +for DIR in home/paulb/private home/paulb/public home/paulb/shared home/paulb/many home/paulb ; do
1.91 + "$E2ACCESS" "$TARGET" --make-dirs "$DIR"
1.92 + "$E2ACCESS" "$TARGET" --copy-in $(find "$DIR" -maxdepth 1 -type f | sort) "$DIR"
1.93 +done
1.94
1.95 # Leave the root of the filesystem.
1.96
1.97 @@ -78,6 +111,11 @@
1.98 "$E2ACCESS" "$TARGET" --list-dirs 'home'
1.99 "$E2ACCESS" "$TARGET" --list-dirs 'home/paulb'
1.100 "$E2ACCESS" "$TARGET" --list-dirs 'home/paulb/many'
1.101 + "$E2ACCESS" "$TARGET" --list-dirs 'home/paulb/private'
1.102 + "$E2ACCESS" "$TARGET" --list-dirs 'home/paulb/public'
1.103 + "$E2ACCESS" "$TARGET" --list-dirs 'home/paulb/shared'
1.104 fi
1.105
1.106 rm -r tmp_e2test
1.107 +
1.108 +# vim: tabstop=4 expandtab shiftwidth=4