1 #!/bin/sh 2 3 THIS_DIR=$(realpath $(dirname "$0")) 4 5 PKGDIR=$1 6 E2ACCESS_DIR=$2 7 TARGET=$3 8 9 if [ ! -e "$PKGDIR" ] || [ ! -e "$E2ACCESS_DIR" ] || [ ! "$TARGET" ] ; then 10 echo "Usage: $0 <package directory> <e2access directory> <target>" 1>&2 11 exit 1 12 fi 13 14 TARGET=`realpath "$TARGET"` 15 16 # Initialise the program details and environment. 17 18 E2ACCESS="$E2ACCESS_DIR"/e2access 19 export LD_LIBRARY_PATH="$E2ACCESS_DIR" 20 21 # Make a filesystem for the example. 22 23 mkdir tmp_e2test 24 cd tmp_e2test 25 mkdir -p home/paulb/many 26 cd home/paulb/many 27 28 # Populate the directory with plenty of files. 29 30 for N in `seq 1 400`; do 31 echo "Contents of #$N." > "file-$N".txt 32 done 33 34 cd .. 35 36 # Put a file in the directory above. 37 38 cp "$PKGDIR/../docs/LICENCE.txt" . 39 40 # Leave the filesystem root. 41 42 cd ../.. 43 44 # Create a filesystem image. 45 46 EXTRA=2000 47 SIZE=$(du -s -k home | cut -f 1) 48 TOTAL=$(($SIZE + $EXTRA)) 49 50 dd if=/dev/zero of="$TARGET" bs=1024 count=$TOTAL 51 52 if ! $(/sbin/mkfs.ext2 -q "$TARGET") ; then 53 exit 1 54 fi 55 56 # Add the directory and files to the image. 57 58 "$E2ACCESS" "$TARGET" --make-dirs home/paulb/many 59 60 "$E2ACCESS" "$TARGET" --copy-in $(find home/paulb/many -maxdepth 1 -type f | sort) home/paulb/many 61 "$E2ACCESS" "$TARGET" --copy-in $(find home/paulb -maxdepth 1 -type f | sort) home/paulb 62 63 # Leave the root of the filesystem. 64 65 cd .. 66 67 "$E2ACCESS" "$TARGET" --list-dirs '' 68 "$E2ACCESS" "$TARGET" --list-dirs 'home' 69 "$E2ACCESS" "$TARGET" --list-dirs 'home/paulb' 70 "$E2ACCESS" "$TARGET" --list-dirs 'home/paulb/many' 71 72 rm -r tmp_e2test