-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock-sync.sh
executable file
·84 lines (69 loc) · 1.85 KB
/
mock-sync.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
dir=$PWD
arch=$1
if [ -z "$arch" ]; then
echo "Specify if 32 or 64 arch sync"
exit 1
fi
shift 1
if [ "$1" = "-n" ]; then
rsync_args=-vvn
shift 1
fi
if [ -r ./mock-config.txt ]; then
. ./mock-config.txt
else
echo "Missing mock-config.txt"
exit 1
fi
if [ -z "$dst_root" ]; then
echo "Specify the dst_root (relative destination root) in the mock-config.txt"
exit 1
fi
if [ ! -z "$parent" ]; then
src_root=$dir/$parent
else
src_root=$dir
fi
if [ $arch -eq 32 ]; then
ROOT=$ROOT32
elif [ $arch -eq 64 ]; then
ROOT=$ROOT64
else
echo "Pick a correct sync arch (32 or 64)"
exit 1
fi
root=`mock -r $ROOT --print-root-path`/builddir
if [ ! -e $dir/mock-sync.txt -a ! -e $dir/mock-rsync.txt ]; then
echo "App has no mock-sync.txt or mock-rsync.txt"
continue
fi
if [ -e $dir/mock-sync.txt ]; then
pushd $src_root
while read srcpath; do
if [ -z "$srcpath" ] || [[ "$srcpath" == \#* ]]; then
continue
fi
if [[ $srcpath == *\** ]]; then
realsrcpath=${srcpath%/*}
wildcard=${srcpath##*/}
srcpath=${realsrcpath}
else
wildcard=""
fi
if [ ! -z "$wildcard" ]; then
mkdir -p $root/$dst_root/$srcpath/
rsync -a --delete-after $srcpath/$wildcard $root/$dst_root/$srcpath/ $rsync_args
elif [ -d $srcpath ]; then
mkdir -p $root/$dst_root/$srcpath/
rsync -a --delete-after $srcpath/ $root/$dst_root/$srcpath/ $rsync_args
else
mkdir -p `dirname $root/$dst_root/$srcpath`
rsync -a --delete-after $srcpath $root/$dst_root/$srcpath $rsync_args
fi
done < "$dir/mock-sync.txt"
popd
fi
if [ -e $dir/mock-rsync.txt ]; then
rsync -a -f ". $dir/mock-rsync.txt" $src_root/ $root/$dst_root/ $rsync_args
fi