-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·116 lines (96 loc) · 2.37 KB
/
build.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
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# set -o errexit
# set -o nounset
# set -o pipefail
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
. ${SCRIPT_DIR}/common.sh
. ${SCRIPT_DIR}/stable-commits
[ -e /etc/os-release ] && . /etc/os-release
set -x
BUILD_PACKAGE="0"
function usage()
{
echo "Usage: $0 [OPTIONS] [COMPONENT]"
echo " where COMPONENT is an individual component to build:"
echo " qemu, ovmf, kernel [host|guest]"
echo " (default is to build all components)"
echo " where OPTIONS are:"
echo " --install PATH Installation path (default $INSTALL_DIR)"
echo " --package Create a tarball containing built components"
echo " -h|--help Usage information"
exit 1
}
INSTALL_DIR="`pwd`/usr/local"
while [ -n "${1:-}" ]; do
case "$1" in
--install)
[ -z "$2" ] && usage
INSTALL_DIR="$2"
shift; shift
;;
-h|--help)
usage
;;
--package)
BUILD_PACKAGE="1"
shift
;;
-*|--*)
echo "Unsupported option: [$1]"
usage
;;
*)
break
;;
esac
done
mkdir -p $INSTALL_DIR
IDIR=$INSTALL_DIR
INSTALL_DIR=$(readlink -e $INSTALL_DIR)
[ -n "$INSTALL_DIR" -a -d "$INSTALL_DIR" ] || {
echo "Installation directory [$IDIR] does not exist, exiting"
exit 1
}
if [ -z "${1:-}" ]; then
build_install_qemu "$INSTALL_DIR"
build_install_ovmf_edk2 "$INSTALL_DIR/share/qemu"
build_kernel ${2:-}
else
case "${1:-}" in
qemu)
build_install_qemu "$INSTALL_DIR"
;;
ovmf)
build_install_ovmf_edk2 "$INSTALL_DIR/share/qemu"
;;
kernel)
# additional argument of "host" or "guest" can be added to limit build to that type
build_kernel "${2:-}"
;;
*)
echo "unknown parameter $1"
exit 1
break
;;
esac
fi
if [[ "$BUILD_PACKAGE" = "1" ]]; then
OUTPUT_DIR="heckler-snp-release-`date "+%F"`"
rm -rf $OUTPUT_DIR
mkdir -p $OUTPUT_DIR/linux/guest
mkdir -p $OUTPUT_DIR/linux/host
mkdir -p $OUTPUT_DIR/usr
cp -dpR $INSTALL_DIR $OUTPUT_DIR/usr/
cp source-commit.* $OUTPUT_DIR/
cp stable-commits $OUTPUT_DIR/source-config
if [ "$ID" = "debian" ] || [ "$ID_LIKE" = "debian" ]; then
cp linux/linux-*-guest-*.deb $OUTPUT_DIR/linux/guest -v || true
cp linux/linux-*-host-*.deb $OUTPUT_DIR/linux/host -v || true
else
cp linux/kernel-*.rpm $OUTPUT_DIR/linux -v || true
fi
cp launch-qemu-shell.sh ${OUTPUT_DIR} -v
cp install.sh ${OUTPUT_DIR} -v
cp kvm.conf ${OUTPUT_DIR} -v
tar zcvf ${OUTPUT_DIR}.tar.gz ${OUTPUT_DIR}
fi