-
Notifications
You must be signed in to change notification settings - Fork 5
/
yoctoTizenInstall
executable file
·172 lines (151 loc) · 4.5 KB
/
yoctoTizenInstall
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
#!/bin/bash
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012-2013 Intel, Inc.
# License: GPLv2
# Authors: Ronan Le Martret <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2,
# as published by the Free Software Foundation.
#
# 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.
SCRIPT_DIR=$(dirname $0)
REBOOT_AFTER="no"
VERBOSE="yes"
SHOW_HELP="no"
DEPLOY_DIR=
CONFIG_FILE=${SCRIPT_DIR}/yoctoTizen_config
# If script have no yoctoTizen_config
if [ ! -e "${CONFIG_FILE}" ] ;then
cp "${SCRIPT_DIR}"/yoctoTizen_config_skeleton "${CONFIG_FILE}"
fi
source ${SCRIPT_DIR}/yoctoTizen_config
SSH_COMMAND="yes"
while test $# -gt 0; do
case $1 in
*-help)
SHOW_HELP="yes"
shift
;;
*-h)
SHOW_HELP="yes"
shift
;;
*-reboot_after)
REBOOT_AFTER="yes"
shift
;;
*-no_remote)
SSH_COMMAND=
shift
;;
*-image_src)
DEPLOY_DIR=$(dirname $2)
IMAGE_FILE=$2
shift
shift
;;
*-verbose)
VERBOSE=$2
shift
shift
;;
*-config)
CONFIG_FILE=$2
shift
shift
;;
*)
echo "Unknown parameter $1."
echo "This script is not accepting this parameter currently."
exit 1
;;
esac
done
# If script have no yoctoTizen_config
if [ ! -e "${CONFIG_FILE}" ] ;then
cp "${SCRIPT_DIR}"/yoctoTizen_config_skeleton "${CONFIG_FILE}"
fi
source ${CONFIG_FILE}
if [ "${SSH_COMMAND}" = "yes" ]; then
SSH_COMMAND="ssh ${REMOTE_USER}@${REMOTE_HOST} -- "
fi
if [ "${SHOW_HELP}" != "no" ]; then
echo "copy yocto image to partition"
echo " --help,-h show this help"
echo " --no_remote do not run this script to remote target"
echo " --image_src_dir use alternative directory source for image/kernel files"
echo " --reboot_after reboot target after copy"
echo " --verbose yes/no default yes"
echo " --config file_path use a external config file"
exit 0
fi
test_parameter() {
if [ -z "$2" ] ;then
echo The variable \"$1\" is empty please configure it.
echo Open file "${SCRIPT_DIR}"/yoctoTizen_config
exit 1
fi
}
if [ -z "${SSH_COMMAND}" ] ; then
test_parameter REMOTE_USER "${REMOTE_USER}"
test_parameter REMOTE_HOST "${REMOTE_HOST}"
fi
test_parameter WORKINGDIR "${WORKINGDIR}"
test_parameter BUILD_PRJ "${BUILD_PRJ}"
test_parameter MACHINE "${MACHINE}"
test_parameter IMAGE_NAME "${IMAGE_NAME}"
test_parameter YOCTO_PART "${YOCTO_PART}"
if [ -z "${DEPLOY_DIR}" ]; then
DEPLOY_DIR="${WORKINGDIR}/poky/${BUILD_PRJ}/tmp-glibc/deploy/images/${MACHINE}"
IMAGE_FILE="${DEPLOY_DIR}/${IMAGE_NAME}-${MACHINE}.ext3"
KERNEL_FILE="${DEPLOY_DIR}/bzImage"
else
if [ ! -d "${DEPLOY_DIR}" ]; then
echo \"${DEPLOY_DIR}\" is not a path directory.
exit 1
fi
KERNEL_FILE="${DEPLOY_DIR}/bzImage"
fi
if [ ! -f "${IMAGE_FILE}" ]; then
echo Can\'t find image file \"${IMAGE_FILE}\"
exit 1
fi
if [ ! -f "${KERNEL_FILE}" ]; then
echo Can\'t find kernel file \"${KERNEL_FILE}\"
exit 1
fi
if [ "${VERBOSE}" = "yes" ] ; then
echo IMAGE_FILE: "${IMAGE_FILE}"
echo KERNEL_FILE: "${KERNEL_FILE}"
set -x
fi
if [ ! -z "${SSH_COMMAND}" ]; then
${SSH_COMMAND} mkdir -p "${REMOTE_WORKINGDIR_DOWNLOADS}"
scp "${IMAGE_FILE}" "${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_WORKINGDIR_DOWNLOADS}"
scp "${KERNEL_FILE}" "${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_WORKINGDIR_DOWNLOADS}"
fi
if [ $(${SSH_COMMAND} id -u) != 0 ] ; then
echo You are not root, please run this script as root.
exit 1
fi
${SSH_COMMAND} rm -fr /${YOCTO_PART}/*
${SSH_COMMAND} mkdir -p /mnt/${YOCTO_PART}_EXT3
${SSH_COMMAND} mount "${REMOTE_WORKINGDIR_DOWNLOADS}/$(basename ${IMAGE_FILE})" /mnt/${YOCTO_PART}_EXT3
${SSH_COMMAND} cp -ar /mnt/${YOCTO_PART}_EXT3/* /${YOCTO_PART}
${SSH_COMMAND} umount /mnt/${YOCTO_PART}_EXT3
${SSH_COMMAND} cp -aL "${REMOTE_WORKINGDIR_DOWNLOADS}/bzImage" /boot/bzImage_yoctoTizen
${SSH_COMMAND} cp /etc/ssh/ssh_host_* /${YOCTO_PART}/etc/ssh/
${SSH_COMMAND} sync
${SSH_COMMAND} sync
if [ "${REBOOT_AFTER}" = "yes" ]; then
${SSH_COMMAND} sed -i s@next_entry=.*@next_entry="${REBOOT_ENTRY}"@ /boot/grub2/grubenv
${SSH_COMMAND} shutdown 0 --reboot
fi
if [ ${VERBOSE} = "yes" ] ; then
set +x
fi