-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadt_wrapper.sh
executable file
·207 lines (178 loc) · 7.74 KB
/
adt_wrapper.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
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
#
# Author : [email protected]
# Homepage :
# License : BSD http://en.wikipedia.org/wiki/BSD_license
# Copyright 2014, peter ducai
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Purpose : wrapper to automate Yocto ADT without user interaction
# Usage : run with --help parameter to see usage
#
#############################
# DEFAULT PARAMS from ADT #
#############################
WRAPPER_VER="0.1"
NOW=$(date +"%s-%d-%m-%Y")
ADT_PATH="adt-installer" # path to ADT installer
INSTALL_DIR="${HOME}/adt"
YOCTOADT_REPO="http://downloads.yoctoproject.org/releases/yocto/yocto-1.5.1/adt-installer"
YOCTOADT_TARGETS="qemux86"
YOCTOADT_QEMU="N"
YOCTOADT_NFS_UTIL="N"
YOCTOADT_ROOTFS_arch="sato-sdk"
YOCTOADT_TARGET_SYSROOT_IMAGE_arch="sato-sdk"
YOCTOADT_TARGET_MACHINE_arch="qemux86"
YOCTOADT_TARGET_SYSROOT_LOC_arch="$HOME/yocto_sdk/sysroots/arm"
########################################
# FUNCTIONS ##
########################################
###############
# print usage #
###############
usage() {
echo -e "\n# USAGE ########################################\n"
echo -e "adt_wrapper.sh --adt-path=\"adt-installer\" --package-system=\"ipk\" --install-path=\"${HOME}\" --target-arch=\"qemux86\" --target-machine=\"core-image-sato\" --target-rootfs=\"sato-sdk\" --sysroot-image=\"core-image-sato-sdk\""
echo -e "\nOPTIONS:"
echo -e "[supported rootfs] minimal minimal-dev sato sato-dev sato-sdk lsb lsb-dev lsb-sdk"
echo -e "[supported archs] x86 x86_64 arm ppc mips"
}
##################################
# process parameters from CLI #
##################################
process_parameters() {
# process parameters
echo "processing paramaters"
for i in "$@"
do
case "$i" in
--package-system=*) echo -e"setting package manager"
PACKAGE_MANAGERS=(${i#*=})
CLI_ARGS="${CLI_ARGS} --set-package-system=\"${PACKAGE_MANAGERS[@]}\""
;;
--install-path=*) INSTALL_DIR=${i#*=}
echo -e "setting installation path to ${INSTALL_DIR}"
CLI_ARGS="${CLI_ARGS} --install-path=\"${INSTALL_DIR}\""
;;
--target-arch=*) YOCTOADT_TARGETS="${i#*=}"
;;
--target-machine=*) YOCTOADT_TARGET_MACHINE_arch="${i#*=}"
;;
--target-rootfs=*) YOCTOADT_ROOTFS_arch="${i#*=}"
;;
--sysroot-image=*) YOCTOADT_TARGET_SYSROOT_IMAGE_arch="${i#*=}"
;;
--sysroot-loc=*) export YOCTOADT_TARGET_SYSROOT_arm="${i#*=}"
;;
--help) print_banner
usage
exit
;;
*) echo "INVALID option!!!"
usage
print_params
exit
;;
esac
done
}
###########################################
# write values into adt_installer.conf #
###########################################
write_adt_conf() {
echo -e "backing up old adt_installer.conf"
cp ${ADT_PATH}/adt_installer.conf ${ADT_PATH}/adt_installer.conf.backup
echo -e "# generated with ADT Wrapper [${NOW}]" > ${ADT_PATH}/adt_installer.conf
echo -e "YOCTOADT_REPO=\"${YOCTOADT_REPO}\"" >> ${ADT_PATH}/adt_installer.conf
echo -e "YOCTOADT_TARGETS=\"arm\"" >> ${ADT_PATH}/adt_installer.conf
echo -e "YOCTOADT_QEMU=\"N\"" >> ${ADT_PATH}/adt_installer.conf
echo -e "YOCTOADT_NFS_UTIL=\"N\"" >> ${ADT_PATH}/adt_installer.conf
echo -e "YOCTOADT_ROOTFS_${YOCTOADT_TARGETS}=\"${YOCTOADT_ROOTFS_arch}\"" >> ${ADT_PATH}/adt_installer.conf
echo -e "YOCTOADT_TARGET_SYSROOT_IMAGE_${YOCTOADT_TARGETS}=\"${YOCTOADT_TARGET_SYSROOT_IMAGE_arch}\"" >> ${ADT_PATH}/adt_installer.conf
echo -e "YOCTOADT_TARGET_MACHINE_${YOCTOADT_TARGETS}=\"${YOCTOADT_TARGET_MACHINE_arch}\"" >> ${ADT_PATH}/adt_installer.conf
echo -e "YOCTOADT_TARGET_SYSROOT_LOC_${YOCTOADT_TARGETS}=\"$HOME/yocto-sdk/sysroots/${YOCTOADT_TARGETS}\"\n" >> ${ADT_PATH}/adt_installer.conf
echo -e "\nnew adt_installer.conf generated\n"
}
##########################
# print paramaters #
##########################
print_params() {
echo -e "\ncurrently PARAMETERS are set to:\n"
echo -e "INSTALL_DIR=\"${INSTALL_DIR}\""
echo -e "ADT_PATH=\"${ADT_PATH}\"\n"
echo -e "YOCTOADT_REPO=\"${YOCTOADT_REPO}\""
echo -e "YOCTOADT_TARGETS=\"arm\""
echo -e "YOCTOADT_QEMU=\"N\""
echo -e "YOCTOADT_NFS_UTIL=\"N\""
echo -e "YOCTOADT_ROOTFS_${YOCTOADT_TARGETS}=\"${YOCTOADT_ROOTFS_arch}\""
echo -e "YOCTOADT_TARGET_SYSROOT_IMAGE_${YOCTOADT_TARGETS}=\"${YOCTOADT_TARGET_SYSROOT_IMAGE_arch}\""
echo -e "YOCTOADT_TARGET_MACHINE_${YOCTOADT_TARGETS}=\"${YOCTOADT_TARGET_MACHINE_arch}\""
echo -e "YOCTOADT_TARGET_SYSROOT_LOC_${YOCTOADT_TARGETS}=\"${YOCTOADT_TARGET_SYSROOT_LOC_arch}\"\n"
}
####################################
# print banner and --help option #
####################################
print_banner() {
echo -e ""
echo -e " ___ ____ ______ "
echo -e " / | / __ \/_ __/ _ ___________ _____ ____ ___ _____ "
echo -e " / /| | / / / / / / | | /| / / ___/ __ \/ __ \/ __ \/ _ \/ ___/ "
echo -e " / ___ |/ /_/ / / / | |/ |/ / / / /_/ / /_/ / /_/ / __/ / "
echo -e "/_/ |_/_____/ /_/ |__/|__/_/ \__,_/ .___/ .___/\___/_/ "
echo -e " /_/ /_/ "
echo -e "Yocto ADT wrapper script ${WRAPPER_VER}"
echo -e "To see all options, run with --help parameter or press Ctrl+C to Cancel"
sleep 5
}
#########################################################################################
# #
# MAIN FUNCTION #
#########################################################################################
if [[ $# -lt 1 ]]; then
print_banner
echo -e "running with default parameters"
process_parameters $@
write_adt_conf
export ADT_INSTALL_PATH=${INSTALL_DIR}
echo -e "${INSTALL_DIR} exported"
export SUDO=""
./${ADT_PATH}/adt_installer <<< "
${INSTALL_DIR}
S
"
else
echo -e "some parameters found... OK"
process_parameters $@
write_adt_conf
export ADT_INSTALL_PATH=${INSTALL_DIR}
echo -e "${INSTALL_DIR} exported"
export SUDO=""
./${ADT_PATH}/adt_installer <<< "
${INSTALL_DIR}
S
"
fi
exit $?