This repository has been archived by the owner on Dec 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlirios-init-build-env
executable file
·180 lines (163 loc) · 4.04 KB
/
lirios-init-build-env
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/bin/sh
#
# This file is part of Liri.
#
# Copyright (C) 2016 Pier Luigi Fiorini <[email protected]>
#
# $BEGIN_LICENSE:GPL3+$
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# $END_LICENSE$
#
set -e
usage() {
echo "Usage: $(basename $0) COMMAND [ARGS]"
echo
echo "Initialize build environment:"
echo " $(basename $0) init --device <name> [--reference <mirror path>] [--repo-url <url>]"
echo " --device <name>: target device name or 'all'"
echo " --reference <mirror path>: path to local mirror, initialized previously with '$(basename $0) mirror'"
echo " --repo-url <url>: url to the repo git sources"
echo "Initialize local mirror:"
echo " $(basename $0) mirror"
echo "List available devices:"
echo " $(basename $0) list-devices"
}
while test -n "$1"; do
case "$1" in
"help" | "--help" | "-h")
usage
exit 0
;;
"--reference" | "-r")
shift
REFERENCE=$1
;;
"--device" | "-d")
shift
DEVICE=$1
;;
"--repo-url")
shift
REPO_URL="--repo-url $1"
;;
*)
if [ -n "$COMMAND" ]; then
echo "Unknown argument: $1"
usage
exit 1
fi
COMMAND=$1
;;
esac
shift
done
if [ -z "${COMMAND}" ]; then
usage
exit 1
fi
DIR=$(readlink -f $(dirname $0))
if [ -n "${REFERENCE}" ]; then
REFERENCE="--reference $(readlink -f ${REFERENCE})"
fi
if [ -z "${REPO_URL}" ]; then
REPO_URL="--repo-url git://github.com/theqtcompany/git-repo"
fi
get_repo() {
REPO="./repo"
if [ -n "$(command -v repo)" ]; then
REPO="repo"
elif [ ! -x "./repo" ]; then
curl -s https://storage.googleapis.com/git-repo-downloads/repo > "./repo"
chmod +x ./repo
fi
}
get_groups() {
case ${DEVICE} in
all)
PROJECT_GROUPS="external"
;;
intel-corei7-64)
PROJECT_GROUPS="intel"
;;
raspberrypi0|raspberrypi|raspberrypi2|raspberrypi3)
PROJECT_GROUPS="rpi"
;;
odroid-c1|odroid-c2)
PROJECT_GROUPS="odroid"
;;
*)
echo "Unknown device configuration, including all meta layers"
PROJECT_GROUPS="external"
;;
esac
PROJECT_GROUPS="${PROJECT_GROUPS} default"
}
list_devices() {
echo "Available device configurations:"
for device in $(ls $DIR/conf/distro/include/*.conf); do
echo " $(basename ${device%%.conf})"
done
}
mirror() {
mkdir -p .repo/manifests
cp ${DIR}/scripts/manifest.xml .repo/manifests/
MANIFEST="manifest.xml"
DEVICE=${DEVICE:-all}
get_groups
${REPO} init ${REPO_URL} -u ${PWD}/.repo/repo -b default -m ${MANIFEST} -g "${PROJECT_GROUPS}" --mirror
${REPO} sync
}
init() {
if [ -z "${DEVICE}" ]; then
echo "device not defined"
usage
exit 1
fi
get_groups
mkdir -p .repo/manifests
rm -f .repo/manifests/manifest*.xml
cp ${DIR}/scripts/manifest*.xml .repo/manifests
if [ -f .repo/manifests/manifest_${DEVICE}.xml ]; then
MANIFEST="manifest_${DEVICE}.xml"
else
MANIFEST="manifest.xml"
fi
${REPO} init ${REPO_URL} -u ${PWD}/.repo/repo -b default -m ${MANIFEST} -g "${PROJECT_GROUPS}" ${REFERENCE}
${REPO} sync --optimized-fetch
if [ ! -e "sources/meta-liri" ]; then
ln -s ${DIR} sources/meta-liri
fi
if [ ! -e "setup-environment.sh" ]; then
ln -s ${DIR}/scripts/setup-environment.sh setup-environment.sh
fi
}
get_repo
case "$COMMAND" in
"init")
init
;;
"mirror")
mirror
;;
"list-devices")
list_devices
;;
*)
echo "Unknown command"
usage
exit 1
;;
esac