forked from dozylynx/oe-build-xen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoe-build-xen.sh
executable file
·137 lines (110 loc) · 4.5 KB
/
oe-build-xen.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
#
# Copyright (c) 2019 BAE Systems
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
OE_RELEASE="thud"
SPEEDUP="--single-branch"
REPOHOST_YOCTO="git.yoctoproject.org"
REPOHOST_OE="git.openembedded.org"
REPOHOST_XEN="xenbits.xen.org"
#---
# Validate input
if [ $# != 2 ] ; then
echo >&2 "Error: $0 <target arch> <xen branch>"
exit 1
fi
case $1 in
"x86-64") MACHINE="genericx86-64";;
"arm64") MACHINE="qemuarm64";;
"arm32") MACHINE="qemuarm";;
*) echo >&2 "Error: invalid arch, requires one of: [x86-64 | arm64 | arm32]" ; exit 2 ;;
esac
XEN_BRANCH="$2"
#---
# Determine Xen version information
# Obtain the git reference for the current tip of the branch to be built:
XEN_SRCREV=$(git ls-remote --heads "git://${REPOHOST_XEN}/xen.git" "refs/heads/${XEN_BRANCH}" | cut -f1 -d' ')
if [ -z "${XEN_SRCREV}" ] ; then
echo >&2 "Error: failed to find specified branch ${XEN_BRANCH} in Xen repository."
exit 3
fi
XEN_REL=$(echo "${XEN_BRANCH}" | sed -ne 's/^.*-//p')
if [ -z "${XEN_REL}" ] ; then
# Since the branch name didn't contain version information, determine the next major release:
LAST_STABLE_RELEASE=$(git ls-remote --heads git://xenbits.xen.org/xen.git | cut -f2 -d' ' | sort -V | tail -1 | sed 's/^.*-//')
MAJOR_VERSION=$(echo $LAST_STABLE_RELEASE | cut -f1 -d.)
MINOR_VERSION=$(echo $LAST_STABLE_RELEASE | cut -f2 -d.)
NEXT_MINOR_VERSION=$(( $(echo "${MINOR_VERSION}" | cut -f2 -d.) + 1 ))
XEN_REL="${MAJOR_VERSION}.${NEXT_MINOR_VERSION}"
fi
#---
# Obtain general build environment
git clone --branch "${OE_RELEASE}" "${SPEEDUP}" "git://${REPOHOST_YOCTO}/poky"
cd poky
git clone --branch "${OE_RELEASE}" "${SPEEDUP}" "git://${REPOHOST_YOCTO}/meta-virtualization"
git clone --branch "${OE_RELEASE}" "${SPEEDUP}" "git://${REPOHOST_OE}/meta-openembedded"
# Initialize state and conf directory
source ./oe-init-build-env build
cd build
#---
# bblayers.conf: add the necessary layers
LAYER_ROOT="$(sed -ne 's/^ \(\/.*\/\)meta \\$/\1/p' <conf/bblayers.conf)"
ESCAPED_LAYER_ROOT="$(echo $LAYER_ROOT | sed 's/\//\\\//g')"
for LAYER in meta-virtualization \
meta-openembedded/meta-python \
meta-openembedded/meta-networking \
meta-openembedded/meta-filesystems \
meta-openembedded/meta-oe
do
ESCAPED_LAYER="$(echo "${LAYER}" | sed 's/\//\\\//g')"
# Match on the meta-yocto-bsp layer line for the insertion point
sed "/^ ${ESCAPED_LAYER_ROOT}meta-yocto-bsp \\\\$/a\\ \\ ${ESCAPED_LAYER_ROOT}${ESCAPED_LAYER} \\\\" \
-i conf/bblayers.conf
done
#---
# Since we're specifying the exact version of Xen that is to be built,
# write a custom Xen recipe to do so.
cat >../meta-virtualization/recipes-extended/xen/xen_git.bb <<EOF
require xen.inc
SRCREV ?= "${XEN_SRCREV}"
XEN_REL = "${XEN_REL}"
XEN_BRANCH = "${XEN_BRANCH}"
FLASK_POLICY_FILE = "xenpolicy-\${XEN_REL}-unstable"
PV = "\${XEN_REL}+git\${SRCPV}"
S = "\${WORKDIR}/git"
SRC_URI = "git://xenbits.xen.org/xen.git;branch=\${XEN_BRANCH}"
EOF
#---
# local.conf: add the necessary variable definitions
cat >>conf/local.conf <<EOF
MACHINE = "${MACHINE}"
DISTRO_FEATURES_append = " virtualization xen"
PREFERRED_VERSION_xen = "${XEN_REL_VALUE}+git%"
# Enable parallelism in the build. These values should be tuned
# to appropriate values for the build host.
BB_NUMBER_THREADS ?= "8"
PARALLEL_MAKE ?= "-j 4"
EOF
#---
# TODO: enable shared sstate cache and the download binary mirror here
#---
# Run the build
bitbake xen && bitbake xen-image-minimal && bitbake xen-guest-image-minimal