1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/test_files/mk_e2test.sh Sun Aug 01 22:48:12 2021 +0200
1.3 @@ -0,0 +1,83 @@
1.4 +#!/bin/sh
1.5 +
1.6 +THIS_DIR=$(realpath $(dirname "$0"))
1.7 +
1.8 +if [ "$1" = '-q' ] ; then
1.9 + QUIET=$1
1.10 + shift 1
1.11 +else
1.12 + QUIET=
1.13 +fi
1.14 +
1.15 +PKGDIR=$1
1.16 +E2ACCESS_DIR=$2
1.17 +TARGET=$3
1.18 +
1.19 +if [ ! -e "$PKGDIR" ] || [ ! -e "$E2ACCESS_DIR" ] || [ ! "$TARGET" ] ; then
1.20 + echo "Usage: $0 [ -q ] <package directory> <e2access directory> <target>" 1>&2
1.21 + exit 1
1.22 +fi
1.23 +
1.24 +PKGDIR=`realpath "$PKGDIR"`
1.25 +E2ACCESS_DIR=`realpath "$E2ACCESS_DIR"`
1.26 +TARGET=`realpath "$TARGET"`
1.27 +
1.28 +# Initialise the program details and environment.
1.29 +
1.30 +E2ACCESS="$E2ACCESS_DIR"/e2access
1.31 +export LD_LIBRARY_PATH="$E2ACCESS_DIR"
1.32 +
1.33 +# Make a filesystem for the example.
1.34 +
1.35 +mkdir tmp_e2test
1.36 +cd tmp_e2test
1.37 +mkdir -p home/paulb/many
1.38 +cd home/paulb/many
1.39 +
1.40 +# Populate the directory with plenty of files.
1.41 +
1.42 +for N in `seq 1 400`; do
1.43 + echo "Contents of #$N." > "file-$N".txt
1.44 +done
1.45 +
1.46 +cd ..
1.47 +
1.48 +# Put a file in the directory above.
1.49 +
1.50 +cp "$PKGDIR/../docs/LICENCE.txt" .
1.51 +
1.52 +# Leave the filesystem root.
1.53 +
1.54 +cd ../..
1.55 +
1.56 +# Create a filesystem image.
1.57 +
1.58 +EXTRA=2000
1.59 +SIZE=$(du -s -k home | cut -f 1)
1.60 +TOTAL=$(($SIZE + $EXTRA))
1.61 +
1.62 +dd if=/dev/zero of="$TARGET" bs=1024 count=$TOTAL
1.63 +
1.64 +if ! $(/sbin/mkfs.ext2 -q "$TARGET") ; then
1.65 + exit 1
1.66 +fi
1.67 +
1.68 +# Add the directory and files to the image.
1.69 +
1.70 +"$E2ACCESS" "$TARGET" --make-dirs home/paulb/many
1.71 +
1.72 +"$E2ACCESS" "$TARGET" --copy-in $(find home/paulb/many -maxdepth 1 -type f | sort) home/paulb/many
1.73 +"$E2ACCESS" "$TARGET" --copy-in $(find home/paulb -maxdepth 1 -type f | sort) home/paulb
1.74 +
1.75 +# Leave the root of the filesystem.
1.76 +
1.77 +cd ..
1.78 +
1.79 +if [ ! "$QUIET" ] ; then
1.80 + "$E2ACCESS" "$TARGET" --list-dirs ''
1.81 + "$E2ACCESS" "$TARGET" --list-dirs 'home'
1.82 + "$E2ACCESS" "$TARGET" --list-dirs 'home/paulb'
1.83 + "$E2ACCESS" "$TARGET" --list-dirs 'home/paulb/many'
1.84 +fi
1.85 +
1.86 +rm -r tmp_e2test