-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.sh
executable file
·63 lines (46 loc) · 1.47 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
if [ $# -ne 3 ]; then
echo "Example: ./run.sh inputdir mntdir fscachedir"
echo " inputdir: an erofs image will be built from this directory"
echo " mntdir: the built erofs will be mounted on this path"
echo " fscachedir: root directory of cachefiles"
exit
fi
inputdir=$1
mntdir=$2
fscachedir=$3
_bootstrap="test.img"
_datablob="blob1.img"
bootstrap="D${_bootstrap}"
datablob="D${_datablob}"
make
if [ ! -e getfan -o ! -e cachefilesd2 ]; then
echo "gcc failed"
exit
fi
mkfs.erofs 2>&1 | grep -q 'command not found'
if [ $? -eq 0 ]; then
echo "erofs-utils need to be installed."
echo "https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git -b master"
exit
fi
# create erofs image, chunk-index layout, chunk size 1M
mkfs.erofs --chunksize=1048576 --blobdev=$_datablob -Eforce-chunk-indexes $_bootstrap $inputdir
if [ ! -e $_bootstrap -o ! -e $_datablob ]; then
echo "mkfs.erofs failed"
exit
fi
_volume="erofs,$_bootstrap"
volume="I$_volume"
bootstrap_fan=$(./getfan $_volume $_bootstrap)
bootstrap_path="$fscachedir/cache/$volume/@$bootstrap_fan/D$_bootstrap"
datablob_fan=$(./getfan $_volume $_datablob)
datablob_path="$fscachedir/cache/$volume/@$datablob_fan/D$_datablob"
rm -f $bootstrap_path
rm -f $datablob_path
./cachefilesd2 $fscachedir &
sleep 2
mount -t erofs none -o fsid=${_bootstrap} -o device=${_datablob} ${mntdir}
trap "umount ${mntdir};pkill cachefilesd2; exit" INT
echo "Ctrl-C to kill cachefilesd2 when test finished..."
read tmp