forked from OpenXT/openxt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_build
executable file
·131 lines (109 loc) · 4.27 KB
/
setup_build
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
#!/bin/sh
# OpenXT git repo setup file.
die() {
echo "$1" 1>&2
exit 1
}
#######################################################################
# checkout_git_branch #
# param1: Path to the git repo #
# param2: Preferred branch to checkout. Fallback will be to master. #
# #
# Checks out the branch specified in param2 for the repo located at #
# the file path in param1. If the branch is not part of the git repo #
# the master branch is checked out instead. #
#######################################################################
checkout_git_branch() {
local path="$1"
local branch="$2"
cd $path
git checkout "$branch" 2>/dev/null|| git checkout -b "$branch" origin/$branch 2>/dev/null || { echo "The value $branch does not exist as a branch or HEAD position. Falling back to the master branch."; git checkout master 2>/dev/null; }
cd $OLDPWD
}
#######################################################################
# fetch_git_repo #
# param1: Path (absolute) to place the repo #
# param2: Git url to fetch #
# #
# Fetches the repo specified by param2 into the directory specified #
# by param1. #
#######################################################################
fetch_git_repo() {
local path="$1"
local repo="$2"
echo "Fetching $repo..."
set +e
git clone -q -n $repo "$path" || die "Clone of git repo failed: $repo"
set -e
}
process_git_repo() {
local path="$1"
local repo="$2"
local branch="$3"
# Remove the directory if it's empty
[ -d $path ] && [ -z "`ls -A1 $path | head -1`" ] && rmdir $path
if [ ! -d $path ]; then
# The path does not exist. Proceed.
fetch_git_repo $path $repo $branch
checkout_git_branch $path $branch
fi
}
setup_git_repo() {
local repo="$1"
local default_tag="$2"
local repo_var=`echo $repo | sed -e 's/openembedded/oe/' -e 's/-/_/g' | tr '[a-z]' '[A-Z]'`
local git_var="${repo_var}_REPO"
local git=${!git_var}
local tag_var="${repo_var}_TAG"
local tag=${!tag_var}
if [ -n "${git}" ]; then
[ -z ${tag} ] && tag=$default_tag
process_git_repo $REPOS/$repo $git $tag
else
echo Clone submodule $repo, using saved HEAD
git submodule update --checkout $REPOS/$repo
if [ -n "$tag" ]; then
echo "Checking out $repo at $tag"
checkout_git_branch $REPOS/$repo $tag
else
echo "Update submodule $repo that follow a branch (update != none)"
git submodule update --remote $REPOS/$repo
fi
fi
}
OE_XENCLIENT_DIR=`pwd`
REPOS=$OE_XENCLIENT_DIR/repos
OE_PARENT_DIR=$(dirname $OE_XENCLIENT_DIR)
# Load our config
[ -f "$OE_PARENT_DIR/.config" ] && . "$OE_PARENT_DIR/.config"
mkdir -p $REPOS || die "Could not create local build dir"
# Pull down the OpenXT repos
process_git_repo $REPOS/xenclient-oe $XENCLIENT_REPO $XENCLIENT_TAG
process_git_repo $REPOS/meta-openxt-ocaml-platform \
$META_OPENXT_OCAML_PLATFORM_REPO $META_OPENXT_OCAML_PLATFORM_TAG
process_git_repo $REPOS/meta-openxt-haskell-platform \
$META_OPENXT_HASKELL_PLATFORM_REPO $META_OPENXT_HASKELL_PLATFORM_TAG
# Initialise the submodules using .gitmodules
git submodule init
# Pull down Bitbake
setup_git_repo bitbake $BB_BRANCH
# Pull down OE repos
for repo in openembedded-core meta-openembedded meta-java meta-selinux \
meta-intel meta-virtualization; do
setup_git_repo $repo $OE_BRANCH
done
if [ ! -e $OE_XENCLIENT_DIR/conf/local.conf ]; then
ln -s $OE_XENCLIENT_DIR/conf/local.conf-dist \
$OE_XENCLIENT_DIR/conf/local.conf
fi
BBPATH=$OE_XENCLIENT_DIR/oe/xenclient:$REPOS/openembedded:$OE_XENCLIENT_DIR/oe-addons
if [ ! -z "$EXTRA_DIR" ]; then
BBPATH=$REPOS/$EXTRA_DIR:$BBPATH
fi
cat > oeenv <<EOF
OE_XENCLIENT_DIR=$OE_XENCLIENT_DIR
PATH=$OE_XENCLIENT_DIR/repos/bitbake/bin:\$PATH
BBPATH=$BBPATH
BB_ENV_EXTRAWHITE="OE_XENCLIENT_DIR MACHINE GIT_AUTHOR_NAME EMAIL"
export OE_XENCLIENT_DIR PATH BBPATH BB_ENV_EXTRAWHITE
EOF