forked from matelakat/storage-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck-blktap.sh
executable file
·103 lines (71 loc) · 1.88 KB
/
check-blktap.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
set -e
function usage() {
cat >&2 << EOF
$0
Check the blktap repository
Usage:
$0 SOURCES WORKSPACE
Where:
SOURCES A directory containing the blktap repository
https://github.com/xapi-project/blktap
WORKSPACE A workspace to be used. For the initial run, just
create an empty directory, and specify the same later
Example:
git clone https://github.com/xapi-project/blktap
git clone https://github.com/matelakat/sm-ci
mkdir workspace
sm-ci/check-blktap.sh blktap workspace/
EOF
exit 1
}
function assert_installed() {
if which $1; then
return
fi
cat >&2 << EOF
Error:
$1 was not found, please install it to your system.
EOF
exit 1
}
[ -z "$1" ] && usage
[ -z "$2" ] && usage
set -eux
SOURCES="$1"
WORKDIR="$2"
# check dependencies
assert_installed fakeroot
assert_installed fakechroot
assert_installed debootstrap
THISFILE=$(readlink -f $0)
THISDIR=$(dirname $THISFILE)
. "$THISDIR/ci_lib.sh"
function install_blktap_prereqs() {
local source_pack
local chroot_dir
source_pack="$1"
chroot_dir="$2"
chroot_dir="$(readlink -f $chroot_dir)"
local chroot_path
chroot_path="$chroot_dir/$CHROOT_SUBDIR"
[ -d "$chroot_path" ]
chroot_run "$chroot_dir" "$THISDIR/blktap_prereqs.sh"
}
function check_blktap() {
local source_pack
local chroot_dir
source_pack="$1"
chroot_dir="$2"
chroot_dir="$(readlink -f $chroot_dir)"
local chroot_path
chroot_path="$chroot_dir/$CHROOT_SUBDIR"
[ -e "$source_pack" ]
[ -d "$chroot_path" ]
cp "$source_pack" "$chroot_path/source.tgz"
tar -czf "$chroot_path/additional_files.tgz" -C "$THISDIR/blktap" ./
chroot_run "$chroot_dir" "$THISDIR/blktap_check.sh"
}
check "$SOURCES" "$WORKDIR" \
"install_blktap_prereqs" \
"check_blktap"